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

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

OpenGL Qt improvments. See History file

  • 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.13 2008/11/06 13:43:44 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 virtual void updateQWidget()=0;
75 void setupViewport(int, int);
76 QString setEncoderPath(QString path);
77 QString getEncoderPath();
78 QString setTempFolderPath(QString path);
79 QString getTempFolderPath();
80 QString setSaveFileName(QString path);
81 QString getSaveFileName();
82 bool isRecording();
83 bool isStopped();
84 bool isPaused();
85 bool isEncoding();
86 bool isWaiting();
87 bool isFailed();
88 void setWaiting();
89 bool isBadEncoder();
90 bool isBadOutput();
91 bool isBadTmp();
92 bool isSuccess();
93 void setBadTmp();
94 void setBadOutput();
95 void setBadEncoder();
96 bool isReadyToEncode();
97 void resetRecording();
98 void encodeVideo();
99 void stopVideo();
100 void saveVideo();
101 bool generateMpegEncoderParameters();
102 void displayRecordingStatus();
103
104protected:
105 void CreateGLQtContext ();
106 virtual void CreateMainWindow (QGLWidget*,QString);
107 void G4resizeGL(int, int);
108 void G4manageContextMenuEvent(QContextMenuEvent *e);
109 void G4MousePressEvent(QMouseEvent *event);
110 void G4MouseReleaseEvent();
111 void G4MouseDoubleClickEvent();
112 void G4MouseMoveEvent(QMouseEvent *event);
113 void G4wheelEvent (QWheelEvent * event);
114 void G4keyPressEvent (QKeyEvent * event);
115 void rotateQtScene(float, float);
116 void rotateQtCamera(float, float);
117 void moveScene(float, float, float,bool);
118 void FinishView();
119
120
121protected:
122 G4int WinSize_x;
123 G4int WinSize_y;
124 QGLWidget* fWindow;
125 QDialog* GLWindow;
126 bool hasPendingEvents();
127 void savePPMToTemp();
128 int fRecordFrameNumber;
129 float fRotationAngleX;
130 float fRotationAngleY;
131 float fRotationAngleZ;
132 float fDeltaRotationAngleX;
133 float fDeltaRotationAngleY;
134 float fDeltaRotationAngleZ;
135
136 bool hasToRepaint;
137 bool readyToPaint;
138 bool zoomAction;
139 QPoint beginZoom;
140 QPoint endZoom;
141
142private:
143 enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4};
144 enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
145
146 void createPopupMenu();
147 void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
148 void rescaleImage(int, int);
149 bool generateEPS(QString,int,QImage);
150 bool generateVectorEPS (QString,int,int,QImage);
151 bool generatePS_PDF(QString,int,QImage);
152 void showMovieParametersDialog();
153 void initMovieParameters();
154 QString createTempFolder();
155 QString removeTempFolder();
156 void setRecordingStatus(RECORDING_STEP);
157 void setRecordingInfos(QString);
158 QString getProcessErrorMsg();
159
160
161#if QT_VERSION < 0x040000
162 QPopupMenu *fContextMenu;
163#else
164 QMenu *fContextMenu;
165#endif
166
167 mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts
168 QPoint fLastPos1;
169 QPoint fLastPos2;
170 QPoint fLastPos3;
171 /** delta of scene rotation. This delta is put in degree */
172 G4double fDeltaRotation;
173 /** delta of scene translation. This delta is put in % of the scene view */
174 G4double fDeltaSceneTranslation;
175 /** delta of depth move. This delta is put in % of the scene view */
176 G4double fDeltaDepth;
177 /** delta of zoom move. This delta is put in % of the scene view */
178 G4double fDeltaZoom;
179 /** delta of auto move/rotation. This delta is put in % of the move/rotation param */
180 G4double fDeltaMove;
181 /** To ensure key event are keep one by one */
182 bool fHoldKeyEvent;
183 /** To ensure move event are keep one by one */
184 bool fHoldMoveEvent;
185 /** To ensure rotate event are keep one by one */
186 bool fHoldRotateEvent;
187 bool fAutoMove;
188 QString fEncoderPath;
189 QString fTempFolderPath;
190 QString fMovieTempFolderPath;
191 QString fSaveFileName;
192 QString fParameterFileName;
193 QAction *fRotateAction;
194 QAction *fMoveAction;
195 QAction *fPickAction;
196 QAction *fFullScreenOn;
197 QAction *fFullScreenOff;
198 QAction *fDrawingWireframe;
199 QAction *fDrawingLineRemoval;
200 QAction *fDrawingSurfaceRemoval;
201 QAction *fDrawingLineSurfaceRemoval;
202 G4OpenGLQtMovieDialog* fMovieParametersDialog;
203 RECORDING_STEP fRecordingStep;
204 QProcess *fProcess;
205 QTime *fLastEventTime;
206 int fSpinningDelay;
207 int fLaunchSpinDelay;
208
209signals:
210 void rotateTheta(int);
211 void rotatePhi(int);
212 void moveX(int);
213 void moveY(int);
214 void moveZ(int);
215
216public slots :
217 void startPauseVideo();
218
219private slots :
220 void actionMouseRotate();
221 void actionMouseMove();
222 void actionMousePick();
223 void actionDrawingWireframe();
224 void actionDrawingLineRemoval();
225 void actionDrawingSurfaceRemoval();
226 void actionDrawingLineSurfaceRemoval();
227 void actionSaveImage();
228 void actionMovieParameters();
229
230 void showShortcuts();
231 void toggleDrawingAction(int);
232 void toggleMouseAction(mouseActions);
233 void toggleRepresentation(bool);
234 void toggleProjection(bool);
235 void toggleBackground(bool);
236 void toggleTransparency(bool);
237 void toggleAntialiasing(bool);
238 void toggleHaloing(bool);
239 void toggleAux(bool);
240 void toggleFullScreen(bool);
241 void processEncodeFinished();
242 void processLookForFinished();
243 void processEncodeStdout();
244 // Only use for Qt>4.0
245 // void dialogClosed();
246};
247
248#endif
249
250#endif
Note: See TracBrowser for help on using the repository browser.