Geant4-11
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;
140 fColour = rhs.fColour;
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.
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
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 if (force) {
186 fForceDrawingStyle = true;
188 } else {
189 fForceDrawingStyle = false;
190 }
191}
192
195 if (nPoints <= 0) {
196 G4cout <<
197 "G4VisAttributes::SetForceNumberOfCloudPoints: number of cloud points"
198 " set to " << fForcedNumberOfCloudPoints << '.' <<
199 "\n This means the viewer default will be used, typically controlled by"
200 "\n \"/vis/viewer/set/numberOfCloudPoints\""
201 << G4endl;
202 }
203}
204
207 fForcedAuxEdgeVisible = visibility;
208}
209
213 else return G4VisAttributes::wireframe;
214}
215
218 else return false;
219}
220
221const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const {
222 // Create an expendable copy on the heap...
223 return new std::vector<G4AttValue>(*fAttValues);
224}
225
227 const G4int nSegmentsMin = fMinLineSegmentsPerCircle;
228 if (nSegments > 0 && nSegments < nSegmentsMin) {
229 nSegments = nSegmentsMin;
230 G4cout <<
231 "G4VisAttributes::SetForcedLineSegmentsPerCircle: attempt to set the"
232 "\nnumber of line segments per circle < " << nSegmentsMin
233 << "; forced to " << nSegments << G4endl;
234 }
236}
237
238std::ostream& operator << (std::ostream& os, const G4VisAttributes& a)
239{
240 os << "G4VisAttributes: ";
241 if (!a.fVisible) os << "in";
242 os << "visible, daughters ";
243 if (a.fDaughtersInvisible) os << "in";
244 os << "visible, colour: " << a.fColour;
245 os << "\n linestyle: ";
246 switch (a.fLineStyle) {
248 os << "solid"; break;
250 os << "dashed"; break;
251 case G4VisAttributes::dotted: os << "dotted"; break;
252 default: os << "unrecognised"; break;
253 }
254 os << ", line width: " << a.fLineWidth;
255 os << ", min line segments per circle: " << a.GetMinLineSegmentsPerCircle();
256 os << "\n drawing style: ";
257 if (a.fForceDrawingStyle) {
258 os << "forced to ";
259 switch (a.fForcedStyle) {
261 os << "wireframe"; break;
263 os << "solid"; break;
264 default: os << "unrecognised"; break;
265 }
266 }
267 else {
268 os << "not forced";
269 }
270 os << ", auxiliary edge visibility: ";
271 if (a.fForceAuxEdgeVisible) {
272 os << "forced to ";
273 if (!a.fForcedAuxEdgeVisible) {
274 os << "not ";
275 }
276 os << "visible";
277 } else {
278 os << "not forced";
279 }
280 os << "\n line segments per circle: ";
282 os << "forced to " << a.fForcedLineSegmentsPerCircle;
283 } else {
284 os << "not forced.";
285 }
286 os << "\n time range: (" << a.fStartTime << ',' << a.fEndTime << ')';
287 os << "\n G4AttValue pointer is ";
288 if (a.fAttValues) {
289 os << "non-";
290 }
291 os << "zero";
292 os << ", G4AttDef pointer is ";
293 if (a.fAttDefs) {
294 os << "non-";
295 }
296 os << "zero";
297 return os;
298}
299
301
302 if (
303 (fVisible != a.fVisible) ||
305 (fColour != a.fColour) ||
306 (fLineStyle != a.fLineStyle) ||
307 (fLineWidth != a.fLineWidth) ||
311 (fStartTime != a.fStartTime) ||
312 (fEndTime != a.fEndTime) ||
313 (fAttValues != a.fAttValues) ||
314 (fAttDefs != a.fAttDefs)
315 )
316 return true;
317
318 if (fForceDrawingStyle) {
319 if (fForcedStyle != a.fForcedStyle) return true;
320 }
321
323 if (fForcedAuxEdgeVisible != a.fForcedAuxEdgeVisible) return true;
324 }
325
326 return false;
327}
328
331}
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const std::vector< G4AttValue > * fAttValues
void SetForceAuxEdgeVisible(G4bool=true)
void SetForceCloud(G4bool=true)
G4int fForcedLineSegmentsPerCircle
ForcedDrawingStyle fForcedStyle
void SetForceWireframe(G4bool=true)
const std::vector< G4AttValue > * CreateAttValues() const
static constexpr G4int fMinLineSegmentsPerCircle
G4bool IsForcedAuxEdgeVisible() const
G4int fForcedNumberOfCloudPoints
static const G4VisAttributes & GetInvisible()
G4bool operator!=(const G4VisAttributes &a) const
ForcedDrawingStyle GetForcedDrawingStyle() const
static G4int GetMinLineSegmentsPerCircle()
G4bool fForcedAuxEdgeVisible
const std::map< G4String, G4AttDef > * fAttDefs
void SetForceSolid(G4bool=true)
void SetForceLineSegmentsPerCircle(G4int nSegments)
G4VisAttributes & operator=(const G4VisAttributes &)
G4bool operator==(const G4VisAttributes &a) const
void SetForceNumberOfCloudPoints(G4int nPoints)
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)