[529] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
[1140] | 27 | // $Id: G4OpenGLSceneHandler.hh,v 1.27 2009/10/21 15:18:14 allison Exp $ |
---|
[915] | 28 | // GEANT4 tag $Name: $ |
---|
[529] | 29 | // |
---|
| 30 | // |
---|
| 31 | // Andrew Walkden 27th March 1996 |
---|
| 32 | // OpenGL scene handler - base for immediate mode and stored mode classes to |
---|
| 33 | // inherit from. |
---|
| 34 | |
---|
| 35 | #ifdef G4VIS_BUILD_OPENGL_DRIVER |
---|
| 36 | |
---|
| 37 | #ifndef G4OPENGLSCENEHANDLER_HH |
---|
| 38 | #define G4OPENGLSCENEHANDLER_HH |
---|
| 39 | |
---|
| 40 | #include "globals.hh" |
---|
| 41 | |
---|
[914] | 42 | #include "G4VSceneHandler.hh" |
---|
[1008] | 43 | #include "G4OpenGLBitMapStore.hh" |
---|
[914] | 44 | #include <GL/gl.h> |
---|
| 45 | #include <GL/glu.h> |
---|
[529] | 46 | |
---|
[593] | 47 | #include <map> |
---|
[529] | 48 | |
---|
[593] | 49 | class G4AttHolder; |
---|
| 50 | |
---|
| 51 | // Base class for various OpenGLSceneHandler classes. |
---|
[529] | 52 | class G4OpenGLSceneHandler: public G4VSceneHandler { |
---|
| 53 | |
---|
[593] | 54 | friend class G4OpenGLViewer; |
---|
| 55 | |
---|
[529] | 56 | public: |
---|
[593] | 57 | virtual void BeginPrimitives (const G4Transform3D& objectTransformation); |
---|
| 58 | virtual void EndPrimitives (); |
---|
[688] | 59 | virtual void BeginPrimitives2D (const G4Transform3D& objectTransformation); |
---|
[593] | 60 | virtual void EndPrimitives2D (); |
---|
[529] | 61 | void AddPrimitive (const G4Polyline&); |
---|
[593] | 62 | void AddPrimitive (const G4Polymarker&); |
---|
[529] | 63 | void AddPrimitive (const G4Text&); |
---|
| 64 | void AddPrimitive (const G4Circle&); |
---|
| 65 | void AddPrimitive (const G4Square&); |
---|
[593] | 66 | void AddPrimitive (const G4Scale&); |
---|
[529] | 67 | void AddPrimitive (const G4Polyhedron&); |
---|
| 68 | void AddPrimitive (const G4NURBS&); |
---|
| 69 | |
---|
[593] | 70 | void PreAddSolid (const G4Transform3D& objectTransformation, |
---|
| 71 | const G4VisAttributes&); |
---|
[529] | 72 | void AddSolid (const G4Box&); |
---|
| 73 | void AddSolid (const G4Cons&); |
---|
| 74 | void AddSolid (const G4Tubs&); |
---|
| 75 | void AddSolid (const G4Trd&); |
---|
| 76 | void AddSolid (const G4Trap&); |
---|
| 77 | void AddSolid (const G4Sphere&); |
---|
| 78 | void AddSolid (const G4Para&); |
---|
| 79 | void AddSolid (const G4Torus&); |
---|
| 80 | void AddSolid (const G4Polycone&); |
---|
| 81 | void AddSolid (const G4Polyhedra&); |
---|
| 82 | void AddSolid (const G4VSolid&); |
---|
| 83 | void AddCompound (const G4VTrajectory&); |
---|
| 84 | void AddCompound (const G4VHit&); |
---|
[1140] | 85 | void AddCompound (const G4THitsMap<G4double>&); |
---|
[529] | 86 | |
---|
| 87 | protected: |
---|
| 88 | |
---|
| 89 | G4OpenGLSceneHandler (G4VGraphicsSystem& system, |
---|
| 90 | G4int id, |
---|
| 91 | const G4String& name = ""); |
---|
| 92 | virtual ~G4OpenGLSceneHandler (); |
---|
| 93 | |
---|
| 94 | const G4Polyhedron* CreateSectionPolyhedron (); |
---|
| 95 | const G4Polyhedron* CreateCutawayPolyhedron (); |
---|
| 96 | |
---|
[688] | 97 | void ClearAndDestroyAtts(); // Destroys att holders and clears pick map. |
---|
| 98 | |
---|
[593] | 99 | GLuint fPickName; |
---|
| 100 | std::map<GLuint, G4AttHolder*> fPickMap; // For picking. |
---|
| 101 | |
---|
[688] | 102 | G4bool fProcessing2D; |
---|
| 103 | |
---|
[529] | 104 | private: |
---|
| 105 | |
---|
[593] | 106 | void AddCircleSquare (const G4VMarker&, G4OpenGLBitMapStore::Shape); |
---|
[529] | 107 | |
---|
[593] | 108 | void DrawXYPolygon |
---|
| 109 | (G4OpenGLBitMapStore::Shape, |
---|
| 110 | G4double size, |
---|
| 111 | const G4Point3D& centre, |
---|
| 112 | const G4VisAttributes* pApplicableVisAtts); |
---|
[529] | 113 | // Draws in world coordinates a polygon in the screen plane knowing |
---|
| 114 | // viewpoint direction and up vector. |
---|
| 115 | |
---|
| 116 | static const GLubyte fStippleMaskHashed [128]; |
---|
[593] | 117 | |
---|
| 118 | G4bool fProcessingPolymarker; |
---|
[529] | 119 | }; |
---|
| 120 | |
---|
| 121 | #include "G4OpenGLSceneHandler.icc" |
---|
| 122 | |
---|
| 123 | #endif |
---|
| 124 | |
---|
| 125 | #endif |
---|