Geant4  10.01
G4VisAttributes.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4VisAttributes.cc 85261 2014-10-27 08:54:57Z gcosmo $
28 //
29 //
30 // John Allison 23rd October 1996
31 
32 #include "G4VisAttributes.hh"
33 
34 #include "G4AttValue.hh"
35 #include "G4AttDef.hh"
36 
38 fVisible (va.fVisible),
39 fDaughtersInvisible (va.fDaughtersInvisible),
40 fColour (va.fColour),
41 fLineStyle (va.fLineStyle),
42 fLineWidth (va.fLineWidth),
43 fForceDrawingStyle (va.fForceDrawingStyle),
44 fForcedStyle (va.fForcedStyle),
45 fForceAuxEdgeVisible (va.fForceAuxEdgeVisible),
46 fForcedLineSegmentsPerCircle (va.fForcedLineSegmentsPerCircle),
47 fStartTime (va.fStartTime),
48 fEndTime (va.fEndTime),
49 // AttValues are created afresh for each object (using the
50 // CreateAttValues message), but deletion is the responsibility of
51 // the creator. So just copy pointer.
52 fAttValues (va.fAttValues),
53 // AttDefs, if any, belong to the object from which they were obtained
54 // (with a GetAttDefs message), so just copy pointer.
55 fAttDefs (va.fAttDefs)
56 {}
57 
59 fVisible (true),
60 fDaughtersInvisible (false),
61 fColour (G4Colour ()),
62 fLineStyle (unbroken),
63 fLineWidth (1.),
64 fForceDrawingStyle (false),
65 fForcedStyle (wireframe),
66 fForceAuxEdgeVisible (false),
67 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
68 fStartTime (-DBL_MAX),
69 fEndTime (DBL_MAX),
70 fAttValues (0),
71 fAttDefs (0)
72 {}
73 
75 fVisible (visibility),
76 fDaughtersInvisible (false),
77 fColour (G4Colour ()),
78 fLineStyle (unbroken),
79 fLineWidth (1.),
80 fForceDrawingStyle (false),
81 fForcedStyle (wireframe),
82 fForceAuxEdgeVisible (false),
83 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
84 fStartTime (-DBL_MAX),
85 fEndTime (DBL_MAX),
86 fAttValues (0),
87 fAttDefs (0)
88 {}
89 
91 fVisible (true),
92 fDaughtersInvisible (false),
93 fColour (colour),
94 fLineStyle (unbroken),
95 fLineWidth (1.),
96 fForceDrawingStyle (false),
97 fForcedStyle (wireframe),
98 fForceAuxEdgeVisible (false),
99 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
100 fStartTime (-DBL_MAX),
101 fEndTime (DBL_MAX),
102 fAttValues (0),
103 fAttDefs (0)
104 {}
105 
107  const G4Colour& colour):
108 fVisible (visibility),
109 fDaughtersInvisible (false),
110 fColour (colour),
111 fLineStyle (unbroken),
112 fLineWidth (1.),
113 fForceDrawingStyle (false),
114 fForcedStyle (wireframe),
115 fForceAuxEdgeVisible (false),
116 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
117 fStartTime (-DBL_MAX),
118 fEndTime (DBL_MAX),
119 fAttValues (0),
120 fAttDefs (0)
121 {}
122 
124 {
125 }
126 
128 {
129  if (&rhs == this) return *this;
130  fVisible = rhs.fVisible;
132  fColour = rhs.fColour;
133  fLineStyle = rhs.fLineStyle;
134  fLineWidth = rhs.fLineWidth;
139  fStartTime = rhs.fStartTime;
140  fEndTime = rhs.fEndTime;
141  // AttValues are created afresh for each object (using the
142  // CreateAttValues message), but deletion is the responsibility of
143  // the creator. So just copy pointer.
144  fAttValues = rhs.fAttValues;
145  // AttDefs, if any, belong to the object from which they were obtained
146  // (with a GetAttDefs message), so just copy pointer.
147  fAttDefs = rhs.fAttDefs;
148  return *this;
149 }
150 
152 
153 const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const {
154  // Create an expendable copy on the heap...
155  return new std::vector<G4AttValue>(*fAttValues);
156 }
157 
159  const G4int nSegmentsMin = fMinLineSegmentsPerCircle;
160  if (nSegments > 0 && nSegments < nSegmentsMin) {
161  nSegments = nSegmentsMin;
162  G4cout <<
163  "G4VisAttributes::SetForcedLineSegmentsPerCircle: attempt to set the"
164  "\nnumber of line segements per circle < " << nSegmentsMin
165  << "; forced to " << nSegments << G4endl;
166  }
167  fForcedLineSegmentsPerCircle = nSegments;
168 }
169 
170 std::ostream& operator << (std::ostream& os, const G4VisAttributes& a) {
171 
172  os << "G4VisAttributes: ";
173  if (&a){
174  if (!a.fVisible) os << "in";
175  os << "visible, daughters ";
176  if (a.fDaughtersInvisible) os << "in";
177  os << "visible, colour: " << a.fColour;
178  os << "\n linestyle: ";
179  switch (a.fLineStyle) {
181  os << "solid"; break;
183  os << "dashed"; break;
184  case G4VisAttributes::dotted: os << "dotted"; break;
185  default: os << "unrecognised"; break;
186  }
187  os << ", line width: " << a.fLineWidth;
188  os << ", min line segments per circle: " << a.GetMinLineSegmentsPerCircle();
189  os << "\n drawing style: ";
190  if (a.fForceDrawingStyle) {
191  os << "forced to: ";
192  switch (a.fForcedStyle) {
194  os << "wireframe"; break;
196  os << "solid"; break;
197  default: os << "unrecognised"; break;
198  }
199  }
200  else {
201  os << "not forced";
202  }
203  os << ", auxiliary edge visibility: ";
204  if (!a.fForceAuxEdgeVisible) {
205  os << "not ";
206  }
207  os << "forced";
208  os << "\n line segments per circle: ";
209  if (a.fForcedLineSegmentsPerCircle > 0) {
210  os << "forced to " << a.fForcedLineSegmentsPerCircle;
211  } else {
212  os << "not forced.";
213  }
214  os << "\n time range: (" << a.fStartTime << ',' << a.fEndTime << ')';
215  os << "\n G4AttValue pointer is ";
216  if (a.fAttValues) {
217  os << "non-";
218  }
219  os << "zero";
220  os << ", G4AttDef pointer is ";
221  if (a.fAttDefs) {
222  os << "non-";
223  }
224  os << "zero";
225  }
226  else os << " zero G4VisAttributes pointer";
227  return os;
228 }
229 
231 
232  if (
233  (fVisible != a.fVisible) ||
235  (fColour != a.fColour) ||
236  (fLineStyle != a.fLineStyle) ||
237  (fLineWidth != a.fLineWidth) ||
241  (fStartTime != a.fStartTime) ||
242  (fEndTime != a.fEndTime) ||
243  (fAttValues != a.fAttValues) ||
244  (fAttDefs != a.fAttDefs)
245  )
246  return true;
247 
248  if (fForceDrawingStyle) {
249  if (fForcedStyle != a.fForcedStyle) return true;
250  }
251 
252  return false;
253 }
254 
256  return !(G4VisAttributes::operator != (a));
257 }
G4bool operator!=(const G4VisAttributes &a) const
const std::map< G4String, G4AttDef > * fAttDefs
std::ostream & operator<<(std::ostream &os, const G4VisAttributes &a)
G4double a
Definition: TRTMaterials.hh:39
int G4int
Definition: G4Types.hh:78
ForcedDrawingStyle fForcedStyle
G4VisAttributes & operator=(const G4VisAttributes &)
G4GLOB_DLL std::ostream G4cout
static G4int GetMinLineSegmentsPerCircle()
bool G4bool
Definition: G4Types.hh:79
const std::vector< G4AttValue > * fAttValues
const std::vector< G4AttValue > * CreateAttValues() const
static const G4VisAttributes Invisible
#define G4endl
Definition: G4ios.hh:61
G4int fForcedLineSegmentsPerCircle
#define DBL_MAX
Definition: templates.hh:83
G4bool operator==(const G4VisAttributes &a) const
void SetForceLineSegmentsPerCircle(G4int nSegments)