39 #include <X11/keysym.h>
44 #include <Xm/MessageB.h>
46 #include <Xm/ToggleB.h>
47 #include <Xm/CascadeB.h>
48 #include <Xm/ArrowBG.h>
50 #include <Xm/RowColumn.h>
51 #include <Xm/FileSB.h>
52 #include <Xm/SelectioB.h>
53 #include <Xm/Protocols.h>
54 #include <Xm/SeparatoG.h>
55 #include <Xm/DialogS.h>
56 #include <Xm/PanedW.h>
57 #include <Xm/LabelG.h>
59 #include <Xm/DrawingA.h>
61 #include <Inventor/Xt/SoXt.h>
63 #include <Inventor/Xt/SoXtCursor.h>
64 #include <Inventor/events/SoKeyboardEvent.h>
65 #include <Inventor/events/SoMouseButtonEvent.h>
66 #include <Inventor/events/SoLocation2Event.h>
67 #include <Inventor/nodes/SoSeparator.h>
68 #include <Inventor/nodes/SoOrthographicCamera.h>
69 #include <Inventor/nodes/SoPerspectiveCamera.h>
70 #include <Inventor/nodes/SoEventCallback.h>
71 #include <Inventor/nodes/SoLineSet.h>
72 #include <Inventor/nodes/SoMaterial.h>
73 #include <Inventor/errors/SoDebugError.h>
74 #include <Inventor/SoPickedPoint.h>
75 #include <Inventor/actions/SoWriteAction.h>
78 #include "wheelmouse.h"
79 #include "SoXtInternal.h"
80 #include <Inventor/sensors/SoTimerSensor.h>
81 #include <Inventor/sensors/SoNodeSensor.h>
82 #include "saveViewPt.h"
84 #include "favorites.h"
86 #include "Geant4_SoPolyhedron.h"
93 #include <Inventor/nodes/SoCallback.h>
94 #include <Inventor/nodes/SoSwitch.h>
95 #include <Inventor/nodes/SoScale.h>
96 #include <Inventor/nodes/SoTranslation.h>
97 #include <Inventor/actions/SoSearchAction.h>
98 #include <Inventor/actions/SoGetBoundingBoxAction.h>
100 #include <Inventor/nodes/SoCoordinate3.h>
102 #include <Inventor/nodes/SoText2.h>
103 #include <Inventor/nodes/SoFont.h>
104 #include <Inventor/nodes/SoPointSet.h>
105 #include <Inventor/nodes/SoDrawStyle.h>
106 #include <Inventor/nodes/SoBaseColor.h>
109 #include <Inventor/nodekits/SoBaseKit.h>
115 #define MIN_SPEED 2.1 // Lower number means faster
116 #define START_STEP 0.3
117 #define SPEED_INDICATOR_STEP 0.045
118 #define MAX_SPEED_INDICATOR 0.81
124 const char *
name, SbBool embed,
125 SoXtFullViewer::BuildFlag flag, SoXtViewer::Type type) :
126 SoXtExaminerViewer(parent, name, embed, flag, type,
FALSE)
134 const char *
name, SbBool embed,
135 SoXtFullViewer::BuildFlag flag, SoXtViewer::Type type,
137 SoXtExaminerViewer(parent, name, embed, flag, type,
FALSE)
158 myCam =
new SoPerspectiveCamera;
192 static const char * superimposed[] = {
193 "#Inventor V2.1 ascii",
"",
200 " OrthographicCamera ",
206 " DEF soxt->callback Callback { }",
209 " DEF soxt->translation Translation ",
211 " translation 0 0 0",
213 " DEF soxt->scale Scale ",
215 " scaleFactor 1 1 1",
217 " DEF soxt->geometry Coordinate3 ",
221 " -0.81 -0.04 0, -0.81 0 0,",
222 " -0.81 0.04 0, 0 -0.04 0,",
224 " 0.81 -0.04 0, 0.81 0 0,",
227 " 0.81 0.02 0, 0.81 -0.02 0,",
230 " 0.4 0.01 0, 0.4 -0.01 0,",
235 " DEF soxt->animSpeedOutlineSwitch Switch ",
240 " emissiveColor 0 0 0",
246 " 12, 11, 10, 9, -1",
251 " DEF soxt->axisSwitch Switch ",
270 " DEF soxt->animSpeedSwitch Switch ",
275 " emissiveColor 0 1 0",
281 " 16, 15, 14, 13, -1",
287 " DEF soxt->curInfoSwitch Switch ",
290 " DEF soxt->curInfoTrans Translation ",
292 " translation 10 20 30 ",
294 " DEF soxt->curInfoFont Font ",
296 " name defaultFont:Bold",
299 " DEF soxt->curInfoText Text2 ",
308 " DEF soxt->mouseOverTransLogName Translation ",
310 " translation 0 0 0 ",
312 " DEF soxt->mouseOverFontLogName Font ",
314 " name defaultFont:Bold",
317 " DEF soxt->mouseOverTextLogName Text2 { } ",
321 " DEF soxt->mouseOverTransSolid Translation ",
323 " translation 0 0 0 ",
325 " DEF soxt->mouseOverFontSolid Font ",
327 " name defaultFont:Bold",
330 " DEF soxt->mouseOverTextSolid Text2 { } ",
334 " DEF soxt->mouseOverTransMaterial Translation ",
336 " translation 0 0 0 ",
338 " DEF soxt->mouseOverFontMaterial Font ",
340 " name defaultFont:Bold",
343 " DEF soxt->mouseOverTextMaterial Text2 { } ",
347 " DEF soxt->mouseOverTransZPos Translation ",
349 " translation 0 0 0 ",
351 " DEF soxt->mouseOverFontZPos Font ",
353 " name defaultFont:Bold",
356 " DEF soxt->mouseOverTextZPos Text2 { } ",
362 for (i = bufsize = 0; superimposed[i]; i++)
363 bufsize += strlen(superimposed[i]) + 1;
364 char * buf =
new char[bufsize + 1];
365 for (i = bufsize = 0; superimposed[i]; i++) {
366 strcpy(buf + bufsize, superimposed[i]);
367 bufsize += strlen(superimposed[i]);
371 SoInput * input =
new SoInput;
372 input->setBuffer(buf, bufsize);
431 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
465 this->
searcher =
new SoSearchAction;
468 searcher->setInterest(SoSearchAction::FIRST);
472 return searcher->getPath()->getTail();
489 if (!action->isOfType(SoGLRenderAction::getClassTypeId()))
491 SbViewportRegion vpRegion =
492 ((SoGLRenderAction *) action)->getViewportRegion();
493 SbVec2s viewportSize = vpRegion.getViewportSizePixels();
495 float aspect = float(viewportSize[0]) / float(viewportSize[1]);
496 float factorx = 1.0f / float(viewportSize[1]) * 220.0f;
497 float factory = factorx;
500 this->
stranslation->translation.setValue(SbVec3f(0.0f, -0.4f, 0.0f));
503 SbVec3f(0.0f, -0.4f / aspect, 0.0f));
507 if (viewportSize[0] > 500)
508 factorx *= 500.0f / 400.0f;
510 factorx *= float(viewportSize[0]) / 400.0f;
511 this->
sscale->scaleFactor.setValue(SbVec3f(factorx, factory, 1.0f));
513 float xInfo, yInfo, xMouseLogName, yMouseLogName, xMouseSolid, yMouseSolid,
514 xMouseMaterial, yMouseMaterial, xMouseZPos, yMouseZPos;
518 yMouseLogName = -.75;
521 xMouseMaterial = 0.0;
522 yMouseMaterial = -.81;
528 xMouseSolid *= aspect;
529 xMouseMaterial *= aspect;
530 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
532 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
534 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
536 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
538 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
541 yMouseSolid /= aspect;
542 yMouseMaterial /= aspect;
543 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
545 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
547 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
549 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
551 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
556 this->
curInfoFont->name.setValue(
"defaultFont:Italic");
561 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
567 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
570 this->
curInfoText->string.setValue(SbString(zPos));
599 Atom WM_DELETE_WINDOW;
602 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::buildWidget",
"Error: Parent is null.");
605 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
606 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
607 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
608 XtSetArg(args[3], XmNbottomAttachment, XmATTACH_FORM);
609 Widget form = XmCreateForm(parent, (
char *)
"Form", args, 4);
612 shell = XtParent(form);
613 WM_DELETE_WINDOW = XInternAtom(XtDisplay(parent),
"WM_DELETE_WINDOW",
615 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW,
618 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
619 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
620 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
621 menuBar = XmCreateMenuBar(form, (
char *)
"MenuBar", args, 3);
632 XmCreateSeparatorGadget(
fileMenu, (
char *)
"Separator", NULL, 0));
634 Widget menu =
addMenu(
"Tools");
639 Widget viewerBase = SoXtFullViewer::buildWidget(form);
641 XtSetArg(args[0], XmNtopAttachment, XmATTACH_WIDGET);
642 XtSetArg(args[1], XmNtopWidget,
menuBar);
643 XtSetArg(args[2], XmNleftAttachment, XmATTACH_FORM);
644 XtSetArg(args[3], XmNrightAttachment, XmATTACH_FORM);
645 XtSetArg(args[4], XmNbottomAttachment, XmATTACH_FORM);
646 XtSetValues(viewerBase, args, 5);
656 Widget menu = XmCreatePulldownMenu(
menuBar, (
char *) name.c_str(), NULL, 0);
658 XtSetArg(args[0], XmNsubMenuId, menu);
659 Widget w = XmCreateCascadeButton(
menuBar, (
char *) name.c_str(), args, 1);
670 Widget button = XmCreatePushButton(menu, (
char *) name.c_str(), NULL, 0);
671 XtManageChild(button);
672 XtAddCallback(button, XmNactivateCallback, cb,
this);
678 SbPList * buttonlist)
682 Widget saveViewPtButton, abbrOutputButton, pickRefPathButton;
685 SoXtExaminerViewer::createViewerButtons(parent, buttonlist);
688 Widget emptyButton = XtVaCreateManagedWidget(
"", xmPushButtonWidgetClass,
690 buttonlist->append(emptyButton);
694 XtSetArg(args[n], XmNtopPosition, 1); n++;
695 XtSetArg(args[n], XmNbottomPosition, 2); n++;
696 XtSetArg(args[n], XmNleftPosition, 0); n++;
697 XtSetArg(args[n], XmNrightPosition, 1); n++;
698 XtSetArg(args[n], XmNarrowDirection, XmARROW_LEFT); n++;
699 XtSetArg(args[n], XmNsensitive, False); n++;
709 XtSetArg(args[n], XmNtopPosition, 1); n++;
710 XtSetArg(args[n], XmNbottomPosition, 2); n++;
711 XtSetArg(args[n], XmNleftPosition, 0); n++;
712 XtSetArg(args[n], XmNrightPosition, 1); n++;
713 XtSetArg(args[n], XmNarrowDirection, XmARROW_RIGHT); n++;
714 XtSetArg(args[n], XmNsensitive, False); n++;
723 saveViewPtButton = XtVaCreateManagedWidget(
"Save", xmPushButtonWidgetClass,
725 XtAddCallback(saveViewPtButton, XmNactivateCallback,
727 Pixmap saveVP, saveVP_ins;
728 saveVP = SoXtInternal::createPixmapFromXpm(saveViewPtButton,
730 saveVP_ins = SoXtInternal::createPixmapFromXpm(saveViewPtButton,
731 saveViewPt_xpm,
TRUE);
732 XtVaSetValues(saveViewPtButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
733 saveVP, XmNselectPixmap, saveVP, XmNlabelInsensitivePixmap,
734 saveVP_ins, XmNselectInsensitivePixmap, saveVP_ins, NULL);
735 buttonlist->append(saveViewPtButton);
738 abbrOutputButton = XtVaCreateManagedWidget(
"Abbr",
739 xmToggleButtonWidgetClass, parent, XmNindicatorOn, False, NULL);
742 Pixmap consolexpm, consolexpm_ins;
743 consolexpm = SoXtInternal::createPixmapFromXpm(abbrOutputButton,
745 consolexpm_ins = SoXtInternal::createPixmapFromXpm(abbrOutputButton,
747 XtVaSetValues(abbrOutputButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
748 consolexpm, XmNselectPixmap, consolexpm, XmNlabelInsensitivePixmap,
749 consolexpm_ins, XmNselectInsensitivePixmap, consolexpm_ins, NULL);
750 buttonlist->append(abbrOutputButton);
753 pickRefPathButton = XtVaCreateManagedWidget(
"Refpath", xmPushButtonWidgetClass,
755 XtAddCallback(pickRefPathButton, XmNactivateCallback,
757 Pixmap favoritesxpm, favoritesxpm_ins;
758 favoritesxpm = SoXtInternal::createPixmapFromXpm(pickRefPathButton,
760 favoritesxpm_ins = SoXtInternal::createPixmapFromXpm(pickRefPathButton,
761 favorites_xpm,
TRUE);
762 XtVaSetValues(pickRefPathButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
763 favoritesxpm, XmNselectPixmap, favoritesxpm, XmNlabelInsensitivePixmap,
764 favoritesxpm_ins, XmNselectInsensitivePixmap, favoritesxpm_ins, NULL);
765 buttonlist->append(pickRefPathButton);
774 SoXtExaminerViewer::afterRealizeHook();
778 SoCamera *cam = getCamera();
780 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
782 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
785 ((SoOrthographicCamera *) cam)->height.getValue();
789 ((SoOrthographicCamera *) cam)->height.getValue();
792 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
794 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
803 String dialogName = (
char *)
"Error Loading File";
804 std::string msg =
"Wrong or corrupted input file.";
809 fileOut.seekp(0, std::ios::end);
830 SoSeparator *root = (SoSeparator *) (getSceneManager()->getSceneGraph());
832 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::afterRealizeHook",
"Root is null.");
834 root->addChild(
myCam);
846 SoEventCallback *moCB =
new SoEventCallback;
847 moCB->addEventCallback(
848 SoLocation2Event::getClassTypeId(),
850 root->addChild(moCB);
854 SoEventCallback *pickCB =
new SoEventCallback;
855 pickCB->addEventCallback(
856 SoMouseButtonEvent::getClassTypeId(),
858 root->addChild(pickCB);
867 SoCamera *cam = getCamera();
874 cam->position = camPosNew;
876 cam->focalDistance = (
prevPt - camPosNew).length();
895 SoCamera *cam = getCamera();
908 cam->focalDistance = (cam->position.getValue() -
center).length();
917 dist = (
prevPt - cam->position.getValue()).length();
924 dist = (
prevPt - cam->position.getValue()).length();
933 particleDir = p2 - p1;
934 particleDir.normalize();
947 SbRotation rot(SbVec3f(0,0,1), particleDir);
961 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
968 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
980 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
983 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
984 camPosNew = p2 - (
camDir);
987 cam->position = camPosNew;
994 camPosNew.getValue(x,y,z);
1005 SoEventCallback *eventCB)
1007 SoHandleEventAction* action = eventCB->getAction();
1008 const SoPickedPoint *
pp = action->getPickedPoint();
1013 SoPath* path = pp->getPath();
1014 SoNode* node = ((SoFullPath*)path)->getTail();
1016 if(node->getTypeId() == SoLineSet::getClassTypeId()){
1026 SoLineSet * trajectory = (SoLineSet *)node;
1032 SoSeparator * grpNode =
1033 (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
1038 int nodeIndex = grpNode->findChild(trajectory);
1041 SoCoordinate3 * coords = 0;
1045 for(
int i = 0; i < 100; ++i) {
1048 tmpNode = grpNode->getChild(nodeIndex);
1049 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
1051 coords = (SoCoordinate3 *)tmpNode;
1057 String dialogName = (
char *)
"No coordinates";
1058 std::string msg =
"Could not find the coordinates node"
1059 " for the picked trajectory."
1060 " Reference trajectory not set";
1077 if(attHolder && attHolder->
GetAttDefs().size()) {
1079 std::string strTrajPoint =
"G4TrajectoryPoint:";
1080 std::ostringstream oss;
1081 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1086 if(oss.str().find(strTrajPoint) != std::string::npos) {
1101 G4String cls((
char*)node->getTypeId().getName().getString());
1102 G4cout <<
"SoNode : " << node
1103 <<
" SoType : " << cls
1104 <<
" name : " <<
name
1121 if(attHolder && attHolder->
GetAttDefs().size()) {
1122 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1128 G4String cls((
char*)node->getTypeId().getName().getString());
1129 G4cout <<
"SoNode : " << node
1130 <<
" SoType : " << cls
1131 <<
" name : " <<
name
1137 eventCB->setHandled();
1144 SoHandleEventAction* action = eventCB->getAction();
1145 const SoPickedPoint *
pp = action->getPickedPoint();
1153 const SbViewportRegion & viewportRegion = action->getViewportRegion();
1155 std::string sLogName;
1157 std::stringstream ssZPos;
1158 std::stringstream ssSolids;
1159 std::stringstream ssMaterials;
1160 SoPath * path = pp->getPath();
1161 SoNode* node = ((SoFullPath*)path)->getTail();
1163 if(node->getTypeId() == Geant4_SoPolyhedron::getClassTypeId()) {
1165 sLogName =
"Logical Volume: ";
1166 sLogName += ((Geant4_SoPolyhedron *)node)->getName().getString();
1168 SoGetBoundingBoxAction bAction(viewportRegion);
1169 bAction.apply((SoFullPath*)path);
1170 SbBox3f bBox = bAction.getBoundingBox();
1171 SbVec3f
center = bBox.getCenter();
1172 center.getValue(x,y,z);
1173 ssZPos <<
"Pos: " << x <<
" " << y <<
" " <<
z;
1176 if(attHolder && attHolder->
GetAttDefs().size()) {
1178 std::vector<const std::map<G4String,G4AttDef>*> vecDefs =
1180 std::vector<const std::vector<G4AttValue>*> vecVals =
1182 for (
size_t i = 0; i < vecDefs.size(); ++i) {
1183 const std::vector<G4AttValue> * vals = vecVals[i];
1185 std::vector<G4AttValue>::const_iterator iValue;
1187 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1188 const G4String& valueName = iValue->GetName();
1189 const G4String& value = iValue->GetValue();
1191 if(valueName ==
"Solid") {
1192 if(ssSolids.str() ==
"")
1193 ssSolids <<
"Solid Name: " << value;
1195 ssSolids <<
", " << value;
1198 if(valueName ==
"Material") {
1199 if(ssMaterials.str() ==
"")
1200 ssMaterials <<
"Material Name: " << value;
1202 ssMaterials <<
", " << value;
1209 bool redraw =
false;
1214 if(std::string(This->
mouseOverTextSolid->string.getValues(0)->getString()) != ssSolids.str()) {
1218 if(std::string(This->
mouseOverTextMaterial->string.getValues(0)->getString()) != ssMaterials.str()){
1222 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) != ssZPos.str()) {
1229 This->scheduleRedraw();
1232 eventCB->setHandled();
1237 This->scheduleRedraw();
1241 This->scheduleRedraw();
1245 This->scheduleRedraw();
1247 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) !=
"") {
1249 This->scheduleRedraw();
1256 SoCamera *cam = getCamera();
1257 const SoType type(ev->getTypeId());
1259 if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
1260 SoMouseButtonEvent * me = (SoMouseButtonEvent *) ev;
1264 switch (me->getButton()) {
1265 case SoMouseButtonEvent::BUTTON4:
1266 if (me->getState() == SoButtonEvent::DOWN) {
1267 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1269 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1270 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1273 }
else if (cam->isOfType(
1274 SoOrthographicCamera::getClassTypeId())) {
1276 ((SoOrthographicCamera *) cam)->height.getValue();
1277 ((SoOrthographicCamera *) cam)->height = height + 5;
1282 case SoMouseButtonEvent::BUTTON5:
1283 if (me->getState() == SoButtonEvent::DOWN) {
1284 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1286 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1288 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1291 }
else if (cam->isOfType(
1292 SoOrthographicCamera::getClassTypeId())) {
1294 ((SoOrthographicCamera *) cam)->height.getValue();
1296 ((SoOrthographicCamera *) cam)->height = height - 5;
1310 if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
1311 SoKeyboardEvent * ke = (SoKeyboardEvent *) ev;
1313 if (SoKeyboardEvent::isKeyPressEvent(ev, ke->getKey())) {
1314 switch (ke->getKey()) {
1315 case SoKeyboardEvent::LEFT_SHIFT:
1318 case SoKeyboardEvent::RIGHT_SHIFT:
1321 case SoKeyboardEvent::LEFT_CONTROL:
1324 case SoKeyboardEvent::RIGHT_CONTROL:
1327 case SoKeyboardEvent::SPACE:
1349 case SoKeyboardEvent::ESCAPE:
1365 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
1376 case SoKeyboardEvent::DELETE:
1381 String dialogName = (
char *)
"Delete Viewpoint";
1382 std::string msg =
"Are you sure you want to delete current viewpoint?";
1387 case SoKeyboardEvent::LEFT_ARROW:
1395 if (SoXtExaminerViewer::isAnimating())
1411 if (SoXtExaminerViewer::isAnimating())
1436 cam->position =
myCam->position;
1443 this->bottomWheelMotion(
1444 this->getBottomWheelValue() + 0.1f);
1454 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1455 "Unhandled viewer state");
1460 case SoKeyboardEvent::RIGHT_ARROW:
1468 if (SoXtExaminerViewer::isAnimating())
1482 if (SoXtExaminerViewer::isAnimating())
1504 cam->position =
myCam->position;
1511 this->bottomWheelMotion(
1512 this->getBottomWheelValue() - 0.1f);
1521 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1522 "Unhandled viewer state");
1527 case SoKeyboardEvent::DOWN_ARROW:
1536 if (SoXtExaminerViewer::isAnimating())
1559 cam->position =
myCam->position;
1566 this->leftWheelMotion(this->getLeftWheelValue() - 0.1f);
1575 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1576 "Unhandled viewer state");
1581 case SoKeyboardEvent::UP_ARROW:
1589 if (SoXtExaminerViewer::isAnimating())
1612 cam->position =
myCam->position;
1619 this->leftWheelMotion(this->getLeftWheelValue() + 0.1f);
1628 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1629 "Unhandled viewer state");
1634 case SoKeyboardEvent::PAGE_UP:
1685 case SoKeyboardEvent::PAGE_DOWN:
1733 case SoKeyboardEvent::E:
1741 if (SoKeyboardEvent::isKeyReleaseEvent(ev, ke->getKey())) {
1742 switch (ke->getKey()) {
1743 case SoKeyboardEvent::LEFT_SHIFT:
1746 case SoKeyboardEvent::RIGHT_SHIFT:
1749 case SoKeyboardEvent::LEFT_CONTROL:
1752 case SoKeyboardEvent::RIGHT_CONTROL:
1765 return SoXtExaminerViewer::processSoEvent(ev);
1781 if (refParticleIdx < lastIdx && !animateSensor->isScheduled())
1807 SbVec3f * points = this->
sgeometry->point.startEditing();
1809 if (points[10][0] == 0.0f)
1811 if (points[14][0] == 0.0f)
1831 SoXtExaminerViewer::actualRedraw();
1834 SoXtExaminerViewer::actualRedraw();
1880 SbVec3f refParticlePt;
1885 for(
int i = 0; i < lineset->numVertices.getNum(); ++i){
1886 for(
int j = 0; j < lineset->numVertices[i]; ++j){
1887 refParticlePt = coords->point[j];
1913 SoSearchAction action;
1914 action.setType(SoLineSet::getClassTypeId(),
false);
1916 action.apply(this->getSceneGraph());
1918 SoPathList &pathList = action.getPaths();
1920 if(pathList.getLength() != 0){
1922 SoCoordinate3 * coords = NULL;
1923 std::vector<SoCoordinate3 *> coordvec;
1924 std::vector<SoLineSet *> linevec;
1926 bool refPathFound =
false;
1927 for(
int i = 0; i < pathList.getLength(); ++i) {
1928 SoFullPath *path = (SoFullPath *)pathList[i];
1931 for (
size_t j = 0; j < attHolder->
GetAttDefs().size(); ++j) {
1932 std::ostringstream oss;
1935 std::string findStr =
"Type of trajectory (Type): ";
1936 std::string compareValue =
"REFERENCE";
1937 size_t idx = oss.str().find(findStr);
1939 if(idx != std::string::npos) {
1940 if(oss.str().substr(idx + findStr.size(), compareValue.size()) == compareValue) {
1943 refPathFound =
true;
1944 coordvec.push_back(coords);
1945 linevec.push_back((SoLineSet *)path->getTail());
1951 findStr =
"Track ID (ID): ";
1952 idx = oss.str().find(findStr);
1953 if(idx != std::string::npos) {
1955 std::string tmpstr = oss.str().substr(idx + findStr.size(),1);
1956 std::istringstream
buffer(tmpstr);
1963 const char * nextChar =
1964 oss.str().substr(idx + findStr.size() + 1,1).c_str();
1965 if(std::isdigit(nextChar[0]))
1970 coordvec.push_back(coords);
1971 linevec.push_back((SoLineSet *)path->getTail());
1987 if(coordvec.empty())
1998 float longestLength = 0.0;
2000 for(
unsigned int i=0;i < linevec.size(); ++i){
2003 std::vector<SbVec3f> trajectory;
2005 for(
int j=0; j < linevec[i]->numVertices.getNum(); ++j){
2007 for(
int k=0; k < linevec[i]->numVertices[j]; ++k){
2008 trajectory.push_back(coordvec[i]->point[k]);
2013 float tmpLength=0.0;
2014 for(
unsigned int j=0; j < trajectory.size() - 1; ++j){
2015 tmpLength += (trajectory[j] - trajectory[j + 1]).length();
2018 if(tmpLength > longestLength){
2020 longestLength = tmpLength;
2032 SoLineSet *trajectory = (SoLineSet *)path->getTail();
2033 SoSeparator * grpNode = (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
2034 int nodeIndex = grpNode->findChild(trajectory);
2039 for(
int i = 0; i < 100; ++i){
2042 tmpNode = grpNode->getChild(nodeIndex);
2043 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
2045 return (SoCoordinate3 *)tmpNode;
2056 std::string field, eltName;
2058 std::map<std::string, int> duplicates;
2059 std::map<std::string, int> sceneElts;
2060 SoSearchAction search;
2061 Geant4_SoPolyhedron *node;
2062 SoGroup *root = (SoGroup *)getSceneManager()->getSceneGraph();
2064 SoBaseKit::setSearchingChildren(
TRUE);
2067 search.setSearchingAll(
TRUE);
2069 search.setType(Geant4_SoPolyhedron::getClassTypeId(), 0);
2072 SoPathList &pl = search.getPaths();
2076 for(
int i = 0; i < pl.getLength(); i++) {
2077 SoFullPath *path = (SoFullPath *)pl[i];
2078 node = (Geant4_SoPolyhedron *)path->getTail();
2079 eltName = node->getName();
2080 if(duplicates.count(eltName))
2081 duplicates[eltName]++;
2083 duplicates[eltName] = 1;
2086 for(
int i = 0; i < pl.getLength(); i++) {
2088 std::stringstream ssCount;
2089 SoFullPath *path = (SoFullPath *)pl[i];
2090 node = (Geant4_SoPolyhedron *)path->getTail();
2091 eltName = node->getName();
2093 if(duplicates[eltName] == 1)
2096 if(sceneElts.count(eltName))
2097 sceneElts[eltName]++;
2099 sceneElts[eltName] = 1;
2101 ssCount << sceneElts[eltName];
2105 field += ssCount.str();
2107 SoGetBoundingBoxAction bAction(getViewportRegion());
2108 bAction.apply(path);
2109 SbBox3f bBox = bAction.getBoundingBox();
2111 SbVec3f centr = bBox.getCenter();
2112 centr.getValue(x,y,z);
2125 return x*x + y*y + z*
z;
2131 SbVec3f &closestPoint,
2170 SbVec3f dbq = b - q;
2171 float sqrDist =
sqrlen(dbq);
2174 for (
size_t i = 1; i < count; ++i) {
2175 const SbVec3f
a = b;
2176 const SbVec3f daq = dbq;
2179 const SbVec3f dab = a - b;
2181 float dab_x, dab_y, dab_z;
2182 dab.getValue(dab_x,dab_y,dab_z);
2183 float daq_x, daq_y, daq_z;
2184 daq.getValue(daq_x, daq_y, daq_z);
2185 float dbq_x, dbq_y, dbq_z;
2186 dbq.getValue(dbq_x, dbq_y, dbq_z);
2188 const float inv_sqrlen = 1./
sqrlen(dab);
2189 const float t = (dab_x*daq_x + dab_y*daq_y + dab_z*daq_z)*inv_sqrlen;
2200 current_dist = daq_x*daq_x + daq_y*daq_y + daq_z*daq_z
2201 - t*(daq_x*dab_x + daq_y*dab_y + daq_z*dab_z)
2202 + t*t*(dab_x*dab_x + dab_y*dab_y + dab_z*dab_z);
2207 current_dist =
sqrlen(dbq);
2210 if (current_dist < sqrDist){
2211 sqrDist = current_dist;
2212 closestPoint = a + t*(b-
a);
2217 dist = std::sqrt(sqrDist);
2227 typedef std::map<elementForSorting, sceneElement> sortedMap;
2236 trajLength[trajIndex] = 0.0;
2240 trajLength[trajIndex] = trajLength[trajIndex-1] + (*itRef - prevPoint).length();
2248 SoGetBoundingBoxAction bAction(this->getViewportRegion());
2249 SbVec3f elementCoord;
2250 std::vector<sceneElement>::iterator itEl;
2255 bAction.apply(itEl->path);
2256 elementCoord = bAction.getBoundingBox().getCenter();
2268 sorted.insert(std::make_pair(el,*itEl));
2274 sortedMap::iterator itSorted = sorted.begin();
2275 for(; itSorted != sorted.end(); itSorted++)
2281 Widget formTop = XtNameToWidget(this->
listsDialog,
"FormTop");
2282 Widget formTopRight = XtNameToWidget(formTop,
"FormTopRight");
2286 delete[] trajLength;
2296 XmString *elements = (XmString *) XtMalloc(size *
sizeof(XmString));
2298 std::vector<sceneElement>::const_iterator it;
2300 std::stringstream ss;
2304 ss <<
" [" << it->closestPointZCoord <<
"]";
2305 elements[count] = XmStringCreateLocalized((
char *)ss.str().c_str());
2316 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2318 labelRight = XmCreateLabelGadget(formTopRight, (
char*)
"Element [S mm]",
2320 XtManageChild(labelRight);
2324 XtSetArg(args[n], XmNvisibleItemCount, 7); n++;
2325 XtSetArg(args[n], XmNitemCount, size); n++;
2326 XtSetArg(args[n], XmNitems, elements); n++;
2327 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2328 XtSetArg(args[n], XmNtopWidget, labelRight); n++;
2329 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2330 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2331 XtSetArg(args[n], XmNwidth, 280); n++;
2334 this->
myElementList = XmCreateScrolledList(formTopRight, (
char *)
"ListRight", args, n);
2336 XtAddCallback(this->
myElementList, XmNbrowseSelectionCallback,
2341 if (elements != NULL) {
2342 for (
int i = 0; i < size; i++)
2343 XmStringFree(elements[i]);
2344 XtFree((
char *) elements);
2353 XtPointer client_data,
2379 Atom WM_DELETE_WINDOW;
2384 topShell = SoXt::getShellWidget(This->getParentWidget());
2387 std::string dialogNameStr = This->
fileName.substr(This->
fileName.rfind(
'/') + 1);
2388 const int nDialog = dialogNameStr.size() + 1;
2389 char *dialogName =
new char[nDialog];
2390 strncpy(dialogName, dialogNameStr.c_str(), nDialog);
2393 XtSetArg(args[n], XmNx, 610); n++;
2394 This->
myShellDialog = XmCreateDialogShell(topShell, dialogName, args, n);
2396 delete[] dialogName;
2397 WM_DELETE_WINDOW = XInternAtom(XtDisplay(w),
"WM_DELETE_WINDOW", False);
2398 XmAddWMProtocolCallback(This->
myShellDialog, WM_DELETE_WINDOW,
2403 XtSetArg(args[n], XmNsashWidth, 1); n++;
2404 XtSetArg(args[n], XmNsashHeight, 1); n++;
2405 XtSetArg(args[n], XmNseparatorOn, False); n++;
2412 Widget formTop = XmCreateForm(This->
listsDialog, (
char *)
"FormTop", args, n);
2415 XtSetArg(args[n], XmNmarginWidth, 8); n++;
2416 XtSetArg(args[n], XmNmarginHeight, 8); n++;
2417 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2418 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2419 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2420 Widget formTopRight = XmCreateForm(formTop, (
char *)
"FormTopRight", args,
2424 XtSetArg(args[n], XmNmarginWidth, 8); n++;
2425 XtSetArg(args[n], XmNmarginHeight, 8); n++;
2426 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2427 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2428 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2429 XtSetArg(args[n], XmNrightWidget, formTopRight); n++;
2430 XtSetArg(args[n], XmNrightOffset, 10); n++;
2431 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2432 Widget formTopLeft = XmCreateForm(formTop, (
char *)
"FormTopLeft", args, n);
2437 XtManageChild(formTopRight);
2443 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2444 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2445 Widget labelLeft = XmCreateLabelGadget(formTopLeft, (
char *)
"ViewPoints",
2447 XtManageChild(labelLeft);
2451 XtSetArg(args[n], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); n++;
2452 XtSetArg(args[n], XmNvisibleItemCount, 7); n++;
2454 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2455 XtSetArg(args[n], XmNtopWidget, labelLeft); n++;
2456 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2457 XtSetArg(args[n], XmNrightWidget, This->
myElementList); n++;
2458 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2459 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2460 XtSetArg(args[n], XmNwidth, 200); n++;
2462 This->
myViewPtList = XmCreateScrolledList(formTopLeft, (
char *)
"ListLeft",
2466 XtAddCallback(This->
myViewPtList, XmNbrowseSelectionCallback,
2472 XtManageChild(formTopLeft);
2474 XtManageChild(formTop);
2478 XtSetArg(args[n], XmNmarginWidth, 6); n++;
2479 Widget formMiddle = XmCreateForm(This->
listsDialog, (
char *)
"MiddleForm", args,
2484 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2485 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2486 XtSetArg(args[n], XmNtopWidget, This->
myViewPtList); n++;
2487 Widget label = XmCreateLabelGadget(formMiddle, (
char *)
"Selection", args,
2489 XtManageChild(label);
2493 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2494 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2495 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2496 XtSetArg(args[n], XmNtopWidget, label); n++;
2497 XtSetArg(args[n], XmNtopOffset, 3); n++;
2498 XtSetArg(args[n], XmNmaxLength, This->
MAX_VP_NAME); n++;
2499 This->
viewPtSelection = XmCreateText(formMiddle, (
char *)
"Txt", args, n);
2502 Dimension h1, h2, h;
2503 XtVaGetValues(label, XmNheight, &h1, NULL);
2506 h = (Dimension) (1.1 * (h1 + h2));
2508 XtVaSetValues(formMiddle, XmNpaneMaximum, h, XmNpaneMinimum, h, NULL);
2509 XtManageChild(formMiddle);
2514 XtSetArg(args[n], XmNfractionBase, 4); n++;
2515 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2517 Widget formAction = XmCreateForm(This->
listsDialog, (
char *)
"ActionForm", args,
2521 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2522 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2523 XtSetArg(args[n], XmNtopOffset, 3); n++;
2524 XtSetArg(args[n], XmNbottomOffset, 5); n++;
2525 Widget separator = XmCreateSeparatorGadget(formAction, (
char *)
"Sep", args, n);
2527 XtManageChild(separator);
2529 Widget button = XmCreatePushButton(formAction, (
char *)
"Delete", NULL, 0);
2530 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2531 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2532 XmATTACH_POSITION, XmNleftPosition, 0, XmNrightAttachment,
2533 XmATTACH_POSITION, XmNrightPosition, 1,
2534 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2537 XtAddCallback(button, XmNactivateCallback,
2539 XtManageChild(button);
2541 button = XmCreatePushButton(formAction, (
char *)
"Rename", NULL, 0);
2542 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2543 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2544 XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment,
2545 XmATTACH_POSITION, XmNrightPosition, 2,
2546 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2549 XtAddCallback(button, XmNactivateCallback,
2551 XtManageChild(button);
2553 button = XmCreatePushButton(formAction, (
char *)
"Sort", NULL, 0);
2554 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2555 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2556 XmATTACH_POSITION, XmNleftPosition, 2, XmNrightAttachment,
2557 XmATTACH_POSITION, XmNrightPosition, 3,
2558 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2561 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)
sortBookmarksCB, This);
2562 XtManageChild(button);
2564 button = XmCreatePushButton(formAction, (
char *)
"Close", NULL, 0);
2565 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2566 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2567 XmATTACH_POSITION, XmNleftPosition, 3, XmNrightAttachment,
2568 XmATTACH_POSITION, XmNrightPosition, 4,
2569 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2572 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc) closeListsDialogCB, This);
2573 XtManageChild(button);
2575 XtManageChild(formAction);
2576 XtVaGetValues(button, XmNheight, &h1, NULL);
2577 XtVaSetValues(formAction, XmNpaneMaximum, h1, XmNpaneMinimum, h1, NULL);
2588 XtPointer client_data,
2589 XtPointer call_data)
2592 std::string elementField;
2594 SoCamera * cam = This->getCamera();
2596 if (This->SoXtExaminerViewer::isAnimating())
2597 This->stopAnimating();
2599 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
2601 value = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
2602 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
2609 This->scheduleRedraw();
2615 elementField = value;
2617 int idx = elementField.find_last_of(
"[");
2619 idx = elementField.size();
2625 SoSearchAction search;
2626 SoNode *root = This->getSceneManager()->getSceneGraph();
2627 int counter, idxUnderscore = elementField.find_last_of(
"_");
2629 This->
parseString<
int>(counter, elementField.substr(idxUnderscore + 1, idx),
error);
2631 SoBaseKit::setSearchingChildren(
TRUE);
2633 search.setSearchingAll(
TRUE);
2636 This->
curEltName = elementField.substr(0, idx);
2640 path = (SoFullPath *)search.getPath();
2643 This->
curEltName = elementField.substr(0, idxUnderscore);
2648 SoPathList &pl = search.getPaths();
2649 path = (SoFullPath *)pl[counter - 1];
2654 if ((idx > 0) && (path)) {
2658 SoGetBoundingBoxAction bAction(This->getViewportRegion());
2659 bAction.apply(path);
2660 SbBox3f bBox = bAction.getBoundingBox();
2661 SbVec3f elementCoord = bBox.getCenter();
2666 float absLengthNow, absLengthMin;
2672 absLengthMin = (p - elementCoord).length();
2678 absLengthNow = (p - elementCoord).length();
2680 if (absLengthNow < absLengthMin) {
2681 absLengthMin = absLengthNow;
2694 This->
distance = (pN - p1).length() / 10;
2697 if (cam->isOfType(SoOrthographicCamera::getClassTypeId()))
2698 ((SoOrthographicCamera *) cam)->height.setValue(This->
defaultHeight);
2700 else if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2701 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
2704 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2705 This->
distance = (This->
prevPt - cam->position.getValue()).length();
2711 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
2714 This->scheduleRedraw();
2727 cam->viewAll(path, This->getViewportRegion());
2738 XtPointer client_data,
2785 std::stringstream out;
2788 fileOut.seekp(0, std::ios::beg);
2796 fileOut.seekp(0, std::ios::end);
2814 SoCamera * camera = getCamera();
2815 if (camera == NULL) {
2816 String dialogName = (
char *)
"Missing Camera Node";
2817 std::string msg =
"Camera is null. Unable to set the viewpoint.";
2823 String dialogName = (
char *)
"Missing Viewpoints";
2824 std::string msg =
"There are no viewpoints to load.";
2829 if (SoXtExaminerViewer::isAnimating())
2836 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
2854 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
2857 camera = getCamera();
2858 ((SoOrthographicCamera *) camera)->height.setValue(
2861 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
2863 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
2866 camera = getCamera();
2867 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
2870 ((SoOrthographicCamera *) camera)->height.setValue(
2873 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::setViewPt",
2874 "Only Perspective and Orthographic cameras are supported.");
2884 XtPointer client_data,
2897 Widget nameViewPtDialog;
2898 Widget parent = This->getParentWidget();
2899 XmString label = XmStringCreateLocalized((
char *)
"Name the viewpoint:");
2901 XtSetArg(args[n], XmNselectionLabelString, label); n++;
2902 XtSetArg(args[n], XmNautoUnmanage, False); n++;
2906 nameViewPtDialog = XmCreatePromptDialog(parent, (
char *)
"Save Viewpoint",
2909 XmStringFree(label);
2910 XtAddCallback(nameViewPtDialog, XmNokCallback,
getViewPtNameCB, This);
2911 XtAddCallback(nameViewPtDialog, XmNcancelCallback,
2912 (XtCallbackProc) XtDestroyWidget, NULL);
2914 Widget text = XtNameToWidget(nameViewPtDialog,
"Text");
2915 XtVaSetValues(text, XmNmaxLength, This->
MAX_VP_NAME, NULL);
2916 std::string autoName =
"";
2921 XmTextSetString(text, (
char *) autoName.c_str());
2922 XmTextSetInsertionPosition(text, autoName.length());
2924 XtUnmanageChild(XtNameToWidget(nameViewPtDialog,
"Help"));
2925 XtManageChild(nameViewPtDialog);
2932 std::stringstream sstream;
2933 std::vector<int> existingViewPts;
2937 for (
unsigned int i = 0; i < this->
viewPtList.size(); ++i) {
2939 if (viewPt.find(
"viewpoint_") != std::string::npos) {
2940 tmp = atoi(viewPt.substr(10).c_str());
2943 if (!viewPt.compare(
"viewpoint_0"))
2944 existingViewPts.push_back(0);
2946 existingViewPts.push_back(tmp);
2954 if (existingViewPts.size() > 0) {
2957 if (std::find(existingViewPts.begin(), existingViewPts.end(), vpNum)
2958 == existingViewPts.end()) {
2959 sstream <<
"viewpoint_" << vpNum;
2960 return sstream.str();
2965 return "viewpoint_0";
2972 XtPointer client_data,
2982 XtPointer client_data,
2989 if(This->isViewing())
2990 This->setViewing(
false);
2991 This->setComponentCursor(SoXtCursor(SoXtCursor::CROSSHAIR));
2999 XtPointer client_data,
3000 XtPointer call_data)
3003 std::string strName;
3005 XmSelectionBoxCallbackStruct *cbs =
3006 (XmSelectionBoxCallbackStruct *) call_data;
3007 XmStringGetLtoR(cbs->value, XmFONTLIST_DEFAULT_TAG, &name);
3020 int beg = strName.find_first_not_of(
' ');
3021 int end = strName.find_last_not_of(
' ');
3022 strName = strName.substr(beg, end - beg + 1);
3024 bool nameExists =
false;
3026 for (
int i = 0; i < size; i++) {
3027 if (!strcmp(This->
viewPtList[i].viewPtName, strName.c_str())) {
3035 name =
new char[nVPName];
3036 strncpy(name, strName.c_str(), nVPName);
3041 XmListAddItemUnselected(This->
myViewPtList, cbs->value, 0);
3046 String dialogName = (
char *)
"Existing Viewpoint";
3047 std::string msg =
"The viewpoint already exists.";
3060 float x, y,
z, angle;
3061 SoCamera * camera = getCamera();
3071 tmp.
position = camera->position.getValue();
3079 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
3080 tmp.
height = ((SoPerspectiveCamera *) camera)->heightAngle.getValue();
3082 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
3083 tmp.
height = ((SoOrthographicCamera *) camera)->height.getValue();
3086 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::saveViewPtCB",
3087 "Only Perspective and Orthographic cameras are supported.");
3094 std::string vpName =
name;
3099 fileOut << vpName << std::endl;
3101 fileOut << x <<
" " << y <<
" " << z << std::endl;
3105 axis.getValue(x, y, z);
3106 fileOut << x <<
" " << y <<
" " << z <<
" " << angle << std::endl;
3120 XtPointer client_data,
3137 std::ofstream out(
"temporaryFile.txt");
3143 XmString vpNameStr = XmStringCreateLocalized(vpName);
3146 XmStringFree(vpNameStr);
3150 out << line <<
"\n";
3152 while (getline(
fileIn, line)) {
3153 end = line.find_last_not_of(
' ');
3154 line = line.substr(0, end + 1);
3155 if (!strcmp(line.c_str(), vpName)) {
3156 while (line.size()) {
3160 while (getline(
fileIn, line))
3161 out << line <<
"\n";
3163 while (line.size()) {
3164 out << line <<
"\n";
3173 while (idx < size) {
3174 if (!strcmp(
viewPtList[idx].viewPtName, vpName)) {
3187 rename(
"temporaryFile.txt",
fileName.c_str());
3190 fileOut.seekp(0, std::ios::end);
3210 int idx = 0, end,
pos;
3212 std::string line, newName;
3221 while (getline(
fileIn, line)) {
3222 end = line.find_last_not_of(
' ');
3223 line = line.substr(0, end + 1);
3227 fileOut.seekp(0, std::ios::end);
3238 while (idx < size) {
3253 float x, y,
z, angle;
3254 int sortIdx = 0, unsortIdx = 0;
3263 int size = sortedViewPts.size();
3264 while (sortIdx < size) {
3265 while (strcmp(sortedViewPts[sortIdx].c_str(),
3269 std::string vpName =
viewPtList[unsortIdx].viewPtName;
3273 fileOut << vpName << std::endl;
3274 viewPtList[unsortIdx].position.getValue(x, y, z);
3275 fileOut << x <<
" " << y <<
" " << z << std::endl;
3278 viewPtList[unsortIdx].orientation.getValue(axis, angle);
3279 axis.getValue(x, y, z);
3280 fileOut << x <<
" " << y <<
" " << z <<
" " << angle << std::endl;
3283 <<
viewPtList[unsortIdx].height << std::endl;
3309 float x, y,
z, angle;
3316 while (getline(
fileIn, token)) {
3318 int end = token.find_last_not_of(
' ');
3319 token = token.substr(0, end + 1);
3321 char *vpName =
new char[token.size() + 1];
3322 strcpy(vpName, token.c_str());
3326 parseString<float>(x, token,
error);
3328 parseString<float>(y, token,
error);
3330 parseString<float>(
z, token,
error);
3332 tmp.
position = axis.setValue(x, y, z);
3334 parseString<float>(x, token,
error);
3336 parseString<float>(y, token,
error);
3338 parseString<float>(
z, token,
error);
3340 parseString<float>(angle, token,
error);
3342 orient.setValue(axis.setValue(x, y, z), angle);
3346 parseString<int>(camType, token,
error);
3383 std::istringstream str(s);
3384 if ((str >> t).fail())
3392 std::string dialogName,
3393 std::string buttonLabel,
3394 XtCallbackProc cbOK)
3398 Widget parent, scrollWidget;
3399 parent = SoXt::getShellWidget(getParentWidget());
3401 if (dialog == NULL) {
3404 XmString str = XmStringCreateLocalized((
char *) buttonLabel.c_str());
3407 XtSetArg(args[n], XmNokLabelString, str); n++;
3408 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3410 dialog = XmCreateFileSelectionDialog(parent,
3411 (
char *) dialogName.c_str(), args,
n);
3413 XtAddCallback(dialog, XmNokCallback, cbOK,
this);
3417 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_DIR_LIST);
3420 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_LIST);
3424 XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
3427 XtManageChild(dialog);
3444 XtPointer client_data,
3455 XtPointer client_data,
3456 XtPointer call_data)
3460 XmFileSelectionBoxCallbackStruct *cbs =
3461 (XmFileSelectionBoxCallbackStruct *) call_data;
3465 if (!(file = (
char *) XmStringUnparse(cbs->value,
3466 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3468 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::fileSelectedCB",
3469 "Internal error during file opening");
3474 if (!This->
fileIn.fail()) {
3478 String dialogName = (
char *)
"Error Loading File";
3479 std::string msg =
"Wrong or corrupted input file.";
3484 This->
fileOut.seekp(0, std::ios::end);
3491 std::string newDialogName = This->
fileName.substr(
3494 (
char *) newDialogName.c_str(), NULL);
3511 String dialogName = (
char *)
"Nonexistent File";
3512 std::string msg =
"Unable to open file.";
3532 viewPts = (XmString *) XtMalloc(size *
sizeof(XmString));
3533 for (
int i = 0; i < size; i++)
3534 viewPts[i] = XmStringCreateLocalized(
viewPtList[i].viewPtName);
3536 XmListAddItemsUnselected(
myViewPtList, viewPts, size, 1);
3538 if (viewPts != NULL) {
3539 for (
int i = 0; i < size; i++)
3540 XmStringFree(viewPts[i]);
3541 XtFree((
char *) viewPts);
3571 XmString warningMsg;
3573 warningMsg = XmStringCreateLocalized((
char *)msg.c_str());
3576 XtSetArg(args[n], XmNmessageString, warningMsg); n++;
3577 Widget warningDialog = XmCreateWarningDialog(getParentWidget(), dialogName, args, n);
3579 XtAddCallback(warningDialog, XmNokCallback, cb,
this);
3581 XmStringFree(warningMsg);
3583 XtVaSetValues (warningDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
3584 XtUnmanageChild(XtNameToWidget(warningDialog,
"Help"));
3585 XtUnmanageChild(XtNameToWidget(warningDialog,
"Cancel"));
3587 XtManageChild(warningDialog);
3592 XtPointer client_data,
3603 XtPointer client_data,
3604 XtPointer call_data)
3609 XmFileSelectionBoxCallbackStruct *cbs =
3610 (XmFileSelectionBoxCallbackStruct *) call_data;
3614 if (!(file = (
char *) XmStringUnparse(cbs->value,
3615 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3617 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::createNewVPFileCB",
3618 "Internal error during file opening");
3625 if (This->
fileIn.fail()) {
3639 String dialogName = (
char *)
"Existing File";
3640 std::string msg =
"'" + fName +
"' already exists. Do you want to overwrite it?";
3651 XtPointer client_data,
3671 XtPointer client_data,
3682 XtPointer client_data,
3683 XtPointer call_data)
3687 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
3692 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3693 XmCHARSET_TEXT, XmCHARSET_TEXT,
3694 NULL, 0, XmOUTPUT_ALL);
3696 std::ifstream ifs(file);
3700 while(ifs >> x >> y >> z){
3707 String dialogName = (
char *)
"Problem reading file";
3708 std::string msg =
"Problem reading file";
3720 XtPointer client_data,
3726 String dialogName = (
char *)
"No Reference Trajectory";
3727 std::string msg =
"You need to start a run or load a reference trajectory from a file";
3734 Widget parent, scrollWidget;
3735 parent = SoXt::getShellWidget(This->getParentWidget());
3740 XmString str = XmStringCreateLocalized((
char *)
"Save");
3743 XtSetArg(args[n], XmNokLabelString, str); n++;
3744 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3746 This->
saveRefCoordsDialog = XmCreateFileSelectionDialog(parent,(
char *)
"Save Ref Coords", args, n);
3771 XtPointer client_data,
3772 XtPointer call_data)
3776 XmFileSelectionBoxCallbackStruct *cbs =
3777 (XmFileSelectionBoxCallbackStruct *) call_data;
3782 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3783 XmCHARSET_TEXT, XmCHARSET_TEXT,
3784 NULL, 0, XmOUTPUT_ALL);
3786 std::ifstream ifile(file);
3791 Widget parent = This->getParentWidget();
3792 Widget confirmOverwriteDialog;
3795 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite", args, 0);
3796 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
3797 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
3802 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
3812 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
3813 XtManageChild(confirmOverwriteDialog);
3819 std::ofstream ofs(file);
3824 ofs << x <<
" " << y <<
" " << z <<
"\n";
3830 String dialogName = (
char *)
"Error opening file";
3831 std::string msg =
"There was a problem trying to open the file '";
3845 XtPointer client_data,
3846 XtPointer call_data)
3848 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
3851 switch (cbs->reason) {
3861 ofs << x <<
" " << y <<
" " << z <<
"\n";
3868 String dialogName = (
char *)
"Error opening file";
3869 std::string msg =
"There was a problem trying to open the file '";
3883 XmProcessTraversal(XtNameToWidget(This->
saveRefCoordsWidget,
"Text"), XmTRAVERSE_CURRENT);
3897 XtPointer client_data,
3909 XtPointer client_data,
3910 XtPointer call_data)
3914 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
3918 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3919 XmCHARSET_TEXT, XmCHARSET_TEXT,
3920 NULL, 0, XmOUTPUT_ALL);
3923 if (!sceneInput.openFile(file)) {
3924 String dialogName = (
char *)
"Problem opening file";
3925 std::string msg =
"Cannot open file ";
3929 sceneInput.closeFile();
3935 String dialogName = (
char *)
"Problem reading file";
3936 std::string msg =
"Problem reading file";
3950 XtPointer client_data,
3957 Widget parent, scrollWidget;
3958 parent = SoXt::getShellWidget(This->getParentWidget());
3963 XmString str = XmStringCreateLocalized((
char *)
"Save");
3966 XtSetArg(args[n], XmNokLabelString, str); n++;
3967 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3969 This->
saveSceneGraphDialog = XmCreateFileSelectionDialog(parent,(
char *)
"Save Scene Graph", args, n);
3995 XtPointer client_data,
3996 XtPointer call_data)
4000 XmFileSelectionBoxCallbackStruct *cbs =
4001 (XmFileSelectionBoxCallbackStruct *) call_data;
4005 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4006 XmCHARSET_TEXT, XmCHARSET_TEXT,
4007 NULL, 0, XmOUTPUT_ALL);
4009 std::ifstream ifile(file);
4014 Widget parent = This->getParentWidget();
4015 Widget confirmOverwriteDialog;
4018 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite", args, 0);
4019 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
4020 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
4025 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
4035 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
4036 XtManageChild(confirmOverwriteDialog);
4042 SoWriteAction writeAction;
4043 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4045 SoOutput * out = writeAction.getOutput();
4047 if(out->openFile(file)){
4048 out->setBinary(
FALSE);
4049 writeAction.apply(root);
4055 String dialogName = (
char *)
"Error opening file";
4056 std::string msg =
"There was a problem trying to open the file '";
4072 XtPointer client_data,
4073 XtPointer call_data)
4075 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
4078 switch (cbs->reason) {
4083 SoWriteAction writeAction;
4084 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4086 SoOutput * out = writeAction.getOutput();
4088 out->setBinary(
FALSE);
4089 writeAction.apply(root);
4098 String dialogName = (
char *)
"Error opening file";
4099 std::string msg =
"There was a problem trying to open the file '";
4131 XtPointer client_data,
4132 XtPointer call_data)
4136 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
4138 vpName = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
4139 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4141 for (
int i = 0; i < (int) This->
viewPtList.size(); i++) {
4142 if (!strcmp(This->
viewPtList[i].viewPtName, vpName)) {
4157 XtPointer client_data,
4165 XmString vpNameStr = XmStringCreateLocalized(vpName);
4172 XmStringFree(vpNameStr);
4179 XtPointer client_data,
4182 std::string vpNameStr;
4184 int *pos_list, pos_cnt;
4189 if (!strlen(vpName) || !strcmp(This->
curViewPtName, vpName)) {
4196 int beg = vpNameStr.find_first_not_of(
' ');
4197 int end = vpNameStr.find_last_not_of(
' ');
4198 vpNameStr = vpNameStr.substr(beg, end - beg + 1);
4199 const int nVPName = vpNameStr.size() + 1;
4200 vpName =
new char[nVPName];
4201 strncpy(vpName, vpNameStr.c_str(), nVPName);
4204 for (
int i = 0; i < size; i++) {
4205 if (!strcmp(vpName, This->
viewPtList[i].viewPtName)) {
4207 String dialogName = (
char *)
"Existing Viewpoint";
4208 std::string msg =
"'";
4210 msg +=
"' already exists. Choose a different name";
4217 XmString vpNameXmStr = XmStringCreateLocalized(vpName);
4219 if (XmListGetSelectedPos(This->
myViewPtList, &pos_list, &pos_cnt)) {
4220 XmListReplaceItemsPos(This->
myViewPtList, &vpNameXmStr, 1, pos_list[0]);
4222 XtFree((
char *) pos_list);
4226 This->scheduleRedraw();
4228 XmStringFree(vpNameXmStr);
4233 XtPointer client_data,
4238 XmString *strList, *newStrList;
4239 std::vector<std::string> charList;
4246 XtVaGetValues(This->
myViewPtList, XmNitemCount, &size, XmNitems, &strList,
4249 for (
int i = 0; i < size; i++) {
4250 vpName = (
char *) XmStringUnparse(strList[i], XmFONTLIST_DEFAULT_TAG,
4251 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4252 charList.push_back(vpName);
4256 std::sort(charList.begin(), charList.end());
4258 newStrList = (XmString *) XtMalloc(size *
sizeof(XmString));
4259 for (
int i = 0; i < size; i++) {
4263 const int nVPName = charList[i].size() + 1;
4264 char *vpName2 =
new char[nVPName];
4265 strncpy(vpName2, charList[i].c_str(), nVPName);
4266 newStrList[i] = XmStringCreateLocalized(vpName2);
4271 XmListAddItemsUnselected(This->
myViewPtList, newStrList, size, 1);
4275 if (newStrList != NULL) {
4276 for (
int i = 0; i < size; i++)
4277 XmStringFree(newStrList[i]);
4278 XtFree((
char *) newStrList);
4288 SbVec3f p1, p2, p3, dirNow, dirNxt, dir, p2_tmp, p_start, p_corner, p_nxt;
4289 float avgDistBtwPts = 0;
4290 float totalDistBtwPts = 0;
4291 std::vector<SbVec3f> newRefParticleTrajectory;
4295 for (
int i = 0; i < size; i++) {
4301 totalDistBtwPts += (p2 - p1).length();
4304 avgDistBtwPts = totalDistBtwPts / numOfPts;
4305 float minDistAllowed = 0.75 * avgDistBtwPts;
4315 p1.getValue(x, y, z);
4317 newRefParticleTrajectory.push_back(refPoint);
4320 while ((p2 - p1).length() < minDistAllowed && j < (size - 1)) {
4340 XtPointer client_data,
4359 SoCamera *cam = getCamera();
4368 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4370 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
4372 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4374 ((SoOrthographicCamera *) cam)->height.getValue();
4382 SoCamera *cam = getCamera();
4392 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4396 ((SoOrthographicCamera *) cam)->height.setValue(
4399 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4401 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4405 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4408 ((SoOrthographicCamera *) cam)->height.setValue(
4417 SbTime curTime = SbTime::getTimeOfDay();
4419 SoTimerSensor *
s = (SoTimerSensor *) sensor;
4421 float t = float((curTime - s->getBaseTime()).getValue())
4424 if ((t > 1.0f) || (t + s->getInterval().getValue() > 1.0f))
4426 SbBool end = (t == 1.0f);
4449 SbTime curTime = SbTime::getTimeOfDay();
4451 SoCamera *cam = This->getCamera();
4452 SoTimerSensor *
s = (SoTimerSensor *) sensor;
4454 float t = float((curTime - s->getBaseTime()).getValue())
4457 if ((t > 1.0f) || (t + s->getInterval().getValue() > 1.0f))
4459 SbBool end = (t == 1.0f);
4489 if (SoXtExaminerViewer::isAnimating())
4493 SbVec3f p1, p2, p2_tmp, camUpV, camD, camD_tmp, leftRightAxis;
4494 float x1, y1, z1, x2, y2, z2;
4511 p1.getValue(x1, y1, z1);
4512 p2.getValue(x2, y2, z2);
4517 p2_tmp.setValue(x2, y1, z2);
4518 camD_tmp = p2_tmp - p1;
4519 camD_tmp.normalize();
4521 camUpV.setValue(0, 1, 0);
4522 rot.setValue(camD_tmp, camD);
4523 rot.multVec(camUpV, camUpV);
4525 leftRightAxis = camD.cross(camUpV);
4527 myCam->position = p1;
4528 myCam->pointAt(p2, camUpV);
4532 myCam->position = p1;
4544 XtPointer client_data,
4550 String dialogName = (
char *)
"No Reference Trajectory";
4551 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4564 This->scheduleRedraw();
4571 if (This->SoXtExaminerViewer::isAnimating())
4572 This->stopAnimating();
4581 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
4584 This->scheduleRedraw();
4596 This->
distance = (pN - p1).length() / 10;
4603 XtPointer client_data,
4622 XtPointer client_data,
4629 String dialogName = (
char *)
"No Reference Trajectory";
4630 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4641 This->
axisSwitch->whichChild.setValue(SO_SWITCH_ALL);
4644 This->scheduleRedraw();
4647 SoCamera *cam = This->getCamera();
4660 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4661 This->toggleCameraType();
4662 cam = This->getCamera();
4670 cam->focalDistance = 0.1f;
4671 ((SoPerspectiveCamera *) cam)->heightAngle = 0.50f;
4678 cam->orientation = (This->
myCam)->orientation.getValue();
4685 SoCamera *cam = getCamera();
4707 void (*callback)(
void *),
void *
object)
SbRotation camStartOrient
#define SPEED_INDICATOR_STEP
void animateRefParticle()
static G4OpenInventorXtExaminerViewer * getObject()
static void loadSceneGraphDialogCB(Widget, XtPointer, XtPointer)
void updateSpeedIndicator(void)
static void constructListsDialog(Widget, XtPointer, XtPointer)
SoText2 * mouseOverTextLogName
static void saveRefCoordsOverWriteCB(Widget, XtPointer, XtPointer)
void renameViewPt(char *vpName)
static void loadBookmarkCB(Widget, XtPointer, XtPointer)
static void saveViewPtCB(Widget, XtPointer, XtPointer)
SoFont * mouseOverFontSolid
~G4OpenInventorXtExaminerViewer()
CLHEP::Hep3Vector G4ThreeVector
Widget saveRefCoordsDialog
Widget loadRefCoordsDialog
std::string viewPtAutoName()
G4OpenInventorXtExaminerViewer * viewer
void setStartingPtForAnimation()
void setReferencePath(SoLineSet *, SoCoordinate3 *, bool append=false)
friend class HookEventProcState
SoTranslation * mouseOverTransZPos
std::vector< SbVec3f > refParticleTrajectory
void evenOutRefParticlePts()
static void sortBookmarksCB(Widget, XtPointer, XtPointer)
SoNodeSensor * sceneChangeSensor
SoText2 * mouseOverTextMaterial
void setReferencePathZPos()
static void pickRefPathCB(Widget, XtPointer, XtPointer)
SoText2 * mouseOverTextSolid
SoSwitch * animSpeedOutlineSwitch
const std::vector< const std::vector< G4AttValue > * > & GetAttValues() const
static void saveSceneGraphOverWriteCB(Widget, XtPointer, XtPointer)
bool viewingBeforePickRef
std::string saveScenegraphFileName
static void lookAtSceneElementCB(Widget, XtPointer, XtPointer)
Widget addMenu(std::string name)
static void overwriteFileCB(Widget, XtPointer, XtPointer)
static void closeListsDialogCB(Widget, XtPointer, XtPointer)
std::vector< float > refZPositions
void parseString(T &t, const std::string &s, bool &error)
SoTranslation * mouseOverTransMaterial
void cleanUpAfterPrevFile()
SoNode * getSuperimpositionNode(SoNode *, const char *name)
static void mouseoverCB(void *aThis, SoEventCallback *eventCB)
void(* escapeCallback)(void *)
static void sceneChangeCB(void *, SoSensor *)
static G4OpenInventorXtExaminerViewer * viewer
void moveCamera(float dist=0, bool lookdown=false)
virtual void actualRedraw(void)
static void prevViewPtCB(Widget, XtPointer, XtPointer)
void createElementsList(Widget)
virtual G4bool Notify(G4ApplicationState requiredState)
SoCoordinate3 * getCoordsNode(SoFullPath *path)
G4OpenInventorXtExaminerViewer(Widget parent=NULL, const char *name=NULL, SbBool embed=TRUE, SoXtFullViewer::BuildFlag flag=BUILD_ALL, SoXtViewer::Type type=BROWSER)
static void animateSensorRotationCB(void *, SoSensor *)
static void invertRefPathCB(Widget, XtPointer, XtPointer)
static void abbrOutputCB(Widget, XtPointer, XtPointer)
static void saveSceneGraphDialogCB(Widget, XtPointer, XtPointer)
SoFont * mouseOverFontLogName
void saveViewPt(char *name)
SoTranslation * curInfoTrans
G4GLOB_DLL std::ostream G4cout
static void createNewVPFileCB(Widget, XtPointer, XtPointer)
float distanceToBeamlineStart
std::vector< viewPtData > viewPtList
void warningMsgDialog(std::string, String, XtCallbackProc)
static void saveSceneGraphCB(Widget, XtPointer, XtPointer)
static void superimpositionCB(void *closure, SoAction *action)
static void closeMainWindowCB(Widget, XtPointer, XtPointer)
static void gotoRefPathStartCB(Widget, XtPointer, XtPointer)
static void renameBookmarkCB(Widget, XtPointer, XtPointer)
HookEventProcState * hookBeamOn
SoCoordinate3 * sgeometry
static void animateRefParticleCB(Widget, XtPointer, XtPointer)
float sqrlen(const SbVec3f &)
void distanceToTrajectory(const SbVec3f &, float &, SbVec3f &, int &)
HookEventProcState(G4OpenInventorXtExaminerViewer *)
SoSearchAction * searcher
SoTimerSensor * animateSensor
static void saveRefCoordsDialogCB(Widget, XtPointer, XtPointer)
void popUpFileSelDialog(Widget &, std::string, std::string, XtCallbackProc)
void addButton(Widget menu, std::string name, XtCallbackProc)
static void viewPtFileSelectedCB(Widget, XtPointer, XtPointer)
static void cancelFileSelDialogCB(Widget, XtPointer, XtPointer)
static void newViewPtFileCB(Widget, XtPointer, XtPointer)
viewPtData camB4Animation
SoFont * mouseOverFontZPos
SoFont * mouseOverFontMaterial
static void deleteViewPtCB(Widget, XtPointer, XtPointer)
void xmAddMouseEventHandler(Widget w)
SoSwitch * animSpeedSwitch
SoTimerSensor * animateSensorRotation
static void animateSensorCB(void *, SoSensor *)
static const char * thisClassName
static void nextViewPtCB(Widget, XtPointer, XtPointer)
void constructor(const SbBool build)
Widget buildWidget(Widget parent)
SoTranslation * stranslation
void superimpositionEvent(SoAction *action)
static void deleteBookmarkCB(Widget, XtPointer, XtPointer)
std::vector< sceneElement > sceneElements
double animateBtwPtsPeriod
SoText2 * mouseOverTextZPos
static void getViewPtNameCB(Widget, XtPointer, XtPointer)
static void openViewPtFileCB(Widget, XtPointer, XtPointer)
static PROLOG_HANDLER error
static void pickingCB(void *aThis, SoEventCallback *eventCB)
virtual SbBool processSoEvent(const SoEvent *const event)
Widget saveSceneGraphDialog
static void loadRefCoordsCB(Widget, XtPointer, XtPointer)
SoSeparator * newSceneGraph
virtual void afterRealizeHook()
void deleteViewPt(char *vpName=NULL)
SoTranslation * mouseOverTransSolid
void sortViewPts(std::vector< std::string >)
static void loadSceneGraphCB(Widget, XtPointer, XtPointer)
static void saveRefCoordsCB(Widget, XtPointer, XtPointer)
#define MAX_SPEED_INDICATOR
void addEscapeCallback(void(*cb)(void *), void *)
Widget saveRefCoordsWidget
static const G4double pos
const std::vector< const std::map< G4String, G4AttDef > * > & GetAttDefs() const
std::string saveRefCoordsFileName
SoTranslation * mouseOverTransLogName
Widget saveScenegraphWidget
static void loadRefCoordsDialogCB(Widget, XtPointer, XtPointer)
virtual void createViewerButtons(Widget parent, SbPList *buttonlist)
Widget loadSceneGraphDialog