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

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

change debug definition, and tag for files

  • 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.14 2009/01/19 16:08: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 "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 QString setEncoderPath(QString path);
76 QString getEncoderPath();
77 QString setTempFolderPath(QString path);
78 QString getTempFolderPath();
79 QString setSaveFileName(QString path);
80 QString getSaveFileName();
81 bool isRecording();
82 bool isStopped();
83 bool isPaused();
84 bool isEncoding();
85 bool isWaiting();
86 bool isFailed();
87 void setWaiting();
88 bool isBadEncoder();
89 bool isBadOutput();
90 bool isBadTmp();
91 bool isSuccess();
92 void setBadTmp();
93 void setBadOutput();
94 void setBadEncoder();
95 bool isReadyToEncode();
96 void resetRecording();
97 void encodeVideo();
98 void stopVideo();
99 void saveVideo();
100 bool generateMpegEncoderParameters();
101 void displayRecordingStatus();
102
103protected:
104 void CreateGLQtContext ();
105 virtual void CreateMainWindow (QGLWidget*,QString);
106 void G4manageContextMenuEvent(QContextMenuEvent *e);
107 void G4MousePressEvent(QMouseEvent *event);
108 void G4MouseReleaseEvent();
109 void G4MouseDoubleClickEvent();
110 void G4MouseMoveEvent(QMouseEvent *event);
111 void G4wheelEvent (QWheelEvent * event);
112 void G4keyPressEvent (QKeyEvent * event);
113 void rotateQtScene(float, float);
114 void rotateQtCamera(float, float);
115 void moveScene(float, float, float,bool);
116 void FinishView();
117
118
119protected:
120 QGLWidget* fWindow;
121 QDialog* GLWindow;
122 bool hasPendingEvents();
123 void savePPMToTemp();
124 int fRecordFrameNumber;
125 float fRotationAngleX;
126 float fRotationAngleY;
127 float fRotationAngleZ;
128 float fDeltaRotationAngleX;
129 float fDeltaRotationAngleY;
130 float fDeltaRotationAngleZ;
131
132 bool hasToRepaint;
133 bool readyToPaint;
134 bool zoomAction;
135 QPoint beginZoom;
136 QPoint endZoom;
137
138private:
139 enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4};
140 enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
141
142 void createPopupMenu();
143 void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
144 void rescaleImage(int, int);
145 bool generateEPS(QString,int,QImage);
146 bool generateVectorEPS (QString,int,int,QImage);
147 bool generatePS_PDF(QString,int,QImage);
148 void showMovieParametersDialog();
149 void initMovieParameters();
150 QString createTempFolder();
151 QString removeTempFolder();
152 void setRecordingStatus(RECORDING_STEP);
153 void setRecordingInfos(QString);
154 QString getProcessErrorMsg();
155
156
157#if QT_VERSION < 0x040000
158 QPopupMenu *fContextMenu;
159#else
160 QMenu *fContextMenu;
161#endif
162
163 mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts
164 QPoint fLastPos1;
165 QPoint fLastPos2;
166 QPoint fLastPos3;
167 /** delta of scene rotation. This delta is put in degree */
168 G4double fDeltaRotation;
169 /** delta of scene translation. This delta is put in % of the scene view */
170 G4double fDeltaSceneTranslation;
171 /** delta of depth move. This delta is put in % of the scene view */
172 G4double fDeltaDepth;
173 /** delta of zoom move. This delta is put in % of the scene view */
174 G4double fDeltaZoom;
175 /** delta of auto move/rotation. This delta is put in % of the move/rotation param */
176 G4double fDeltaMove;
177 /** To ensure key event are keep one by one */
178 bool fHoldKeyEvent;
179 /** To ensure move event are keep one by one */
180 bool fHoldMoveEvent;
181 /** To ensure rotate event are keep one by one */
182 bool fHoldRotateEvent;
183 bool fAutoMove;
184 QString fEncoderPath;
185 QString fTempFolderPath;
186 QString fMovieTempFolderPath;
187 QString fSaveFileName;
188 QString fParameterFileName;
189 QAction *fRotateAction;
190 QAction *fMoveAction;
191 QAction *fPickAction;
192 QAction *fFullScreenOn;
193 QAction *fFullScreenOff;
194 QAction *fDrawingWireframe;
195 QAction *fDrawingLineRemoval;
196 QAction *fDrawingSurfaceRemoval;
197 QAction *fDrawingLineSurfaceRemoval;
198 G4OpenGLQtMovieDialog* fMovieParametersDialog;
199 RECORDING_STEP fRecordingStep;
200 QProcess *fProcess;
201 QTime *fLastEventTime;
202 int fSpinningDelay;
203 int fLaunchSpinDelay;
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.