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>
72 #include <Inventor/nodes/SoLineSet.h>
73 #include <Inventor/nodes/SoMaterial.h>
74 #include <Inventor/errors/SoDebugError.h>
75 #include <Inventor/SoPickedPoint.h>
76 #include <Inventor/actions/SoWriteAction.h>
81 #include <Inventor/sensors/SoTimerSensor.h>
82 #include <Inventor/sensors/SoNodeSensor.h>
97 #include <Inventor/nodes/SoCallback.h>
98 #include <Inventor/nodes/SoSwitch.h>
99 #include <Inventor/nodes/SoScale.h>
100 #include <Inventor/nodes/SoTranslation.h>
101 #include <Inventor/actions/SoSearchAction.h>
102 #include <Inventor/actions/SoGetBoundingBoxAction.h>
104 #include <Inventor/nodes/SoCoordinate3.h>
106 #include <Inventor/nodes/SoText2.h>
107 #include <Inventor/nodes/SoFont.h>
108 #include <Inventor/nodes/SoPointSet.h>
109 #include <Inventor/nodes/SoDrawStyle.h>
110 #include <Inventor/nodes/SoBaseColor.h>
113 #include <Inventor/nodekits/SoBaseKit.h>
116 #include <Inventor/SbVec3f.h>
122 #define MIN_SPEED 2.1 // Lower number means faster
123 #define START_STEP 0.3
124 #define SPEED_INDICATOR_STEP 0.045
125 #define MAX_SPEED_INDICATOR 0.81
131 const char *
name, SbBool embed,
132 SoXtFullViewer::BuildFlag flag, SoXtViewer::Type type) :
133 SoXtExaminerViewer(parent, name, embed, flag, type,
FALSE)
141 const char *
name, SbBool embed,
142 SoXtFullViewer::BuildFlag flag, SoXtViewer::Type type,
144 SoXtExaminerViewer(parent, name, embed, flag, type,
FALSE)
165 myCam =
new SoPerspectiveCamera;
201 static const char * superimposed[] = {
202 "#Inventor V2.1 ascii",
"",
209 " OrthographicCamera ",
215 " DEF soxt->callback Callback { }",
218 " DEF soxt->translation Translation ",
220 " translation 0 0 0",
222 " DEF soxt->scale Scale ",
224 " scaleFactor 1 1 1",
226 " DEF soxt->geometry Coordinate3 ",
230 " -0.81 -0.04 0, -0.81 0 0,",
231 " -0.81 0.04 0, 0 -0.04 0,",
233 " 0.81 -0.04 0, 0.81 0 0,",
236 " 0.81 0.02 0, 0.81 -0.02 0,",
239 " 0.4 0.01 0, 0.4 -0.01 0,",
244 " DEF soxt->animSpeedOutlineSwitch Switch ",
249 " emissiveColor 0 0 0",
255 " 12, 11, 10, 9, -1",
260 " DEF soxt->axisSwitch Switch ",
279 " DEF soxt->animSpeedSwitch Switch ",
284 " emissiveColor 0 1 0",
290 " 16, 15, 14, 13, -1",
296 " DEF soxt->curInfoSwitch Switch ",
299 " DEF soxt->curInfoTrans Translation ",
301 " translation 10 20 30 ",
303 " DEF soxt->curInfoFont Font ",
305 " name defaultFont:Bold",
308 " DEF soxt->curInfoText Text2 ",
317 " DEF soxt->mouseOverTransLogName Translation ",
319 " translation 0 0 0 ",
321 " DEF soxt->mouseOverFontLogName Font ",
323 " name defaultFont:Bold",
326 " DEF soxt->mouseOverTextLogName Text2 { } ",
330 " DEF soxt->mouseOverTransSolid Translation ",
332 " translation 0 0 0 ",
334 " DEF soxt->mouseOverFontSolid Font ",
336 " name defaultFont:Bold",
339 " DEF soxt->mouseOverTextSolid Text2 { } ",
343 " DEF soxt->mouseOverTransMaterial Translation ",
345 " translation 0 0 0 ",
347 " DEF soxt->mouseOverFontMaterial Font ",
349 " name defaultFont:Bold",
352 " DEF soxt->mouseOverTextMaterial Text2 { } ",
356 " DEF soxt->mouseOverTransZPos Translation ",
358 " translation 0 0 0 ",
360 " DEF soxt->mouseOverFontZPos Font ",
362 " name defaultFont:Bold",
365 " DEF soxt->mouseOverTextZPos Text2 { } ",
371 for (i = bufsize = 0; superimposed[i]; i++)
372 bufsize += strlen(superimposed[i]) + 1;
373 char * buf =
new char[bufsize + 1];
374 for (i = bufsize = 0; superimposed[i]; i++) {
375 strcpy(buf + bufsize, superimposed[i]);
376 bufsize += strlen(superimposed[i]);
380 SoInput * input =
new SoInput;
381 input->setBuffer(buf, bufsize);
440 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
475 this->
searcher =
new SoSearchAction;
478 searcher->setInterest(SoSearchAction::FIRST);
482 return searcher->getPath()->getTail();
499 if (!action->isOfType(SoGLRenderAction::getClassTypeId()))
501 SbViewportRegion vpRegion =
502 ((SoGLRenderAction *) action)->getViewportRegion();
503 SbVec2s viewportSize = vpRegion.getViewportSizePixels();
505 float aspect = float(viewportSize[0]) / float(viewportSize[1]);
506 float factorx = 1.0f / float(viewportSize[1]) * 220.0f;
507 float factory = factorx;
513 SbVec3f(0.0
f, -0.4
f / aspect, 0.0
f));
517 if (viewportSize[0] > 500)
518 factorx *= 500.0f / 400.0f;
520 factorx *= float(viewportSize[0]) / 400.0f;
521 this->
sscale->scaleFactor.setValue(SbVec3f(factorx, factory, 1.0
f));
523 float xInfo, yInfo, xMouseLogName, yMouseLogName, xMouseSolid, yMouseSolid,
524 xMouseMaterial, yMouseMaterial, xMouseZPos, yMouseZPos;
528 yMouseLogName = -.75;
531 xMouseMaterial = 0.0;
532 yMouseMaterial = -.81;
538 xMouseSolid *= aspect;
539 xMouseMaterial *= aspect;
540 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
542 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
544 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
546 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
548 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
551 yMouseSolid /= aspect;
552 yMouseMaterial /= aspect;
553 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
555 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
557 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
559 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
561 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
566 this->
curInfoFont->name.setValue(
"defaultFont:Italic");
571 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
577 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
580 this->
curInfoText->string.setValue(SbString(zPos));
609 Atom WM_DELETE_WINDOW;
612 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::buildWidget",
"Error: Parent is null.");
615 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
616 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
617 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
618 XtSetArg(args[3], XmNbottomAttachment, XmATTACH_FORM);
619 Widget form = XmCreateForm(parent, (
char *)
"Form", args, 4);
622 shell = XtParent(form);
623 WM_DELETE_WINDOW = XInternAtom(XtDisplay(parent),
"WM_DELETE_WINDOW",
625 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW,
628 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
629 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
630 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
631 menuBar = XmCreateMenuBar(form, (
char *)
"MenuBar", args, 3);
642 XmCreateSeparatorGadget(
fileMenu, (
char *)
"Separator", NULL, 0));
644 Widget menu =
addMenu(
"Tools");
649 Widget viewerBase = SoXtFullViewer::buildWidget(form);
651 XtSetArg(args[0], XmNtopAttachment, XmATTACH_WIDGET);
652 XtSetArg(args[1], XmNtopWidget,
menuBar);
653 XtSetArg(args[2], XmNleftAttachment, XmATTACH_FORM);
654 XtSetArg(args[3], XmNrightAttachment, XmATTACH_FORM);
655 XtSetArg(args[4], XmNbottomAttachment, XmATTACH_FORM);
656 XtSetValues(viewerBase, args, 5);
666 Widget menu = XmCreatePulldownMenu(
menuBar, (
char *) name.c_str(), NULL, 0);
668 XtSetArg(args[0], XmNsubMenuId, menu);
669 Widget
w = XmCreateCascadeButton(
menuBar, (
char *) name.c_str(), args, 1);
680 Widget button = XmCreatePushButton(menu, (
char *) name.c_str(), NULL, 0);
681 XtManageChild(button);
682 XtAddCallback(button, XmNactivateCallback, cb,
this);
688 SbPList * buttonlist)
692 Widget saveViewPtButton, abbrOutputButton, pickRefPathButton;
693 Widget switchWireFrameButton;
696 SoXtExaminerViewer::createViewerButtons(parent, buttonlist);
699 Widget emptyButton = XtVaCreateManagedWidget(
"", xmPushButtonWidgetClass,
701 buttonlist->append(emptyButton);
705 XtSetArg(args[n], XmNtopPosition, 1); n++;
706 XtSetArg(args[n], XmNbottomPosition, 2); n++;
707 XtSetArg(args[n], XmNleftPosition, 0); n++;
708 XtSetArg(args[n], XmNrightPosition, 1); n++;
709 XtSetArg(args[n], XmNarrowDirection, XmARROW_LEFT); n++;
710 XtSetArg(args[n], XmNsensitive, False); n++;
720 XtSetArg(args[n], XmNtopPosition, 1); n++;
721 XtSetArg(args[n], XmNbottomPosition, 2); n++;
722 XtSetArg(args[n], XmNleftPosition, 0); n++;
723 XtSetArg(args[n], XmNrightPosition, 1); n++;
724 XtSetArg(args[n], XmNarrowDirection, XmARROW_RIGHT); n++;
725 XtSetArg(args[n], XmNsensitive, False); n++;
734 saveViewPtButton = XtVaCreateManagedWidget(
"Save", xmPushButtonWidgetClass,
736 XtAddCallback(saveViewPtButton, XmNactivateCallback,
738 Pixmap saveVP, saveVP_ins;
743 XtVaSetValues(saveViewPtButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
744 saveVP, XmNselectPixmap, saveVP, XmNlabelInsensitivePixmap,
745 saveVP_ins, XmNselectInsensitivePixmap, saveVP_ins, NULL);
746 buttonlist->append(saveViewPtButton);
749 abbrOutputButton = XtVaCreateManagedWidget(
"Abbr",
750 xmToggleButtonWidgetClass, parent, XmNindicatorOn, False, NULL);
753 Pixmap pickextxpm, pickextxpm_ins;
758 XtVaSetValues(abbrOutputButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
759 pickextxpm, XmNselectPixmap, pickextxpm, XmNlabelInsensitivePixmap,
760 pickextxpm_ins, XmNselectInsensitivePixmap, pickextxpm_ins, NULL);
769 buttonlist->append(abbrOutputButton);
772 pickRefPathButton = XtVaCreateManagedWidget(
"Refpath", xmPushButtonWidgetClass,
774 XtAddCallback(pickRefPathButton, XmNactivateCallback,
776 Pixmap pickrefxpm, pickrefxpm_ins;
781 XtVaSetValues(pickRefPathButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
782 pickrefxpm, XmNselectPixmap, pickrefxpm, XmNlabelInsensitivePixmap,
783 pickrefxpm_ins, XmNselectInsensitivePixmap, pickrefxpm_ins, NULL);
785 buttonlist->append(pickRefPathButton);
788 switchWireFrameButton = XtVaCreateManagedWidget(
"Wireframe",
789 xmToggleButtonWidgetClass, parent, XmNindicatorOn, False, NULL);
790 XtAddCallback(switchWireFrameButton, XmNvalueChangedCallback,
792 Pixmap wireframe, wireframe_ins;
797 XtVaSetValues(switchWireFrameButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
798 wireframe, XmNselectPixmap, wireframe, XmNlabelInsensitivePixmap,
799 wireframe_ins, XmNselectInsensitivePixmap, wireframe_ins, NULL);
800 buttonlist->append(switchWireFrameButton);
808 SoXtExaminerViewer::afterRealizeHook();
812 SoCamera *cam = getCamera();
814 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
816 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
819 ((SoOrthographicCamera *) cam)->height.getValue();
823 ((SoOrthographicCamera *) cam)->height.getValue();
826 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
828 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
837 String dialogName = (
char *)
"Error Loading File";
838 std::string msg =
"Wrong or corrupted input file.";
843 fileOut.seekp(0, std::ios::end);
862 SoSeparator *root = (SoSeparator *) (getSceneManager()->getSceneGraph());
864 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::afterRealizeHook",
"Root is null.");
866 root->addChild(
myCam);
878 SoEventCallback *moCB =
new SoEventCallback;
879 moCB->addEventCallback(
880 SoLocation2Event::getClassTypeId(),
882 root->addChild(moCB);
886 SoEventCallback *pickCB =
new SoEventCallback;
887 pickCB->addEventCallback(
888 SoMouseButtonEvent::getClassTypeId(),
890 root->addChild(pickCB);
899 SoCamera *cam = getCamera();
906 cam->position = camPosNew;
908 cam->focalDistance = (
prevPt - camPosNew).length();
927 SoCamera *cam = getCamera();
940 cam->focalDistance = (cam->position.getValue() -
center).length();
949 dist = (
prevPt - cam->position.getValue()).length();
956 dist = (
prevPt - cam->position.getValue()).length();
965 particleDir = p2 - p1;
966 particleDir.normalize();
979 SbRotation rot(SbVec3f(0,0,1), particleDir);
993 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1013 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1016 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
1018 camPosNew = p2 - (
camDir*cam->focalDistance.getValue());
1022 cam->position = camPosNew;
1024 cam->focalDistance = (p2 - camPosNew).length();
1027 camPosNew.getValue(x,y,z);
1038 SoEventCallback *eventCB)
1040 SoHandleEventAction* action = eventCB->getAction();
1041 const SoPickedPoint *
pp = action->getPickedPoint();
1046 SoPath* path = pp->getPath();
1047 SoNode* node = ((SoFullPath*)path)->getTail();
1049 if(node->getTypeId() == SoLineSet::getClassTypeId()){
1059 SoLineSet * trajectory = (SoLineSet *)node;
1065 SoSeparator * grpNode =
1066 (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
1071 int nodeIndex = grpNode->findChild(trajectory);
1074 SoCoordinate3 * coords = 0;
1078 for(
int i = 0; i < 100; ++i) {
1081 tmpNode = grpNode->getChild(nodeIndex);
1082 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
1084 coords = (SoCoordinate3 *)tmpNode;
1090 String dialogName = (
char *)
"No coordinates";
1091 std::string msg =
"Could not find the coordinates node"
1092 " for the picked trajectory."
1093 " Reference trajectory not set";
1110 if(attHolder && attHolder->
GetAttDefs().size()) {
1112 std::string strTrajPoint =
"G4TrajectoryPoint:";
1113 std::ostringstream oss;
1114 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1119 if(oss.str().find(strTrajPoint) != std::string::npos) {
1134 G4String cls((
char*)node->getTypeId().getName().getString());
1135 G4cout <<
"SoNode : " << node
1136 <<
" SoType : " << cls
1137 <<
" name : " <<
name
1154 if(attHolder && attHolder->
GetAttDefs().size()) {
1155 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1161 G4String cls((
char*)node->getTypeId().getName().getString());
1162 G4cout <<
"SoNode : " << node
1163 <<
" SoType : " << cls
1164 <<
" name : " <<
name
1170 eventCB->setHandled();
1177 SoHandleEventAction* action = eventCB->getAction();
1178 const SoPickedPoint*
pp = action->getPickedPoint();
1186 const SbViewportRegion & viewportRegion = action->getViewportRegion();
1188 std::string sLogName;
1190 std::stringstream ssZPos;
1191 std::stringstream ssSolids;
1192 std::stringstream ssMaterials;
1193 SoPath * path = pp->getPath();
1194 SoNode* node = ((SoFullPath*)path)->getTail();
1196 if(node->getTypeId() == Geant4_SoPolyhedron::getClassTypeId()) {
1198 sLogName =
"Logical Volume: ";
1201 SoGetBoundingBoxAction bAction(viewportRegion);
1202 bAction.apply((SoFullPath*)path);
1203 SbBox3f bBox = bAction.getBoundingBox();
1204 SbVec3f
center = bBox.getCenter();
1205 center.getValue(x,y,z);
1206 ssZPos <<
"Pos: " << x <<
" " << y <<
" " <<
z;
1209 if(attHolder && attHolder->
GetAttDefs().size()) {
1211 std::vector<const std::map<G4String,G4AttDef>*> vecDefs =
1213 std::vector<const std::vector<G4AttValue>*> vecVals =
1215 for (
size_t i = 0; i < vecDefs.size(); ++i) {
1216 const std::vector<G4AttValue> * vals = vecVals[i];
1218 std::vector<G4AttValue>::const_iterator iValue;
1220 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1221 const G4String& valueName = iValue->GetName();
1224 if(valueName ==
"Solid") {
1225 if(ssSolids.str() ==
"")
1226 ssSolids <<
"Solid Name: " << value;
1228 ssSolids <<
", " <<
value;
1231 if(valueName ==
"Material") {
1232 if(ssMaterials.str() ==
"")
1233 ssMaterials <<
"Material Name: " << value;
1235 ssMaterials <<
", " <<
value;
1242 else if(node->getTypeId() == SoLineSet::getClassTypeId()) {
1245 if(attHolder && attHolder->
GetAttDefs().size()) {
1246 std::string strTrajPoint =
"G4TrajectoryPoint:";
1247 std::ostringstream oss;
1249 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1252 const std::vector<G4AttValue>* vals = attHolder->
GetAttValues()[i];
1253 std::vector<G4AttValue>::const_iterator iValue;
1254 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1255 const G4String& valueName = iValue->GetName();
1260 if (valueName ==
"PN") t1 =
value;
1261 if (valueName ==
"Ch") {
1262 if (atof(value.c_str()) > 0)
1268 if (valueName ==
"PDG") {
1276 if (valueName ==
"EventID") t2 =
"Evt " +
value;
1277 if (valueName ==
"ID") t2 +=
" Trk " +
value;
1278 if (valueName ==
"PID") {
1279 t2 +=
" Prt " +
value;
1283 if (valueName ==
"IKE") t3 =
"KE " +
value;
1284 if (valueName ==
"IMom") {
1286 unsigned ipos = value.rfind(
" ");
1289 t3 +=
" P (" + value1 +
")";
1291 if (valueName ==
"IMag") {
1292 t3 +=
" " + value +
"/c";
1297 if (valueName ==
"NTP") {
1298 std::ostringstream t4oss;
1299 t4oss <<
"TrjPts " <<
value;
1300 t4oss <<
" Pos " << pp->getPoint()[0] <<
" " << pp->getPoint()[1] <<
1301 " " << pp->getPoint()[2];
1324 This->scheduleRedraw();
1325 eventCB->setHandled();
1329 bool redraw =
false;
1334 if(std::string(This->
mouseOverTextSolid->string.getValues(0)->getString()) != ssSolids.str()) {
1338 if(std::string(This->
mouseOverTextMaterial->string.getValues(0)->getString()) != ssMaterials.str()){
1342 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) != ssZPos.str()) {
1349 This->scheduleRedraw();
1352 eventCB->setHandled();
1357 This->scheduleRedraw();
1361 This->scheduleRedraw();
1365 This->scheduleRedraw();
1367 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) !=
"") {
1369 This->scheduleRedraw();
1376 SoCamera *cam = getCamera();
1377 const SoType type(ev->getTypeId());
1379 if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
1380 SoMouseButtonEvent * me = (SoMouseButtonEvent *) ev;
1384 switch (me->getButton()) {
1385 case SoMouseButtonEvent::BUTTON4:
1386 if (me->getState() == SoButtonEvent::DOWN) {
1387 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1389 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1390 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1393 }
else if (cam->isOfType(
1394 SoOrthographicCamera::getClassTypeId())) {
1396 ((SoOrthographicCamera *) cam)->height.getValue();
1397 ((SoOrthographicCamera *) cam)->height = height + 5;
1402 case SoMouseButtonEvent::BUTTON5:
1403 if (me->getState() == SoButtonEvent::DOWN) {
1404 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1406 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1408 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1411 }
else if (cam->isOfType(
1412 SoOrthographicCamera::getClassTypeId())) {
1414 ((SoOrthographicCamera *) cam)->height.getValue();
1416 ((SoOrthographicCamera *) cam)->height = height - 5;
1430 if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
1431 SoKeyboardEvent * ke = (SoKeyboardEvent *) ev;
1433 if (SoKeyboardEvent::isKeyPressEvent(ev, ke->getKey())) {
1434 switch (ke->getKey()) {
1435 case SoKeyboardEvent::LEFT_SHIFT:
1438 case SoKeyboardEvent::RIGHT_SHIFT:
1441 case SoKeyboardEvent::LEFT_CONTROL:
1444 case SoKeyboardEvent::RIGHT_CONTROL:
1447 case SoKeyboardEvent::SPACE:
1469 case SoKeyboardEvent::ESCAPE:
1485 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
1496 case SoKeyboardEvent::DELETE:
1501 String dialogName = (
char *)
"Delete Viewpoint";
1502 std::string msg =
"Are you sure you want to delete current viewpoint?";
1507 case SoKeyboardEvent::LEFT_ARROW:
1515 if (SoXtExaminerViewer::isAnimating())
1531 if (SoXtExaminerViewer::isAnimating())
1556 cam->position =
myCam->position;
1563 this->bottomWheelMotion(
1564 this->getBottomWheelValue() + 0.1
f);
1574 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1575 "Unhandled viewer state");
1580 case SoKeyboardEvent::RIGHT_ARROW:
1588 if (SoXtExaminerViewer::isAnimating())
1602 if (SoXtExaminerViewer::isAnimating())
1624 cam->position =
myCam->position;
1631 this->bottomWheelMotion(
1632 this->getBottomWheelValue() - 0.1
f);
1641 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1642 "Unhandled viewer state");
1647 case SoKeyboardEvent::DOWN_ARROW:
1656 if (SoXtExaminerViewer::isAnimating())
1679 cam->position =
myCam->position;
1686 this->leftWheelMotion(this->getLeftWheelValue() - 0.1
f);
1695 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1696 "Unhandled viewer state");
1701 case SoKeyboardEvent::UP_ARROW:
1709 if (SoXtExaminerViewer::isAnimating())
1732 cam->position =
myCam->position;
1739 this->leftWheelMotion(this->getLeftWheelValue() + 0.1
f);
1748 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1749 "Unhandled viewer state");
1754 case SoKeyboardEvent::PAGE_UP:
1805 case SoKeyboardEvent::PAGE_DOWN:
1861 if (SoKeyboardEvent::isKeyReleaseEvent(ev, ke->getKey())) {
1862 switch (ke->getKey()) {
1863 case SoKeyboardEvent::LEFT_SHIFT:
1866 case SoKeyboardEvent::RIGHT_SHIFT:
1869 case SoKeyboardEvent::LEFT_CONTROL:
1872 case SoKeyboardEvent::RIGHT_CONTROL:
1885 return SoXtExaminerViewer::processSoEvent(ev);
1901 if (refParticleIdx < lastIdx && !animateSensor->isScheduled())
1927 SbVec3f * points = this->
sgeometry->point.startEditing();
1929 if (points[10][0] == 0.0
f)
1931 if (points[14][0] == 0.0
f)
1951 SoXtExaminerViewer::actualRedraw();
1954 SoXtExaminerViewer::actualRedraw();
2000 SbVec3f refParticlePt;
2005 for(
int i = 0; i < lineset->numVertices.getNum(); ++i){
2006 for(
int j = 0; j < lineset->numVertices[i]; ++j){
2007 refParticlePt = coords->point[j];
2033 SoSearchAction action;
2034 action.setType(SoLineSet::getClassTypeId(),
false);
2036 action.apply(this->getSceneGraph());
2038 SoPathList &pathList = action.getPaths();
2040 if(pathList.getLength() != 0){
2042 SoCoordinate3 * coords = NULL;
2043 std::vector<SoCoordinate3 *> coordvec;
2044 std::vector<SoLineSet *> linevec;
2046 bool refPathFound =
false;
2047 for(
int i = 0; i < pathList.getLength(); ++i) {
2048 SoFullPath *path = (SoFullPath *)pathList[i];
2051 for (
size_t j = 0; j < attHolder->
GetAttDefs().size(); ++j) {
2052 std::ostringstream oss;
2055 std::string findStr =
"Type of trajectory (Type): ";
2056 std::string compareValue =
"REFERENCE";
2057 size_t idx = oss.str().find(findStr);
2059 if(idx != std::string::npos) {
2060 if(oss.str().substr(idx + findStr.size(), compareValue.size()) == compareValue) {
2063 refPathFound =
true;
2064 coordvec.push_back(coords);
2065 linevec.push_back((SoLineSet *)path->getTail());
2071 findStr =
"Track ID (ID): ";
2072 idx = oss.str().find(findStr);
2073 if(idx != std::string::npos) {
2075 std::string tmpstr = oss.str().substr(idx + findStr.size(),1);
2076 std::istringstream
buffer(tmpstr);
2084 char nextChar = oss.str().at(idx+findStr.size()+1);
2087 if(std::isdigit(nextChar))
2093 coordvec.push_back(coords);
2094 linevec.push_back((SoLineSet *)path->getTail());
2110 if(coordvec.empty())
2121 float longestLength = 0.0;
2123 for(
unsigned int i=0;i < linevec.size(); ++i){
2126 std::vector<SbVec3f> trajectory;
2128 for(
int j=0; j < linevec[i]->numVertices.getNum(); ++j){
2130 for(
int k=0; k < linevec[i]->numVertices[j]; ++k){
2131 trajectory.push_back(coordvec[i]->point[k]);
2136 float tmpLength=0.0;
2137 for(
unsigned int j=0; j < trajectory.size() - 1; ++j){
2138 tmpLength += (trajectory[j] - trajectory[j + 1]).length();
2141 if(tmpLength > longestLength){
2143 longestLength = tmpLength;
2155 SoLineSet *trajectory = (SoLineSet *)path->getTail();
2156 SoSeparator * grpNode = (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
2157 int nodeIndex = grpNode->findChild(trajectory);
2162 for(
int i = 0; i < 100; ++i){
2165 tmpNode = grpNode->getChild(nodeIndex);
2166 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
2168 return (SoCoordinate3 *)tmpNode;
2179 std::string field, eltName;
2181 std::map<std::string, int> duplicates;
2182 std::map<std::string, int> sceneElts;
2183 SoSearchAction search;
2185 SoGroup *root = (SoGroup *)getSceneManager()->getSceneGraph();
2187 SoBaseKit::setSearchingChildren(
TRUE);
2190 search.setSearchingAll(
TRUE);
2192 search.setType(Geant4_SoPolyhedron::getClassTypeId(), 0);
2195 SoPathList &pl = search.getPaths();
2199 for(
int i = 0; i < pl.getLength(); i++) {
2200 SoFullPath *path = (SoFullPath *)pl[i];
2202 eltName = node->getName();
2203 if(duplicates.count(eltName))
2204 duplicates[eltName]++;
2206 duplicates[eltName] = 1;
2209 for(
int i = 0; i < pl.getLength(); i++) {
2211 std::stringstream ssCount;
2212 SoFullPath *path = (SoFullPath *)pl[i];
2214 eltName = node->getName();
2216 if(duplicates[eltName] == 1)
2219 if(sceneElts.count(eltName))
2220 sceneElts[eltName]++;
2222 sceneElts[eltName] = 1;
2224 ssCount << sceneElts[eltName];
2228 field += ssCount.str();
2230 SoGetBoundingBoxAction bAction(getViewportRegion());
2231 bAction.apply(path);
2232 SbBox3f bBox = bAction.getBoundingBox();
2234 SbVec3f centr = bBox.getCenter();
2235 centr.getValue(x,y,z);
2248 return x*x + y*y + z*
z;
2254 SbVec3f &closestPoint,
2293 SbVec3f dbq = b - q;
2294 float sqrDist =
sqrlen(dbq);
2297 for (
size_t i = 1; i < count; ++i) {
2298 const SbVec3f
a = b;
2299 const SbVec3f daq = dbq;
2302 const SbVec3f dab = a - b;
2304 float dab_x, dab_y, dab_z;
2305 dab.getValue(dab_x,dab_y,dab_z);
2306 float daq_x, daq_y, daq_z;
2307 daq.getValue(daq_x, daq_y, daq_z);
2308 float dbq_x, dbq_y, dbq_z;
2309 dbq.getValue(dbq_x, dbq_y, dbq_z);
2311 const float inv_sqrlen = 1./
sqrlen(dab);
2312 const float t = (dab_x*daq_x + dab_y*daq_y + dab_z*daq_z)*inv_sqrlen;
2323 current_dist = daq_x*daq_x + daq_y*daq_y + daq_z*daq_z
2324 - t*(daq_x*dab_x + daq_y*dab_y + daq_z*dab_z)
2325 + t*t*(dab_x*dab_x + dab_y*dab_y + dab_z*dab_z);
2330 current_dist =
sqrlen(dbq);
2333 if (current_dist < sqrDist){
2334 sqrDist = current_dist;
2335 closestPoint = a + t*(b-
a);
2340 dist = std::sqrt(sqrDist);
2350 typedef std::map<elementForSorting, sceneElement> sortedMap;
2359 trajLength[trajIndex] = 0.0;
2363 trajLength[trajIndex] = trajLength[trajIndex-1] + (*itRef - prevPoint).length();
2371 SoGetBoundingBoxAction bAction(this->getViewportRegion());
2372 SbVec3f elementCoord;
2373 std::vector<sceneElement>::iterator itEl;
2378 bAction.apply(itEl->path);
2381 elementCoord = itEl->center;
2399 sorted.insert(std::make_pair(el,*itEl));
2405 sortedMap::iterator itSorted = sorted.begin();
2406 for(; itSorted != sorted.end(); itSorted++)
2412 Widget formTop = XtNameToWidget(this->
listsDialog,
"FormTop");
2413 Widget formTopRight = XtNameToWidget(formTop,
"FormTopRight");
2417 delete[] trajLength;
2427 XmString *elements = (XmString *) XtMalloc(size *
sizeof(XmString));
2429 std::vector<sceneElement>::const_iterator it;
2431 std::stringstream
ss;
2435 ss <<
" [" << it->closestPointZCoord <<
"]";
2436 elements[count] = XmStringCreateLocalized((
char *)ss.str().c_str());
2447 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2449 labelRight = XmCreateLabelGadget(formTopRight, (
char*)
"Element [S mm]",
2451 XtManageChild(labelRight);
2455 XtSetArg(args[n], XmNvisibleItemCount, 7); n++;
2456 XtSetArg(args[n], XmNitemCount, size); n++;
2457 XtSetArg(args[n], XmNitems, elements); n++;
2458 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2459 XtSetArg(args[n], XmNtopWidget, labelRight); n++;
2460 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2461 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2463 XtSetArg(args[n], XmNwidth, 240); n++;
2467 this->
myElementList = XmCreateScrolledList(formTopRight, (
char *)
"ListRight", args, n);
2469 XtAddCallback(this->
myElementList, XmNbrowseSelectionCallback,
2474 if (elements != NULL) {
2475 for (
int i = 0; i < size; i++)
2476 XmStringFree(elements[i]);
2477 XtFree((
char *) elements);
2486 XtPointer client_data,
2513 Atom WM_DELETE_WINDOW;
2525 std::string dialogNameStr = This->
fileName.substr(This->
fileName.rfind(
'/') + 1);
2526 const int nDialog = dialogNameStr.size() + 1;
2527 char *dialogName =
new char[nDialog];
2528 strncpy(dialogName, dialogNameStr.c_str(), nDialog);
2531 XtSetArg(args[n], XmNx, 610); n++;
2532 This->
myShellDialog = XmCreateDialogShell(topShell, dialogName, args, n);
2534 delete[] dialogName;
2535 WM_DELETE_WINDOW = XInternAtom(XtDisplay(w),
"WM_DELETE_WINDOW", False);
2536 XmAddWMProtocolCallback(This->
myShellDialog, WM_DELETE_WINDOW,
2541 XtSetArg(args[n], XmNsashWidth, 1); n++;
2542 XtSetArg(args[n], XmNsashHeight, 1); n++;
2543 XtSetArg(args[n], XmNseparatorOn, False); n++;
2553 Widget formTop = XmCreateForm(This->
listsDialog, (
char *)
"FormTop", args, n);
2556 XtSetArg(args[n], XmNmarginWidth, 8); n++;
2557 XtSetArg(args[n], XmNmarginHeight, 8); n++;
2558 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2559 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2560 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2561 Widget formTopRight = XmCreateForm(formTop, (
char *)
"FormTopRight", args,
2565 XtSetArg(args[n], XmNmarginWidth, 8); n++;
2566 XtSetArg(args[n], XmNmarginHeight, 8); n++;
2567 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2568 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2569 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2570 XtSetArg(args[n], XmNrightWidget, formTopRight); n++;
2571 XtSetArg(args[n], XmNrightOffset, 10); n++;
2572 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2573 Widget formTopLeft = XmCreateForm(formTop, (
char *)
"FormTopLeft", args, n);
2578 XtManageChild(formTopRight);
2584 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2585 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2586 Widget labelLeft = XmCreateLabelGadget(formTopLeft, (
char *)
"ViewPoints",
2588 XtManageChild(labelLeft);
2592 XtSetArg(args[n], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); n++;
2593 XtSetArg(args[n], XmNvisibleItemCount, 7); n++;
2595 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2596 XtSetArg(args[n], XmNtopWidget, labelLeft); n++;
2597 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2598 XtSetArg(args[n], XmNrightWidget, This->
myElementList); n++;
2599 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2600 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2602 XtSetArg(args[n], XmNwidth, 160); n++;
2605 This->
myViewPtList = XmCreateScrolledList(formTopLeft, (
char *)
"ListLeft",
2609 XtAddCallback(This->
myViewPtList, XmNbrowseSelectionCallback,
2615 XtManageChild(formTopLeft);
2617 XtManageChild(formTop);
2621 XtSetArg(args[n], XmNmarginWidth, 6); n++;
2624 Widget formMiddle = XmCreateForm(This->
listsDialog, (
char *)
"MiddleForm", args, n);
2628 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2629 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2630 XtSetArg(args[n], XmNtopWidget, This->
myViewPtList); n++;
2631 Widget label = XmCreateLabelGadget(formMiddle, (
char *)
"Selection", args,
2633 XtManageChild(label);
2637 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2638 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2639 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2640 XtSetArg(args[n], XmNtopWidget, label); n++;
2641 XtSetArg(args[n], XmNtopOffset, 3); n++;
2642 XtSetArg(args[n], XmNmaxLength, This->
MAX_VP_NAME); n++;
2643 This->
viewPtSelection = XmCreateText(formMiddle, (
char *)
"Txt", args, n);
2646 Dimension
h1,
h2, h;
2647 XtVaGetValues(label, XmNheight, &h1, NULL);
2650 h = (Dimension) (1.1 * (h1 + h2));
2652 XtVaSetValues(formMiddle, XmNpaneMaximum, h, XmNpaneMinimum, h, NULL);
2653 XtManageChild(formMiddle);
2658 XtSetArg(args[n], XmNfractionBase, 4); n++;
2659 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2663 Widget formAction = XmCreateForm(This->
listsDialog, (
char *)
"ActionForm", args, n);
2666 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2667 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2668 XtSetArg(args[n], XmNtopOffset, 3); n++;
2669 XtSetArg(args[n], XmNbottomOffset, 5); n++;
2670 Widget separator = XmCreateSeparatorGadget(formAction, (
char *)
"Sep", args, n);
2672 XtManageChild(separator);
2674 Widget button = XmCreatePushButton(formAction, (
char *)
"Delete", NULL, 0);
2675 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2676 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2677 XmATTACH_POSITION, XmNleftPosition, 0, XmNrightAttachment,
2678 XmATTACH_POSITION, XmNrightPosition, 1,
2679 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2682 XtAddCallback(button, XmNactivateCallback,
2684 XtManageChild(button);
2686 button = XmCreatePushButton(formAction, (
char *)
"Rename", NULL, 0);
2687 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2688 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2689 XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment,
2690 XmATTACH_POSITION, XmNrightPosition, 2,
2691 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2694 XtAddCallback(button, XmNactivateCallback,
2696 XtManageChild(button);
2698 button = XmCreatePushButton(formAction, (
char *)
"Sort", NULL, 0);
2699 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2700 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2701 XmATTACH_POSITION, XmNleftPosition, 2, XmNrightAttachment,
2702 XmATTACH_POSITION, XmNrightPosition, 3,
2703 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2706 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)
sortBookmarksCB, This);
2707 XtManageChild(button);
2709 button = XmCreatePushButton(formAction, (
char *)
"Close", NULL, 0);
2710 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2711 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2712 XmATTACH_POSITION, XmNleftPosition, 3, XmNrightAttachment,
2713 XmATTACH_POSITION, XmNrightPosition, 4,
2714 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2717 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc) closeListsDialogCB, This);
2718 XtManageChild(button);
2720 XtManageChild(formAction);
2721 XtVaGetValues(button, XmNheight, &h1, NULL);
2722 XtVaSetValues(formAction, XmNpaneMaximum, h1, XmNpaneMinimum, h1, NULL);
2733 XtPointer client_data,
2734 XtPointer call_data)
2737 std::string elementField;
2739 SoCamera * cam = This->getCamera();
2741 if (This->SoXtExaminerViewer::isAnimating())
2742 This->stopAnimating();
2744 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
2746 value = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
2747 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
2754 This->scheduleRedraw();
2760 elementField =
value;
2762 int idx = elementField.find_last_of(
"[");
2764 idx = elementField.size();
2770 SoSearchAction search;
2771 SoNode *root = This->getSceneManager()->getSceneGraph();
2772 int counter, idxUnderscore = elementField.find_last_of(
"_");
2774 This->
parseString<
int>(counter, elementField.substr(idxUnderscore + 1, idx),
error);
2776 SoBaseKit::setSearchingChildren(
TRUE);
2778 search.setSearchingAll(
TRUE);
2781 This->
curEltName = elementField.substr(0, idx);
2785 path = (SoFullPath *)search.getPath();
2788 This->
curEltName = elementField.substr(0, idxUnderscore);
2793 SoPathList &pl = search.getPaths();
2794 path = (SoFullPath *)pl[counter - 1];
2799 if ((idx > 0) && (path)) {
2803 SoGetBoundingBoxAction bAction(This->getViewportRegion());
2804 bAction.apply(path);
2805 SbBox3f bBox = bAction.getBoundingBox();
2806 SbVec3f elementCoord = bBox.getCenter();
2811 float absLengthNow, absLengthMin;
2817 absLengthMin = (p - elementCoord).length();
2823 absLengthNow = (p - elementCoord).length();
2825 if (absLengthNow < absLengthMin) {
2826 absLengthMin = absLengthNow;
2839 This->
distance = (pN - p1).length() / 10;
2851 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2855 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2856 This->
distance = (This->
prevPt - cam->position.getValue()).length();
2862 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
2865 This->scheduleRedraw();
2878 cam->viewAll(path, This->getViewportRegion());
2889 XtPointer client_data,
2936 std::stringstream out;
2939 fileOut.seekp(0, std::ios::beg);
2947 fileOut.seekp(0, std::ios::end);
2965 SoCamera * camera = getCamera();
2966 if (camera == NULL) {
2967 String dialogName = (
char *)
"Missing Camera Node";
2968 std::string msg =
"Camera is null. Unable to set the viewpoint.";
2974 String dialogName = (
char *)
"Missing Viewpoints";
2975 std::string msg =
"There are no viewpoints to load.";
2980 if (SoXtExaminerViewer::isAnimating())
2987 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
3005 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
3008 camera = getCamera();
3009 ((SoOrthographicCamera *) camera)->height.setValue(
3012 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
3014 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
3017 camera = getCamera();
3018 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
3021 ((SoOrthographicCamera *) camera)->height.setValue(
3024 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::setViewPt",
3025 "Only Perspective and Orthographic cameras are supported.");
3035 XtPointer client_data,
3048 Widget nameViewPtDialog;
3049 Widget parent = This->getParentWidget();
3050 XmString label = XmStringCreateLocalized((
char *)
"Name the viewpoint:");
3052 XtSetArg(args[n], XmNselectionLabelString, label); n++;
3054 XtSetArg(args[n], XmNautoUnmanage, False); n++;
3056 XtSetArg(args[n], XmNtitle,
"Save Bookmark"); n++;
3057 nameViewPtDialog = XmCreatePromptDialog(parent, String(
"Save Bookmark"),
3060 XmStringFree(label);
3061 XtAddCallback(nameViewPtDialog, XmNokCallback,
getViewPtNameCB, This);
3062 XtAddCallback(nameViewPtDialog, XmNcancelCallback,
3063 (XtCallbackProc) XtDestroyWidget, NULL);
3065 Widget text = XtNameToWidget(nameViewPtDialog,
"Text");
3066 XtVaSetValues(text, XmNmaxLength, This->
MAX_VP_NAME, NULL);
3067 std::string autoName =
"";
3072 XmTextSetString(text, (
char *) autoName.c_str());
3073 XmTextSetInsertionPosition(text, autoName.length());
3075 XtUnmanageChild(XtNameToWidget(nameViewPtDialog,
"Help"));
3076 XtManageChild(nameViewPtDialog);
3083 std::stringstream sstream;
3084 std::vector<int> existingViewPts;
3088 for (
unsigned int i = 0; i < this->
viewPtList.size(); ++i) {
3090 if (viewPt.find(
"viewpoint_") != std::string::npos) {
3091 tmp = atoi(viewPt.substr(10).c_str());
3094 if (!viewPt.compare(
"viewpoint_0"))
3095 existingViewPts.push_back(0);
3097 existingViewPts.push_back(tmp);
3105 if (existingViewPts.size() > 0) {
3108 if (std::find(existingViewPts.begin(), existingViewPts.end(), vpNum)
3109 == existingViewPts.end()) {
3110 sstream <<
"viewpoint_" << vpNum;
3111 return sstream.str();
3116 return "viewpoint_0";
3123 XtPointer client_data,
3134 XtPointer client_data,
3141 if(This->isViewing())
3142 This->setViewing(
false);
3143 This->setComponentCursor(SoXtCursor(SoXtCursor::CROSSHAIR));
3149 XtPointer client_data,
3155 if (XmToggleButtonGetState(w)) {
3156 This->setDrawStyle(SoXtViewer::STILL, SoXtViewer::VIEW_LINE);
3157 This->setDrawStyle(SoXtViewer::INTERACTIVE, SoXtViewer::VIEW_LINE);
3159 This->setDrawStyle(SoXtViewer::STILL, SoXtViewer::VIEW_AS_IS);
3160 This->setDrawStyle(SoXtViewer::INTERACTIVE,
3161 SoXtViewer::VIEW_SAME_AS_STILL);
3169 XtPointer client_data,
3170 XtPointer call_data)
3173 std::string strName;
3175 XmSelectionBoxCallbackStruct *cbs =
3176 (XmSelectionBoxCallbackStruct *) call_data;
3177 XmStringGetLtoR(cbs->value, XmFONTLIST_DEFAULT_TAG, &name);
3190 int beg = strName.find_first_not_of(
' ');
3191 int end = strName.find_last_not_of(
' ');
3192 strName = strName.substr(beg, end - beg + 1);
3194 bool nameExists =
false;
3196 for (
int i = 0; i < size; i++) {
3197 if (!strcmp(This->
viewPtList[i].viewPtName, strName.c_str())) {
3205 name =
new char[nVPName];
3206 strncpy(name, strName.c_str(), nVPName);
3211 XmListAddItemUnselected(This->
myViewPtList, cbs->value, 0);
3216 String dialogName = (
char *)
"Existing Viewpoint";
3217 std::string msg =
"The viewpoint already exists.";
3231 SoCamera * camera = getCamera();
3241 tmp.
position = camera->position.getValue();
3249 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
3250 tmp.
height = ((SoPerspectiveCamera *) camera)->heightAngle.getValue();
3252 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
3253 tmp.
height = ((SoOrthographicCamera *) camera)->height.getValue();
3256 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::saveViewPtCB",
3257 "Only Perspective and Orthographic cameras are supported.");
3264 std::string vpName =
name;
3269 fileOut << vpName << std::endl;
3271 fileOut << x <<
" " << y <<
" " << z << std::endl;
3275 axis.getValue(x, y, z);
3276 fileOut << x <<
" " << y <<
" " << z <<
" " << angle << std::endl;
3290 XtPointer client_data,
3307 std::ofstream out(
"temporaryFile.txt");
3313 XmString vpNameStr = XmStringCreateLocalized(vpName);
3316 XmStringFree(vpNameStr);
3320 out << line <<
"\n";
3322 while (getline(
fileIn, line)) {
3323 end = line.find_last_not_of(
' ');
3324 line = line.substr(0, end + 1);
3325 if (!strcmp(line.c_str(), vpName)) {
3326 while (line.size()) {
3330 while (getline(
fileIn, line))
3331 out << line <<
"\n";
3333 while (line.size()) {
3334 out << line <<
"\n";
3343 while (idx < size) {
3344 if (!strcmp(
viewPtList[idx].viewPtName, vpName)) {
3357 int istat =
remove(
fileName.c_str());
3359 char dialogName[] =
"Warning";
3363 istat = rename(
"temporaryFile.txt",
fileName.c_str());
3365 char dialogName[] =
"Warning";
3370 fileOut.seekp(0, std::ios::end);
3390 int idx = 0, end,
pos;
3392 std::string line, newName;
3401 while (getline(
fileIn, line)) {
3402 end = line.find_last_not_of(
' ');
3403 line = line.substr(0, end + 1);
3407 fileOut.seekp(0, std::ios::end);
3418 while (idx < size) {
3434 int sortIdx = 0, unsortIdx = 0;
3443 int size = sortedViewPts.size();
3444 while (sortIdx < size) {
3445 while (strcmp(sortedViewPts[sortIdx].c_str(),
3449 std::string vpName =
viewPtList[unsortIdx].viewPtName;
3453 fileOut << vpName << std::endl;
3454 viewPtList[unsortIdx].position.getValue(x, y, z);
3455 fileOut << x <<
" " << y <<
" " << z << std::endl;
3458 viewPtList[unsortIdx].orientation.getValue(axis, angle);
3459 axis.getValue(x, y, z);
3460 fileOut << x <<
" " << y <<
" " << z <<
" " << angle << std::endl;
3463 <<
viewPtList[unsortIdx].height << std::endl;
3496 while (getline(
fileIn, token)) {
3498 int end = token.find_last_not_of(
' ');
3499 token = token.substr(0, end + 1);
3501 char *vpName =
new char[token.size() + 1];
3502 strcpy(vpName, token.c_str());
3506 parseString<float>(
x, token,
error);
3508 parseString<float>(
y, token,
error);
3510 parseString<float>(
z, token,
error);
3512 tmp.
position = axis.setValue(x, y, z);
3514 parseString<float>(
x, token,
error);
3516 parseString<float>(
y, token,
error);
3518 parseString<float>(
z, token,
error);
3522 orient.setValue(axis.setValue(x, y, z),
angle);
3526 parseString<int>(camType, token,
error);
3563 std::istringstream str(s);
3564 if ((str >> t).fail())
3572 std::string dialogName,
3573 std::string buttonLabel,
3574 XtCallbackProc cbOK)
3578 Widget parent, scrollWidget;
3579 parent = SoXt::getShellWidget(getParentWidget());
3581 if (dialog == NULL) {
3584 XmString str = XmStringCreateLocalized((
char *) buttonLabel.c_str());
3587 XtSetArg(args[n], XmNokLabelString, str); n++;
3588 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3590 dialog = XmCreateFileSelectionDialog(parent,
3591 (
char *) dialogName.c_str(), args,
n);
3593 XtAddCallback(dialog, XmNokCallback, cbOK,
this);
3597 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_DIR_LIST);
3600 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_LIST);
3604 XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
3607 XtManageChild(dialog);
3624 XtPointer client_data,
3635 XtPointer client_data,
3636 XtPointer call_data)
3640 XmFileSelectionBoxCallbackStruct *cbs =
3641 (XmFileSelectionBoxCallbackStruct *) call_data;
3645 if (!(file = (
char *) XmStringUnparse(cbs->value,
3646 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3648 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::fileSelectedCB",
3649 "Internal error during file opening");
3654 if (!This->
fileIn.fail()) {
3658 String dialogName = (
char *)
"Error Loading File";
3659 std::string msg =
"Wrong or corrupted input file.";
3664 This->
fileOut.seekp(0, std::ios::end);
3671 std::string newDialogName = This->
fileName.substr(
3674 (
char *) newDialogName.c_str(), NULL);
3691 String dialogName = (
char *)
"Nonexistent File";
3692 std::string msg =
"Unable to open file.";
3712 viewPts = (XmString *) XtMalloc(size *
sizeof(XmString));
3713 for (
int i = 0; i < size; i++)
3714 viewPts[i] = XmStringCreateLocalized(
viewPtList[i].viewPtName);
3716 XmListAddItemsUnselected(
myViewPtList, viewPts, size, 1);
3718 if (viewPts != NULL) {
3719 for (
int i = 0; i < size; i++)
3720 XmStringFree(viewPts[i]);
3721 XtFree((
char *) viewPts);
3751 XmString warningMsg;
3753 warningMsg = XmStringCreateLocalized((
char *)msg.c_str());
3756 XtSetArg(args[n], XmNmessageString, warningMsg); n++;
3757 Widget warningDialog = XmCreateWarningDialog(getParentWidget(), dialogName, args, n);
3759 XtAddCallback(warningDialog, XmNokCallback, cb,
this);
3761 XmStringFree(warningMsg);
3763 XtVaSetValues (warningDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
3764 XtUnmanageChild(XtNameToWidget(warningDialog,
"Help"));
3765 XtUnmanageChild(XtNameToWidget(warningDialog,
"Cancel"));
3767 XtManageChild(warningDialog);
3772 XtPointer client_data,
3783 XtPointer client_data,
3784 XtPointer call_data)
3789 XmFileSelectionBoxCallbackStruct *cbs =
3790 (XmFileSelectionBoxCallbackStruct *) call_data;
3794 if (!(file = (
char *) XmStringUnparse(cbs->value,
3795 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3797 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::createNewVPFileCB",
3798 "Internal error during file opening");
3805 if (This->
fileIn.fail()) {
3819 String dialogName = (
char *)
"Existing File";
3820 std::string msg =
"'" + fName +
"' already exists. Do you want to overwrite it?";
3831 XtPointer client_data,
3851 XtPointer client_data,
3862 XtPointer client_data,
3863 XtPointer call_data)
3867 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
3872 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3873 XmCHARSET_TEXT, XmCHARSET_TEXT,
3874 NULL, 0, XmOUTPUT_ALL);
3876 std::ifstream ifs(file);
3880 while(ifs >> x >> y >> z){
3887 String dialogName = (
char *)
"Problem reading file";
3888 std::string msg =
"Problem reading file";
3900 XtPointer client_data,
3906 String dialogName = (
char *)
"No Reference Trajectory";
3907 std::string msg =
"You need to start a run or load a reference trajectory from a file";
3914 Widget parent, scrollWidget;
3915 parent = SoXt::getShellWidget(This->getParentWidget());
3920 XmString str = XmStringCreateLocalized((
char *)
"Save");
3923 XtSetArg(args[n], XmNokLabelString, str); n++;
3924 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3926 This->
saveRefCoordsDialog = XmCreateFileSelectionDialog(parent,(
char *)
"Save Ref Coords", args, n);
3951 XtPointer client_data,
3952 XtPointer call_data)
3956 XmFileSelectionBoxCallbackStruct *cbs =
3957 (XmFileSelectionBoxCallbackStruct *) call_data;
3962 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3963 XmCHARSET_TEXT, XmCHARSET_TEXT,
3964 NULL, 0, XmOUTPUT_ALL);
3966 std::ifstream ifile(file);
3971 Widget parent = This->getParentWidget();
3972 Widget confirmOverwriteDialog;
3975 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite", args, 0);
3976 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
3977 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
3982 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
3992 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
3993 XtManageChild(confirmOverwriteDialog);
3999 std::ofstream ofs(file);
4004 ofs << x <<
" " << y <<
" " << z <<
"\n";
4010 String dialogName = (
char *)
"Error opening file";
4011 std::string msg =
"There was a problem trying to open the file '";
4025 XtPointer client_data,
4026 XtPointer call_data)
4028 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
4031 switch (cbs->reason) {
4041 ofs << x <<
" " << y <<
" " << z <<
"\n";
4048 String dialogName = (
char *)
"Error opening file";
4049 std::string msg =
"There was a problem trying to open the file '";
4063 XmProcessTraversal(XtNameToWidget(This->
saveRefCoordsWidget,
"Text"), XmTRAVERSE_CURRENT);
4077 XtPointer client_data,
4089 XtPointer client_data,
4090 XtPointer call_data)
4094 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
4098 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4099 XmCHARSET_TEXT, XmCHARSET_TEXT,
4100 NULL, 0, XmOUTPUT_ALL);
4103 if (!sceneInput.openFile(file)) {
4104 String dialogName = (
char *)
"Problem opening file";
4105 std::string msg =
"Cannot open file ";
4109 sceneInput.closeFile();
4115 String dialogName = (
char *)
"Problem reading file";
4116 std::string msg =
"Problem reading file";
4130 XtPointer client_data,
4137 Widget parent, scrollWidget;
4138 parent = SoXt::getShellWidget(This->getParentWidget());
4143 XmString str = XmStringCreateLocalized((
char *)
"Save");
4146 XtSetArg(args[n], XmNokLabelString, str); n++;
4147 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
4149 This->
saveSceneGraphDialog = XmCreateFileSelectionDialog(parent,(
char *)
"Save Scene Graph", args, n);
4175 XtPointer client_data,
4176 XtPointer call_data)
4180 XmFileSelectionBoxCallbackStruct *cbs =
4181 (XmFileSelectionBoxCallbackStruct *) call_data;
4185 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4186 XmCHARSET_TEXT, XmCHARSET_TEXT,
4187 NULL, 0, XmOUTPUT_ALL);
4189 std::ifstream ifile(file);
4194 Widget parent = This->getParentWidget();
4195 Widget confirmOverwriteDialog;
4198 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite", args, 0);
4199 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
4200 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
4205 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
4215 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
4216 XtManageChild(confirmOverwriteDialog);
4222 SoWriteAction writeAction;
4223 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4225 SoOutput * out = writeAction.getOutput();
4227 if(out->openFile(file)){
4228 out->setBinary(
FALSE);
4229 writeAction.apply(root);
4235 String dialogName = (
char *)
"Error opening file";
4236 std::string msg =
"There was a problem trying to open the file '";
4252 XtPointer client_data,
4253 XtPointer call_data)
4255 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
4258 switch (cbs->reason) {
4263 SoWriteAction writeAction;
4264 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4266 SoOutput * out = writeAction.getOutput();
4268 out->setBinary(
FALSE);
4269 writeAction.apply(root);
4278 String dialogName = (
char *)
"Error opening file";
4279 std::string msg =
"There was a problem trying to open the file '";
4311 XtPointer client_data,
4312 XtPointer call_data)
4316 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
4318 vpName = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
4319 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4322 if (!strcmp(This->
viewPtList[i].viewPtName, vpName)) {
4337 XtPointer client_data,
4345 XmString vpNameStr = XmStringCreateLocalized(vpName);
4352 XmStringFree(vpNameStr);
4359 XtPointer client_data,
4362 std::string vpNameStr;
4364 int *pos_list, pos_cnt;
4369 if (!strlen(vpName) || !strcmp(This->
curViewPtName, vpName)) {
4376 int beg = vpNameStr.find_first_not_of(
' ');
4377 int end = vpNameStr.find_last_not_of(
' ');
4378 vpNameStr = vpNameStr.substr(beg, end - beg + 1);
4379 const int nVPName = vpNameStr.size() + 1;
4380 char* vpName1 =
new char[nVPName];
4381 strncpy(vpName1, vpNameStr.c_str(), nVPName);
4384 for (
int i = 0; i < size; i++) {
4385 if (!strcmp(vpName1, This->
viewPtList[i].viewPtName)) {
4387 String dialogName = (
char *)
"Existing Viewpoint";
4388 std::string msg =
"'";
4390 msg +=
"' already exists. Choose a different name";
4398 XmString vpNameXmStr = XmStringCreateLocalized(vpName1);
4400 if (XmListGetSelectedPos(This->
myViewPtList, &pos_list, &pos_cnt)) {
4401 XmListReplaceItemsPos(This->
myViewPtList, &vpNameXmStr, 1, pos_list[0]);
4403 XtFree((
char *) pos_list);
4407 This->scheduleRedraw();
4409 XmStringFree(vpNameXmStr);
4415 XtPointer client_data,
4420 XmString *strList, *newStrList;
4421 std::vector<std::string> charList;
4428 XtVaGetValues(This->
myViewPtList, XmNitemCount, &size, XmNitems, &strList,
4431 for (
int i = 0; i < size; i++) {
4432 vpName = (
char *) XmStringUnparse(strList[i], XmFONTLIST_DEFAULT_TAG,
4433 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4434 charList.push_back(vpName);
4438 std::sort(charList.begin(), charList.end());
4440 newStrList = (XmString *) XtMalloc(size *
sizeof(XmString));
4441 for (
int i = 0; i < size; i++) {
4445 const int nVPName = charList[i].size() + 1;
4446 char *vpName2 =
new char[nVPName];
4447 strncpy(vpName2, charList[i].c_str(), nVPName);
4448 newStrList[i] = XmStringCreateLocalized(vpName2);
4453 XmListAddItemsUnselected(This->
myViewPtList, newStrList, size, 1);
4457 if (newStrList != NULL) {
4458 for (
int i = 0; i < size; i++)
4459 XmStringFree(newStrList[i]);
4460 XtFree((
char *) newStrList);
4470 SbVec3f p1, p2, p3, dirNow, dirNxt,
dir, p2_tmp, p_start, p_corner, p_nxt;
4471 float avgDistBtwPts = 0;
4472 float totalDistBtwPts = 0;
4473 std::vector<SbVec3f> newRefParticleTrajectory;
4477 for (
int i = 0; i < size; i++) {
4483 totalDistBtwPts += (p2 - p1).length();
4486 avgDistBtwPts = totalDistBtwPts / numOfPts;
4487 float minDistAllowed = 0.75 * avgDistBtwPts;
4497 p1.getValue(x, y, z);
4499 newRefParticleTrajectory.push_back(refPoint);
4502 while ((p2 - p1).length() < minDistAllowed && j < (size - 1)) {
4522 XtPointer client_data,
4541 SoCamera *cam = getCamera();
4550 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4552 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
4554 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4556 ((SoOrthographicCamera *) cam)->height.getValue();
4564 SoCamera *cam = getCamera();
4574 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4578 ((SoOrthographicCamera *) cam)->height.setValue(
4581 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4583 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4587 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4590 ((SoOrthographicCamera *) cam)->height.setValue(
4599 SbTime curTime = SbTime::getTimeOfDay();
4601 SoTimerSensor *
s = (SoTimerSensor *) sensor;
4603 float t = float((curTime - s->getBaseTime()).
getValue())
4606 if ((t > 1.0
f) || (t + s->getInterval().getValue() > 1.0f))
4608 SbBool end = (t == 1.0f);
4631 SbTime curTime = SbTime::getTimeOfDay();
4633 SoCamera *cam = This->getCamera();
4634 SoTimerSensor *
s = (SoTimerSensor *) sensor;
4636 float t = float((curTime - s->getBaseTime()).
getValue())
4639 if ((t > 1.0
f) || (t + s->getInterval().getValue() > 1.0f))
4641 SbBool end = (t == 1.0f);
4671 if (SoXtExaminerViewer::isAnimating())
4675 SbVec3f p1, p2, p2_tmp, camUpV, camD, camD_tmp, leftRightAxis;
4693 p1.getValue(x1, y1, z1);
4694 p2.getValue(x2, y2, z2);
4699 p2_tmp.setValue(x2, y1, z2);
4700 camD_tmp = p2_tmp - p1;
4701 camD_tmp.normalize();
4703 camUpV.setValue(0, 1, 0);
4704 rot.setValue(camD_tmp, camD);
4705 rot.multVec(camUpV, camUpV);
4707 leftRightAxis = camD.cross(camUpV);
4709 myCam->position = p1;
4710 myCam->pointAt(p2, camUpV);
4714 myCam->position = p1;
4720 myCam->focalDistance = 0.1f;
4732 XtPointer client_data,
4738 String dialogName = (
char *)
"No Reference Trajectory";
4739 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4752 This->scheduleRedraw();
4759 if (This->SoXtExaminerViewer::isAnimating())
4760 This->stopAnimating();
4769 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
4772 This->scheduleRedraw();
4784 This->
distance = (pN - p1).length() / 10;
4791 XtPointer client_data,
4810 XtPointer client_data,
4817 String dialogName = (
char *)
"No Reference Trajectory";
4818 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4829 This->
axisSwitch->whichChild.setValue(SO_SWITCH_ALL);
4832 This->scheduleRedraw();
4835 SoCamera *cam = This->getCamera();
4848 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4849 This->toggleCameraType();
4850 cam = This->getCamera();
4858 cam->focalDistance = 0.1f;
4859 ((SoPerspectiveCamera *) cam)->heightAngle = 0.50f;
4866 cam->orientation = (This->
myCam)->orientation.getValue();
4873 SoCamera *cam = getCamera();
4895 void (*callback)(
void *),
void *
object)
void createElementsList(Widget)
std::string saveRefCoordsFileName
static void saveRefCoordsCB(Widget, XtPointer, XtPointer)
static const char * pickext_xpm[]
Widget saveRefCoordsWidget
static G4OpenInventorXtExaminerViewer * viewer
static void loadRefCoordsCB(Widget, XtPointer, XtPointer)
SoFont * mouseOverFontSolid
void animateRefParticle()
void warningMsgDialog(std::string, String, XtCallbackProc)
void xmAddMouseEventHandler(Widget w)
static void abbrOutputCB(Widget, XtPointer, XtPointer)
void constructor(const SbBool build)
void addEscapeCallback(void(*cb)(void *), void *)
std::vector< ExP01TrackerHit * > a
static const G4double pos
SbRotation camStartOrient
static const char * wireframe_xpm[]
SoCoordinate3 * sgeometry
void superimpositionEvent(SoAction *action)
static void animateSensorRotationCB(void *, SoSensor *)
Float_t y1[n_points_granero]
static void loadSceneGraphCB(Widget, XtPointer, XtPointer)
void distanceToTrajectory(const SbVec3f &, float &, SbVec3f &, int &)
Float_t x1[n_points_granero]
void updateSpeedIndicator(void)
G4double getValue(const ArrayType &array, Value1D value)
std::string viewPtAutoName()
virtual void afterRealizeHook()
static void newViewPtFileCB(Widget, XtPointer, XtPointer)
Widget saveScenegraphWidget
SoTranslation * mouseOverTransZPos
static void saveSceneGraphCB(Widget, XtPointer, XtPointer)
virtual SbBool processSoEvent(const SoEvent *const event)
static void saveViewPtCB(Widget, XtPointer, XtPointer)
SoText2 * mouseOverTextLogName
void saveViewPt(char *name)
HookEventProcState(G4OpenInventorXtExaminerViewer *)
SoTranslation * mouseOverTransLogName
static void prevViewPtCB(Widget, XtPointer, XtPointer)
SoTranslation * curInfoTrans
SoTimerSensor * animateSensorRotation
static void saveSceneGraphOverWriteCB(Widget, XtPointer, XtPointer)
static const char * pickref_xpm[]
Widget addMenu(std::string name)
static void saveRefCoordsOverWriteCB(Widget, XtPointer, XtPointer)
SoText2 * mouseOverTextSolid
const std::vector< const std::map< G4String, G4AttDef > * > & GetAttDefs() const
SoFont * mouseOverFontMaterial
static void nextViewPtCB(Widget, XtPointer, XtPointer)
void deleteViewPt(char *vpName=NULL)
static void sortBookmarksCB(Widget, XtPointer, XtPointer)
void addButton(Widget menu, std::string name, XtCallbackProc)
Float_t y2[n_points_geant4]
SoSwitch * animSpeedSwitch
static void loadRefCoordsDialogCB(Widget, XtPointer, XtPointer)
SoTranslation * mouseOverTransSolid
const XML_Char const XML_Char * data
std::string saveScenegraphFileName
static void invertRefPathCB(Widget, XtPointer, XtPointer)
static void saveSceneGraphDialogCB(Widget, XtPointer, XtPointer)
static void getViewPtNameCB(Widget, XtPointer, XtPointer)
void setReferencePath(SoLineSet *, SoCoordinate3 *, bool append=false)
static void superimpositionCB(void *closure, SoAction *action)
void setStartingPtForAnimation()
std::vector< SbVec3f > refParticleTrajectory
std::vector< float > refZPositions
static void lookAtSceneElementCB(Widget, XtPointer, XtPointer)
Widget buildWidget(Widget parent)
static void constructListsDialog(Widget, XtPointer, XtPointer)
static void openViewPtFileCB(Widget, XtPointer, XtPointer)
static void pickRefPathCB(Widget, XtPointer, XtPointer)
static void deleteBookmarkCB(Widget, XtPointer, XtPointer)
const XML_Char int const XML_Char * value
std::vector< sceneElement > sceneElements
SoNodeSensor * sceneChangeSensor
SoFont * mouseOverFontLogName
void evenOutRefParticlePts()
static void gotoRefPathStartCB(Widget, XtPointer, XtPointer)
virtual void actualRedraw(void)
bool viewingBeforePickRef
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
SoFont * mouseOverFontZPos
double animateBtwPtsPeriod
SoSearchAction * searcher
static void overwriteFileCB(Widget, XtPointer, XtPointer)
static void deleteViewPtCB(Widget, XtPointer, XtPointer)
#define SPEED_INDICATOR_STEP
HookEventProcState * hookBeamOn
void renameViewPt(char *vpName)
G4OpenInventorXtExaminerViewer(Widget parent=NULL, const char *name=NULL, SbBool embed=TRUE, SoXtFullViewer::BuildFlag flag=BUILD_ALL, SoXtViewer::Type type=BROWSER)
void popUpFileSelDialog(Widget &, std::string, std::string, XtCallbackProc)
static void closeListsDialogCB(Widget, XtPointer, XtPointer)
SoTranslation * stranslation
SoNode * getSuperimpositionNode(SoNode *, const char *name)
static void viewPtFileSelectedCB(Widget, XtPointer, XtPointer)
virtual void createViewerButtons(Widget parent, SbPList *buttonlist)
#define MAX_SPEED_INDICATOR
viewPtData camB4Animation
void cleanUpAfterPrevFile()
const std::vector< const std::vector< G4AttValue > * > & GetAttValues() const
Widget saveSceneGraphDialog
SoText2 * mouseOverTextZPos
static const char * saveViewPt_xpm[]
std::vector< viewPtData > viewPtList
SoText2 * mouseOverTextMaterial
static void cancelFileSelDialogCB(Widget, XtPointer, XtPointer)
static void switchWireFrameCB(Widget, XtPointer, XtPointer)
static Pixmap createPixmapFromXpm(Widget button, const char **xpm, SbBool ghost=FALSE)
friend class HookEventProcState
static void pickingCB(void *aThis, SoEventCallback *eventCB)
static void saveRefCoordsDialogCB(Widget, XtPointer, XtPointer)
float sqrlen(const SbVec3f &)
SoTimerSensor * animateSensor
static void renameBookmarkCB(Widget, XtPointer, XtPointer)
SoSeparator * newSceneGraph
~G4OpenInventorXtExaminerViewer()
static void animateRefParticleCB(Widget, XtPointer, XtPointer)
static void loadBookmarkCB(Widget, XtPointer, XtPointer)
void parseString(T &t, const std::string &s, bool &error)
SoSwitch * animSpeedOutlineSwitch
G4GLOB_DLL std::ostream G4cout
G4OpenInventorXtExaminerViewer * viewer
float distanceToBeamlineStart
SoTranslation * mouseOverTransMaterial
static void loadSceneGraphDialogCB(Widget, XtPointer, XtPointer)
static PROLOG_HANDLER error
void(* escapeCallback)(void *)
static void animateSensorCB(void *, SoSensor *)
static void closeMainWindowCB(Widget, XtPointer, XtPointer)
Float_t x2[n_points_geant4]
void setReferencePathZPos()
void sortViewPts(std::vector< std::string >)
SoCoordinate3 * getCoordsNode(SoFullPath *path)
static void mouseoverCB(void *aThis, SoEventCallback *eventCB)
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
Widget saveRefCoordsDialog
void moveCamera(float dist=0, bool lookdown=false)
virtual G4bool Notify(G4ApplicationState requiredState)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
static const char * thisClassName
Widget loadRefCoordsDialog
static void sceneChangeCB(void *, SoSensor *)
Widget loadSceneGraphDialog
static void createNewVPFileCB(Widget, XtPointer, XtPointer)