33#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
35#ifndef G4OPENGLQTVIEWER_HH
36#define G4OPENGLQTVIEWER_HH
46class G4OpenGLSceneHandler;
53class QContextMenuEvent;
69class G4OpenGLSceneHandler;
70class G4OpenGLQtMovieDialog;
75class 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&);
119 void addPVSceneTreeElement(
const G4String& model,
121 int currentPVPOIndex);
122 void addNonPVSceneTreeElement(
const G4String& model,
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 bool hasPendingEvents();
152 void savePPMToTemp();
153 int fRecordFrameNumber;
160 enum RECORDING_STEP {WAIT,
START,PAUSE,CONTINUE,STOP,READY_TO_ENCODE,
ENCODING,FAILED,SUCCESS,BAD_ENCODER,BAD_OUTPUT,BAD_TMP,SAVE};
162 void createPopupMenu();
163 void createRadioAction(QAction *,QAction *,
const std::string&,
unsigned int a=1);
164 void rescaleImage(
int,
int);
165 bool printPDF(
const std::string,
int,QImage);
166 void showMovieParametersDialog();
167 void initMovieParameters();
168 QString createTempFolder();
169 QString removeTempFolder();
170 void setRecordingStatus(RECORDING_STEP);
171 void setRecordingInfos(
const QString&);
172 QString getProcessErrorMsg();
173 QWidget* getParentWidget();
174 bool parseAndInsertInSceneTree(QTreeWidgetItem *,
176 unsigned int fullPathIndex,
177 const QString& parentRoot,
178 unsigned int currentIndex,
179 int currentPVPOIndex);
180 void setCheckComponent(QTreeWidgetItem* item,
bool check);
181 void initSceneTreeComponent();
182 bool parseAndCheckVisibility(QTreeWidgetItem * treeNode,
int POindex);
183 QTreeWidgetItem* createTreeWidgetItem(
const PVPath& fullPath,
187 const QString& logicalName,
188 Qt::CheckState state,
189 QTreeWidgetItem * treeNode,
191 QString getModelShortName(
const G4String& modelShortName);
192 void cloneSceneTree(QTreeWidgetItem* rootItem);
193 void changeDepthOnSceneTreeItem(
double lookForDepth,
double currentDepth,QTreeWidgetItem* item);
194 void updatePositivePoIndexSceneTreeWidgetQuickMap(
int POindex,QTreeWidgetItem* item);
195 void changeQColorForTreeWidgetItem(QTreeWidgetItem* item,
const QColor&);
197 bool isSameSceneTreeElement(QTreeWidgetItem* parentOldItem,QTreeWidgetItem* parentNewItem);
198 void changeOpenCloseVisibleHiddenSelectedColorSceneTreeElement(QTreeWidgetItem* subItem);
199 bool isPVVolume(QTreeWidgetItem* item);
200 QTreeWidgetItem* cloneWidgetItem(QTreeWidgetItem* item);
201 void clearSceneTreeSelection(QTreeWidgetItem*);
202 void clearTreeWidgetElements(QTreeWidgetItem* item);
205 QTreeWidgetItem* getTreeWidgetItem(
int POindex);
208 QTreeWidgetItem* getOldTreeWidgetItem(
int POindex);
225 bool fHoldRotateEvent;
227 QString fEncoderPath;
228 QString fTempFolderPath;
229 QString fMovieTempFolderPath;
230 QString fSaveFileName;
231 QString fParameterFileName;
232 QAction *fMouseRotateAction;
233 QAction *fMouseMoveAction;
234 QAction *fMousePickAction;
235 QAction *fMouseZoomInAction;
236 QAction *fMouseZoomOutAction;
237 QAction *fFullScreenOn;
238 QAction *fFullScreenOff;
239 QAction *fDrawingWireframe;
240 QAction *fDrawingLineRemoval;
241 QAction *fDrawingSurfaceRemoval;
242 QAction *fDrawingLineSurfaceRemoval;
243 QAction *fProjectionOrtho;
244 QAction *fProjectionPerspective;
245 G4OpenGLQtMovieDialog* fMovieParametersDialog;
246 RECORDING_STEP fRecordingStep;
248 QTime *fLastEventTime;
250 int fNbMaxFramesPerSec;
251 float fNbMaxAnglePerSec;
252 int fLaunchSpinDelay;
253 QTabWidget* fUISceneTreeComponentsTBWidget;
256 bool fControlKeyPress;
259 bool fCheckSceneTreeComponentSignalLock;
260 QTreeWidget* fSceneTreeComponentTreeWidget;
262 QTreeWidget* fOldSceneTreeComponentTreeWidget;
263 QWidget* fSceneTreeWidget;
264 bool fPVRootNodeCreate;
265 QLineEdit* fHelpLine;
270 QString fTouchableVolumes;
271 QDialog* fShortcutsDialog;
272 QTextEdit *fTreeInfoDialogInfos;
273 QPushButton * fSceneTreeButtonApply;
274 QTextEdit *fShortcutsDialogInfos;
275 QSlider* fSceneTreeDepthSlider;
276 std::map <int, PVPath > fTreeItemModels;
277 std::map <int, PVPath > fOldTreeItemModels;
280 std::map <int, QTreeWidgetItem*> fPositivePoIndexSceneTreeWidgetQuickMap;
282 std::map <int, QTreeWidgetItem*> fOldPositivePoIndexSceneTreeWidgetQuickMap;
283 std::vector <QTreeWidgetItem*> fOldNullPoIndexSceneTreeWidgetQuickVector;
285 std::map <int, QColor> fOldVisAttrColorMap;
287 unsigned int fSceneTreeDepth;
288 QTreeWidgetItem* fModelShortNameItem;
290 int fMaxPOindexInserted;
292 QSignalMapper *signalMapperMouse;
293 QSignalMapper *signalMapperSurface;
296 std::map <int, QTreeWidgetItem*>::const_iterator fLastSceneTreeWidgetAskFor;
299 std::map <int, QTreeWidgetItem*>::const_iterator fOldLastSceneTreeWidgetAskFor;
303 void startPauseVideo();
306 void updateToolbarAndMouseContextMenu();
309 void actionSaveImage();
310 void actionChangeBackgroundColor();
311 void actionChangeTextColor();
312 void actionChangeDefaultColor();
313 void actionMovieParameters();
315 void showShortcuts();
316 void toggleMouseAction(
int);
317 void toggleSurfaceAction(
int);
318 void toggleRepresentation(
bool);
319 void toggleProjection(
bool);
320 void toggleTransparency(
bool);
321 void toggleAntialiasing(
bool);
322 void toggleHaloing(
bool);
323 void toggleAux(
bool);
324 void toggleHiddenMarkers(
bool);
325 void toggleFullScreen(
bool);
326 void processEncodeFinished();
327 void processLookForFinished();
328 void processEncodeStdout();
329 void sceneTreeComponentItemChanged(QTreeWidgetItem* item,
int id);
332 void sceneTreeComponentSelected();
333 void changeDepthInSceneTree(
int);
334 void changeSearchSelection();
335 void changeColorAndTransparency(QTreeWidgetItem* item,
int val);
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
std::vector< PVNodeID > PVPath