00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "G4VisAttributes.hh"
00033
00034 #include "G4AttValue.hh"
00035 #include "G4AttDef.hh"
00036
00037 G4VisAttributes::G4VisAttributes (const G4VisAttributes& va):
00038 fVisible (va.fVisible),
00039 fDaughtersInvisible (va.fDaughtersInvisible),
00040 fColour (va.fColour),
00041 fLineStyle (va.fLineStyle),
00042 fLineWidth (va.fLineWidth),
00043 fForceDrawingStyle (va.fForceDrawingStyle),
00044 fForcedStyle (va.fForcedStyle),
00045 fForceAuxEdgeVisible (va.fForceAuxEdgeVisible),
00046 fForcedLineSegmentsPerCircle (va.fForcedLineSegmentsPerCircle),
00047 fStartTime (va.fStartTime),
00048 fEndTime (va.fEndTime),
00049
00050
00051
00052 fAttValues (va.fAttValues),
00053
00054
00055 fAttDefs (va.fAttDefs)
00056 {}
00057
00058 G4VisAttributes::G4VisAttributes ():
00059 fVisible (true),
00060 fDaughtersInvisible (false),
00061 fColour (G4Colour ()),
00062 fLineStyle (unbroken),
00063 fLineWidth (1.),
00064 fForceDrawingStyle (false),
00065 fForcedStyle (wireframe),
00066 fForceAuxEdgeVisible (false),
00067 fForcedLineSegmentsPerCircle (0),
00068 fStartTime (-DBL_MAX),
00069 fEndTime (DBL_MAX),
00070 fAttValues (0),
00071 fAttDefs (0)
00072 {}
00073
00074 G4VisAttributes::G4VisAttributes (G4bool visibility):
00075 fVisible (visibility),
00076 fDaughtersInvisible (false),
00077 fColour (G4Colour ()),
00078 fLineStyle (unbroken),
00079 fLineWidth (1.),
00080 fForceDrawingStyle (false),
00081 fForcedStyle (wireframe),
00082 fForceAuxEdgeVisible (false),
00083 fForcedLineSegmentsPerCircle (0),
00084 fStartTime (-DBL_MAX),
00085 fEndTime (DBL_MAX),
00086 fAttValues (0),
00087 fAttDefs (0)
00088 {}
00089
00090 G4VisAttributes::G4VisAttributes (const G4Colour& colour):
00091 fVisible (true),
00092 fDaughtersInvisible (false),
00093 fColour (colour),
00094 fLineStyle (unbroken),
00095 fLineWidth (1.),
00096 fForceDrawingStyle (false),
00097 fForcedStyle (wireframe),
00098 fForceAuxEdgeVisible (false),
00099 fForcedLineSegmentsPerCircle (0),
00100 fStartTime (-DBL_MAX),
00101 fEndTime (DBL_MAX),
00102 fAttValues (0),
00103 fAttDefs (0)
00104 {}
00105
00106 G4VisAttributes::G4VisAttributes (G4bool visibility,
00107 const G4Colour& colour):
00108 fVisible (visibility),
00109 fDaughtersInvisible (false),
00110 fColour (colour),
00111 fLineStyle (unbroken),
00112 fLineWidth (1.),
00113 fForceDrawingStyle (false),
00114 fForcedStyle (wireframe),
00115 fForceAuxEdgeVisible (false),
00116 fForcedLineSegmentsPerCircle (0),
00117 fStartTime (-DBL_MAX),
00118 fEndTime (DBL_MAX),
00119 fAttValues (0),
00120 fAttDefs (0)
00121 {}
00122
00123 G4VisAttributes::~G4VisAttributes()
00124 {
00125 }
00126
00127 G4VisAttributes& G4VisAttributes::operator= (const G4VisAttributes& rhs)
00128 {
00129 if (&rhs == this) return *this;
00130 fVisible = rhs.fVisible;
00131 fDaughtersInvisible = rhs.fDaughtersInvisible;
00132 fColour = rhs.fColour;
00133 fLineStyle = rhs.fLineStyle;
00134 fLineWidth = rhs.fLineWidth;
00135 fForceDrawingStyle = rhs.fForceDrawingStyle;
00136 fForcedStyle = rhs.fForcedStyle;
00137 fForceAuxEdgeVisible = rhs.fForceAuxEdgeVisible;
00138 fForcedLineSegmentsPerCircle = rhs.fForcedLineSegmentsPerCircle;
00139 fStartTime = rhs.fStartTime;
00140 fEndTime = rhs.fEndTime;
00141
00142
00143
00144 fAttValues = rhs.fAttValues;
00145
00146
00147 fAttDefs = rhs.fAttDefs;
00148 return *this;
00149 }
00150
00151 const G4VisAttributes G4VisAttributes::Invisible = G4VisAttributes (false);
00152
00153 const std::vector<G4AttValue>* G4VisAttributes::CreateAttValues () const {
00154
00155 return new std::vector<G4AttValue>(*fAttValues);
00156 }
00157
00158 void G4VisAttributes::SetForceLineSegmentsPerCircle (G4int nSegments) {
00159 const G4int nSegmentsMin = 12;
00160 if (nSegments > 0 && nSegments < nSegmentsMin) {
00161 nSegments = nSegmentsMin;
00162 G4cout <<
00163 "G4VisAttributes::SetForcedLineSegmentsPerCircle: attempt to set the"
00164 "\nnumber of line segements per circle < " << nSegmentsMin
00165 << "; forced to " << nSegments << G4endl;
00166 }
00167 fForcedLineSegmentsPerCircle = nSegments;
00168 }
00169
00170 std::ostream& operator << (std::ostream& os, const G4VisAttributes& a) {
00171
00172 os << "G4VisAttributes: ";
00173 if (&a){
00174 if (!a.fVisible) os << "in";
00175 os << "visible, daughters ";
00176 if (a.fDaughtersInvisible) os << "in";
00177 os << "visible, colour: " << a.fColour;
00178 os << "\n linestyle: ";
00179 switch (a.fLineStyle) {
00180 case G4VisAttributes::unbroken:
00181 os << "solid"; break;
00182 case G4VisAttributes::dashed:
00183 os << "dashed"; break;
00184 case G4VisAttributes::dotted: os << "dotted"; break;
00185 default: os << "unrecognised"; break;
00186 }
00187 os << ", line width: " << a.fLineWidth;
00188 os << "\n drawing style: ";
00189 if (a.fForceDrawingStyle) {
00190 os << "forced to: ";
00191 switch (a.fForcedStyle) {
00192 case G4VisAttributes::wireframe:
00193 os << "wireframe"; break;
00194 case G4VisAttributes::solid:
00195 os << "solid"; break;
00196 default: os << "unrecognised"; break;
00197 }
00198 }
00199 else {
00200 os << "not forced";
00201 }
00202 os << ", auxiliary edge visibility: ";
00203 if (!a.fForceAuxEdgeVisible) {
00204 os << "not ";
00205 }
00206 os << "forced";
00207 os << "\n line segments per circle: ";
00208 if (a.fForcedLineSegmentsPerCircle > 0) {
00209 os << "forced to " << a.fForcedLineSegmentsPerCircle;
00210 } else {
00211 os << "not forced.";
00212 }
00213 os << "\n time range: (" << a.fStartTime << ',' << a.fEndTime << ')';
00214 os << "\n G4AttValue pointer is ";
00215 if (a.fAttValues) {
00216 os << "non-";
00217 }
00218 os << "zero";
00219 os << ", G4AttDef pointer is ";
00220 if (a.fAttDefs) {
00221 os << "non-";
00222 }
00223 os << "zero";
00224 }
00225 else os << " zero G4VisAttributes pointer";
00226 return os;
00227 }
00228
00229 G4bool G4VisAttributes::operator != (const G4VisAttributes& a) const {
00230
00231 if (
00232 (fVisible != a.fVisible) ||
00233 (fDaughtersInvisible != a.fDaughtersInvisible) ||
00234 (fColour != a.fColour) ||
00235 (fLineStyle != a.fLineStyle) ||
00236 (fLineWidth != a.fLineWidth) ||
00237 (fForceDrawingStyle != a.fForceDrawingStyle) ||
00238 (fForceAuxEdgeVisible!= a.fForceAuxEdgeVisible)||
00239 (fForcedLineSegmentsPerCircle != a.fForcedLineSegmentsPerCircle) ||
00240 (fStartTime != a.fStartTime) ||
00241 (fEndTime != a.fEndTime) ||
00242 (fAttValues != a.fAttValues) ||
00243 (fAttDefs != a.fAttDefs)
00244 )
00245 return true;
00246
00247 if (fForceDrawingStyle) {
00248 if (fForcedStyle != a.fForcedStyle) return true;
00249 }
00250
00251 return false;
00252 }
00253
00254 G4bool G4VisAttributes::operator == (const G4VisAttributes& a) const {
00255 return !(G4VisAttributes::operator != (a));
00256 }