34 #if defined (G4VIS_BUILD_OPENGLQT_DRIVER) || defined (G4VIS_USE_OPENGLQT)
36 #ifndef G4OPENGLQTVIEWER_HH
37 #define G4OPENGLQTVIEWER_HH
49 class G4OpenGLSceneHandler;
57 class QContextMenuEvent;
70 class QTreeWidgetItem;
73 class G4OpenGLSceneHandler;
74 class G4OpenGLQtMovieDialog;
76 #if QT_VERSION < 0x050600
81 class QTableWidgetItem;
85 class G4OpenGLQtViewer:
public QObject,
virtual public G4OpenGLViewer {
90 typedef std::vector<PVNodeID>
PVPath;
93 G4OpenGLQtViewer (G4OpenGLSceneHandler& scene);
94 virtual ~G4OpenGLQtViewer ();
95 #ifdef G4MULTITHREADED
98 virtual void DoneWithMasterThread ();
100 virtual void MovingToVisSubThread ();
102 virtual void SwitchToVisSubThread ();
104 virtual void DoneWithVisSubThread ();
108 virtual void SwitchToMasterThread ();
112 G4OpenGLQtViewer (
const G4OpenGLQtViewer&);
113 G4OpenGLQtViewer& operator= (
const G4OpenGLQtViewer&);
115 virtual void updateQWidget()=0;
116 void updateSceneTreeWidget();
117 void updateViewerPropertiesTableWidget();
118 void updatePickInfosWidget(
int,
int);
119 QString setEncoderPath(QString path);
120 QString getEncoderPath();
121 QString setTempFolderPath(QString path);
122 QString getTempFolderPath();
123 QString setSaveFileName(QString path);
124 QString getSaveFileName();
138 void setBadEncoder();
139 bool isReadyToEncode();
140 void resetRecording();
144 bool generateMpegEncoderParameters();
145 void displayRecordingStatus();
146 void DrawText(
const G4Text&);
150 int currentPVPOIndex);
152 int currentPVPOIndex,
153 const std::string& modelDescription,
155 bool isTouchableVisible(
int POindex);
156 void clearTreeWidget();
157 bool exportImage(std::string
name=
"",
int width=-1,
int height=-1);
160 void G4MousePressEvent(QMouseEvent *event);
161 void G4wheelEvent (QWheelEvent * event);
162 void G4keyPressEvent (QKeyEvent * event);
163 void G4keyReleaseEvent (QKeyEvent * event);
164 void G4MouseDoubleClickEvent();
165 void G4MouseReleaseEvent(QMouseEvent *evnt);
166 void G4MouseMoveEvent(QMouseEvent *event);
169 void CreateGLQtContext ();
170 virtual void CreateMainWindow (QGLWidget*,
const QString&);
171 void G4manageContextMenuEvent(QContextMenuEvent *
e);
172 void rotateQtScene(
float,
float);
173 void rotateQtSceneToggle(
float,
float);
174 void moveScene(
float,
float,
float,
bool);
176 void updateKeyModifierState(
const Qt::KeyboardModifiers&);
177 void displaySceneTreeComponent();
178 G4Colour getColorForPoIndex(
int poIndex);
183 const std::vector<G4ModelingParameters::VisAttributesModifier>*
184 GetPrivateVisAttributesModifiers()
const;
185 bool isCurrentWidget();
189 void savePPMToTemp();
190 int fRecordFrameNumber;
194 bool fQGLWidgetInitialiseCompleted;
195 bool fPaintEventLock;
201 bool fMouseOnSceneTree;
204 enum RECORDING_STEP {WAIT,
START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,
ENCODING,FAILED,
SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
206 void createPopupMenu();
207 void createRadioAction(QAction *,QAction *,
const std::string&,
unsigned int a=1);
208 void rescaleImage(
int,
int);
209 bool printPDF(
const std::string,
int,QImage);
210 void showMovieParametersDialog();
211 void initMovieParameters();
212 QString createTempFolder();
213 QString removeTempFolder();
214 void setRecordingStatus(RECORDING_STEP);
215 void setRecordingInfos(
const QString&);
216 QString getProcessErrorMsg();
217 QWidget* getParentWidget();
218 bool parseAndInsertInSceneTree(QTreeWidgetItem *,
220 unsigned int fullPathIndex,
221 const QString& parentRoot,
222 unsigned int currentIndex,
223 int currentPVPOIndex);
224 void setCheckComponent(QTreeWidgetItem* item,
bool check);
225 void createSceneTreeComponent();
226 void createSceneTreeWidget();
227 void createViewerPropertiesWidget();
228 void createPickInfosWidget();
229 bool parseAndCheckVisibility(QTreeWidgetItem * treeNode,
int POindex);
230 QTreeWidgetItem* createTreeWidgetItem(
const PVPath& fullPath,
234 const QString& logicalName,
235 Qt::CheckState state,
236 QTreeWidgetItem * treeNode,
238 QString getModelShortName(
const G4String& modelShortName);
239 void cloneSceneTree(QTreeWidgetItem* rootItem);
240 void changeDepthOnSceneTreeItem(
double lookForDepth,
double currentDepth,QTreeWidgetItem* item);
241 void updatePositivePoIndexSceneTreeWidgetQuickMap(
int POindex,QTreeWidgetItem* item);
242 void changeQColorForTreeWidgetItem(QTreeWidgetItem* item,
const QColor&);
244 bool isSameSceneTreeElement(QTreeWidgetItem* parentOldItem,QTreeWidgetItem* parentNewItem);
245 void changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(QTreeWidgetItem* subItem);
246 bool isPVVolume(QTreeWidgetItem* item);
247 QTreeWidgetItem* cloneWidgetItem(QTreeWidgetItem* item);
248 void clearSceneTreeSelection(QTreeWidgetItem*);
249 void clearTreeWidgetElements(QTreeWidgetItem* item);
252 QTreeWidgetItem* getTreeWidgetItem(
int POindex);
255 QTreeWidgetItem* getOldTreeWidgetItem(
int POindex);
258 std::string parseSceneTreeAndSaveState();
260 std::string parseSceneTreeElementAndSaveState(QTreeWidgetItem* item,
unsigned int level);
261 QString GetCommandParameterList (
const G4UIcommand *aCommand);
262 void changeColorAndTransparency(GLuint index,
G4Color color);
264 #ifdef G4MULTITHREADED
265 inline void SetQGLContextVisSubThread(QThread *th) {
266 fQGLContextVisSubThread = th;
268 inline void SetQGLContextMainThread(QThread *th) {
269 fQGLContextMainThread = th;
277 QPoint fLastPickPoint;
288 bool fHoldRotateEvent;
290 QString fEncoderPath;
291 QString fTempFolderPath;
292 QString fMovieTempFolderPath;
293 QString fSaveFileName;
294 QString fParameterFileName;
295 QAction *fMouseRotateAction;
296 QAction *fMouseMoveAction;
297 QAction *fMousePickAction;
298 QAction *fMouseZoomInAction;
299 QAction *fMouseZoomOutAction;
300 QAction *fFullScreenOn;
301 QAction *fFullScreenOff;
302 QAction *fDrawingWireframe;
303 QAction *fDrawingLineRemoval;
304 QAction *fDrawingSurfaceRemoval;
305 QAction *fDrawingLineSurfaceRemoval;
306 QAction *fProjectionOrtho;
307 QAction *fProjectionPerspective;
308 G4OpenGLQtMovieDialog* fMovieParametersDialog;
309 RECORDING_STEP fRecordingStep;
311 QTime *fLastEventTime;
313 int fNbMaxFramesPerSec;
314 float fNbMaxAnglePerSec;
315 int fLaunchSpinDelay;
316 QWidget* fUISceneTreeWidget;
317 QWidget* fUIViewerPropertiesWidget;
318 QWidget* fUIPickInfosWidget;
321 bool fControlKeyPress;
324 bool fCheckSceneTreeComponentSignalLock;
325 bool fViewerPropertiesTableWidgetIsInit;
326 QTreeWidget* fSceneTreeComponentTreeWidget;
328 QWidget* fSceneTreeWidget;
329 bool fPVRootNodeCreate;
330 QLineEdit* fFilterOutput;
331 QString fFileSavePath;
334 QString fTouchableVolumes;
335 QDialog* fShortcutsDialog;
336 QTableWidget *fViewerPropertiesTableWidget;
337 QWidget* fPickInfosWidget;
338 QScrollArea* fPickInfosScrollArea;
339 int fTreeWidgetInfosIgnoredCommands;
340 QPushButton * fSceneTreeButtonApply;
341 QTextEdit *fShortcutsDialogInfos;
342 QSlider* fSceneTreeDepthSlider;
343 std::map <int, PVPath > fTreeItemModels;
344 std::map <int, PVPath > fOldTreeItemModels;
347 std::map <int, QTreeWidgetItem*> fPositivePoIndexSceneTreeWidgetQuickMap;
349 std::map <int, QTreeWidgetItem*> fOldPositivePoIndexSceneTreeWidgetQuickMap;
350 std::vector <QTreeWidgetItem*> fOldNullPoIndexSceneTreeWidgetQuickVector;
352 std::map <int, QColor> fOldVisAttrColorMap;
354 unsigned int fSceneTreeDepth;
355 QTreeWidgetItem* fModelShortNameItem;
357 int fMaxPOindexInserted;
359 #if QT_VERSION < 0x050600
360 QSignalMapper *fSignalMapperMouse;
361 QSignalMapper *fSignalMapperSurface;
362 QSignalMapper *fSignalMapperPicking;
365 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIterator;
366 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIteratorEnd;
369 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIterator;
370 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIteratorEnd;
373 QPixmap* fTreeIconOpen;
374 QPixmap* fTreeIconClosed;
375 QPixmap* fSearchIcon;
377 int fLastExportSliderValue;
379 GLuint fLastHighlightName;
382 #ifdef G4MULTITHREADED
383 QThread* fQGLContextVisSubThread;
384 QThread* fQGLContextMainThread;
388 G4AutoLock* lWaitForVisSubThreadQtOpenGLContextInitialized;
389 G4AutoLock* lWaitForVisSubThreadQtOpenGLContextMoved;
392 void startPauseVideo();
395 void updateToolbarAndMouseContextMenu();
398 void actionSaveImage();
399 void actionChangeBackgroundColor();
400 void actionChangeTextColor();
401 void actionChangeDefaultColor();
402 void actionMovieParameters();
404 void showShortcuts();
405 void toggleMouseAction(
int);
406 void toggleSurfaceAction(
int);
407 void toggleProjection(
bool);
408 void toggleTransparency(
bool);
409 void toggleAntialiasing(
bool);
410 void toggleHaloing(
bool);
411 void toggleAux(
bool);
412 void toggleHiddenMarkers(
bool);
413 void toggleFullScreen(
bool);
414 void processEncodeFinished();
415 void processLookForFinished();
416 void processEncodeStdout();
417 void sceneTreeComponentItemChanged(QTreeWidgetItem* item,
int id);
418 void toggleSceneTreeComponentPickingCout(
int);
419 void togglePicking();
420 void currentTabActivated(
int);
423 void sceneTreeComponentSelected();
424 void changeDepthInSceneTree(
int);
425 void changeSearchSelection();
426 void changeColorAndTransparency(QTreeWidgetItem* item,
int val);
427 void tableWidgetViewerSetItemChanged(QTableWidgetItem *);