Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // 23 // >> 24 // $Id: G4VisAttributes.cc,v 1.8 2002/11/20 14:18:34 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-05-01-patch-01 $ 27 // 26 // 28 // 27 // 29 // John Allison 23rd October 1996 28 // John Allison 23rd October 1996 30 29 31 #include "G4VisAttributes.hh" 30 #include "G4VisAttributes.hh" 32 31 33 #include "G4AttValue.hh" << 34 #include "G4AttDef.hh" << 35 << 36 G4VisAttributes::G4VisAttributes (): 32 G4VisAttributes::G4VisAttributes (): 37 fVisible (true), << 33 fVisible (true), 38 fDaughtersInvisible (false), << 34 fDaughtersInvisible (false), 39 fLineStyle (unbroken), << 35 fColour (G4Colour ()), 40 fLineWidth (1.), << 36 fLineStyle (unbroken), 41 fForceDrawingStyle (false), << 37 fLineWidth (1.), 42 fForcedStyle (wireframe), << 38 fForceDrawingStyle (false), 43 fForcedNumberOfCloudPoints (0), // <= 0 means << 39 fAttValues (0), 44 fForceAuxEdgeVisible (false), << 40 fAttDefs (0) 45 fForcedAuxEdgeVisible(false), << 46 fForcedLineSegmentsPerCircle (0), // <=0 mean << 47 fStartTime (-fVeryLongTime), << 48 fEndTime (fVeryLongTime), << 49 fAttValues (nullptr), << 50 fAttDefs (nullptr) << 51 {} 41 {} 52 42 53 G4VisAttributes::G4VisAttributes (G4bool visib 43 G4VisAttributes::G4VisAttributes (G4bool visibility): 54 fVisible (visibility), << 44 fVisible (visibility), 55 fDaughtersInvisible (false), << 45 fDaughtersInvisible (false), 56 << 46 fColour (G4Colour ()), 57 fLineStyle (unbroken), << 47 fLineStyle (unbroken), 58 fLineWidth (1.), << 48 fLineWidth (1.), 59 fForceDrawingStyle (false), << 49 fForceDrawingStyle (false), 60 fForcedStyle (wireframe), << 50 fAttValues (0), 61 fForcedNumberOfCloudPoints (0), // <= 0 means << 51 fAttDefs (0) 62 fForceAuxEdgeVisible (false), << 63 fForcedAuxEdgeVisible(false), << 64 fForcedLineSegmentsPerCircle (0), // <=0 mean << 65 fStartTime (-fVeryLongTime), << 66 fEndTime (fVeryLongTime), << 67 fAttValues (nullptr), << 68 fAttDefs (nullptr) << 69 {} 52 {} 70 53 71 G4VisAttributes::G4VisAttributes (const G4Colo 54 G4VisAttributes::G4VisAttributes (const G4Colour& colour): 72 fVisible (true), << 55 fVisible (true), 73 fDaughtersInvisible (false), << 56 fDaughtersInvisible (false), 74 fColour (colour), << 57 fColour (colour), 75 fLineStyle (unbroken), << 58 fLineStyle (unbroken), 76 fLineWidth (1.), << 59 fLineWidth (1.), 77 fForceDrawingStyle (false), << 60 fForceDrawingStyle (false), 78 fForcedStyle (wireframe), << 61 fAttValues (0), 79 fForcedNumberOfCloudPoints (0), // <= 0 means << 62 fAttDefs (0) 80 fForceAuxEdgeVisible (false), << 81 fForcedAuxEdgeVisible(false), << 82 fForcedLineSegmentsPerCircle (0), // <=0 mean << 83 fStartTime (-fVeryLongTime), << 84 fEndTime (fVeryLongTime), << 85 fAttValues (nullptr), << 86 fAttDefs (nullptr) << 87 {} 63 {} 88 64 89 G4VisAttributes::G4VisAttributes (G4bool visib 65 G4VisAttributes::G4VisAttributes (G4bool visibility, 90 const G4Colo << 66 const G4Colour& colour): 91 fVisible (visibility), << 67 fVisible (visibility), 92 fDaughtersInvisible (false), << 68 fDaughtersInvisible (false), 93 fColour (colour), << 69 fColour (colour), 94 fLineStyle (unbroken), << 70 fLineStyle (unbroken), 95 fLineWidth (1.), << 71 fLineWidth (1.), 96 fForceDrawingStyle (false), << 72 fForceDrawingStyle (false), 97 fForcedStyle (wireframe), << 73 fAttValues (0), 98 fForcedNumberOfCloudPoints (0), // <= 0 means << 74 fAttDefs (0) 99 fForceAuxEdgeVisible (false), << 100 fForcedAuxEdgeVisible(false), << 101 fForcedLineSegmentsPerCircle (0), // <=0 mean << 102 fStartTime (-fVeryLongTime), << 103 fEndTime (fVeryLongTime), << 104 fAttValues (nullptr), << 105 fAttDefs (nullptr) << 106 {} 75 {} 107 76 108 << 77 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 78 135 const G4VisAttributes& G4VisAttributes::GetInv 79 const G4VisAttributes& G4VisAttributes::GetInvisible() { 136 static const G4VisAttributes invisible = G4V << 80 return Invisible; 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 << 195 const std::vector<G4AttValue>* G4VisAttributes << 196 // Create an expendable copy on the heap... << 197 return new std::vector<G4AttValue>(*fAttValu << 198 } 81 } 199 82 200 void G4VisAttributes::SetForceLineSegmentsPerC << 83 G4std::ostream& operator << (G4std::ostream& os, const G4VisAttributes& a) { 201 const G4int nSegmentsMin = fMinLineSegmentsP << 84 202 if (nSegments < nSegmentsMin) { << 203 nSegments = nSegmentsMin; << 204 G4cout << << 205 "G4VisAttributes::SetForcedLineSegmentsP << 206 "\nnumber of line segments per circle < << 207 << "; forced to " << nSegments << G4e << 208 } << 209 fForcedLineSegmentsPerCircle = nSegments; << 210 } << 211 << 212 std::ostream& operator << (std::ostream& os, c << 213 { << 214 os << std::defaultfloat; << 215 os << "G4VisAttributes: "; 85 os << "G4VisAttributes: "; 216 if (!a.fVisible) os << "in"; << 86 if (&a){ 217 os << "visible, daughters "; << 87 if (!a.fVisible) os << "in"; 218 if (a.fDaughtersInvisible) os << "in"; << 88 os << "visible, daughters "; 219 os << "visible, colour: " << a.fColour; << 89 if (a.fDaughtersInvisible) os << "in"; 220 os << "\n linestyle: "; << 90 os << "visible, colour: " << a.fColour; 221 switch (a.fLineStyle) { << 91 os << "\n linestyle: "; >> 92 switch (a.fLineStyle) { 222 case G4VisAttributes::unbroken: 93 case G4VisAttributes::unbroken: 223 os << "solid"; break; 94 os << "solid"; break; 224 case G4VisAttributes::dashed: 95 case G4VisAttributes::dashed: 225 os << "dashed"; break; 96 os << "dashed"; break; 226 case G4VisAttributes::dotted: os << "dotte 97 case G4VisAttributes::dotted: os << "dotted"; break; 227 default: os << "unrecognised"; break; 98 default: os << "unrecognised"; break; 228 } << 99 } 229 os << ", line width: " << a.fLineWidth; << 100 os << ", line width: " << a.fLineWidth; 230 os << ", min line segments per circle: " << << 101 os << "\n drawing style "; 231 os << "\n drawing style: "; << 102 if (a.fForceDrawingStyle) { 232 if (a.fForceDrawingStyle) { << 103 os << "forced to: "; 233 os << "forced to "; << 104 switch (a.fForcedStyle) { 234 switch (a.fForcedStyle) { << 235 case G4VisAttributes::wireframe: 105 case G4VisAttributes::wireframe: 236 os << "wireframe"; break; << 106 os << "wireframe"; break; 237 case G4VisAttributes::solid: 107 case G4VisAttributes::solid: 238 os << "solid"; break; << 108 os << "solid"; break; 239 default: os << "unrecognised"; break; 109 default: os << "unrecognised"; break; >> 110 } 240 } 111 } 241 } << 112 else { 242 else { << 113 os << "unforced"; 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 } 114 } 251 os << "visible"; << 115 os << "\n vector<G4AttValue> pointer is "; 252 } else { << 116 if (a.fAttValues) { 253 os << "not forced"; << 117 os << "non-"; 254 } << 118 } 255 os << "\n line segments per circle: "; << 119 os << "zero"; 256 if (a.fForcedLineSegmentsPerCircle > 0) { << 120 os << "\n vector<G4AttDef> pointer is "; 257 os << "forced to " << a.fForcedLineSegment << 121 if (a.fAttDefs) { 258 } else { << 122 os << "non-"; 259 os << "not forced."; << 123 } 260 } << 124 os << "zero"; 261 os << "\n time range: (" << a.fStartTime << << 125 } 262 os << "\n G4AttValue pointer is "; << 126 else os << " zero G4VisAttributes pointer"; 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; 127 return os; 273 } 128 } 274 129 275 G4bool G4VisAttributes::operator != (const G4V 130 G4bool G4VisAttributes::operator != (const G4VisAttributes& a) const { 276 131 277 if ( 132 if ( 278 (fVisible != a.fVisible) 133 (fVisible != a.fVisible) || 279 (fDaughtersInvisible != a.fDaughtersInvi 134 (fDaughtersInvisible != a.fDaughtersInvisible) || 280 (fColour != a.fColour) 135 (fColour != a.fColour) || 281 (fLineStyle != a.fLineStyle) 136 (fLineStyle != a.fLineStyle) || 282 (fLineWidth != a.fLineWidth) 137 (fLineWidth != a.fLineWidth) || 283 (fForceDrawingStyle != a.fForceDrawingS 138 (fForceDrawingStyle != a.fForceDrawingStyle) || 284 (fForceAuxEdgeVisible!= a.fForceAuxEdgeV << 285 (fForcedLineSegmentsPerCircle != a.fForc << 286 (fStartTime != a.fStartTime) << 287 (fEndTime != a.fEndTime) << 288 (fAttValues != a.fAttValues) 139 (fAttValues != a.fAttValues) || 289 (fAttDefs != a.fAttDefs) 140 (fAttDefs != a.fAttDefs) 290 ) 141 ) 291 return true; 142 return true; 292 143 293 if (fForceDrawingStyle) { 144 if (fForceDrawingStyle) { 294 if (fForcedStyle != a.fForcedStyle) return 145 if (fForcedStyle != a.fForcedStyle) return true; 295 } << 296 << 297 if (fForceAuxEdgeVisible) { << 298 if (fForcedAuxEdgeVisible != a.fForcedAuxE << 299 } 146 } 300 147 301 return false; 148 return false; 302 } 149 } 303 150 304 G4bool G4VisAttributes::operator == (const G4V 151 G4bool G4VisAttributes::operator == (const G4VisAttributes& a) const { 305 return !(G4VisAttributes::operator != (a)); 152 return !(G4VisAttributes::operator != (a)); 306 } 153 } 307 154