34#if defined (G4VIS_BUILD_OPENGLQT_DRIVER) || defined (G4VIS_USE_OPENGLQT)
36#ifndef G4OPENGLQTVIEWER_HH
37#define G4OPENGLQTVIEWER_HH
49class G4OpenGLSceneHandler;
57class QContextMenuEvent;
74class G4OpenGLSceneHandler;
75class G4OpenGLQtMovieDialog;
77#if QT_VERSION < 0x050600
82class QTableWidgetItem;
86class G4OpenGLQtViewer:
public QObject,
virtual public G4OpenGLViewer {
91 typedef std::vector<PVNodeID>
PVPath;
94 G4OpenGLQtViewer (G4OpenGLSceneHandler& scene);
95 virtual ~G4OpenGLQtViewer ();
99 virtual void DoneWithMasterThread ();
101 virtual void MovingToVisSubThread ();
103 virtual void SwitchToVisSubThread ();
105 virtual void DoneWithVisSubThread ();
109 virtual void SwitchToMasterThread ();
113 G4OpenGLQtViewer (
const G4OpenGLQtViewer&);
114 G4OpenGLQtViewer& operator= (
const G4OpenGLQtViewer&);
116 virtual void updateQWidget()=0;
117 void updateSceneTreeWidget();
118 void updateViewerPropertiesTableWidget();
119 void updatePickInfosWidget(
int,
int);
120 QString setEncoderPath(QString path);
121 QString getEncoderPath();
122 QString setTempFolderPath(QString path);
123 QString getTempFolderPath();
124 QString setSaveFileName(QString path);
125 QString getSaveFileName();
139 void setBadEncoder();
140 bool isReadyToEncode();
141 void resetRecording();
145 bool generateMpegEncoderParameters();
146 void displayRecordingStatus();
147 void DrawText(
const G4Text&);
149 void addPVSceneTreeElement(
const G4String& model,
151 int currentPVPOIndex);
152 void addNonPVSceneTreeElement(
const G4String& model,
153 int currentPVPOIndex,
154 const std::string& modelDescription,
156 bool isTouchableVisible(
int POindex);
157 void clearTreeWidget();
158 bool exportImage(std::string name=
"",
int width=-1,
int height=-1);
161 void G4MousePressEvent(QMouseEvent *event);
162 void G4wheelEvent (QWheelEvent * event);
163 void G4keyPressEvent (QKeyEvent * event);
164 void G4keyReleaseEvent (QKeyEvent * event);
165 void G4MouseDoubleClickEvent();
166 void G4MouseReleaseEvent(QMouseEvent *evnt);
167 void G4MouseMoveEvent(QMouseEvent *event);
170 void CreateGLQtContext ();
171 virtual void CreateMainWindow (QGLWidget*,
const QString&);
172 void G4manageContextMenuEvent(QContextMenuEvent *e);
173 void rotateQtScene(
float,
float);
174 void rotateQtSceneToggle(
float,
float);
175 void moveScene(
float,
float,
float,
bool);
177 void updateKeyModifierState(
const Qt::KeyboardModifiers&);
178 void displaySceneTreeComponent();
179 G4Colour getColorForPoIndex(
int poIndex);
184 const std::vector<G4ModelingParameters::VisAttributesModifier>*
185 GetPrivateVisAttributesModifiers()
const;
186 bool isCurrentWidget();
190 void savePPMToTemp();
191 int fRecordFrameNumber;
195 bool fQGLWidgetInitialiseCompleted;
196 bool fPaintEventLock;
202 bool fMouseOnSceneTree;
205 enum RECORDING_STEP {WAIT,
START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,
ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
207 void createPopupMenu();
208 void createRadioAction(QAction *,QAction *,
const std::string&,
unsigned int a=1);
209 void rescaleImage(
int,
int);
210 bool printPDF(
const std::string,
int,QImage);
211 void showMovieParametersDialog();
212 void initMovieParameters();
213 QString createTempFolder();
214 QString removeTempFolder();
215 void setRecordingStatus(RECORDING_STEP);
216 void setRecordingInfos(
const QString&);
217 QString getProcessErrorMsg();
218 QWidget* getParentWidget();
219 bool parseAndInsertInSceneTree(QTreeWidgetItem *,
221 unsigned int fullPathIndex,
222 const QString& parentRoot,
223 unsigned int currentIndex,
224 int currentPVPOIndex);
225 void setCheckComponent(QTreeWidgetItem* item,
bool check);
226 void createSceneTreeComponent();
227 void createSceneTreeWidget();
228 void createViewerPropertiesWidget();
229 void createPickInfosWidget();
230 bool parseAndCheckVisibility(QTreeWidgetItem * treeNode,
int POindex);
231 QTreeWidgetItem* createTreeWidgetItem(
const PVPath& fullPath,
235 const QString& logicalName,
236 Qt::CheckState state,
237 QTreeWidgetItem * treeNode,
239 QString getModelShortName(
const G4String& modelShortName);
240 void cloneSceneTree(QTreeWidgetItem* rootItem);
241 void changeDepthOnSceneTreeItem(
double lookForDepth,
double currentDepth,QTreeWidgetItem* item);
242 void updatePositivePoIndexSceneTreeWidgetQuickMap(
int POindex,QTreeWidgetItem* item);
243 void changeQColorForTreeWidgetItem(QTreeWidgetItem* item,
const QColor&);
245 bool isSameSceneTreeElement(QTreeWidgetItem* parentOldItem,QTreeWidgetItem* parentNewItem);
246 void changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(QTreeWidgetItem* subItem);
247 bool isPVVolume(QTreeWidgetItem* item);
248 QTreeWidgetItem* cloneWidgetItem(QTreeWidgetItem* item);
249 void clearSceneTreeSelection(QTreeWidgetItem*);
250 void clearTreeWidgetElements(QTreeWidgetItem* item);
253 QTreeWidgetItem* getTreeWidgetItem(
int POindex);
256 QTreeWidgetItem* getOldTreeWidgetItem(
int POindex);
259 std::string parseSceneTreeAndSaveState();
261 std::string parseSceneTreeElementAndSaveState(QTreeWidgetItem* item,
unsigned int level);
262 QString GetCommandParameterList (
const G4UIcommand *aCommand);
263 void changeColorAndTransparency(GLuint index,
G4Color color);
265#ifdef G4MULTITHREADED
266 inline void SetQGLContextVisSubThread(QThread *th) {
267 fQGLContextVisSubThread = th;
269 inline void SetQGLContextMainThread(QThread *th) {
270 fQGLContextMainThread = th;
278 QPoint fLastPickPoint;
289 bool fHoldRotateEvent;
291 QString fEncoderPath;
292 QString fTempFolderPath;
293 QString fMovieTempFolderPath;
294 QString fSaveFileName;
295 QString fParameterFileName;
296 QAction *fMouseRotateAction;
297 QAction *fMouseMoveAction;
298 QAction *fMousePickAction;
299 QAction *fMouseZoomInAction;
300 QAction *fMouseZoomOutAction;
301 QAction *fFullScreenOn;
302 QAction *fFullScreenOff;
303 QAction *fDrawingWireframe;
304 QAction *fDrawingLineRemoval;
305 QAction *fDrawingSurfaceRemoval;
306 QAction *fDrawingLineSurfaceRemoval;
307 QAction *fProjectionOrtho;
308 QAction *fProjectionPerspective;
309 G4OpenGLQtMovieDialog* fMovieParametersDialog;
310 RECORDING_STEP fRecordingStep;
312#if QT_VERSION < 0x050e00
313 QTime *fLastEventTime;
315 QElapsedTimer *fLastEventTime;
318 int fNbMaxFramesPerSec;
319 float fNbMaxAnglePerSec;
320 int fLaunchSpinDelay;
321 QWidget* fUISceneTreeWidget;
322 QWidget* fUIViewerPropertiesWidget;
323 QWidget* fUIPickInfosWidget;
326 bool fControlKeyPress;
329 bool fCheckSceneTreeComponentSignalLock;
330 bool fViewerPropertiesTableWidgetIsInit;
331 QTreeWidget* fSceneTreeComponentTreeWidget;
333 QWidget* fSceneTreeWidget;
334 bool fPVRootNodeCreate;
335 QLineEdit* fFilterOutput;
336 QString fFileSavePath;
339 QString fTouchableVolumes;
340 QDialog* fShortcutsDialog;
341 QTableWidget *fViewerPropertiesTableWidget;
342 QWidget* fPickInfosWidget;
343 QScrollArea* fPickInfosScrollArea;
344 int fTreeWidgetInfosIgnoredCommands;
345 QPushButton * fSceneTreeButtonApply;
346 QTextEdit *fShortcutsDialogInfos;
347 QSlider* fSceneTreeDepthSlider;
348 std::map <int, PVPath > fTreeItemModels;
349 std::map <int, PVPath > fOldTreeItemModels;
352 std::map <int, QTreeWidgetItem*> fPositivePoIndexSceneTreeWidgetQuickMap;
354 std::map <int, QTreeWidgetItem*> fOldPositivePoIndexSceneTreeWidgetQuickMap;
355 std::vector <QTreeWidgetItem*> fOldNullPoIndexSceneTreeWidgetQuickVector;
357 std::map <int, QColor> fOldVisAttrColorMap;
359 unsigned int fSceneTreeDepth;
360 QTreeWidgetItem* fModelShortNameItem;
362 int fMaxPOindexInserted;
364#if QT_VERSION < 0x050600
365 QSignalMapper *fSignalMapperMouse;
366 QSignalMapper *fSignalMapperSurface;
367 QSignalMapper *fSignalMapperPicking;
370 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIterator;
371 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIteratorEnd;
374 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIterator;
375 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIteratorEnd;
378 QPixmap* fTreeIconOpen;
379 QPixmap* fTreeIconClosed;
380 QPixmap* fSearchIcon;
382 int fLastExportSliderValue;
384 GLuint fLastHighlightName;
387#ifdef G4MULTITHREADED
388 QThread* fQGLContextVisSubThread;
389 QThread* fQGLContextMainThread;
393 G4AutoLock* lWaitForVisSubThreadQtOpenGLContextInitialized;
394 G4AutoLock* lWaitForVisSubThreadQtOpenGLContextMoved;
397 void startPauseVideo();
400 void updateToolbarAndMouseContextMenu();
403 void actionSaveImage();
404 void actionChangeBackgroundColor();
405 void actionChangeTextColor();
406 void actionChangeDefaultColor();
407 void actionMovieParameters();
409 void showShortcuts();
410 void toggleMouseAction(
int);
411 void toggleSurfaceAction(
int);
412 void toggleProjection(
bool);
413 void toggleTransparency(
bool);
414 void toggleAntialiasing(
bool);
415 void toggleHaloing(
bool);
416 void toggleAux(
bool);
417 void toggleHiddenMarkers(
bool);
418 void toggleFullScreen(
bool);
419 void processEncodeFinished();
420 void processLookForFinished();
421 void processEncodeStdout();
422 void sceneTreeComponentItemChanged(QTreeWidgetItem* item,
int id);
423 void toggleSceneTreeComponentPickingCout(
int);
424 void togglePicking();
425 void currentTabActivated(
int);
428 void sceneTreeComponentSelected();
429 void changeDepthInSceneTree(
int);
430 void changeSearchSelection();
431 void changeColorAndTransparency(QTreeWidgetItem* item,
int val);
432 void tableWidgetViewerSetItemChanged(QTableWidgetItem *);
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
std::vector< PVNodeID > PVPath