ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VisAttributes.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4VisAttributes.cc
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 //
28 //
29 // John Allison 23rd October 1996
30 
31 #include "G4VisAttributes.hh"
32 
33 #include "G4AttValue.hh"
34 #include "G4AttDef.hh"
35 
37 fVisible (true),
38 fDaughtersInvisible (false),
39 fColour (G4Colour ()),
40 fLineStyle (unbroken),
41 fLineWidth (1.),
42 fForceDrawingStyle (false),
43 fForcedStyle (wireframe),
44 fForcedNumberOfCloudPoints (10000),
45 fForceAuxEdgeVisible (false),
46 fForcedAuxEdgeVisible(false),
47 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
48 fStartTime (-fVeryLongTime),
49 fEndTime (fVeryLongTime),
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 fForcedNumberOfCloudPoints (10000),
63 fForceAuxEdgeVisible (false),
64 fForcedAuxEdgeVisible(false),
65 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
66 fStartTime (-fVeryLongTime),
67 fEndTime (fVeryLongTime),
68 fAttValues (0),
69 fAttDefs (0)
70 {}
71 
73 fVisible (true),
74 fDaughtersInvisible (false),
75 fColour (colour),
76 fLineStyle (unbroken),
77 fLineWidth (1.),
78 fForceDrawingStyle (false),
79 fForcedStyle (wireframe),
80 fForcedNumberOfCloudPoints (10000),
81 fForceAuxEdgeVisible (false),
82 fForcedAuxEdgeVisible(false),
83 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
84 fStartTime (-fVeryLongTime),
85 fEndTime (fVeryLongTime),
86 fAttValues (0),
87 fAttDefs (0)
88 {}
89 
91  const G4Colour& colour):
92 fVisible (visibility),
93 fDaughtersInvisible (false),
94 fColour (colour),
95 fLineStyle (unbroken),
96 fLineWidth (1.),
97 fForceDrawingStyle (false),
98 fForcedStyle (wireframe),
99 fForcedNumberOfCloudPoints (10000),
100 fForceAuxEdgeVisible (false),
101 fForcedAuxEdgeVisible(false),
102 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
103 fStartTime (-fVeryLongTime),
104 fEndTime (fVeryLongTime),
105 fAttValues (0),
106 fAttDefs (0)
107 {}
108 
110 fVisible (va.fVisible),
111 fDaughtersInvisible (va.fDaughtersInvisible),
112 fColour (va.fColour),
113 fLineStyle (va.fLineStyle),
114 fLineWidth (va.fLineWidth),
115 fForceDrawingStyle (va.fForceDrawingStyle),
116 fForcedStyle (va.fForcedStyle),
117 fForcedNumberOfCloudPoints (va.fForcedNumberOfCloudPoints),
118 fForceAuxEdgeVisible (va.fForceAuxEdgeVisible),
119 fForcedAuxEdgeVisible(va.fForcedAuxEdgeVisible),
120 fForcedLineSegmentsPerCircle (va.fForcedLineSegmentsPerCircle),
121 fStartTime (va.fStartTime),
122 fEndTime (va.fEndTime),
123 // AttValues are created afresh for each object (using the
124 // CreateAttValues message), but deletion is the responsibility of
125 // the creator. So just copy pointer.
126 fAttValues (va.fAttValues),
127 // AttDefs, if any, belong to the object from which they were obtained
128 // (with a GetAttDefs message), so just copy pointer.
129 fAttDefs (va.fAttDefs)
130 {}
131 
133 {}
134 
136 {
137  if (&rhs == this) return *this;
138  fVisible = rhs.fVisible;
140  fColour = rhs.fColour;
141  fLineStyle = rhs.fLineStyle;
142  fLineWidth = rhs.fLineWidth;
149  fStartTime = rhs.fStartTime;
150  fEndTime = rhs.fEndTime;
151  // AttValues are created afresh for each object (using the
152  // CreateAttValues message), but deletion is the responsibility of
153  // the creator. So just copy pointer.
154  fAttValues = rhs.fAttValues;
155  // AttDefs, if any, belong to the object from which they were obtained
156  // (with a GetAttDefs message), so just copy pointer.
157  fAttDefs = rhs.fAttDefs;
158  return *this;
159 }
160 
161 #ifndef WIN32
162 // Deprecated 14 July 2016 JA
164 #endif
165 
167  static const G4VisAttributes invisible = G4VisAttributes(false);
168  return invisible;
169 }
170 
172  if (force) {
173  fForceDrawingStyle = true;
175  } else {
176  fForceDrawingStyle = false;
177  }
178 }
179 
181  if (force) {
182  fForceDrawingStyle = true;
184  } else {
185  fForceDrawingStyle = false;
186  }
187 }
188 
190  if (force) {
191  fForceDrawingStyle = true;
193  } else {
194  fForceDrawingStyle = false;
195  }
196 }
197 
199  fForcedNumberOfCloudPoints = nPoints;
200  if (nPoints <= 0) {
201  G4cout <<
202  "G4VisAttributes::SetForceNumberOfCloudPoints: number of cloud points"
203  "set to " << fForcedNumberOfCloudPoints
204  << ". This means the viewer default will be used."
205  << G4endl;
206  }
207 }
208 
210  fForceAuxEdgeVisible = true;
212 }
213 
216  if (fForceDrawingStyle) return fForcedStyle;
217  else return G4VisAttributes::wireframe;
218 }
219 
222  else return false;
223 }
224 
225 const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const {
226  // Create an expendable copy on the heap...
227  return new std::vector<G4AttValue>(*fAttValues);
228 }
229 
231  const G4int nSegmentsMin = fMinLineSegmentsPerCircle;
232  if (nSegments > 0 && nSegments < nSegmentsMin) {
233  nSegments = nSegmentsMin;
234  G4cout <<
235  "G4VisAttributes::SetForcedLineSegmentsPerCircle: attempt to set the"
236  "\nnumber of line segements per circle < " << nSegmentsMin
237  << "; forced to " << nSegments << G4endl;
238  }
239  fForcedLineSegmentsPerCircle = nSegments;
240 }
241 
242 std::ostream& operator << (std::ostream& os, const G4VisAttributes& a)
243 {
244  os << "G4VisAttributes: ";
245  if (!a.fVisible) os << "in";
246  os << "visible, daughters ";
247  if (a.fDaughtersInvisible) os << "in";
248  os << "visible, colour: " << a.fColour;
249  os << "\n linestyle: ";
250  switch (a.fLineStyle) {
252  os << "solid"; break;
254  os << "dashed"; break;
255  case G4VisAttributes::dotted: os << "dotted"; break;
256  default: os << "unrecognised"; break;
257  }
258  os << ", line width: " << a.fLineWidth;
259  os << ", min line segments per circle: " << a.GetMinLineSegmentsPerCircle();
260  os << "\n drawing style: ";
261  if (a.fForceDrawingStyle) {
262  os << "forced to ";
263  switch (a.fForcedStyle) {
265  os << "wireframe"; break;
267  os << "solid"; break;
268  default: os << "unrecognised"; break;
269  }
270  }
271  else {
272  os << "not forced";
273  }
274  os << ", auxiliary edge visibility: ";
275  if (a.fForceAuxEdgeVisible) {
276  os << "forced to ";
277  if (!a.fForcedAuxEdgeVisible) {
278  os << "not ";
279  }
280  os << "visible";
281  } else {
282  os << "not forced";
283  }
284  os << "\n line segments per circle: ";
285  if (a.fForcedLineSegmentsPerCircle > 0) {
286  os << "forced to " << a.fForcedLineSegmentsPerCircle;
287  } else {
288  os << "not forced.";
289  }
290  os << "\n time range: (" << a.fStartTime << ',' << a.fEndTime << ')';
291  os << "\n G4AttValue pointer is ";
292  if (a.fAttValues) {
293  os << "non-";
294  }
295  os << "zero";
296  os << ", G4AttDef pointer is ";
297  if (a.fAttDefs) {
298  os << "non-";
299  }
300  os << "zero";
301  return os;
302 }
303 
305 
306  if (
307  (fVisible != a.fVisible) ||
309  (fColour != a.fColour) ||
310  (fLineStyle != a.fLineStyle) ||
311  (fLineWidth != a.fLineWidth) ||
315  (fStartTime != a.fStartTime) ||
316  (fEndTime != a.fEndTime) ||
317  (fAttValues != a.fAttValues) ||
318  (fAttDefs != a.fAttDefs)
319  )
320  return true;
321 
322  if (fForceDrawingStyle) {
323  if (fForcedStyle != a.fForcedStyle) return true;
324  }
325 
326  if (fForceAuxEdgeVisible) {
327  if (fForcedAuxEdgeVisible != a.fForcedAuxEdgeVisible) return true;
328  }
329 
330  return false;
331 }
332 
334  return !(G4VisAttributes::operator != (a));
335 }