30#ifndef G4OPENINVENTORQTEXAMINERVIEWER_HH
31#define G4OPENINVENTORQTEXAMINERVIEWER_HH
33#if defined (G4VIS_BUILD_OIQT_DRIVER) || defined (G4VIS_USE_OIQT)
40class G4OpenInventorQtExaminerViewer;
49 G4OpenInventorQtExaminerViewer* viewer;
60#include <Inventor/SbLinear.h>
61#include <Inventor/nodes/SoLineSet.h>
62#include <Inventor/nodes/SoEventCallback.h>
63#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
64#include <Inventor/events/SoKeyboardEvent.h>
88class G4OpenInventorQtExaminerViewer:
public QObject,
89 public SoQtExaminerViewer {
95 friend class G4OpenInventorQtViewer;
99 void FileOpenBookmarkCB();
100 void FileNewBookmarkCB();
101 void FileLoadRefPathCB();
102 void FileSaveRefPathCB();
103 void FileLoadSceneGraphCB();
104 void FileSaveSceneGraphCB();
106 void ToolsAnimateRefParticleCB();
107 void ToolsRefPathStartCB();
108 void ToolsRefPathInvertCB();
110 void HelpControlsCB();
116 void AbbrOutputCB(
bool);
117 void PickRefPathCB();
118 void SwitchWireFrameCB(
bool);
121 void LoadBookmarkCB(QListWidgetItem*);
122 void DeleteBookmarkCB();
123 void RenameBookmarkCB();
124 void SortBookmarksCB();
125 void LookAtSceneElementCB(QListWidgetItem*);
129 static G4OpenInventorQtExaminerViewer* viewer;
131 void (*escapeCallback)();
133 void* examinerObject;
134 SbBool lshiftdown, rshiftdown, lctrldown, rctrldown;
142 QMessageBox* helpmsgbox;
146 QAction* FileOpenBookmark;
147 QAction* FileNewBookmark;
148 QAction* FileLoadRefPath;
149 QAction* FileSaveRefPath;
150 QAction* FileLoadSceneGraph;
151 QAction* FileSaveSceneGraph;
153 QAction* ToolsAnimateRefParticle;
154 QAction* ToolsRefPathStart;
155 QAction* ToolsRefPathInvert;
158 QAction* HelpControls;
161 QPushButton* saveViewPtButton;
162 QPushButton* nextViewPtButton;
163 QPushButton* prevViewPtButton;
164 QPushButton* abbrOutputButton;
166 QPushButton* pickRefPathButton;
167 QPushButton* switchWireFrameButton;
170 QListWidgetItem* saveViewPtItem;
177 G4OpenInventorQtExaminerViewer(QWidget* parent = NULL,
178 const char* name = NULL,
180 SoQtFullViewer::BuildFlag flag = BUILD_ALL,
181 SoQtViewer::Type type = BROWSER);
183 ~G4OpenInventorQtExaminerViewer();
185 template <
class T>
void parseString(T &t,
const std::string &s,
bool &error);
189 QMenuBar* getMenubar() {
return menubar; }
190 QMenu* getFileMenu() {
return filemenu; }
191 QMenu* getEtcMenu() {
return etcmenu; }
192 QFont* getFont() {
return font; };
194 void setExternalQtApp() { externalQtApp =
TRUE; }
197 std::string saveScenegraphFileName;
198 std::string saveRefCoordsFileName;
200 void addEscapeCallback(
void (*cb)());
204 bool pickRefPathFlag;
205 bool viewingBeforePickRef;
218 void construct(
const SbBool build);
219 void buildWidget(QWidget* parent);
221 virtual void afterRealizeHook();
227 static void sceneChangeCB(
void*, SoSensor*);
230 SbBool processSoEvent(
const SoEvent*
const event);
232 void saveViewPt(
char* name);
234 void addViewPoints();
236 void writeViewPtIdx();
237 void cleanUpAfterPrevFile();
238 void deleteViewPt(
char *vpName = NULL);
239 void renameViewPt(
char *vpName);
240 void sortViewPts(std::vector<std::string>);
242 void moveCamera(
float dist = 0,
bool lookdown =
false);
243 std::string curEltName;
247 void updateViewParams(SoKeyboardEvent::Key);
249 static void mouseoverCB(
void *aThis, SoEventCallback *eventCB);
250 static void pickingCB(
void *aThis, SoEventCallback *eventCB);
254 static void animateRefParticleCB();
255 static void animateSensorCB(
void *, SoSensor *);
256 static void animateSensorRotationCB(
void *, SoSensor *);
257 void animateRefParticle();
258 void saveCurCamera();
259 void restoreCamera();
260 double animateBtwPtsPeriod, speedStep;
264 SoTimerSensor *animateSensor;
265 SoTimerSensor *animateSensorRotation;
266 SoNodeSensor *sceneChangeSensor;
267 SbVec3f camStartPos, camEndPos;
268 SbRotation camStartOrient, camEndOrient;
270 void setReferencePath(SoLineSet*, SoCoordinate3*,
bool append =
false);
271 void setReferencePathZPos();
272 void findAndSetRefPath();
273 SoCoordinate3* getCoordsNode(SoFullPath *path);
274 void getSceneElements();
275 float sqrlen(
const SbVec3f&);
276 void distanceToTrajectory(
const SbVec3f&,
float&, SbVec3f&,
int&);
278 void createElementsList();
280 void evenOutRefParticlePts();
283 void gotoRefPathStart();
285 void invertRefPath();
307 SbRotation orientation;
316 struct sceneElement {
320 float closestPointZCoord;
323 struct elementForSorting {
324 float closestPointZCoord;
325 SbVec3f closestPoint;
326 float smallestDistance;
327 float distanceToBeamlineStart;
332 if (closestPointZCoord < other.closestPointZCoord)
334 if (closestPointZCoord > other.closestPointZCoord)
340 if (distanceToBeamlineStart < other.distanceToBeamlineStart)
342 if (distanceToBeamlineStart > other.distanceToBeamlineStart)
354 std::vector<sceneElement> sceneElements;
355 std::vector<viewPtData> viewPtList;
356 std::string fileName;
357 std::ifstream fileIn;
358 std::ofstream fileOut;
364 std::vector<SbVec3f> refParticleTrajectory;
366 std::vector<float> refZPositions;
371 State currentState, prevState, beforePausing;
376 SbVec3f prevParticleDir;
377 void* prevColorField;
379 viewPtData camB4Animation;
383 void setStartingPtForAnimation();
384 float left_right, up_down;
388 std::string viewPtAutoName();
392 SoSearchAction * searcher;
394 SoNode * superimposition;
395 SoCoordinate3 * sgeometry;
398 SoTranslation * stranslation;
399 SoTranslation * curInfoTrans;
400 SoTranslation * mouseOverTransSolid;
401 SoTranslation * mouseOverTransMaterial;
402 SoTranslation * mouseOverTransLogName;
403 SoTranslation * mouseOverTransZPos;
407 SoText2 * curInfoText;
411 SoText2* mouseOverTextSolid;
412 SoText2* mouseOverTextMaterial;
413 SoText2* mouseOverTextLogName;
414 SoText2* mouseOverTextZPos;
417 SoFont* mouseOverFontSolid;
418 SoFont* mouseOverFontMaterial;
419 SoFont* mouseOverFontLogName;
420 SoFont* mouseOverFontZPos;
421 SoSwitch* axisSwitch;
422 SoSwitch* animSpeedOutlineSwitch;
423 SoSwitch* animSpeedSwitch;
424 SoSwitch* curInfoSwitch;
426 SoNode* getSuperimpositionNode(SoNode*,
const char* name);
428 void superimpositionEvent(SoAction* action);
429 static void superimpositionCB(
void* closure, SoAction* action);
432 virtual void actualRedraw(
void);
433 void updateSpeedIndicator(
void);
441 float defaultHeightAngle;
446 SbVec3f upVector, offsetFromCenter, center;
449 SoSeparator* newSceneGraph;
virtual G4bool Notify(G4ApplicationState requiredState)
bool operator<(const HepRotation &r, const HepLorentzRotation <)
const char * name(G4int ptype)