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

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

changement des shorcuts

  • 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.23 2010/06/04 15:27:47 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 rotateQtSceneInViewDirection(float, float);
119  void rotateQtCameraInViewDirection(float, float);
120  void moveScene(float, float, float,bool);
121  void FinishView();
122
123
124protected:
125  QGLWidget* fWindow;
126  QWidget* fGLWindow;
127  bool hasPendingEvents();
128  void savePPMToTemp();
129  int fRecordFrameNumber;
130
131  bool fHasToRepaint;
132  bool fReadyToPaint;
133  bool fIsRepainting;
134
135private:
136  enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4};
137  enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
138
139  void createPopupMenu();
140  void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
141  void rescaleImage(int, int);
142  bool printPDF(const std::string,int,QImage); 
143  void showMovieParametersDialog();
144  void initMovieParameters();
145  QString createTempFolder();
146  QString removeTempFolder();
147  void setRecordingStatus(RECORDING_STEP);
148  void setRecordingInfos(QString);
149  QString getProcessErrorMsg();
150  QWidget* getParentWidget();
151
152#if QT_VERSION < 0x040000
153  QPopupMenu *fContextMenu;
154#else
155  QMenu *fContextMenu;
156#endif
157
158  mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts
159  QPoint fLastPos1;
160  QPoint fLastPos2;
161  QPoint fLastPos3;
162  /** delta of scene rotation. This delta is put in degree */
163  G4double fDeltaRotation;
164  /** delta of scene translation. This delta is put in % of the scene view */
165  G4double fDeltaSceneTranslation;
166  /** delta of depth move. This delta is put in % of the scene view */
167  G4double fDeltaDepth;
168  /** delta of zoom move. This delta is put in % of the scene view */
169  G4double fDeltaZoom;
170  /** delta of auto move/rotation. This delta is put in % of the move/rotation param */
171  G4double fDeltaMove;
172  /** To ensure key event are keep one by one */
173  bool fHoldKeyEvent;
174  /** To ensure move event are keep one by one */
175  bool fHoldMoveEvent;
176  /** To ensure rotate event are keep one by one */
177  bool fHoldRotateEvent;
178  bool fAutoMove;
179  QString fEncoderPath;
180  QString fTempFolderPath;
181  QString fMovieTempFolderPath;
182  QString fSaveFileName;
183  QString fParameterFileName;
184  QAction *fRotateAction;
185  QAction *fMoveAction;
186  QAction *fPickAction;
187  QAction *fFullScreenOn;
188  QAction *fFullScreenOff;
189  QAction *fDrawingWireframe;
190  QAction *fDrawingLineRemoval;
191  QAction *fDrawingSurfaceRemoval;
192  QAction *fDrawingLineSurfaceRemoval;
193  G4OpenGLQtMovieDialog* fMovieParametersDialog;
194  RECORDING_STEP fRecordingStep;
195  QProcess *fProcess;
196  QTime *fLastEventTime;
197  int fSpinningDelay;
198  int fNbMaxFramesPerSec;
199  float fNbMaxAnglePerSec;
200  int fLaunchSpinDelay;
201
202  G4double fXRot;
203  G4double fYRot;
204
205signals:
206 void rotateTheta(int);
207 void rotatePhi(int);
208 void moveX(int);
209 void moveY(int);
210 void moveZ(int);
211
212public slots :
213  void startPauseVideo();
214
215private slots :
216  void actionMouseRotate();
217  void actionMouseMove();
218  void actionMousePick();
219  void actionDrawingWireframe();
220  void actionDrawingLineRemoval();
221  void actionDrawingSurfaceRemoval();
222  void actionDrawingLineSurfaceRemoval();
223  void actionSaveImage();
224  void actionMovieParameters();
225
226  void showShortcuts();
227  void toggleDrawingAction(int);
228  void toggleMouseAction(mouseActions);
229  void toggleRepresentation(bool);
230  void toggleProjection(bool);
231  void toggleBackground(bool);
232  void toggleTransparency(bool);
233  void toggleAntialiasing(bool);
234  void toggleHaloing(bool);
235  void toggleAux(bool);
236  void toggleFullScreen(bool);
237  void processEncodeFinished();
238  void processLookForFinished();
239  void processEncodeStdout();
240  // Only use for Qt>4.0
241  //  void dialogClosed();
242};
243
244#endif
245
246#endif
Note: See TracBrowser for help on using the repository browser.