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);
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 void g4GluPickMatrix(GLdouble
x, GLdouble y, GLdouble
width, GLdouble height,
187 void g4GluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
188 GLdouble centerx, GLdouble centery, GLdouble
190 GLdouble upx, GLdouble upy, GLdouble upz );
192 void g4GlOrtho (GLdouble
left, GLdouble
right,
193 GLdouble bottom, GLdouble top,
194 GLdouble near, GLdouble far);
196 void g4GlFrustum (GLdouble
left, GLdouble
right,
197 GLdouble bottom, GLdouble top,
198 GLdouble near, GLdouble far);
204 G4OpenGLSceneHandler& fOpenGLSceneHandler;
207 transparency_enabled,
208 antialiasing_enabled,
213 G4double fDisplayHeadTimeX, fDisplayHeadTimeY;
215 G4double fDisplayHeadTimeRed, fDisplayHeadTimeGreen, fDisplayHeadTimeBlue;
216 G4bool fDisplayLightFront;
217 G4double fDisplayLightFrontX, fDisplayLightFrontY, fDisplayLightFrontZ,
219 G4double fDisplayLightFrontRed, fDisplayLightFrontGreen, fDisplayLightFrontBlue;
224 unsigned int fWinSize_x;
225 unsigned int fWinSize_y;
226 std::vector < std::string > fExportImageFormatVector;
227 std::string fDefaultExportImageFormat;
228 std::string fExportImageFormat;
229 int fExportFilenameIndex;
239 int fGl2psDefaultLineWith;
240 int fGl2psDefaultPointSize;
241 bool fGlViewInitialized;
247 G4int getRealExportWidth();
248 G4int getRealExportHeight();
249 GLubyte* grabPixels (
int inColor,
251 unsigned int height);
252 bool printNonVectoredEPS ();
255 bool printVectoredEPS();
258 bool fIsGettingPickInfos;
261 #ifdef G4OPENGL_VERSION_2
263 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
264 inline Wt::WGLWidget::Program getShaderProgram() {
265 return fShaderProgram;
267 inline Wt::WGLWidget::UniformLocation getShaderProjectionMatrix() {
268 return fpMatrixUniform;
270 inline Wt::WGLWidget::UniformLocation getShaderTransformMatrix() {
271 return ftMatrixUniform;
274 inline GLuint getShaderProgram() {
275 return fShaderProgram;
277 inline GLuint getShaderProjectionMatrix() {
278 return fpMatrixUniform;
280 inline GLuint getShaderTransformMatrix() {
281 return ftMatrixUniform;
283 inline GLuint getShaderViewModelMatrix() {
284 return fmvMatrixUniform;
291 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
292 #define Shader Wt::WGLWidget::Shader
294 #define Shader GLuint
298 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
299 Wt::WGLWidget::Program fShaderProgram;
302 Wt::WGLWidget::AttribLocation fVertexPositionAttribute;
303 Wt::WGLWidget::AttribLocation fVertexNormalAttribute;
304 Wt::WGLWidget::UniformLocation fpMatrixUniform;
305 Wt::WGLWidget::UniformLocation fcMatrixUniform;
306 Wt::WGLWidget::UniformLocation fmvMatrixUniform;
307 Wt::WGLWidget::UniformLocation fnMatrixUniform;
308 Wt::WGLWidget::UniformLocation ftMatrixUniform;
310 GLuint fShaderProgram;
313 GLuint fVertexPositionAttribute;
314 GLuint fVertexNormalAttribute;
315 GLuint fpMatrixUniform;
316 GLuint fcMatrixUniform;
317 GLuint fmvMatrixUniform;
318 GLuint fnMatrixUniform;
319 GLuint ftMatrixUniform;
virtual void ClearView()=0
void print(G4double elem)
const G4double x[NPOINTSGL]
G4bool isInitialized()
Check if the generator is initialized.
std::string getName(const ParticleType t)
Get the native INCL name of the particle.