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;
254 struct sceneElement {
258 float closestPointZCoord;
261 struct elementForSorting {
262 float closestPointZCoord;
263 SbVec3f closestPoint;
264 float smallestDistance;
265 float distanceToBeamlineStart;
268 bool operator<(elementForSorting
const &other)
const
270 if (closestPointZCoord < other.closestPointZCoord)
272 if (closestPointZCoord > other.closestPointZCoord)
278 if (distanceToBeamlineStart < other.distanceToBeamlineStart)
280 if (distanceToBeamlineStart > other.distanceToBeamlineStart)
292 std::vector<sceneElement> sceneElements;
293 std::vector<viewPtData> viewPtList;
294 std::string fileName;
295 std::ifstream fileIn;
296 std::ofstream fileOut;
302 std::vector<SbVec3f> refParticleTrajectory;
304 std::vector<float> refZPositions;
308 State currentState, prevState, beforePausing;
313 SbVec3f prevParticleDir;
314 void * prevColorField;
316 viewPtData camB4Animation;
320 void setStartingPtForAnimation();
321 float left_right, up_down;
325 static void getViewPtNameCB(Widget, XtPointer, XtPointer);
326 std::string viewPtAutoName();
329 SoSearchAction * searcher;
331 SoNode * superimposition;
332 SoCoordinate3 * sgeometry;
335 SoTranslation * stranslation;
336 SoTranslation * curInfoTrans;
337 SoTranslation * mouseOverTransSolid;
338 SoTranslation * mouseOverTransMaterial;
339 SoTranslation * mouseOverTransLogName;
340 SoTranslation * mouseOverTransZPos;
344 SoText2 * curInfoText;
347 SoText2 * mouseOverTextSolid;
348 SoText2 * mouseOverTextMaterial;
349 SoText2 * mouseOverTextLogName;
350 SoText2 * mouseOverTextZPos;
352 SoFont * curInfoFont;
353 SoFont * mouseOverFontSolid;
354 SoFont * mouseOverFontMaterial;
355 SoFont * mouseOverFontLogName;
356 SoFont * mouseOverFontZPos;
357 SoSwitch * axisSwitch;
358 SoSwitch * animSpeedOutlineSwitch;
359 SoSwitch * animSpeedSwitch;
360 SoSwitch * curInfoSwitch;
362 SoNode * getSuperimpositionNode(SoNode *,
const char * name);
364 void superimpositionEvent(SoAction * action);
365 static void superimpositionCB(
void * closure, SoAction * action);
367 virtual void actualRedraw(
void);
368 void updateSpeedIndicator(
void);
375 float defaultHeightAngle;
378 SbVec3f upVector, offsetFromCenter, center;
381 SoSeparator * newSceneGraph;
~G4OpenInventorXtExaminerViewer()
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
bool viewingBeforePickRef
std::string saveScenegraphFileName
Widget addMenu(std::string name)
void updateViewParams(SoKeyboardEvent::Key)
void parseString(T &t, const std::string &s, bool &error)
void moveCamera(float dist=0, bool lookdown=false)
Widget createScale(Widget, char *, int, float)
virtual G4bool Notify(G4ApplicationState requiredState)
G4OpenInventorXtExaminerViewer(Widget parent=NULL, const char *name=NULL, SbBool embed=TRUE, SoXtFullViewer::BuildFlag flag=BUILD_ALL, SoXtViewer::Type type=BROWSER)
void warningMsgDialog(std::string, String, XtCallbackProc)
HookEventProcState(G4OpenInventorXtExaminerViewer *)
void addButton(Widget menu, std::string name, XtCallbackProc)
bool operator<(const CexmcAngularRange &left, const CexmcAngularRange &right)
Widget buildWidget(Widget parent)
virtual SbBool processSoEvent(const SoEvent *const event)
virtual void afterRealizeHook()
void addEscapeCallback(void(*cb)(void *), void *)
Widget saveRefCoordsWidget
std::string saveRefCoordsFileName
Widget saveScenegraphWidget
virtual void createViewerButtons(Widget parent, SbPList *buttonlist)