Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenInventor/src/G4OpenInventorSceneHandler.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 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/OpenInventor/src/G4OpenInventorSceneHandler.cc (Version 11.3.0) and /visualization/OpenInventor/src/G4OpenInventorSceneHandler.cc (Version 10.3)


  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: G4OpenInventorSceneHandler.cc 66373 2012-12-18 09:41:34Z gcosmo $
 27 //                                                 28 //
 28 //                                                 29 // 
 29 // Jeff Kallenbach 01 Aug 1996                     30 // Jeff Kallenbach 01 Aug 1996
 30 // OpenInventor stored scene - creates OpenInv     31 // OpenInventor stored scene - creates OpenInventor display lists.
                                                   >>  32 #ifdef G4VIS_BUILD_OI_DRIVER
 31                                                    33 
 32 // this :                                          34 // this :
 33 #include "G4OpenInventorSceneHandler.hh"           35 #include "G4OpenInventorSceneHandler.hh"
 34                                                    36 
 35 #include <Inventor/SoPath.h>                       37 #include <Inventor/SoPath.h>
 36 #include <Inventor/SoNodeKitPath.h>                38 #include <Inventor/SoNodeKitPath.h>
 37 #include <Inventor/nodes/SoCoordinate3.h>          39 #include <Inventor/nodes/SoCoordinate3.h>
 38 #include <Inventor/nodes/SoCoordinate4.h>          40 #include <Inventor/nodes/SoCoordinate4.h>
 39 #include <Inventor/nodes/SoSeparator.h>            41 #include <Inventor/nodes/SoSeparator.h>
 40 #include <Inventor/nodes/SoDrawStyle.h>            42 #include <Inventor/nodes/SoDrawStyle.h>
 41 #include <Inventor/nodes/SoLightModel.h>           43 #include <Inventor/nodes/SoLightModel.h>
 42 #include <Inventor/nodes/SoMaterial.h>             44 #include <Inventor/nodes/SoMaterial.h>
 43 #include <Inventor/nodes/SoLineSet.h>              45 #include <Inventor/nodes/SoLineSet.h>
 44 #include <Inventor/nodes/SoCube.h>                 46 #include <Inventor/nodes/SoCube.h>
 45 #include <Inventor/nodes/SoFont.h>                 47 #include <Inventor/nodes/SoFont.h>
 46 #include <Inventor/nodes/SoText2.h>                48 #include <Inventor/nodes/SoText2.h>
 47 #include <Inventor/nodes/SoFaceSet.h>              49 #include <Inventor/nodes/SoFaceSet.h>
 48 #include <Inventor/nodes/SoNormal.h>               50 #include <Inventor/nodes/SoNormal.h>
 49 #include <Inventor/nodes/SoNormalBinding.h>        51 #include <Inventor/nodes/SoNormalBinding.h>
 50 #include <Inventor/nodes/SoComplexity.h>           52 #include <Inventor/nodes/SoComplexity.h>
 51 #include <Inventor/nodes/SoTranslation.h>          53 #include <Inventor/nodes/SoTranslation.h>
 52 #include <Inventor/nodes/SoTransform.h>            54 #include <Inventor/nodes/SoTransform.h>
 53 #include <Inventor/nodes/SoResetTransform.h>       55 #include <Inventor/nodes/SoResetTransform.h>
 54 #include <Inventor/nodes/SoMatrixTransform.h>      56 #include <Inventor/nodes/SoMatrixTransform.h>
 55                                                    57 
 56 #define USE_SOPOLYHEDRON                           58 #define USE_SOPOLYHEDRON
 57                                                    59 
 58 #ifndef USE_SOPOLYHEDRON                           60 #ifndef USE_SOPOLYHEDRON
 59 #include "HEPVis/nodes/SoBox.h"                    61 #include "HEPVis/nodes/SoBox.h"
 60 #include "HEPVis/nodes/SoTubs.h"                   62 #include "HEPVis/nodes/SoTubs.h"
 61 #include "HEPVis/nodes/SoCons.h"                   63 #include "HEPVis/nodes/SoCons.h"
 62 #include "HEPVis/nodes/SoTrd.h"                    64 #include "HEPVis/nodes/SoTrd.h"
 63 #include "HEPVis/nodes/SoTrap.h"                   65 #include "HEPVis/nodes/SoTrap.h"
 64 #endif                                             66 #endif
 65 #include "HEPVis/nodes/SoMarkerSet.h"              67 #include "HEPVis/nodes/SoMarkerSet.h"
 66                                                <<  68 typedef HEPVis_SoMarkerSet SoMarkerSet;
 67 using SoMarkerSet = HEPVis_SoMarkerSet;        << 
 68                                                << 
 69 #include "HEPVis/nodekits/SoDetectorTreeKit.h"     69 #include "HEPVis/nodekits/SoDetectorTreeKit.h"
 70 #include "HEPVis/misc/SoStyleCache.h"              70 #include "HEPVis/misc/SoStyleCache.h"
 71                                                    71 
 72 #include "SoG4Polyhedron.h"                        72 #include "SoG4Polyhedron.h"
 73 #include "SoG4LineSet.h"                           73 #include "SoG4LineSet.h"
 74 #include "SoG4MarkerSet.h"                         74 #include "SoG4MarkerSet.h"
 75                                                    75 
 76 #include "G4Scene.hh"                              76 #include "G4Scene.hh"
 77 #include "G4OpenInventor.hh"                       77 #include "G4OpenInventor.hh"
 78 #include "G4OpenInventorTransform3D.hh"            78 #include "G4OpenInventorTransform3D.hh"
 79 #include "G4ThreeVector.hh"                        79 #include "G4ThreeVector.hh"
 80 #include "G4Point3D.hh"                            80 #include "G4Point3D.hh"
 81 #include "G4Normal3D.hh"                           81 #include "G4Normal3D.hh"
 82 #include "G4Transform3D.hh"                        82 #include "G4Transform3D.hh"
 83 #include "G4Polyline.hh"                           83 #include "G4Polyline.hh"
 84 #include "G4Text.hh"                               84 #include "G4Text.hh"
 85 #include "G4Circle.hh"                             85 #include "G4Circle.hh"
 86 #include "G4Square.hh"                             86 #include "G4Square.hh"
 87 #include "G4Polymarker.hh"                         87 #include "G4Polymarker.hh"
 88 #include "G4Polyhedron.hh"                         88 #include "G4Polyhedron.hh"
 89 #include "G4Box.hh"                                89 #include "G4Box.hh"
 90 #include "G4Tubs.hh"                               90 #include "G4Tubs.hh"
 91 #include "G4Cons.hh"                               91 #include "G4Cons.hh"
 92 #include "G4Trap.hh"                               92 #include "G4Trap.hh"
 93 #include "G4Trd.hh"                                93 #include "G4Trd.hh"
 94 #include "G4ModelingParameters.hh"                 94 #include "G4ModelingParameters.hh"
 95 #include "G4VPhysicalVolume.hh"                    95 #include "G4VPhysicalVolume.hh"
 96 #include "G4LogicalVolume.hh"                      96 #include "G4LogicalVolume.hh"
 97 #include "G4Material.hh"                           97 #include "G4Material.hh"
 98 #include "G4VisAttributes.hh"                      98 #include "G4VisAttributes.hh"
 99                                                    99 
