29 #ifndef HookEventProcState_H
30 #define HookEventProcState_H 1
47 #ifndef G4OPENINVENTORXTEXAMINERVIEWER_HH
48 #define G4OPENINVENTORXTEXAMINERVIEWER_HH
53 #include <Inventor/SbLinear.h>
54 #include <Inventor/nodes/SoLineSet.h>
55 #include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
56 #include <Inventor/events/SoKeyboardEvent.h>
65 Widget prevViewPtButton, nextViewPtButton;
66 Widget menuBar, fileMenu, openFileDialog, newFileDialog,
67 loadRefCoordsDialog, saveRefCoordsDialog,
68 loadSceneGraphDialog, saveSceneGraphDialog,
69 viewPtSelection, listsDialog, myShellDialog, myViewPtList, myElementList;
72 void (*escapeCallback)(
void *);
73 void * examinerObject;
74 SbBool lshiftdown, rshiftdown, lctrldown, rctrldown;
80 const char *
name = NULL,
82 SoXtFullViewer::BuildFlag flag = BUILD_ALL,
83 SoXtViewer::Type type = BROWSER);
86 template <
class T>
void parseString(T &t,
const std::string &
s,
bool &error);
88 void addButton(Widget menu, std::string name, XtCallbackProc);
110 SoXtFullViewer::BuildFlag flag,
111 SoXtViewer::Type type,
120 void moveCamera(
float dist = 0,
bool lookdown =
false);
131 void constructor(
const SbBool build);
138 static void sceneChangeCB(
void *, SoSensor *);
141 void writeViewPtIdx();
142 void cleanUpAfterPrevFile();
144 void popUpFileSelDialog(Widget&, std::string, std::string, XtCallbackProc);
145 static void cancelFileSelDialogCB(Widget, XtPointer, XtPointer);
146 static void openViewPtFileCB(Widget, XtPointer, XtPointer);
147 static void viewPtFileSelectedCB(Widget, XtPointer, XtPointer);
148 static void newViewPtFileCB(Widget, XtPointer, XtPointer);
149 static void createNewVPFileCB(Widget, XtPointer, XtPointer);
150 static void overwriteFileCB(Widget, XtPointer, XtPointer);
151 static void loadRefCoordsDialogCB(Widget, XtPointer, XtPointer);
152 static void loadRefCoordsCB(Widget, XtPointer, XtPointer);
153 static void saveRefCoordsDialogCB(Widget, XtPointer, XtPointer);
154 static void saveRefCoordsCB(Widget, XtPointer, XtPointer);
155 static void saveRefCoordsOverWriteCB(Widget, XtPointer, XtPointer);
156 static void loadSceneGraphDialogCB(Widget, XtPointer, XtPointer);
157 static void loadSceneGraphCB(Widget, XtPointer, XtPointer);
158 static void saveSceneGraphDialogCB(Widget, XtPointer, XtPointer);
159 static void saveSceneGraphCB(Widget, XtPointer, XtPointer);
160 static void saveSceneGraphOverWriteCB(Widget, XtPointer, XtPointer);
161 static void mouseoverCB(
void *aThis, SoEventCallback *eventCB);
162 static void pickingCB(
void *aThis, SoEventCallback *eventCB);
166 void addViewPoints();
167 static void closeListsDialogCB(Widget, XtPointer, XtPointer);
168 static void loadBookmarkCB(Widget, XtPointer, XtPointer);
169 static void renameBookmarkCB(Widget, XtPointer, XtPointer);
170 void renameViewPt(
char *vpName);
171 static void sortBookmarksCB(Widget, XtPointer, XtPointer);
172 void sortViewPts(std::vector<std::string>);
173 static void deleteBookmarkCB(Widget, XtPointer, XtPointer);
174 static void deleteViewPtCB(Widget, XtPointer, XtPointer);
175 void deleteViewPt(
char *vpName = NULL);
178 static void animateRefParticleCB(Widget, XtPointer, XtPointer);
179 static void animateSensorCB(
void *, SoSensor *);
180 static void animateSensorRotationCB(
void *, SoSensor *);
181 void animateRefParticle();
182 void saveCurCamera();
183 void restoreCamera();
184 double animateBtwPtsPeriod, speedStep;
188 SoTimerSensor *animateSensor;
189 SoTimerSensor *animateSensorRotation;
190 SoNodeSensor *sceneChangeSensor;
191 SbVec3f camStartPos, camEndPos;
192 SbRotation camStartOrient, camEndOrient;
194 static void prevViewPtCB(Widget, XtPointer, XtPointer);
195 static void nextViewPtCB(Widget, XtPointer, XtPointer);
196 static void saveViewPtCB(Widget, XtPointer, XtPointer);
197 static void abbrOutputCB(Widget, XtPointer, XtPointer);
198 static void pickRefPathCB(Widget, XtPointer, XtPointer);
199 static void constructListsDialog(Widget, XtPointer, XtPointer);
200 void saveViewPt(
char *name);
203 static void lookAtSceneElementCB(Widget, XtPointer, XtPointer);
204 static void cancelSceneElementSelectionCB(Widget, XtPointer, XtPointer);
206 void setReferencePath(SoLineSet*, SoCoordinate3*,
bool append =
false);
207 void setReferencePathZPos();
208 void findAndSetRefPath();
209 SoCoordinate3 *getCoordsNode(SoFullPath *path);
210 void getSceneElements();
211 float sqrlen(
const SbVec3f&);
212 void distanceToTrajectory(
const SbVec3f&,
float&, SbVec3f&,
int&);
214 void createElementsList(Widget);
215 static void closeMainWindowCB(Widget, XtPointer, XtPointer);
216 void evenOutRefParticlePts();
218 static void gotoRefPathStartCB(Widget, XtPointer, XtPointer);
219 void gotoRefPathStart();
220 static void invertRefPathCB(Widget, XtPointer, XtPointer);
221 void invertRefPath();
244 SbRotation orientation;
253 struct sceneElement {
257 float closestPointZCoord;
259 sceneElement operator=(sceneElement
const &rhs)
const {
263 el.center = rhs.center;
264 el.closestPointZCoord = rhs.closestPointZCoord;
270 struct elementForSorting {
271 float closestPointZCoord;
272 SbVec3f closestPoint;
273 float smallestDistance;
274 float distanceToBeamlineStart;
277 bool operator<(elementForSorting
const &other)
const
279 if (closestPointZCoord < other.closestPointZCoord)
281 if (closestPointZCoord > other.closestPointZCoord)
287 if (distanceToBeamlineStart < other.distanceToBeamlineStart)
289 if (distanceToBeamlineStart > other.distanceToBeamlineStart)
301 std::vector<sceneElement> sceneElements;
302 std::vector<viewPtData> viewPtList;
303 std::string fileName;
304 std::ifstream fileIn;
305 std::ofstream fileOut;
311 std::vector<SbVec3f> refParticleTrajectory;
313 std::vector<float> refZPositions;
317 State currentState, prevState, beforePausing;
322 SbVec3f prevParticleDir;
323 void * prevColorField;
325 viewPtData camB4Animation;
329 void setStartingPtForAnimation();
330 float left_right, up_down;
334 static void getViewPtNameCB(Widget, XtPointer, XtPointer);
335 std::string viewPtAutoName();
338 SoSearchAction * searcher;
340 SoNode * superimposition;
341 SoCoordinate3 * sgeometry;
344 SoTranslation * stranslation;
345 SoTranslation * curInfoTrans;
346 SoTranslation * mouseOverTransSolid;
347 SoTranslation * mouseOverTransMaterial;
348 SoTranslation * mouseOverTransLogName;
349 SoTranslation * mouseOverTransZPos;
353 SoText2 * curInfoText;
356 SoText2 * mouseOverTextSolid;
357 SoText2 * mouseOverTextMaterial;
358 SoText2 * mouseOverTextLogName;
359 SoText2 * mouseOverTextZPos;
361 SoFont * curInfoFont;
362 SoFont * mouseOverFontSolid;
363 SoFont * mouseOverFontMaterial;
364 SoFont * mouseOverFontLogName;
365 SoFont * mouseOverFontZPos;
366 SoSwitch * axisSwitch;
367 SoSwitch * animSpeedOutlineSwitch;
368 SoSwitch * animSpeedSwitch;
369 SoSwitch * curInfoSwitch;
371 SoNode * getSuperimpositionNode(SoNode *,
const char * name);
373 void superimpositionEvent(SoAction * action);
374 static void superimpositionCB(
void * closure, SoAction * action);
376 virtual void actualRedraw(
void);
377 void updateSpeedIndicator(
void);
384 float defaultHeightAngle;
387 SbVec3f upVector, offsetFromCenter, center;
390 SoSeparator * newSceneGraph;