source: trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh@ 802

Last change on this file since 802 was 801, checked in by garnier, 18 years ago

r840@wl-72126: garnier | 2008-05-16 17:45:55 +0200
en test avec de nouveaux calculs...

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