Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // >> 27 // $Id: G4VisAttributes.cc,v 1.17 2010-12-07 09:36:59 allison Exp $ >> 28 // GEANT4 tag $Name: not supported by cvs2svn $ 27 // 29 // 28 // 30 // 29 // John Allison 23rd October 1996 31 // John Allison 23rd October 1996 30 32 31 #include "G4VisAttributes.hh" 33 #include "G4VisAttributes.hh" 32 34 33 #include "G4AttValue.hh" 35 #include "G4AttValue.hh" 34 #include "G4AttDef.hh" << 35 36 36 G4VisAttributes::G4VisAttributes (): 37 G4VisAttributes::G4VisAttributes (): 37 fVisible (true), 38 fVisible (true), 38 fDaughtersInvisible (false), 39 fDaughtersInvisible (false), >> 40 fColour (G4Colour ()), 39 fLineStyle (unbroken), 41 fLineStyle (unbroken), 40 fLineWidth (1.), 42 fLineWidth (1.), 41 fForceDrawingStyle (false), 43 fForceDrawingStyle (false), 42 fForcedStyle (wireframe), 44 fForcedStyle (wireframe), 43 fForcedNumberOfCloudPoints (0), // <= 0 means << 44 fForceAuxEdgeVisible (false), 45 fForceAuxEdgeVisible (false), 45 fForcedAuxEdgeVisible(false), << 46 fForcedLineSegmentsPerCircle (0), // <=0 mean 46 fForcedLineSegmentsPerCircle (0), // <=0 means not forced. 47 fStartTime (-fVeryLongTime), << 47 fStartTime (-DBL_MAX), 48 fEndTime (fVeryLongTime), << 48 fEndTime (DBL_MAX), 49 fAttValues (nullptr), << 49 fAttValues (0), 50 fAttDefs (nullptr) << 50 fAttDefs (0) 51 {} 51 {} 52 52 53 G4VisAttributes::G4VisAttributes (G4bool visib 53 G4VisAttributes::G4VisAttributes (G4bool visibility): 54 fVisible (visibility), 54 fVisible (visibility), 55 fDaughtersInvisible (false), 55 fDaughtersInvisible (false), 56 << 56 fColour (G4Colour ()), 57 fLineStyle (unbroken), 57 fLineStyle (unbroken), 58 fLineWidth (1.), 58 fLineWidth (1.), 59 fForceDrawingStyle (false), 59 fForceDrawingStyle (false), 60 fForcedStyle (wireframe), 60 fForcedStyle (wireframe), 61 fForcedNumberOfCloudPoints (0), // <= 0 means << 62 fForceAuxEdgeVisible (false), 61 fForceAuxEdgeVisible (false), 63 fForcedAuxEdgeVisible(false), << 64 fForcedLineSegmentsPerCircle (0), // <=0 mean 62 fForcedLineSegmentsPerCircle (0), // <=0 means not forced. 65 fStartTime (-fVeryLongTime), << 63 fStartTime (-DBL_MAX), 66 fEndTime (fVeryLongTime), << 64 fEndTime (DBL_MAX), 67 fAttValues (nullptr), << 65 fAttValues (0), 68 fAttDefs (nullptr) << 66 fAttDefs (0) 69 {} 67 {} 70 68 71 G4VisAttributes::G4VisAttributes (const G4Colo 69 G4VisAttributes::G4VisAttributes (const G4Colour& colour): 72 fVisible (true), 70 fVisible (true), 73 fDaughtersInvisible (false), 71 fDaughtersInvisible (false), 74 fColour (colour), 72 fColour (colour), 75 fLineStyle (unbroken), 73 fLineStyle (unbroken), 76 fLineWidth (1.), 74 fLineWidth (1.), 77 fForceDrawingStyle (false), 75 fForceDrawingStyle (false), 78 fForcedStyle (wireframe), 76 fForcedStyle (wireframe), 79 fForcedNumberOfCloudPoints (0), // <= 0 means << 80 fForceAuxEdgeVisible (false), 77 fForceAuxEdgeVisible (false), 81 fForcedAuxEdgeVisible(false), << 82 fForcedLineSegmentsPerCircle (0), // <=0 mean 78 fForcedLineSegmentsPerCircle (0), // <=0 means not forced. 83 fStartTime (-fVeryLongTime), << 79 fStartTime (-DBL_MAX), 84 fEndTime (fVeryLongTime), << 80 fEndTime (DBL_MAX), 85 fAttValues (nullptr), << 81 fAttValues (0), 86 fAttDefs (nullptr) << 82 fAttDefs (0) 87 {} 83 {} 88 84 89 G4VisAttributes::G4VisAttributes (G4bool visib 85 G4VisAttributes::G4VisAttributes (G4bool visibility, 90 const G4Colo << 86 const G4Colour& colour): 91 fVisible (visibility), 87 fVisible (visibility), 92 fDaughtersInvisible (false), 88 fDaughtersInvisible (false), 93 fColour (colour), 89 fColour (colour), 94 fLineStyle (unbroken), 90 fLineStyle (unbroken), 95 fLineWidth (1.), 91 fLineWidth (1.), 96 fForceDrawingStyle (false), 92 fForceDrawingStyle (false), 97 fForcedStyle (wireframe), 93 fForcedStyle (wireframe), 98 fForcedNumberOfCloudPoints (0), // <= 0 means << 99 fForceAuxEdgeVisible (false), 94 fForceAuxEdgeVisible (false), 100 fForcedAuxEdgeVisible(false), << 101 fForcedLineSegmentsPerCircle (0), // <=0 mean 95 fForcedLineSegmentsPerCircle (0), // <=0 means not forced. 102 fStartTime (-fVeryLongTime), << 96 fStartTime (-DBL_MAX), 103 fEndTime (fVeryLongTime), << 97 fEndTime (DBL_MAX), 104 fAttValues (nullptr), << 98 fAttValues (0), 105 fAttDefs (nullptr) << 99 fAttDefs (0) 106 {} 100 {} 107 101 108 << 102 const G4VisAttributes G4VisAttributes::Invisible = G4VisAttributes (false); 109 G4VisAttributes& G4VisAttributes::operator= (c << 110 { << 111 if (&rhs == this) return *this; << 112 fVisible = rhs.fVisible; << 113 fDaughtersInvisible = rhs.fDaughtersInvisi << 114 fColour = rhs.fColour; << 115 fLineStyle = rhs.fLineStyle; << 116 fLineWidth = rhs.fLineWidth; << 117 fForceDrawingStyle = rhs.fForceDrawingSty << 118 fForcedStyle = rhs.fForcedStyle; << 119 fForcedNumberOfCloudPoints = rhs.fForcedNumb << 120 fForceAuxEdgeVisible = rhs.fForceAuxEdgeVis << 121 fForcedAuxEdgeVisible = rhs.fForcedAuxEdgeVi << 122 fForcedLineSegmentsPerCircle = rhs.fForcedLi << 123 fStartTime = rhs.fStartTime; << 124 fEndTime = rhs.fEndTime; << 125 // AttValues are created afresh for each obj << 126 // CreateAttValues message), but deletion is << 127 // the creator. So just copy pointer. << 128 fAttValues = rhs.fAttValues; << 129 // AttDefs, if any, belong to the object fro << 130 // (with a GetAttDefs message), so just copy << 131 fAttDefs = rhs.fAttDefs; << 132 return *this; << 133 } << 134 << 135 const G4VisAttributes& G4VisAttributes::GetInv << 136 static const G4VisAttributes invisible = G4V << 137 return invisible; << 138 } << 139 << 140 void G4VisAttributes::SetForceWireframe (G4boo << 141 if (force) { << 142 fForceDrawingStyle = true; << 143 fForcedStyle = G4VisAttributes::wireframe; << 144 } else { << 145 fForceDrawingStyle = false; << 146 } << 147 } << 148 << 149 void G4VisAttributes::SetForceSolid (G4bool fo << 150 if (force) { << 151 fForceDrawingStyle = true; << 152 fForcedStyle = G4VisAttributes::solid; << 153 } else { << 154 fForceDrawingStyle = false; << 155 } << 156 } << 157 << 158 void G4VisAttributes::SetForceCloud (G4bool fo << 159 if (force) { << 160 fForceDrawingStyle = true; << 161 fForcedStyle = G4VisAttributes::cloud; << 162 } else { << 163 fForceDrawingStyle = false; << 164 } << 165 } << 166 << 167 void G4VisAttributes::SetForceNumberOfCloudPoi << 168 fForcedNumberOfCloudPoints = nPoints; << 169 if (nPoints <= 0) { << 170 G4cout << << 171 "G4VisAttributes::SetForceNumberOfCloudPoi << 172 " set to " << fForcedNumberOfCloudPoints < << 173 "\n This means the viewer default will be << 174 "\n \"/vis/viewer/set/numberOfCloudPoints << 175 << G4endl; << 176 } << 177 } << 178 << 179 void G4VisAttributes::SetForceAuxEdgeVisible ( << 180 fForceAuxEdgeVisible = true; << 181 fForcedAuxEdgeVisible = visibility; << 182 } << 183 << 184 G4VisAttributes::ForcedDrawingStyle << 185 G4VisAttributes::GetForcedDrawingStyle () cons << 186 if (fForceDrawingStyle) return fForcedStyle; << 187 return G4VisAttributes::wireframe; << 188 } << 189 << 190 G4bool G4VisAttributes::IsForcedAuxEdgeVisible << 191 if (fForceAuxEdgeVisible) return fForcedAuxE << 192 return false; << 193 } << 194 103 195 const std::vector<G4AttValue>* G4VisAttributes 104 const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const { 196 // Create an expendable copy on the heap... 105 // Create an expendable copy on the heap... 197 return new std::vector<G4AttValue>(*fAttValu 106 return new std::vector<G4AttValue>(*fAttValues); 198 } 107 } 199 108 200 void G4VisAttributes::SetForceLineSegmentsPerC 109 void G4VisAttributes::SetForceLineSegmentsPerCircle (G4int nSegments) { 201 const G4int nSegmentsMin = fMinLineSegmentsP << 110 const G4int nSegmentsMin = 12; 202 if (nSegments < nSegmentsMin) { << 111 if (nSegments > 0 && nSegments < nSegmentsMin) { 203 nSegments = nSegmentsMin; 112 nSegments = nSegmentsMin; 204 G4cout << 113 G4cout << 205 "G4VisAttributes::SetForcedLineSegmentsP 114 "G4VisAttributes::SetForcedLineSegmentsPerCircle: attempt to set the" 206 "\nnumber of line segments per circle < << 115 "\nnumber of line segements per circle < " << nSegmentsMin 207 << "; forced to " << nSegments << G4e 116 << "; forced to " << nSegments << G4endl; 208 } 117 } 209 fForcedLineSegmentsPerCircle = nSegments; 118 fForcedLineSegmentsPerCircle = nSegments; 210 } 119 } 211 120 212 std::ostream& operator << (std::ostream& os, c << 121 std::ostream& operator << (std::ostream& os, const G4VisAttributes& a) { 213 { << 122 214 os << std::defaultfloat; << 215 os << "G4VisAttributes: "; 123 os << "G4VisAttributes: "; 216 if (!a.fVisible) os << "in"; << 124 if (&a){ 217 os << "visible, daughters "; << 125 if (!a.fVisible) os << "in"; 218 if (a.fDaughtersInvisible) os << "in"; << 126 os << "visible, daughters "; 219 os << "visible, colour: " << a.fColour; << 127 if (a.fDaughtersInvisible) os << "in"; 220 os << "\n linestyle: "; << 128 os << "visible, colour: " << a.fColour; 221 switch (a.fLineStyle) { << 129 os << "\n linestyle: "; >> 130 switch (a.fLineStyle) { 222 case G4VisAttributes::unbroken: 131 case G4VisAttributes::unbroken: 223 os << "solid"; break; 132 os << "solid"; break; 224 case G4VisAttributes::dashed: 133 case G4VisAttributes::dashed: 225 os << "dashed"; break; 134 os << "dashed"; break; 226 case G4VisAttributes::dotted: os << "dotte 135 case G4VisAttributes::dotted: os << "dotted"; break; 227 default: os << "unrecognised"; break; 136 default: os << "unrecognised"; break; 228 } << 137 } 229 os << ", line width: " << a.fLineWidth; << 138 os << ", line width: " << a.fLineWidth; 230 os << ", min line segments per circle: " << << 139 os << "\n drawing style: "; 231 os << "\n drawing style: "; << 140 if (a.fForceDrawingStyle) { 232 if (a.fForceDrawingStyle) { << 141 os << "forced to: "; 233 os << "forced to "; << 142 switch (a.fForcedStyle) { 234 switch (a.fForcedStyle) { << 235 case G4VisAttributes::wireframe: 143 case G4VisAttributes::wireframe: 236 os << "wireframe"; break; << 144 os << "wireframe"; break; 237 case G4VisAttributes::solid: 145 case G4VisAttributes::solid: 238 os << "solid"; break; << 146 os << "solid"; break; 239 default: os << "unrecognised"; break; 147 default: os << "unrecognised"; break; >> 148 } 240 } 149 } 241 } << 150 else { 242 else { << 151 os << "not forced"; 243 os << "not forced"; << 152 } 244 } << 153 os << ", auxiliary edge visibility: "; 245 os << ", auxiliary edge visibility: "; << 154 if (!a.fForceAuxEdgeVisible) { 246 if (a.fForceAuxEdgeVisible) { << 247 os << "forced to "; << 248 if (!a.fForcedAuxEdgeVisible) { << 249 os << "not "; 155 os << "not "; 250 } 156 } 251 os << "visible"; << 157 os << "forced"; 252 } else { << 158 os << "\n line segments per circle: "; 253 os << "not forced"; << 159 if (a.fForcedLineSegmentsPerCircle > 0) { 254 } << 160 os << "forced to " << a.fForcedLineSegmentsPerCircle; 255 os << "\n line segments per circle: "; << 161 } else { 256 if (a.fForcedLineSegmentsPerCircle > 0) { << 162 os << "not forced."; 257 os << "forced to " << a.fForcedLineSegment << 163 } 258 } else { << 164 os << "\n time range: (" << a.fStartTime << ',' << a.fEndTime << ')'; 259 os << "not forced."; << 165 os << "\n G4AttValue pointer is "; 260 } << 166 if (a.fAttValues) { 261 os << "\n time range: (" << a.fStartTime << << 167 os << "non-"; 262 os << "\n G4AttValue pointer is "; << 168 } 263 if (a.fAttValues != nullptr) { << 169 os << "zero"; 264 os << "non-"; << 170 os << ", G4AttDef pointer is "; 265 } << 171 if (a.fAttDefs) { 266 os << "zero"; << 172 os << "non-"; 267 os << ", G4AttDef pointer is "; << 173 } 268 if (a.fAttDefs != nullptr) { << 174 os << "zero"; 269 os << "non-"; << 175 } 270 } << 176 else os << " zero G4VisAttributes pointer"; 271 os << "zero"; << 272 return os; 177 return os; 273 } 178 } 274 179 275 G4bool G4VisAttributes::operator != (const G4V 180 G4bool G4VisAttributes::operator != (const G4VisAttributes& a) const { 276 181 277 if ( 182 if ( 278 (fVisible != a.fVisible) 183 (fVisible != a.fVisible) || 279 (fDaughtersInvisible != a.fDaughtersInvi 184 (fDaughtersInvisible != a.fDaughtersInvisible) || 280 (fColour != a.fColour) 185 (fColour != a.fColour) || 281 (fLineStyle != a.fLineStyle) 186 (fLineStyle != a.fLineStyle) || 282 (fLineWidth != a.fLineWidth) 187 (fLineWidth != a.fLineWidth) || 283 (fForceDrawingStyle != a.fForceDrawingS 188 (fForceDrawingStyle != a.fForceDrawingStyle) || 284 (fForceAuxEdgeVisible!= a.fForceAuxEdgeV << 189 (fForceAuxEdgeVisible!= a.fForceAuxEdgeVisible)|| 285 (fForcedLineSegmentsPerCircle != a.fForc 190 (fForcedLineSegmentsPerCircle != a.fForcedLineSegmentsPerCircle) || 286 (fStartTime != a.fStartTime) 191 (fStartTime != a.fStartTime) || 287 (fEndTime != a.fEndTime) 192 (fEndTime != a.fEndTime) || 288 (fAttValues != a.fAttValues) 193 (fAttValues != a.fAttValues) || 289 (fAttDefs != a.fAttDefs) 194 (fAttDefs != a.fAttDefs) 290 ) 195 ) 291 return true; 196 return true; 292 197 293 if (fForceDrawingStyle) { 198 if (fForceDrawingStyle) { 294 if (fForcedStyle != a.fForcedStyle) return 199 if (fForcedStyle != a.fForcedStyle) return true; 295 } << 296 << 297 if (fForceAuxEdgeVisible) { << 298 if (fForcedAuxEdgeVisible != a.fForcedAuxE << 299 } 200 } 300 201 301 return false; 202 return false; 302 } 203 } 303 204 304 G4bool G4VisAttributes::operator == (const G4V 205 G4bool G4VisAttributes::operator == (const G4VisAttributes& a) const { 305 return !(G4VisAttributes::operator != (a)); 206 return !(G4VisAttributes::operator != (a)); 306 } 207 } 307 208