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
RevLine 
[530]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//
[754]27// $Id: G4OpenGLQtViewer.hh,v 1.9 2008/03/11 16:05:56 lgarnier Exp $
[593]28// GEANT4 tag $Name: $
[530]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
[595]44#include <qobject.h>
45#include <qpoint.h>
[536]46
[593]47class QGLWidget;
48class QDialog;
49class QContextMenuEvent;
[600]50#if QT_VERSION < 0x040000
51class QPopupMenu;
52#else
[593]53class QMenu;
[600]54#endif
[593]55class QImage;
56class QAction;
[696]57class QMouseEvent;
58class QKeyEvent;
[804]59class QWheelEvent;
[750]60class QProcess;
[797]61class QTime;
[593]62
[530]63class G4OpenGLSceneHandler;
[731]64class G4OpenGLQtMovieDialog;
[530]65
[561]66class G4OpenGLQtViewer: public QObject, virtual public G4OpenGLViewer {
[530]67
[561]68 Q_OBJECT
69
[530]70public:
71 G4OpenGLQtViewer (G4OpenGLSceneHandler& scene);
72 virtual ~G4OpenGLQtViewer ();
73 void SetView ();
[800]74 void ClearView ();
[530]75 void ShowView ();
[561]76 virtual void updateQWidget()=0;
[673]77 void setupViewport(int, int);
[733]78 QString setEncoderPath(QString path);
[730]79 QString getEncoderPath();
[733]80 QString setTempFolderPath(QString path);
[732]81 QString getTempFolderPath();
[733]82 QString setSaveFileName(QString path);
83 QString getSaveFileName();
[745]84 bool isRecording();
[748]85 bool isStopped();
[745]86 bool isReadyToEncode();
[750]87 void resetRecording();
88 void encodeVideo();
[747]89 bool generateMpegEncoderParameters();
[752]90 void displayRecordingStatus();
[561]91
[530]92protected:
93 void CreateGLQtContext ();
[561]94 virtual void CreateMainWindow (QGLWidget*);
95 void manageContextMenuEvent(QContextMenuEvent *e);
[720]96#if QT_VERSION < 0x040000
[797]97 void G4MousePressEvent(QPoint);
[720]98#else
[797]99 void G4MousePressEvent(QPoint);
[720]100#endif
[797]101 void G4MouseReleaseEvent();
[673]102 void G4MouseDoubleClickEvent(QPoint p);
[600]103#if QT_VERSION < 0x040000
[797]104 void G4MouseMoveEvent(int, int, Qt::ButtonState);
[600]105#else
[797]106 void G4MouseMoveEvent(int, int, Qt::MouseButtons);
[600]107#endif
[804]108 void G4wheelEvent (QWheelEvent * event);
[696]109 void G4keyPressEvent (QKeyEvent * event);
[798]110 void rotateQtScene(float, float);
111 void rotateQtCamera(float, float);
112 void moveScene(float, float, float,bool);
[561]113
[600]114
[530]115protected:
116 G4int WinSize_x;
117 G4int WinSize_y;
[536]118 QGLWidget* fWindow;
[541]119 QDialog* GLWindow;
[720]120 bool hasPendingEvents();
[739]121 void savePPMToTemp();
[723]122 int fRecordFrameNumber;
[800]123 float fRotationAngleX;
124 float fRotationAngleY;
125 float fRotationAngleZ;
[801]126 float fDeltaRotationAngleX;
127 float fDeltaRotationAngleY;
128 float fDeltaRotationAngleZ;
[561]129
[530]130private:
[745]131 enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4};
[751]132 enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS};
[745]133
[561]134 void createPopupMenu();
135 void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
[585]136 void rescaleImage(int, int);
[588]137 bool generateEPS(QString,int,QImage);
[652]138 bool generateVectorEPS (QString,int,int,QImage);
[588]139 bool generatePS_PDF(QString,int,QImage);
[731]140 void showMovieParametersDialog();
[735]141 void initMovieParameters();
[741]142 QString createTempFolder();
143 QString removeTempFolder();
[744]144 void startPauseVideo();
145 void stopVideo();
146 void setRecordingStatus(RECORDING_STEP);
147 void setRecordingInfos(QString);
[754]148 QString getProcessErrorMsg();
[586]149
[744]150
[600]151#if QT_VERSION < 0x040000
152 QPopupMenu *fContextMenu;
153#else
[561]154 QMenu *fContextMenu;
[600]155#endif
[744]156
[713]157 mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts
[798]158 QPoint fLastPos1;
159 QPoint fLastPos2;
160 QPoint fLastPos3;
[713]161 /** delta of scene rotation. This delta is put in degree */
162 G4double fDeltaRotation;
[702]163 /** delta of scene translation. This delta is put in % of the scene view */
[712]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;
[721]169 /** delta of auto move/rotation. This delta is put in % of the move/rotation param */
170 G4double fDeltaMove;
[702]171 /** To ensure key event are keep one by one */
[721]172 bool fHoldKeyEvent;
[728]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;
[720]177 bool fAutoMove;
[730]178 QString fEncoderPath;
[732]179 QString fTempFolderPath;
[738]180 QString fMovieTempFolderPath;
[733]181 QString fSaveFileName;
[740]182 QString fParameterFileName;
[717]183 QAction *fRotateAction;
184 QAction *fMoveAction;
185 QAction *fPickAction;
186 QAction *fFullScreenOn;
187 QAction *fFullScreenOff;
[561]188 QAction *fDrawingWireframe;
189 QAction *fDrawingLineRemoval;
190 QAction *fDrawingSurfaceRemoval;
191 QAction *fDrawingLineSurfaceRemoval;
[732]192 G4OpenGLQtMovieDialog* fMovieParametersDialog;
[744]193 RECORDING_STEP fRecordingStep;
[749]194 QProcess *fProcess;
[797]195 QTime *fLastEventTime;
196 int fSpinningDelay;
[798]197 int fLaunchSpinDelay;
[561]198
[843]199signals:
200 void rotateTheta(int);
201 void rotatePhi(int);
202 void moveX(int);
203 void moveY(int);
204 void moveZ(int);
205
[561]206private slots :
[678]207 void actionMouseRotate();
[713]208 void actionMouseMove();
[681]209 void actionMousePick();
[561]210 void actionDrawingWireframe();
211 void actionDrawingLineRemoval();
212 void actionDrawingSurfaceRemoval();
213 void actionDrawingLineSurfaceRemoval();
[731]214 void actionSaveImage();
215 void actionMovieParameters();
[565]216
[721]217 void showShortcuts();
[561]218 void toggleDrawingAction(int);
[678]219 void toggleMouseAction(mouseActions);
[561]220 void toggleRepresentation(bool);
[702]221 void toggleProjection(bool);
[561]222 void toggleBackground(bool);
223 void toggleTransparency(bool);
224 void toggleAntialiasing(bool);
225 void toggleHaloing(bool);
226 void toggleAux(bool);
[717]227 void toggleFullScreen(bool);
[754]228 void processEncodeFinished();
229 void processLookForFinished();
230 void processEncodeStdout();
[656]231 // Only use for Qt>4.0
[711]232 // void dialogClosed();
[530]233};
234
235#endif
236
237#endif
Note: See TracBrowser for help on using the repository browser.