[1350] | 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.25 2010/10/08 10:07:31 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 <qobject.h> |
---|
| 42 | #include "G4OpenGLViewer.hh" |
---|
| 43 | |
---|
| 44 | #include <qpoint.h> |
---|
| 45 | |
---|
| 46 | class G4OpenGLSceneHandler; |
---|
| 47 | class G4UImanager; |
---|
| 48 | |
---|
| 49 | class QGLWidget; |
---|
| 50 | class QDialog; |
---|
| 51 | class QContextMenuEvent; |
---|
| 52 | #if QT_VERSION < 0x040000 |
---|
| 53 | class QPopupMenu; |
---|
| 54 | #else |
---|
| 55 | class QMenu; |
---|
| 56 | #endif |
---|
| 57 | class QImage; |
---|
| 58 | class QAction; |
---|
| 59 | class QMouseEvent; |
---|
| 60 | class QKeyEvent; |
---|
| 61 | class QWheelEvent; |
---|
| 62 | class QProcess; |
---|
| 63 | class QTime; |
---|
| 64 | |
---|
| 65 | class G4OpenGLSceneHandler; |
---|
| 66 | class G4OpenGLQtMovieDialog; |
---|
| 67 | |
---|
| 68 | class G4OpenGLQtViewer: public QObject, virtual public G4OpenGLViewer { |
---|
| 69 | |
---|
| 70 | Q_OBJECT |
---|
| 71 | |
---|
| 72 | public: |
---|
| 73 | G4OpenGLQtViewer (G4OpenGLSceneHandler& scene); |
---|
| 74 | virtual ~G4OpenGLQtViewer (); |
---|
| 75 | void SetView (); |
---|
| 76 | virtual void updateQWidget()=0; |
---|
| 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 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(); |
---|
| 97 | bool isReadyToEncode(); |
---|
| 98 | void resetRecording(); |
---|
| 99 | void encodeVideo(); |
---|
| 100 | void stopVideo(); |
---|
| 101 | void saveVideo(); |
---|
| 102 | bool generateMpegEncoderParameters(); |
---|
| 103 | void displayRecordingStatus(); |
---|
| 104 | void drawText(const char * ,int x,int y,int z, int size); |
---|
| 105 | |
---|
| 106 | protected: |
---|
| 107 | void CreateGLQtContext (); |
---|
| 108 | virtual void CreateMainWindow (QGLWidget*,QString); |
---|
| 109 | void G4manageContextMenuEvent(QContextMenuEvent *e); |
---|
| 110 | void G4MousePressEvent(QMouseEvent *event); |
---|
| 111 | void G4MouseReleaseEvent(); |
---|
| 112 | void G4MouseDoubleClickEvent(); |
---|
| 113 | void G4MouseMoveEvent(QMouseEvent *event); |
---|
| 114 | void G4wheelEvent (QWheelEvent * event); |
---|
| 115 | void G4keyPressEvent (QKeyEvent * event); |
---|
| 116 | void rotateQtScene(float, float); |
---|
| 117 | void rotateQtCamera(float, float); |
---|
| 118 | void rotateQtSceneInViewDirection(float, float); |
---|
| 119 | void rotateQtCameraInViewDirection(float, float); |
---|
| 120 | void moveScene(float, float, float,bool); |
---|
| 121 | void FinishView(); |
---|
| 122 | #if QT_VERSION < 0x040000 |
---|
| 123 | void updateKeyModifierState(Qt::ButtonState); |
---|
| 124 | #else |
---|
| 125 | void updateKeyModifierState(Qt::KeyboardModifiers); |
---|
| 126 | #endif |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | protected: |
---|
| 130 | QGLWidget* fWindow; |
---|
| 131 | QWidget* fGLWindow; |
---|
| 132 | bool hasPendingEvents(); |
---|
| 133 | void savePPMToTemp(); |
---|
| 134 | int fRecordFrameNumber; |
---|
| 135 | |
---|
| 136 | bool fHasToRepaint; |
---|
| 137 | bool fReadyToPaint; |
---|
| 138 | bool fIsRepainting; |
---|
| 139 | |
---|
| 140 | private: |
---|
| 141 | enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4}; |
---|
| 142 | enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE}; |
---|
| 143 | |
---|
| 144 | void createPopupMenu(); |
---|
| 145 | void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1); |
---|
| 146 | void rescaleImage(int, int); |
---|
| 147 | bool printPDF(const std::string,int,QImage); |
---|
| 148 | void showMovieParametersDialog(); |
---|
| 149 | void initMovieParameters(); |
---|
| 150 | QString createTempFolder(); |
---|
| 151 | QString removeTempFolder(); |
---|
| 152 | void setRecordingStatus(RECORDING_STEP); |
---|
| 153 | void setRecordingInfos(QString); |
---|
| 154 | QString getProcessErrorMsg(); |
---|
| 155 | QWidget* getParentWidget(); |
---|
| 156 | |
---|
| 157 | #if QT_VERSION < 0x040000 |
---|
| 158 | QPopupMenu *fContextMenu; |
---|
| 159 | #else |
---|
| 160 | QMenu *fContextMenu; |
---|
| 161 | #endif |
---|
| 162 | |
---|
| 163 | mouseActions fMouseAction; // 1: rotate 2:move 3:pick 4:shortcuts |
---|
| 164 | QPoint fLastPos1; |
---|
| 165 | QPoint fLastPos2; |
---|
| 166 | QPoint fLastPos3; |
---|
| 167 | /** delta of scene rotation. This delta is put in degree */ |
---|
| 168 | G4double fDeltaRotation; |
---|
| 169 | /** delta of scene translation. This delta is put in % of the scene view */ |
---|
| 170 | G4double fDeltaSceneTranslation; |
---|
| 171 | /** delta of depth move. This delta is put in % of the scene view */ |
---|
| 172 | G4double fDeltaDepth; |
---|
| 173 | /** delta of zoom move. This delta is put in % of the scene view */ |
---|
| 174 | G4double fDeltaZoom; |
---|
| 175 | /** delta of auto move/rotation. This delta is put in % of the move/rotation param */ |
---|
| 176 | G4double fDeltaMove; |
---|
| 177 | /** To ensure key event are keep one by one */ |
---|
| 178 | bool fHoldKeyEvent; |
---|
| 179 | /** To ensure move event are keep one by one */ |
---|
| 180 | bool fHoldMoveEvent; |
---|
| 181 | /** To ensure rotate event are keep one by one */ |
---|
| 182 | bool fHoldRotateEvent; |
---|
| 183 | bool fAutoMove; |
---|
| 184 | QString fEncoderPath; |
---|
| 185 | QString fTempFolderPath; |
---|
| 186 | QString fMovieTempFolderPath; |
---|
| 187 | QString fSaveFileName; |
---|
| 188 | QString fParameterFileName; |
---|
| 189 | QAction *fRotateAction; |
---|
| 190 | QAction *fMoveAction; |
---|
| 191 | QAction *fPickAction; |
---|
| 192 | QAction *fFullScreenOn; |
---|
| 193 | QAction *fFullScreenOff; |
---|
| 194 | QAction *fDrawingWireframe; |
---|
| 195 | QAction *fDrawingLineRemoval; |
---|
| 196 | QAction *fDrawingSurfaceRemoval; |
---|
| 197 | QAction *fDrawingLineSurfaceRemoval; |
---|
| 198 | G4OpenGLQtMovieDialog* fMovieParametersDialog; |
---|
| 199 | RECORDING_STEP fRecordingStep; |
---|
| 200 | QProcess *fProcess; |
---|
| 201 | QTime *fLastEventTime; |
---|
| 202 | int fSpinningDelay; |
---|
| 203 | int fNbMaxFramesPerSec; |
---|
| 204 | float fNbMaxAnglePerSec; |
---|
| 205 | int fLaunchSpinDelay; |
---|
| 206 | |
---|
| 207 | G4double fXRot; |
---|
| 208 | G4double fYRot; |
---|
| 209 | bool fNoKeyPress; |
---|
| 210 | bool fAltKeyPress; |
---|
| 211 | bool fControlKeyPress; |
---|
| 212 | bool fShiftKeyPress; |
---|
| 213 | |
---|
| 214 | signals: |
---|
| 215 | void rotateTheta(int); |
---|
| 216 | void rotatePhi(int); |
---|
| 217 | void moveX(int); |
---|
| 218 | void moveY(int); |
---|
| 219 | void moveZ(int); |
---|
| 220 | |
---|
| 221 | public slots : |
---|
| 222 | void startPauseVideo(); |
---|
| 223 | |
---|
| 224 | private slots : |
---|
| 225 | void actionMouseRotate(); |
---|
| 226 | void actionMouseMove(); |
---|
| 227 | void actionMousePick(); |
---|
| 228 | void actionDrawingWireframe(); |
---|
| 229 | void actionDrawingLineRemoval(); |
---|
| 230 | void actionDrawingSurfaceRemoval(); |
---|
| 231 | void actionDrawingLineSurfaceRemoval(); |
---|
| 232 | void actionSaveImage(); |
---|
| 233 | void actionChangeBackgroundColor(); |
---|
| 234 | void actionChangeTextColor(); |
---|
| 235 | void actionChangeDefaultColor(); |
---|
| 236 | void actionMovieParameters(); |
---|
| 237 | |
---|
| 238 | void showShortcuts(); |
---|
| 239 | void toggleDrawingAction(int); |
---|
| 240 | void toggleMouseAction(mouseActions); |
---|
| 241 | void toggleRepresentation(bool); |
---|
| 242 | void toggleProjection(bool); |
---|
| 243 | void toggleTransparency(bool); |
---|
| 244 | void toggleAntialiasing(bool); |
---|
| 245 | void toggleHaloing(bool); |
---|
| 246 | void toggleAux(bool); |
---|
| 247 | void toggleFullScreen(bool); |
---|
| 248 | void processEncodeFinished(); |
---|
| 249 | void processLookForFinished(); |
---|
| 250 | void processEncodeStdout(); |
---|
| 251 | // Only use for Qt>4.0 |
---|
| 252 | // void dialogClosed(); |
---|
| 253 | }; |
---|
| 254 | |
---|
| 255 | #endif |
---|
| 256 | |
---|
| 257 | #endif |
---|