35 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
37 #ifndef G4OPENGLQTVIEWER_HH
38 #define G4OPENGLQTVIEWER_HH
50 class G4OpenGLSceneHandler;
58 class QContextMenuEvent;
71 class QTreeWidgetItem;
74 class G4OpenGLSceneHandler;
75 class G4OpenGLQtMovieDialog;
80 class QTableWidgetItem;
84 class G4OpenGLQtViewer:
public QObject,
virtual public G4OpenGLViewer {
89 typedef std::vector<PVNodeID>
PVPath;
92 G4OpenGLQtViewer (G4OpenGLSceneHandler& scene);
93 virtual ~G4OpenGLQtViewer ();
94 #ifdef G4MULTITHREADED
97 virtual void DoneWithMasterThread ();
99 virtual void MovingToVisSubThread ();
101 virtual void SwitchToVisSubThread ();
103 virtual void DoneWithVisSubThread ();
107 virtual void SwitchToMasterThread ();
111 G4OpenGLQtViewer (
const G4OpenGLQtViewer&);
112 G4OpenGLQtViewer& operator= (
const G4OpenGLQtViewer&);
114 virtual void updateQWidget()=0;
115 void updateSceneTreeWidget();
116 void updateViewerPropertiesTableWidget();
117 void updatePickInfosWidget(
int,
int);
118 QString setEncoderPath(QString path);
119 QString getEncoderPath();
120 QString setTempFolderPath(QString path);
121 QString getTempFolderPath();
122 QString setSaveFileName(QString path);
123 QString getSaveFileName();
137 void setBadEncoder();
138 bool isReadyToEncode();
139 void resetRecording();
143 bool generateMpegEncoderParameters();
144 void displayRecordingStatus();
145 void DrawText(
const G4Text&);
149 int currentPVPOIndex);
151 int currentPVPOIndex,
152 const std::string& modelDescription,
154 bool isTouchableVisible(
int POindex);
155 void clearTreeWidget();
156 bool exportImage(std::string
name=
"",
int width=-1,
int height=-1);
159 void G4MousePressEvent(QMouseEvent *event);
160 void G4wheelEvent (QWheelEvent * event);
161 void G4keyPressEvent (QKeyEvent * event);
162 void G4keyReleaseEvent (QKeyEvent * event);
163 void G4MouseDoubleClickEvent();
164 void G4MouseReleaseEvent(QMouseEvent *evnt);
165 void G4MouseMoveEvent(QMouseEvent *event);
168 void CreateGLQtContext ();
169 virtual void CreateMainWindow (QGLWidget*,
const QString&);
170 void G4manageContextMenuEvent(QContextMenuEvent *
e);
171 void rotateQtScene(
float,
float);
172 void rotateQtSceneToggle(
float,
float);
173 void moveScene(
float,
float,
float,
bool);
175 void updateKeyModifierState(
const Qt::KeyboardModifiers&);
176 void displaySceneTreeComponent();
177 G4Colour getColorForPoIndex(
int poIndex);
182 const std::vector<G4ModelingParameters::VisAttributesModifier>*
183 GetPrivateVisAttributesModifiers()
const;
184 bool isCurrentWidget();
188 bool hasPendingEvents();
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 QSignalMapper *fSignalMapperMouse;
360 QSignalMapper *fSignalMapperSurface;
361 QSignalMapper *fSignalMapperPicking;
364 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIterator;
365 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIteratorEnd;
368 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIterator;
369 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIteratorEnd;
372 QPixmap* fTreeIconOpen;
373 QPixmap* fTreeIconClosed;
374 QPixmap* fSearchIcon;
376 int fLastExportSliderValue;
378 GLuint fLastHighlightName;
381 #ifdef G4MULTITHREADED
382 QThread* fQGLContextVisSubThread;
383 QThread* fQGLContextMainThread;
387 G4AutoLock* lWaitForVisSubThreadQtOpenGLContextInitialized;
388 G4AutoLock* lWaitForVisSubThreadQtOpenGLContextMoved;
391 void startPauseVideo();
394 void updateToolbarAndMouseContextMenu();
397 void actionSaveImage();
398 void actionChangeBackgroundColor();
399 void actionChangeTextColor();
400 void actionChangeDefaultColor();
401 void actionMovieParameters();
403 void showShortcuts();
404 void toggleMouseAction(
int);
405 void toggleSurfaceAction(
int);
406 void toggleProjection(
bool);
407 void toggleTransparency(
bool);
408 void toggleAntialiasing(
bool);
409 void toggleHaloing(
bool);
410 void toggleAux(
bool);
411 void toggleHiddenMarkers(
bool);
412 void toggleFullScreen(
bool);
413 void processEncodeFinished();
414 void processLookForFinished();
415 void processEncodeStdout();
416 void sceneTreeComponentItemChanged(QTreeWidgetItem* item,
int id);
417 void toggleSceneTreeComponentPickingCout(
int);
418 void togglePicking();
419 void currentTabActivated(
int);
422 void sceneTreeComponentSelected();
423 void changeDepthInSceneTree(
int);
424 void changeSearchSelection();
425 void changeColorAndTransparency(QTreeWidgetItem* item,
int val);
426 void tableWidgetViewerSetItemChanged(QTableWidgetItem *);
std::vector< ExP01TrackerHit * > a
std::vector< PVNodeID > PVPath
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
const XML_Char XML_Content * model