[830] | 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 $ |
---|
[1337] | 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[830] | 29 | // |
---|
| 30 | // |
---|
| 31 | // John Allison 23rd October 1996 |
---|
| 32 | |
---|
| 33 | #include "G4VisAttributes.hh" |
---|
| 34 | |
---|
| 35 | #include "G4AttValue.hh" |
---|
| 36 | |
---|
| 37 | G4VisAttributes::G4VisAttributes (): |
---|
| 38 | fVisible (true), |
---|
| 39 | fDaughtersInvisible (false), |
---|
| 40 | fColour (G4Colour ()), |
---|
| 41 | fLineStyle (unbroken), |
---|
| 42 | fLineWidth (1.), |
---|
| 43 | fForceDrawingStyle (false), |
---|
| 44 | fForceAuxEdgeVisible (false), |
---|
| 45 | fForcedLineSegmentsPerCircle (0), // <=0 means not forced. |
---|
| 46 | fStartTime (-DBL_MAX), |
---|
| 47 | fEndTime (DBL_MAX), |
---|
| 48 | fAttValues (0), |
---|
| 49 | fAttDefs (0) |
---|
| 50 | {} |
---|
| 51 | |
---|
| 52 | G4VisAttributes::G4VisAttributes (G4bool visibility): |
---|
| 53 | fVisible (visibility), |
---|
| 54 | fDaughtersInvisible (false), |
---|
| 55 | fColour (G4Colour ()), |
---|
| 56 | fLineStyle (unbroken), |
---|
| 57 | fLineWidth (1.), |
---|
| 58 | fForceDrawingStyle (false), |
---|
| 59 | fForceAuxEdgeVisible (false), |
---|
| 60 | fForcedLineSegmentsPerCircle (0), // <=0 means not forced. |
---|
| 61 | fStartTime (-DBL_MAX), |
---|
| 62 | fEndTime (DBL_MAX), |
---|
| 63 | fAttValues (0), |
---|
| 64 | fAttDefs (0) |
---|
| 65 | {} |
---|
| 66 | |
---|
| 67 | G4VisAttributes::G4VisAttributes (const G4Colour& colour): |
---|
| 68 | fVisible (true), |
---|
| 69 | fDaughtersInvisible (false), |
---|
| 70 | fColour (colour), |
---|
| 71 | fLineStyle (unbroken), |
---|
| 72 | fLineWidth (1.), |
---|
| 73 | fForceDrawingStyle (false), |
---|
| 74 | fForceAuxEdgeVisible (false), |
---|
| 75 | fForcedLineSegmentsPerCircle (0), // <=0 means not forced. |
---|
| 76 | fStartTime (-DBL_MAX), |
---|
| 77 | fEndTime (DBL_MAX), |
---|
| 78 | fAttValues (0), |
---|
| 79 | fAttDefs (0) |
---|
| 80 | {} |
---|
| 81 | |
---|
| 82 | G4VisAttributes::G4VisAttributes (G4bool visibility, |
---|
| 83 | const G4Colour& colour): |
---|
| 84 | fVisible (visibility), |
---|
| 85 | fDaughtersInvisible (false), |
---|
| 86 | fColour (colour), |
---|
| 87 | fLineStyle (unbroken), |
---|
| 88 | fLineWidth (1.), |
---|
| 89 | fForceDrawingStyle (false), |
---|
| 90 | fForcedLineSegmentsPerCircle (0), // <=0 means not forced. |
---|
| 91 | fStartTime (-DBL_MAX), |
---|
| 92 | fEndTime (DBL_MAX), |
---|
| 93 | fAttValues (0), |
---|
| 94 | fAttDefs (0) |
---|
| 95 | {} |
---|
| 96 | |
---|
| 97 | const G4VisAttributes G4VisAttributes::Invisible = G4VisAttributes (false); |
---|
| 98 | |
---|
| 99 | const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const { |
---|
| 100 | // Create an expendable copy on the heap... |
---|
| 101 | return new std::vector<G4AttValue>(*fAttValues); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | void 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 | |
---|
| 116 | std::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 | |
---|
| 175 | G4bool 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 | |
---|
| 200 | G4bool G4VisAttributes::operator == (const G4VisAttributes& a) const { |
---|
| 201 | return !(G4VisAttributes::operator != (a)); |
---|
| 202 | } |
---|