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