Geant4 11.2.2
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),
39fLineStyle (unbroken),
40fLineWidth (1.),
41fForceDrawingStyle (false),
42fForcedStyle (wireframe),
43fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer
44fForceAuxEdgeVisible (false),
45fForcedAuxEdgeVisible(false),
46fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
47fStartTime (-fVeryLongTime),
48fEndTime (fVeryLongTime),
49fAttValues (nullptr),
50fAttDefs (nullptr)
51{}
52
54fVisible (visibility),
55fDaughtersInvisible (false),
56
57fLineStyle (unbroken),
58fLineWidth (1.),
59fForceDrawingStyle (false),
60fForcedStyle (wireframe),
61fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer
62fForceAuxEdgeVisible (false),
63fForcedAuxEdgeVisible(false),
64fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
65fStartTime (-fVeryLongTime),
66fEndTime (fVeryLongTime),
67fAttValues (nullptr),
68fAttDefs (nullptr)
69{}
70
72fVisible (true),
73fDaughtersInvisible (false),
74fColour (colour),
75fLineStyle (unbroken),
76fLineWidth (1.),
77fForceDrawingStyle (false),
78fForcedStyle (wireframe),
79fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer
80fForceAuxEdgeVisible (false),
81fForcedAuxEdgeVisible(false),
82fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
83fStartTime (-fVeryLongTime),
84fEndTime (fVeryLongTime),
85fAttValues (nullptr),
86fAttDefs (nullptr)
87{}
88
90 const G4Colour& colour):
91fVisible (visibility),
92fDaughtersInvisible (false),
93fColour (colour),
94fLineStyle (unbroken),
95fLineWidth (1.),
96fForceDrawingStyle (false),
97fForcedStyle (wireframe),
98fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer
99fForceAuxEdgeVisible (false),
100fForcedAuxEdgeVisible(false),
101fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
102fStartTime (-fVeryLongTime),
103fEndTime (fVeryLongTime),
104fAttValues (nullptr),
105fAttDefs (nullptr)
106{}
107
108
110{
111 if (&rhs == this) return *this;
112 fVisible = rhs.fVisible;
113 fDaughtersInvisible = rhs.fDaughtersInvisible;
114 fColour = rhs.fColour;
115 fLineStyle = rhs.fLineStyle;
116 fLineWidth = rhs.fLineWidth;
117 fForceDrawingStyle = rhs.fForceDrawingStyle;
118 fForcedStyle = rhs.fForcedStyle;
119 fForcedNumberOfCloudPoints = rhs.fForcedNumberOfCloudPoints;
120 fForceAuxEdgeVisible = rhs.fForceAuxEdgeVisible;
121 fForcedAuxEdgeVisible = rhs.fForcedAuxEdgeVisible;
122 fForcedLineSegmentsPerCircle = rhs.fForcedLineSegmentsPerCircle;
123 fStartTime = rhs.fStartTime;
124 fEndTime = rhs.fEndTime;
125 // AttValues are created afresh for each object (using the
126 // CreateAttValues message), but deletion is the responsibility of
127 // the creator. So just copy pointer.
128 fAttValues = rhs.fAttValues;
129 // AttDefs, if any, belong to the object from which they were obtained
130 // (with a GetAttDefs message), so just copy pointer.
131 fAttDefs = rhs.fAttDefs;
132 return *this;
133}
134
136 static const G4VisAttributes invisible = G4VisAttributes(false);
137 return invisible;
138}
139
141 if (force) {
142 fForceDrawingStyle = true;
143 fForcedStyle = G4VisAttributes::wireframe;
144 } else {
145 fForceDrawingStyle = false;
146 }
147}
148
150 if (force) {
151 fForceDrawingStyle = true;
152 fForcedStyle = G4VisAttributes::solid;
153 } else {
154 fForceDrawingStyle = false;
155 }
156}
157
159 if (force) {
160 fForceDrawingStyle = true;
161 fForcedStyle = G4VisAttributes::cloud;
162 } else {
163 fForceDrawingStyle = false;
164 }
165}
166
168 fForcedNumberOfCloudPoints = nPoints;
169 if (nPoints <= 0) {
170 G4cout <<
171 "G4VisAttributes::SetForceNumberOfCloudPoints: number of cloud points"
172 " set to " << fForcedNumberOfCloudPoints << '.' <<
173 "\n This means the viewer default will be used, typically controlled by"
174 "\n \"/vis/viewer/set/numberOfCloudPoints\""
175 << G4endl;
176 }
177}
178
180 fForceAuxEdgeVisible = true;
181 fForcedAuxEdgeVisible = visibility;
182}
183
186 if (fForceDrawingStyle) return fForcedStyle;
188}
189
191 if (fForceAuxEdgeVisible) return fForcedAuxEdgeVisible;
192 return false;
193}
194
195const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const {
196 // Create an expendable copy on the heap...
197 return new std::vector<G4AttValue>(*fAttValues);
198}
199
201 const G4int nSegmentsMin = fMinLineSegmentsPerCircle;
202 if (nSegments < nSegmentsMin) {
203 nSegments = nSegmentsMin;
204 G4cout <<
205 "G4VisAttributes::SetForcedLineSegmentsPerCircle: attempt to set the"
206 "\nnumber of line segments per circle < " << nSegmentsMin
207 << "; forced to " << nSegments << G4endl;
208 }
209 fForcedLineSegmentsPerCircle = nSegments;
210}
211
212std::ostream& operator << (std::ostream& os, const G4VisAttributes& a)
213{
214 os << std::defaultfloat;
215 os << "G4VisAttributes: ";
216 if (!a.fVisible) os << "in";
217 os << "visible, daughters ";
218 if (a.fDaughtersInvisible) os << "in";
219 os << "visible, colour: " << a.fColour;
220 os << "\n linestyle: ";
221 switch (a.fLineStyle) {
223 os << "solid"; break;
225 os << "dashed"; break;
226 case G4VisAttributes::dotted: os << "dotted"; break;
227 default: os << "unrecognised"; break;
228 }
229 os << ", line width: " << a.fLineWidth;
230 os << ", min line segments per circle: " << a.GetMinLineSegmentsPerCircle();
231 os << "\n drawing style: ";
232 if (a.fForceDrawingStyle) {
233 os << "forced to ";
234 switch (a.fForcedStyle) {
236 os << "wireframe"; break;
238 os << "solid"; break;
239 default: os << "unrecognised"; break;
240 }
241 }
242 else {
243 os << "not forced";
244 }
245 os << ", auxiliary edge visibility: ";
246 if (a.fForceAuxEdgeVisible) {
247 os << "forced to ";
248 if (!a.fForcedAuxEdgeVisible) {
249 os << "not ";
250 }
251 os << "visible";
252 } else {
253 os << "not forced";
254 }
255 os << "\n line segments per circle: ";
256 if (a.fForcedLineSegmentsPerCircle > 0) {
257 os << "forced to " << a.fForcedLineSegmentsPerCircle;
258 } else {
259 os << "not forced.";
260 }
261 os << "\n time range: (" << a.fStartTime << ',' << a.fEndTime << ')';
262 os << "\n G4AttValue pointer is ";
263 if (a.fAttValues != nullptr) {
264 os << "non-";
265 }
266 os << "zero";
267 os << ", G4AttDef pointer is ";
268 if (a.fAttDefs != nullptr) {
269 os << "non-";
270 }
271 os << "zero";
272 return os;
273}
274
276
277 if (
278 (fVisible != a.fVisible) ||
279 (fDaughtersInvisible != a.fDaughtersInvisible) ||
280 (fColour != a.fColour) ||
281 (fLineStyle != a.fLineStyle) ||
282 (fLineWidth != a.fLineWidth) ||
283 (fForceDrawingStyle != a.fForceDrawingStyle) ||
284 (fForceAuxEdgeVisible!= a.fForceAuxEdgeVisible) ||
285 (fForcedLineSegmentsPerCircle != a.fForcedLineSegmentsPerCircle) ||
286 (fStartTime != a.fStartTime) ||
287 (fEndTime != a.fEndTime) ||
288 (fAttValues != a.fAttValues) ||
289 (fAttDefs != a.fAttDefs)
290 )
291 return true;
292
293 if (fForceDrawingStyle) {
294 if (fForcedStyle != a.fForcedStyle) return true;
295 }
296
297 if (fForceAuxEdgeVisible) {
298 if (fForcedAuxEdgeVisible != a.fForcedAuxEdgeVisible) return true;
299 }
300
301 return false;
302}
303
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:67
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 &)
G4bool operator==(const G4VisAttributes &a) const
void SetForceNumberOfCloudPoints(G4int nPoints)