33 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
35 #ifndef G4OPENGLQTVIEWER_HH
36 #define G4OPENGLQTVIEWER_HH
46 class G4OpenGLSceneHandler;
53 class QContextMenuEvent;
66 class QTreeWidgetItem;
69 class G4OpenGLSceneHandler;
70 class G4OpenGLQtMovieDialog;
75 class G4OpenGLQtViewer:
public QObject,
virtual public G4OpenGLViewer {
80 typedef std::vector<PVNodeID>
PVPath;
83 G4OpenGLQtViewer (G4OpenGLSceneHandler& scene);
84 virtual ~G4OpenGLQtViewer ();
86 G4OpenGLQtViewer (
const G4OpenGLQtViewer&);
87 G4OpenGLQtViewer& operator= (
const G4OpenGLQtViewer&);
89 virtual void updateQWidget()=0;
90 QString setEncoderPath(QString path);
91 QString getEncoderPath();
92 QString setTempFolderPath(QString path);
93 QString getTempFolderPath();
94 QString setSaveFileName(QString path);
95 QString getSaveFileName();
109 void setBadEncoder();
110 bool isReadyToEncode();
111 void resetRecording();
115 bool generateMpegEncoderParameters();
116 void displayRecordingStatus();
117 void DrawText(
const G4Text&);
121 int currentPVPOIndex);
123 int currentPVPOIndex,
124 const std::string& modelDescription,
126 bool isTouchableVisible(
int POindex);
127 void clearTreeWidget();
129 void G4MousePressEvent(QMouseEvent *event);
130 void G4wheelEvent (QWheelEvent * event);
131 void G4keyPressEvent (QKeyEvent * event);
132 void G4MouseDoubleClickEvent();
133 void G4MouseReleaseEvent();
134 void G4MouseMoveEvent(QMouseEvent *event);
137 void CreateGLQtContext ();
138 virtual void CreateMainWindow (QGLWidget*,
const QString&);
139 void G4manageContextMenuEvent(QContextMenuEvent *e);
140 void rotateQtScene(
float,
float);
141 void rotateQtSceneToggle(
float,
float);
142 void moveScene(
float,
float,
float,
bool);
144 void updateKeyModifierState(
const Qt::KeyboardModifiers&);
145 void displaySceneTreeComponent();
146 G4Colour getColorForPoIndex(
int poIndex);
151 const std::vector<G4ModelingParameters::VisAttributesModifier>*
152 GetPrivateVisAttributesModifiers()
const;
157 bool hasPendingEvents();
158 void savePPMToTemp();
159 int fRecordFrameNumber;
166 enum RECORDING_STEP {WAIT,
START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,
ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
168 void createPopupMenu();
169 void createRadioAction(QAction *,QAction *,
const std::string&,
unsigned int a=1);
170 void rescaleImage(
int,
int);
171 bool printPDF(
const std::string,
int,QImage);
172 void showMovieParametersDialog();
173 void initMovieParameters();
174 QString createTempFolder();
175 QString removeTempFolder();
176 void setRecordingStatus(RECORDING_STEP);
177 void setRecordingInfos(
const QString&);
178 QString getProcessErrorMsg();
179 QWidget* getParentWidget();
180 bool parseAndInsertInSceneTree(QTreeWidgetItem *,
182 unsigned int fullPathIndex,
183 const QString& parentRoot,
184 unsigned int currentIndex,
185 int currentPVPOIndex);
186 void setCheckComponent(QTreeWidgetItem* item,
bool check);
187 void initSceneTreeComponent();
188 bool parseAndCheckVisibility(QTreeWidgetItem * treeNode,
int POindex);
189 QTreeWidgetItem* createTreeWidgetItem(
const PVPath& fullPath,
193 const QString& logicalName,
194 Qt::CheckState state,
195 QTreeWidgetItem * treeNode,
197 QString getModelShortName(
const G4String& modelShortName);
198 void cloneSceneTree(QTreeWidgetItem* rootItem);
199 void changeDepthOnSceneTreeItem(
double lookForDepth,
double currentDepth,QTreeWidgetItem* item);
200 void updatePositivePoIndexSceneTreeWidgetQuickMap(
int POindex,QTreeWidgetItem* item);
201 void changeQColorForTreeWidgetItem(QTreeWidgetItem* item,
const QColor&);
203 bool isSameSceneTreeElement(QTreeWidgetItem* parentOldItem,QTreeWidgetItem* parentNewItem);
204 void changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(QTreeWidgetItem* subItem);
205 bool isPVVolume(QTreeWidgetItem* item);
206 QTreeWidgetItem* cloneWidgetItem(QTreeWidgetItem* item);
207 void clearSceneTreeSelection(QTreeWidgetItem*);
208 void clearTreeWidgetElements(QTreeWidgetItem* item);
211 QTreeWidgetItem* getTreeWidgetItem(
int POindex);
214 QTreeWidgetItem* getOldTreeWidgetItem(
int POindex);
217 std::string parseSceneTreeAndSaveState();
219 std::string parseSceneTreeElementAndSaveState(QTreeWidgetItem* item,
unsigned int level);
235 bool fHoldRotateEvent;
237 QString fEncoderPath;
238 QString fTempFolderPath;
239 QString fMovieTempFolderPath;
240 QString fSaveFileName;
241 QString fParameterFileName;
242 QAction *fMouseRotateAction;
243 QAction *fMouseMoveAction;
244 QAction *fMousePickAction;
245 QAction *fMouseZoomInAction;
246 QAction *fMouseZoomOutAction;
247 QAction *fFullScreenOn;
248 QAction *fFullScreenOff;
249 QAction *fDrawingWireframe;
250 QAction *fDrawingLineRemoval;
251 QAction *fDrawingSurfaceRemoval;
252 QAction *fDrawingLineSurfaceRemoval;
253 QAction *fProjectionOrtho;
254 QAction *fProjectionPerspective;
255 G4OpenGLQtMovieDialog* fMovieParametersDialog;
256 RECORDING_STEP fRecordingStep;
258 QTime *fLastEventTime;
260 int fNbMaxFramesPerSec;
261 float fNbMaxAnglePerSec;
262 int fLaunchSpinDelay;
263 QTabWidget* fUISceneTreeComponentsTBWidget;
266 bool fControlKeyPress;
269 bool fCheckSceneTreeComponentSignalLock;
270 QTreeWidget* fSceneTreeComponentTreeWidget;
272 QTreeWidget* fOldSceneTreeComponentTreeWidget;
273 QWidget* fSceneTreeWidget;
274 bool fPVRootNodeCreate;
275 QLineEdit* fHelpLine;
276 QString fFileSavePath;
277 QString fDefaultSaveFileFormat;
281 QString fTouchableVolumes;
282 QDialog* fShortcutsDialog;
283 QTextEdit *fTreeInfoDialogInfos;
284 QPushButton * fSceneTreeButtonApply;
285 QTextEdit *fShortcutsDialogInfos;
286 QSlider* fSceneTreeDepthSlider;
287 std::map <int, PVPath > fTreeItemModels;
288 std::map <int, PVPath > fOldTreeItemModels;
291 std::map <int, QTreeWidgetItem*> fPositivePoIndexSceneTreeWidgetQuickMap;
293 std::map <int, QTreeWidgetItem*> fOldPositivePoIndexSceneTreeWidgetQuickMap;
294 std::vector <QTreeWidgetItem*> fOldNullPoIndexSceneTreeWidgetQuickVector;
296 std::map <int, QColor> fOldVisAttrColorMap;
298 unsigned int fSceneTreeDepth;
299 QTreeWidgetItem* fModelShortNameItem;
301 int fMaxPOindexInserted;
303 QSignalMapper *signalMapperMouse;
304 QSignalMapper *signalMapperSurface;
307 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIterator;
308 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskForIteratorEnd;
311 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIterator;
312 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskForIteratorEnd;
316 void startPauseVideo();
319 void updateToolbarAndMouseContextMenu();
322 void actionSaveImage();
323 void actionChangeBackgroundColor();
324 void actionChangeTextColor();
325 void actionChangeDefaultColor();
326 void actionMovieParameters();
328 void showShortcuts();
329 void toggleMouseAction(
int);
330 void toggleSurfaceAction(
int);
331 void toggleProjection(
bool);
332 void toggleTransparency(
bool);
333 void toggleAntialiasing(
bool);
334 void toggleHaloing(
bool);
335 void toggleAux(
bool);
336 void toggleHiddenMarkers(
bool);
337 void toggleFullScreen(
bool);
338 void processEncodeFinished();
339 void processLookForFinished();
340 void processEncodeStdout();
341 void sceneTreeComponentItemChanged(QTreeWidgetItem* item,
int id);
344 void sceneTreeComponentSelected();
345 void changeDepthInSceneTree(
int);
346 void changeSearchSelection();
347 void changeColorAndTransparency(QTreeWidgetItem* item,
int val);
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
const XML_Char XML_Content * model
std::vector< PVNodeID > PVPath