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