source: trunk/source/visualization/OpenGL/include/G4OpenGLQtViewer.hh @ 1228

Last change on this file since 1228 was 1228, checked in by garnier, 14 years ago

update geant4.9.3 tag

  • Property svn:mime-type set to text/cpp
File size: 7.3 KB
Line 
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: G4OpenGLQtViewer.hh,v 1.21 2010/01/06 15:05:29 lgarnier Exp $
28// GEANT4 tag $Name:  $
29//
30//
31// G4OpenGLQtViewer : Class to provide WindowsNT specific
32//                       functionality for OpenGL in GEANT4
33
34#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
35
36#ifndef G4OPENGLQTVIEWER_HH
37#define G4OPENGLQTVIEWER_HH
38
39#include "globals.hh"
40
41#include <qobject.h>
42#include "G4OpenGLViewer.hh"
43
44#include <qpoint.h>
45
46class G4OpenGLSceneHandler;
47class G4UImanager;
48
49class QGLWidget;
50class QDialog;
51class QContextMenuEvent;
52#if QT_VERSION < 0x040000
53class QPopupMenu;
54#else
55class QMenu;
56#endif
57class QImage;
58class QAction;
59class QMouseEvent;
60class QKeyEvent;
61class QWheelEvent;
62class QProcess;
63class QTime;
64
65class G4OpenGLSceneHandler;
66class G4OpenGLQtMovieDialog;
67
68class G4OpenGLQtViewer: public QObject, virtual public G4OpenGLViewer {
69
70  Q_OBJECT
71
72public:
73  G4OpenGLQtViewer (G4OpenGLSceneHandler& scene);
74  virtual ~G4OpenGLQtViewer ();
75  void SetView ();
76  virtual void updateQWidget()=0;
77  QString setEncoderPath(QString path);
78  QString getEncoderPath();
79  QString setTempFolderPath(QString path);
80  QString getTempFolderPath();
81  QString setSaveFileName(QString path);
82  QString getSaveFileName();
83  bool isRecording();
84  bool isStopped();
85  bool isPaused();
86  bool isEncoding();
87  bool isWaiting();
88  bool isFailed();
89  void setWaiting();
90  bool isBadEncoder();
91  bool isBadOutput();
92  bool isBadTmp();
93  bool isSuccess();
94  void setBadTmp();
95  void setBadOutput();
96  void setBadEncoder();
97  bool isReadyToEncode();
98  void resetRecording();
99  void encodeVideo();
100  void stopVideo();
101  void saveVideo();
102  bool generateMpegEncoderParameters();
103  void displayRecordingStatus();
104  void drawText(const char * ,int x,int y,int z, int size);
105
106protected:
107  void CreateGLQtContext ();
108  virtual void CreateMainWindow (QGLWidget*,QString);
109  void G4manageContextMenuEvent(QContextMenuEvent *e);
110  void G4MousePressEvent(QMouseEvent *event);
111  void G4MouseReleaseEvent();
112  void G4MouseDoubleClickEvent();
113  void G4MouseMoveEvent(QMouseEvent *event);
114  void G4wheelEvent (QWheelEvent * event);
115  void G4keyPressEvent (QKeyEvent * event);
116  void rotateQtScene(float, float);
117  void rotateQtCamera(float, float);
118  void moveScene(float, float, float,bool);
119  void FinishView();
120
121
122protected:
123  QGLWidget* fWindow;
124  QWidget* fGLWindow;
125  bool hasPendingEvents();
126  void savePPMToTemp();
127  int fRecordFrameNumber;
128  float fRotationAngleX;
129  float fRotationAngleY;
130  float fRotationAngleZ;
131  float fDeltaRotationAngleX;
132  float fDeltaRotationAngleY;
133  float fDeltaRotationAngleZ;
134
135  bool fHasToRepaint;
136  bool fReadyToPaint;
137
138private:
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  void createPopupMenu();
143  void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
144  void rescaleImage(int, int);
145  bool printPDF(const std::string,int,QImage); 
146  void showMovieParametersDialog();
147  void initMovieParameters();
148  QString createTempFolder();
149  QString removeTempFolder();
150  void setRecordingStatus(RECORDING_STEP);
151  void setRecordingInfos(QString);
152  QString getProcessErrorMsg();
153  QWidget* getParentWidget();
154
155#if QT_VERSION < 0x040000
156  QPopupMenu *fContextMenu;
157#else
158  QMenu *fContextMenu;
159#endif
160
161  mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts
162  QPoint fLastPos1;
163  QPoint fLastPos2;
164  QPoint fLastPos3;
165  /** delta of scene rotation. This delta is put in degree */
166  G4double fDeltaRotation;
167  /** delta of scene translation. This delta is put in % of the scene view */
168  G4double fDeltaSceneTranslation;
169  /** delta of depth move. This delta is put in % of the scene view */
170  G4double fDeltaDepth;
171  /** delta of zoom move. This delta is put in % of the scene view */
172  G4double fDeltaZoom;
173  /** delta of auto move/rotation. This delta is put in % of the move/rotation param */
174  G4double fDeltaMove;
175  /** To ensure key event are keep one by one */
176  bool fHoldKeyEvent;
177  /** To ensure move event are keep one by one */
178  bool fHoldMoveEvent;
179  /** To ensure rotate event are keep one by one */
180  bool fHoldRotateEvent;
181  bool fAutoMove;
182  QString fEncoderPath;
183  QString fTempFolderPath;
184  QString fMovieTempFolderPath;
185  QString fSaveFileName;
186  QString fParameterFileName;
187  QAction *fRotateAction;
188  QAction *fMoveAction;
189  QAction *fPickAction;
190  QAction *fFullScreenOn;
191  QAction *fFullScreenOff;
192  QAction *fDrawingWireframe;
193  QAction *fDrawingLineRemoval;
194  QAction *fDrawingSurfaceRemoval;
195  QAction *fDrawingLineSurfaceRemoval;
196  G4OpenGLQtMovieDialog* fMovieParametersDialog;
197  RECORDING_STEP fRecordingStep;
198  QProcess *fProcess;
199  QTime *fLastEventTime;
200  int fSpinningDelay;
201  int fLaunchSpinDelay;
202
203signals:
204 void rotateTheta(int);
205 void rotatePhi(int);
206 void moveX(int);
207 void moveY(int);
208 void moveZ(int);
209
210public slots :
211  void startPauseVideo();
212
213private slots :
214  void actionMouseRotate();
215  void actionMouseMove();
216  void actionMousePick();
217  void actionDrawingWireframe();
218  void actionDrawingLineRemoval();
219  void actionDrawingSurfaceRemoval();
220  void actionDrawingLineSurfaceRemoval();
221  void actionSaveImage();
222  void actionMovieParameters();
223
224  void showShortcuts();
225  void toggleDrawingAction(int);
226  void toggleMouseAction(mouseActions);
227  void toggleRepresentation(bool);
228  void toggleProjection(bool);
229  void toggleBackground(bool);
230  void toggleTransparency(bool);
231  void toggleAntialiasing(bool);
232  void toggleHaloing(bool);
233  void toggleAux(bool);
234  void toggleFullScreen(bool);
235  void processEncodeFinished();
236  void processLookForFinished();
237  void processEncodeStdout();
238  // Only use for Qt>4.0
239  //  void dialogClosed();
240};
241
242#endif
243
244#endif
Note: See TracBrowser for help on using the repository browser.