Geant4  10.03
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 98730 2016-08-09 10:47:54Z 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 (true),
39 fDaughtersInvisible (false),
40 fColour (G4Colour ()),
41 fLineStyle (unbroken),
42 fLineWidth (1.),
43 fForceDrawingStyle (false),
44 fForcedStyle (wireframe),
45 fForceAuxEdgeVisible (false),
46 fForcedAuxEdgeVisible(false),
47 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
48 fStartTime (-DBL_MAX),
49 fEndTime (DBL_MAX),
50 fAttValues (0),
51 fAttDefs (0)
52 {}
53 
55 fVisible (visibility),
56 fDaughtersInvisible (false),
57 fColour (G4Colour ()),
58 fLineStyle (unbroken),
59 fLineWidth (1.),
60 fForceDrawingStyle (false),
61 fForcedStyle (wireframe),
62 fForceAuxEdgeVisible (false),
63 fForcedAuxEdgeVisible(false),
64 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
65 fStartTime (-DBL_MAX),
66 fEndTime (DBL_MAX),
67 fAttValues (0),
68 fAttDefs (0)
69 {}
70 
72 fVisible (true),
73 fDaughtersInvisible (false),
74 fColour (colour),
75 fLineStyle (unbroken),
76 fLineWidth (1.),
77 fForceDrawingStyle (false),
78 fForcedStyle (wireframe),
79 fForceAuxEdgeVisible (false),
80 fForcedAuxEdgeVisible(false),
81 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
82 fStartTime (-DBL_MAX),
83 fEndTime (DBL_MAX),
84 fAttValues (0),
85 fAttDefs (0)
86 {}
87 
89  const G4Colour& colour):
90 fVisible (visibility),
91 fDaughtersInvisible (false),
92 fColour (colour),
93 fLineStyle (unbroken),
94 fLineWidth (1.),
95 fForceDrawingStyle (false),
96 fForcedStyle (wireframe),
97 fForceAuxEdgeVisible (false),
98 fForcedAuxEdgeVisible(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 fVisible (va.fVisible),
108 fDaughtersInvisible (va.fDaughtersInvisible),
109 fColour (va.fColour),
110 fLineStyle (va.fLineStyle),
111 fLineWidth (va.fLineWidth),
112 fForceDrawingStyle (va.fForceDrawingStyle),
113 fForcedStyle (va.fForcedStyle),
114 fForceAuxEdgeVisible (va.fForceAuxEdgeVisible),
115 fForcedAuxEdgeVisible(va.fForcedAuxEdgeVisible),
116 fForcedLineSegmentsPerCircle (va.fForcedLineSegmentsPerCircle),
117 fStartTime (va.fStartTime),
118 fEndTime (va.fEndTime),
119 // AttValues are created afresh for each object (using the
120 // CreateAttValues message), but deletion is the responsibility of
121 // the creator. So just copy pointer.
122 fAttValues (va.fAttValues),
123 // AttDefs, if any, belong to the object from which they were obtained
124 // (with a GetAttDefs message), so just copy pointer.
125 fAttDefs (va.fAttDefs)
126 {}
127 
129 {}
130 
132 {
133  if (&rhs == this) return *this;
134  fVisible = rhs.fVisible;
136  fColour = rhs.fColour;
137  fLineStyle = rhs.fLineStyle;
138  fLineWidth = rhs.fLineWidth;
144  fStartTime = rhs.fStartTime;
145  fEndTime = rhs.fEndTime;
146  // AttValues are created afresh for each object (using the
147  // CreateAttValues message), but deletion is the responsibility of
148  // the creator. So just copy pointer.
149  fAttValues = rhs.fAttValues;
150  // AttDefs, if any, belong to the object from which they were obtained
151  // (with a GetAttDefs message), so just copy pointer.
152  fAttDefs = rhs.fAttDefs;
153  return *this;
154 }
155 
156 // Deprecated 14 July 2016 JA
158 
160  static const G4VisAttributes invisible = G4VisAttributes(false);
161  return invisible;
162 }
163 
165  if (force) {
166  fForceDrawingStyle = true;
168  } else {
169  fForceDrawingStyle = false;
170  }
171 }
172 
174  if (force) {
175  fForceDrawingStyle = true;
177  } else {
178  fForceDrawingStyle = false;
179  }
180 }
181 
183  fForceAuxEdgeVisible = true;
184  fForcedAuxEdgeVisible = visibility;
185 }
186 
189  if (fForceDrawingStyle) return fForcedStyle;
190  else return G4VisAttributes::wireframe;
191 }
192 
195  else return false;
196 }
197 
198 const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const {
199  // Create an expendable copy on the heap...
200  return new std::vector<G4AttValue>(*fAttValues);
201 }
202 
204  const G4int nSegmentsMin = fMinLineSegmentsPerCircle;
205  if (nSegments > 0 && nSegments < nSegmentsMin) {
206  nSegments = nSegmentsMin;
207  G4cout <<
208  "G4VisAttributes::SetForcedLineSegmentsPerCircle: attempt to set the"
209  "\nnumber of line segements per circle < " << nSegmentsMin
210  << "; forced to " << nSegments << G4endl;
211  }
212  fForcedLineSegmentsPerCircle = nSegments;
213 }
214 
215 std::ostream& operator << (std::ostream& os, const G4VisAttributes& a)
216 {
217  os << "G4VisAttributes: ";
218  if (!a.fVisible) os << "in";
219  os << "visible, daughters ";
220  if (a.fDaughtersInvisible) os << "in";
221  os << "visible, colour: " << a.fColour;
222  os << "\n linestyle: ";
223  switch (a.fLineStyle) {
225  os << "solid"; break;
227  os << "dashed"; break;
228  case G4VisAttributes::dotted: os << "dotted"; break;
229  default: os << "unrecognised"; break;
230  }
231  os << ", line width: " << a.fLineWidth;
232  os << ", min line segments per circle: " << a.GetMinLineSegmentsPerCircle();
233  os << "\n drawing style: ";
234  if (a.fForceDrawingStyle) {
235  os << "forced to ";
236  switch (a.fForcedStyle) {
238  os << "wireframe"; break;
240  os << "solid"; break;
241  default: os << "unrecognised"; break;
242  }
243  }
244  else {
245  os << "not forced";
246  }
247  os << ", auxiliary edge visibility: ";
248  if (a.fForceAuxEdgeVisible) {
249  os << "forced to ";
250  if (!a.fForcedAuxEdgeVisible) {
251  os << "not ";
252  }
253  os << "visible";
254  } else {
255  os << "not forced";
256  }
257  os << "\n line segments per circle: ";
258  if (a.fForcedLineSegmentsPerCircle > 0) {
259  os << "forced to " << a.fForcedLineSegmentsPerCircle;
260  } else {
261  os << "not forced.";
262  }
263  os << "\n time range: (" << a.fStartTime << ',' << a.fEndTime << ')';
264  os << "\n G4AttValue pointer is ";
265  if (a.fAttValues) {
266  os << "non-";
267  }
268  os << "zero";
269  os << ", G4AttDef pointer is ";
270  if (a.fAttDefs) {
271  os << "non-";
272  }
273  os << "zero";
274  return os;
275 }
276 
278 
279  if (
280  (fVisible != a.fVisible) ||
282  (fColour != a.fColour) ||
283  (fLineStyle != a.fLineStyle) ||
284  (fLineWidth != a.fLineWidth) ||
288  (fStartTime != a.fStartTime) ||
289  (fEndTime != a.fEndTime) ||
290  (fAttValues != a.fAttValues) ||
291  (fAttDefs != a.fAttDefs)
292  )
293  return true;
294 
295  if (fForceDrawingStyle) {
296  if (fForcedStyle != a.fForcedStyle) return true;
297  }
298 
299  if (fForceAuxEdgeVisible) {
300  if (fForcedAuxEdgeVisible != a.fForcedAuxEdgeVisible) return true;
301  }
302 
303  return false;
304 }
305 
307  return !(G4VisAttributes::operator != (a));
308 }
G4bool operator!=(const G4VisAttributes &a) const
const std::map< G4String, G4AttDef > * fAttDefs
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
std::ostream & operator<<(std::ostream &os, const G4VisAttributes &a)
int G4int
Definition: G4Types.hh:78
void SetForceSolid(G4bool=true)
ForcedDrawingStyle fForcedStyle
G4VisAttributes & operator=(const G4VisAttributes &)
G4GLOB_DLL std::ostream G4cout
static G4int GetMinLineSegmentsPerCircle()
G4bool fForcedAuxEdgeVisible
bool G4bool
Definition: G4Types.hh:79
G4bool IsForcedAuxEdgeVisible() const
const std::vector< G4AttValue > * fAttValues
const std::vector< G4AttValue > * CreateAttValues() const
static const G4VisAttributes Invisible
#define G4endl
Definition: G4ios.hh:61
void SetForceAuxEdgeVisible(G4bool=true)
G4int fForcedLineSegmentsPerCircle
#define DBL_MAX
Definition: templates.hh:83
static const G4VisAttributes & GetInvisible()
void SetForceWireframe(G4bool=true)
ForcedDrawingStyle GetForcedDrawingStyle() const
G4bool operator==(const G4VisAttributes &a) const
void SetForceLineSegmentsPerCircle(G4int nSegments)