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

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

fixes et cvs update

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