100 #define G4warn G4cout                          << 
101                                                << 
102 G4int G4OpenInventorSceneHandler::fSceneIdCoun    100 G4int G4OpenInventorSceneHandler::fSceneIdCount = 0;
103                                                   101 
104 G4OpenInventorSceneHandler::G4OpenInventorScen    102 G4OpenInventorSceneHandler::G4OpenInventorSceneHandler (G4OpenInventor& system,
105                                           cons    103                                           const G4String& name)
106 :G4VSceneHandler (system, fSceneIdCount++, nam    104 :G4VSceneHandler (system, fSceneIdCount++, name)
107 ,fRoot(0)                                         105 ,fRoot(0)
108 ,fDetectorRoot(0)                                 106 ,fDetectorRoot(0)
109 ,fTransientRoot(0)                                107 ,fTransientRoot(0)
110 ,fCurrentSeparator(0)                             108 ,fCurrentSeparator(0)
111 ,fModelingSolid(false)                            109 ,fModelingSolid(false)
112 ,fReducedWireFrame(true)                          110 ,fReducedWireFrame(true)
113 ,fStyleCache(0)                                   111 ,fStyleCache(0)
114 ,fPreviewAndFull(true)                            112 ,fPreviewAndFull(true)
115 {                                                 113 {
116   fStyleCache = new SoStyleCache;                 114   fStyleCache = new SoStyleCache;
117   fStyleCache->ref();                             115   fStyleCache->ref();
118                                                   116 
119   fRoot = new SoSeparator;                        117   fRoot = new SoSeparator;
120   fRoot->ref();                                   118   fRoot->ref();
121   fRoot->setName("Root");                         119   fRoot->setName("Root");
122                                                   120   
123   fDetectorRoot = new SoSeparator;                121   fDetectorRoot = new SoSeparator;
124   fDetectorRoot->setName("StaticRoot");           122   fDetectorRoot->setName("StaticRoot");
125   fRoot->addChild(fDetectorRoot);                 123   fRoot->addChild(fDetectorRoot);
126                                                   124   
127   fTransientRoot = new SoSeparator;               125   fTransientRoot = new SoSeparator;
128   fTransientRoot->setName("TransientRoot");       126   fTransientRoot->setName("TransientRoot");
129   fRoot->addChild(fTransientRoot);                127   fRoot->addChild(fTransientRoot);
130                                                   128   
131   fCurrentSeparator = fTransientRoot;             129   fCurrentSeparator = fTransientRoot;
132 }                                                 130 }
133                                                   131 
134 G4OpenInventorSceneHandler::~G4OpenInventorSce    132 G4OpenInventorSceneHandler::~G4OpenInventorSceneHandler ()
135 {                                                 133 {
136   fRoot->unref();                                 134   fRoot->unref();
137   fStyleCache->unref();                           135   fStyleCache->unref();
138 }                                                 136 }
139                                                   137 
140 void G4OpenInventorSceneHandler::ClearStore ()    138 void G4OpenInventorSceneHandler::ClearStore ()
141 {                                                 139 {
142   fDetectorRoot->removeAllChildren();             140   fDetectorRoot->removeAllChildren();
143   fSeparatorMap.clear();                          141   fSeparatorMap.clear();
144                                                   142 
145   fTransientRoot->removeAllChildren();            143   fTransientRoot->removeAllChildren();
146 }                                                 144 }
147                                                   145 
148 void G4OpenInventorSceneHandler::ClearTransien    146 void G4OpenInventorSceneHandler::ClearTransientStore ()
149 {                                                 147 {
150   fTransientRoot->removeAllChildren();            148   fTransientRoot->removeAllChildren();
151 }                                                 149 }
152                                                   150 
153 //                                                151 //
154 // Generates prerequisites for solids             152 // Generates prerequisites for solids
155 //                                                153 //  
156 void G4OpenInventorSceneHandler::PreAddSolid      154 void G4OpenInventorSceneHandler::PreAddSolid
157 (const G4Transform3D& objectTransformation,       155 (const G4Transform3D& objectTransformation,
158  const G4VisAttributes& visAttribs)               156  const G4VisAttributes& visAttribs)
159 {                                                 157 {
160   G4VSceneHandler::PreAddSolid (objectTransfor    158   G4VSceneHandler::PreAddSolid (objectTransformation, visAttribs);
161   // Stores arguments away for future use, e.g    159   // Stores arguments away for future use, e.g., AddPrimitives.
162                                                   160 
163   GeneratePrerequisites();                        161   GeneratePrerequisites();
164 }                                                 162 }
165                                                   163 
166 //                                                164 //
167 // Generates prerequisites for primitives         165 // Generates prerequisites for primitives
168 //                                                166 //  
169 void G4OpenInventorSceneHandler::BeginPrimitiv    167 void G4OpenInventorSceneHandler::BeginPrimitives
170 (const G4Transform3D& objectTransformation) {     168 (const G4Transform3D& objectTransformation) {
171                                                   169 
172   G4VSceneHandler::BeginPrimitives (objectTran    170   G4VSceneHandler::BeginPrimitives (objectTransformation);
173                                                   171 
174   // If thread of control has already passed t    172   // If thread of control has already passed through PreAddSolid,
175   // avoid opening a graphical data base compo    173   // avoid opening a graphical data base component again.
176   if (!fProcessingSolid) {                        174   if (!fProcessingSolid) {
177     GeneratePrerequisites();                      175     GeneratePrerequisites();
178   }                                               176   }
179 }                                                 177 }
180                                                   178 
181 //                                                179 //
182 // Method for handling G4Polyline objects (fro    180 // Method for handling G4Polyline objects (from tracking).
183 //                                                181 //
184 void G4OpenInventorSceneHandler::AddPrimitive     182 void G4OpenInventorSceneHandler::AddPrimitive (const G4Polyline& line)
185 {                                                 183 {
186   if (fProcessing2D) {                            184   if (fProcessing2D) {
187     static G4bool warned = false;                 185     static G4bool warned = false;
188     if (!warned) {                                186     if (!warned) {
189       warned = true;                              187       warned = true;
190       G4Exception                                 188       G4Exception
191   ("G4OpenInventorSceneHandler::AddPrimitive (    189   ("G4OpenInventorSceneHandler::AddPrimitive (const G4Polyline&)",
192    "OpenInventor-0001", JustWarning,              190    "OpenInventor-0001", JustWarning,
193    "2D polylines not implemented.  Ignored.");    191    "2D polylines not implemented.  Ignored.");
194     }                                             192     }
195     return;                                       193     return;
196   }                                               194   }
197                                                   195 
198   // Get vis attributes - pick up defaults if     196   // Get vis attributes - pick up defaults if none.
199   const G4VisAttributes* pVA =                    197   const G4VisAttributes* pVA =
200   fpViewer -> GetApplicableVisAttributes (line    198   fpViewer -> GetApplicableVisAttributes (line.GetVisAttributes ());
201                                                   199   
202   AddProperties(pVA);  // Colour, etc.            200   AddProperties(pVA);  // Colour, etc.
203   AddTransform();      // Transformation          201   AddTransform();      // Transformation
204                                                   202 
205   G4int nPoints = (G4int)line.size();          << 203   G4int nPoints = line.size();
206   SbVec3f* pCoords = new SbVec3f[nPoints];        204   SbVec3f* pCoords = new SbVec3f[nPoints];
207                                                   205 
208   for (G4int iPoint = 0; iPoint < nPoints ; ++ << 206   for (G4int iPoint = 0; iPoint < nPoints ; iPoint++) {
209     pCoords[iPoint].setValue((G4float)line[iPo << 207     pCoords[iPoint].setValue((float)line[iPoint].x(),
210                              (G4float)line[iPo << 208                              (float)line[iPoint].y(),
211                              (G4float)line[iPo << 209                              (float)line[iPoint].z());
212   }                                               210   }
213                                                   211 
214   //                                              212   //
215   // Point Set                                    213   // Point Set
216   //                                              214   // 
217   SoCoordinate3 *polyCoords = new SoCoordinate    215   SoCoordinate3 *polyCoords = new SoCoordinate3;
218   polyCoords->point.setValues(0,nPoints,pCoord    216   polyCoords->point.setValues(0,nPoints,pCoords);
219   fCurrentSeparator->addChild(polyCoords);        217   fCurrentSeparator->addChild(polyCoords);
220                                                   218   
221   //                                              219   //
222   // Wireframe                                    220   // Wireframe
223   //                                              221   // 
224   SoDrawStyle* drawStyle = fStyleCache->getLin    222   SoDrawStyle* drawStyle = fStyleCache->getLineStyle();
225   fCurrentSeparator->addChild(drawStyle);         223   fCurrentSeparator->addChild(drawStyle);
226                                                   224 
227   SoG4LineSet *pLine = new SoG4LineSet;           225   SoG4LineSet *pLine = new SoG4LineSet;
228                                                   226 
229   // Loads G4Atts for picking...                  227   // Loads G4Atts for picking...
230   if (fpViewer->GetViewParameters().IsPicking(    228   if (fpViewer->GetViewParameters().IsPicking()) LoadAtts(line, pLine);
231                                                   229 
232 #ifdef INVENTOR2_0                                230 #ifdef INVENTOR2_0
233   pLine->numVertices.setValues(0,1,(const G4lo << 231   pLine->numVertices.setValues(0,1,(const long *)&nPoints);
234 #else                                             232 #else 
235   pLine->numVertices.setValues(0,1,&nPoints);     233   pLine->numVertices.setValues(0,1,&nPoints);
236 #endif                                            234 #endif
237                                                   235 
238   fCurrentSeparator->addChild(pLine);             236   fCurrentSeparator->addChild(pLine);
239                                                   237 
240   delete [] pCoords;                              238   delete [] pCoords;
241 }                                                 239 }
242                                                   240 
243 void G4OpenInventorSceneHandler::AddPrimitive     241 void G4OpenInventorSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
244 {                                                 242 {
245   if (fProcessing2D) {                            243   if (fProcessing2D) {
246     static G4bool warned = false;                 244     static G4bool warned = false;
247     if (!warned) {                                245     if (!warned) {
248       warned = true;                              246       warned = true;
249       G4Exception                                 247       G4Exception
250   ("G4OpenInventorSceneHandler::AddPrimitive (    248   ("G4OpenInventorSceneHandler::AddPrimitive (const G4Polymarker&)",
251    "OpenInventor-0002", JustWarning,              249    "OpenInventor-0002", JustWarning,
252    "2D polymarkers not implemented.  Ignored."    250    "2D polymarkers not implemented.  Ignored.");
253     }                                             251     }
254     return;                                       252     return;
255   }                                               253   }
256                                                   254 
257   // Get vis attributes - pick up defaults if     255   // Get vis attributes - pick up defaults if none.
258   const G4VisAttributes* pVA =                    256   const G4VisAttributes* pVA =
259   fpViewer -> GetApplicableVisAttributes (poly    257   fpViewer -> GetApplicableVisAttributes (polymarker.GetVisAttributes ());
260                                                   258 
261   AddProperties(pVA);  // Colour, etc.            259   AddProperties(pVA);  // Colour, etc.
262   AddTransform();      // Transformation          260   AddTransform();      // Transformation
263                                                   261 
264   G4int pointn = (G4int)polymarker.size();     << 262   G4int pointn = polymarker.size();
265   if(pointn<=0) return;                           263   if(pointn<=0) return;
266                                                   264 
267   SbVec3f* points = new SbVec3f[pointn];          265   SbVec3f* points = new SbVec3f[pointn];
268   for (G4int iPoint = 0; iPoint < pointn ; ++i << 266   for (G4int iPoint = 0; iPoint < pointn ; iPoint++) {
269     points[iPoint].setValue((G4float)polymarke << 267     points[iPoint].setValue((float)polymarker[iPoint].x(),
270                             (G4float)polymarke << 268                             (float)polymarker[iPoint].y(),
271                             (G4float)polymarke << 269                             (float)polymarker[iPoint].z());
272   }                                               270   }
273                                                   271 
274   SoCoordinate3* coordinate3 = new SoCoordinat    272   SoCoordinate3* coordinate3 = new SoCoordinate3;
275   coordinate3->point.setValues(0,pointn,points    273   coordinate3->point.setValues(0,pointn,points);
276   fCurrentSeparator->addChild(coordinate3);       274   fCurrentSeparator->addChild(coordinate3);
277                                                   275 
278   MarkerSizeType sizeType;                        276   MarkerSizeType sizeType;
279   G4double screenSize = GetMarkerSize (polymar    277   G4double screenSize = GetMarkerSize (polymarker, sizeType);
280   switch (sizeType) {                             278   switch (sizeType) {
281   default:                                        279   default:
282   case screen:                                    280   case screen:
283     // Draw in screen coordinates.  OK.           281     // Draw in screen coordinates.  OK.
284     break;                                        282     break;
285   case world:                                     283   case world:
286     // Draw in world coordinates.   Not implem    284     // Draw in world coordinates.   Not implemented.  Use screenSize = 10.
287     screenSize = 10.;                             285     screenSize = 10.;
288     break;                                        286     break;
289   }                                               287   }
290                                                   288   
291   SoG4MarkerSet* markerSet = new SoG4MarkerSet    289   SoG4MarkerSet* markerSet = new SoG4MarkerSet;
292   markerSet->numPoints = pointn;                  290   markerSet->numPoints = pointn;
293                                                   291 
294   // Loads G4Atts for picking...                  292   // Loads G4Atts for picking...
295   if (fpViewer->GetViewParameters().IsPicking(    293   if (fpViewer->GetViewParameters().IsPicking())
296     LoadAtts(polymarker, markerSet);              294     LoadAtts(polymarker, markerSet);
297                                                   295 
298   G4VMarker::FillStyle style = polymarker.GetF    296   G4VMarker::FillStyle style = polymarker.GetFillStyle();
299   switch (polymarker.GetMarkerType()) {           297   switch (polymarker.GetMarkerType()) {
300   default:                                        298   default:
301     // Are available 5_5, 7_7 and 9_9             299     // Are available 5_5, 7_7 and 9_9
302   case G4Polymarker::dots:                        300   case G4Polymarker::dots:
303     if (screenSize <= 5.) {                       301     if (screenSize <= 5.) {
304       markerSet->markerIndex = SoMarkerSet::CI    302       markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_5_5;
305     } else if (screenSize <= 7.) {                303     } else if (screenSize <= 7.) {
306       markerSet->markerIndex = SoMarkerSet::CI    304       markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_7_7;
307     } else {                                      305     } else {
308       markerSet->markerIndex = SoMarkerSet::CI    306       markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_9_9;
309     }                                             307     }
310     break;                                        308     break;
311   case G4Polymarker::circles:                     309   case G4Polymarker::circles:
312     if (screenSize <= 5.) {                       310     if (screenSize <= 5.) {
313       if (style == G4VMarker::filled) {           311       if (style == G4VMarker::filled) {
314   markerSet->markerIndex = SoMarkerSet::CIRCLE    312   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_5_5;
315       } else {                                    313       } else {
316   markerSet->markerIndex = SoMarkerSet::CIRCLE    314   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_5_5;
317       }                                           315       }
318     } else if (screenSize <= 7.) {                316     } else if (screenSize <= 7.) {
319       if (style == G4VMarker::filled) {           317       if (style == G4VMarker::filled) {
320   markerSet->markerIndex = SoMarkerSet::CIRCLE    318   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_7_7;
321       } else {                                    319       } else {
322   markerSet->markerIndex = SoMarkerSet::CIRCLE    320   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_7_7;
323       }                                           321       }
324     } else {                                      322     } else {
325       if (style == G4VMarker::filled) {           323       if (style == G4VMarker::filled) {
326   markerSet->markerIndex = SoMarkerSet::CIRCLE    324   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_9_9;
327       } else {                                    325       } else {
328   markerSet->markerIndex = SoMarkerSet::CIRCLE    326   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_9_9;
329       }                                           327       }
330     }                                             328     }
331     break;                                        329     break;
332   case G4Polymarker::squares:                     330   case G4Polymarker::squares:
333     if (screenSize <= 5.) {                       331     if (screenSize <= 5.) {
334       if (style == G4VMarker::filled) {           332       if (style == G4VMarker::filled) {
335   markerSet->markerIndex = SoMarkerSet::SQUARE    333   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_5_5;
336       } else {                                    334       } else {
337   markerSet->markerIndex = SoMarkerSet::SQUARE    335   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_5_5;
338       }                                           336       }
339     } else if (screenSize <= 7.) {                337     } else if (screenSize <= 7.) {
340       if (style == G4VMarker::filled) {           338       if (style == G4VMarker::filled) {
341   markerSet->markerIndex = SoMarkerSet::SQUARE    339   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_7_7;
342       } else {                                    340       } else {
343   markerSet->markerIndex = SoMarkerSet::SQUARE    341   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_7_7;
344       }                                           342       }
345     } else {                                      343     } else {
346       if (style == G4VMarker::filled) {           344       if (style == G4VMarker::filled) {
347   markerSet->markerIndex = SoMarkerSet::SQUARE    345   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_9_9;
348       } else {                                    346       } else {
349   markerSet->markerIndex = SoMarkerSet::SQUARE    347   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_9_9;
350       }                                           348       }
351     }                                             349     }
352   }                                               350   }
353   fCurrentSeparator->addChild(markerSet);         351   fCurrentSeparator->addChild(markerSet);
354                                                   352 
355   delete [] points;                               353   delete [] points;
356 }                                                 354 }
357                                                   355 
358 // Method for handling G4Text objects             356 // Method for handling G4Text objects
359 //                                                357 //
360 void G4OpenInventorSceneHandler::AddPrimitive     358 void G4OpenInventorSceneHandler::AddPrimitive (const G4Text& text)
361 {                                                 359 {
362   if (fProcessing2D) {                            360   if (fProcessing2D) {
363     static G4bool warned = false;                 361     static G4bool warned = false;
364     if (!warned) {                                362     if (!warned) {
365       warned = true;                              363       warned = true;
366       G4Exception                                 364       G4Exception
367   ("G4OpenInventorSceneHandler::AddPrimitive (    365   ("G4OpenInventorSceneHandler::AddPrimitive (const G4Text&)",
368    "OpenInventor-0003", JustWarning,              366    "OpenInventor-0003", JustWarning,
369    "2D text not implemented.  Ignored.");         367    "2D text not implemented.  Ignored.");
370     }                                             368     }
371     return;                                       369     return;
372   }                                               370   }
373                                                   371 
374   AddProperties(text.GetVisAttributes());  //     372   AddProperties(text.GetVisAttributes());  // Colour, etc.
375   AddTransform(text.GetPosition());        //     373   AddTransform(text.GetPosition());        // Transformation
376                                                   374 
377   //                                              375   //
378   // Color.  Note: text colour is worked out d    376   // Color.  Note: text colour is worked out differently.  This
379   // over-rides the colour added in AddPropert    377   // over-rides the colour added in AddProperties...
380   //                                              378   //
381   const G4Colour& c = GetTextColour (text);       379   const G4Colour& c = GetTextColour (text);
382   SoMaterial* material =                          380   SoMaterial* material = 
383     fStyleCache->getMaterial((G4float)c.GetRed << 381     fStyleCache->getMaterial((float)c.GetRed(),
384                              (G4float)c.GetGre << 382                              (float)c.GetGreen(),
385                              (G4float)c.GetBlu << 383                              (float)c.GetBlue(),
386                              (G4float)(1-c.Get << 384                              (float)(1-c.GetAlpha()));
387   fCurrentSeparator->addChild(material);          385   fCurrentSeparator->addChild(material);
388                                                   386 
389   MarkerSizeType sizeType;                        387   MarkerSizeType sizeType;
390   G4double size = GetMarkerSize (text, sizeTyp    388   G4double size = GetMarkerSize (text, sizeType);
391   switch (sizeType) {                             389   switch (sizeType) {
392   default:                                        390   default:
393   case screen:                                    391   case screen:
394     // Draw in screen coordinates.  OK.           392     // Draw in screen coordinates.  OK.
395     break;                                        393     break;
396   case world:                                     394   case world:
397     // Draw in world coordinates.   Not implem    395     // Draw in world coordinates.   Not implemented.  Use size = 20.
398     size = 20.;                                   396     size = 20.;
399     break;                                        397     break;
400   }                                               398   }
401                                                   399 
402   //                                              400   //
403   // Font                                         401   // Font
404   //                                              402   // 
405   SoFont *g4Font = new SoFont();                  403   SoFont *g4Font = new SoFont();
406   g4Font->size = size;                            404   g4Font->size = size;
407   fCurrentSeparator->addChild(g4Font);            405   fCurrentSeparator->addChild(g4Font);
408                                                   406 
409   //                                              407   //
410   // Text                                         408   // Text
411   //                                              409   // 
412   SoText2 *g4String = new SoText2();              410   SoText2 *g4String = new SoText2();
413   g4String->string.setValue(text.GetText());      411   g4String->string.setValue(text.GetText());
414   g4String->spacing = 2.0;                        412   g4String->spacing = 2.0;
415   switch (text.GetLayout()) {                     413   switch (text.GetLayout()) {
416   default:                                        414   default:
417   case G4Text::left:                              415   case G4Text::left:
418     g4String->justification = SoText2::LEFT; b    416     g4String->justification = SoText2::LEFT; break;
419   case G4Text::centre:                            417   case G4Text::centre:
420     g4String->justification = SoText2::CENTER;    418     g4String->justification = SoText2::CENTER; break;
421   case G4Text::right:                             419   case G4Text::right:
422     g4String->justification = SoText2::RIGHT;     420     g4String->justification = SoText2::RIGHT; break;
423   }                                               421   }
424   fCurrentSeparator->addChild(g4String);          422   fCurrentSeparator->addChild(g4String);
425 }                                                 423 }
426                                                   424 
427 //                                                425 //
428 // Method for handling G4Circle objects           426 // Method for handling G4Circle objects
429 //                                                427 //
430 void G4OpenInventorSceneHandler::AddPrimitive     428 void G4OpenInventorSceneHandler::AddPrimitive (const G4Circle& circle) {
431   AddCircleSquare(G4OICircle, circle);            429   AddCircleSquare(G4OICircle, circle);
432 }                                                 430 }
433                                                   431 
434 //                                                432 //
435 // Method for handling G4Square objects - defa    433 // Method for handling G4Square objects - defaults to wireframe
436 //                                                434 //
437 void G4OpenInventorSceneHandler::AddPrimitive     435 void G4OpenInventorSceneHandler::AddPrimitive (const G4Square& square) {
438   AddCircleSquare(G4OISquare, square);            436   AddCircleSquare(G4OISquare, square);
439 }                                                 437 }
440                                                   438 
441 void G4OpenInventorSceneHandler::AddCircleSqua    439 void G4OpenInventorSceneHandler::AddCircleSquare
442 (G4OIMarker markerType, const G4VMarker& marke    440 (G4OIMarker markerType, const G4VMarker& marker)
443 {                                                 441 {
444   if (fProcessing2D) {                            442   if (fProcessing2D) {
445     static G4bool warned = false;                 443     static G4bool warned = false;
446     if (!warned) {                                444     if (!warned) {
447       warned = true;                              445       warned = true;
448       G4Exception                                 446       G4Exception
449   ("G4OpenInventorSceneHandler::AddCircleSquar    447   ("G4OpenInventorSceneHandler::AddCircleSquare",
450    "OpenInventor-0004", JustWarning,              448    "OpenInventor-0004", JustWarning,
451    "2D circles and squares not implemented.  I    449    "2D circles and squares not implemented.  Ignored.");
452     }                                             450     }
453     return;                                       451     return;
454   }                                               452   }
455                                                   453 
456   // Get vis attributes - pick up defaults if     454   // Get vis attributes - pick up defaults if none.
457   const G4VisAttributes* pVA =                    455   const G4VisAttributes* pVA =
458   fpViewer -> GetApplicableVisAttributes (mark    456   fpViewer -> GetApplicableVisAttributes (marker.GetVisAttributes ());
459                                                   457 
460   AddProperties(pVA);  // Colour, etc.            458   AddProperties(pVA);  // Colour, etc.
461   AddTransform();      // Transformation          459   AddTransform();      // Transformation
462                                                   460 
463   MarkerSizeType sizeType;                        461   MarkerSizeType sizeType;
464   G4double screenSize = GetMarkerSize (marker,    462   G4double screenSize = GetMarkerSize (marker, sizeType);
465   switch (sizeType) {                             463   switch (sizeType) {
466   default:                                        464   default:
467   case screen:                                    465   case screen:
468     // Draw in screen coordinates.  OK.           466     // Draw in screen coordinates.  OK.
469     break;                                        467     break;
470   case world:                                     468   case world:
471     // Draw in world coordinates.   Not implem    469     // Draw in world coordinates.   Not implemented.  Use size = 10.
472     screenSize = 10.;                             470     screenSize = 10.;
473     break;                                        471     break;
474   }                                               472   }
475                                                   473 
476   G4Point3D centre = marker.GetPosition();        474   G4Point3D centre = marker.GetPosition();
477                                                   475 
478   // Borrowed from AddPrimitive(G4Polymarker)     476   // Borrowed from AddPrimitive(G4Polymarker) - inefficient? JA
479   SbVec3f* points = new SbVec3f[1];               477   SbVec3f* points = new SbVec3f[1];
480   points[0].setValue((G4float)centre.x(),      << 478   points[0].setValue((float)centre.x(),
481          (G4float)centre.y(),                  << 479          (float)centre.y(),
482          (G4float)centre.z());                 << 480          (float)centre.z());
483   SoCoordinate3* coordinate3 = new SoCoordinat    481   SoCoordinate3* coordinate3 = new SoCoordinate3;
484   coordinate3->point.setValues(0,1,points);       482   coordinate3->point.setValues(0,1,points);
485   fCurrentSeparator->addChild(coordinate3);       483   fCurrentSeparator->addChild(coordinate3);
486                                                   484 
487   SoG4MarkerSet* markerSet = new SoG4MarkerSet    485   SoG4MarkerSet* markerSet = new SoG4MarkerSet;
488   markerSet->numPoints = 1;                       486   markerSet->numPoints = 1;
489                                                   487 
490   // Loads G4Atts for picking...                  488   // Loads G4Atts for picking...
491   if (fpViewer->GetViewParameters().IsPicking(    489   if (fpViewer->GetViewParameters().IsPicking()) LoadAtts(marker, markerSet);
492                                                   490 
493   G4VMarker::FillStyle style = marker.GetFillS    491   G4VMarker::FillStyle style = marker.GetFillStyle();
494   switch (markerType) {                           492   switch (markerType) {
495   case G4OICircle:                                493   case G4OICircle:
496     if (screenSize <= 5.) {                       494     if (screenSize <= 5.) {
497       if (style == G4VMarker::filled) {           495       if (style == G4VMarker::filled) {
498   markerSet->markerIndex = SoMarkerSet::CIRCLE    496   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_5_5;
499       } else {                                    497       } else {
500   markerSet->markerIndex = SoMarkerSet::CIRCLE    498   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_5_5;
501       }                                           499       }
502     } else if (screenSize <= 7.) {                500     } else if (screenSize <= 7.) {
503       if (style == G4VMarker::filled) {           501       if (style == G4VMarker::filled) {
504   markerSet->markerIndex = SoMarkerSet::CIRCLE    502   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_7_7;
505       } else {                                    503       } else {
506   markerSet->markerIndex = SoMarkerSet::CIRCLE    504   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_7_7;
507       }                                           505       }
508     } else {                                      506     } else {
509       if (style == G4VMarker::filled) {           507       if (style == G4VMarker::filled) {
510   markerSet->markerIndex = SoMarkerSet::CIRCLE    508   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_9_9;
511       } else {                                    509       } else {
512   markerSet->markerIndex = SoMarkerSet::CIRCLE    510   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_9_9;
513       }                                           511       }
514     }                                             512     }
515     break;                                        513     break;
516   case G4OISquare:                                514   case G4OISquare:
517     if (screenSize <= 5.) {                       515     if (screenSize <= 5.) {
518       if (style == G4VMarker::filled) {           516       if (style == G4VMarker::filled) {
519   markerSet->markerIndex = SoMarkerSet::SQUARE    517   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_5_5;
520       } else {                                    518       } else {
521   markerSet->markerIndex = SoMarkerSet::SQUARE    519   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_5_5;
522       }                                           520       }
523     } else if (screenSize <= 7.) {                521     } else if (screenSize <= 7.) {
524       if (style == G4VMarker::filled) {           522       if (style == G4VMarker::filled) {
525   markerSet->markerIndex = SoMarkerSet::SQUARE    523   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_7_7;
526       } else {                                    524       } else {
527   markerSet->markerIndex = SoMarkerSet::SQUARE    525   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_7_7;
528       }                                           526       }
529     } else {                                      527     } else {
530       if (style == G4VMarker::filled) {           528       if (style == G4VMarker::filled) {
531   markerSet->markerIndex = SoMarkerSet::SQUARE    529   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_9_9;
532       } else {                                    530       } else {
533   markerSet->markerIndex = SoMarkerSet::SQUARE    531   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_9_9;
534       }                                           532       }
535     }                                             533     }
536   break;                                          534   break;
537   }                                               535   }
538   fCurrentSeparator->addChild(markerSet);         536   fCurrentSeparator->addChild(markerSet);
539                                                   537 
540   delete [] points;                               538   delete [] points;
541 }                                                 539 }
542                                                   540 
543 //                                                541 //
544 // Method for handling G4Polyhedron objects fo    542 // Method for handling G4Polyhedron objects for drawing solids.
545 //                                                543 //
546 void G4OpenInventorSceneHandler::AddPrimitive     544 void G4OpenInventorSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron)
547 {                                                 545 {
548   if (polyhedron.GetNoFacets() == 0) return;      546   if (polyhedron.GetNoFacets() == 0) return;
549                                                   547 
550   if (fProcessing2D) {                            548   if (fProcessing2D) {
551     static G4bool warned = false;                 549     static G4bool warned = false;
552     if (!warned) {                                550     if (!warned) {
553       warned = true;                              551       warned = true;
554       G4Exception                                 552       G4Exception
555   ("G4OpenInventorSceneHandler::AddPrimitive (    553   ("G4OpenInventorSceneHandler::AddPrimitive (const G4Polyhedron&)",
556    "OpenInventor-0005", JustWarning,              554    "OpenInventor-0005", JustWarning,
557    "2D polyhedra not implemented.  Ignored.");    555    "2D polyhedra not implemented.  Ignored.");
558     }                                             556     }
559     return;                                       557     return;
560   }                                               558   }
561                                                   559 
562   // Get vis attributes - pick up defaults if     560   // Get vis attributes - pick up defaults if none.
563   const G4VisAttributes* pVA =                    561   const G4VisAttributes* pVA =
564   fpViewer -> GetApplicableVisAttributes (poly    562   fpViewer -> GetApplicableVisAttributes (polyhedron.GetVisAttributes ());
565                                                   563 
566   AddProperties(pVA);  // Colour, etc.            564   AddProperties(pVA);  // Colour, etc.
567   AddTransform();      // Transformation          565   AddTransform();      // Transformation
568                                                   566 
569   SoG4Polyhedron* soPolyhedron = new SoG4Polyh    567   SoG4Polyhedron* soPolyhedron = new SoG4Polyhedron(polyhedron);
570                                                   568 
571   // Loads G4Atts for picking...                  569   // Loads G4Atts for picking...
572   if (fpViewer->GetViewParameters().IsPicking(    570   if (fpViewer->GetViewParameters().IsPicking())
573     LoadAtts(polyhedron, soPolyhedron);           571     LoadAtts(polyhedron, soPolyhedron);
574                                                   572 
575   SbString name = "Non-geometry";                 573   SbString name = "Non-geometry";
576   G4PhysicalVolumeModel* pPVModel =               574   G4PhysicalVolumeModel* pPVModel =
577     dynamic_cast<G4PhysicalVolumeModel*>(fpMod    575     dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
578   if (pPVModel) {                                 576   if (pPVModel) {
579     name = pPVModel->GetCurrentLV()->GetName()    577     name = pPVModel->GetCurrentLV()->GetName().c_str();
580   }                                               578   }
581   SbName sbName(name);                            579   SbName sbName(name);
582   soPolyhedron->setName(sbName);                  580   soPolyhedron->setName(sbName);
583   soPolyhedron->solid.setValue(fModelingSolid)    581   soPolyhedron->solid.setValue(fModelingSolid);
584   soPolyhedron->reducedWireFrame.setValue(fRed    582   soPolyhedron->reducedWireFrame.setValue(fReducedWireFrame?TRUE:FALSE);
585   fCurrentSeparator->addChild(soPolyhedron);      583   fCurrentSeparator->addChild(soPolyhedron);  
586 }                                                 584 }
587                                                   585 
588 void G4OpenInventorSceneHandler::AddCompound(c << 
589   StandardSpecialMeshRendering(mesh);          << 
590 }                                              << 
591                                                << 
592 void G4OpenInventorSceneHandler::GeneratePrere    586 void G4OpenInventorSceneHandler::GeneratePrerequisites()
593 {                                                 587 {
594   // Utility for PreAddSolid and BeginPrimitiv    588   // Utility for PreAddSolid and BeginPrimitives.
595                                                   589 
596   // This routines prepares for adding items t    590   // This routines prepares for adding items to the scene database.  We
597   // are expecting two kinds of solids: leaf p    591   // are expecting two kinds of solids: leaf parts and non-leaf parts.
598   // For non-leaf parts, we create a detector     592   // For non-leaf parts, we create a detector tree kit.  This has two
599   // separators.  The solid itself goes in the    593   // separators.  The solid itself goes in the preview separator, the
600   // full separator is forseen for daughters.     594   // full separator is forseen for daughters.  This separator is not
601   // only created--it is also put in a diction    595   // only created--it is also put in a dictionary for future use by
602   // the leaf part.                               596   // the leaf part.
603                                                   597 
604   // For leaf parts, we first locate the mothe    598   // For leaf parts, we first locate the mother volume and find its
605   // separator through the dictionary.            599   // separator through the dictionary.
606                                                   600 
607   // The private member fCurrentSeparator is s    601   // The private member fCurrentSeparator is set to the proper
608   // location on in the scene database so that    602   // location on in the scene database so that when the solid is
609   // actually added (in addthis), it is put in    603   // actually added (in addthis), it is put in the right place.
610                                                   604 
611   G4PhysicalVolumeModel* pPVModel =               605   G4PhysicalVolumeModel* pPVModel =
612     dynamic_cast<G4PhysicalVolumeModel*>(fpMod    606     dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
613                                                   607   
614   if (pPVModel) {                                 608   if (pPVModel) {
615                                                   609 
616     // This call comes from a G4PhysicalVolume    610     // This call comes from a G4PhysicalVolumeModel.  drawnPVPath is
617     // the path of the current drawn (non-cull    611     // the path of the current drawn (non-culled) volume in terms of
618     // drawn (non-culled) ancestors.  Each nod << 612     // drawn (non-culled) ancesters.  Each node is identified by a
619     // PVNodeID object, which is a physical vo    613     // PVNodeID object, which is a physical volume and copy number.  It
620     // is a vector of PVNodeIDs corresponding     614     // is a vector of PVNodeIDs corresponding to the geometry hierarchy
621     // actually selected, i.e., not culled.       615     // actually selected, i.e., not culled.
622     using PVNodeID = G4PhysicalVolumeModel::G4 << 616     typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID;
623     using PVPath = std::vector<PVNodeID>;      << 617     typedef std::vector<PVNodeID> PVPath;
624     const PVPath& drawnPVPath = pPVModel->GetD    618     const PVPath& drawnPVPath = pPVModel->GetDrawnPVPath();
625     //G4int currentDepth = pPVModel->GetCurren    619     //G4int currentDepth = pPVModel->GetCurrentDepth();
626     G4VPhysicalVolume* pCurrentPV = pPVModel->    620     G4VPhysicalVolume* pCurrentPV = pPVModel->GetCurrentPV();
627     G4LogicalVolume* pCurrentLV = pPVModel->Ge    621     G4LogicalVolume* pCurrentLV = pPVModel->GetCurrentLV();
628     //G4Material* pCurrentMaterial = pPVModel-    622     //G4Material* pCurrentMaterial = pPVModel->GetCurrentMaterial();
629     // Note: pCurrentMaterial may be zero (par    623     // Note: pCurrentMaterial may be zero (parallel world).
630                                                   624 
631     // The simplest algorithm, used by the Ope    625     // The simplest algorithm, used by the Open Inventor Driver
632     // developers, is to rely on the fact the     626     // developers, is to rely on the fact the G4PhysicalVolumeModel
633     // traverses the geometry hierarchy in an     627     // traverses the geometry hierarchy in an orderly manner.  The last
634     // mother, if any, will be the node to whi    628     // mother, if any, will be the node to which the volume should be
635     // added.  So it is enough to keep a map o    629     // added.  So it is enough to keep a map of scene graph nodes keyed
636     // on the volume path ID.  Actually, it is    630     // on the volume path ID.  Actually, it is enough to use the logical
637     // volume as the key.  (An alternative wou    631     // volume as the key.  (An alternative would be to keep the PVNodeID
638     // in the tree and match the PVPath from t    632     // in the tree and match the PVPath from the root down.)
639                                                   633 
640     // Find mother.  ri points to mother, if a    634     // Find mother.  ri points to mother, if any...
641     PVPath::const_reverse_iterator ri;            635     PVPath::const_reverse_iterator ri;
642     G4LogicalVolume* MotherVolume = 0;            636     G4LogicalVolume* MotherVolume = 0;
643     ri = ++drawnPVPath.rbegin();                  637     ri = ++drawnPVPath.rbegin();
644     if (ri != drawnPVPath.rend()) {               638     if (ri != drawnPVPath.rend()) {
645       // This volume has a mother.                639       // This volume has a mother.
646       MotherVolume = ri->GetPhysicalVolume()->    640       MotherVolume = ri->GetPhysicalVolume()->GetLogicalVolume();
647     }                                             641     }
648                                                   642 
649     if (pCurrentLV->GetNoDaughters()!=0 ||        643     if (pCurrentLV->GetNoDaughters()!=0 ||
650   pCurrentPV->IsReplicated()) {  //????Don't u    644   pCurrentPV->IsReplicated()) {  //????Don't understand this???? JA
651       // This block of code is executed for no    645       // This block of code is executed for non-leaf parts:
652                                                   646 
653       // Make the detector tree kit:              647       // Make the detector tree kit:
654       SoDetectorTreeKit* detectorTreeKit = new    648       SoDetectorTreeKit* detectorTreeKit = new SoDetectorTreeKit();  
655                                                   649 
656       SoSeparator* previewSeparator   =           650       SoSeparator* previewSeparator   =  
657   (SoSeparator*) detectorTreeKit->getPart("pre    651   (SoSeparator*) detectorTreeKit->getPart("previewSeparator",TRUE);
658       previewSeparator->renderCaching = SoSepa    652       previewSeparator->renderCaching = SoSeparator::OFF;
659                                                   653 
660       SoSeparator* fullSeparator =                654       SoSeparator* fullSeparator =  
661   (SoSeparator*) detectorTreeKit->getPart("ful    655   (SoSeparator*) detectorTreeKit->getPart("fullSeparator",   TRUE);
662       fullSeparator->renderCaching = SoSeparat    656       fullSeparator->renderCaching = SoSeparator::OFF;
663                                                   657 
664       if(fPreviewAndFull) detectorTreeKit->set    658       if(fPreviewAndFull) detectorTreeKit->setPreviewAndFull();
665       else detectorTreeKit->setPreview(TRUE);     659       else detectorTreeKit->setPreview(TRUE);
666                                                   660 
667       // Colour, etc., for SoDetectorTreeKit.     661       // Colour, etc., for SoDetectorTreeKit.  Treated differently to
668       // othere SoNodes(?).  Use fpVisAttribs     662       // othere SoNodes(?).  Use fpVisAttribs stored away in
669       // PreAddSolid...                           663       // PreAddSolid...
670       const G4VisAttributes* pApplicableVisAtt    664       const G4VisAttributes* pApplicableVisAttribs =
671   fpViewer->GetApplicableVisAttributes (fpVisA    665   fpViewer->GetApplicableVisAttributes (fpVisAttribs);
672                                                   666 
673       // First find the color attributes...       667       // First find the color attributes...
674       const G4Colour& g4Col =  pApplicableVisA    668       const G4Colour& g4Col =  pApplicableVisAttribs->GetColour ();
675       const G4double red = g4Col.GetRed ();    << 669       const double red = g4Col.GetRed ();
676       const G4double green = g4Col.GetGreen () << 670       const double green = g4Col.GetGreen ();
677       const G4double blue = g4Col.GetBlue ();  << 671       const double blue = g4Col.GetBlue ();
678       G4double transparency = 1 - g4Col.GetAlp << 672       double transparency = 1 - g4Col.GetAlpha();
679                                                   673 
680       // Drawing style...                         674       // Drawing style...
681       G4ViewParameters::DrawingStyle drawing_s    675       G4ViewParameters::DrawingStyle drawing_style =
682   GetDrawingStyle(pApplicableVisAttribs);         676   GetDrawingStyle(pApplicableVisAttribs);
683       switch (drawing_style) {                    677       switch (drawing_style) {
684       case (G4ViewParameters::wireframe):         678       case (G4ViewParameters::wireframe):    
685   fModelingSolid = false;                         679   fModelingSolid = false;
686   break;                                          680   break;
687       case (G4ViewParameters::hlr):               681       case (G4ViewParameters::hlr):
688       case (G4ViewParameters::hsr):               682       case (G4ViewParameters::hsr):
689       case (G4ViewParameters::hlhsr):             683       case (G4ViewParameters::hlhsr):
690   fModelingSolid = true;                          684   fModelingSolid = true;
691   break;                                          685   break;
692       case (G4ViewParameters::cloud):          << 
693         fModelingSolid = false;                << 
694         break;                                 << 
695       }                                           686       }
696                                                   687 
697       SoMaterial* material =                      688       SoMaterial* material = 
698   fStyleCache->getMaterial((G4float)red,       << 689   fStyleCache->getMaterial((float)red,
699          (G4float)green,                       << 690          (float)green,
700          (G4float)blue,                        << 691          (float)blue,
701          (G4float)transparency);               << 692          (float)transparency);
702       detectorTreeKit->setPart("appearance.mat    693       detectorTreeKit->setPart("appearance.material",material);
703                                                   694 
704       SoLightModel* lightModel =                  695       SoLightModel* lightModel = 
705   fModelingSolid ? fStyleCache->getLightModelP    696   fModelingSolid ? fStyleCache->getLightModelPhong() : 
706   fStyleCache->getLightModelBaseColor();          697   fStyleCache->getLightModelBaseColor();
707       detectorTreeKit->setPart("appearance.lig    698       detectorTreeKit->setPart("appearance.lightModel",lightModel);
708                                                   699 
709       // Add the full separator to the diction    700       // Add the full separator to the dictionary; it is indexed by the 
710       // address of the logical volume!           701       // address of the logical volume!
711       fSeparatorMap[pCurrentLV] = fullSeparato    702       fSeparatorMap[pCurrentLV] = fullSeparator;
712                                                   703 
713       // Find out where to add this volume.       704       // Find out where to add this volume.
714       // If no mother can be found, it goes un    705       // If no mother can be found, it goes under root.
715       if (MotherVolume) {                         706       if (MotherVolume) {
716   if (fSeparatorMap.find(MotherVolume) != fSep    707   if (fSeparatorMap.find(MotherVolume) != fSeparatorMap.end()) {
717     //printf("debug : PreAddSolid : mother %s     708     //printf("debug : PreAddSolid : mother %s found in map\n",
718     //     MotherVolume->GetName().c_str());      709     //     MotherVolume->GetName().c_str());
719     fSeparatorMap[MotherVolume]->addChild(dete    710     fSeparatorMap[MotherVolume]->addChild(detectorTreeKit);
720   } else {                                        711   } else {
721     // Mother not previously encountered.  Sho    712     // Mother not previously encountered.  Shouldn't happen, since
722     // G4PhysicalVolumeModel sends volumes as     713     // G4PhysicalVolumeModel sends volumes as it encounters them,
723     // i.e., mothers before daughters, in its     714     // i.e., mothers before daughters, in its descent of the
724     // geometry tree.  Error!                     715     // geometry tree.  Error!
725     G4warn <<                                  << 716     G4cout <<
726       "ERROR: G4OpenInventorSceneHandler::Gene    717       "ERROR: G4OpenInventorSceneHandler::GeneratePrerequisites: Mother "
727      << ri->GetPhysicalVolume()->GetName()        718      << ri->GetPhysicalVolume()->GetName()
728      << ':' << ri->GetCopyNo()                    719      << ':' << ri->GetCopyNo()
729      << " not previously encountered."            720      << " not previously encountered."
730       "\nShouldn't happen!  Please report to v    721       "\nShouldn't happen!  Please report to visualization coordinator."
731      << G4endl;                                   722      << G4endl;
732     // Continue anyway.  Add to root of scene     723     // Continue anyway.  Add to root of scene graph tree...
733     //printf("debug : PreAddSolid : mother %s     724     //printf("debug : PreAddSolid : mother %s not found in map !!!\n",
734     //     MotherVolume->GetName().c_str());      725     //     MotherVolume->GetName().c_str());
735     fDetectorRoot->addChild(detectorTreeKit);     726     fDetectorRoot->addChild(detectorTreeKit);
736   }                                               727   }
737       } else {                                    728       } else {
738   //printf("debug : PreAddSolid : has no mothe    729   //printf("debug : PreAddSolid : has no mother\n");
739   fDetectorRoot->addChild(detectorTreeKit);       730   fDetectorRoot->addChild(detectorTreeKit);
740       }                                           731       }
741                                                   732 
742       fCurrentSeparator = previewSeparator;       733       fCurrentSeparator = previewSeparator;
743                                                   734 
744     } else {                                      735     } else {
745       // This block of code is executed for le    736       // This block of code is executed for leaf parts.
746                                                   737 
747       if (MotherVolume) {                         738       if (MotherVolume) {
748   if (fSeparatorMap.find(MotherVolume) != fSep    739   if (fSeparatorMap.find(MotherVolume) != fSeparatorMap.end()) {
749     fCurrentSeparator = fSeparatorMap[MotherVo    740     fCurrentSeparator = fSeparatorMap[MotherVolume];
750   } else {                                        741   } else {
751     // Mother not previously encountered.  Sho    742     // Mother not previously encountered.  Shouldn't happen, since
752     // G4PhysicalVolumeModel sends volumes as     743     // G4PhysicalVolumeModel sends volumes as it encounters them,
753     // i.e., mothers before daughters, in its     744     // i.e., mothers before daughters, in its descent of the
754     // geometry tree.  Error!                     745     // geometry tree.  Error!
755     G4warn << "ERROR: G4OpenInventorSceneHandl << 746     G4cout << "ERROR: G4OpenInventorSceneHandler::PreAddSolid: Mother "
756      << ri->GetPhysicalVolume()->GetName()        747      << ri->GetPhysicalVolume()->GetName()
757      << ':' << ri->GetCopyNo()                    748      << ':' << ri->GetCopyNo()
758      << " not previously encountered."            749      << " not previously encountered."
759       "\nShouldn't happen!  Please report to v    750       "\nShouldn't happen!  Please report to visualization coordinator."
760      << G4endl;                                   751      << G4endl;
761     // Continue anyway.  Add to root of scene     752     // Continue anyway.  Add to root of scene graph tree...
762     fCurrentSeparator = fDetectorRoot;            753     fCurrentSeparator = fDetectorRoot;
763   }                                               754   }
764       } else {                                    755       } else {
765   fCurrentSeparator = fDetectorRoot;              756   fCurrentSeparator = fDetectorRoot;
766       }                                           757       }
767     }                                             758     }
768                                                   759 
769   } else {                                        760   } else {
770     // Not from G4PhysicalVolumeModel, so add     761     // Not from G4PhysicalVolumeModel, so add to root as leaf part...
771                                                   762 
772     if (fReadyForTransients) {                    763     if (fReadyForTransients) {
773       fCurrentSeparator = fTransientRoot;         764       fCurrentSeparator = fTransientRoot;
774     } else {                                      765     } else {
775       fCurrentSeparator = fDetectorRoot;          766       fCurrentSeparator = fDetectorRoot;
776     }                                             767     }
777   }                                               768   }
778 }                                                 769 }
779                                                   770 
780 void G4OpenInventorSceneHandler::AddProperties    771 void G4OpenInventorSceneHandler::AddProperties(const G4VisAttributes* visAtts)
781 {                                                 772 {
782   // Use the applicable vis attributes...         773   // Use the applicable vis attributes...
783   const G4VisAttributes* pApplicableVisAttribs    774   const G4VisAttributes* pApplicableVisAttribs =
784     fpViewer->GetApplicableVisAttributes (visA    775     fpViewer->GetApplicableVisAttributes (visAtts);
785                                                   776 
786   // First find the color attributes...           777   // First find the color attributes...
787   const G4Colour& g4Col =  pApplicableVisAttri    778   const G4Colour& g4Col =  pApplicableVisAttribs->GetColour ();
788   const G4double red = g4Col.GetRed ();        << 779   const double red = g4Col.GetRed ();
789   const G4double green = g4Col.GetGreen ();    << 780   const double green = g4Col.GetGreen ();
790   const G4double blue = g4Col.GetBlue ();      << 781   const double blue = g4Col.GetBlue ();
791   G4double transparency = 1 - g4Col.GetAlpha() << 782   double transparency = 1 - g4Col.GetAlpha();
792                                                   783 
793   // Drawing style...                             784   // Drawing style...
794   G4ViewParameters::DrawingStyle drawing_style    785   G4ViewParameters::DrawingStyle drawing_style =
795     GetDrawingStyle(pApplicableVisAttribs);       786     GetDrawingStyle(pApplicableVisAttribs);
796   switch (drawing_style) {                        787   switch (drawing_style) {
797   case (G4ViewParameters::wireframe):             788   case (G4ViewParameters::wireframe):    
798     fModelingSolid = false;                       789     fModelingSolid = false;
799     break;                                        790     break;
800   case (G4ViewParameters::hlr):                   791   case (G4ViewParameters::hlr):
801   case (G4ViewParameters::hsr):                   792   case (G4ViewParameters::hsr):
802   case (G4ViewParameters::hlhsr):                 793   case (G4ViewParameters::hlhsr):
803     fModelingSolid = true;                        794     fModelingSolid = true;
804     break;                                        795     break;
805   case (G4ViewParameters::cloud):              << 
806     fModelingSolid = false;                    << 
807     break;                                     << 
808   }                                               796   }
809                                                   797 
810   // Edge visibility...                           798   // Edge visibility...
811   G4bool isAuxEdgeVisible = GetAuxEdgeVisible     799   G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pApplicableVisAttribs);
812   fReducedWireFrame = !isAuxEdgeVisible;          800   fReducedWireFrame = !isAuxEdgeVisible;
813                                                   801 
814   SoMaterial* material =                          802   SoMaterial* material = 
815     fStyleCache->getMaterial((G4float)red,     << 803     fStyleCache->getMaterial((float)red,
816            (G4float)green,                     << 804            (float)green,
817            (G4float)blue,                      << 805            (float)blue,
818            (G4float)transparency);             << 806            (float)transparency);
819   fCurrentSeparator->addChild(material);          807   fCurrentSeparator->addChild(material);
820                                                   808 
821   SoLightModel* lightModel =                      809   SoLightModel* lightModel = 
822     fModelingSolid ? fStyleCache->getLightMode    810     fModelingSolid ? fStyleCache->getLightModelPhong() : 
823     fStyleCache->getLightModelBaseColor();        811     fStyleCache->getLightModelBaseColor();
824   fCurrentSeparator->addChild(lightModel);        812   fCurrentSeparator->addChild(lightModel);
825 }                                                 813 }
826                                                   814 
827 void G4OpenInventorSceneHandler::AddTransform(    815 void G4OpenInventorSceneHandler::AddTransform(const G4Point3D& translation)
828 {                                                 816 {
829   // AddTransform takes fObjectTransformation     817   // AddTransform takes fObjectTransformation and "adds" a translation.
830   // Set up the geometrical transformation for    818   // Set up the geometrical transformation for the coming
831   fCurrentSeparator->addChild(fStyleCache->get    819   fCurrentSeparator->addChild(fStyleCache->getResetTransform());
832                                                   820 
833   SoMatrixTransform* matrixTransform = new SoM    821   SoMatrixTransform* matrixTransform = new SoMatrixTransform;
834   G4OpenInventorTransform3D oiTran                822   G4OpenInventorTransform3D oiTran
835   (fObjectTransformation * G4Translate3D(trans    823   (fObjectTransformation * G4Translate3D(translation));
836   SbMatrix* sbMatrix = oiTran.GetSbMatrix();      824   SbMatrix* sbMatrix = oiTran.GetSbMatrix();
837                                                   825 
838   const G4Vector3D scale = fpViewer->GetViewPa    826   const G4Vector3D scale = fpViewer->GetViewParameters().GetScaleFactor();
839   SbMatrix sbScale;                               827   SbMatrix sbScale;
840   sbScale.setScale                                828   sbScale.setScale
841     (SbVec3f((G4float)scale.x(),(G4float)scale << 829     (SbVec3f((float)scale.x(),(float)scale.y(),(float)scale.z()));
842   sbMatrix->multRight(sbScale);                   830   sbMatrix->multRight(sbScale);
843                                                   831 
844   matrixTransform->matrix.setValue(*sbMatrix);    832   matrixTransform->matrix.setValue(*sbMatrix);
845   delete sbMatrix;                                833   delete sbMatrix;
846   fCurrentSeparator->addChild(matrixTransform)    834   fCurrentSeparator->addChild(matrixTransform);
847 }                                                 835 }
                                                   >> 836 #endif
848                                                   837