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 // 27 // 28 // 28 // 29 // John Allison 23rd October 1996 29 // John Allison 23rd October 1996 30 30 31 #include "G4VisAttributes.hh" 31 #include "G4VisAttributes.hh" 32 32 33 #include "G4AttValue.hh" 33 #include "G4AttValue.hh" 34 #include "G4AttDef.hh" 34 #include "G4AttDef.hh" 35 35 36 G4VisAttributes::G4VisAttributes (): 36 G4VisAttributes::G4VisAttributes (): 37 fVisible (true), 37 fVisible (true), 38 fDaughtersInvisible (false), 38 fDaughtersInvisible (false), >> 39 fColour (G4Colour ()), 39 fLineStyle (unbroken), 40 fLineStyle (unbroken), 40 fLineWidth (1.), 41 fLineWidth (1.), 41 fForceDrawingStyle (false), 42 fForceDrawingStyle (false), 42 fForcedStyle (wireframe), 43 fForcedStyle (wireframe), 43 fForcedNumberOfCloudPoints (0), // <= 0 means 44 fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer 44 fForceAuxEdgeVisible (false), 45 fForceAuxEdgeVisible (false), 45 fForcedAuxEdgeVisible(false), 46 fForcedAuxEdgeVisible(false), 46 fForcedLineSegmentsPerCircle (0), // <=0 mean 47 fForcedLineSegmentsPerCircle (0), // <=0 means not forced. 47 fStartTime (-fVeryLongTime), 48 fStartTime (-fVeryLongTime), 48 fEndTime (fVeryLongTime), 49 fEndTime (fVeryLongTime), 49 fAttValues (nullptr), << 50 fAttValues (0), 50 fAttDefs (nullptr) << 51 fAttDefs (0) 51 {} 52 {} 52 53 53 G4VisAttributes::G4VisAttributes (G4bool visib 54 G4VisAttributes::G4VisAttributes (G4bool visibility): 54 fVisible (visibility), 55 fVisible (visibility), 55 fDaughtersInvisible (false), 56 fDaughtersInvisible (false), 56 << 57 fColour (G4Colour ()), 57 fLineStyle (unbroken), 58 fLineStyle (unbroken), 58 fLineWidth (1.), 59 fLineWidth (1.), 59 fForceDrawingStyle (false), 60 fForceDrawingStyle (false), 60 fForcedStyle (wireframe), 61 fForcedStyle (wireframe), 61 fForcedNumberOfCloudPoints (0), // <= 0 means 62 fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer 62 fForceAuxEdgeVisible (false), 63 fForceAuxEdgeVisible (false), 63 fForcedAuxEdgeVisible(false), 64 fForcedAuxEdgeVisible(false), 64 fForcedLineSegmentsPerCircle (0), // <=0 mean 65 fForcedLineSegmentsPerCircle (0), // <=0 means not forced. 65 fStartTime (-fVeryLongTime), 66 fStartTime (-fVeryLongTime), 66 fEndTime (fVeryLongTime), 67 fEndTime (fVeryLongTime), 67 fAttValues (nullptr), << 68 fAttValues (0), 68 fAttDefs (nullptr) << 69 fAttDefs (0) 69 {} 70 {} 70 71 71 G4VisAttributes::G4VisAttributes (const G4Colo 72 G4VisAttributes::G4VisAttributes (const G4Colour& colour): 72 fVisible (true), 73 fVisible (true), 73 fDaughtersInvisible (false), 74 fDaughtersInvisible (false), 74 fColour (colour), 75 fColour (colour), 75 fLineStyle (unbroken), 76 fLineStyle (unbroken), 76 fLineWidth (1.), 77 fLineWidth (1.), 77 fForceDrawingStyle (false), 78 fForceDrawingStyle (false), 78 fForcedStyle (wireframe), 79 fForcedStyle (wireframe), 79 fForcedNumberOfCloudPoints (0), // <= 0 means 80 fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer 80 fForceAuxEdgeVisible (false), 81 fForceAuxEdgeVisible (false), 81 fForcedAuxEdgeVisible(false), 82 fForcedAuxEdgeVisible(false), 82 fForcedLineSegmentsPerCircle (0), // <=0 mean 83 fForcedLineSegmentsPerCircle (0), // <=0 means not forced. 83 fStartTime (-fVeryLongTime), 84 fStartTime (-fVeryLongTime), 84 fEndTime (fVeryLongTime), 85 fEndTime (fVeryLongTime), 85 fAttValues (nullptr), << 86 fAttValues (0), 86 fAttDefs (nullptr) << 87 fAttDefs (0) 87 {} 88 {} 88 89 89 G4VisAttributes::G4VisAttributes (G4bool visib 90 G4VisAttributes::G4VisAttributes (G4bool visibility, 90 const G4Colo 91 const G4Colour& colour): 91 fVisible (visibility), 92 fVisible (visibility), 92 fDaughtersInvisible (false), 93 fDaughtersInvisible (false), 93 fColour (colour), 94 fColour (colour), 94 fLineStyle (unbroken), 95 fLineStyle (unbroken), 95 fLineWidth (1.), 96 fLineWidth (1.), 96 fForceDrawingStyle (false), 97 fForceDrawingStyle (false), 97 fForcedStyle (wireframe), 98 fForcedStyle (wireframe), 98 fForcedNumberOfCloudPoints (0), // <= 0 means 99 fForcedNumberOfCloudPoints (0), // <= 0 means under control of viewer 99 fForceAuxEdgeVisible (false), 100 fForceAuxEdgeVisible (false), 100 fForcedAuxEdgeVisible(false), 101 fForcedAuxEdgeVisible(false), 101 fForcedLineSegmentsPerCircle (0), // <=0 mean 102 fForcedLineSegmentsPerCircle (0), // <=0 means not forced. 102 fStartTime (-fVeryLongTime), 103 fStartTime (-fVeryLongTime), 103 fEndTime (fVeryLongTime), 104 fEndTime (fVeryLongTime), 104 fAttValues (nullptr), << 105 fAttValues (0), 105 fAttDefs (nullptr) << 106 fAttDefs (0) 106 {} 107 {} 107 108 >> 109 G4VisAttributes::G4VisAttributes (const G4VisAttributes& va): >> 110 fVisible (va.fVisible), >> 111 fDaughtersInvisible (va.fDaughtersInvisible), >> 112 fColour (va.fColour), >> 113 fLineStyle (va.fLineStyle), >> 114 fLineWidth (va.fLineWidth), >> 115 fForceDrawingStyle (va.fForceDrawingStyle), >> 116 fForcedStyle (va.fForcedStyle), >> 117 fForcedNumberOfCloudPoints (va.fForcedNumberOfCloudPoints), >> 118 fForceAuxEdgeVisible (va.fForceAuxEdgeVisible), >> 119 fForcedAuxEdgeVisible(va.fForcedAuxEdgeVisible), >> 120 fForcedLineSegmentsPerCircle (va.fForcedLineSegmentsPerCircle), >> 121 fStartTime (va.fStartTime), >> 122 fEndTime (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. >> 126 fAttValues (va.fAttValues), >> 127 // AttDefs, if any, belong to the object from which they were obtained >> 128 // (with a GetAttDefs message), so just copy pointer. >> 129 fAttDefs (va.fAttDefs) >> 130 {} >> 131 >> 132 G4VisAttributes::~G4VisAttributes() >> 133 {} 108 134 109 G4VisAttributes& G4VisAttributes::operator= (c 135 G4VisAttributes& G4VisAttributes::operator= (const G4VisAttributes& rhs) 110 { 136 { 111 if (&rhs == this) return *this; 137 if (&rhs == this) return *this; 112 fVisible = rhs.fVisible; 138 fVisible = rhs.fVisible; 113 fDaughtersInvisible = rhs.fDaughtersInvisi 139 fDaughtersInvisible = rhs.fDaughtersInvisible; 114 fColour = rhs.fColour; 140 fColour = rhs.fColour; 115 fLineStyle = rhs.fLineStyle; 141 fLineStyle = rhs.fLineStyle; 116 fLineWidth = rhs.fLineWidth; 142 fLineWidth = rhs.fLineWidth; 117 fForceDrawingStyle = rhs.fForceDrawingSty 143 fForceDrawingStyle = rhs.fForceDrawingStyle; 118 fForcedStyle = rhs.fForcedStyle; 144 fForcedStyle = rhs.fForcedStyle; 119 fForcedNumberOfCloudPoints = rhs.fForcedNumb 145 fForcedNumberOfCloudPoints = rhs.fForcedNumberOfCloudPoints; 120 fForceAuxEdgeVisible = rhs.fForceAuxEdgeVis 146 fForceAuxEdgeVisible = rhs.fForceAuxEdgeVisible; 121 fForcedAuxEdgeVisible = rhs.fForcedAuxEdgeVi 147 fForcedAuxEdgeVisible = rhs.fForcedAuxEdgeVisible; 122 fForcedLineSegmentsPerCircle = rhs.fForcedLi 148 fForcedLineSegmentsPerCircle = rhs.fForcedLineSegmentsPerCircle; 123 fStartTime = rhs.fStartTime; 149 fStartTime = rhs.fStartTime; 124 fEndTime = rhs.fEndTime; 150 fEndTime = rhs.fEndTime; 125 // AttValues are created afresh for each obj 151 // AttValues are created afresh for each object (using the 126 // CreateAttValues message), but deletion is 152 // CreateAttValues message), but deletion is the responsibility of 127 // the creator. So just copy pointer. 153 // the creator. So just copy pointer. 128 fAttValues = rhs.fAttValues; 154 fAttValues = rhs.fAttValues; 129 // AttDefs, if any, belong to the object fro 155 // AttDefs, if any, belong to the object from which they were obtained 130 // (with a GetAttDefs message), so just copy 156 // (with a GetAttDefs message), so just copy pointer. 131 fAttDefs = rhs.fAttDefs; 157 fAttDefs = rhs.fAttDefs; 132 return *this; 158 return *this; 133 } 159 } 134 160 >> 161 #ifndef WIN32 >> 162 // Deprecated 14 July 2016 JA >> 163 const G4VisAttributes G4VisAttributes::Invisible = G4VisAttributes (false); >> 164 #endif >> 165 135 const G4VisAttributes& G4VisAttributes::GetInv 166 const G4VisAttributes& G4VisAttributes::GetInvisible() { 136 static const G4VisAttributes invisible = G4V 167 static const G4VisAttributes invisible = G4VisAttributes(false); 137 return invisible; 168 return invisible; 138 } 169 } 139 170 140 void G4VisAttributes::SetForceWireframe (G4boo 171 void G4VisAttributes::SetForceWireframe (G4bool force) { 141 if (force) { 172 if (force) { 142 fForceDrawingStyle = true; 173 fForceDrawingStyle = true; 143 fForcedStyle = G4VisAttributes::wireframe; 174 fForcedStyle = G4VisAttributes::wireframe; 144 } else { 175 } else { 145 fForceDrawingStyle = false; 176 fForceDrawingStyle = false; 146 } 177 } 147 } 178 } 148 179 149 void G4VisAttributes::SetForceSolid (G4bool fo 180 void G4VisAttributes::SetForceSolid (G4bool force) { 150 if (force) { 181 if (force) { 151 fForceDrawingStyle = true; 182 fForceDrawingStyle = true; 152 fForcedStyle = G4VisAttributes::solid; 183 fForcedStyle = G4VisAttributes::solid; 153 } else { 184 } else { 154 fForceDrawingStyle = false; 185 fForceDrawingStyle = false; 155 } 186 } 156 } 187 } 157 188 158 void G4VisAttributes::SetForceCloud (G4bool fo 189 void G4VisAttributes::SetForceCloud (G4bool force) { 159 if (force) { 190 if (force) { 160 fForceDrawingStyle = true; 191 fForceDrawingStyle = true; 161 fForcedStyle = G4VisAttributes::cloud; 192 fForcedStyle = G4VisAttributes::cloud; 162 } else { 193 } else { 163 fForceDrawingStyle = false; 194 fForceDrawingStyle = false; 164 } 195 } 165 } 196 } 166 197 167 void G4VisAttributes::SetForceNumberOfCloudPoi 198 void G4VisAttributes::SetForceNumberOfCloudPoints (G4int nPoints) { 168 fForcedNumberOfCloudPoints = nPoints; 199 fForcedNumberOfCloudPoints = nPoints; 169 if (nPoints <= 0) { 200 if (nPoints <= 0) { 170 G4cout << 201 G4cout << 171 "G4VisAttributes::SetForceNumberOfCloudPoi 202 "G4VisAttributes::SetForceNumberOfCloudPoints: number of cloud points" 172 " set to " << fForcedNumberOfCloudPoints < << 203 "set to " << fForcedNumberOfCloudPoints 173 "\n This means the viewer default will be << 204 << ". This means the viewer default will be used." 174 "\n \"/vis/viewer/set/numberOfCloudPoints << 175 << G4endl; 205 << G4endl; 176 } 206 } 177 } 207 } 178 208 179 void G4VisAttributes::SetForceAuxEdgeVisible ( 209 void G4VisAttributes::SetForceAuxEdgeVisible (G4bool visibility) { 180 fForceAuxEdgeVisible = true; 210 fForceAuxEdgeVisible = true; 181 fForcedAuxEdgeVisible = visibility; 211 fForcedAuxEdgeVisible = visibility; 182 } 212 } 183 213 184 G4VisAttributes::ForcedDrawingStyle 214 G4VisAttributes::ForcedDrawingStyle 185 G4VisAttributes::GetForcedDrawingStyle () cons 215 G4VisAttributes::GetForcedDrawingStyle () const { 186 if (fForceDrawingStyle) return fForcedStyle; 216 if (fForceDrawingStyle) return fForcedStyle; 187 return G4VisAttributes::wireframe; << 217 else return G4VisAttributes::wireframe; 188 } 218 } 189 219 190 G4bool G4VisAttributes::IsForcedAuxEdgeVisible 220 G4bool G4VisAttributes::IsForcedAuxEdgeVisible () const { 191 if (fForceAuxEdgeVisible) return fForcedAuxE 221 if (fForceAuxEdgeVisible) return fForcedAuxEdgeVisible; 192 return false; << 222 else return false; 193 } 223 } 194 224 195 const std::vector<G4AttValue>* G4VisAttributes 225 const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const { 196 // Create an expendable copy on the heap... 226 // Create an expendable copy on the heap... 197 return new std::vector<G4AttValue>(*fAttValu 227 return new std::vector<G4AttValue>(*fAttValues); 198 } 228 } 199 229 200 void G4VisAttributes::SetForceLineSegmentsPerC 230 void G4VisAttributes::SetForceLineSegmentsPerCircle (G4int nSegments) { 201 const G4int nSegmentsMin = fMinLineSegmentsP 231 const G4int nSegmentsMin = fMinLineSegmentsPerCircle; 202 if (nSegments < nSegmentsMin) { << 232 if (nSegments > 0 && nSegments < nSegmentsMin) { 203 nSegments = nSegmentsMin; 233 nSegments = nSegmentsMin; 204 G4cout << 234 G4cout << 205 "G4VisAttributes::SetForcedLineSegmentsP 235 "G4VisAttributes::SetForcedLineSegmentsPerCircle: attempt to set the" 206 "\nnumber of line segments per circle < 236 "\nnumber of line segments per circle < " << nSegmentsMin 207 << "; forced to " << nSegments << G4e 237 << "; forced to " << nSegments << G4endl; 208 } 238 } 209 fForcedLineSegmentsPerCircle = nSegments; 239 fForcedLineSegmentsPerCircle = nSegments; 210 } 240 } 211 241 212 std::ostream& operator << (std::ostream& os, c 242 std::ostream& operator << (std::ostream& os, const G4VisAttributes& a) 213 { 243 { 214 os << std::defaultfloat; << 215 os << "G4VisAttributes: "; 244 os << "G4VisAttributes: "; 216 if (!a.fVisible) os << "in"; 245 if (!a.fVisible) os << "in"; 217 os << "visible, daughters "; 246 os << "visible, daughters "; 218 if (a.fDaughtersInvisible) os << "in"; 247 if (a.fDaughtersInvisible) os << "in"; 219 os << "visible, colour: " << a.fColour; 248 os << "visible, colour: " << a.fColour; 220 os << "\n linestyle: "; 249 os << "\n linestyle: "; 221 switch (a.fLineStyle) { 250 switch (a.fLineStyle) { 222 case G4VisAttributes::unbroken: 251 case G4VisAttributes::unbroken: 223 os << "solid"; break; 252 os << "solid"; break; 224 case G4VisAttributes::dashed: 253 case G4VisAttributes::dashed: 225 os << "dashed"; break; 254 os << "dashed"; break; 226 case G4VisAttributes::dotted: os << "dotte 255 case G4VisAttributes::dotted: os << "dotted"; break; 227 default: os << "unrecognised"; break; 256 default: os << "unrecognised"; break; 228 } 257 } 229 os << ", line width: " << a.fLineWidth; 258 os << ", line width: " << a.fLineWidth; 230 os << ", min line segments per circle: " << 259 os << ", min line segments per circle: " << a.GetMinLineSegmentsPerCircle(); 231 os << "\n drawing style: "; 260 os << "\n drawing style: "; 232 if (a.fForceDrawingStyle) { 261 if (a.fForceDrawingStyle) { 233 os << "forced to "; 262 os << "forced to "; 234 switch (a.fForcedStyle) { 263 switch (a.fForcedStyle) { 235 case G4VisAttributes::wireframe: 264 case G4VisAttributes::wireframe: 236 os << "wireframe"; break; 265 os << "wireframe"; break; 237 case G4VisAttributes::solid: 266 case G4VisAttributes::solid: 238 os << "solid"; break; 267 os << "solid"; break; 239 default: os << "unrecognised"; break; 268 default: os << "unrecognised"; break; 240 } 269 } 241 } 270 } 242 else { 271 else { 243 os << "not forced"; 272 os << "not forced"; 244 } 273 } 245 os << ", auxiliary edge visibility: "; 274 os << ", auxiliary edge visibility: "; 246 if (a.fForceAuxEdgeVisible) { 275 if (a.fForceAuxEdgeVisible) { 247 os << "forced to "; 276 os << "forced to "; 248 if (!a.fForcedAuxEdgeVisible) { 277 if (!a.fForcedAuxEdgeVisible) { 249 os << "not "; 278 os << "not "; 250 } 279 } 251 os << "visible"; 280 os << "visible"; 252 } else { 281 } else { 253 os << "not forced"; 282 os << "not forced"; 254 } 283 } 255 os << "\n line segments per circle: "; 284 os << "\n line segments per circle: "; 256 if (a.fForcedLineSegmentsPerCircle > 0) { 285 if (a.fForcedLineSegmentsPerCircle > 0) { 257 os << "forced to " << a.fForcedLineSegment 286 os << "forced to " << a.fForcedLineSegmentsPerCircle; 258 } else { 287 } else { 259 os << "not forced."; 288 os << "not forced."; 260 } 289 } 261 os << "\n time range: (" << a.fStartTime << 290 os << "\n time range: (" << a.fStartTime << ',' << a.fEndTime << ')'; 262 os << "\n G4AttValue pointer is "; 291 os << "\n G4AttValue pointer is "; 263 if (a.fAttValues != nullptr) { << 292 if (a.fAttValues) { 264 os << "non-"; 293 os << "non-"; 265 } 294 } 266 os << "zero"; 295 os << "zero"; 267 os << ", G4AttDef pointer is "; 296 os << ", G4AttDef pointer is "; 268 if (a.fAttDefs != nullptr) { << 297 if (a.fAttDefs) { 269 os << "non-"; 298 os << "non-"; 270 } 299 } 271 os << "zero"; 300 os << "zero"; 272 return os; 301 return os; 273 } 302 } 274 303 275 G4bool G4VisAttributes::operator != (const G4V 304 G4bool G4VisAttributes::operator != (const G4VisAttributes& a) const { 276 305 277 if ( 306 if ( 278 (fVisible != a.fVisible) 307 (fVisible != a.fVisible) || 279 (fDaughtersInvisible != a.fDaughtersInvi 308 (fDaughtersInvisible != a.fDaughtersInvisible) || 280 (fColour != a.fColour) 309 (fColour != a.fColour) || 281 (fLineStyle != a.fLineStyle) 310 (fLineStyle != a.fLineStyle) || 282 (fLineWidth != a.fLineWidth) 311 (fLineWidth != a.fLineWidth) || 283 (fForceDrawingStyle != a.fForceDrawingS 312 (fForceDrawingStyle != a.fForceDrawingStyle) || 284 (fForceAuxEdgeVisible!= a.fForceAuxEdgeV 313 (fForceAuxEdgeVisible!= a.fForceAuxEdgeVisible) || 285 (fForcedLineSegmentsPerCircle != a.fForc 314 (fForcedLineSegmentsPerCircle != a.fForcedLineSegmentsPerCircle) || 286 (fStartTime != a.fStartTime) 315 (fStartTime != a.fStartTime) || 287 (fEndTime != a.fEndTime) 316 (fEndTime != a.fEndTime) || 288 (fAttValues != a.fAttValues) 317 (fAttValues != a.fAttValues) || 289 (fAttDefs != a.fAttDefs) 318 (fAttDefs != a.fAttDefs) 290 ) 319 ) 291 return true; 320 return true; 292 321 293 if (fForceDrawingStyle) { 322 if (fForceDrawingStyle) { 294 if (fForcedStyle != a.fForcedStyle) return 323 if (fForcedStyle != a.fForcedStyle) return true; 295 } 324 } 296 325 297 if (fForceAuxEdgeVisible) { 326 if (fForceAuxEdgeVisible) { 298 if (fForcedAuxEdgeVisible != a.fForcedAuxE 327 if (fForcedAuxEdgeVisible != a.fForcedAuxEdgeVisible) return true; 299 } 328 } 300 329 301 return false; 330 return false; 302 } 331 } 303 332 304 G4bool G4VisAttributes::operator == (const G4V 333 G4bool G4VisAttributes::operator == (const G4VisAttributes& a) const { 305 return !(G4VisAttributes::operator != (a)); 334 return !(G4VisAttributes::operator != (a)); 306 } 335 } 307 336