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

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

add DrawText

  • Property svn:mime-type set to text/cpp
File size: 7.2 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.17 2009/05/13 10:28:00 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 "G4OpenGLViewer.hh"
42
43#include <qobject.h>
44#include <qpoint.h>
45
46class G4OpenGLSceneHandler;
47
48class QGLWidget;
49class QDialog;
50class QContextMenuEvent;
51#if QT_VERSION < 0x040000
52class QPopupMenu;
53#else
54class QMenu;
55#endif
56class QImage;
57class QAction;
58class QMouseEvent;
59class QKeyEvent;
60class QWheelEvent;
61class QProcess;
62class QTime;
63
64class G4OpenGLSceneHandler;
65class G4OpenGLQtMovieDialog;
66
67class G4OpenGLQtViewer: public QObject, virtual public G4OpenGLViewer {
68
69 Q_OBJECT
70
71public:
72 G4OpenGLQtViewer (G4OpenGLSceneHandler& scene);
73 virtual ~G4OpenGLQtViewer ();
74 void SetView ();
75 virtual void updateQWidget()=0;
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 void drawText(const char * ,int x,int y,int z, int size);
104
105protected:
106 void CreateGLQtContext ();
107 virtual void CreateMainWindow (QGLWidget*,QString);
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 QGLWidget* fWindow;
123 QDialog* fGLWindow;
124 bool hasPendingEvents();
125 void savePPMToTemp();
126 int fRecordFrameNumber;
127 float fRotationAngleX;
128 float fRotationAngleY;
129 float fRotationAngleZ;
130 float fDeltaRotationAngleX;
131 float fDeltaRotationAngleY;
132 float fDeltaRotationAngleZ;
133
134 bool fHasToRepaint;
135 bool fReadyToPaint;
136
137private:
138 enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4};
139 enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
140
141 void createPopupMenu();
142 void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
143 void rescaleImage(int, int);
144 bool printPDF(const std::string,int,QImage);
145 void showMovieParametersDialog();
146 void initMovieParameters();
147 QString createTempFolder();
148 QString removeTempFolder();
149 void setRecordingStatus(RECORDING_STEP);
150 void setRecordingInfos(QString);
151 QString getProcessErrorMsg();
152
153
154#if QT_VERSION < 0x040000
155 QPopupMenu *fContextMenu;
156#else
157 QMenu *fContextMenu;
158#endif
159
160 mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts
161 QPoint fLastPos1;
162 QPoint fLastPos2;
163 QPoint fLastPos3;
164 /** delta of scene rotation. This delta is put in degree */
165 G4double fDeltaRotation;
166 /** delta of scene translation. This delta is put in % of the scene view */
167 G4double fDeltaSceneTranslation;
168 /** delta of depth move. This delta is put in % of the scene view */
169 G4double fDeltaDepth;
170 /** delta of zoom move. This delta is put in % of the scene view */
171 G4double fDeltaZoom;
172 /** delta of auto move/rotation. This delta is put in % of the move/rotation param */
173 G4double fDeltaMove;
174 /** To ensure key event are keep one by one */
175 bool fHoldKeyEvent;
176 /** To ensure move event are keep one by one */
177 bool fHoldMoveEvent;
178 /** To ensure rotate event are keep one by one */
179 bool fHoldRotateEvent;
180 bool fAutoMove;
181 QString fEncoderPath;
182 QString fTempFolderPath;
183 QString fMovieTempFolderPath;
184 QString fSaveFileName;
185 QString fParameterFileName;
186 QAction *fRotateAction;
187 QAction *fMoveAction;
188 QAction *fPickAction;
189 QAction *fFullScreenOn;
190 QAction *fFullScreenOff;
191 QAction *fDrawingWireframe;
192 QAction *fDrawingLineRemoval;
193 QAction *fDrawingSurfaceRemoval;
194 QAction *fDrawingLineSurfaceRemoval;
195 G4OpenGLQtMovieDialog* fMovieParametersDialog;
196 RECORDING_STEP fRecordingStep;
197 QProcess *fProcess;
198 QTime *fLastEventTime;
199 int fSpinningDelay;
200 int fLaunchSpinDelay;
201
202signals:
203 void rotateTheta(int);
204 void rotatePhi(int);
205 void moveX(int);
206 void moveY(int);
207 void moveZ(int);
208
209public slots :
210 void startPauseVideo();
211
212private slots :
213 void actionMouseRotate();
214 void actionMouseMove();
215 void actionMousePick();
216 void actionDrawingWireframe();
217 void actionDrawingLineRemoval();
218 void actionDrawingSurfaceRemoval();
219 void actionDrawingLineSurfaceRemoval();
220 void actionSaveImage();
221 void actionMovieParameters();
222
223 void showShortcuts();
224 void toggleDrawingAction(int);
225 void toggleMouseAction(mouseActions);
226 void toggleRepresentation(bool);
227 void toggleProjection(bool);
228 void toggleBackground(bool);
229 void toggleTransparency(bool);
230 void toggleAntialiasing(bool);
231 void toggleHaloing(bool);
232 void toggleAux(bool);
233 void toggleFullScreen(bool);
234 void processEncodeFinished();
235 void processLookForFinished();
236 void processEncodeStdout();
237 // Only use for Qt>4.0
238 // void dialogClosed();
239};
240
241#endif
242
243#endif
Note: See TracBrowser for help on using the repository browser.