00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
00034
00035 #ifndef G4OPENGLWTVIEWER_HH
00036 #define G4OPENGLWTVIEWER_HH
00037
00038 #include "globals.hh"
00039
00040 #include "G4OpenGLViewer.hh"
00041
00042 #include <Wt/WObject>
00043 #include <Wt/WPoint>
00044 #include <Wt/WTime>
00045
00046 class G4OpenGLSceneHandler;
00047 class G4UImanager;
00048
00049 class WDialog;
00050 #ifdef _A_FINIR_FIXME
00051 class WContextMenuEvent;
00052 #endif
00053 class WMenu;
00054 class WImage;
00055 #ifdef _A_FINIR_FIXME
00056 class WWheelEvent;
00057 #endif
00058 class WProcess;
00059
00060 class G4OpenGLSceneHandler;
00061 class G4OpenGLWtMovieDialog;
00062
00063 class G4OpenGLWtViewer: public Wt::WObject, virtual public G4OpenGLViewer {
00064
00065 public:
00066 G4OpenGLWtViewer (G4OpenGLSceneHandler& scene);
00067 virtual ~G4OpenGLWtViewer ();
00068 void SetView ();
00069 virtual void updateWWidget()=0;
00070 #ifdef _A_FINIR_FIXME
00071 Wt::WString setEncoderPath(Wt::WString path);
00072 Wt::WString getEncoderPath();
00073 Wt::WString setTempFolderPath(Wt::WString path);
00074 Wt::WString getTempFolderPath();
00075 Wt::WString setSaveFileName(Wt::WString path);
00076 Wt::WString getSaveFileName();
00077 bool isRecording();
00078 bool isStopped();
00079 bool isPaused();
00080 bool isEncoding();
00081 bool isWaiting();
00082 bool isFailed();
00083 void setWaiting();
00084 bool isBadEncoder();
00085 bool isBadOutput();
00086 bool isBadTmp();
00087 bool isSuccess();
00088 void setBadTmp();
00089 void setBadOutput();
00090 void setBadEncoder();
00091 bool isReadyToEncode();
00092 void resetRecording();
00093 void encodeVideo();
00094 void stopVideo();
00095 void saveVideo();
00096 bool generateMpegEncoderParameters();
00097 void displayRecordingStatus();
00098 #endif
00099 void drawText(const char * ,int x,int y,int z, int size);
00100
00101 protected:
00102 void CreateGLWtContext ();
00103 virtual void CreateMainWindow (Wt::WGLWidget*,Wt::WString);
00104 #ifdef _A_FINIR_FIXME
00105 void G4manageContextMenuEvent(Wt::WContextMenuEvent *e);
00106 #endif
00107 void G4MousePressEvent(Wt::WMouseEvent *event);
00108 void G4MouseReleaseEvent();
00109 void G4MouseDoubleClickEvent();
00110 void G4MouseMoveEvent(Wt::WMouseEvent *event);
00111 #ifdef _A_FINIR_FIXME
00112 void G4wheelEvent (Wt::WWheelEvent * event);
00113 #endif
00114 void G4keyPressEvent (Wt::WKeyEvent * event);
00115 void rotateWtScene(float, float);
00116 void rotateWtCamera(float, float);
00117 void rotateWtSceneInViewDirection(float, float);
00118 void rotateWtCameraInViewDirection(float, float);
00119 void moveScene(float, float, float,bool);
00120 void FinishView();
00121 #ifdef _A_FINIR_FIXME
00122 void updateKeyModifierState(Wt::KeyboardModifiers);
00123 #endif
00124
00125 protected:
00126 Wt::WGLWidget* fWindow;
00127 Wt::WWidget* fGLWindow;
00128 bool hasPendingEvents();
00129 #ifdef _A_FINIR_FIXME
00130 void savePPMToTemp();
00131 #endif
00132 int fRecordFrameNumber;
00133
00134 bool fHasToRepaint;
00135 bool fReadyToPaint;
00136 bool fIsRepainting;
00137
00138 private:
00139 enum mouseActions {STYLE1,STYLE2,STYLE3,STYLE4};
00140 enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
00141
00142 #ifdef _A_FINIR_FIXME
00143 void createPopupMenu();
00144 void createRadioAction(Wt::WAction *,Wt::WAction *, const std::string&,unsigned int a=1);
00145 #endif
00146 void rescaleImage(int, int);
00147 #ifdef _A_FINIR_FIXME
00148 bool printPDF(const std::string,int,WImage);
00149 void showMovieParametersDialog();
00150 void initMovieParameters();
00151 Wt::WString createTempFolder();
00152 Wt::WString removeTempFolder();
00153 void setRecordingStatus(RECORDING_STEP);
00154 void setRecordingInfos(Wt::WString);
00155 Wt::WString getProcessErrorMsg();
00156
00157 WMenu *fContextMenu;
00158 #endif
00159
00160 mouseActions fMouseAction;
00161 Wt::WPoint fLastPos1;
00162 Wt::WPoint fLastPos2;
00163 Wt::WPoint fLastPos3;
00165 G4double fDeltaRotation;
00167 G4double fDeltaSceneTranslation;
00169 G4double fDeltaDepth;
00171 G4double fDeltaZoom;
00173 G4double fDeltaMove;
00175 bool fHoldKeyEvent;
00177 bool fHoldMoveEvent;
00179 bool fHoldRotateEvent;
00180 bool fAutoMove;
00181 Wt::WString fEncoderPath;
00182 Wt::WString fTempFolderPath;
00183 Wt::WString fMovieTempFolderPath;
00184 Wt::WString fSaveFileName;
00185 Wt::WString fParameterFileName;
00186 #ifdef _A_FINIR_FIXME
00187 WAction *fRotateAction;
00188 WAction *fMoveAction;
00189 WAction *fPickAction;
00190 WAction *fFullScreenOn;
00191 WAction *fFullScreenOff;
00192 WAction *fDrawingWireframe;
00193 WAction *fDrawingLineRemoval;
00194 WAction *fDrawingSurfaceRemoval;
00195 WAction *fDrawingLineSurfaceRemoval;
00196 #endif
00197 G4OpenGLWtMovieDialog* fMovieParametersDialog;
00198 RECORDING_STEP fRecordingStep;
00199 WProcess *fProcess;
00200 Wt::WTime *fLastEventTime;
00201 int fSpinningDelay;
00202 int fNbMaxFramesPerSec;
00203 float fNbMaxAnglePerSec;
00204 int fLaunchSpinDelay;
00205
00206 G4double fXRot;
00207 G4double fYRot;
00208 bool fNoKeyPress;
00209 bool fAltKeyPress;
00210 bool fControlKeyPress;
00211 bool fShiftKeyPress;
00212
00213 #ifdef _A_FINIR_FIXME
00214 void rotateTheta(int);
00215 void rotatePhi(int);
00216 void moveX(int);
00217 void moveY(int);
00218 void moveZ(int);
00219 #endif
00220
00221 public :
00222 void startPauseVideo();
00223
00224 private :
00225 #ifdef _A_FINIR_FIXME
00226 void actionMouseRotate();
00227 void actionMouseMove();
00228 void actionMousePick();
00229 void actionDrawingWireframe();
00230 void actionDrawingLineRemoval();
00231 void actionDrawingSurfaceRemoval();
00232 void actionDrawingLineSurfaceRemoval();
00233 void actionSaveImage();
00234 void actionChangeBackgroundColor();
00235 void actionChangeTextColor();
00236 void actionChangeDefaultColor();
00237 void actionMovieParameters();
00238 #endif
00239
00240 void showShortcuts();
00241 #ifdef _A_FINIR_FIXME
00242 void toggleDrawingAction(int);
00243 void toggleMouseAction(mouseActions);
00244 void toggleRepresentation(bool);
00245 void toggleProjection(bool);
00246 void toggleTransparency(bool);
00247 void toggleAntialiasing(bool);
00248 void toggleHaloing(bool);
00249 void toggleAux(bool);
00250 void toggleFullScreen(bool);
00251 #endif
00252 void processEncodeFinished();
00253 void processLookForFinished();
00254 void processEncodeStdout();
00255
00256
00257 };
00258
00259 #endif
00260
00261 #endif