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: G4AxesModel.cc,v 1.5 2001/08/14 18:43:29 johna Exp $ >> 25 // GEANT4 tag $Name: geant4-04-00 $ 27 // 26 // 28 // 27 // 29 // John Allison 3rd April 2001 28 // John Allison 3rd April 2001 30 // Model which knows how to draw axes. 29 // Model which knows how to draw axes. 31 30 32 #include "G4AxesModel.hh" 31 #include "G4AxesModel.hh" 33 32 34 #include "G4ModelingParameters.hh" 33 #include "G4ModelingParameters.hh" 35 #include "G4VGraphicsScene.hh" 34 #include "G4VGraphicsScene.hh" 36 #include "G4VisAttributes.hh" 35 #include "G4VisAttributes.hh" 37 #include "G4Polyline.hh" 36 #include "G4Polyline.hh" 38 #include "G4Colour.hh" 37 #include "G4Colour.hh" 39 #include "G4UnitsTable.hh" << 40 #include "G4ArrowModel.hh" << 41 #include "G4TextModel.hh" << 42 << 43 G4AxesModel::~G4AxesModel () << 44 { << 45 delete fZAnnotationModel; << 46 delete fZLabelModel; << 47 delete fZAxisModel; << 48 delete fYAnnotationModel; << 49 delete fYLabelModel; << 50 delete fYAxisModel; << 51 delete fXAnnotationModel; << 52 delete fXLabelModel; << 53 delete fXAxisModel; << 54 } << 55 38 56 G4AxesModel::G4AxesModel << 39 G4AxesModel::~G4AxesModel () {} 57 (G4double x0, G4double y0, G4double z0, G4doub << 58 G4double arrowWidth, const G4String& colourSt << 59 const G4String& description, << 60 G4bool withAnnotation, << 61 G4double textSize, << 62 const G4Transform3D& transform) << 63 { << 64 Construct << 65 (x0,y0,z0,length,arrowWidth, << 66 colourString,description,withAnnotation,tex << 67 transform); << 68 } << 69 40 70 // Alternative short constructor << 71 G4AxesModel::G4AxesModel 41 G4AxesModel::G4AxesModel 72 (G4double x0, G4double y0, G4double z0, G4doub << 42 (G4double x0, G4double y0, G4double z0, G4double length): 73 const G4Transform3D& transform) << 43 fX0(x0), fY0(y0), fZ0(z0), fLength(length) { 74 { << 44 fGlobalTag = "G4AxesModel"; 75 G4double arrowWidth = 1.; << 45 fGlobalDescription = fGlobalTag; 76 const G4String& colourString = "auto"; << 77 const G4String& description = ""; << 78 G4bool withAnnotation = true; << 79 G4double textSize = 10.; << 80 Construct << 81 (x0,y0,z0,length,arrowWidth, << 82 colourString,description,withAnnotation,tex << 83 transform); << 84 } 46 } 85 47 86 void G4AxesModel::Construct << 48 void G4AxesModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler) { 87 (G4double x0, G4double y0, G4double z0, G4doub << 49 88 G4double arrowWidth, const G4String& colourSt << 50 G4Polyline x_axis, y_axis, z_axis; 89 const G4String& description, << 51 90 G4bool withAnnotation, << 52 G4Colour cx(1.0, 0.0, 0.0); // color for x-axis 91 G4double textSize, << 53 G4Colour cy(0.0, 1.0, 0.0); // color for y-axis 92 const G4Transform3D& transform) << 54 G4Colour cz(0.0, 0.0, 1.0); // color for z-axis 93 { << 55 94 fXAxisModel = nullptr; << 56 G4VisAttributes ax(cx); // VA for x-axis 95 fXLabelModel = nullptr; << 57 G4VisAttributes ay(cy); // VA for y-axis 96 fXAnnotationModel = nullptr; << 58 G4VisAttributes az(cz); // VA for z-axis 97 fYAxisModel = nullptr; << 59 98 fYLabelModel = nullptr; << 60 sceneHandler.BeginPrimitives(); 99 fYAnnotationModel = nullptr; << 61 100 fZAxisModel = nullptr; << 62 //----- Draw x-axis 101 fZLabelModel = nullptr; << 63 x_axis.SetVisAttributes(&ax); 102 fZAnnotationModel = nullptr; << 64 x_axis.push_back(G4Point3D(fX0,fY0,fZ0)); 103 << 65 x_axis.push_back(G4Point3D((fX0 + fLength),fY0,fZ0)); 104 fTransform = transform; << 66 sceneHandler.AddPrimitive(x_axis); 105 << 67 106 fType = "Axes"; << 68 //----- Draw y-axis 107 fGlobalTag = fType; << 69 y_axis.SetVisAttributes(&ay); 108 fGlobalDescription = fType + ": " + descript << 70 y_axis.push_back(G4Point3D(fX0,fY0,fZ0)); 109 fExtent = G4VisExtent << 71 y_axis.push_back(G4Point3D(fX0,(fY0 + fLength),fZ0)); 110 (x0, x0+length, y0, y0+length, z0, z0+leng << 72 sceneHandler.AddPrimitive(y_axis); 111 << 73 112 G4Colour colour(1,1,1,1); // Default white << 74 //----- Draw z-axis 113 G4bool autoColour = false; << 75 z_axis.SetVisAttributes(&az); 114 if (colourString == "auto") autoColour = tru << 76 z_axis.push_back(G4Point3D(fX0,fY0,fZ0)); 115 else { << 77 z_axis.push_back(G4Point3D(fX0,fY0,(fZ0 + fLength))); 116 if (!G4Colour::GetColour(colourString, col << 78 sceneHandler.AddPrimitive(z_axis); 117 G4ExceptionDescription ed; << 118 ed << "Colour \"" << colourString << 119 << "\" not found. Defaulting to white and << 120 G4Exception << 121 ("G4AxesModel::G4AxesModel", << 122 "modeling0011", JustWarning, ed); << 123 } << 124 } << 125 << 126 G4String annotation = G4BestUnit(length,"Len << 127 G4int lineSegmentsPerCircle = 6; << 128 << 129 G4Colour xColour(colour); << 130 if (autoColour) xColour = G4Colour::Red(); << 131 fXAxisModel = new G4ArrowModel << 132 (x0, y0, z0, x0+length, y0, z0, arrowWidth << 133 xColour, "x-axis: " + description, << 134 lineSegmentsPerCircle, fTransform); << 135 if (withAnnotation) { << 136 G4VisAttributes va(xColour); << 137 G4Text lmtext("x",G4Point3D(x0+1.05*length << 138 lmtext.SetScreenSize(textSize); << 139 lmtext.SetOffset(0.5*textSize,0.5*textSize << 140 lmtext.SetLayout(G4Text::centre); << 141 lmtext.SetVisAttributes(va); << 142 fXLabelModel = new G4TextModel(lmtext,fTra << 143 G4Text amtext(annotation,G4Point3D(x0+0.8* << 144 amtext.SetScreenSize(textSize); << 145 amtext.SetOffset(-1.5*textSize,-1.5*textSi << 146 amtext.SetLayout(G4Text::centre); << 147 amtext.SetVisAttributes(va); << 148 fXAnnotationModel = new G4TextModel(amtext << 149 } << 150 << 151 G4Colour yColour(colour); << 152 if (autoColour) yColour = G4Colour::Green(); << 153 fYAxisModel = new G4ArrowModel << 154 (x0, y0, z0, x0, y0+length, z0, arrowWidth << 155 yColour, "y-axis: " + description, << 156 lineSegmentsPerCircle, fTransform); << 157 if (withAnnotation) { << 158 G4VisAttributes va(yColour); << 159 G4Text lmtext("y",G4Point3D(x0,y0+1.05*len << 160 lmtext.SetScreenSize(textSize); << 161 lmtext.SetOffset(0.5*textSize,0.5*textSize << 162 lmtext.SetLayout(G4Text::centre); << 163 lmtext.SetVisAttributes(va); << 164 fYLabelModel = new G4TextModel(lmtext,fTra << 165 G4Text amtext(annotation,G4Point3D(x0,y0+0 << 166 amtext.SetScreenSize(textSize); << 167 amtext.SetOffset(-1.5*textSize,-1.5*textSi << 168 amtext.SetLayout(G4Text::centre); << 169 amtext.SetVisAttributes(va); << 170 fYAnnotationModel = new G4TextModel(amtext << 171 } << 172 << 173 G4Colour zColour(colour); << 174 if (autoColour) zColour = G4Colour::Blue(); << 175 fZAxisModel = new G4ArrowModel << 176 (x0, y0, z0, x0, y0, z0+length, arrowWidth << 177 zColour, "z-axis: " + description, << 178 lineSegmentsPerCircle, fTransform); << 179 if (withAnnotation) { << 180 G4VisAttributes va(zColour); << 181 G4Text lmtext("z",G4Point3D(x0,y0,z0+1.05* << 182 lmtext.SetScreenSize(textSize); << 183 lmtext.SetOffset(0.5*textSize,0.5*textSize << 184 lmtext.SetLayout(G4Text::centre); << 185 lmtext.SetVisAttributes(va); << 186 fZLabelModel = new G4TextModel(lmtext,fTra << 187 G4Text amtext(annotation,G4Point3D(x0,y0,z << 188 amtext.SetScreenSize(textSize); << 189 amtext.SetOffset(-1.5*textSize,-1.5*textSi << 190 amtext.SetLayout(G4Text::centre); << 191 amtext.SetVisAttributes(va); << 192 fZAnnotationModel = new G4TextModel(amtext << 193 } << 194 } << 195 79 196 void G4AxesModel::DescribeYourselfTo (G4VGraph << 80 sceneHandler.EndPrimitives(); 197 { << 198 if (fXAxisModel) fXAxisModel-> De << 199 if (fXLabelModel) fXLabelModel-> De << 200 if (fXAnnotationModel) fXAnnotationModel->De << 201 << 202 if (fYAxisModel) fYAxisModel-> De << 203 if (fYLabelModel) fYLabelModel-> De << 204 if (fYAnnotationModel) fYAnnotationModel->De << 205 << 206 if (fZAxisModel) fZAxisModel-> De << 207 if (fZLabelModel) fZLabelModel-> De << 208 if (fZAnnotationModel) fZAnnotationModel->De << 209 } 81 } 210 82