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

Last change on this file since 866 was 866, checked in by garnier, 17 years ago

see history

  • Property svn:mime-type set to text/cpp
File size: 7.4 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.12 2008/10/15 10:24:04 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 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
105protected:
106 void CreateGLQtContext ();
107 virtual void CreateMainWindow (QGLWidget*,QString);
108 void manageContextMenuEvent(QContextMenuEvent *e);
109#if QT_VERSION < 0x040000
110 void G4MousePressEvent(QPoint);
111#else
112 void G4MousePressEvent(QPoint);
113#endif
114 void G4MouseReleaseEvent();
115 void G4MouseDoubleClickEvent(QPoint p);
116#if QT_VERSION < 0x040000
117 void G4MouseMoveEvent(int, int, Qt::ButtonState);
118#else
119 void G4MouseMoveEvent(int, int, Qt::MouseButtons);
120#endif
121 void G4wheelEvent (QWheelEvent * event);
122 void G4keyPressEvent (QKeyEvent * event);
123 void rotateQtScene(float, float);
124 void rotateQtCamera(float, float);
125 void moveScene(float, float, float,bool);
126
127
128protected:
129 G4int WinSize_x;
130 G4int WinSize_y;
131 QGLWidget* fWindow;
132 QDialog* GLWindow;
133 bool hasPendingEvents();
134 void savePPMToTemp();
135 int fRecordFrameNumber;
136 float fRotationAngleX;
137 float fRotationAngleY;
138 float fRotationAngleZ;
139 float fDeltaRotationAngleX;
140 float fDeltaRotationAngleY;
141 float fDeltaRotationAngleZ;
142
143private:
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 void createPopupMenu();
148 void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
149 void rescaleImage(int, int);
150 bool generateEPS(QString,int,QImage);
151 bool generateVectorEPS (QString,int,int,QImage);
152 bool generatePS_PDF(QString,int,QImage);
153 void showMovieParametersDialog();
154 void initMovieParameters();
155 QString createTempFolder();
156 QString removeTempFolder();
157 void setRecordingStatus(RECORDING_STEP);
158 void setRecordingInfos(QString);
159 QString getProcessErrorMsg();
160
161
162#if QT_VERSION < 0x040000
163 QPopupMenu *fContextMenu;
164#else
165 QMenu *fContextMenu;
166#endif
167
168 mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts
169 QPoint fLastPos1;
170 QPoint fLastPos2;
171 QPoint fLastPos3;
172 /** delta of scene rotation. This delta is put in degree */
173 G4double fDeltaRotation;
174 /** delta of scene translation. This delta is put in % of the scene view */
175 G4double fDeltaSceneTranslation;
176 /** delta of depth move. This delta is put in % of the scene view */
177 G4double fDeltaDepth;
178 /** delta of zoom move. This delta is put in % of the scene view */
179 G4double fDeltaZoom;
180 /** delta of auto move/rotation. This delta is put in % of the move/rotation param */
181 G4double fDeltaMove;
182 /** To ensure key event are keep one by one */
183 bool fHoldKeyEvent;
184 /** To ensure move event are keep one by one */
185 bool fHoldMoveEvent;
186 /** To ensure rotate event are keep one by one */
187 bool fHoldRotateEvent;
188 bool fAutoMove;
189 QString fEncoderPath;
190 QString fTempFolderPath;
191 QString fMovieTempFolderPath;
192 QString fSaveFileName;
193 QString fParameterFileName;
194 QAction *fRotateAction;
195 QAction *fMoveAction;
196 QAction *fPickAction;
197 QAction *fFullScreenOn;
198 QAction *fFullScreenOff;
199 QAction *fDrawingWireframe;
200 QAction *fDrawingLineRemoval;
201 QAction *fDrawingSurfaceRemoval;
202 QAction *fDrawingLineSurfaceRemoval;
203 G4OpenGLQtMovieDialog* fMovieParametersDialog;
204 RECORDING_STEP fRecordingStep;
205 QProcess *fProcess;
206 QTime *fLastEventTime;
207 int fSpinningDelay;
208 int fLaunchSpinDelay;
209
210signals:
211 void rotateTheta(int);
212 void rotatePhi(int);
213 void moveX(int);
214 void moveY(int);
215 void moveZ(int);
216
217public slots :
218 void startPauseVideo();
219
220private slots :
221 void actionMouseRotate();
222 void actionMouseMove();
223 void actionMousePick();
224 void actionDrawingWireframe();
225 void actionDrawingLineRemoval();
226 void actionDrawingSurfaceRemoval();
227 void actionDrawingLineSurfaceRemoval();
228 void actionSaveImage();
229 void actionMovieParameters();
230
231 void showShortcuts();
232 void toggleDrawingAction(int);
233 void toggleMouseAction(mouseActions);
234 void toggleRepresentation(bool);
235 void toggleProjection(bool);
236 void toggleBackground(bool);
237 void toggleTransparency(bool);
238 void toggleAntialiasing(bool);
239 void toggleHaloing(bool);
240 void toggleAux(bool);
241 void toggleFullScreen(bool);
242 void processEncodeFinished();
243 void processLookForFinished();
244 void processEncodeStdout();
245 // Only use for Qt>4.0
246 // void dialogClosed();
247};
248
249#endif
250
251#endif
Note: See TracBrowser for help on using the repository browser.