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[ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/modeling/src/G4AxesModel.cc (Version 11.3.0) and /visualization/modeling/src/G4AxesModel.cc (Version 10.0)


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