Geant4-11
G4OpenGLStoredSceneHandler.hh
Go to the documentation of this file.
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//
27//
28//
29// Andrew Walkden 10th February 1997
30// G4OpenGLStoredSceneHandler - creates OpenGL Display lists.
31
32#ifndef G4OPENGLSTOREDSCENEHANDLER_HH
33#define G4OPENGLSTOREDSCENEHANDLER_HH
34
35#include "globals.hh"
37#include "G4Text.hh"
38#include <map>
39#include <vector>
40
41class G4OpenGLStored;
42
44
45 friend class G4OpenGLStoredViewer; // ..allows access to P/TODLs.
46
47public:
48
51 void BeginPrimitives (const G4Transform3D& objectTransformation);
52 void EndPrimitives ();
53 void BeginPrimitives2D (const G4Transform3D& objectTransformation);
54 void EndPrimitives2D ();
55 void BeginModeling ();
56 void EndModeling ();
58 void AddPrimitive (const G4Polyline&);
59 void AddPrimitive (const G4Polymarker&);
60 void AddPrimitive (const G4Circle&);
61 void AddPrimitive (const G4Square&);
62 void AddPrimitive (const G4Text&);
63 void AddPrimitive (const G4Polyhedron&);
64 void ClearStore ();
65 void ClearTransientStore ();
66
69
70protected:
71
75 // Return false if no further processing required.
76
78
79 // Two virtual functions for extra processing in a sub-class, for
80 // example, to make a display tree. They are to return true if the
81 // visible object uses gl commands for drawing. This is
82 // predominantly true; a notable exception is Qt text. In that
83 // case, a display list does not need to be created; all relevant
84 // information is assumed to be stored in the PO/TOList.
86 (const G4Visible&, size_t /*currentPOListIndex*/) {return true;}
88 (const G4Visible&, size_t /*currentTOListIndex*/) {return true;}
89
90 static G4int fSceneIdCount; // static counter for OpenGLStored scenes.
91 // Display list management. All static since there's only one OGL store.
92 static G4int fDisplayListId; // Workspace.
93 static G4bool fMemoryForDisplayLists; // avoid memory overflow
94 static G4int fDisplayListLimit; // avoid memory overflow
95
96 // PODL = Persistent Object Display List.
97 // This "top PODL" was made redundant when the PO list was
98 // "unwrapped" 27th October 2011, but keep it for now in case we
99 // need to wrap it again.
100 GLint fTopPODL; // List which calls the other PODLs.
101
102 // G4Text plus transform and 2/3D.
103 struct G4TextPlus {
104 G4TextPlus(const G4Text& text): fG4Text(text), fProcessing2D(false) {}
107 };
108
109 // PO = Persistent Object, i.e., run-durantion object, e.g., geometry.
110 struct PO {
111 PO();
112 PO(const PO&);
113 PO(G4int id, const G4Transform3D& tr = G4Transform3D());
114 ~PO();
115 PO& operator= (const PO&);
118 GLuint fPickName;
122 };
123 std::vector<PO> fPOList;
124
125 // TO = Transient Object, e.g., trajectories.
126 struct TO {
127 TO();
128 TO(const TO&);
129 TO(G4int id, const G4Transform3D& tr = G4Transform3D());
130 ~TO();
131 TO& operator= (const TO&);
134 GLuint fPickName;
135 G4double fStartTime, fEndTime; // Time range (e.g., for trajectory steps).
139 };
140 std::vector<TO> fTOList;
141
142 // Stop-gap solution of structure re-use.
143 // A proper implementation would use geometry hierarchy.
144 std::map <const G4VSolid*, G4int, std::less <const G4VSolid*> > fSolidMap;
145
146private:
147 bool AddPrimitivePreambleInternal(const G4Visible& visible, bool isMarker, bool isPolyline);
148
149};
150
151#endif
HepGeom::Transform3D G4Transform3D
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
virtual G4bool ExtraPOProcessing(const G4Visible &, size_t)
bool AddPrimitivePreambleInternal(const G4Visible &visible, bool isMarker, bool isPolyline)
std::map< const G4VSolid *, G4int, std::less< const G4VSolid * > > fSolidMap
void AddPrimitive(const G4Polyline &)
static void SetDisplayListLimit(G4int lim)
G4bool AddPrimitivePreamble(const G4VMarker &visible)
G4OpenGLStoredSceneHandler(G4VGraphicsSystem &system, const G4String &name="")
virtual G4bool ExtraTOProcessing(const G4Visible &, size_t)
void BeginPrimitives(const G4Transform3D &objectTransformation)
void BeginPrimitives2D(const G4Transform3D &objectTransformation)
Definition: G4Text.hh:72
virtual void AddPrimitive(const G4Polyline &)=0
const char * name(G4int ptype)