35 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER 37 #ifndef G4OPENGLQTVIEWER_HH 38 #define G4OPENGLQTVIEWER_HH 49 class G4OpenGLSceneHandler;
57 class QContextMenuEvent;
70 class QTreeWidgetItem;
73 class G4OpenGLSceneHandler;
74 class G4OpenGLQtMovieDialog;
79 class QTableWidgetItem;
83 class G4OpenGLQtViewer:
public QObject,
virtual public G4OpenGLViewer {
88 typedef std::vector<PVNodeID>
PVPath;
91 G4OpenGLQtViewer (G4OpenGLSceneHandler& scene);
92 virtual ~G4OpenGLQtViewer ();
93 #ifdef G4MULTITHREADED 96 virtual void DoneWithMasterThread ();
98 virtual void MovingToVisSubThread ();
100 virtual void SwitchToVisSubThread ();
102 virtual void DoneWithVisSubThread ();
106 virtual void SwitchToMasterThread ();
110 G4OpenGLQtViewer (
const G4OpenGLQtViewer&);
111 G4OpenGLQtViewer& operator= (
const G4OpenGLQtViewer&);
113 virtual void updateQWidget()=0;
114 void updateSceneTreeComponentTreeWidgetInfos();
115 QString setEncoderPath(QString path);
116 QString getEncoderPath();
117 QString setTempFolderPath(QString path);
118 QString getTempFolderPath();
119 QString setSaveFileName(QString path);
120 QString getSaveFileName();
134 void setBadEncoder();
135 bool isReadyToEncode();
136 void resetRecording();
140 bool generateMpegEncoderParameters();
141 void displayRecordingStatus();
142 void DrawText(
const G4Text&);
144 void addPVSceneTreeElement(
const G4String& model,
146 int currentPVPOIndex);
147 void addNonPVSceneTreeElement(
const G4String& model,
148 int currentPVPOIndex,
149 const std::string& modelDescription,
151 bool isTouchableVisible(
int POindex);
152 void clearTreeWidget();
153 bool exportImage(std::string
name=
"",
int width=-1,
int height=-1);
156 void G4MousePressEvent(QMouseEvent *event);
157 void G4wheelEvent (QWheelEvent * event);
158 void G4keyPressEvent (QKeyEvent * event);
159 void G4keyReleaseEvent (QKeyEvent * event);
160 void G4MouseDoubleClickEvent();
161 void G4MouseReleaseEvent(QMouseEvent *evnt);
162 void G4MouseMoveEvent(QMouseEvent *event);
165 void CreateGLQtContext ();
166 virtual void CreateMainWindow (QGLWidget*,
const QString&);
167 void G4manageContextMenuEvent(QContextMenuEvent *
e);
168 void rotateQtScene(
float,
float);
169 void rotateQtSceneToggle(
float,
float);
170 void moveScene(
float,
float,
float,
bool);
172 void updateKeyModifierState(
const Qt::KeyboardModifiers&);
173 void displaySceneTreeComponent();
174 G4Colour getColorForPoIndex(
int poIndex);
179 const std::vector<G4ModelingParameters::VisAttributesModifier>*
180 GetPrivateVisAttributesModifiers()
const;
184 bool hasPendingEvents();
185 void savePPMToTemp();
186 int fRecordFrameNumber;
190 bool fQGLWidgetInitialiseCompleted;
191 bool fPaintEventLock;
194 enum RECORDING_STEP {WAIT,
START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,
ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
196 void createPopupMenu();
197 void createRadioAction(QAction *,QAction *,
const std::string&,
unsigned int a=1);
198 void rescaleImage(
int,
int);
199 bool printPDF(
const std::string,
int,QImage);
200 void showMovieParametersDialog();
201 void initMovieParameters();
202 QString createTempFolder();
203 QString removeTempFolder();
204 void setRecordingStatus(RECORDING_STEP);
205 void setRecordingInfos(
const QString&);
206 QString getProcessErrorMsg();
207 QWidget* getParentWidget();
208 bool parseAndInsertInSceneTree(QTreeWidgetItem *,
210 unsigned int fullPathIndex,
211 const QString& parentRoot,
212 unsigned int currentIndex,
213 int currentPVPOIndex);
214 void setCheckComponent(QTreeWidgetItem* item,
bool check);
215 void createSceneTreeComponent();
216 void createViewerPropertiesComponent();
217 void createPickingComponent();
218 bool parseAndCheckVisibility(QTreeWidgetItem * treeNode,
int POindex);
219 QTreeWidgetItem* createTreeWidgetItem(
const PVPath& fullPath,
223 const QString& logicalName,
224 Qt::CheckState state,
225 QTreeWidgetItem * treeNode,
227 QString getModelShortName(
const G4String& modelShortName);
228 void cloneSceneTree(QTreeWidgetItem* rootItem);
229 void changeDepthOnSceneTreeItem(
double lookForDepth,
double currentDepth,QTreeWidgetItem* item);
230 void updatePositivePoIndexSceneTreeWidgetQuickMap(
int POindex,QTreeWidgetItem* item);
231 void changeQColorForTreeWidgetItem(QTreeWidgetItem* item,
const QColor&);
233 bool isSameSceneTreeElement(QTreeWidgetItem* parentOldItem,QTreeWidgetItem* parentNewItem);
234 void changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(QTreeWidgetItem* subItem);
235 bool isPVVolume(QTreeWidgetItem* item);
236 QTreeWidgetItem* cloneWidgetItem(QTreeWidgetItem* item);
237 void clearSceneTreeSelection(QTreeWidgetItem*);
238 void clearTreeWidgetElements(QTreeWidgetItem* item);
241 QTreeWidgetItem* getTreeWidgetItem(
int POindex);
244 QTreeWidgetItem* getOldTreeWidgetItem(
int POindex);
247 std::string parseSceneTreeAndSaveState();
249 std::string parseSceneTreeElementAndSaveState(QTreeWidgetItem* item,
unsigned int level);
250 QString GetCommandParameterList (
const G4UIcommand *aCommand);
251 void changeColorAndTransparency(GLuint
index,
G4Color color);
253 #ifdef G4MULTITHREADED 254 inline void SetQGLContextVisSubThread(QThread *th) {
255 fQGLContextVisSubThread = th;
257 inline void SetQGLContextMainThread(QThread *th) {
258 fQGLContextMainThread = th;
276 bool fHoldRotateEvent;
278 QString fEncoderPath;
279 QString fTempFolderPath;
280 QString fMovieTempFolderPath;
281 QString fSaveFileName;
282 QString fParameterFileName;
283 QAction *fMouseRotateAction;
284 QAction *fMouseMoveAction;
285 QAction *fMousePickAction;
286 QAction *fMouseZoomInAction;
287 QAction *fMouseZoomOutAction;
288 QAction *fFullScreenOn;
289 QAction *fFullScreenOff;
290 QAction *fDrawingWireframe;
291 QAction *fDrawingLineRemoval;
292 QAction *fDrawingSurfaceRemoval;
293 QAction *fDrawingLineSurfaceRemoval;
294 QAction *fProjectionOrtho;
295 QAction *fProjectionPerspective;
296 G4OpenGLQtMovieDialog* fMovieParametersDialog;
297 RECORDING_STEP fRecordingStep;
299 QTime *fLastEventTime;
301 int fNbMaxFramesPerSec;
302 float fNbMaxAnglePerSec;
303 int fLaunchSpinDelay;
304 QTabWidget* fUISceneTreeComponentsTBWidget;
307 bool fControlKeyPress;
310 bool fCheckSceneTreeComponentSignalLock;
311 QTreeWidget* fSceneTreeComponentTreeWidget;
313 QTreeWidget* fOldSceneTreeComponentTreeWidget;
314 QWidget* fSceneTreeWidget;
315 bool fPVRootNodeCreate;
316 QLineEdit* fFilterOutput;
317 QString fFileSavePath;
318 QPushButton* fSceneTreeViewerButton;
319 QPushButton* fViewerPropertiesButton;
320 QPushButton* fViewerPickingButton;
323 QString fTouchableVolumes;
324 QDialog* fShortcutsDialog;
325 QTableWidget *fSceneTreeComponentTreeWidgetInfos;
326 QWidget* fSceneTreeComponentPickingInfos;
327 QWidget* fSceneTreeViewerInfos;
328 QScrollArea* fSceneTreeComponentPickingScrollArea;
329 int fTreeWidgetInfosIgnoredCommands;
330 QPushButton * fSceneTreeButtonApply;
331 QTextEdit *fShortcutsDialogInfos;
332 QSlider* fSceneTreeDepthSlider;
333 std::map <int, PVPath > fTreeItemModels;
334 std::map <int, PVPath > fOldTreeItemModels;
337 std::map <int, QTreeWidgetItem*> fPositivePoIndexSceneTreeWidgetQuickMap;
339 std::map <int, QTreeWidgetItem*> fOldPositivePoIndexSceneTreeWidgetQuickMap;
340 std::vector <QTreeWidgetItem*> fOldNullPoIndexSceneTreeWidgetQuickVector;
342 std::map <int, QColor> fOldVisAttrColorMap;
344 unsigned int fSceneTreeDepth;
345 QTreeWidgetItem* fModelShortNameItem;
347 int fMaxPOindexInserted;
349 QSignalMapper *fSignalMapperMouse;
350 QSignalMapper *fSignalMapperSurface;
351 QSignalMapper *fSignalMapperPicking;
354 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIterator;
355 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIteratorEnd;
358 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIterator;
359 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIteratorEnd;
362 QPixmap* fTreeIconOpen;
363 QPixmap* fTreeIconClosed;
364 QPixmap* fSearchIcon;
366 int fLastExportSliderValue;
368 GLuint fLastHighlightName;
371 #ifdef G4MULTITHREADED 372 QThread* fQGLContextVisSubThread;
373 QThread* fQGLContextMainThread;
377 void startPauseVideo();
380 void updateToolbarAndMouseContextMenu();
383 void actionSaveImage();
384 void actionChangeBackgroundColor();
385 void actionChangeTextColor();
386 void actionChangeDefaultColor();
387 void actionMovieParameters();
389 void showShortcuts();
390 void toggleMouseAction(
int);
391 void toggleSurfaceAction(
int);
392 void toggleProjection(
bool);
393 void toggleTransparency(
bool);
394 void toggleAntialiasing(
bool);
395 void toggleHaloing(
bool);
396 void toggleAux(
bool);
397 void toggleHiddenMarkers(
bool);
398 void toggleFullScreen(
bool);
399 void processEncodeFinished();
400 void processLookForFinished();
401 void processEncodeStdout();
402 void sceneTreeComponentItemChanged(QTreeWidgetItem* item,
int id);
403 void toggleSceneTreeViewerInfos();
404 void toggleSceneTreeComponentTreeWidgetInfos();
405 void toggleSceneTreeComponentPickingInfos();
406 void toggleSceneTreeComponentPickingCout(
int);
407 void togglePicking();
410 void sceneTreeComponentSelected();
411 void changeDepthInSceneTree(
int);
412 void changeSearchSelection();
413 void changeColorAndTransparency(QTreeWidgetItem* item,
int val);
414 void tableWidgetViewerSetItemChanged(QTableWidgetItem *);
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
std::vector< PVNodeID > PVPath