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

Last change on this file since 844 was 844, checked in by garnier, 16 years ago

update before commit to cvs

  • Property svn:mime-type set to text/cpp
File size: 7.1 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.9 2008/03/11 16:05:56 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 "G4VViewer.hh"
42#include "G4OpenGLSceneHandler.hh"
43
44#include <qobject.h>
45#include <qpoint.h>
46
47class QGLWidget;
48class QDialog;
49class QContextMenuEvent;
50#if QT_VERSION < 0x040000
51class QPopupMenu;
52#else
53class QMenu;
54#endif
55class QImage;
56class QAction;
57class QMouseEvent;
58class QKeyEvent;
59class QWheelEvent;
60class QProcess;
61class QTime;
62
63class G4OpenGLSceneHandler;
64class G4OpenGLQtMovieDialog;
65
66class G4OpenGLQtViewer: public QObject, virtual public G4OpenGLViewer {
67
68  Q_OBJECT
69
70public:
71  G4OpenGLQtViewer (G4OpenGLSceneHandler& scene);
72  virtual ~G4OpenGLQtViewer ();
73  void SetView ();
74  void ShowView ();
75  virtual void updateQWidget()=0;
76  void setupViewport(int, int);
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 isReadyToEncode();
86  void resetRecording();
87  void encodeVideo();
88  bool generateMpegEncoderParameters();
89  void displayRecordingStatus();
90
91protected:
92  void CreateGLQtContext ();
93  virtual void CreateMainWindow (QGLWidget*);
94  void manageContextMenuEvent(QContextMenuEvent *e);
95#if QT_VERSION < 0x040000
96  void G4MousePressEvent(QPoint);
97#else
98  void G4MousePressEvent(QPoint);
99#endif
100  void G4MouseReleaseEvent();
101  void G4MouseDoubleClickEvent(QPoint p);
102#if QT_VERSION < 0x040000
103  void G4MouseMoveEvent(int, int, Qt::ButtonState);
104#else
105  void G4MouseMoveEvent(int, int, Qt::MouseButtons);
106#endif
107  void G4wheelEvent (QWheelEvent * event);
108  void G4keyPressEvent (QKeyEvent * event);
109  void rotateQtScene(float, float);
110  void rotateQtCamera(float, float);
111  void moveScene(float, float, float,bool);
112
113
114protected:
115  G4int WinSize_x;
116  G4int WinSize_y;
117  QGLWidget* fWindow;
118  QDialog* GLWindow;
119  bool hasPendingEvents();
120  void savePPMToTemp();
121  int fRecordFrameNumber;
122  float fRotationAngleX;
123  float fRotationAngleY;
124  float fRotationAngleZ;
125  float fDeltaRotationAngleX;
126  float fDeltaRotationAngleY;
127  float fDeltaRotationAngleZ;
128
129private:
130  enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4};
131  enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS};
132
133  void createPopupMenu();
134  void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
135  void rescaleImage(int, int);
136  bool generateEPS(QString,int,QImage); 
137  bool generateVectorEPS (QString,int,int,QImage);
138  bool generatePS_PDF(QString,int,QImage); 
139  void showMovieParametersDialog();
140  void initMovieParameters();
141  QString createTempFolder();
142  QString removeTempFolder();
143  void startPauseVideo();
144  void stopVideo();
145  void setRecordingStatus(RECORDING_STEP);
146  void setRecordingInfos(QString);
147  QString getProcessErrorMsg();
148
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 fLaunchSpinDelay;
197
198signals:
199 void rotateTheta(int);
200 void rotatePhi(int);
201 void moveX(int);
202 void moveY(int);
203 void moveZ(int);
204
205private slots :
206  void actionMouseRotate();
207  void actionMouseMove();
208  void actionMousePick();
209  void actionDrawingWireframe();
210  void actionDrawingLineRemoval();
211  void actionDrawingSurfaceRemoval();
212  void actionDrawingLineSurfaceRemoval();
213  void actionSaveImage();
214  void actionMovieParameters();
215
216  void showShortcuts();
217  void toggleDrawingAction(int);
218  void toggleMouseAction(mouseActions);
219  void toggleRepresentation(bool);
220  void toggleProjection(bool);
221  void toggleBackground(bool);
222  void toggleTransparency(bool);
223  void toggleAntialiasing(bool);
224  void toggleHaloing(bool);
225  void toggleAux(bool);
226  void toggleFullScreen(bool);
227  void processEncodeFinished();
228  void processLookForFinished();
229  void processEncodeStdout();
230  // Only use for Qt>4.0
231  //  void dialogClosed();
232};
233
234#endif
235
236#endif
Note: See TracBrowser for help on using the repository browser.