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 updateSceneTreeWidget();
115 void updateViewerPropertiesTableWidget();
116 void updatePickInfosWidget(
int,
int);
117 QString setEncoderPath(QString path);
118 QString getEncoderPath();
119 QString setTempFolderPath(QString path);
120 QString getTempFolderPath();
121 QString setSaveFileName(QString path);
122 QString getSaveFileName();
136 void setBadEncoder();
137 bool isReadyToEncode();
138 void resetRecording();
142 bool generateMpegEncoderParameters();
143 void displayRecordingStatus();
144 void DrawText(
const G4Text&);
148 int currentPVPOIndex);
150 int currentPVPOIndex,
151 const std::string& modelDescription,
153 bool isTouchableVisible(
int POindex);
154 void clearTreeWidget();
155 bool exportImage(std::string
name=
"",
int width=-1,
int height=-1);
158 void G4MousePressEvent(QMouseEvent *event);
159 void G4wheelEvent (QWheelEvent * event);
160 void G4keyPressEvent (QKeyEvent * event);
161 void G4keyReleaseEvent (QKeyEvent * event);
162 void G4MouseDoubleClickEvent();
163 void G4MouseReleaseEvent(QMouseEvent *evnt);
164 void G4MouseMoveEvent(QMouseEvent *event);
167 void CreateGLQtContext ();
168 virtual void CreateMainWindow (QGLWidget*,
const QString&);
169 void G4manageContextMenuEvent(QContextMenuEvent *e);
170 void rotateQtScene(
float,
float);
171 void rotateQtSceneToggle(
float,
float);
172 void moveScene(
float,
float,
float,
bool);
174 void updateKeyModifierState(
const Qt::KeyboardModifiers&);
175 void displaySceneTreeComponent();
176 G4Colour getColorForPoIndex(
int poIndex);
181 const std::vector<G4ModelingParameters::VisAttributesModifier>*
182 GetPrivateVisAttributesModifiers()
const;
183 bool isCurrentWidget();
187 bool hasPendingEvents();
188 void savePPMToTemp();
189 int fRecordFrameNumber;
193 bool fQGLWidgetInitialiseCompleted;
194 bool fPaintEventLock;
200 bool fMouseOnSceneTree;
203 enum RECORDING_STEP {WAIT,
START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,
ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
205 void createPopupMenu();
206 void createRadioAction(QAction *,QAction *,
const std::string&,
unsigned int a=1);
207 void rescaleImage(
int,
int);
208 bool printPDF(
const std::string,
int,QImage);
209 void showMovieParametersDialog();
210 void initMovieParameters();
211 QString createTempFolder();
212 QString removeTempFolder();
213 void setRecordingStatus(RECORDING_STEP);
214 void setRecordingInfos(
const QString&);
215 QString getProcessErrorMsg();
216 QWidget* getParentWidget();
217 bool parseAndInsertInSceneTree(QTreeWidgetItem *,
219 unsigned int fullPathIndex,
220 const QString& parentRoot,
221 unsigned int currentIndex,
222 int currentPVPOIndex);
223 void setCheckComponent(QTreeWidgetItem* item,
bool check);
224 void createSceneTreeComponent();
225 void createSceneTreeWidget();
226 void createViewerPropertiesWidget();
227 void createPickInfosWidget();
228 bool parseAndCheckVisibility(QTreeWidgetItem * treeNode,
int POindex);
229 QTreeWidgetItem* createTreeWidgetItem(
const PVPath& fullPath,
233 const QString& logicalName,
234 Qt::CheckState state,
235 QTreeWidgetItem * treeNode,
237 QString getModelShortName(
const G4String& modelShortName);
238 void cloneSceneTree(QTreeWidgetItem* rootItem);
239 void changeDepthOnSceneTreeItem(
double lookForDepth,
double currentDepth,QTreeWidgetItem* item);
240 void updatePositivePoIndexSceneTreeWidgetQuickMap(
int POindex,QTreeWidgetItem* item);
241 void changeQColorForTreeWidgetItem(QTreeWidgetItem* item,
const QColor&);
243 bool isSameSceneTreeElement(QTreeWidgetItem* parentOldItem,QTreeWidgetItem* parentNewItem);
244 void changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(QTreeWidgetItem* subItem);
245 bool isPVVolume(QTreeWidgetItem* item);
246 QTreeWidgetItem* cloneWidgetItem(QTreeWidgetItem* item);
247 void clearSceneTreeSelection(QTreeWidgetItem*);
248 void clearTreeWidgetElements(QTreeWidgetItem* item);
251 QTreeWidgetItem* getTreeWidgetItem(
int POindex);
254 QTreeWidgetItem* getOldTreeWidgetItem(
int POindex);
257 std::string parseSceneTreeAndSaveState();
259 std::string parseSceneTreeElementAndSaveState(QTreeWidgetItem* item,
unsigned int level);
260 QString GetCommandParameterList (
const G4UIcommand *aCommand);
261 void changeColorAndTransparency(GLuint index,
G4Color color);
263 #ifdef G4MULTITHREADED
264 inline void SetQGLContextVisSubThread(QThread *th) {
265 fQGLContextVisSubThread = th;
267 inline void SetQGLContextMainThread(QThread *th) {
268 fQGLContextMainThread = th;
276 QPoint fLastPickPoint;
287 bool fHoldRotateEvent;
289 QString fEncoderPath;
290 QString fTempFolderPath;
291 QString fMovieTempFolderPath;
292 QString fSaveFileName;
293 QString fParameterFileName;
294 QAction *fMouseRotateAction;
295 QAction *fMouseMoveAction;
296 QAction *fMousePickAction;
297 QAction *fMouseZoomInAction;
298 QAction *fMouseZoomOutAction;
299 QAction *fFullScreenOn;
300 QAction *fFullScreenOff;
301 QAction *fDrawingWireframe;
302 QAction *fDrawingLineRemoval;
303 QAction *fDrawingSurfaceRemoval;
304 QAction *fDrawingLineSurfaceRemoval;
305 QAction *fProjectionOrtho;
306 QAction *fProjectionPerspective;
307 G4OpenGLQtMovieDialog* fMovieParametersDialog;
308 RECORDING_STEP fRecordingStep;
310 QTime *fLastEventTime;
312 int fNbMaxFramesPerSec;
313 float fNbMaxAnglePerSec;
314 int fLaunchSpinDelay;
315 QWidget* fUISceneTreeWidget;
316 QWidget* fUIViewerPropertiesWidget;
317 QWidget* fUIPickInfosWidget;
320 bool fControlKeyPress;
323 bool fCheckSceneTreeComponentSignalLock;
324 bool fViewerPropertiesTableWidgetIsInit;
325 QTreeWidget* fSceneTreeComponentTreeWidget;
327 QWidget* fSceneTreeWidget;
328 bool fPVRootNodeCreate;
329 QLineEdit* fFilterOutput;
330 QString fFileSavePath;
333 QString fTouchableVolumes;
334 QDialog* fShortcutsDialog;
335 QTableWidget *fViewerPropertiesTableWidget;
336 QWidget* fPickInfosWidget;
337 QScrollArea* fPickInfosScrollArea;
338 int fTreeWidgetInfosIgnoredCommands;
339 QPushButton * fSceneTreeButtonApply;
340 QTextEdit *fShortcutsDialogInfos;
341 QSlider* fSceneTreeDepthSlider;
342 std::map <int, PVPath > fTreeItemModels;
343 std::map <int, PVPath > fOldTreeItemModels;
346 std::map <int, QTreeWidgetItem*> fPositivePoIndexSceneTreeWidgetQuickMap;
348 std::map <int, QTreeWidgetItem*> fOldPositivePoIndexSceneTreeWidgetQuickMap;
349 std::vector <QTreeWidgetItem*> fOldNullPoIndexSceneTreeWidgetQuickVector;
351 std::map <int, QColor> fOldVisAttrColorMap;
353 unsigned int fSceneTreeDepth;
354 QTreeWidgetItem* fModelShortNameItem;
356 int fMaxPOindexInserted;
358 QSignalMapper *fSignalMapperMouse;
359 QSignalMapper *fSignalMapperSurface;
360 QSignalMapper *fSignalMapperPicking;
363 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIterator;
364 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIteratorEnd;
367 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIterator;
368 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIteratorEnd;
371 QPixmap* fTreeIconOpen;
372 QPixmap* fTreeIconClosed;
373 QPixmap* fSearchIcon;
375 int fLastExportSliderValue;
377 GLuint fLastHighlightName;
380 #ifdef G4MULTITHREADED
381 QThread* fQGLContextVisSubThread;
382 QThread* fQGLContextMainThread;
386 void startPauseVideo();
389 void updateToolbarAndMouseContextMenu();
392 void actionSaveImage();
393 void actionChangeBackgroundColor();
394 void actionChangeTextColor();
395 void actionChangeDefaultColor();
396 void actionMovieParameters();
398 void showShortcuts();
399 void toggleMouseAction(
int);
400 void toggleSurfaceAction(
int);
401 void toggleProjection(
bool);
402 void toggleTransparency(
bool);
403 void toggleAntialiasing(
bool);
404 void toggleHaloing(
bool);
405 void toggleAux(
bool);
406 void toggleHiddenMarkers(
bool);
407 void toggleFullScreen(
bool);
408 void processEncodeFinished();
409 void processLookForFinished();
410 void processEncodeStdout();
411 void sceneTreeComponentItemChanged(QTreeWidgetItem* item,
int id);
412 void toggleSceneTreeComponentPickingCout(
int);
413 void togglePicking();
414 void currentTabActivated(
int);
417 void sceneTreeComponentSelected();
418 void changeDepthInSceneTree(
int);
419 void changeSearchSelection();
420 void changeColorAndTransparency(QTreeWidgetItem* item,
int val);
421 void tableWidgetViewerSetItemChanged(QTableWidgetItem *);
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
std::vector< PVNodeID > PVPath
const XML_Char XML_Content * model