30 #ifdef G4VIS_BUILD_OIX_DRIVER
41 #include <X11/keysym.h>
46 #include <Xm/MessageB.h>
48 #include <Xm/ToggleB.h>
49 #include <Xm/CascadeB.h>
50 #include <Xm/ArrowBG.h>
52 #include <Xm/RowColumn.h>
53 #include <Xm/FileSB.h>
54 #include <Xm/SelectioB.h>
55 #include <Xm/Protocols.h>
56 #include <Xm/SeparatoG.h>
57 #include <Xm/DialogS.h>
58 #include <Xm/PanedW.h>
59 #include <Xm/LabelG.h>
61 #include <Xm/DrawingA.h>
63 #include <Inventor/Xt/SoXt.h>
65 #include <Inventor/Xt/SoXtCursor.h>
66 #include <Inventor/events/SoKeyboardEvent.h>
67 #include <Inventor/events/SoMouseButtonEvent.h>
68 #include <Inventor/events/SoLocation2Event.h>
69 #include <Inventor/nodes/SoSeparator.h>
70 #include <Inventor/nodes/SoOrthographicCamera.h>
71 #include <Inventor/nodes/SoPerspectiveCamera.h>
74 #include <Inventor/nodes/SoLineSet.h>
75 #include <Inventor/nodes/SoMaterial.h>
76 #include <Inventor/errors/SoDebugError.h>
77 #include <Inventor/SoPickedPoint.h>
78 #include <Inventor/actions/SoWriteAction.h>
83 #include <Inventor/sensors/SoTimerSensor.h>
84 #include <Inventor/sensors/SoNodeSensor.h>
99 #include <Inventor/nodes/SoCallback.h>
100 #include <Inventor/nodes/SoSwitch.h>
101 #include <Inventor/nodes/SoScale.h>
102 #include <Inventor/nodes/SoTranslation.h>
103 #include <Inventor/actions/SoSearchAction.h>
104 #include <Inventor/actions/SoGetBoundingBoxAction.h>
106 #include <Inventor/nodes/SoCoordinate3.h>
108 #include <Inventor/nodes/SoText2.h>
109 #include <Inventor/nodes/SoFont.h>
110 #include <Inventor/nodes/SoPointSet.h>
111 #include <Inventor/nodes/SoDrawStyle.h>
112 #include <Inventor/nodes/SoBaseColor.h>
115 #include <Inventor/nodekits/SoBaseKit.h>
118 #include <Inventor/SbVec3f.h>
122 static const char* thisClassName =
"G4OpenInventorXtExaminerViewer";
124 #define MIN_SPEED 2.1 // Lower number means faster
125 #define START_STEP 0.3
126 #define SPEED_INDICATOR_STEP 0.045
127 #define MAX_SPEED_INDICATOR 0.81
133 const char *
name, SbBool embed,
135 SoXtExaminerViewer(parent, name, embed, flag, type,
FALSE)
138 this->constructor(
TRUE);
143 const char *
name, SbBool embed,
146 SoXtExaminerViewer(parent, name, embed, flag, type,
FALSE)
148 this->constructor(build);
154 setClassName(thisClassName);
167 myCam =
new SoPerspectiveCamera;
203 static const char * superimposed[] = {
204 "#Inventor V2.1 ascii",
"",
211 " OrthographicCamera ",
217 " DEF soxt->callback Callback { }",
220 " DEF soxt->translation Translation ",
222 " translation 0 0 0",
224 " DEF soxt->scale Scale ",
226 " scaleFactor 1 1 1",
228 " DEF soxt->geometry Coordinate3 ",
232 " -0.81 -0.04 0, -0.81 0 0,",
233 " -0.81 0.04 0, 0 -0.04 0,",
235 " 0.81 -0.04 0, 0.81 0 0,",
238 " 0.81 0.02 0, 0.81 -0.02 0,",
241 " 0.4 0.01 0, 0.4 -0.01 0,",
246 " DEF soxt->animSpeedOutlineSwitch Switch ",
251 " emissiveColor 0 0 0",
257 " 12, 11, 10, 9, -1",
262 " DEF soxt->axisSwitch Switch ",
281 " DEF soxt->animSpeedSwitch Switch ",
286 " emissiveColor 0 1 0",
292 " 16, 15, 14, 13, -1",
298 " DEF soxt->curInfoSwitch Switch ",
301 " DEF soxt->curInfoTrans Translation ",
303 " translation 10 20 30 ",
305 " DEF soxt->curInfoFont Font ",
307 " name defaultFont:Bold",
310 " DEF soxt->curInfoText Text2 ",
319 " DEF soxt->mouseOverTransLogName Translation ",
321 " translation 0 0 0 ",
323 " DEF soxt->mouseOverFontLogName Font ",
325 " name defaultFont:Bold",
328 " DEF soxt->mouseOverTextLogName Text2 { } ",
332 " DEF soxt->mouseOverTransSolid Translation ",
334 " translation 0 0 0 ",
336 " DEF soxt->mouseOverFontSolid Font ",
338 " name defaultFont:Bold",
341 " DEF soxt->mouseOverTextSolid Text2 { } ",
345 " DEF soxt->mouseOverTransMaterial Translation ",
347 " translation 0 0 0 ",
349 " DEF soxt->mouseOverFontMaterial Font ",
351 " name defaultFont:Bold",
354 " DEF soxt->mouseOverTextMaterial Text2 { } ",
358 " DEF soxt->mouseOverTransZPos Translation ",
360 " translation 0 0 0 ",
362 " DEF soxt->mouseOverFontZPos Font ",
364 " name defaultFont:Bold",
367 " DEF soxt->mouseOverTextZPos Text2 { } ",
373 for (i = bufsize = 0; superimposed[i]; i++)
374 bufsize += strlen(superimposed[i]) + 1;
375 char * buf =
new char[bufsize + 1];
376 for (i = bufsize = 0; superimposed[i]; i++) {
377 strcpy(buf + bufsize, superimposed[i]);
378 bufsize += strlen(superimposed[i]);
382 SoInput * input =
new SoInput;
383 input->setBuffer(buf, bufsize);
442 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
477 this->
searcher =
new SoSearchAction;
480 searcher->setInterest(SoSearchAction::FIRST);
484 return searcher->getPath()->getTail();
501 if (!action->isOfType(SoGLRenderAction::getClassTypeId()))
503 SbViewportRegion vpRegion =
504 ((SoGLRenderAction *) action)->getViewportRegion();
505 SbVec2s viewportSize = vpRegion.getViewportSizePixels();
507 float aspect = float(viewportSize[0]) / float(viewportSize[1]);
508 float factorx = 1.0f / float(viewportSize[1]) * 220.0f;
509 float factory = factorx;
515 SbVec3f(0.0
f, -0.4
f / aspect, 0.0
f));
519 if (viewportSize[0] > 500)
520 factorx *= 500.0f / 400.0f;
522 factorx *= float(viewportSize[0]) / 400.0f;
523 this->
sscale->scaleFactor.setValue(SbVec3f(factorx, factory, 1.0
f));
525 float xInfo, yInfo, xMouseLogName, yMouseLogName, xMouseSolid, yMouseSolid,
526 xMouseMaterial, yMouseMaterial, xMouseZPos, yMouseZPos;
530 yMouseLogName = -.75;
533 xMouseMaterial = 0.0;
534 yMouseMaterial = -.81;
540 xMouseSolid *= aspect;
541 xMouseMaterial *= aspect;
542 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
544 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
546 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
548 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
550 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
553 yMouseSolid /= aspect;
554 yMouseMaterial /= aspect;
555 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
557 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
559 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
561 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
563 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
568 this->
curInfoFont->name.setValue(
"defaultFont:Italic");
573 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
579 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
582 this->
curInfoText->string.setValue(SbString(zPos));
611 Atom WM_DELETE_WINDOW;
614 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::buildWidget",
"Error: Parent is null.");
617 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
618 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
619 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
620 XtSetArg(args[3], XmNbottomAttachment, XmATTACH_FORM);
621 Widget form = XmCreateForm(parent, (
char *)
"Form", args, 4);
624 shell = XtParent(form);
625 WM_DELETE_WINDOW = XInternAtom(XtDisplay(parent),
"WM_DELETE_WINDOW",
627 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW,
630 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
631 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
632 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
633 menuBar = XmCreateMenuBar(form, (
char *)
"MenuBar", args, 3);
644 XmCreateSeparatorGadget(
fileMenu, (
char *)
"Separator", NULL, 0));
646 Widget menu =
addMenu(
"Tools");
651 Widget viewerBase = SoXtFullViewer::buildWidget(form);
653 XtSetArg(args[0], XmNtopAttachment, XmATTACH_WIDGET);
654 XtSetArg(args[1], XmNtopWidget,
menuBar);
655 XtSetArg(args[2], XmNleftAttachment, XmATTACH_FORM);
656 XtSetArg(args[3], XmNrightAttachment, XmATTACH_FORM);
657 XtSetArg(args[4], XmNbottomAttachment, XmATTACH_FORM);
658 XtSetValues(viewerBase, args, 5);
668 Widget menu = XmCreatePulldownMenu(
menuBar, (
char *) name.c_str(), NULL, 0);
670 XtSetArg(args[0], XmNsubMenuId, menu);
671 Widget
w = XmCreateCascadeButton(
menuBar, (
char *) name.c_str(), args, 1);
682 Widget button = XmCreatePushButton(menu, (
char *) name.c_str(), NULL, 0);
683 XtManageChild(button);
684 XtAddCallback(button, XmNactivateCallback, cb,
this);
690 SbPList * buttonlist)
694 Widget saveViewPtButton, abbrOutputButton, pickRefPathButton;
695 Widget switchWireFrameButton;
698 SoXtExaminerViewer::createViewerButtons(parent, buttonlist);
701 Widget emptyButton = XtVaCreateManagedWidget(
"", xmPushButtonWidgetClass,
703 buttonlist->append(emptyButton);
707 XtSetArg(args[n], XmNtopPosition, 1); n++;
708 XtSetArg(args[n], XmNbottomPosition, 2); n++;
709 XtSetArg(args[n], XmNleftPosition, 0); n++;
710 XtSetArg(args[n], XmNrightPosition, 1); n++;
711 XtSetArg(args[n], XmNarrowDirection, XmARROW_LEFT); n++;
712 XtSetArg(args[n], XmNsensitive, False); n++;
722 XtSetArg(args[n], XmNtopPosition, 1); n++;
723 XtSetArg(args[n], XmNbottomPosition, 2); n++;
724 XtSetArg(args[n], XmNleftPosition, 0); n++;
725 XtSetArg(args[n], XmNrightPosition, 1); n++;
726 XtSetArg(args[n], XmNarrowDirection, XmARROW_RIGHT); n++;
727 XtSetArg(args[n], XmNsensitive, False); n++;
736 saveViewPtButton = XtVaCreateManagedWidget(
"Save", xmPushButtonWidgetClass,
738 XtAddCallback(saveViewPtButton, XmNactivateCallback,
740 Pixmap saveVP, saveVP_ins;
745 XtVaSetValues(saveViewPtButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
746 saveVP, XmNselectPixmap, saveVP, XmNlabelInsensitivePixmap,
747 saveVP_ins, XmNselectInsensitivePixmap, saveVP_ins, NULL);
748 buttonlist->append(saveViewPtButton);
751 abbrOutputButton = XtVaCreateManagedWidget(
"Abbr",
752 xmToggleButtonWidgetClass, parent, XmNindicatorOn, False, NULL);
755 Pixmap pickextxpm, pickextxpm_ins;
760 XtVaSetValues(abbrOutputButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
761 pickextxpm, XmNselectPixmap, pickextxpm, XmNlabelInsensitivePixmap,
762 pickextxpm_ins, XmNselectInsensitivePixmap, pickextxpm_ins, NULL);
771 buttonlist->append(abbrOutputButton);
774 pickRefPathButton = XtVaCreateManagedWidget(
"Refpath", xmPushButtonWidgetClass,
776 XtAddCallback(pickRefPathButton, XmNactivateCallback,
778 Pixmap pickrefxpm, pickrefxpm_ins;
783 XtVaSetValues(pickRefPathButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
784 pickrefxpm, XmNselectPixmap, pickrefxpm, XmNlabelInsensitivePixmap,
785 pickrefxpm_ins, XmNselectInsensitivePixmap, pickrefxpm_ins, NULL);
787 buttonlist->append(pickRefPathButton);
790 switchWireFrameButton = XtVaCreateManagedWidget(
"Wireframe",
791 xmToggleButtonWidgetClass, parent, XmNindicatorOn, False, NULL);
792 XtAddCallback(switchWireFrameButton, XmNvalueChangedCallback,
799 XtVaSetValues(switchWireFrameButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
800 wireframe, XmNselectPixmap, wireframe, XmNlabelInsensitivePixmap,
801 wireframe_ins, XmNselectInsensitivePixmap, wireframe_ins, NULL);
802 buttonlist->append(switchWireFrameButton);
810 SoXtExaminerViewer::afterRealizeHook();
814 SoCamera *cam = getCamera();
816 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
818 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
821 ((SoOrthographicCamera *) cam)->height.getValue();
825 ((SoOrthographicCamera *) cam)->height.getValue();
828 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
830 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
839 String dialogName = (
char *)
"Error Loading File";
840 std::string msg =
"Wrong or corrupted input file.";
845 fileOut.seekp(0, std::ios::end);
864 SoSeparator *root = (SoSeparator *) (getSceneManager()->getSceneGraph());
866 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::afterRealizeHook",
"Root is null.");
868 root->addChild(
myCam);
880 SoEventCallback *moCB =
new SoEventCallback;
881 moCB->addEventCallback(
882 SoLocation2Event::getClassTypeId(),
884 root->addChild(moCB);
888 SoEventCallback *pickCB =
new SoEventCallback;
889 pickCB->addEventCallback(
890 SoMouseButtonEvent::getClassTypeId(),
892 root->addChild(pickCB);
901 SoCamera *cam = getCamera();
908 cam->position = camPosNew;
929 SoCamera *cam = getCamera();
942 cam->focalDistance = (cam->position.getValue() -
center).
length();
967 particleDir = p2 - p1;
968 particleDir.normalize();
981 SbRotation rot(SbVec3f(0,0,1), particleDir);
995 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
997 distance = (
prevPt - cam->position.getValue()).
length();
1015 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1018 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
1020 camPosNew = p2 - (
camDir*cam->focalDistance.getValue());
1024 cam->position = camPosNew;
1026 cam->focalDistance = (p2 - camPosNew).
length();
1029 camPosNew.getValue(x,y,z);
1040 SoEventCallback *eventCB)
1042 SoHandleEventAction* action = eventCB->getAction();
1043 const SoPickedPoint *
pp = action->getPickedPoint();
1048 SoPath* path = pp->getPath();
1049 SoNode* node = ((SoFullPath*)path)->getTail();
1051 if(node->getTypeId() == SoLineSet::getClassTypeId()){
1061 SoLineSet * trajectory = (SoLineSet *)node;
1067 SoSeparator * grpNode =
1068 (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
1073 int nodeIndex = grpNode->findChild(trajectory);
1076 SoCoordinate3 * coords = 0;
1080 for(
int i = 0; i < 100; ++i) {
1083 tmpNode = grpNode->getChild(nodeIndex);
1084 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
1086 coords = (SoCoordinate3 *)tmpNode;
1092 String dialogName = (
char *)
"No coordinates";
1093 std::string msg =
"Could not find the coordinates node"
1094 " for the picked trajectory."
1095 " Reference trajectory not set";
1112 if(attHolder && attHolder->
GetAttDefs().size()) {
1114 std::string strTrajPoint =
"G4TrajectoryPoint:";
1115 std::ostringstream oss;
1116 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1121 if(oss.str().find(strTrajPoint) != std::string::npos) {
1136 G4String cls((
char*)node->getTypeId().getName().getString());
1137 G4cout <<
"SoNode : " << node
1138 <<
" SoType : " << cls
1139 <<
" name : " << name
1156 if(attHolder && attHolder->
GetAttDefs().size()) {
1157 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1163 G4String cls((
char*)node->getTypeId().getName().getString());
1164 G4cout <<
"SoNode : " << node
1165 <<
" SoType : " << cls
1166 <<
" name : " << name
1172 eventCB->setHandled();
1179 SoHandleEventAction* action = eventCB->getAction();
1180 const SoPickedPoint* pp = action->getPickedPoint();
1188 const SbViewportRegion & viewportRegion = action->getViewportRegion();
1190 std::string sLogName;
1192 std::stringstream ssZPos;
1193 std::stringstream ssSolids;
1194 std::stringstream ssMaterials;
1195 SoPath * path = pp->getPath();
1196 SoNode* node = ((SoFullPath*)path)->getTail();
1198 if(node->getTypeId() == Geant4_SoPolyhedron::getClassTypeId()) {
1200 sLogName =
"Logical Volume: ";
1203 SoGetBoundingBoxAction bAction(viewportRegion);
1204 bAction.apply((SoFullPath*)path);
1205 SbBox3f bBox = bAction.getBoundingBox();
1206 SbVec3f
center = bBox.getCenter();
1207 center.getValue(x,y,z);
1208 ssZPos <<
"Pos: " << x <<
" " << y <<
" " <<
z;
1211 if(attHolder && attHolder->
GetAttDefs().size()) {
1213 std::vector<const std::map<G4String,G4AttDef>*> vecDefs =
1215 std::vector<const std::vector<G4AttValue>*> vecVals =
1217 for (
size_t i = 0; i < vecDefs.size(); ++i) {
1218 const std::vector<G4AttValue> * vals = vecVals[i];
1220 std::vector<G4AttValue>::const_iterator iValue;
1222 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1223 const G4String& valueName = iValue->GetName();
1226 if(valueName ==
"Solid") {
1227 if(ssSolids.str() ==
"")
1228 ssSolids <<
"Solid Name: " << value;
1230 ssSolids <<
", " <<
value;
1233 if(valueName ==
"Material") {
1234 if(ssMaterials.str() ==
"")
1235 ssMaterials <<
"Material Name: " << value;
1237 ssMaterials <<
", " <<
value;
1244 else if(node->getTypeId() == SoLineSet::getClassTypeId()) {
1247 if(attHolder && attHolder->
GetAttDefs().size()) {
1248 std::string strTrajPoint =
"G4TrajectoryPoint:";
1249 std::ostringstream oss;
1251 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1254 const std::vector<G4AttValue>* vals = attHolder->
GetAttValues()[i];
1255 std::vector<G4AttValue>::const_iterator iValue;
1256 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1257 const G4String& valueName = iValue->GetName();
1258 const G4String& value = iValue->GetValue();
1262 if (valueName ==
"PN") t1 =
value;
1263 if (valueName ==
"Ch") {
1264 if (atof(value.c_str()) > 0)
1270 if (valueName ==
"PDG") {
1278 if (valueName ==
"EventID") t2 =
"Evt " +
value;
1279 if (valueName ==
"ID") t2 +=
" Trk " +
value;
1280 if (valueName ==
"PID") {
1281 t2 +=
" Prt " +
value;
1285 if (valueName ==
"IKE") t3 =
"KE " +
value;
1286 if (valueName ==
"IMom") {
1288 unsigned ipos = value.rfind(
" ");
1291 t3 +=
" P (" + value1 +
")";
1293 if (valueName ==
"IMag") {
1294 t3 +=
" " + value +
"/c";
1299 if (valueName ==
"NTP") {
1300 std::ostringstream t4oss;
1301 t4oss <<
"TrjPts " <<
value;
1302 t4oss <<
" Pos " << pp->getPoint()[0] <<
" " << pp->getPoint()[1] <<
1303 " " << pp->getPoint()[2];
1326 This->scheduleRedraw();
1327 eventCB->setHandled();
1331 bool redraw =
false;
1336 if(std::string(This->
mouseOverTextSolid->string.getValues(0)->getString()) != ssSolids.str()) {
1340 if(std::string(This->
mouseOverTextMaterial->string.getValues(0)->getString()) != ssMaterials.str()){
1344 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) != ssZPos.str()) {
1351 This->scheduleRedraw();
1354 eventCB->setHandled();
1359 This->scheduleRedraw();
1363 This->scheduleRedraw();
1367 This->scheduleRedraw();
1369 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) !=
"") {
1371 This->scheduleRedraw();
1378 SoCamera *cam = getCamera();
1379 const SoType type(ev->getTypeId());
1381 if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
1382 SoMouseButtonEvent * me = (SoMouseButtonEvent *) ev;
1386 switch (me->getButton()) {
1387 case SoMouseButtonEvent::BUTTON4:
1388 if (me->getState() == SoButtonEvent::DOWN) {
1389 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1391 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1392 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1395 }
else if (cam->isOfType(
1396 SoOrthographicCamera::getClassTypeId())) {
1398 ((SoOrthographicCamera *) cam)->height.getValue();
1399 ((SoOrthographicCamera *) cam)->height = height + 5;
1404 case SoMouseButtonEvent::BUTTON5:
1405 if (me->getState() == SoButtonEvent::DOWN) {
1406 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1408 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1410 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1413 }
else if (cam->isOfType(
1414 SoOrthographicCamera::getClassTypeId())) {
1416 ((SoOrthographicCamera *) cam)->height.getValue();
1418 ((SoOrthographicCamera *) cam)->height = height - 5;
1432 if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
1433 SoKeyboardEvent * ke = (SoKeyboardEvent *) ev;
1435 if (SoKeyboardEvent::isKeyPressEvent(ev, ke->getKey())) {
1436 switch (ke->getKey()) {
1437 case SoKeyboardEvent::LEFT_SHIFT:
1440 case SoKeyboardEvent::RIGHT_SHIFT:
1443 case SoKeyboardEvent::LEFT_CONTROL:
1446 case SoKeyboardEvent::RIGHT_CONTROL:
1449 case SoKeyboardEvent::SPACE:
1471 case SoKeyboardEvent::ESCAPE:
1487 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
1498 case SoKeyboardEvent::DELETE:
1503 String dialogName = (
char *)
"Delete Viewpoint";
1504 std::string msg =
"Are you sure you want to delete current viewpoint?";
1509 case SoKeyboardEvent::LEFT_ARROW:
1517 if (SoXtExaminerViewer::isAnimating())
1533 if (SoXtExaminerViewer::isAnimating())
1558 cam->position =
myCam->position;
1565 this->bottomWheelMotion(
1566 this->getBottomWheelValue() + 0.1
f);
1576 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1577 "Unhandled viewer state");
1582 case SoKeyboardEvent::RIGHT_ARROW:
1590 if (SoXtExaminerViewer::isAnimating())
1604 if (SoXtExaminerViewer::isAnimating())
1626 cam->position =
myCam->position;
1633 this->bottomWheelMotion(
1634 this->getBottomWheelValue() - 0.1
f);
1643 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1644 "Unhandled viewer state");
1649 case SoKeyboardEvent::DOWN_ARROW:
1658 if (SoXtExaminerViewer::isAnimating())
1681 cam->position =
myCam->position;
1688 this->leftWheelMotion(this->getLeftWheelValue() - 0.1
f);
1697 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1698 "Unhandled viewer state");
1703 case SoKeyboardEvent::UP_ARROW:
1711 if (SoXtExaminerViewer::isAnimating())
1734 cam->position =
myCam->position;
1741 this->leftWheelMotion(this->getLeftWheelValue() + 0.1
f);
1750 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1751 "Unhandled viewer state");
1756 case SoKeyboardEvent::PAGE_UP:
1807 case SoKeyboardEvent::PAGE_DOWN:
1863 if (SoKeyboardEvent::isKeyReleaseEvent(ev, ke->getKey())) {
1864 switch (ke->getKey()) {
1865 case SoKeyboardEvent::LEFT_SHIFT:
1868 case SoKeyboardEvent::RIGHT_SHIFT:
1871 case SoKeyboardEvent::LEFT_CONTROL:
1874 case SoKeyboardEvent::RIGHT_CONTROL:
1887 return SoXtExaminerViewer::processSoEvent(ev);
1903 if (refParticleIdx < lastIdx && !animateSensor->isScheduled())
1929 SbVec3f * points = this->
sgeometry->point.startEditing();
1931 if (points[10][0] == 0.0
f)
1933 if (points[14][0] == 0.0
f)
1953 SoXtExaminerViewer::actualRedraw();
1956 SoXtExaminerViewer::actualRedraw();
2002 SbVec3f refParticlePt;
2007 for(
int i = 0; i < lineset->numVertices.getNum(); ++i){
2008 for(
int j = 0; j < lineset->numVertices[i]; ++j){
2009 refParticlePt = coords->point[j];
2035 SoSearchAction action;
2036 action.setType(SoLineSet::getClassTypeId(),
false);
2038 action.apply(this->getSceneGraph());
2040 SoPathList &pathList = action.getPaths();
2042 if(pathList.getLength() != 0){
2044 SoCoordinate3 * coords = NULL;
2045 std::vector<SoCoordinate3 *> coordvec;
2046 std::vector<SoLineSet *> linevec;
2048 bool refPathFound =
false;
2049 for(
int i = 0; i < pathList.getLength(); ++i) {
2050 SoFullPath *path = (SoFullPath *)pathList[i];
2053 for (
size_t j = 0; j < attHolder->
GetAttDefs().size(); ++j) {
2054 std::ostringstream oss;
2057 std::string findStr =
"Type of trajectory (Type): ";
2058 std::string compareValue =
"REFERENCE";
2059 size_t idx = oss.str().find(findStr);
2061 if(idx != std::string::npos) {
2062 if(oss.str().substr(idx + findStr.size(), compareValue.size()) == compareValue) {
2065 refPathFound =
true;
2066 coordvec.push_back(coords);
2067 linevec.push_back((SoLineSet *)path->getTail());
2073 findStr =
"Track ID (ID): ";
2074 idx = oss.str().find(findStr);
2075 if(idx != std::string::npos) {
2077 std::string tmpstr = oss.str().substr(idx + findStr.size(),1);
2078 std::istringstream
buffer(tmpstr);
2086 char nextChar = oss.str().at(idx+findStr.size()+1);
2089 if(std::isdigit(nextChar))
2095 coordvec.push_back(coords);
2096 linevec.push_back((SoLineSet *)path->getTail());
2112 if(coordvec.empty())
2123 float longestLength = 0.0;
2125 for(
unsigned int i=0;i < linevec.size(); ++i){
2128 std::vector<SbVec3f> trajectory;
2130 for(
int j=0; j < linevec[i]->numVertices.getNum(); ++j){
2132 for(
int k=0;
k < linevec[i]->numVertices[j]; ++
k){
2133 trajectory.push_back(coordvec[i]->
point[
k]);
2138 float tmpLength=0.0;
2139 for(
unsigned int j=0; j < trajectory.size() - 1; ++j){
2140 tmpLength += (trajectory[j] - trajectory[j + 1]).
length();
2143 if(tmpLength > longestLength){
2145 longestLength = tmpLength;
2157 SoLineSet *trajectory = (SoLineSet *)path->getTail();
2158 SoSeparator * grpNode = (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
2159 int nodeIndex = grpNode->findChild(trajectory);
2164 for(
int i = 0; i < 100; ++i){
2167 tmpNode = grpNode->getChild(nodeIndex);
2168 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
2170 return (SoCoordinate3 *)tmpNode;
2181 std::string field, eltName;
2183 std::map<std::string, int> duplicates;
2184 std::map<std::string, int> sceneElts;
2185 SoSearchAction search;
2187 SoGroup *root = (SoGroup *)getSceneManager()->getSceneGraph();
2189 SoBaseKit::setSearchingChildren(
TRUE);
2192 search.setSearchingAll(
TRUE);
2194 search.setType(Geant4_SoPolyhedron::getClassTypeId(), 0);
2197 SoPathList &
pl = search.getPaths();
2201 for(
int i = 0; i < pl.getLength(); i++) {
2202 SoFullPath *path = (SoFullPath *)pl[i];
2204 eltName = node->getName();
2205 if(duplicates.count(eltName))
2206 duplicates[eltName]++;
2208 duplicates[eltName] = 1;
2211 for(
int i = 0; i < pl.getLength(); i++) {
2213 std::stringstream ssCount;
2214 SoFullPath *path = (SoFullPath *)pl[i];
2216 eltName = node->getName();
2218 if(duplicates[eltName] == 1)
2221 if(sceneElts.count(eltName))
2222 sceneElts[eltName]++;
2224 sceneElts[eltName] = 1;
2226 ssCount << sceneElts[eltName];
2230 field += ssCount.str();
2232 SoGetBoundingBoxAction bAction(getViewportRegion());
2233 bAction.apply(path);
2234 SbBox3f bBox = bAction.getBoundingBox();
2236 SbVec3f centr = bBox.getCenter();
2237 centr.getValue(x,y,z);
2240 sceneElement el = { field, path, centr, 0.0 };
2250 return x*x + y*y + z*
z;
2256 SbVec3f &closestPoint,
2295 SbVec3f dbq = b - q;
2296 float sqrDist =
sqrlen(dbq);
2299 for (
size_t i = 1; i < count; ++i) {
2300 const SbVec3f a =
b;
2301 const SbVec3f daq = dbq;
2304 const SbVec3f dab = a -
b;
2306 float dab_x, dab_y, dab_z;
2307 dab.getValue(dab_x,dab_y,dab_z);
2308 float daq_x, daq_y, daq_z;
2309 daq.getValue(daq_x, daq_y, daq_z);
2310 float dbq_x, dbq_y, dbq_z;
2311 dbq.getValue(dbq_x, dbq_y, dbq_z);
2313 const float inv_sqrlen = 1./
sqrlen(dab);
2314 const float t = (dab_x*daq_x + dab_y*daq_y + dab_z*daq_z)*inv_sqrlen;
2325 current_dist = daq_x*daq_x + daq_y*daq_y + daq_z*daq_z
2326 - t*(daq_x*dab_x + daq_y*dab_y + daq_z*dab_z)
2327 + t*t*(dab_x*dab_x + dab_y*dab_y + dab_z*dab_z);
2332 current_dist =
sqrlen(dbq);
2335 if (current_dist < sqrDist){
2336 sqrDist = current_dist;
2337 closestPoint = a + t*(b-
a);
2342 dist = std::sqrt(sqrDist);
2352 typedef std::map<elementForSorting, sceneElement> sortedMap;
2361 trajLength[trajIndex] = 0.0;
2365 trajLength[trajIndex] = trajLength[trajIndex-1] + (*itRef - prevPoint).
length();
2373 SoGetBoundingBoxAction bAction(this->getViewportRegion());
2374 SbVec3f elementCoord;
2375 std::vector<sceneElement>::iterator itEl;
2377 elementForSorting el;
2380 bAction.apply(itEl->path);
2383 elementCoord = itEl->center;
2393 itEl->closestPointZCoord = el.closestPointZCoord = trajLength[index];
2401 sorted.insert(std::make_pair(el,*itEl));
2407 sortedMap::iterator itSorted = sorted.begin();
2408 for(; itSorted != sorted.end(); itSorted++)
2414 Widget formTop = XtNameToWidget(this->
listsDialog,
"FormTop");
2415 Widget formTopRight = XtNameToWidget(formTop,
"FormTopRight");
2419 delete[] trajLength;
2429 XmString *
elements = (XmString *) XtMalloc(size *
sizeof(XmString));
2431 std::vector<sceneElement>::const_iterator
it;
2433 std::stringstream ss;
2437 ss <<
" [" << it->closestPointZCoord <<
"]";
2438 elements[count] = XmStringCreateLocalized((
char *)ss.str().c_str());
2449 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2451 labelRight = XmCreateLabelGadget(formTopRight, (
char*)
"Element [S mm]",
2453 XtManageChild(labelRight);
2457 XtSetArg(args[n], XmNvisibleItemCount, 7); n++;
2458 XtSetArg(args[n], XmNitemCount, size); n++;
2459 XtSetArg(args[n], XmNitems, elements); n++;
2460 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2461 XtSetArg(args[n], XmNtopWidget, labelRight); n++;
2462 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2463 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2465 XtSetArg(args[n], XmNwidth, 240); n++;
2469 this->
myElementList = XmCreateScrolledList(formTopRight, (
char *)
"ListRight", args, n);
2471 XtAddCallback(this->
myElementList, XmNbrowseSelectionCallback,
2476 if (elements != NULL) {
2477 for (
int i = 0; i < size; i++)
2478 XmStringFree(elements[i]);
2479 XtFree((
char *) elements);
2488 XtPointer client_data,
2515 Atom WM_DELETE_WINDOW;
2527 std::string dialogNameStr = This->
fileName.substr(This->
fileName.rfind(
'/') + 1);
2528 const int nDialog = dialogNameStr.size() + 1;
2529 char *dialogName =
new char[nDialog];
2530 strncpy(dialogName, dialogNameStr.c_str(), nDialog);
2533 XtSetArg(args[n], XmNx, 610); n++;
2534 This->
myShellDialog = XmCreateDialogShell(topShell, dialogName, args, n);
2536 delete[] dialogName;
2537 WM_DELETE_WINDOW = XInternAtom(XtDisplay(w),
"WM_DELETE_WINDOW", False);
2538 XmAddWMProtocolCallback(This->
myShellDialog, WM_DELETE_WINDOW,
2543 XtSetArg(args[n], XmNsashWidth, 1); n++;
2544 XtSetArg(args[n], XmNsashHeight, 1); n++;
2545 XtSetArg(args[n], XmNseparatorOn, False); n++;
2555 Widget formTop = XmCreateForm(This->
listsDialog, (
char *)
"FormTop", args, n);
2558 XtSetArg(args[n], XmNmarginWidth, 8); n++;
2559 XtSetArg(args[n], XmNmarginHeight, 8); n++;
2560 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2561 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2562 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2563 Widget formTopRight = XmCreateForm(formTop, (
char *)
"FormTopRight", args,
2567 XtSetArg(args[n], XmNmarginWidth, 8); n++;
2568 XtSetArg(args[n], XmNmarginHeight, 8); n++;
2569 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2570 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2571 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2572 XtSetArg(args[n], XmNrightWidget, formTopRight); n++;
2573 XtSetArg(args[n], XmNrightOffset, 10); n++;
2574 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2575 Widget formTopLeft = XmCreateForm(formTop, (
char *)
"FormTopLeft", args, n);
2580 XtManageChild(formTopRight);
2586 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2587 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2588 Widget labelLeft = XmCreateLabelGadget(formTopLeft, (
char *)
"ViewPoints",
2590 XtManageChild(labelLeft);
2594 XtSetArg(args[n], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); n++;
2595 XtSetArg(args[n], XmNvisibleItemCount, 7); n++;
2597 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2598 XtSetArg(args[n], XmNtopWidget, labelLeft); n++;
2599 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2600 XtSetArg(args[n], XmNrightWidget, This->
myElementList); n++;
2601 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2602 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2604 XtSetArg(args[n], XmNwidth, 160); n++;
2607 This->
myViewPtList = XmCreateScrolledList(formTopLeft, (
char *)
"ListLeft",
2611 XtAddCallback(This->
myViewPtList, XmNbrowseSelectionCallback,
2617 XtManageChild(formTopLeft);
2619 XtManageChild(formTop);
2623 XtSetArg(args[n], XmNmarginWidth, 6); n++;
2626 Widget formMiddle = XmCreateForm(This->
listsDialog, (
char *)
"MiddleForm", args, n);
2630 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2631 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2632 XtSetArg(args[n], XmNtopWidget, This->
myViewPtList); n++;
2633 Widget label = XmCreateLabelGadget(formMiddle, (
char *)
"Selection", args,
2635 XtManageChild(label);
2639 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2640 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2641 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2642 XtSetArg(args[n], XmNtopWidget, label); n++;
2643 XtSetArg(args[n], XmNtopOffset, 3); n++;
2644 XtSetArg(args[n], XmNmaxLength, This->
MAX_VP_NAME); n++;
2645 This->
viewPtSelection = XmCreateText(formMiddle, (
char *)
"Txt", args, n);
2648 Dimension
h1,
h2,
h;
2649 XtVaGetValues(label, XmNheight, &h1, NULL);
2652 h = (Dimension) (1.1 * (h1 + h2));
2654 XtVaSetValues(formMiddle, XmNpaneMaximum, h, XmNpaneMinimum, h, NULL);
2655 XtManageChild(formMiddle);
2660 XtSetArg(args[n], XmNfractionBase, 4); n++;
2661 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2665 Widget formAction = XmCreateForm(This->
listsDialog, (
char *)
"ActionForm", args, n);
2668 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2669 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2670 XtSetArg(args[n], XmNtopOffset, 3); n++;
2671 XtSetArg(args[n], XmNbottomOffset, 5); n++;
2672 Widget
separator = XmCreateSeparatorGadget(formAction, (
char *)
"Sep", args, n);
2674 XtManageChild(separator);
2676 Widget button = XmCreatePushButton(formAction, (
char *)
"Delete", NULL, 0);
2677 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2678 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2679 XmATTACH_POSITION, XmNleftPosition, 0, XmNrightAttachment,
2680 XmATTACH_POSITION, XmNrightPosition, 1,
2681 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2684 XtAddCallback(button, XmNactivateCallback,
2686 XtManageChild(button);
2688 button = XmCreatePushButton(formAction, (
char *)
"Rename", NULL, 0);
2689 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2690 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2691 XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment,
2692 XmATTACH_POSITION, XmNrightPosition, 2,
2693 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2696 XtAddCallback(button, XmNactivateCallback,
2698 XtManageChild(button);
2700 button = XmCreatePushButton(formAction, (
char *)
"Sort", NULL, 0);
2701 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2702 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2703 XmATTACH_POSITION, XmNleftPosition, 2, XmNrightAttachment,
2704 XmATTACH_POSITION, XmNrightPosition, 3,
2705 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2708 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)
sortBookmarksCB, This);
2709 XtManageChild(button);
2711 button = XmCreatePushButton(formAction, (
char *)
"Close", NULL, 0);
2712 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2713 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2714 XmATTACH_POSITION, XmNleftPosition, 3, XmNrightAttachment,
2715 XmATTACH_POSITION, XmNrightPosition, 4,
2716 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2719 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)
closeListsDialogCB, This);
2720 XtManageChild(button);
2722 XtManageChild(formAction);
2723 XtVaGetValues(button, XmNheight, &h1, NULL);
2724 XtVaSetValues(formAction, XmNpaneMaximum, h1, XmNpaneMinimum, h1, NULL);
2735 XtPointer client_data,
2736 XtPointer call_data)
2739 std::string elementField;
2741 SoCamera * cam = This->getCamera();
2743 if (This->SoXtExaminerViewer::isAnimating())
2744 This->stopAnimating();
2746 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
2748 value = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
2749 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
2756 This->scheduleRedraw();
2762 elementField =
value;
2764 int idx = elementField.find_last_of(
"[");
2766 idx = elementField.size();
2772 SoSearchAction search;
2773 SoNode *root = This->getSceneManager()->getSceneGraph();
2774 int counter, idxUnderscore = elementField.find_last_of(
"_");
2776 This->
parseString<
int>(counter, elementField.substr(idxUnderscore + 1, idx),
error);
2778 SoBaseKit::setSearchingChildren(
TRUE);
2780 search.setSearchingAll(
TRUE);
2783 This->
curEltName = elementField.substr(0, idx);
2787 path = (SoFullPath *)search.getPath();
2790 This->
curEltName = elementField.substr(0, idxUnderscore);
2795 SoPathList &pl = search.getPaths();
2796 path = (SoFullPath *)pl[counter - 1];
2801 if ((idx > 0) && (path)) {
2805 SoGetBoundingBoxAction bAction(This->getViewportRegion());
2806 bAction.apply(path);
2807 SbBox3f bBox = bAction.getBoundingBox();
2808 SbVec3f elementCoord = bBox.getCenter();
2813 float absLengthNow, absLengthMin;
2819 absLengthMin = (p - elementCoord).
length();
2825 absLengthNow = (p - elementCoord).
length();
2827 if (absLengthNow < absLengthMin) {
2828 absLengthMin = absLengthNow;
2853 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2857 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2864 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
2867 This->scheduleRedraw();
2880 cam->viewAll(path, This->getViewportRegion());
2891 XtPointer client_data,
2938 std::stringstream out;
2941 fileOut.seekp(0, std::ios::beg);
2949 fileOut.seekp(0, std::ios::end);
2967 SoCamera * camera = getCamera();
2968 if (camera == NULL) {
2969 String dialogName = (
char *)
"Missing Camera Node";
2970 std::string msg =
"Camera is null. Unable to set the viewpoint.";
2976 String dialogName = (
char *)
"Missing Viewpoints";
2977 std::string msg =
"There are no viewpoints to load.";
2982 if (SoXtExaminerViewer::isAnimating())
2989 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
3007 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
3010 camera = getCamera();
3011 ((SoOrthographicCamera *) camera)->height.setValue(
3014 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
3016 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
3019 camera = getCamera();
3020 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
3023 ((SoOrthographicCamera *) camera)->height.setValue(
3026 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::setViewPt",
3027 "Only Perspective and Orthographic cameras are supported.");
3037 XtPointer client_data,
3050 Widget nameViewPtDialog;
3051 Widget parent = This->getParentWidget();
3052 XmString label = XmStringCreateLocalized((
char *)
"Name the viewpoint:");
3054 XtSetArg(args[n], XmNselectionLabelString, label); n++;
3056 XtSetArg(args[n], XmNautoUnmanage, False); n++;
3058 XtSetArg(args[n], XmNtitle,
"Save Bookmark"); n++;
3059 nameViewPtDialog = XmCreatePromptDialog(parent, String(
"Save Bookmark"),
3062 XmStringFree(label);
3063 XtAddCallback(nameViewPtDialog, XmNokCallback,
getViewPtNameCB, This);
3064 XtAddCallback(nameViewPtDialog, XmNcancelCallback,
3069 Widget text = XtNameToWidget(nameViewPtDialog,
"Text");
3070 XtVaSetValues(text, XmNmaxLength, This->
MAX_VP_NAME, NULL);
3071 std::string autoName =
"";
3076 XmTextSetString(text, (
char *) autoName.c_str());
3077 XmTextSetInsertionPosition(text, autoName.length());
3079 XtUnmanageChild(XtNameToWidget(nameViewPtDialog,
"Help"));
3080 XtManageChild(nameViewPtDialog);
3087 std::stringstream sstream;
3088 std::vector<int> existingViewPts;
3092 for (
unsigned int i = 0; i < this->
viewPtList.size(); ++i) {
3094 if (viewPt.find(
"viewpoint_") != std::string::npos) {
3095 tmp = atoi(viewPt.substr(10).c_str());
3098 if (!viewPt.compare(
"viewpoint_0"))
3099 existingViewPts.push_back(0);
3101 existingViewPts.push_back(tmp);
3109 if (existingViewPts.size() > 0) {
3112 if (std::find(existingViewPts.begin(), existingViewPts.end(), vpNum)
3113 == existingViewPts.end()) {
3114 sstream <<
"viewpoint_" << vpNum;
3115 return sstream.str();
3120 return "viewpoint_0";
3127 XtPointer client_data,
3138 XtPointer client_data,
3145 if(This->isViewing())
3146 This->setViewing(
false);
3147 This->setComponentCursor(SoXtCursor(SoXtCursor::CROSSHAIR));
3153 XtPointer client_data,
3159 if (XmToggleButtonGetState(w)) {
3160 This->setDrawStyle(SoXtViewer::STILL, SoXtViewer::VIEW_LINE);
3161 This->setDrawStyle(SoXtViewer::INTERACTIVE, SoXtViewer::VIEW_LINE);
3163 This->setDrawStyle(SoXtViewer::STILL, SoXtViewer::VIEW_AS_IS);
3164 This->setDrawStyle(SoXtViewer::INTERACTIVE,
3165 SoXtViewer::VIEW_SAME_AS_STILL);
3173 XtPointer client_data,
3174 XtPointer call_data)
3177 std::string strName;
3179 XmSelectionBoxCallbackStruct *cbs =
3180 (XmSelectionBoxCallbackStruct *) call_data;
3181 XmStringGetLtoR(cbs->value, XmFONTLIST_DEFAULT_TAG, &name);
3194 int beg = strName.find_first_not_of(
' ');
3195 int end = strName.find_last_not_of(
' ');
3196 strName = strName.substr(beg, end - beg + 1);
3198 bool nameExists =
false;
3200 for (
int i = 0; i < size; i++) {
3201 if (!strcmp(This->
viewPtList[i].viewPtName, strName.c_str())) {
3209 name =
new char[nVPName];
3210 strncpy(name, strName.c_str(), nVPName);
3215 XmListAddItemUnselected(This->
myViewPtList, cbs->value, 0);
3220 String dialogName = (
char *)
"Existing Viewpoint";
3221 std::string msg =
"The viewpoint already exists.";
3242 SoCamera * camera = getCamera();
3250 tmp.viewPtName =
name;
3251 tmp.viewportMapping = camera->viewportMapping.getValue();
3252 tmp.position = camera->position.getValue();
3253 tmp.orientation = camera->orientation.getValue();
3254 tmp.aspectRatio = camera->aspectRatio.getValue();
3255 tmp.nearDistance = camera->nearDistance.getValue();
3256 tmp.farDistance = camera->farDistance.getValue();
3257 tmp.focalDistance = camera->focalDistance.getValue();
3260 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
3261 tmp.height = ((SoPerspectiveCamera *) camera)->heightAngle.getValue();
3263 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
3264 tmp.height = ((SoOrthographicCamera *) camera)->height.getValue();
3267 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::saveViewPtCB",
3268 "Only Perspective and Orthographic cameras are supported.");
3275 std::string vpName =
name;
3280 fileOut << vpName << std::endl;
3281 tmp.position.getValue(x, y, z);
3282 fileOut << x <<
" " << y <<
" " << z << std::endl;
3285 tmp.orientation.getValue(axis, angle);
3286 axis.getValue(x, y, z);
3287 fileOut << x <<
" " << y <<
" " << z <<
" " << angle << std::endl;
3289 fileOut << tmp.camType <<
" " << tmp.height << std::endl;
3290 fileOut << tmp.focalDistance <<
" ";
3291 fileOut << tmp.nearDistance <<
" ";
3292 fileOut << tmp.farDistance << std::endl;
3293 fileOut << tmp.viewportMapping <<
" ";
3294 fileOut << tmp.aspectRatio <<
"\n" << std::endl;
3301 XtPointer client_data,
3318 std::ofstream out(
"temporaryFile.txt");
3324 XmString vpNameStr = XmStringCreateLocalized(vpName);
3327 XmStringFree(vpNameStr);
3331 out << line <<
"\n";
3333 while (getline(
fileIn, line)) {
3334 end = line.find_last_not_of(
' ');
3335 line = line.substr(0, end + 1);
3336 if (!strcmp(line.c_str(), vpName)) {
3337 while (line.size()) {
3341 while (getline(
fileIn, line))
3342 out << line <<
"\n";
3344 while (line.size()) {
3345 out << line <<
"\n";
3354 while (idx < size) {
3355 if (!strcmp(
viewPtList[idx].viewPtName, vpName)) {
3368 int istat =
remove(
fileName.c_str());
3370 char dialogName[] =
"Warning";
3374 istat = rename(
"temporaryFile.txt",
fileName.c_str());
3376 char dialogName[] =
"Warning";
3381 fileOut.seekp(0, std::ios::end);
3401 int idx = 0, end,
pos;
3403 std::string line, newName;
3412 while (getline(
fileIn, line)) {
3413 end = line.find_last_not_of(
' ');
3414 line = line.substr(0, end + 1);
3418 fileOut.seekp(0, std::ios::end);
3429 while (idx < size) {
3445 int sortIdx = 0, unsortIdx = 0;
3454 int size = sortedViewPts.size();
3455 while (sortIdx < size) {
3456 while (strcmp(sortedViewPts[sortIdx].c_str(),
3460 std::string vpName =
viewPtList[unsortIdx].viewPtName;
3464 fileOut << vpName << std::endl;
3465 viewPtList[unsortIdx].position.getValue(x, y, z);
3466 fileOut << x <<
" " << y <<
" " << z << std::endl;
3469 viewPtList[unsortIdx].orientation.getValue(axis, angle);
3470 axis.getValue(x, y, z);
3471 fileOut << x <<
" " << y <<
" " << z <<
" " << angle << std::endl;
3474 <<
viewPtList[unsortIdx].height << std::endl;
3507 while (getline(
fileIn, token)) {
3509 int end = token.find_last_not_of(
' ');
3510 token = token.substr(0, end + 1);
3512 char *vpName =
new char[token.size() + 1];
3513 strcpy(vpName, token.c_str());
3514 tmp.viewPtName = vpName;
3517 parseString<float>(
x, token,
error);
3519 parseString<float>(
y, token,
error);
3521 parseString<float>(
z, token,
error);
3523 tmp.position = axis.setValue(x, y, z);
3525 parseString<float>(
x, token,
error);
3527 parseString<float>(
y, token,
error);
3529 parseString<float>(
z, token,
error);
3533 orient.setValue(axis.setValue(x, y, z),
angle);
3534 tmp.orientation = orient.getValue();
3537 parseString<int>(camType, token,
error);
3541 parseString<float>(tmp.height, token,
error);
3543 parseString<float>(tmp.focalDistance, token,
error);
3545 parseString<float>(tmp.nearDistance, token,
error);
3547 parseString<float>(tmp.farDistance, token,
error);
3549 parseString<int>(tmp.viewportMapping, token,
error);
3551 parseString<float>(tmp.aspectRatio, token,
error);
3574 std::istringstream str(s);
3575 if ((str >> t).fail())
3583 std::string dialogName,
3584 std::string buttonLabel,
3585 XtCallbackProc cbOK)
3589 Widget parent, scrollWidget;
3590 parent = SoXt::getShellWidget(getParentWidget());
3592 if (dialog == NULL) {
3595 XmString str = XmStringCreateLocalized((
char *) buttonLabel.c_str());
3598 XtSetArg(args[n], XmNokLabelString, str); n++;
3599 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3601 dialog = XmCreateFileSelectionDialog(parent,
3602 (
char *) dialogName.c_str(), args,
n);
3604 XtAddCallback(dialog, XmNokCallback, cbOK,
this);
3608 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_DIR_LIST);
3611 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_LIST);
3615 XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
3618 XtManageChild(dialog);
3635 XtPointer client_data,
3646 XtPointer client_data,
3647 XtPointer call_data)
3651 XmFileSelectionBoxCallbackStruct *cbs =
3652 (XmFileSelectionBoxCallbackStruct *) call_data;
3656 if (!(file = (
char *) XmStringUnparse(cbs->value,
3657 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3659 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::fileSelectedCB",
3660 "Internal error during file opening");
3665 if (!This->
fileIn.fail()) {
3669 String dialogName = (
char *)
"Error Loading File";
3670 std::string msg =
"Wrong or corrupted input file.";
3675 This->
fileOut.seekp(0, std::ios::end);
3682 std::string newDialogName = This->
fileName.substr(
3685 (
char *) newDialogName.c_str(), NULL);
3702 String dialogName = (
char *)
"Nonexistent File";
3703 std::string msg =
"Unable to open file.";
3723 viewPts = (XmString *) XtMalloc(size *
sizeof(XmString));
3724 for (
int i = 0; i < size; i++)
3725 viewPts[i] = XmStringCreateLocalized(
viewPtList[i].viewPtName);
3727 XmListAddItemsUnselected(
myViewPtList, viewPts, size, 1);
3729 if (viewPts != NULL) {
3730 for (
int i = 0; i < size; i++)
3731 XmStringFree(viewPts[i]);
3732 XtFree((
char *) viewPts);
3762 XmString warningMsg;
3764 warningMsg = XmStringCreateLocalized((
char *)msg.c_str());
3767 XtSetArg(args[n], XmNmessageString, warningMsg); n++;
3768 Widget warningDialog = XmCreateWarningDialog(getParentWidget(), dialogName, args, n);
3770 XtAddCallback(warningDialog, XmNokCallback, cb,
this);
3772 XmStringFree(warningMsg);
3774 XtVaSetValues (warningDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
3775 XtUnmanageChild(XtNameToWidget(warningDialog,
"Help"));
3776 XtUnmanageChild(XtNameToWidget(warningDialog,
"Cancel"));
3778 XtManageChild(warningDialog);
3783 XtPointer client_data,
3794 XtPointer client_data,
3795 XtPointer call_data)
3800 XmFileSelectionBoxCallbackStruct *cbs =
3801 (XmFileSelectionBoxCallbackStruct *) call_data;
3805 if (!(file = (
char *) XmStringUnparse(cbs->value,
3806 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3808 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::createNewVPFileCB",
3809 "Internal error during file opening");
3816 if (This->
fileIn.fail()) {
3830 String dialogName = (
char *)
"Existing File";
3831 std::string msg =
"'" + fName +
"' already exists. Do you want to overwrite it?";
3842 XtPointer client_data,
3862 XtPointer client_data,
3873 XtPointer client_data,
3874 XtPointer call_data)
3878 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
3883 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3884 XmCHARSET_TEXT, XmCHARSET_TEXT,
3885 NULL, 0, XmOUTPUT_ALL);
3887 std::ifstream ifs(file);
3891 while(ifs >> x >> y >> z){
3898 String dialogName = (
char *)
"Problem reading file";
3899 std::string msg =
"Problem reading file";
3911 XtPointer client_data,
3917 String dialogName = (
char *)
"No Reference Trajectory";
3918 std::string msg =
"You need to start a run or load a reference trajectory from a file";
3925 Widget parent, scrollWidget;
3926 parent = SoXt::getShellWidget(This->getParentWidget());
3931 XmString str = XmStringCreateLocalized((
char *)
"Save");
3934 XtSetArg(args[n], XmNokLabelString, str); n++;
3935 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3937 This->
saveRefCoordsDialog = XmCreateFileSelectionDialog(parent,(
char *)
"Save Ref Coords", args, n);
3962 XtPointer client_data,
3963 XtPointer call_data)
3967 XmFileSelectionBoxCallbackStruct *cbs =
3968 (XmFileSelectionBoxCallbackStruct *) call_data;
3973 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3974 XmCHARSET_TEXT, XmCHARSET_TEXT,
3975 NULL, 0, XmOUTPUT_ALL);
3977 std::ifstream ifile(file);
3982 Widget parent = This->getParentWidget();
3983 Widget confirmOverwriteDialog;
3986 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite", args, 0);
3987 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
3988 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
3993 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
4003 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
4004 XtManageChild(confirmOverwriteDialog);
4010 std::ofstream ofs(file);
4015 ofs << x <<
" " << y <<
" " << z <<
"\n";
4021 String dialogName = (
char *)
"Error opening file";
4022 std::string msg =
"There was a problem trying to open the file '";
4036 XtPointer client_data,
4037 XtPointer call_data)
4039 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
4042 switch (cbs->reason) {
4052 ofs << x <<
" " << y <<
" " << z <<
"\n";
4059 String dialogName = (
char *)
"Error opening file";
4060 std::string msg =
"There was a problem trying to open the file '";
4074 XmProcessTraversal(XtNameToWidget(This->
saveRefCoordsWidget,
"Text"), XmTRAVERSE_CURRENT);
4088 XtPointer client_data,
4100 XtPointer client_data,
4101 XtPointer call_data)
4105 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
4109 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4110 XmCHARSET_TEXT, XmCHARSET_TEXT,
4111 NULL, 0, XmOUTPUT_ALL);
4114 if (!sceneInput.openFile(file)) {
4115 String dialogName = (
char *)
"Problem opening file";
4116 std::string msg =
"Cannot open file ";
4120 sceneInput.closeFile();
4126 String dialogName = (
char *)
"Problem reading file";
4127 std::string msg =
"Problem reading file";
4141 XtPointer client_data,
4148 Widget parent, scrollWidget;
4149 parent = SoXt::getShellWidget(This->getParentWidget());
4154 XmString str = XmStringCreateLocalized((
char *)
"Save");
4157 XtSetArg(args[n], XmNokLabelString, str); n++;
4158 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
4160 This->
saveSceneGraphDialog = XmCreateFileSelectionDialog(parent,(
char *)
"Save Scene Graph", args, n);
4186 XtPointer client_data,
4187 XtPointer call_data)
4191 XmFileSelectionBoxCallbackStruct *cbs =
4192 (XmFileSelectionBoxCallbackStruct *) call_data;
4196 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4197 XmCHARSET_TEXT, XmCHARSET_TEXT,
4198 NULL, 0, XmOUTPUT_ALL);
4200 std::ifstream ifile(file);
4205 Widget parent = This->getParentWidget();
4206 Widget confirmOverwriteDialog;
4209 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite", args, 0);
4210 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
4211 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
4216 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
4226 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
4227 XtManageChild(confirmOverwriteDialog);
4233 SoWriteAction writeAction;
4234 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4236 SoOutput * out = writeAction.getOutput();
4238 if(out->openFile(file)){
4239 out->setBinary(
FALSE);
4240 writeAction.apply(root);
4246 String dialogName = (
char *)
"Error opening file";
4247 std::string msg =
"There was a problem trying to open the file '";
4263 XtPointer client_data,
4264 XtPointer call_data)
4266 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
4269 switch (cbs->reason) {
4274 SoWriteAction writeAction;
4275 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4277 SoOutput * out = writeAction.getOutput();
4279 out->setBinary(
FALSE);
4280 writeAction.apply(root);
4289 String dialogName = (
char *)
"Error opening file";
4290 std::string msg =
"There was a problem trying to open the file '";
4322 XtPointer client_data,
4323 XtPointer call_data)
4327 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
4329 vpName = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
4330 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4333 if (!strcmp(This->
viewPtList[i].viewPtName, vpName)) {
4348 XtPointer client_data,
4356 XmString vpNameStr = XmStringCreateLocalized(vpName);
4363 XmStringFree(vpNameStr);
4370 XtPointer client_data,
4373 std::string vpNameStr;
4375 int *pos_list, pos_cnt;
4380 if (!strlen(vpName) || !strcmp(This->
curViewPtName, vpName)) {
4387 int beg = vpNameStr.find_first_not_of(
' ');
4388 int end = vpNameStr.find_last_not_of(
' ');
4389 vpNameStr = vpNameStr.substr(beg, end - beg + 1);
4390 const int nVPName = vpNameStr.size() + 1;
4391 char* vpName1 =
new char[nVPName];
4392 strncpy(vpName1, vpNameStr.c_str(), nVPName);
4395 for (
int i = 0; i < size; i++) {
4396 if (!strcmp(vpName1, This->
viewPtList[i].viewPtName)) {
4398 String dialogName = (
char *)
"Existing Viewpoint";
4399 std::string msg =
"'";
4401 msg +=
"' already exists. Choose a different name";
4409 XmString vpNameXmStr = XmStringCreateLocalized(vpName1);
4411 if (XmListGetSelectedPos(This->
myViewPtList, &pos_list, &pos_cnt)) {
4412 XmListReplaceItemsPos(This->
myViewPtList, &vpNameXmStr, 1, pos_list[0]);
4414 XtFree((
char *) pos_list);
4418 This->scheduleRedraw();
4420 XmStringFree(vpNameXmStr);
4426 XtPointer client_data,
4431 XmString *strList, *newStrList;
4432 std::vector<std::string> charList;
4439 XtVaGetValues(This->
myViewPtList, XmNitemCount, &size, XmNitems, &strList,
4442 for (
int i = 0; i < size; i++) {
4443 vpName = (
char *) XmStringUnparse(strList[i], XmFONTLIST_DEFAULT_TAG,
4444 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4445 charList.push_back(vpName);
4449 std::sort(charList.begin(), charList.end());
4451 newStrList = (XmString *) XtMalloc(size *
sizeof(XmString));
4452 for (
int i = 0; i < size; i++) {
4456 const int nVPName = charList[i].size() + 1;
4457 char *vpName2 =
new char[nVPName];
4458 strncpy(vpName2, charList[i].c_str(), nVPName);
4459 newStrList[i] = XmStringCreateLocalized(vpName2);
4464 XmListAddItemsUnselected(This->
myViewPtList, newStrList, size, 1);
4468 if (newStrList != NULL) {
4469 for (
int i = 0; i < size; i++)
4470 XmStringFree(newStrList[i]);
4471 XtFree((
char *) newStrList);
4481 SbVec3f p1, p2, p3, dirNow, dirNxt,
dir, p2_tmp, p_start, p_corner, p_nxt;
4482 float avgDistBtwPts = 0;
4483 float totalDistBtwPts = 0;
4484 std::vector<SbVec3f> newRefParticleTrajectory;
4488 for (
int i = 0; i < size; i++) {
4494 totalDistBtwPts += (p2 - p1).
length();
4497 avgDistBtwPts = totalDistBtwPts / numOfPts;
4498 float minDistAllowed = 0.75 * avgDistBtwPts;
4508 p1.getValue(x, y, z);
4510 newRefParticleTrajectory.push_back(refPoint);
4513 while ((p2 - p1).
length() < minDistAllowed && j < (size - 1)) {
4533 XtPointer client_data,
4552 SoCamera *cam = getCamera();
4561 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4563 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
4565 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4567 ((SoOrthographicCamera *) cam)->height.getValue();
4575 SoCamera *cam = getCamera();
4585 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4589 ((SoOrthographicCamera *) cam)->height.setValue(
4592 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4594 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4598 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4601 ((SoOrthographicCamera *) cam)->height.setValue(
4610 SbTime curTime = SbTime::getTimeOfDay();
4612 SoTimerSensor *s = (SoTimerSensor *) sensor;
4614 float t = float((curTime - s->getBaseTime()).
getValue())
4617 if ((t > 1.0
f) || (t + s->getInterval().getValue() > 1.0f))
4619 SbBool end = (t == 1.0f);
4642 SbTime curTime = SbTime::getTimeOfDay();
4644 SoCamera *cam = This->getCamera();
4645 SoTimerSensor *s = (SoTimerSensor *) sensor;
4647 float t = float((curTime - s->getBaseTime()).
getValue())
4650 if ((t > 1.0
f) || (t + s->getInterval().getValue() > 1.0f))
4652 SbBool end = (t == 1.0f);
4682 if (SoXtExaminerViewer::isAnimating())
4686 SbVec3f p1, p2, p2_tmp, camUpV, camD, camD_tmp, leftRightAxis;
4704 p1.getValue(x1, y1, z1);
4705 p2.getValue(x2, y2, z2);
4710 p2_tmp.setValue(x2, y1, z2);
4711 camD_tmp = p2_tmp - p1;
4712 camD_tmp.normalize();
4714 camUpV.setValue(0, 1, 0);
4715 rot.setValue(camD_tmp, camD);
4716 rot.multVec(camUpV, camUpV);
4718 leftRightAxis = camD.cross(camUpV);
4720 myCam->position = p1;
4721 myCam->pointAt(p2, camUpV);
4725 myCam->position = p1;
4731 myCam->focalDistance = 0.1f;
4743 XtPointer client_data,
4749 String dialogName = (
char *)
"No Reference Trajectory";
4750 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4763 This->scheduleRedraw();
4770 if (This->SoXtExaminerViewer::isAnimating())
4771 This->stopAnimating();
4780 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
4783 This->scheduleRedraw();
4802 XtPointer client_data,
4821 XtPointer client_data,
4828 String dialogName = (
char *)
"No Reference Trajectory";
4829 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4839 This->
maxSpeed = SPEED_INDICATOR_STEP;
4840 This->
axisSwitch->whichChild.setValue(SO_SWITCH_ALL);
4843 This->scheduleRedraw();
4846 SoCamera *cam = This->getCamera();
4859 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4860 This->toggleCameraType();
4861 cam = This->getCamera();
4869 cam->focalDistance = 0.1f;
4870 ((SoPerspectiveCamera *) cam)->heightAngle = 0.50f;
4877 cam->orientation = (This->
myCam)->orientation.getValue();
4884 SoCamera *cam = getCamera();
4906 void (*callback)(
void *),
void *
object)
4942 #endif // G4VIS_BUILD_OIX_DRIVER