source: trunk/source/graphics_reps/src/G4VisAttributes.cc@ 927

Last change on this file since 927 was 850, checked in by garnier, 17 years ago

geant4.8.2 beta

File size: 6.8 KB
Line 
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,v 1.16 2007/01/05 14:12:13 allison Exp $
28// GEANT4 tag $Name: HEAD $
29//
30//
31// John Allison 23rd October 1996
32
33#include "G4VisAttributes.hh"
34
35#include "G4AttValue.hh"
36
37G4VisAttributes::G4VisAttributes ():
38fVisible (true),
39fDaughtersInvisible (false),
40fColour (G4Colour ()),
41fLineStyle (unbroken),
42fLineWidth (1.),
43fForceDrawingStyle (false),
44fForceAuxEdgeVisible (false),
45fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
46fStartTime (-DBL_MAX),
47fEndTime (DBL_MAX),
48fAttValues (0),
49fAttDefs (0)
50{}
51
52G4VisAttributes::G4VisAttributes (G4bool visibility):
53fVisible (visibility),
54fDaughtersInvisible (false),
55fColour (G4Colour ()),
56fLineStyle (unbroken),
57fLineWidth (1.),
58fForceDrawingStyle (false),
59fForceAuxEdgeVisible (false),
60fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
61fStartTime (-DBL_MAX),
62fEndTime (DBL_MAX),
63fAttValues (0),
64fAttDefs (0)
65{}
66
67G4VisAttributes::G4VisAttributes (const G4Colour& colour):
68fVisible (true),
69fDaughtersInvisible (false),
70fColour (colour),
71fLineStyle (unbroken),
72fLineWidth (1.),
73fForceDrawingStyle (false),
74fForceAuxEdgeVisible (false),
75fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
76fStartTime (-DBL_MAX),
77fEndTime (DBL_MAX),
78fAttValues (0),
79fAttDefs (0)
80{}
81
82G4VisAttributes::G4VisAttributes (G4bool visibility,
83 const G4Colour& colour):
84fVisible (visibility),
85fDaughtersInvisible (false),
86fColour (colour),
87fLineStyle (unbroken),
88fLineWidth (1.),
89fForceDrawingStyle (false),
90fForcedLineSegmentsPerCircle (0), // <=0 means not forced.
91fStartTime (-DBL_MAX),
92fEndTime (DBL_MAX),
93fAttValues (0),
94fAttDefs (0)
95{}
96
97const G4VisAttributes G4VisAttributes::Invisible = G4VisAttributes (false);
98
99const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const {
100 // Create an expendable copy on the heap...
101 return new std::vector<G4AttValue>(*fAttValues);
102}
103
104void G4VisAttributes::SetForceLineSegmentsPerCircle (G4int nSegments) {
105 const G4int nSegmentsMin = 12;
106 if (nSegments > 0 && nSegments < nSegmentsMin) {
107 nSegments = nSegmentsMin;
108 G4cout <<
109 "G4VisAttributes::SetForcedLineSegmentsPerCircle: attempt to set the"
110 "\nnumber of line segements per circle < " << nSegmentsMin
111 << "; forced to " << nSegments << G4endl;
112 }
113 fForcedLineSegmentsPerCircle = nSegments;
114}
115
116std::ostream& operator << (std::ostream& os, const G4VisAttributes& a) {
117
118 os << "G4VisAttributes: ";
119 if (&a){
120 if (!a.fVisible) os << "in";
121 os << "visible, daughters ";
122 if (a.fDaughtersInvisible) os << "in";
123 os << "visible, colour: " << a.fColour;
124 os << "\n linestyle: ";
125 switch (a.fLineStyle) {
126 case G4VisAttributes::unbroken:
127 os << "solid"; break;
128 case G4VisAttributes::dashed:
129 os << "dashed"; break;
130 case G4VisAttributes::dotted: os << "dotted"; break;
131 default: os << "unrecognised"; break;
132 }
133 os << ", line width: " << a.fLineWidth;
134 os << "\n drawing style: ";
135 if (a.fForceDrawingStyle) {
136 os << "forced to: ";
137 switch (a.fForcedStyle) {
138 case G4VisAttributes::wireframe:
139 os << "wireframe"; break;
140 case G4VisAttributes::solid:
141 os << "solid"; break;
142 default: os << "unrecognised"; break;
143 }
144 }
145 else {
146 os << "not forced";
147 }
148 os << ", auxiliary edge visibility: ";
149 if (!a.fForceAuxEdgeVisible) {
150 os << "not ";
151 }
152 os << "forced";
153 os << "\n line segments per circle: ";
154 if (a.fForcedLineSegmentsPerCircle > 0) {
155 os << "forced to " << a.fForcedLineSegmentsPerCircle;
156 } else {
157 os << "not forced.";
158 }
159 os << "\n time range: (" << a.fStartTime << ',' << a.fEndTime << ')';
160 os << "\n G4AttValue pointer is ";
161 if (a.fAttValues) {
162 os << "non-";
163 }
164 os << "zero";
165 os << ", G4AttDef pointer is ";
166 if (a.fAttDefs) {
167 os << "non-";
168 }
169 os << "zero";
170 }
171 else os << " zero G4VisAttributes pointer";
172 return os;
173}
174
175G4bool G4VisAttributes::operator != (const G4VisAttributes& a) const {
176
177 if (
178 (fVisible != a.fVisible) ||
179 (fDaughtersInvisible != a.fDaughtersInvisible) ||
180 (fColour != a.fColour) ||
181 (fLineStyle != a.fLineStyle) ||
182 (fLineWidth != a.fLineWidth) ||
183 (fForceDrawingStyle != a.fForceDrawingStyle) ||
184 (fForceAuxEdgeVisible!= a.fForceAuxEdgeVisible)||
185 (fForcedLineSegmentsPerCircle != a.fForcedLineSegmentsPerCircle) ||
186 (fStartTime != a.fStartTime) ||
187 (fEndTime != a.fEndTime) ||
188 (fAttValues != a.fAttValues) ||
189 (fAttDefs != a.fAttDefs)
190 )
191 return true;
192
193 if (fForceDrawingStyle) {
194 if (fForcedStyle != a.fForcedStyle) return true;
195 }
196
197 return false;
198}
199
200G4bool G4VisAttributes::operator == (const G4VisAttributes& a) const {
201 return !(G4VisAttributes::operator != (a));
202}
Note: See TracBrowser for help on using the repository browser.