Geant4 Cross Reference |
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 // John Allison 19th July 1996. 29 // John Allison 19th July 1996. 30 // 30 // 31 // Class description 31 // Class description 32 // 32 // 33 // Abstract interface class for graphics scene 33 // Abstract interface class for graphics scene handlers. 34 // Inherits from G4VGraphicsScene, in the inte 34 // Inherits from G4VGraphicsScene, in the intercoms category, which is 35 // a minimal abstract interface for the GEANT4 35 // a minimal abstract interface for the GEANT4 kernel. 36 36 37 #ifndef G4VSCENEHANDLER_HH 37 #ifndef G4VSCENEHANDLER_HH 38 #define G4VSCENEHANDLER_HH 38 #define G4VSCENEHANDLER_HH 39 39 40 #include "globals.hh" 40 #include "globals.hh" 41 41 42 #include "G4VGraphicsScene.hh" 42 #include "G4VGraphicsScene.hh" 43 #include "G4ViewerList.hh" 43 #include "G4ViewerList.hh" 44 #include "G4ViewParameters.hh" 44 #include "G4ViewParameters.hh" 45 #include "G4THitsMap.hh" 45 #include "G4THitsMap.hh" 46 #include "G4PseudoScene.hh" 46 #include "G4PseudoScene.hh" 47 47 48 #include <map> << 49 << 50 class G4Scene; 48 class G4Scene; 51 class G4VGraphicsSystem; 49 class G4VGraphicsSystem; 52 class G4AttHolder; 50 class G4AttHolder; 53 51 54 class G4VSceneHandler: public G4VGraphicsScene 52 class G4VSceneHandler: public G4VGraphicsScene { 55 53 56 friend class G4VViewer; 54 friend class G4VViewer; 57 friend std::ostream& operator << (std::ostre 55 friend std::ostream& operator << (std::ostream& os, const G4VSceneHandler& s); 58 56 59 public: // With description 57 public: // With description 60 58 61 enum MarkerSizeType {world, screen}; 59 enum MarkerSizeType {world, screen}; 62 60 63 G4VSceneHandler (G4VGraphicsSystem& system, 61 G4VSceneHandler (G4VGraphicsSystem& system, 64 G4int id, 62 G4int id, 65 const G4String& name = ""); 63 const G4String& name = ""); 66 64 67 virtual ~G4VSceneHandler (); 65 virtual ~G4VSceneHandler (); 68 66 69 //////////////////////////////////////////// 67 /////////////////////////////////////////////////////////////////// 70 // Methods for adding raw GEANT4 objects to 68 // Methods for adding raw GEANT4 objects to the scene handler. They 71 // must always be called in the triplet PreA 69 // must always be called in the triplet PreAddSolid, AddSolid and 72 // PostAddSolid. The transformation and vis 70 // PostAddSolid. The transformation and visualization attributes 73 // must be set by the call to PreAddSolid. 71 // must be set by the call to PreAddSolid. If your graphics system 74 // is sophisticated enough to handle a parti 72 // is sophisticated enough to handle a particular solid shape as a 75 // primitive, in your derived class write a 73 // primitive, in your derived class write a function to override one 76 // or more of the following. See the implem 74 // or more of the following. See the implementation of 77 // G4VSceneHandler::AddSolid (const G4Box& b 75 // G4VSceneHandler::AddSolid (const G4Box& box) for more 78 // suggestions. If not, please implement th 76 // suggestions. If not, please implement the base class invocation. 79 77 80 virtual void PreAddSolid (const G4Transform3 78 virtual void PreAddSolid (const G4Transform3D& objectTransformation, 81 const G4VisAttributes&); 79 const G4VisAttributes&); 82 // objectTransformation is the transformatio 80 // objectTransformation is the transformation in the world 83 // coordinate system of the object about to 81 // coordinate system of the object about to be added, and visAttribs 84 // is its visualization attributes. 82 // is its visualization attributes. 85 // IMPORTANT: invoke this from your polymorp 83 // IMPORTANT: invoke this from your polymorphic versions, e.g.: 86 // void MyXXXSceneHandler::PreAddSolid 84 // void MyXXXSceneHandler::PreAddSolid 87 // (const G4Transform3D& objectTransformati 85 // (const G4Transform3D& objectTransformation, 88 // const G4VisAttributes& visAttribs) { 86 // const G4VisAttributes& visAttribs) { 89 // G4VSceneHandler::PreAddSolid (objectTra 87 // G4VSceneHandler::PreAddSolid (objectTransformation, visAttribs); 90 // ... 88 // ... 91 // } 89 // } 92 90 93 virtual void PostAddSolid (); 91 virtual void PostAddSolid (); 94 // IMPORTANT: invoke this from your polymorp 92 // IMPORTANT: invoke this from your polymorphic versions, e.g.: 95 // void MyXXXSceneHandler::PostAddSolid () { 93 // void MyXXXSceneHandler::PostAddSolid () { 96 // ... 94 // ... 97 // G4VSceneHandler::PostAddSolid (); 95 // G4VSceneHandler::PostAddSolid (); 98 // } 96 // } 99 97 100 // From geometry/solids/CSG 98 // From geometry/solids/CSG 101 virtual void AddSolid (const G4Box&); 99 virtual void AddSolid (const G4Box&); 102 virtual void AddSolid (const G4Cons&); 100 virtual void AddSolid (const G4Cons&); 103 virtual void AddSolid (const G4Orb&); 101 virtual void AddSolid (const G4Orb&); 104 virtual void AddSolid (const G4Para&); 102 virtual void AddSolid (const G4Para&); 105 virtual void AddSolid (const G4Sphere&); 103 virtual void AddSolid (const G4Sphere&); 106 virtual void AddSolid (const G4Torus&); 104 virtual void AddSolid (const G4Torus&); 107 virtual void AddSolid (const G4Trap&); 105 virtual void AddSolid (const G4Trap&); 108 virtual void AddSolid (const G4Trd&); 106 virtual void AddSolid (const G4Trd&); 109 virtual void AddSolid (const G4Tubs&); 107 virtual void AddSolid (const G4Tubs&); 110 108 111 // From geometry/solids/specific 109 // From geometry/solids/specific 112 virtual void AddSolid (const G4Ellipsoid&); 110 virtual void AddSolid (const G4Ellipsoid&); 113 virtual void AddSolid (const G4Polycone&); 111 virtual void AddSolid (const G4Polycone&); 114 virtual void AddSolid (const G4Polyhedra&); 112 virtual void AddSolid (const G4Polyhedra&); 115 virtual void AddSolid (const G4TessellatedSo 113 virtual void AddSolid (const G4TessellatedSolid&); 116 114 117 // For solids not above. 115 // For solids not above. 118 virtual void AddSolid (const G4VSolid&); 116 virtual void AddSolid (const G4VSolid&); 119 117 120 //////////////////////////////////////////// 118 /////////////////////////////////////////////////////////////////// 121 // Methods for adding "compound" GEANT4 obje 119 // Methods for adding "compound" GEANT4 objects to the scene 122 // handler. These methods may either (a) in 120 // handler. These methods may either (a) invoke "user code" that 123 // uses the "user interface", G4VVisManager 121 // uses the "user interface", G4VVisManager (see, for example, 124 // G4VSceneHandler, which for trajectories u 122 // G4VSceneHandler, which for trajectories uses 125 // G4VTrajectory::DrawTrajectory, via G4Traj 123 // G4VTrajectory::DrawTrajectory, via G4TrajectoriesModel in the 126 // Modeling Category) or (b) invoke AddPrimi 124 // Modeling Category) or (b) invoke AddPrimitives below (between 127 // calls to Begin/EndPrimitives) or (c) use 125 // calls to Begin/EndPrimitives) or (c) use graphics-system-specific 128 // code or (d) any combination of the above. 126 // code or (d) any combination of the above. 129 127 130 virtual void AddCompound (const G4VTrajector 128 virtual void AddCompound (const G4VTrajectory&); 131 virtual void AddCompound (const G4VHit&); 129 virtual void AddCompound (const G4VHit&); 132 virtual void AddCompound (const G4VDigi&); 130 virtual void AddCompound (const G4VDigi&); 133 virtual void AddCompound (const G4THitsMap<G 131 virtual void AddCompound (const G4THitsMap<G4double>&); 134 virtual void AddCompound (const G4THitsMap<G 132 virtual void AddCompound (const G4THitsMap<G4StatDouble>&); 135 virtual void AddCompound (const G4Mesh&); 133 virtual void AddCompound (const G4Mesh&); 136 134 137 //////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////// 138 // Functions for adding primitives. 136 // Functions for adding primitives. 139 137 140 virtual void BeginModeling (); 138 virtual void BeginModeling (); 141 // IMPORTANT: invoke this from your polymorp 139 // IMPORTANT: invoke this from your polymorphic versions, e.g.: 142 // void MyXXXSceneHandler::BeginModeling () 140 // void MyXXXSceneHandler::BeginModeling () { 143 // G4VSceneHandler::BeginModeling (); 141 // G4VSceneHandler::BeginModeling (); 144 // ... 142 // ... 145 // } 143 // } 146 144 147 virtual void EndModeling (); 145 virtual void EndModeling (); 148 // IMPORTANT: invoke this from your polymorp 146 // IMPORTANT: invoke this from your polymorphic versions, e.g.: 149 // void MyXXXSceneHandler::EndModeling () { 147 // void MyXXXSceneHandler::EndModeling () { 150 // ... 148 // ... 151 // G4VSceneHandler::EndModeling (); 149 // G4VSceneHandler::EndModeling (); 152 // } 150 // } 153 151 154 virtual void BeginPrimitives 152 virtual void BeginPrimitives 155 (const G4Transform3D& objectTransformation = 153 (const G4Transform3D& objectTransformation = G4Transform3D()); 156 // IMPORTANT: invoke this from your polymorp 154 // IMPORTANT: invoke this from your polymorphic versions, e.g.: 157 // void MyXXXSceneHandler::BeginPrimitives 155 // void MyXXXSceneHandler::BeginPrimitives 158 // (const G4Transform3D& objectTransformatio 156 // (const G4Transform3D& objectTransformation) { 159 // G4VSceneHandler::BeginPrimitives (objec 157 // G4VSceneHandler::BeginPrimitives (objectTransformation); 160 // ... 158 // ... 161 // } 159 // } 162 160 163 virtual void EndPrimitives (); 161 virtual void EndPrimitives (); 164 // IMPORTANT: invoke this from your polymorp 162 // IMPORTANT: invoke this from your polymorphic versions, e.g.: 165 // void MyXXXSceneHandler::EndPrimitives () 163 // void MyXXXSceneHandler::EndPrimitives () { 166 // ... 164 // ... 167 // G4VSceneHandler::EndPrimitives (); 165 // G4VSceneHandler::EndPrimitives (); 168 // } 166 // } 169 167 170 virtual void BeginPrimitives2D 168 virtual void BeginPrimitives2D 171 (const G4Transform3D& objectTransformation = 169 (const G4Transform3D& objectTransformation = G4Transform3D()); 172 // The x,y coordinates of the primitives pas 170 // The x,y coordinates of the primitives passed to AddPrimitive are 173 // intrepreted as screen coordinates, -1 < x 171 // intrepreted as screen coordinates, -1 < x,y < 1. The 174 // z-coordinate is ignored. 172 // z-coordinate is ignored. 175 // IMPORTANT: invoke this from your polymorp 173 // IMPORTANT: invoke this from your polymorphic versions, e.g.: 176 // void MyXXXSceneHandler::BeginPrimitives2D 174 // void MyXXXSceneHandler::BeginPrimitives2D 177 // (const G4Transform3D& objectTransformatio 175 // (const G4Transform3D& objectTransformation) { 178 // G4VSceneHandler::BeginPrimitives2D (obj 176 // G4VSceneHandler::BeginPrimitives2D (objectTransformation); 179 // ... 177 // ... 180 // } 178 // } 181 179 182 virtual void EndPrimitives2D (); 180 virtual void EndPrimitives2D (); 183 // IMPORTANT: invoke this from your polymorp 181 // IMPORTANT: invoke this from your polymorphic versions, e.g.: 184 // void MyXXXSceneHandler::EndPrimitives2D ( 182 // void MyXXXSceneHandler::EndPrimitives2D () { 185 // ... 183 // ... 186 // G4VSceneHandler::EndPrimitives2D (); 184 // G4VSceneHandler::EndPrimitives2D (); 187 // } 185 // } 188 186 189 virtual void AddPrimitive (const G4Polyline& 187 virtual void AddPrimitive (const G4Polyline&) = 0; 190 virtual void AddPrimitive (const G4Text&) 188 virtual void AddPrimitive (const G4Text&) = 0; 191 virtual void AddPrimitive (const G4Circle&) 189 virtual void AddPrimitive (const G4Circle&) = 0; 192 virtual void AddPrimitive (const G4Square&) 190 virtual void AddPrimitive (const G4Square&) = 0; 193 virtual void AddPrimitive (const G4Polymarke 191 virtual void AddPrimitive (const G4Polymarker&); 194 virtual void AddPrimitive (const G4Polyhedro 192 virtual void AddPrimitive (const G4Polyhedron&) = 0; 195 virtual void AddPrimitive (const G4Plotter&) 193 virtual void AddPrimitive (const G4Plotter&); 196 194 197 // Other virtual functions 195 // Other virtual functions 198 virtual const G4VisExtent& GetExtent() const 196 virtual const G4VisExtent& GetExtent() const; 199 197 200 //////////////////////////////////////////// 198 ////////////////////////////////////////////////////////////// 201 // Access functions. 199 // Access functions. 202 const G4String& GetName () con 200 const G4String& GetName () const; 203 G4int GetSceneHandlerId () con 201 G4int GetSceneHandlerId () const; 204 G4int GetViewCount () con 202 G4int GetViewCount () const; 205 G4VGraphicsSystem* GetGraphicsSystem () con 203 G4VGraphicsSystem* GetGraphicsSystem () const; 206 G4Scene* GetScene () con 204 G4Scene* GetScene () const; 207 const G4ViewerList& GetViewerList () con 205 const G4ViewerList& GetViewerList () const; 208 G4VModel* GetModel () con 206 G4VModel* GetModel () const; 209 G4VViewer* GetCurrentViewer () con 207 G4VViewer* GetCurrentViewer () const; 210 G4bool GetMarkForClearingTransi 208 G4bool GetMarkForClearingTransientStore () const; 211 G4bool IsReadyForTransients () 209 G4bool IsReadyForTransients () const; 212 G4bool GetTransientsDrawnThisEv 210 G4bool GetTransientsDrawnThisEvent () const; 213 G4bool GetTransientsDrawnThisRu 211 G4bool GetTransientsDrawnThisRun () const; 214 const G4Transform3D& GetObjectTransformation 212 const G4Transform3D& GetObjectTransformation () const; 215 void SetName (const 213 void SetName (const G4String&); 216 void SetCurrentViewer (G4VViewer*); 214 void SetCurrentViewer (G4VViewer*); 217 virtual void SetScene (G4Scen 215 virtual void SetScene (G4Scene*); 218 G4ViewerList& SetViewerList (); // Non-c 216 G4ViewerList& SetViewerList (); // Non-const so you can change. 219 void SetModel (G4VModel*); 217 void SetModel (G4VModel*); 220 void SetMarkForClearingTransientSto 218 void SetMarkForClearingTransientStore (G4bool); 221 // Sets flag which will cause transient stor 219 // Sets flag which will cause transient store to be cleared at the 222 // next call to BeginPrimitives(). Maintain 220 // next call to BeginPrimitives(). Maintained by vis manager. 223 void SetTransientsDrawnThisEvent 221 void SetTransientsDrawnThisEvent (G4bool); 224 void SetTransientsDrawnThisRun 222 void SetTransientsDrawnThisRun (G4bool); 225 void SetObjectTransformation 223 void SetObjectTransformation (const G4Transform3D&); 226 // Maintained by vis manager. 224 // Maintained by vis manager. 227 225 228 //////////////////////////////////////////// 226 ////////////////////////////////////////////////////////////// 229 // Public utility functions. 227 // Public utility functions. 230 228 231 const G4Colour& GetColour (); // To be depr 229 const G4Colour& GetColour (); // To be deprecated? 232 const G4Colour& GetColor (); 230 const G4Colour& GetColor (); 233 // Returns colour - checks fpVisAttribs and 231 // Returns colour - checks fpVisAttribs and gets applicable colour. 234 // Assumes fpVisAttribs point to the G4VisAt 232 // Assumes fpVisAttribs point to the G4VisAttributes of the current object. 235 // If the pointer is null, the colour is obt 233 // If the pointer is null, the colour is obtained from the default view 236 // parameters of the current viewer. 234 // parameters of the current viewer. 237 235 238 const G4Colour& GetColour (const G4Visible&) 236 const G4Colour& GetColour (const G4Visible&); 239 const G4Colour& GetColor (const G4Visible&) 237 const G4Colour& GetColor (const G4Visible&); 240 // Returns colour, or viewer default colour. 238 // Returns colour, or viewer default colour. 241 // Makes no assumptions about the validity o 239 // Makes no assumptions about the validity of data member fpVisAttribs. 242 // If the G4Visible has no vis attributes, i 240 // If the G4Visible has no vis attributes, i.e., the pointer is null, 243 // the colour is obtained from the default v 241 // the colour is obtained from the default view parameters of the 244 // current viewer. 242 // current viewer. 245 243 246 const G4Colour& GetTextColour (const G4Text& 244 const G4Colour& GetTextColour (const G4Text&); 247 const G4Colour& GetTextColor (const G4Text& 245 const G4Colour& GetTextColor (const G4Text&); 248 // Returns colour of G4Text object, or defau 246 // Returns colour of G4Text object, or default text colour. 249 247 250 G4double GetLineWidth(const G4VisAttributes* 248 G4double GetLineWidth(const G4VisAttributes*); 251 // Returns line width of G4VisAttributes mul 249 // Returns line width of G4VisAttributes multiplied by GlobalLineWidthScale. 252 250 253 G4ViewParameters::DrawingStyle GetDrawingSty 251 G4ViewParameters::DrawingStyle GetDrawingStyle (const G4VisAttributes*); 254 // Returns drawing style from current view p 252 // Returns drawing style from current view parameters, unless the user 255 // has forced through the vis attributes, th 253 // has forced through the vis attributes, thereby over-riding the 256 // current view parameter. 254 // current view parameter. 257 255 258 G4int GetNumberOfCloudPoints (const G4VisAtt 256 G4int GetNumberOfCloudPoints (const G4VisAttributes*) const; 259 // Returns no of cloud points from current v 257 // Returns no of cloud points from current view parameters, unless the user 260 // has forced through the vis attributes, th 258 // has forced through the vis attributes, thereby over-riding the 261 // current view parameter. 259 // current view parameter. 262 260 263 G4bool GetAuxEdgeVisible (const G4VisAttribu 261 G4bool GetAuxEdgeVisible (const G4VisAttributes*); 264 // Returns auxiliary edge visibility from cu 262 // Returns auxiliary edge visibility from current view parameters, 265 // unless the user has forced through the vi 263 // unless the user has forced through the vis attributes, thereby 266 // over-riding the current view parameter. 264 // over-riding the current view parameter. 267 265 268 G4int GetNoOfSides(const G4VisAttributes*); 266 G4int GetNoOfSides(const G4VisAttributes*); 269 // Returns no. of sides (lines segments per 267 // Returns no. of sides (lines segments per circle) from current 270 // view parameters, unless the user has forc 268 // view parameters, unless the user has forced through the vis 271 // attributes, thereby over-riding the curre 269 // attributes, thereby over-riding the current view parameter. 272 270 273 G4double GetMarkerSize (const G4VMarker&, Ma 271 G4double GetMarkerSize (const G4VMarker&, MarkerSizeType&); 274 // Returns applicable marker size (diameter) 272 // Returns applicable marker size (diameter) and type (in second 275 // argument). Uses global default marker if 273 // argument). Uses global default marker if marker sizes are not 276 // set. Multiplies by GlobalMarkerScale. 274 // set. Multiplies by GlobalMarkerScale. 277 275 278 G4double GetMarkerDiameter (const G4VMarker& 276 G4double GetMarkerDiameter (const G4VMarker&, MarkerSizeType&); 279 // Alias for GetMarkerSize. 277 // Alias for GetMarkerSize. 280 278 281 G4double GetMarkerRadius (const G4VMarker&, 279 G4double GetMarkerRadius (const G4VMarker&, MarkerSizeType&); 282 // GetMarkerSize / 2. 280 // GetMarkerSize / 2. 283 281 284 G4ModelingParameters* CreateModelingParamete 282 G4ModelingParameters* CreateModelingParameters (); 285 // Only the scene handler and view know what 283 // Only the scene handler and view know what the Modeling Parameters should 286 // be. For historical reasons, the GEANT4 V 284 // be. For historical reasons, the GEANT4 Visualization Environment 287 // maintains its own Scene Data and View Par 285 // maintains its own Scene Data and View Parameters, which must be 288 // converted, when needed, to Modeling Param 286 // converted, when needed, to Modeling Parameters. 289 287 290 void DrawEvent(const G4Event*); 288 void DrawEvent(const G4Event*); 291 // Checks scene's end-of-event model list an 289 // Checks scene's end-of-event model list and draws trajectories, 292 // hits, etc. 290 // hits, etc. 293 291 294 void DrawEndOfRunModels(); 292 void DrawEndOfRunModels(); 295 // Draws end-of-run models. 293 // Draws end-of-run models. 296 294 297 //////////////////////////////////////////// 295 ////////////////////////////////////////////////////////////// 298 // Administration functions. 296 // Administration functions. 299 297 300 template <class T> void AddSolidT (const T& 298 template <class T> void AddSolidT (const T& solid); 301 template <class T> void AddSolidWithAuxiliar 299 template <class T> void AddSolidWithAuxiliaryEdges (const T& solid); 302 300 303 G4int IncrementViewCount (); 301 G4int IncrementViewCount (); 304 302 305 virtual void ClearStore (); 303 virtual void ClearStore (); 306 // Clears graphics database (display lists) 304 // Clears graphics database (display lists) if any. 307 305 308 virtual void ClearTransientStore (); 306 virtual void ClearTransientStore (); 309 // Clears transient part of graphics databas 307 // Clears transient part of graphics database (display lists) if any. 310 308 311 void AddViewerToList (G4VViewer* pView) 309 void AddViewerToList (G4VViewer* pView); // Add view to view List. 312 void RemoveViewerFromList (G4VViewer* pView) 310 void RemoveViewerFromList (G4VViewer* pView); // Remove view from view List. 313 311 314 protected: 312 protected: 315 313 316 //////////////////////////////////////////// 314 ////////////////////////////////////////////////////////////// 317 // Core routine for looping over models, red 315 // Core routine for looping over models, redrawing stored events, etc. 318 // Overload with care (see, for example, 316 // Overload with care (see, for example, 319 // G4OpenGLScenehandler::ProcessScene). 317 // G4OpenGLScenehandler::ProcessScene). 320 virtual void ProcessScene (); 318 virtual void ProcessScene (); 321 319 322 //////////////////////////////////////////// 320 ////////////////////////////////////////////////////////////// 323 // Default routine used by default AddSolid 321 // Default routine used by default AddSolid (). 324 virtual void RequestPrimitives (const G4VSol 322 virtual void RequestPrimitives (const G4VSolid& solid); 325 323 326 //////////////////////////////////////////// 324 ////////////////////////////////////////////////////////////// 327 // Other internal routines... 325 // Other internal routines... 328 326 329 virtual G4DisplacedSolid* CreateSectionSolid 327 virtual G4DisplacedSolid* CreateSectionSolid (); 330 virtual G4DisplacedSolid* CreateCutawaySolid 328 virtual G4DisplacedSolid* CreateCutawaySolid (); 331 // Generic clipping using the BooleanProcess 329 // Generic clipping using the BooleanProcessor in graphics_reps is 332 // implemented in this class. Subclasses th 330 // implemented in this class. Subclasses that implement their own 333 // clipping should provide an override that 331 // clipping should provide an override that returns zero. 334 332 335 void LoadAtts(const G4Visible&, G4AttHolder* 333 void LoadAtts(const G4Visible&, G4AttHolder*); 336 // Load G4AttValues and G4AttDefs associated 334 // Load G4AttValues and G4AttDefs associated with the G4Visible 337 // object onto the G4AttHolder object. It c 335 // object onto the G4AttHolder object. It checks fpModel, and also 338 // loads the G4AttValues and G4AttDefs from 336 // loads the G4AttValues and G4AttDefs from G4PhysicalVolumeModel, 339 // G4VTrajectory, G4VTrajectoryPoint, G4VHit 337 // G4VTrajectory, G4VTrajectoryPoint, G4VHit or G4VDigi, as 340 // appropriate. The G4AttHolder object is a 338 // appropriate. The G4AttHolder object is an object of a class that 341 // publicly inherits G4AttHolder - see, e.g. 339 // publicly inherits G4AttHolder - see, e.g., SoG4Polyhedron in the 342 // Open Inventor driver. G4AttHolder delete 340 // Open Inventor driver. G4AttHolder deletes G4AttValues in its 343 // destructor to ensure proper clean-up of G 341 // destructor to ensure proper clean-up of G4AttValues. 344 342 345 //////////////////////////////////////////// 343 ////////////////////////////////////////////////////////////// 346 // Special mesh rendering utilities... 344 // Special mesh rendering utilities... 347 345 348 struct NameAndVisAtts { 346 struct NameAndVisAtts { 349 NameAndVisAtts(const G4String& name = "",c 347 NameAndVisAtts(const G4String& name = "",const G4VisAttributes& visAtts = G4VisAttributes()) 350 : fName(name),fVisAtts(visAtts) {} 348 : fName(name),fVisAtts(visAtts) {} 351 G4String fName; 349 G4String fName; 352 G4VisAttributes fVisAtts; 350 G4VisAttributes fVisAtts; 353 }; 351 }; 354 352 355 class PseudoSceneFor3DRectMeshPositions: pub 353 class PseudoSceneFor3DRectMeshPositions: public G4PseudoScene { 356 public: 354 public: 357 PseudoSceneFor3DRectMeshPositions 355 PseudoSceneFor3DRectMeshPositions 358 (G4PhysicalVolumeModel* pvModel // input 356 (G4PhysicalVolumeModel* pvModel // input 359 , const G4Mesh* pMesh // input...the fol << 357 , G4int depth // input...the following are outputs by reference 360 , std::multimap<const G4Material*,const G 358 , std::multimap<const G4Material*,const G4ThreeVector>& positionByMaterial 361 , std::map<const G4Material*,NameAndVisAt 359 , std::map<const G4Material*,NameAndVisAtts>& nameAndVisAttsByMaterial) 362 : fpPVModel(pvModel) 360 : fpPVModel(pvModel) 363 , fpMesh(pMesh) << 361 , fDepth(depth) 364 , fPositionByMaterial(positionByMaterial) 362 , fPositionByMaterial(positionByMaterial) 365 , fNameAndVisAttsByMaterial(nameAndVisAtts 363 , fNameAndVisAttsByMaterial(nameAndVisAttsByMaterial) 366 {} 364 {} 367 private: 365 private: 368 using G4PseudoScene::AddSolid; // except 366 using G4PseudoScene::AddSolid; // except for... 369 void AddSolid(const G4Box&) override; 367 void AddSolid(const G4Box&) override; 370 void ProcessVolume(const G4VSolid&) overri 368 void ProcessVolume(const G4VSolid&) override { 371 // Do nothing if uninteresting solids fo 369 // Do nothing if uninteresting solids found, e.g., the container if not marked invisible. 372 } 370 } 373 G4PhysicalVolumeModel* fpPVModel; 371 G4PhysicalVolumeModel* fpPVModel; 374 const G4Mesh* fpMesh; << 372 G4int fDepth; 375 std::multimap<const G4Material*,const G4Th 373 std::multimap<const G4Material*,const G4ThreeVector>& fPositionByMaterial; 376 std::map<const G4Material*,NameAndVisAtts> 374 std::map<const G4Material*,NameAndVisAtts>& fNameAndVisAttsByMaterial; 377 }; 375 }; 378 376 379 class PseudoSceneForTetVertices: public G4Ps 377 class PseudoSceneForTetVertices: public G4PseudoScene { 380 public: 378 public: 381 PseudoSceneForTetVertices 379 PseudoSceneForTetVertices 382 (G4PhysicalVolumeModel* pvModel // input 380 (G4PhysicalVolumeModel* pvModel // input 383 , const G4Mesh* pMesh // input...the fol << 381 , G4int depth // input...the following are outputs by reference 384 , std::multimap<const G4Material*,std::ve 382 , std::multimap<const G4Material*,std::vector<G4ThreeVector>>& verticesByMaterial 385 , std::map<const G4Material*,NameAndVisAt 383 , std::map<const G4Material*,NameAndVisAtts>& nameAndVisAttsByMaterial) 386 : fpPVModel(pvModel) 384 : fpPVModel(pvModel) 387 , fpMesh(pMesh) << 385 , fDepth(depth) 388 , fVerticesByMaterial(verticesByMaterial) 386 , fVerticesByMaterial(verticesByMaterial) 389 , fNameAndVisAttsByMaterial(nameAndVisAtts 387 , fNameAndVisAttsByMaterial(nameAndVisAttsByMaterial) 390 {} 388 {} 391 private: 389 private: 392 using G4PseudoScene::AddSolid; // except 390 using G4PseudoScene::AddSolid; // except for... 393 void AddSolid(const G4VSolid& solid) overr 391 void AddSolid(const G4VSolid& solid) override; 394 void ProcessVolume(const G4VSolid&) overri 392 void ProcessVolume(const G4VSolid&) override { 395 // Do nothing if uninteresting solids fo 393 // Do nothing if uninteresting solids found, e.g., the container if not marked invisible. 396 } 394 } 397 G4PhysicalVolumeModel* fpPVModel; 395 G4PhysicalVolumeModel* fpPVModel; 398 const G4Mesh* fpMesh; << 396 G4int fDepth; 399 std::multimap<const G4Material*,std::vecto 397 std::multimap<const G4Material*,std::vector<G4ThreeVector>>& fVerticesByMaterial; 400 std::map<const G4Material*,NameAndVisAtts> 398 std::map<const G4Material*,NameAndVisAtts>& fNameAndVisAttsByMaterial; 401 }; 399 }; 402 400 403 void StandardSpecialMeshRendering(const G4Me 401 void StandardSpecialMeshRendering(const G4Mesh&); 404 // Standard way of special mesh rendering. 402 // Standard way of special mesh rendering. 405 // MySceneHandler::AddCompound(const G4Mesh& 403 // MySceneHandler::AddCompound(const G4Mesh& mesh) may use this if 406 // appropriate or implement its own special 404 // appropriate or implement its own special mesh rendereing. 407 405 408 void Draw3DRectMeshAsDots(const G4Mesh&); 406 void Draw3DRectMeshAsDots(const G4Mesh&); 409 // For a rectangular 3-D mesh, draw as colou 407 // For a rectangular 3-D mesh, draw as coloured dots by colour and material, 410 // one dot randomly placed in each visible m 408 // one dot randomly placed in each visible mesh cell. 411 409 412 void Draw3DRectMeshAsSurfaces(const G4Mesh&) 410 void Draw3DRectMeshAsSurfaces(const G4Mesh&); 413 // For a rectangular 3-D mesh, draw as surfa 411 // For a rectangular 3-D mesh, draw as surfaces by colour and material 414 // with inner shared faces removed. 412 // with inner shared faces removed. 415 413 416 void DrawTetMeshAsDots(const G4Mesh&); 414 void DrawTetMeshAsDots(const G4Mesh&); 417 // For a tetrahedron mesh, draw as coloured 415 // For a tetrahedron mesh, draw as coloured dots by colour and material, 418 // one dot randomly placed in each visible m 416 // one dot randomly placed in each visible mesh cell. 419 417 420 void DrawTetMeshAsSurfaces(const G4Mesh&); 418 void DrawTetMeshAsSurfaces(const G4Mesh&); 421 // For a tetrahedron mesh, draw as surfaces 419 // For a tetrahedron mesh, draw as surfaces by colour and material 422 // with inner shared faces removed. 420 // with inner shared faces removed. 423 421 424 G4ThreeVector GetPointInBox(const G4ThreeVec 422 G4ThreeVector GetPointInBox(const G4ThreeVector& pos, 425 G4double halfX, 423 G4double halfX, 426 G4double halfY, 424 G4double halfY, 427 G4double halfZ) 425 G4double halfZ) const; 428 // Sample a random point inside the box 426 // Sample a random point inside the box 429 427 430 G4ThreeVector GetPointInTet(const std::vecto 428 G4ThreeVector GetPointInTet(const std::vector<G4ThreeVector>& vertices) const; 431 // Sample a random point inside the tetrahed 429 // Sample a random point inside the tetrahedron 432 430 433 //////////////////////////////////////////// 431 ////////////////////////////////////////////////////////////// 434 // Data members 432 // Data members 435 433 436 G4VGraphicsSystem& fSystem; // Grap 434 G4VGraphicsSystem& fSystem; // Graphics system. 437 const G4int fSceneHandlerId; // Id o 435 const G4int fSceneHandlerId; // Id of this instance. 438 G4String fName; 436 G4String fName; 439 G4int fViewCount; // To d 437 G4int fViewCount; // To determine view ids. 440 G4ViewerList fViewerList; // View 438 G4ViewerList fViewerList; // Viewers. 441 G4VViewer* fpViewer; // Curr 439 G4VViewer* fpViewer; // Current viewer. 442 G4Scene* fpScene; // Scen 440 G4Scene* fpScene; // Scene for this scene handler. 443 G4bool fMarkForClearingTransient 441 G4bool fMarkForClearingTransientStore; 444 G4bool fReadyForTransients; // 442 G4bool fReadyForTransients; // I.e., not processing the 445 // run-duration part 443 // run-duration part of scene. 446 G4bool fTransientsDrawnThisEvent 444 G4bool fTransientsDrawnThisEvent; // Maintained by vis 447 G4bool fTransientsDrawnThisRun; 445 G4bool fTransientsDrawnThisRun; // manager. 448 G4bool fProcessingSolid; // True 446 G4bool fProcessingSolid; // True if within Pre/PostAddSolid. 449 G4bool fProcessing2D; // True 447 G4bool fProcessing2D; // True for 2D. 450 G4VModel* fpModel; // Curr 448 G4VModel* fpModel; // Current model. 451 G4Transform3D fObjectTransformation; // Curr 449 G4Transform3D fObjectTransformation; // Current accumulated 452 // object transformation. 450 // object transformation. 453 G4int fNestingDepth; // For 451 G4int fNestingDepth; // For Begin/EndPrimitives. 454 const G4VisAttributes* fpVisAttribs; // Work 452 const G4VisAttributes* fpVisAttribs; // Working vis attributes. 455 const G4Transform3D fIdentityTransformation; 453 const G4Transform3D fIdentityTransformation; 456 std::map<G4VPhysicalVolume*,G4String> fProbl << 457 454 458 private: 455 private: 459 456 460 G4VSceneHandler (const G4VSceneHandler&); 457 G4VSceneHandler (const G4VSceneHandler&); 461 G4VSceneHandler& operator = (const G4VSceneH 458 G4VSceneHandler& operator = (const G4VSceneHandler&); 462 }; 459 }; 463 460 464 #include "G4VSceneHandler.icc" 461 #include "G4VSceneHandler.icc" 465 462 466 #endif 463 #endif 467 464