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_OPENGLQT_DRIVER
00034
00035 #ifndef G4OPENGLQTVIEWER_HH
00036 #define G4OPENGLQTVIEWER_HH
00037
00038 #include "globals.hh"
00039
00040 #include "G4OpenGLViewer.hh"
00041 #include "G4PhysicalVolumeModel.hh"
00042
00043 #include <qobject.h>
00044 #include <qpoint.h>
00045
00046 class G4OpenGLSceneHandler;
00047 class G4UImanager;
00048 class G4Text;
00049
00050 class QGLWidget;
00051 class QDialog;
00052 class QTextEdit;
00053 class QContextMenuEvent;
00054 class QMenu;
00055 class QImage;
00056 class QAction;
00057 class QTabWidget;
00058 class QMouseEvent;
00059 class QKeyEvent;
00060 class QWheelEvent;
00061 class QProcess;
00062 class QTime;
00063 class QVBoxLayout;
00064 class QPushButton;
00065 class QSlider;
00066 class QTreeWidgetItem;
00067 class QTreeWidget;
00068 class QColor;
00069 class G4OpenGLSceneHandler;
00070 class G4OpenGLQtMovieDialog;
00071 class QLineEdit;
00072 class QSignalMapper;
00073 class G4UIQt;
00074
00075 class G4OpenGLQtViewer: public QObject, virtual public G4OpenGLViewer {
00076
00077 Q_OBJECT
00078
00079 typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID;
00080 typedef std::vector<PVNodeID> PVPath;
00081
00082 public:
00083 G4OpenGLQtViewer (G4OpenGLSceneHandler& scene);
00084 virtual ~G4OpenGLQtViewer ();
00085 private:
00086 G4OpenGLQtViewer (const G4OpenGLQtViewer&);
00087 G4OpenGLQtViewer& operator= (const G4OpenGLQtViewer&);
00088 public:
00089 virtual void updateQWidget()=0;
00090 QString setEncoderPath(QString path);
00091 QString getEncoderPath();
00092 QString setTempFolderPath(QString path);
00093 QString getTempFolderPath();
00094 QString setSaveFileName(QString path);
00095 QString getSaveFileName();
00096 bool isRecording();
00097 bool isStopped();
00098 bool isPaused();
00099 bool isEncoding();
00100 bool isWaiting();
00101 bool isFailed();
00102 void setWaiting();
00103 bool isBadEncoder();
00104 bool isBadOutput();
00105 bool isBadTmp();
00106 bool isSuccess();
00107 void setBadTmp();
00108 void setBadOutput();
00109 void setBadEncoder();
00110 bool isReadyToEncode();
00111 void resetRecording();
00112 void encodeVideo();
00113 void stopVideo();
00114 void saveVideo();
00115 bool generateMpegEncoderParameters();
00116 void displayRecordingStatus();
00117 void DrawText(const G4Text&);
00118 void ResetView ();
00119 void addPVSceneTreeElement(const G4String& model,
00120 G4PhysicalVolumeModel* pPVModel,
00121 int currentPVPOIndex);
00122 void addNonPVSceneTreeElement(const G4String& model,
00123 int currentPVPOIndex,
00124 const std::string& modelDescription,
00125 const G4Visible& visible);
00126 bool isTouchableVisible(int POindex);
00127 void clearTreeWidget();
00128 public:
00129 void G4MousePressEvent(QMouseEvent *event);
00130 void G4wheelEvent (QWheelEvent * event);
00131 void G4keyPressEvent (QKeyEvent * event);
00132 void G4MouseDoubleClickEvent();
00133 void G4MouseReleaseEvent();
00134 void G4MouseMoveEvent(QMouseEvent *event);
00135
00136 protected:
00137 void CreateGLQtContext ();
00138 virtual void CreateMainWindow (QGLWidget*,const QString&);
00139 void G4manageContextMenuEvent(QContextMenuEvent *e);
00140 void rotateQtScene(float, float);
00141 void rotateQtSceneToggle(float, float);
00142 void moveScene(float, float, float,bool);
00143 void FinishView();
00144 void updateKeyModifierState(const Qt::KeyboardModifiers&);
00145 void displaySceneTreeComponent();
00146 G4Colour getColorForPoIndex(int poIndex);
00147
00148 protected:
00149 QGLWidget* fWindow;
00150 QWidget* fGLWindow;
00151 bool hasPendingEvents();
00152 void savePPMToTemp();
00153 int fRecordFrameNumber;
00154
00155 bool fHasToRepaint;
00156 bool fReadyToPaint;
00157 bool fIsRepainting;
00158
00159 private:
00160 enum RECORDING_STEP {WAIT,START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
00161
00162 void createPopupMenu();
00163 void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1);
00164 void rescaleImage(int, int);
00165 bool printPDF(const std::string,int,QImage);
00166 void showMovieParametersDialog();
00167 void initMovieParameters();
00168 QString createTempFolder();
00169 QString removeTempFolder();
00170 void setRecordingStatus(RECORDING_STEP);
00171 void setRecordingInfos(const QString&);
00172 QString getProcessErrorMsg();
00173 QWidget* getParentWidget();
00174 bool parseAndInsertInSceneTree(QTreeWidgetItem *,
00175 G4PhysicalVolumeModel* pPVModel,
00176 unsigned int fullPathIndex,
00177 const QString& parentRoot,
00178 unsigned int currentIndex,
00179 int currentPVPOIndex);
00180 void setCheckComponent(QTreeWidgetItem* item,bool check);
00181 void initSceneTreeComponent();
00182 bool parseAndCheckVisibility(QTreeWidgetItem * treeNode,int POindex);
00183 QTreeWidgetItem* createTreeWidgetItem(const PVPath& fullPath,
00184 const QString& name,
00185 int copyNb,
00186 int POIndex,
00187 const QString& logicalName,
00188 Qt::CheckState state,
00189 QTreeWidgetItem * treeNode,
00190 const G4Colour& color);
00191 QString getModelShortName(const G4String& modelShortName);
00192 void cloneSceneTree(QTreeWidgetItem* rootItem);
00193 void changeDepthOnSceneTreeItem(double lookForDepth,double currentDepth,QTreeWidgetItem* item);
00194 void updatePositivePoIndexSceneTreeWidgetQuickMap(int POindex,QTreeWidgetItem* item);
00195 void changeQColorForTreeWidgetItem(QTreeWidgetItem* item, const QColor&);
00196
00197 bool isSameSceneTreeElement(QTreeWidgetItem* parentOldItem,QTreeWidgetItem* parentNewItem);
00198 void changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(QTreeWidgetItem* subItem);
00199 bool isPVVolume(QTreeWidgetItem* item);
00200 QTreeWidgetItem* cloneWidgetItem(QTreeWidgetItem* item);
00201 void clearSceneTreeSelection(QTreeWidgetItem*);
00202 void clearTreeWidgetElements(QTreeWidgetItem* item);
00203
00204
00205 QTreeWidgetItem* getTreeWidgetItem(int POindex);
00206
00207
00208 QTreeWidgetItem* getOldTreeWidgetItem(int POindex);
00209
00210
00211 QMenu *fContextMenu;
00212 QPoint fLastPos1;
00213 QPoint fLastPos2;
00214 QPoint fLastPos3;
00215
00216
00217 G4double fDeltaDepth;
00218
00219 G4double fDeltaZoom;
00220
00221 bool fHoldKeyEvent;
00222
00223 bool fHoldMoveEvent;
00224
00225 bool fHoldRotateEvent;
00226 bool fAutoMove;
00227 QString fEncoderPath;
00228 QString fTempFolderPath;
00229 QString fMovieTempFolderPath;
00230 QString fSaveFileName;
00231 QString fParameterFileName;
00232 QAction *fMouseRotateAction;
00233 QAction *fMouseMoveAction;
00234 QAction *fMousePickAction;
00235 QAction *fMouseZoomInAction;
00236 QAction *fMouseZoomOutAction;
00237 QAction *fFullScreenOn;
00238 QAction *fFullScreenOff;
00239 QAction *fDrawingWireframe;
00240 QAction *fDrawingLineRemoval;
00241 QAction *fDrawingSurfaceRemoval;
00242 QAction *fDrawingLineSurfaceRemoval;
00243 QAction *fProjectionOrtho;
00244 QAction *fProjectionPerspective;
00245 G4OpenGLQtMovieDialog* fMovieParametersDialog;
00246 RECORDING_STEP fRecordingStep;
00247 QProcess *fProcess;
00248 QTime *fLastEventTime;
00249 int fSpinningDelay;
00250 int fNbMaxFramesPerSec;
00251 float fNbMaxAnglePerSec;
00252 int fLaunchSpinDelay;
00253 QTabWidget* fUISceneTreeComponentsTBWidget;
00254 bool fNoKeyPress;
00255 bool fAltKeyPress;
00256 bool fControlKeyPress;
00257 bool fShiftKeyPress;
00258 bool fBatchMode;
00259 bool fCheckSceneTreeComponentSignalLock;
00260 QTreeWidget* fSceneTreeComponentTreeWidget;
00261
00262 QTreeWidget* fOldSceneTreeComponentTreeWidget;
00263 QWidget* fSceneTreeWidget;
00264 bool fPVRootNodeCreate;
00265 QLineEdit* fHelpLine;
00266
00267
00268 int fNbRotation ;
00269 int fTimeRotation;
00270 QString fTouchableVolumes;
00271 QDialog* fShortcutsDialog;
00272 QTextEdit *fTreeInfoDialogInfos;
00273 QPushButton * fSceneTreeButtonApply;
00274 QTextEdit *fShortcutsDialogInfos;
00275 QSlider* fSceneTreeDepthSlider;
00276 std::map <int, PVPath > fTreeItemModels;
00277 std::map <int, PVPath > fOldTreeItemModels;
00278
00279
00280 std::map <int, QTreeWidgetItem*> fPositivePoIndexSceneTreeWidgetQuickMap;
00281
00282 std::map <int, QTreeWidgetItem*> fOldPositivePoIndexSceneTreeWidgetQuickMap;
00283 std::vector <QTreeWidgetItem*> fOldNullPoIndexSceneTreeWidgetQuickVector;
00284
00285 std::map <int, QColor> fOldVisAttrColorMap;
00286
00287 unsigned int fSceneTreeDepth;
00288 QTreeWidgetItem* fModelShortNameItem;
00289 int fNumber;
00290 int fMaxPOindexInserted;
00291 G4UIQt* fUiQt;
00292 QSignalMapper *signalMapperMouse;
00293 QSignalMapper *signalMapperSurface;
00294
00295
00296 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskFor;
00297
00298
00299 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskFor;
00300
00301
00302 public Q_SLOTS :
00303 void startPauseVideo();
00304
00305 protected Q_SLOTS :
00306 void updateToolbarAndMouseContextMenu();
00307
00308 private Q_SLOTS :
00309 void actionSaveImage();
00310 void actionChangeBackgroundColor();
00311 void actionChangeTextColor();
00312 void actionChangeDefaultColor();
00313 void actionMovieParameters();
00314
00315 void showShortcuts();
00316 void toggleMouseAction(int);
00317 void toggleSurfaceAction(int);
00318 void toggleRepresentation(bool);
00319 void toggleProjection(bool);
00320 void toggleTransparency(bool);
00321 void toggleAntialiasing(bool);
00322 void toggleHaloing(bool);
00323 void toggleAux(bool);
00324 void toggleHiddenMarkers(bool);
00325 void toggleFullScreen(bool);
00326 void processEncodeFinished();
00327 void processLookForFinished();
00328 void processEncodeStdout();
00329 void sceneTreeComponentItemChanged(QTreeWidgetItem* item, int id);
00330
00331
00332 void sceneTreeComponentSelected();
00333 void changeDepthInSceneTree(int);
00334 void changeSearchSelection();
00335 void changeColorAndTransparency(QTreeWidgetItem* item,int val);
00336 };
00337
00338 #endif
00339
00340 #endif