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);
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;
281 bool operator<(elementForSorting
const &other)
const
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 std::string viewPtAutoName();
343 SoSearchAction * searcher;
345 SoNode * superimposition;
346 SoCoordinate3 * sgeometry;
349 SoTranslation * stranslation;
350 SoTranslation * curInfoTrans;
351 SoTranslation * mouseOverTransSolid;
352 SoTranslation * mouseOverTransMaterial;
353 SoTranslation * mouseOverTransLogName;
354 SoTranslation * mouseOverTransZPos;
358 SoText2 * curInfoText;
361 SoText2 * mouseOverTextSolid;
362 SoText2 * mouseOverTextMaterial;
363 SoText2 * mouseOverTextLogName;
364 SoText2 * mouseOverTextZPos;
366 SoFont * curInfoFont;
367 SoFont * mouseOverFontSolid;
368 SoFont * mouseOverFontMaterial;
369 SoFont * mouseOverFontLogName;
370 SoFont * mouseOverFontZPos;
371 SoSwitch * axisSwitch;
372 SoSwitch * animSpeedOutlineSwitch;
373 SoSwitch * animSpeedSwitch;
374 SoSwitch * curInfoSwitch;
376 SoNode * getSuperimpositionNode(SoNode *,
const char *
name);
378 void superimpositionEvent(SoAction * action);
379 static void superimpositionCB(
void * closure, SoAction * action);
381 virtual void actualRedraw(
void);
382 void updateSpeedIndicator(
void);
389 float defaultHeightAngle;
394 SbVec3f upVector, offsetFromCenter, center;
397 SoSeparator* newSceneGraph;
~G4OpenInventorXtExaminerViewer()
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)
friend class G4OpenInventorXtExaminerViewerMessenger
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)
friend class G4OpenInventorXtExtendedViewer
static PROLOG_HANDLER error
virtual SbBool processSoEvent(const SoEvent *const event)
virtual void afterRealizeHook()
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
void addEscapeCallback(void(*cb)(void *), void *)
Widget saveRefCoordsWidget
std::string saveRefCoordsFileName
Widget saveScenegraphWidget
virtual void createViewerButtons(Widget parent, SbPList *buttonlist)