Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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//
28//
29// John Allison 23rd October 1996
30
31#include "G4VisAttributes.hh"
32
33#include "G4AttValue.hh"
34#include "G4AttDef.hh"
35
37fVisible (true),
38fDaughtersInvisible (false),
39fColour (G4Colour ()),
40fLineStyle (unbroken),
41fLineWidth (1.),
42fForceDrawingStyle (false),
43fForcedStyle (wireframe),
44fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer
45fForceAuxEdgeVisible (false),
46fForcedAuxEdgeVisible(false),
47fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
48fStartTime (-fVeryLongTime),
49fEndTime (fVeryLongTime),
50fAttValues (0),
51fAttDefs (0)
52{}
53
55fVisible (visibility),
56fDaughtersInvisible (false),
57fColour (G4Colour ()),
58fLineStyle (unbroken),
59fLineWidth (1.),
60fForceDrawingStyle (false),
61fForcedStyle (wireframe),
62fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer
63fForceAuxEdgeVisible (false),
64fForcedAuxEdgeVisible(false),
65fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
66fStartTime (-fVeryLongTime),
67fEndTime (fVeryLongTime),
68fAttValues (0),
69fAttDefs (0)
70{}
71
73fVisible (true),
74fDaughtersInvisible (false),
75fColour (colour),
76fLineStyle (unbroken),
77fLineWidth (1.),
78fForceDrawingStyle (false),
79fForcedStyle (wireframe),
80fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer
81fForceAuxEdgeVisible (false),
82fForcedAuxEdgeVisible(false),
83fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
84fStartTime (-fVeryLongTime),
85fEndTime (fVeryLongTime),
86fAttValues (0),
87fAttDefs (0)
88{}
89
91 const G4Colour& colour):
92fVisible (visibility),
93fDaughtersInvisible (false),
94fColour (colour),
95fLineStyle (unbroken),
96fLineWidth (1.),
97fForceDrawingStyle (false),
98fForcedStyle (wireframe),
99fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer
100fForceAuxEdgeVisible (false),
101fForcedAuxEdgeVisible(false),
102fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
103fStartTime (-fVeryLongTime),
104fEndTime (fVeryLongTime),
105fAttValues (0),
106fAttDefs (0)
107{}
108
110fVisible (va.fVisible),
111fDaughtersInvisible (va.fDaughtersInvisible),
112fColour (va.fColour),
113fLineStyle (va.fLineStyle),
114fLineWidth (va.fLineWidth),
115fForceDrawingStyle (va.fForceDrawingStyle),
116fForcedStyle (va.fForcedStyle),
117fForcedNumberOfCloudPoints (va.fForcedNumberOfCloudPoints),
118fForceAuxEdgeVisible (va.fForceAuxEdgeVisible),
119fForcedAuxEdgeVisible(va.fForcedAuxEdgeVisible),
120fForcedLineSegmentsPerCircle (va.fForcedLineSegmentsPerCircle),
121fStartTime (va.fStartTime),
122fEndTime (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.
126fAttValues (va.fAttValues),
127// AttDefs, if any, belong to the object from which they were obtained
128// (with a GetAttDefs message), so just copy pointer.
129fAttDefs (va.fAttDefs)
130{}
131
133{}
134
136{
137 if (&rhs == this) return *this;
138 fVisible = rhs.fVisible;
139 fDaughtersInvisible = rhs.fDaughtersInvisible;
140 fColour = rhs.fColour;
141 fLineStyle = rhs.fLineStyle;
142 fLineWidth = rhs.fLineWidth;
143 fForceDrawingStyle = rhs.fForceDrawingStyle;
144 fForcedStyle = rhs.fForcedStyle;
145 fForcedNumberOfCloudPoints = rhs.fForcedNumberOfCloudPoints;
146 fForceAuxEdgeVisible = rhs.fForceAuxEdgeVisible;
147 fForcedAuxEdgeVisible = rhs.fForcedAuxEdgeVisible;
148 fForcedLineSegmentsPerCircle = rhs.fForcedLineSegmentsPerCircle;
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;
174 fForcedStyle = G4VisAttributes::wireframe;
175 } else {
176 fForceDrawingStyle = false;
177 }
178}
179
181 if (force) {
182 fForceDrawingStyle = true;
183 fForcedStyle = G4VisAttributes::solid;
184 } else {
185 fForceDrawingStyle = false;
186 }
187}
188
190 if (force) {
191 fForceDrawingStyle = true;
192 fForcedStyle = G4VisAttributes::cloud;
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;
211 fForcedAuxEdgeVisible = visibility;
212}
213
216 if (fForceDrawingStyle) return fForcedStyle;
217 else return G4VisAttributes::wireframe;
218}
219
221 if (fForceAuxEdgeVisible) return fForcedAuxEdgeVisible;
222 else return false;
223}
224
225const 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 segments per circle < " << nSegmentsMin
237 << "; forced to " << nSegments << G4endl;
238 }
239 fForcedLineSegmentsPerCircle = nSegments;
240}
241
242std::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) ||
308 (fDaughtersInvisible != a.fDaughtersInvisible) ||
309 (fColour != a.fColour) ||
310 (fLineStyle != a.fLineStyle) ||
311 (fLineWidth != a.fLineWidth) ||
312 (fForceDrawingStyle != a.fForceDrawingStyle) ||
313 (fForceAuxEdgeVisible!= a.fForceAuxEdgeVisible) ||
314 (fForcedLineSegmentsPerCircle != a.fForcedLineSegmentsPerCircle) ||
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
335}
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
std::ostream & operator<<(std::ostream &os, const G4VisAttributes &a)
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void SetForceAuxEdgeVisible(G4bool=true)
void SetForceCloud(G4bool=true)
void SetForceWireframe(G4bool=true)
const std::vector< G4AttValue > * CreateAttValues() const
static constexpr G4int fMinLineSegmentsPerCircle
G4bool IsForcedAuxEdgeVisible() const
static const G4VisAttributes & GetInvisible()
G4bool operator!=(const G4VisAttributes &a) const
ForcedDrawingStyle GetForcedDrawingStyle() const
static G4int GetMinLineSegmentsPerCircle()
void SetForceSolid(G4bool=true)
void SetForceLineSegmentsPerCircle(G4int nSegments)
G4VisAttributes & operator=(const G4VisAttributes &)
static const G4VisAttributes Invisible
G4bool operator==(const G4VisAttributes &a) const
void SetForceNumberOfCloudPoints(G4int nPoints)