Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLWtViewer.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// G4OpenGLWtViewer : Class to provide WindowsNT specific
30// functionality for OpenGL in GEANT4
31
32#if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
33
34#ifndef G4OPENGLWTVIEWER_HH
35#define G4OPENGLWTVIEWER_HH
36
37#include "globals.hh"
38
39#include "G4OpenGLViewer.hh"
40
41#include <Wt/WObject>
42#include <Wt/WPoint>
43#include <Wt/WTime>
44#include <Wt/WContainerWidget>
45#include <Wt/WMatrix4x4>
46
47class G4OpenGLSceneHandler;
48class G4UImanager;
49
50class WDialog;
51#ifdef _A_FINIR_FIXME
52class WContextMenuEvent;
53#endif
54class WMenu;
55class WImage;
56#ifdef _A_FINIR_FIXME
57class WWheelEvent;
58#endif
59class WProcess;
60class G4UIWt;
61
62class G4OpenGLSceneHandler;
63class G4OpenGLWtMovieDialog;
64
65class G4OpenGLWtViewer: virtual public G4OpenGLViewer {
66
67public:
68 G4OpenGLWtViewer (G4OpenGLSceneHandler& scene);
69 virtual ~G4OpenGLWtViewer ();
70 virtual void updateWWidget()=0;
71
72 Wt::WMatrix4x4 mMatrix;
73
74#ifdef _A_FINIR_FIXME
75 Wt::WString setEncoderPath(Wt::WString path);
76 Wt::WString getEncoderPath();
77 Wt::WString setTempFolderPath(Wt::WString path);
78 Wt::WString getTempFolderPath();
79 Wt::WString setSaveFileName(Wt::WString path);
80 Wt::WString getSaveFileName();
81 bool isRecording();
82 bool isStopped();
83 bool isPaused();
84 bool isEncoding();
85 bool isWaiting();
86 bool isFailed();
87 void setWaiting();
88 bool isBadEncoder();
89 bool isBadOutput();
90 bool isBadTmp();
91 bool isSuccess();
92 void setBadTmp();
93 void setBadOutput();
94 void setBadEncoder();
95 bool isReadyToEncode();
96 void resetRecording();
97 void encodeVideo();
98 void stopVideo();
99 void saveVideo();
100 bool generateMpegEncoderParameters();
101 void displayRecordingStatus();
102#endif
103 void drawText(const char * ,int x,int y,int z, int size);
104protected:
105 void CreateGLWtContext ();
106 virtual void CreateMainWindow (Wt::WGLWidget*,Wt::WString);
107#ifdef _A_FINIR_FIXME
108 void G4manageContextMenuEvent(Wt::WContextMenuEvent *e);
109#endif
110 void G4MousePressEvent(Wt::WMouseEvent *event);
111 void G4MouseReleaseEvent();
112 void G4MouseDoubleClickEvent();
113 void G4MouseMoveEvent(Wt::WMouseEvent *event);
114// void G4wheelEvent (Wt::WWheelEvent * event);
115 void G4keyPressEvent (Wt::WKeyEvent * event);
116 void rotateWtScene(float, float);
117 void rotateWtSceneToggle(float, float);
118 void moveScene(float, float, float,bool);
119#ifdef _A_FINIR_FIXME
120 void updateKeyModifierState(Wt::KeyboardModifiers);
121#endif
122
123 inline Wt::WGLWidget* getGLWindow() {
124 return fWindow;
125 }
126
127
128protected:
129 Wt::WGLWidget* fWindow;
130 Wt::WWidget* fGLWindow;
131 bool hasPendingEvents();
132 void resizeGL(int width, int height);
133
134#ifdef _A_FINIR_FIXME
135 void savePPMToTemp();
136#endif
137 int fRecordFrameNumber;
138
139 bool fHasToRepaint;
140 bool fReadyToPaint;
141 bool fIsRepainting;
142
143private:
144 enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4};
145 enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
146
147#ifdef _A_FINIR_FIXME
148 void createPopupMenu();
149 void createRadioAction(Wt::WAction *,Wt::WAction *, const std::string&,unsigned int a=1);
150#endif
151 void rescaleImage(int, int);
152#ifdef _A_FINIR_FIXME
153 bool printPDF(const std::string,int,WImage);
154 void showMovieParametersDialog();
155 void initMovieParameters();
156 Wt::WString createTempFolder();
157 Wt::WString removeTempFolder();
158 void setRecordingStatus(RECORDING_STEP);
159 void setRecordingInfos(Wt::WString);
160 Wt::WString getProcessErrorMsg();
161
162 WMenu *fContextMenu;
163#endif
164
165 mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts
166 Wt::WPoint fLastPos1;
167 Wt::WPoint fLastPos2;
168 Wt::WPoint fLastPos3;
169 /** delta of scene rotation. This delta is put in degree */
170 G4double fDeltaRotation;
171 /** delta of scene translation. This delta is put in % of the scene view */
172 G4double fDeltaSceneTranslation;
173 /** delta of depth move. This delta is put in % of the scene view */
174 G4double fDeltaDepth;
175 /** delta of zoom move. This delta is put in % of the scene view */
176 G4double fDeltaZoom;
177 /** delta of auto move/rotation. This delta is put in % of the move/rotation param */
178 G4double fDeltaMove;
179 /** To ensure key event are keep one by one */
180 bool fHoldKeyEvent;
181 /** To ensure move event are keep one by one */
182 bool fHoldMoveEvent;
183 /** To ensure rotate event are keep one by one */
184 bool fHoldRotateEvent;
185 bool fAutoMove;
186 Wt::WString fEncoderPath;
187 Wt::WString fTempFolderPath;
188 Wt::WString fMovieTempFolderPath;
189 Wt::WString fSaveFileName;
190 Wt::WString fParameterFileName;
191#ifdef _A_FINIR_FIXME
192 WAction *fRotateAction;
193 WAction *fMoveAction;
194 WAction *fPickAction;
195 WAction *fFullScreenOn;
196 WAction *fFullScreenOff;
197 WAction *fDrawingWireframe;
198 WAction *fDrawingLineRemoval;
199 WAction *fDrawingSurfaceRemoval;
200 WAction *fDrawingLineSurfaceRemoval;
201#endif
202 G4OpenGLWtMovieDialog* fMovieParametersDialog;
203 RECORDING_STEP fRecordingStep;
204 WProcess *fProcess;
205 Wt::WTime *fLastEventTime;
206 int fSpinningDelay;
207 int fNbMaxFramesPerSec;
208 float fNbMaxAnglePerSec;
209 int fLaunchSpinDelay;
210 Wt::WTabWidget* fUISceneTreeComponentsTBWidget;
211
212 G4double fXRot;
213 G4double fYRot;
214 bool fNoKeyPress;
215 bool fAltKeyPress;
216 bool fControlKeyPress;
217 bool fShiftKeyPress;
218 bool fBatchMode;
219 G4UIWt* fUiWt;
220
221#ifdef _A_FINIR_FIXME
222 void rotateTheta(int);
223 void rotatePhi(int);
224 void moveX(int);
225 void moveY(int);
226 void moveZ(int);
227#endif
228
229public :
230 void startPauseVideo();
231
232private :
233#ifdef _A_FINIR_FIXME
234 void actionMouseRotate();
235 void actionMouseMove();
236 void actionMousePick();
237 void actionDrawingWireframe();
238 void actionDrawingLineRemoval();
239 void actionDrawingSurfaceRemoval();
240 void actionDrawingLineSurfaceRemoval();
241 void actionSaveImage();
242 void actionChangeBackgroundColor();
243 void actionChangeTextColor();
244 void actionChangeDefaultColor();
245 void actionMovieParameters();
246#endif
247
248 void showShortcuts();
249#ifdef _A_FINIR_FIXME
250 void toggleDrawingAction(int);
251 void toggleMouseAction(mouseActions);
252 void toggleRepresentation(bool);
253 void toggleProjection(bool);
254 void toggleTransparency(bool);
255 void toggleAntialiasing(bool);
256 void toggleHaloing(bool);
257 void toggleAux(bool);
258 void toggleFullScreen(bool);
259#endif
260 void processEncodeFinished();
261 void processLookForFinished();
262 void processEncodeStdout();
263 // Only use for Wt>4.0
264 // void dialogClosed();
265
266
267};
268
269#endif
270
271#endif
double G4double
Definition: G4Types.hh:83
struct encoding ENCODING
Definition: xmltok.h:124