ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpenGLWtViewer.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4OpenGLWtViewer.hh
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 
47 class G4OpenGLSceneHandler;
48 class G4UImanager;
49 
50 class WDialog;
51 #ifdef _A_FINIR_FIXME
52 class WContextMenuEvent;
53 #endif
54 class WMenu;
55 class WImage;
56 #ifdef _A_FINIR_FIXME
57 class WWheelEvent;
58 #endif
59 class WProcess;
60 class G4UIWt;
61 
62 class G4OpenGLSceneHandler;
63 class G4OpenGLWtMovieDialog;
64 
65 class G4OpenGLWtViewer: virtual public G4OpenGLViewer {
66 
67 public:
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);
104 protected:
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 
128 protected:
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 
143 private:
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;
170  G4double fDeltaRotation;
172  G4double fDeltaSceneTranslation;
174  G4double fDeltaDepth;
176  G4double fDeltaZoom;
178  G4double fDeltaMove;
180  bool fHoldKeyEvent;
182  bool fHoldMoveEvent;
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 
229 public :
230  void startPauseVideo();
231 
232 private :
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