33 #ifdef G4VIS_BUILD_OPENGL_DRIVER
35 #ifndef G4OPENGLVIEWER_HH
36 #define G4OPENGLVIEWER_HH
40 #ifdef G4OPENGL_VERSION_2
44 class G4OpenGLSceneHandler;
48 class G4OpenGLViewerPickMap {
54 inline void setHitNumber(
G4int n) {
58 inline void setSubHitNumber(
G4int n) {
61 inline void setPickName(
G4int n) {
65 inline void addAttributes(
G4String att) {
66 fAttributes.push_back(att);
73 inline G4int getHitNumber() {
77 inline G4int getSubHitNumber() {
81 inline G4int getPickName() {
85 inline std::vector <G4String > getAttributes() {
96 std::vector <G4String > fAttributes;
101 class G4OpenGLViewer:
virtual public G4VViewer {
103 friend class G4OpenGLSceneHandler;
104 friend class G4OpenGLImmediateSceneHandler;
105 friend class G4OpenGLStoredSceneHandler;
106 friend class G4OpenGLFileSceneHandler;
111 void ClearViewWithoutFlush ();
114 virtual bool exportImage(std::string
name=
"",
int width=-1,
int height=-1);
116 bool setExportImageFormat(std::string format,
bool quiet =
false);
120 #ifdef G4OPENGL_VERSION_2
121 inline G4OpenGLVboDrawer* getWtDrawer() {
return fVboDrawer;}
124 void setVboDrawer(G4OpenGLVboDrawer* drawer);
125 G4OpenGLVboDrawer* fVboDrawer;
128 return fGlViewInitialized;
133 G4OpenGLViewer (G4OpenGLSceneHandler& scene);
134 virtual ~G4OpenGLViewer ();
137 G4OpenGLViewer(
const G4OpenGLViewer&);
138 G4OpenGLViewer& operator= (
const G4OpenGLViewer&);
144 virtual void DrawText(
const G4Text&);
145 void ChangePointSize(
G4double size);
146 void ChangeLineWidth(
G4double width);
147 void HaloingFirstPass ();
148 void HaloingSecondPass ();
149 void HLRFirstPass ();
150 void HLRSecondPass ();
151 void HLRThirdPass ();
152 void InitializeGLView ();
154 void ResizeWindow(
unsigned int,
unsigned int);
155 virtual G4String Pick(GLdouble x, GLdouble y);
156 std::vector < G4OpenGLViewerPickMap* > GetPickDetails(GLdouble x, GLdouble y);
157 virtual void CreateFontLists () {}
172 std::string getRealPrintFilename();
173 unsigned int getWinWidth()
const;
174 unsigned int getWinHeight()
const;
177 GLdouble getSceneNearWidth();
178 GLdouble getSceneFarWidth();
179 GLdouble getSceneDepth();
180 void addExportImageFormat(std::string format);
183 G4bool isFramebufferReady();
185 void g4GluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height,
189 void g4GluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
190 GLdouble centerx, GLdouble centery, GLdouble
192 GLdouble upx, GLdouble upy, GLdouble upz );
194 void g4GlOrtho (GLdouble left, GLdouble right,
195 GLdouble bottom, GLdouble top,
196 GLdouble near, GLdouble far);
198 void g4GlFrustum (GLdouble left, GLdouble right,
199 GLdouble bottom, GLdouble top,
200 GLdouble near, GLdouble far);
206 G4OpenGLSceneHandler& fOpenGLSceneHandler;
209 transparency_enabled,
210 antialiasing_enabled,
215 G4double fDisplayHeadTimeX, fDisplayHeadTimeY;
217 G4double fDisplayHeadTimeRed, fDisplayHeadTimeGreen, fDisplayHeadTimeBlue;
218 G4bool fDisplayLightFront;
219 G4double fDisplayLightFrontX, fDisplayLightFrontY, fDisplayLightFrontZ,
221 G4double fDisplayLightFrontRed, fDisplayLightFrontGreen, fDisplayLightFrontBlue;
226 unsigned int fWinSize_x;
227 unsigned int fWinSize_y;
228 std::vector < std::string > fExportImageFormatVector;
229 std::string fDefaultExportImageFormat;
230 std::string fExportImageFormat;
231 int fExportFilenameIndex;
241 int fGl2psDefaultLineWith;
242 int fGl2psDefaultPointSize;
243 bool fGlViewInitialized;
249 G4int getRealExportWidth();
250 G4int getRealExportHeight();
251 GLubyte* grabPixels (
int inColor,
253 unsigned int height);
254 bool printNonVectoredEPS ();
257 bool printVectoredEPS();
260 bool fIsGettingPickInfos;
263 #ifdef G4OPENGL_VERSION_2
265 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
266 inline Wt::WGLWidget::Program getShaderProgram() {
267 return fShaderProgram;
269 inline Wt::WGLWidget::UniformLocation getShaderProjectionMatrix() {
270 return fpMatrixUniform;
272 inline Wt::WGLWidget::UniformLocation getShaderTransformMatrix() {
273 return ftMatrixUniform;
276 inline GLuint getShaderProgram() {
277 return fShaderProgram;
279 inline GLuint getShaderProjectionMatrix() {
280 return fpMatrixUniform;
282 inline GLuint getShaderTransformMatrix() {
283 return ftMatrixUniform;
285 inline GLuint getShaderViewModelMatrix() {
286 return fmvMatrixUniform;
293 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
294 #define Shader Wt::WGLWidget::Shader
296 #define Shader GLuint
300 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
301 Wt::WGLWidget::Program fShaderProgram;
304 Wt::WGLWidget::AttribLocation fVertexPositionAttribute;
305 Wt::WGLWidget::AttribLocation fVertexNormalAttribute;
306 Wt::WGLWidget::UniformLocation fpMatrixUniform;
307 Wt::WGLWidget::UniformLocation fcMatrixUniform;
308 Wt::WGLWidget::UniformLocation fmvMatrixUniform;
309 Wt::WGLWidget::UniformLocation fnMatrixUniform;
310 Wt::WGLWidget::UniformLocation ftMatrixUniform;
312 GLuint fShaderProgram;
315 GLuint fVertexPositionAttribute;
316 GLuint fVertexNormalAttribute;
317 GLuint fpMatrixUniform;
318 GLuint fcMatrixUniform;
319 GLuint fmvMatrixUniform;
320 GLuint fnMatrixUniform;
321 GLuint ftMatrixUniform;
virtual void ClearView()=0
void print(G4double elem)
std::string getName(const ParticleType t)
Get the native INCL name of the particle.