Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4OpenGLStoredSceneHandler.hh
이 파일의 문서화 페이지로 가기
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 // $Id: G4OpenGLStoredSceneHandler.hh 81942 2014-06-06 15:54:20Z gcosmo $
28 //
29 //
30 // Andrew Walkden 10th February 1997
31 // G4OpenGLStoredSceneHandler - creates OpenGL Display lists.
32 
33 #ifdef G4VIS_BUILD_OPENGL_DRIVER
34 
35 #ifndef G4OPENGLSTOREDSCENEHANDLER_HH
36 #define G4OPENGLSTOREDSCENEHANDLER_HH
37 
38 #include "globals.hh"
39 #include "G4OpenGLSceneHandler.hh"
40 #include "G4Text.hh"
41 #include <map>
42 #include <vector>
43 
44 class G4OpenGLStored;
45 
46 class G4OpenGLStoredSceneHandler: public G4OpenGLSceneHandler {
47 
48  friend class G4OpenGLStoredViewer; // ..allows access to P/TODLs.
49 
50 public:
51 
52  G4OpenGLStoredSceneHandler (G4VGraphicsSystem& system, const G4String& name = "");
53  virtual ~G4OpenGLStoredSceneHandler ();
54  void BeginPrimitives (const G4Transform3D& objectTransformation);
55  void EndPrimitives ();
56  void BeginPrimitives2D (const G4Transform3D& objectTransformation);
57  void EndPrimitives2D ();
58  void BeginModeling ();
59  void EndModeling ();
60  void AddPrimitive (const G4Polyline&);
61  void AddPrimitive (const G4Polymarker&);
62  void AddPrimitive (const G4Circle&);
63  void AddPrimitive (const G4Square&);
64  void AddPrimitive (const G4Text&);
65  void AddPrimitive (const G4Scale&);
66  void AddPrimitive (const G4Polyhedron&);
67  void ClearStore ();
68  void ClearTransientStore ();
69 
70  static G4int GetDisplayListLimit() {return fDisplayListLimit;}
71  static void SetDisplayListLimit(G4int lim) {fDisplayListLimit = lim;}
72 
73 protected:
74 
75  G4bool AddPrimitivePreamble(const G4VMarker& visible);
76  G4bool AddPrimitivePreamble(const G4Polyline& visible);
77  G4bool AddPrimitivePreamble(const G4Polyhedron& visible);
78  // Return false if no further processing required.
79 
80  void AddPrimitivePostamble();
81 
82  // Two virtual functions for extra processing in a sub-class, for
83  // example, to make a display tree. They are to return true if the
84  // visible object uses gl commands for drawing. This is
85  // predominantly true; a notable exception is Qt text. In that
86  // case, a display list does not need to be created; all relevant
87  // information is assumed to be stored in the PO/TOList.
88  virtual G4bool ExtraPOProcessing
89  (const G4Visible&, size_t /*currentPOListIndex*/) {return true;}
90  virtual G4bool ExtraTOProcessing
91  (const G4Visible&, size_t /*currentTOListIndex*/) {return true;}
92 
93  static G4int fSceneIdCount; // static counter for OpenGLStored scenes.
94  // Display list management. All static since there's only one OGL store.
95  static G4int fDisplayListId; // Workspace.
96  static G4bool fMemoryForDisplayLists; // avoid memory overflow
97  static G4int fDisplayListLimit; // avoid memory overflow
98 
99  // PODL = Persistent Object Display List.
100  // This "top PODL" was made redundant when the PO list was
101  // "unwrapped" 27th October 2011, but keep it for now in case we
102  // need to wrap it again.
103  GLint fTopPODL; // List which calls the other PODLs.
104 
105  // G4Text plus transform and 2/3D.
106  struct G4TextPlus {
107  G4TextPlus(const G4Text& text): fG4Text(text), fProcessing2D(false) {}
108  G4Text fG4Text;
109  G4bool fProcessing2D;
110  };
111 
112  // PO = Persistent Object, i.e., run-durantion object, e.g., geometry.
113  struct PO {
114  PO();
115  PO(const PO&);
116  PO(G4int id, const G4Transform3D& tr = G4Transform3D());
117  ~PO();
118  PO& operator= (const PO&);
119  G4int fDisplayListId;
120  G4Transform3D fTransform;
121  GLuint fPickName;
122  G4Colour fColour;
123  G4TextPlus* fpG4TextPlus;
124  G4bool fMarkerOrPolyline;
125  };
126  std::vector<PO> fPOList;
127 
128  // TO = Transient Object, e.g., trajectories.
129  struct TO {
130  TO();
131  TO(const TO&);
132  TO(G4int id, const G4Transform3D& tr = G4Transform3D());
133  ~TO();
134  TO& operator= (const TO&);
135  G4int fDisplayListId;
136  G4Transform3D fTransform;
137  GLuint fPickName;
138  G4double fStartTime, fEndTime; // Time range (e.g., for trajectory steps).
139  G4Colour fColour;
140  G4TextPlus* fpG4TextPlus;
141  G4bool fMarkerOrPolyline;
142  };
143  std::vector<TO> fTOList;
144 
145  // Stop-gap solution of structure re-use.
146  // A proper implementation would use geometry hierarchy.
147  std::map <const G4VSolid*, G4int, std::less <const G4VSolid*> > fSolidMap;
148 
149 private:
150  bool AddPrimitivePreambleInternal(const G4Visible& visible, bool isMarker, bool isPolyline);
151 
152 };
153 
154 #endif
155 
156 #endif
const XML_Char * name
Definition: expat.h:151
system("rm -rf microbeam.root")
HepGeom::Transform3D G4Transform3D
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
Definition: G4Text.hh:73
int G4int
Definition: G4Types.hh:78