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.7.p2)


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