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