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

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

Add some signals

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