29#ifndef HookEventProcState_H
30#define HookEventProcState_H 1
48#ifndef G4OPENINVENTORXTEXAMINERVIEWER_HH
49#define G4OPENINVENTORXTEXAMINERVIEWER_HH
54#include <Inventor/SbLinear.h>
55#include <Inventor/nodes/SoLineSet.h>
56#include <Inventor/nodes/SoEventCallback.h>
57#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
58#include <Inventor/events/SoKeyboardEvent.h>
72 Widget prevViewPtButton, nextViewPtButton;
73 Widget menuBar, fileMenu, openFileDialog, newFileDialog,
74 loadRefCoordsDialog, saveRefCoordsDialog,
75 loadSceneGraphDialog, saveSceneGraphDialog,
76 viewPtSelection, listsDialog, myShellDialog, myViewPtList, myElementList;
79 void (*escapeCallback)(
void *);
80 void * examinerObject;
81 SbBool lshiftdown, rshiftdown, lctrldown, rctrldown;
87 const char *name = NULL,
89 SoXtFullViewer::BuildFlag flag = BUILD_ALL,
90 SoXtViewer::Type type = BROWSER);
94 template <
class T>
void parseString(T &t,
const std::string &s,
bool &error);
96 Widget
addMenu(std::string name);
97 void addButton(Widget menu, std::string name, XtCallbackProc);
121 SoXtFullViewer::BuildFlag flag,
122 SoXtViewer::Type type,
131 void moveCamera(
float dist = 0,
bool lookdown =
false);
142 void constructor(
const SbBool build);
150 static void sceneChangeCB(
void *, SoSensor *);
153 void writeViewPtIdx();
154 void cleanUpAfterPrevFile();
156 void popUpFileSelDialog(Widget&, std::string, std::string, XtCallbackProc);
157 static void cancelFileSelDialogCB(Widget, XtPointer, XtPointer);
158 static void openViewPtFileCB(Widget, XtPointer, XtPointer);
159 static void viewPtFileSelectedCB(Widget, XtPointer, XtPointer);
160 static void newViewPtFileCB(Widget, XtPointer, XtPointer);
161 static void createNewVPFileCB(Widget, XtPointer, XtPointer);
162 static void overwriteFileCB(Widget, XtPointer, XtPointer);
163 static void loadRefCoordsDialogCB(Widget, XtPointer, XtPointer);
164 static void loadRefCoordsCB(Widget, XtPointer, XtPointer);
165 static void saveRefCoordsDialogCB(Widget, XtPointer, XtPointer);
166 static void saveRefCoordsCB(Widget, XtPointer, XtPointer);
167 static void saveRefCoordsOverWriteCB(Widget, XtPointer, XtPointer);
168 static void loadSceneGraphDialogCB(Widget, XtPointer, XtPointer);
169 static void loadSceneGraphCB(Widget, XtPointer, XtPointer);
170 static void saveSceneGraphDialogCB(Widget, XtPointer, XtPointer);
171 static void saveSceneGraphCB(Widget, XtPointer, XtPointer);
172 static void saveSceneGraphOverWriteCB(Widget, XtPointer, XtPointer);
173 static void mouseoverCB(
void *aThis, SoEventCallback *eventCB);
174 static void pickingCB(
void *aThis, SoEventCallback *eventCB);
178 void addViewPoints();
179 static void closeListsDialogCB(Widget, XtPointer, XtPointer);
180 static void loadBookmarkCB(Widget, XtPointer, XtPointer);
181 static void renameBookmarkCB(Widget, XtPointer, XtPointer);
182 void renameViewPt(
char *vpName);
183 static void sortBookmarksCB(Widget, XtPointer, XtPointer);
184 void sortViewPts(std::vector<std::string>);
185 static void deleteBookmarkCB(Widget, XtPointer, XtPointer);
186 static void deleteViewPtCB(Widget, XtPointer, XtPointer);
187 void deleteViewPt(
char *vpName = NULL);
190 static void animateRefParticleCB(Widget, XtPointer, XtPointer);
191 static void animateSensorCB(
void *, SoSensor *);
192 static void animateSensorRotationCB(
void *, SoSensor *);
193 void animateRefParticle();
194 void saveCurCamera();
195 void restoreCamera();
196 double animateBtwPtsPeriod, speedStep;
200 SoTimerSensor *animateSensor;
201 SoTimerSensor *animateSensorRotation;
202 SoNodeSensor *sceneChangeSensor;
203 SbVec3f camStartPos, camEndPos;
204 SbRotation camStartOrient, camEndOrient;
206 static void prevViewPtCB(Widget, XtPointer, XtPointer);
207 static void nextViewPtCB(Widget, XtPointer, XtPointer);
208 static void saveViewPtCB(Widget, XtPointer, XtPointer);
209 static void abbrOutputCB(Widget, XtPointer, XtPointer);
210 static void pickRefPathCB(Widget, XtPointer, XtPointer);
211 static void switchWireFrameCB(Widget, XtPointer, XtPointer);
212 static void constructListsDialog(Widget, XtPointer, XtPointer);
213 void saveViewPt(
char *name);
216 static void lookAtSceneElementCB(Widget, XtPointer, XtPointer);
217 static void cancelSceneElementSelectionCB(Widget, XtPointer, XtPointer);
219 void setReferencePath(SoLineSet*, SoCoordinate3*,
bool append =
false);
220 void setReferencePathZPos();
221 void findAndSetRefPath();
222 SoCoordinate3* getCoordsNode(SoFullPath *path);
223 void getSceneElements();
224 float sqrlen(
const SbVec3f&);
225 void distanceToTrajectory(
const SbVec3f&,
float&, SbVec3f&,
int&);
227 void createElementsList(Widget);
228 static void closeMainWindowCB(Widget, XtPointer, XtPointer);
229 void evenOutRefParticlePts();
231 static void gotoRefPathStartCB(Widget, XtPointer, XtPointer);
232 void gotoRefPathStart();
233 static void invertRefPathCB(Widget, XtPointer, XtPointer);
234 void invertRefPath();
257 SbRotation orientation;
267 struct sceneElement {
271 float closestPointZCoord;
274 struct elementForSorting {
275 float closestPointZCoord;
276 SbVec3f closestPoint;
277 float smallestDistance;
278 float distanceToBeamlineStart;
283 if (closestPointZCoord < other.closestPointZCoord)
285 if (closestPointZCoord > other.closestPointZCoord)
291 if (distanceToBeamlineStart < other.distanceToBeamlineStart)
293 if (distanceToBeamlineStart > other.distanceToBeamlineStart)
305 std::vector<sceneElement> sceneElements;
306 std::vector<viewPtData> viewPtList;
307 std::string fileName;
308 std::ifstream fileIn;
309 std::ofstream fileOut;
315 std::vector<SbVec3f> refParticleTrajectory;
317 std::vector<float> refZPositions;
322 State currentState, prevState, beforePausing;
327 SbVec3f prevParticleDir;
328 void* prevColorField;
330 viewPtData camB4Animation;
334 void setStartingPtForAnimation();
335 float left_right, up_down;
339 static void getViewPtNameCB(Widget, XtPointer, XtPointer);
340 static void getViewPtNameCancelCB(Widget, XtPointer, XtPointer);
341 std::string viewPtAutoName();
344 SoSearchAction * searcher;
346 SoNode * superimposition;
347 SoCoordinate3 * sgeometry;
350 SoTranslation * stranslation;
351 SoTranslation * curInfoTrans;
352 SoTranslation * mouseOverTransSolid;
353 SoTranslation * mouseOverTransMaterial;
354 SoTranslation * mouseOverTransLogName;
355 SoTranslation * mouseOverTransZPos;
359 SoText2 * curInfoText;
362 SoText2 * mouseOverTextSolid;
363 SoText2 * mouseOverTextMaterial;
364 SoText2 * mouseOverTextLogName;
365 SoText2 * mouseOverTextZPos;
367 SoFont * curInfoFont;
368 SoFont * mouseOverFontSolid;
369 SoFont * mouseOverFontMaterial;
370 SoFont * mouseOverFontLogName;
371 SoFont * mouseOverFontZPos;
372 SoSwitch * axisSwitch;
373 SoSwitch * animSpeedOutlineSwitch;
374 SoSwitch * animSpeedSwitch;
375 SoSwitch * curInfoSwitch;
377 SoNode * getSuperimpositionNode(SoNode *,
const char * name);
379 void superimpositionEvent(SoAction * action);
380 static void superimpositionCB(
void * closure, SoAction * action);
382 virtual void actualRedraw(
void);
383 void updateSpeedIndicator(
void);
390 float defaultHeightAngle;
395 SbVec3f upVector, offsetFromCenter, center;
398 SoSeparator* newSceneGraph;
void warningMsgDialog(std::string, String, XtCallbackProc)
virtual SbBool processSoEvent(const SoEvent *const event)
void addButton(Widget menu, std::string name, XtCallbackProc)
bool viewingBeforePickRef
std::string saveRefCoordsFileName
~G4OpenInventorXtExaminerViewer()
virtual void createViewerButtons(Widget parent, SbPList *buttonlist)
Widget createScale(Widget, char *, int, float)
void updateViewParams(SoKeyboardEvent::Key)
void addEscapeCallback(void(*cb)(void *), void *)
void moveCamera(float dist=0, bool lookdown=false)
Widget saveRefCoordsWidget
Widget addMenu(std::string name)
void parseString(T &t, const std::string &s, bool &error)
virtual void afterRealizeHook()
std::string saveScenegraphFileName
Widget saveScenegraphWidget
Widget buildWidget(Widget parent)
virtual G4bool Notify(G4ApplicationState requiredState)
bool operator<(const HepRotation &r, const HepLorentzRotation <)
const char * name(G4int ptype)