Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
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 // $Id: G4VisAttributes.cc 110390 2018-05-22 08:28:07Z 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 (-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 fForceAuxEdgeVisible (false),
63 fForcedAuxEdgeVisible(false),
64 fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
65 fStartTime (-fVeryLongTime),
66 fEndTime (fVeryLongTime),
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 (-fVeryLongTime),
83 fEndTime (fVeryLongTime),
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 (-fVeryLongTime),
101 fEndTime (fVeryLongTime),
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 #ifndef WIN32
157 // Deprecated 14 July 2016 JA
159 #endif
160 
162  static const G4VisAttributes invisible = G4VisAttributes(false);
163  return invisible;
164 }
165 
167  if (force) {
168  fForceDrawingStyle = true;
170  } else {
171  fForceDrawingStyle = false;
172  }
173 }
174 
176  if (force) {
177  fForceDrawingStyle = true;
179  } else {
180  fForceDrawingStyle = false;
181  }
182 }
183 
185  fForceAuxEdgeVisible = true;
186  fForcedAuxEdgeVisible = visibility;
187 }
188 
191  if (fForceDrawingStyle) return fForcedStyle;
192  else return G4VisAttributes::wireframe;
193 }
194 
197  else return false;
198 }
199 
200 const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const {
201  // Create an expendable copy on the heap...
202  return new std::vector<G4AttValue>(*fAttValues);
203 }
204 
206  const G4int nSegmentsMin = fMinLineSegmentsPerCircle;
207  if (nSegments > 0 && nSegments < nSegmentsMin) {
208  nSegments = nSegmentsMin;
209  G4cout <<
210  "G4VisAttributes::SetForcedLineSegmentsPerCircle: attempt to set the"
211  "\nnumber of line segements per circle < " << nSegmentsMin
212  << "; forced to " << nSegments << G4endl;
213  }
214  fForcedLineSegmentsPerCircle = nSegments;
215 }
216 
217 std::ostream& operator << (std::ostream& os, const G4VisAttributes& a)
218 {
219  os << "G4VisAttributes: ";
220  if (!a.fVisible) os << "in";
221  os << "visible, daughters ";
222  if (a.fDaughtersInvisible) os << "in";
223  os << "visible, colour: " << a.fColour;
224  os << "\n linestyle: ";
225  switch (a.fLineStyle) {
227  os << "solid"; break;
229  os << "dashed"; break;
230  case G4VisAttributes::dotted: os << "dotted"; break;
231  default: os << "unrecognised"; break;
232  }
233  os << ", line width: " << a.fLineWidth;
234  os << ", min line segments per circle: " << a.GetMinLineSegmentsPerCircle();
235  os << "\n drawing style: ";
236  if (a.fForceDrawingStyle) {
237  os << "forced to ";
238  switch (a.fForcedStyle) {
240  os << "wireframe"; break;
242  os << "solid"; break;
243  default: os << "unrecognised"; break;
244  }
245  }
246  else {
247  os << "not forced";
248  }
249  os << ", auxiliary edge visibility: ";
250  if (a.fForceAuxEdgeVisible) {
251  os << "forced to ";
252  if (!a.fForcedAuxEdgeVisible) {
253  os << "not ";
254  }
255  os << "visible";
256  } else {
257  os << "not forced";
258  }
259  os << "\n line segments per circle: ";
260  if (a.fForcedLineSegmentsPerCircle > 0) {
261  os << "forced to " << a.fForcedLineSegmentsPerCircle;
262  } else {
263  os << "not forced.";
264  }
265  os << "\n time range: (" << a.fStartTime << ',' << a.fEndTime << ')';
266  os << "\n G4AttValue pointer is ";
267  if (a.fAttValues) {
268  os << "non-";
269  }
270  os << "zero";
271  os << ", G4AttDef pointer is ";
272  if (a.fAttDefs) {
273  os << "non-";
274  }
275  os << "zero";
276  return os;
277 }
278 
280 
281  if (
282  (fVisible != a.fVisible) ||
284  (fColour != a.fColour) ||
285  (fLineStyle != a.fLineStyle) ||
286  (fLineWidth != a.fLineWidth) ||
290  (fStartTime != a.fStartTime) ||
291  (fEndTime != a.fEndTime) ||
292  (fAttValues != a.fAttValues) ||
293  (fAttDefs != a.fAttDefs)
294  )
295  return true;
296 
297  if (fForceDrawingStyle) {
298  if (fForcedStyle != a.fForcedStyle) return true;
299  }
300 
301  if (fForceAuxEdgeVisible) {
302  if (fForcedAuxEdgeVisible != a.fForcedAuxEdgeVisible) return true;
303  }
304 
305  return false;
306 }
307 
309  return !(G4VisAttributes::operator != (a));
310 }
ForcedDrawingStyle fForcedStyle
void SetForceAuxEdgeVisible(G4bool=true)
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
#define G4endl
Definition: G4ios.hh:61
ForcedDrawingStyle GetForcedDrawingStyle() const
G4int fForcedLineSegmentsPerCircle
G4bool fForcedAuxEdgeVisible
static const G4VisAttributes & GetInvisible()
static G4int GetMinLineSegmentsPerCircle()
G4bool IsForcedAuxEdgeVisible() const
G4bool operator!=(const G4VisAttributes &a) const
void SetForceLineSegmentsPerCircle(G4int nSegments)
bool G4bool
Definition: G4Types.hh:79
const std::vector< G4AttValue > * CreateAttValues() const
static constexpr G4int fMinLineSegmentsPerCircle
const std::map< G4String, G4AttDef > * fAttDefs
G4bool operator==(const G4VisAttributes &a) const
G4VisAttributes & operator=(const G4VisAttributes &)
void SetForceSolid(G4bool=true)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
void SetForceWireframe(G4bool=true)
const std::vector< G4AttValue > * fAttValues
static const G4VisAttributes Invisible