Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLViewer.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 27th March 1996
30// OpenGL viewer - opens window, hard copy, etc.
31
32#ifndef G4OPENGLVIEWER_HH
33#define G4OPENGLVIEWER_HH
34
35#include "G4VViewer.hh"
36#include "G4OpenGL.hh"
37
39class G4gl2ps;
40class G4Text;
41
43 public :
44 inline void setName(G4String n) {
45 fName = n;
46 }
47
48 inline void setHitNumber(G4int n) {
49 fHitNumber = n;
50 }
51
52 inline void setSubHitNumber(G4int n) {
53 fSubHitNumber = n;
54 }
55 inline void setPickName(G4int n) {
56 fPickName= n;
57 }
58
59 inline void addAttributes(G4String att) {
60 fAttributes.push_back(att);
61 }
62
63
64 inline G4String getName() {
65 return fName;
66 }
68 return fHitNumber;
69 }
70
72 return fSubHitNumber;
73 }
74
75 inline G4int getPickName() {
76 return fPickName;
77 }
78
79 inline std::vector <G4String > getAttributes() {
80 return fAttributes;
81 }
82
84
85 private :
86 G4String fName;
87 G4int fHitNumber;
88 G4int fSubHitNumber;
89 G4int fPickName;
90 std::vector <G4String > fAttributes;
91
92};
93
94// Base class for various OpenGLView classes.
95class G4OpenGLViewer: virtual public G4VViewer {
96
102
103public:
104 void ClearView ();
105 void ClearViewWithoutFlush ();
106
107 virtual bool exportImage(std::string name="", int width=-1, int height=-1);
108 bool setExportImageFormat(std::string format,bool quiet = false);
109
110protected:
112 virtual ~G4OpenGLViewer ();
113
114private:
116 G4OpenGLViewer& operator= (const G4OpenGLViewer&);
117
118protected:
119 void SetView ();
120 void ResetView ();
121
122 virtual void DrawText(const G4Text&);
123 void ChangePointSize(G4double size);
124 void ChangeLineWidth(G4double width);
125 void HaloingFirstPass ();
126 void HaloingSecondPass ();
130 void InitializeGLView ();
131 void ResizeGLView();
132 void ResizeWindow(unsigned int, unsigned int);
133 virtual G4String Pick(GLdouble x, GLdouble y);
134 const std::vector < G4OpenGLViewerPickMap* > & GetPickDetails(GLdouble x, GLdouble y);
135 virtual void CreateFontLists () {}
136 void rotateScene (G4double dx, G4double dy);
137 void rotateSceneToggle (G4double dx, G4double dy);
138//////////////////////////////Vectored PostScript production functions///
139 // print EPS file. Depending of fVectoredPs, it will print Vectored or not
141 // set the new print size.
142 // -1 means 'print size' = 'window size'
143 // Setting size greater than max OpenGL viewport size will set the size to
144 // maximum
145 bool setExportFilename(G4String name,G4bool inc = true);
146 // set export filename.
147 // if inc, then the filename will be increment by one each time
148 // try to guesss the correct format according to the extention
149
150 std::string getRealPrintFilename();
151 unsigned int getWinWidth() const;
152 unsigned int getWinHeight() const;
154 // return true if size has change since last redraw
155 GLdouble getSceneNearWidth();
156 GLdouble getSceneFarWidth();
157 GLdouble getSceneDepth();
158 void addExportImageFormat(std::string format);
159 // add a image format to the available export format list
162
163 void g4GluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height,
164 GLint viewport[4]);
165 // MESA implementation of gluPickMatrix
166
167 void g4GluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
168 GLdouble centerx, GLdouble centery, GLdouble
169 centerz,
170 GLdouble upx, GLdouble upy, GLdouble upz );
171 // MESA implementation of gluLookAt
172 void g4GlOrtho (GLdouble left, GLdouble right,
173 GLdouble bottom, GLdouble top,
174 GLdouble near, GLdouble far);
175 // Redefinition on glOrtho to solve precision issues
176 void g4GlFrustum (GLdouble left, GLdouble right,
177 GLdouble bottom, GLdouble top,
178 GLdouble near, GLdouble far);
179 // Redefinition on glFrustum to solve precision issues
180
183
185 G4Colour background; //the OpenGL clear colour
186 G4bool
187 transparency_enabled, //is alpha blending enabled?
188 antialiasing_enabled, //is antialiasing enabled?
189 haloing_enabled; //is haloing enabled for wireframe?
191
192 G4double fRot_sens; // Rotation sensibility in degrees
193 G4double fPan_sens; // Translation sensibility
194 unsigned int fWinSize_x;
195 unsigned int fWinSize_y;
196 std::vector < std::string > fExportImageFormatVector;
202
203
204private :
205 G4float fPointSize;
206 G4String fExportFilename;
207 G4String fDefaultExportFilename;
208 G4bool fSizeHasChanged;
209 int fGl2psDefaultLineWith;
210 int fGl2psDefaultPointSize;
211 bool fGlViewInitialized;
212
213 // size of the OpenGL frame
214 void rotateSceneThetaPhi(G4double dx, G4double dy);
215 void rotateSceneInViewDirection (G4double dx, G4double dy);
216 bool printGl2PS();
217 G4int getRealExportWidth();
218 G4int getRealExportHeight();
219 GLubyte* grabPixels (int inColor,
220 unsigned int width,
221 unsigned int height);
222 bool printNonVectoredEPS ();
223 // print non vectored EPS files
224
225 bool printVectoredEPS();
226 // print vectored EPS files
227
228 bool fIsGettingPickInfos;
229 // Block SetView() during picking
230
231};
232
233#endif
float G4float
Definition G4Types.hh:84
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
void setSubHitNumber(G4int n)
void setName(G4String n)
std::vector< G4String > getAttributes()
void setHitNumber(G4int n)
void addAttributes(G4String att)
void setPickName(G4int n)
unsigned int fWinSize_y
void g4GluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height, GLint viewport[4])
void g4GlFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
std::vector< std::string > fExportImageFormatVector
void g4GluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz)
void rotateSceneToggle(G4double dx, G4double dy)
virtual void CreateFontLists()
bool setExportImageFormat(std::string format, bool quiet=false)
unsigned int getWinHeight() const
std::string fExportImageFormat
void HLRThirdPass()
void ClearViewWithoutFlush()
void ResizeWindow(unsigned int, unsigned int)
unsigned int getWinWidth() const
std::string fDefaultExportImageFormat
bool setExportFilename(G4String name, G4bool inc=true)
G4OpenGLViewer(G4OpenGLSceneHandler &scene)
void addExportImageFormat(std::string format)
G4bool antialiasing_enabled
void ChangeLineWidth(G4double width)
virtual void DrawText(const G4Text &)
GLdouble getSceneFarWidth()
void setExportSize(G4int, G4int)
virtual G4String Pick(GLdouble x, GLdouble y)
void rotateScene(G4double dx, G4double dy)
void ChangePointSize(G4double size)
GLdouble getSceneDepth()
G4bool isFramebufferReady()
G4bool transparency_enabled
virtual bool exportImage(std::string name="", int width=-1, int height=-1)
void g4GlOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
G4gl2ps * fGL2PSAction
G4bool isGl2psWriting()
G4bool sizeHasChanged()
G4OpenGLSceneHandler & fOpenGLSceneHandler
virtual ~G4OpenGLViewer()
unsigned int fWinSize_x
void HLRFirstPass()
friend class G4OpenGLFileSceneHandler
std::string getRealPrintFilename()
void HLRSecondPass()
GLdouble getSceneNearWidth()
const std::vector< G4OpenGLViewerPickMap * > & GetPickDetails(GLdouble x, GLdouble y)