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>
79 #include "wheelmouse.h"
80 #include "SoXtInternal.h"
81 #include <Inventor/sensors/SoTimerSensor.h>
82 #include <Inventor/sensors/SoNodeSensor.h>
83 #include "saveViewPt.h"
89 #include "Geant4_SoPolyhedron.h"
96 #include <Inventor/nodes/SoCallback.h>
97 #include <Inventor/nodes/SoSwitch.h>
98 #include <Inventor/nodes/SoScale.h>
99 #include <Inventor/nodes/SoTranslation.h>
100 #include <Inventor/actions/SoSearchAction.h>
101 #include <Inventor/actions/SoGetBoundingBoxAction.h>
103 #include <Inventor/nodes/SoCoordinate3.h>
105 #include <Inventor/nodes/SoText2.h>
106 #include <Inventor/nodes/SoFont.h>
107 #include <Inventor/nodes/SoPointSet.h>
108 #include <Inventor/nodes/SoDrawStyle.h>
109 #include <Inventor/nodes/SoBaseColor.h>
112 #include <Inventor/nodekits/SoBaseKit.h>
115 #include <Inventor/SbVec3f.h>
121 #define MIN_SPEED 2.1 // Lower number means faster
122 #define START_STEP 0.3
123 #define SPEED_INDICATOR_STEP 0.045
124 #define MAX_SPEED_INDICATOR 0.81
130 const char *
name, SbBool embed,
131 SoXtFullViewer::BuildFlag flag, SoXtViewer::Type type) :
132 SoXtExaminerViewer(parent, name, embed, flag, type,
FALSE)
140 const char *
name, SbBool embed,
141 SoXtFullViewer::BuildFlag flag, SoXtViewer::Type type,
143 SoXtExaminerViewer(parent, name, embed, flag, type,
FALSE)
164 myCam =
new SoPerspectiveCamera;
200 static const char * superimposed[] = {
201 "#Inventor V2.1 ascii",
"",
208 " OrthographicCamera ",
214 " DEF soxt->callback Callback { }",
217 " DEF soxt->translation Translation ",
219 " translation 0 0 0",
221 " DEF soxt->scale Scale ",
223 " scaleFactor 1 1 1",
225 " DEF soxt->geometry Coordinate3 ",
229 " -0.81 -0.04 0, -0.81 0 0,",
230 " -0.81 0.04 0, 0 -0.04 0,",
232 " 0.81 -0.04 0, 0.81 0 0,",
235 " 0.81 0.02 0, 0.81 -0.02 0,",
238 " 0.4 0.01 0, 0.4 -0.01 0,",
243 " DEF soxt->animSpeedOutlineSwitch Switch ",
248 " emissiveColor 0 0 0",
254 " 12, 11, 10, 9, -1",
259 " DEF soxt->axisSwitch Switch ",
278 " DEF soxt->animSpeedSwitch Switch ",
283 " emissiveColor 0 1 0",
289 " 16, 15, 14, 13, -1",
295 " DEF soxt->curInfoSwitch Switch ",
298 " DEF soxt->curInfoTrans Translation ",
300 " translation 10 20 30 ",
302 " DEF soxt->curInfoFont Font ",
304 " name defaultFont:Bold",
307 " DEF soxt->curInfoText Text2 ",
316 " DEF soxt->mouseOverTransLogName Translation ",
318 " translation 0 0 0 ",
320 " DEF soxt->mouseOverFontLogName Font ",
322 " name defaultFont:Bold",
325 " DEF soxt->mouseOverTextLogName Text2 { } ",
329 " DEF soxt->mouseOverTransSolid Translation ",
331 " translation 0 0 0 ",
333 " DEF soxt->mouseOverFontSolid Font ",
335 " name defaultFont:Bold",
338 " DEF soxt->mouseOverTextSolid Text2 { } ",
342 " DEF soxt->mouseOverTransMaterial Translation ",
344 " translation 0 0 0 ",
346 " DEF soxt->mouseOverFontMaterial Font ",
348 " name defaultFont:Bold",
351 " DEF soxt->mouseOverTextMaterial Text2 { } ",
355 " DEF soxt->mouseOverTransZPos Translation ",
357 " translation 0 0 0 ",
359 " DEF soxt->mouseOverFontZPos Font ",
361 " name defaultFont:Bold",
364 " DEF soxt->mouseOverTextZPos Text2 { } ",
370 for (i = bufsize = 0; superimposed[i]; i++)
371 bufsize += strlen(superimposed[i]) + 1;
372 char * buf =
new char[bufsize + 1];
373 for (i = bufsize = 0; superimposed[i]; i++) {
374 strcpy(buf + bufsize, superimposed[i]);
375 bufsize += strlen(superimposed[i]);
379 SoInput * input =
new SoInput;
380 input->setBuffer(buf, bufsize);
439 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
474 this->
searcher =
new SoSearchAction;
477 searcher->setInterest(SoSearchAction::FIRST);
481 return searcher->getPath()->getTail();
498 if (!action->isOfType(SoGLRenderAction::getClassTypeId()))
500 SbViewportRegion vpRegion =
501 ((SoGLRenderAction *) action)->getViewportRegion();
502 SbVec2s viewportSize = vpRegion.getViewportSizePixels();
504 float aspect = float(viewportSize[0]) / float(viewportSize[1]);
505 float factorx = 1.0f / float(viewportSize[1]) * 220.0f;
506 float factory = factorx;
509 this->
stranslation->translation.setValue(SbVec3f(0.0f, -0.4f, 0.0f));
512 SbVec3f(0.0f, -0.4f / aspect, 0.0f));
516 if (viewportSize[0] > 500)
517 factorx *= 500.0f / 400.0f;
519 factorx *= float(viewportSize[0]) / 400.0f;
520 this->
sscale->scaleFactor.setValue(SbVec3f(factorx, factory, 1.0f));
522 float xInfo, yInfo, xMouseLogName, yMouseLogName, xMouseSolid, yMouseSolid,
523 xMouseMaterial, yMouseMaterial, xMouseZPos, yMouseZPos;
527 yMouseLogName = -.75;
530 xMouseMaterial = 0.0;
531 yMouseMaterial = -.81;
537 xMouseSolid *= aspect;
538 xMouseMaterial *= aspect;
539 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
541 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
543 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
545 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
547 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
550 yMouseSolid /= aspect;
551 yMouseMaterial /= aspect;
552 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
554 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
556 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
558 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
560 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
565 this->
curInfoFont->name.setValue(
"defaultFont:Italic");
570 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
576 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
579 this->
curInfoText->string.setValue(SbString(zPos));
608 Atom WM_DELETE_WINDOW;
611 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::buildWidget",
"Error: Parent is null.");
614 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
615 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
616 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
617 XtSetArg(args[3], XmNbottomAttachment, XmATTACH_FORM);
618 Widget form = XmCreateForm(parent, (
char *)
"Form", args, 4);
621 shell = XtParent(form);
622 WM_DELETE_WINDOW = XInternAtom(XtDisplay(parent),
"WM_DELETE_WINDOW",
624 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW,
627 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
628 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
629 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
630 menuBar = XmCreateMenuBar(form, (
char *)
"MenuBar", args, 3);
641 XmCreateSeparatorGadget(
fileMenu, (
char *)
"Separator", NULL, 0));
643 Widget menu =
addMenu(
"Tools");
648 Widget viewerBase = SoXtFullViewer::buildWidget(form);
650 XtSetArg(args[0], XmNtopAttachment, XmATTACH_WIDGET);
651 XtSetArg(args[1], XmNtopWidget,
menuBar);
652 XtSetArg(args[2], XmNleftAttachment, XmATTACH_FORM);
653 XtSetArg(args[3], XmNrightAttachment, XmATTACH_FORM);
654 XtSetArg(args[4], XmNbottomAttachment, XmATTACH_FORM);
655 XtSetValues(viewerBase, args, 5);
665 Widget menu = XmCreatePulldownMenu(
menuBar, (
char *) name.c_str(), NULL, 0);
667 XtSetArg(args[0], XmNsubMenuId, menu);
668 Widget w = XmCreateCascadeButton(
menuBar, (
char *) name.c_str(), args, 1);
679 Widget button = XmCreatePushButton(menu, (
char *) name.c_str(), NULL, 0);
680 XtManageChild(button);
681 XtAddCallback(button, XmNactivateCallback, cb,
this);
687 SbPList * buttonlist)
691 Widget saveViewPtButton, abbrOutputButton, pickRefPathButton;
694 SoXtExaminerViewer::createViewerButtons(parent, buttonlist);
697 Widget emptyButton = XtVaCreateManagedWidget(
"", xmPushButtonWidgetClass,
699 buttonlist->append(emptyButton);
703 XtSetArg(args[n], XmNtopPosition, 1); n++;
704 XtSetArg(args[n], XmNbottomPosition, 2); n++;
705 XtSetArg(args[n], XmNleftPosition, 0); n++;
706 XtSetArg(args[n], XmNrightPosition, 1); n++;
707 XtSetArg(args[n], XmNarrowDirection, XmARROW_LEFT); n++;
708 XtSetArg(args[n], XmNsensitive, False); n++;
718 XtSetArg(args[n], XmNtopPosition, 1); n++;
719 XtSetArg(args[n], XmNbottomPosition, 2); n++;
720 XtSetArg(args[n], XmNleftPosition, 0); n++;
721 XtSetArg(args[n], XmNrightPosition, 1); n++;
722 XtSetArg(args[n], XmNarrowDirection, XmARROW_RIGHT); n++;
723 XtSetArg(args[n], XmNsensitive, False); n++;
732 saveViewPtButton = XtVaCreateManagedWidget(
"Save", xmPushButtonWidgetClass,
734 XtAddCallback(saveViewPtButton, XmNactivateCallback,
736 Pixmap saveVP, saveVP_ins;
737 saveVP = SoXtInternal::createPixmapFromXpm(saveViewPtButton,
739 saveVP_ins = SoXtInternal::createPixmapFromXpm(saveViewPtButton,
740 saveViewPt_xpm,
TRUE);
741 XtVaSetValues(saveViewPtButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
742 saveVP, XmNselectPixmap, saveVP, XmNlabelInsensitivePixmap,
743 saveVP_ins, XmNselectInsensitivePixmap, saveVP_ins, NULL);
744 buttonlist->append(saveViewPtButton);
747 abbrOutputButton = XtVaCreateManagedWidget(
"Abbr",
748 xmToggleButtonWidgetClass, parent, XmNindicatorOn, False, NULL);
751 Pixmap pickextxpm, pickextxpm_ins;
752 pickextxpm = SoXtInternal::createPixmapFromXpm(abbrOutputButton,
754 pickextxpm_ins = SoXtInternal::createPixmapFromXpm(abbrOutputButton,
756 XtVaSetValues(abbrOutputButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
757 pickextxpm, XmNselectPixmap, pickextxpm, XmNlabelInsensitivePixmap,
758 pickextxpm_ins, XmNselectInsensitivePixmap, pickextxpm_ins, NULL);
767 buttonlist->append(abbrOutputButton);
770 pickRefPathButton = XtVaCreateManagedWidget(
"Refpath", xmPushButtonWidgetClass,
772 XtAddCallback(pickRefPathButton, XmNactivateCallback,
774 Pixmap pickrefxpm, pickrefxpm_ins;
775 pickrefxpm = SoXtInternal::createPixmapFromXpm(pickRefPathButton,
777 pickrefxpm_ins = SoXtInternal::createPixmapFromXpm(pickRefPathButton,
779 XtVaSetValues(pickRefPathButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
780 pickrefxpm, XmNselectPixmap, pickrefxpm, XmNlabelInsensitivePixmap,
781 pickrefxpm_ins, XmNselectInsensitivePixmap, pickrefxpm_ins, NULL);
790 buttonlist->append(pickRefPathButton);
799 SoXtExaminerViewer::afterRealizeHook();
803 SoCamera *cam = getCamera();
805 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
807 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
810 ((SoOrthographicCamera *) cam)->height.getValue();
814 ((SoOrthographicCamera *) cam)->height.getValue();
817 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
819 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
828 String dialogName = (
char *)
"Error Loading File";
829 std::string msg =
"Wrong or corrupted input file.";
834 fileOut.seekp(0, std::ios::end);
855 SoSeparator *root = (SoSeparator *) (getSceneManager()->getSceneGraph());
857 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::afterRealizeHook",
"Root is null.");
859 root->addChild(
myCam);
871 SoEventCallback *moCB =
new SoEventCallback;
872 moCB->addEventCallback(
873 SoLocation2Event::getClassTypeId(),
875 root->addChild(moCB);
879 SoEventCallback *pickCB =
new SoEventCallback;
880 pickCB->addEventCallback(
881 SoMouseButtonEvent::getClassTypeId(),
883 root->addChild(pickCB);
892 SoCamera *cam = getCamera();
899 cam->position = camPosNew;
901 cam->focalDistance = (
prevPt - camPosNew).length();
920 SoCamera *cam = getCamera();
933 cam->focalDistance = (cam->position.getValue() -
center).length();
942 dist = (
prevPt - cam->position.getValue()).length();
949 dist = (
prevPt - cam->position.getValue()).length();
958 particleDir = p2 - p1;
959 particleDir.normalize();
972 SbRotation rot(SbVec3f(0,0,1), particleDir);
986 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
993 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
1005 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1008 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
1009 camPosNew = p2 - (
camDir);
1012 cam->position = camPosNew;
1019 camPosNew.getValue(x,y,z);
1030 SoEventCallback *eventCB)
1032 SoHandleEventAction* action = eventCB->getAction();
1033 const SoPickedPoint *
pp = action->getPickedPoint();
1038 SoPath* path = pp->getPath();
1039 SoNode* node = ((SoFullPath*)path)->getTail();
1041 if(node->getTypeId() == SoLineSet::getClassTypeId()){
1048 This->setComponentCursor(SoXtCursor(SoXtCursor::DEFAULT));
1051 SoLineSet * trajectory = (SoLineSet *)node;
1057 SoSeparator * grpNode =
1058 (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
1063 int nodeIndex = grpNode->findChild(trajectory);
1066 SoCoordinate3 * coords = 0;
1070 for(
int i = 0; i < 100; ++i) {
1073 tmpNode = grpNode->getChild(nodeIndex);
1074 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
1076 coords = (SoCoordinate3 *)tmpNode;
1082 String dialogName = (
char *)
"No coordinates";
1083 std::string msg =
"Could not find the coordinates node"
1084 " for the picked trajectory."
1085 " Reference trajectory not set";
1102 if(attHolder && attHolder->
GetAttDefs().size()) {
1104 std::string strTrajPoint =
"G4TrajectoryPoint:";
1105 std::ostringstream oss;
1106 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1111 if(oss.str().find(strTrajPoint) != std::string::npos) {
1126 G4String cls((
char*)node->getTypeId().getName().getString());
1127 G4cout <<
"SoNode : " << node
1128 <<
" SoType : " << cls
1129 <<
" name : " <<
name
1146 if(attHolder && attHolder->
GetAttDefs().size()) {
1147 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1153 G4String cls((
char*)node->getTypeId().getName().getString());
1154 G4cout <<
"SoNode : " << node
1155 <<
" SoType : " << cls
1156 <<
" name : " <<
name
1162 eventCB->setHandled();
1169 SoHandleEventAction* action = eventCB->getAction();
1170 const SoPickedPoint*
pp = action->getPickedPoint();
1178 const SbViewportRegion & viewportRegion = action->getViewportRegion();
1180 std::string sLogName;
1182 std::stringstream ssZPos;
1183 std::stringstream ssSolids;
1184 std::stringstream ssMaterials;
1185 SoPath * path = pp->getPath();
1186 SoNode* node = ((SoFullPath*)path)->getTail();
1188 if(node->getTypeId() == Geant4_SoPolyhedron::getClassTypeId()) {
1190 sLogName =
"Logical Volume: ";
1191 sLogName += ((Geant4_SoPolyhedron *)node)->getName().getString();
1193 SoGetBoundingBoxAction bAction(viewportRegion);
1194 bAction.apply((SoFullPath*)path);
1195 SbBox3f bBox = bAction.getBoundingBox();
1196 SbVec3f
center = bBox.getCenter();
1197 center.getValue(x,y,z);
1198 ssZPos <<
"Pos: " << x <<
" " << y <<
" " << z;
1201 if(attHolder && attHolder->
GetAttDefs().size()) {
1203 std::vector<const std::map<G4String,G4AttDef>*> vecDefs =
1205 std::vector<const std::vector<G4AttValue>*> vecVals =
1207 for (
size_t i = 0; i < vecDefs.size(); ++i) {
1208 const std::vector<G4AttValue> * vals = vecVals[i];
1210 std::vector<G4AttValue>::const_iterator iValue;
1212 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1213 const G4String& valueName = iValue->GetName();
1214 const G4String& value = iValue->GetValue();
1216 if(valueName ==
"Solid") {
1217 if(ssSolids.str() ==
"")
1218 ssSolids <<
"Solid Name: " << value;
1220 ssSolids <<
", " << value;
1223 if(valueName ==
"Material") {
1224 if(ssMaterials.str() ==
"")
1225 ssMaterials <<
"Material Name: " << value;
1227 ssMaterials <<
", " << value;
1234 else if(node->getTypeId() == SoLineSet::getClassTypeId()) {
1237 if(attHolder && attHolder->
GetAttDefs().size()) {
1238 std::string strTrajPoint =
"G4TrajectoryPoint:";
1239 std::ostringstream oss;
1241 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1244 const std::vector<G4AttValue>* vals = attHolder->
GetAttValues()[i];
1245 std::vector<G4AttValue>::const_iterator iValue;
1246 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1247 const G4String& valueName = iValue->GetName();
1248 const G4String& value = iValue->GetValue();
1252 if (valueName ==
"PN") t1 = value;
1253 if (valueName ==
"Ch") {
1254 if (atof(value.c_str()) > 0)
1260 if (valueName ==
"PDG") {
1268 if (valueName ==
"EventID") t2 =
"Evt " + value;
1269 if (valueName ==
"ID") t2 +=
" Trk " + value;
1270 if (valueName ==
"PID") {
1271 t2 +=
" Prt " + value;
1275 if (valueName ==
"IKE") t3 =
"KE " + value;
1276 if (valueName ==
"IMom") {
1278 unsigned ipos = value.rfind(
" ");
1281 t3 +=
" P (" + value1 +
")";
1283 if (valueName ==
"IMag") {
1284 t3 +=
" " + value +
"/c";
1289 if (valueName ==
"NTP") {
1290 std::ostringstream t4oss;
1291 t4oss <<
"TrjPts " << value;
1292 t4oss <<
" Pos " << pp->getPoint()[0] <<
" " << pp->getPoint()[1] <<
1293 " " << pp->getPoint()[2];
1316 This->scheduleRedraw();
1317 eventCB->setHandled();
1321 bool redraw =
false;
1326 if(std::string(This->
mouseOverTextSolid->string.getValues(0)->getString()) != ssSolids.str()) {
1330 if(std::string(This->
mouseOverTextMaterial->string.getValues(0)->getString()) != ssMaterials.str()){
1334 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) != ssZPos.str()) {
1341 This->scheduleRedraw();
1344 eventCB->setHandled();
1349 This->scheduleRedraw();
1353 This->scheduleRedraw();
1357 This->scheduleRedraw();
1359 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) !=
"") {
1361 This->scheduleRedraw();
1368 SoCamera *cam = getCamera();
1369 const SoType type(ev->getTypeId());
1371 if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
1372 SoMouseButtonEvent * me = (SoMouseButtonEvent *) ev;
1376 switch (me->getButton()) {
1377 case SoMouseButtonEvent::BUTTON4:
1378 if (me->getState() == SoButtonEvent::DOWN) {
1379 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1381 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1382 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1385 }
else if (cam->isOfType(
1386 SoOrthographicCamera::getClassTypeId())) {
1388 ((SoOrthographicCamera *) cam)->height.getValue();
1389 ((SoOrthographicCamera *) cam)->height = height + 5;
1394 case SoMouseButtonEvent::BUTTON5:
1395 if (me->getState() == SoButtonEvent::DOWN) {
1396 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1398 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1400 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1403 }
else if (cam->isOfType(
1404 SoOrthographicCamera::getClassTypeId())) {
1406 ((SoOrthographicCamera *) cam)->height.getValue();
1408 ((SoOrthographicCamera *) cam)->height = height - 5;
1422 if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
1423 SoKeyboardEvent * ke = (SoKeyboardEvent *) ev;
1425 if (SoKeyboardEvent::isKeyPressEvent(ev, ke->getKey())) {
1426 switch (ke->getKey()) {
1427 case SoKeyboardEvent::LEFT_SHIFT:
1430 case SoKeyboardEvent::RIGHT_SHIFT:
1433 case SoKeyboardEvent::LEFT_CONTROL:
1436 case SoKeyboardEvent::RIGHT_CONTROL:
1439 case SoKeyboardEvent::SPACE:
1461 case SoKeyboardEvent::ESCAPE:
1477 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
1488 case SoKeyboardEvent::DELETE:
1493 String dialogName = (
char *)
"Delete Viewpoint";
1494 std::string msg =
"Are you sure you want to delete current viewpoint?";
1499 case SoKeyboardEvent::LEFT_ARROW:
1507 if (SoXtExaminerViewer::isAnimating())
1523 if (SoXtExaminerViewer::isAnimating())
1548 cam->position =
myCam->position;
1555 this->bottomWheelMotion(
1556 this->getBottomWheelValue() + 0.1f);
1566 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1567 "Unhandled viewer state");
1572 case SoKeyboardEvent::RIGHT_ARROW:
1580 if (SoXtExaminerViewer::isAnimating())
1594 if (SoXtExaminerViewer::isAnimating())
1616 cam->position =
myCam->position;
1623 this->bottomWheelMotion(
1624 this->getBottomWheelValue() - 0.1f);
1633 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1634 "Unhandled viewer state");
1639 case SoKeyboardEvent::DOWN_ARROW:
1648 if (SoXtExaminerViewer::isAnimating())
1671 cam->position =
myCam->position;
1678 this->leftWheelMotion(this->getLeftWheelValue() - 0.1f);
1687 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1688 "Unhandled viewer state");
1693 case SoKeyboardEvent::UP_ARROW:
1701 if (SoXtExaminerViewer::isAnimating())
1724 cam->position =
myCam->position;
1731 this->leftWheelMotion(this->getLeftWheelValue() + 0.1f);
1740 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1741 "Unhandled viewer state");
1746 case SoKeyboardEvent::PAGE_UP:
1797 case SoKeyboardEvent::PAGE_DOWN:
1845 case SoKeyboardEvent::E:
1853 if (SoKeyboardEvent::isKeyReleaseEvent(ev, ke->getKey())) {
1854 switch (ke->getKey()) {
1855 case SoKeyboardEvent::LEFT_SHIFT:
1858 case SoKeyboardEvent::RIGHT_SHIFT:
1861 case SoKeyboardEvent::LEFT_CONTROL:
1864 case SoKeyboardEvent::RIGHT_CONTROL:
1877 return SoXtExaminerViewer::processSoEvent(ev);
1893 if (refParticleIdx < lastIdx && !animateSensor->isScheduled())
1919 SbVec3f * points = this->
sgeometry->point.startEditing();
1921 if (points[10][0] == 0.0f)
1923 if (points[14][0] == 0.0f)
1943 SoXtExaminerViewer::actualRedraw();
1946 SoXtExaminerViewer::actualRedraw();
1992 SbVec3f refParticlePt;
1997 for(
int i = 0; i < lineset->numVertices.getNum(); ++i){
1998 for(
int j = 0; j < lineset->numVertices[i]; ++j){
1999 refParticlePt = coords->point[j];
2025 SoSearchAction action;
2026 action.setType(SoLineSet::getClassTypeId(),
false);
2028 action.apply(this->getSceneGraph());
2030 SoPathList &pathList = action.getPaths();
2032 if(pathList.getLength() != 0){
2034 SoCoordinate3 * coords = NULL;
2035 std::vector<SoCoordinate3 *> coordvec;
2036 std::vector<SoLineSet *> linevec;
2038 bool refPathFound =
false;
2039 for(
int i = 0; i < pathList.getLength(); ++i) {
2040 SoFullPath *path = (SoFullPath *)pathList[i];
2043 for (
size_t j = 0; j < attHolder->
GetAttDefs().size(); ++j) {
2044 std::ostringstream oss;
2047 std::string findStr =
"Type of trajectory (Type): ";
2048 std::string compareValue =
"REFERENCE";
2049 size_t idx = oss.str().find(findStr);
2051 if(idx != std::string::npos) {
2052 if(oss.str().substr(idx + findStr.size(), compareValue.size()) == compareValue) {
2055 refPathFound =
true;
2056 coordvec.push_back(coords);
2057 linevec.push_back((SoLineSet *)path->getTail());
2063 findStr =
"Track ID (ID): ";
2064 idx = oss.str().find(findStr);
2065 if(idx != std::string::npos) {
2067 std::string tmpstr = oss.str().substr(idx + findStr.size(),1);
2068 std::istringstream
buffer(tmpstr);
2076 char nextChar = oss.str().at(idx+findStr.size()+1);
2079 if(std::isdigit(nextChar))
2085 coordvec.push_back(coords);
2086 linevec.push_back((SoLineSet *)path->getTail());
2102 if(coordvec.empty())
2113 float longestLength = 0.0;
2115 for(
unsigned int i=0;i < linevec.size(); ++i){
2118 std::vector<SbVec3f> trajectory;
2120 for(
int j=0; j < linevec[i]->numVertices.getNum(); ++j){
2122 for(
int k=0; k < linevec[i]->numVertices[j]; ++k){
2123 trajectory.push_back(coordvec[i]->point[k]);
2128 float tmpLength=0.0;
2129 for(
unsigned int j=0; j < trajectory.size() - 1; ++j){
2130 tmpLength += (trajectory[j] - trajectory[j + 1]).length();
2133 if(tmpLength > longestLength){
2135 longestLength = tmpLength;
2147 SoLineSet *trajectory = (SoLineSet *)path->getTail();
2148 SoSeparator * grpNode = (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
2149 int nodeIndex = grpNode->findChild(trajectory);
2154 for(
int i = 0; i < 100; ++i){
2157 tmpNode = grpNode->getChild(nodeIndex);
2158 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
2160 return (SoCoordinate3 *)tmpNode;
2171 std::string field, eltName;
2173 std::map<std::string, int> duplicates;
2174 std::map<std::string, int> sceneElts;
2175 SoSearchAction search;
2176 Geant4_SoPolyhedron *node;
2177 SoGroup *root = (SoGroup *)getSceneManager()->getSceneGraph();
2179 SoBaseKit::setSearchingChildren(
TRUE);
2182 search.setSearchingAll(
TRUE);
2184 search.setType(Geant4_SoPolyhedron::getClassTypeId(), 0);
2187 SoPathList &pl = search.getPaths();
2191 for(
int i = 0; i < pl.getLength(); i++) {
2192 SoFullPath *path = (SoFullPath *)pl[i];
2193 node = (Geant4_SoPolyhedron *)path->getTail();
2194 eltName = node->getName();
2195 if(duplicates.count(eltName))
2196 duplicates[eltName]++;
2198 duplicates[eltName] = 1;
2201 for(
int i = 0; i < pl.getLength(); i++) {
2203 std::stringstream ssCount;
2204 SoFullPath *path = (SoFullPath *)pl[i];
2205 node = (Geant4_SoPolyhedron *)path->getTail();
2206 eltName = node->getName();
2208 if(duplicates[eltName] == 1)
2211 if(sceneElts.count(eltName))
2212 sceneElts[eltName]++;
2214 sceneElts[eltName] = 1;
2216 ssCount << sceneElts[eltName];
2220 field += ssCount.str();
2222 SoGetBoundingBoxAction bAction(getViewportRegion());
2223 bAction.apply(path);
2224 SbBox3f bBox = bAction.getBoundingBox();
2226 SbVec3f centr = bBox.getCenter();
2227 centr.getValue(x,y,z);
2240 return x*x + y*y + z*z;
2246 SbVec3f &closestPoint,
2285 SbVec3f dbq = b - q;
2286 float sqrDist =
sqrlen(dbq);
2289 for (
size_t i = 1; i < count; ++i) {
2290 const SbVec3f
a = b;
2291 const SbVec3f daq = dbq;
2294 const SbVec3f dab = a - b;
2296 float dab_x, dab_y, dab_z;
2297 dab.getValue(dab_x,dab_y,dab_z);
2298 float daq_x, daq_y, daq_z;
2299 daq.getValue(daq_x, daq_y, daq_z);
2300 float dbq_x, dbq_y, dbq_z;
2301 dbq.getValue(dbq_x, dbq_y, dbq_z);
2303 const float inv_sqrlen = 1./
sqrlen(dab);
2304 const float t = (dab_x*daq_x + dab_y*daq_y + dab_z*daq_z)*inv_sqrlen;
2315 current_dist = daq_x*daq_x + daq_y*daq_y + daq_z*daq_z
2316 - t*(daq_x*dab_x + daq_y*dab_y + daq_z*dab_z)
2317 + t*t*(dab_x*dab_x + dab_y*dab_y + dab_z*dab_z);
2322 current_dist =
sqrlen(dbq);
2325 if (current_dist < sqrDist){
2326 sqrDist = current_dist;
2327 closestPoint = a + t*(b-
a);
2332 dist = std::sqrt(sqrDist);
2342 typedef std::map<elementForSorting, sceneElement> sortedMap;
2351 trajLength[trajIndex] = 0.0;
2355 trajLength[trajIndex] = trajLength[trajIndex-1] + (*itRef - prevPoint).length();
2363 SoGetBoundingBoxAction bAction(this->getViewportRegion());
2364 SbVec3f elementCoord;
2365 std::vector<sceneElement>::iterator itEl;
2370 bAction.apply(itEl->path);
2373 elementCoord = itEl->center;
2391 sorted.insert(std::make_pair(el,*itEl));
2397 sortedMap::iterator itSorted = sorted.begin();
2398 for(; itSorted != sorted.end(); itSorted++)
2404 Widget formTop = XtNameToWidget(this->
listsDialog,
"FormTop");
2405 Widget formTopRight = XtNameToWidget(formTop,
"FormTopRight");
2409 delete[] trajLength;
2419 XmString *elements = (XmString *) XtMalloc(size *
sizeof(XmString));
2421 std::vector<sceneElement>::const_iterator it;
2423 std::stringstream ss;
2427 ss <<
" [" << it->closestPointZCoord <<
"]";
2428 elements[count] = XmStringCreateLocalized((
char *)ss.str().c_str());
2439 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2441 labelRight = XmCreateLabelGadget(formTopRight, (
char*)
"Element [S mm]",
2443 XtManageChild(labelRight);
2447 XtSetArg(args[n], XmNvisibleItemCount, 7); n++;
2448 XtSetArg(args[n], XmNitemCount, size); n++;
2449 XtSetArg(args[n], XmNitems, elements); n++;
2450 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2451 XtSetArg(args[n], XmNtopWidget, labelRight); n++;
2452 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2453 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2455 XtSetArg(args[n], XmNwidth, 240); n++;
2459 this->
myElementList = XmCreateScrolledList(formTopRight, (
char *)
"ListRight", args, n);
2461 XtAddCallback(this->
myElementList, XmNbrowseSelectionCallback,
2466 if (elements != NULL) {
2467 for (
int i = 0; i < size; i++)
2468 XmStringFree(elements[i]);
2469 XtFree((
char *) elements);
2478 XtPointer client_data,
2505 Atom WM_DELETE_WINDOW;
2517 std::string dialogNameStr = This->
fileName.substr(This->
fileName.rfind(
'/') + 1);
2518 const int nDialog = dialogNameStr.size() + 1;
2519 char *dialogName =
new char[nDialog];
2520 strncpy(dialogName, dialogNameStr.c_str(), nDialog);
2523 XtSetArg(args[n], XmNx, 610); n++;
2524 This->
myShellDialog = XmCreateDialogShell(topShell, dialogName, args, n);
2526 delete[] dialogName;
2527 WM_DELETE_WINDOW = XInternAtom(XtDisplay(w),
"WM_DELETE_WINDOW", False);
2528 XmAddWMProtocolCallback(This->
myShellDialog, WM_DELETE_WINDOW,
2533 XtSetArg(args[n], XmNsashWidth, 1); n++;
2534 XtSetArg(args[n], XmNsashHeight, 1); n++;
2535 XtSetArg(args[n], XmNseparatorOn, False); n++;
2545 Widget formTop = XmCreateForm(This->
listsDialog, (
char *)
"FormTop", args, n);
2548 XtSetArg(args[n], XmNmarginWidth, 8); n++;
2549 XtSetArg(args[n], XmNmarginHeight, 8); n++;
2550 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2551 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2552 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2553 Widget formTopRight = XmCreateForm(formTop, (
char *)
"FormTopRight", args,
2557 XtSetArg(args[n], XmNmarginWidth, 8); n++;
2558 XtSetArg(args[n], XmNmarginHeight, 8); n++;
2559 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2560 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2561 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2562 XtSetArg(args[n], XmNrightWidget, formTopRight); n++;
2563 XtSetArg(args[n], XmNrightOffset, 10); n++;
2564 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2565 Widget formTopLeft = XmCreateForm(formTop, (
char *)
"FormTopLeft", args, n);
2570 XtManageChild(formTopRight);
2576 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2577 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2578 Widget labelLeft = XmCreateLabelGadget(formTopLeft, (
char *)
"ViewPoints",
2580 XtManageChild(labelLeft);
2584 XtSetArg(args[n], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); n++;
2585 XtSetArg(args[n], XmNvisibleItemCount, 7); n++;
2587 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2588 XtSetArg(args[n], XmNtopWidget, labelLeft); n++;
2589 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2590 XtSetArg(args[n], XmNrightWidget, This->
myElementList); n++;
2591 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2592 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2594 XtSetArg(args[n], XmNwidth, 160); n++;
2597 This->
myViewPtList = XmCreateScrolledList(formTopLeft, (
char *)
"ListLeft",
2601 XtAddCallback(This->
myViewPtList, XmNbrowseSelectionCallback,
2607 XtManageChild(formTopLeft);
2609 XtManageChild(formTop);
2613 XtSetArg(args[n], XmNmarginWidth, 6); n++;
2616 Widget formMiddle = XmCreateForm(This->
listsDialog, (
char *)
"MiddleForm", args, n);
2620 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2621 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2622 XtSetArg(args[n], XmNtopWidget, This->
myViewPtList); n++;
2623 Widget label = XmCreateLabelGadget(formMiddle, (
char *)
"Selection", args,
2625 XtManageChild(label);
2629 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2630 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2631 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2632 XtSetArg(args[n], XmNtopWidget, label); n++;
2633 XtSetArg(args[n], XmNtopOffset, 3); n++;
2634 XtSetArg(args[n], XmNmaxLength, This->
MAX_VP_NAME); n++;
2635 This->
viewPtSelection = XmCreateText(formMiddle, (
char *)
"Txt", args, n);
2638 Dimension h1, h2, h;
2639 XtVaGetValues(label, XmNheight, &h1, NULL);
2642 h = (Dimension) (1.1 * (h1 + h2));
2644 XtVaSetValues(formMiddle, XmNpaneMaximum, h, XmNpaneMinimum, h, NULL);
2645 XtManageChild(formMiddle);
2650 XtSetArg(args[n], XmNfractionBase, 4); n++;
2651 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2655 Widget formAction = XmCreateForm(This->
listsDialog, (
char *)
"ActionForm", args, n);
2658 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2659 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2660 XtSetArg(args[n], XmNtopOffset, 3); n++;
2661 XtSetArg(args[n], XmNbottomOffset, 5); n++;
2662 Widget separator = XmCreateSeparatorGadget(formAction, (
char *)
"Sep", args, n);
2664 XtManageChild(separator);
2666 Widget button = XmCreatePushButton(formAction, (
char *)
"Delete", NULL, 0);
2667 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2668 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2669 XmATTACH_POSITION, XmNleftPosition, 0, XmNrightAttachment,
2670 XmATTACH_POSITION, XmNrightPosition, 1,
2671 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2674 XtAddCallback(button, XmNactivateCallback,
2676 XtManageChild(button);
2678 button = XmCreatePushButton(formAction, (
char *)
"Rename", NULL, 0);
2679 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2680 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2681 XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment,
2682 XmATTACH_POSITION, XmNrightPosition, 2,
2683 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2686 XtAddCallback(button, XmNactivateCallback,
2688 XtManageChild(button);
2690 button = XmCreatePushButton(formAction, (
char *)
"Sort", NULL, 0);
2691 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2692 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2693 XmATTACH_POSITION, XmNleftPosition, 2, XmNrightAttachment,
2694 XmATTACH_POSITION, XmNrightPosition, 3,
2695 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2698 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)
sortBookmarksCB, This);
2699 XtManageChild(button);
2701 button = XmCreatePushButton(formAction, (
char *)
"Close", NULL, 0);
2702 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2703 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2704 XmATTACH_POSITION, XmNleftPosition, 3, XmNrightAttachment,
2705 XmATTACH_POSITION, XmNrightPosition, 4,
2706 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2709 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc) closeListsDialogCB, This);
2710 XtManageChild(button);
2712 XtManageChild(formAction);
2713 XtVaGetValues(button, XmNheight, &h1, NULL);
2714 XtVaSetValues(formAction, XmNpaneMaximum, h1, XmNpaneMinimum, h1, NULL);
2725 XtPointer client_data,
2726 XtPointer call_data)
2729 std::string elementField;
2731 SoCamera * cam = This->getCamera();
2733 if (This->SoXtExaminerViewer::isAnimating())
2734 This->stopAnimating();
2736 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
2738 value = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
2739 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
2746 This->scheduleRedraw();
2752 elementField = value;
2754 int idx = elementField.find_last_of(
"[");
2756 idx = elementField.size();
2762 SoSearchAction search;
2763 SoNode *root = This->getSceneManager()->getSceneGraph();
2764 int counter, idxUnderscore = elementField.find_last_of(
"_");
2766 This->
parseString<
int>(counter, elementField.substr(idxUnderscore + 1, idx),
error);
2768 SoBaseKit::setSearchingChildren(
TRUE);
2770 search.setSearchingAll(
TRUE);
2773 This->
curEltName = elementField.substr(0, idx);
2777 path = (SoFullPath *)search.getPath();
2780 This->
curEltName = elementField.substr(0, idxUnderscore);
2785 SoPathList &pl = search.getPaths();
2786 path = (SoFullPath *)pl[counter - 1];
2791 if ((idx > 0) && (path)) {
2795 SoGetBoundingBoxAction bAction(This->getViewportRegion());
2796 bAction.apply(path);
2797 SbBox3f bBox = bAction.getBoundingBox();
2798 SbVec3f elementCoord = bBox.getCenter();
2803 float absLengthNow, absLengthMin;
2809 absLengthMin = (p - elementCoord).length();
2815 absLengthNow = (p - elementCoord).length();
2817 if (absLengthNow < absLengthMin) {
2818 absLengthMin = absLengthNow;
2831 This->
distance = (pN - p1).length() / 10;
2834 if (cam->isOfType(SoOrthographicCamera::getClassTypeId()))
2835 ((SoOrthographicCamera *) cam)->height.setValue(This->
defaultHeight);
2837 else if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2838 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
2841 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2842 This->
distance = (This->
prevPt - cam->position.getValue()).length();
2848 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
2851 This->scheduleRedraw();
2864 cam->viewAll(path, This->getViewportRegion());
2875 XtPointer client_data,
2922 std::stringstream out;
2925 fileOut.seekp(0, std::ios::beg);
2933 fileOut.seekp(0, std::ios::end);
2951 SoCamera * camera = getCamera();
2952 if (camera == NULL) {
2953 String dialogName = (
char *)
"Missing Camera Node";
2954 std::string msg =
"Camera is null. Unable to set the viewpoint.";
2960 String dialogName = (
char *)
"Missing Viewpoints";
2961 std::string msg =
"There are no viewpoints to load.";
2966 if (SoXtExaminerViewer::isAnimating())
2973 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
2991 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
2994 camera = getCamera();
2995 ((SoOrthographicCamera *) camera)->height.setValue(
2998 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
3000 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
3003 camera = getCamera();
3004 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
3007 ((SoOrthographicCamera *) camera)->height.setValue(
3010 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::setViewPt",
3011 "Only Perspective and Orthographic cameras are supported.");
3021 XtPointer client_data,
3034 Widget nameViewPtDialog;
3035 Widget parent = This->getParentWidget();
3036 XmString label = XmStringCreateLocalized((
char *)
"Name the viewpoint:");
3038 XtSetArg(args[n], XmNselectionLabelString, label); n++;
3039 XtSetArg(args[n], XmNautoUnmanage, False); n++;
3043 nameViewPtDialog = XmCreatePromptDialog(parent, (
char *)
"Save Viewpoint",
3046 XmStringFree(label);
3047 XtAddCallback(nameViewPtDialog, XmNokCallback,
getViewPtNameCB, This);
3048 XtAddCallback(nameViewPtDialog, XmNcancelCallback,
3049 (XtCallbackProc) XtDestroyWidget, NULL);
3051 Widget text = XtNameToWidget(nameViewPtDialog,
"Text");
3052 XtVaSetValues(text, XmNmaxLength, This->
MAX_VP_NAME, NULL);
3053 std::string autoName =
"";
3058 XmTextSetString(text, (
char *) autoName.c_str());
3059 XmTextSetInsertionPosition(text, autoName.length());
3061 XtUnmanageChild(XtNameToWidget(nameViewPtDialog,
"Help"));
3062 XtManageChild(nameViewPtDialog);
3069 std::stringstream sstream;
3070 std::vector<int> existingViewPts;
3074 for (
unsigned int i = 0; i < this->
viewPtList.size(); ++i) {
3076 if (viewPt.find(
"viewpoint_") != std::string::npos) {
3077 tmp = atoi(viewPt.substr(10).c_str());
3080 if (!viewPt.compare(
"viewpoint_0"))
3081 existingViewPts.push_back(0);
3083 existingViewPts.push_back(tmp);
3091 if (existingViewPts.size() > 0) {
3094 if (std::find(existingViewPts.begin(), existingViewPts.end(), vpNum)
3095 == existingViewPts.end()) {
3096 sstream <<
"viewpoint_" << vpNum;
3097 return sstream.str();
3102 return "viewpoint_0";
3109 XtPointer client_data,
3119 XtPointer client_data,
3126 if(This->isViewing())
3127 This->setViewing(
false);
3128 This->setComponentCursor(SoXtCursor(SoXtCursor::CROSSHAIR));
3136 XtPointer client_data,
3137 XtPointer call_data)
3140 std::string strName;
3142 XmSelectionBoxCallbackStruct *cbs =
3143 (XmSelectionBoxCallbackStruct *) call_data;
3144 XmStringGetLtoR(cbs->value, XmFONTLIST_DEFAULT_TAG, &name);
3157 int beg = strName.find_first_not_of(
' ');
3158 int end = strName.find_last_not_of(
' ');
3159 strName = strName.substr(beg, end - beg + 1);
3161 bool nameExists =
false;
3163 for (
int i = 0; i < size; i++) {
3164 if (!strcmp(This->
viewPtList[i].viewPtName, strName.c_str())) {
3172 name =
new char[nVPName];
3173 strncpy(name, strName.c_str(), nVPName);
3178 XmListAddItemUnselected(This->
myViewPtList, cbs->value, 0);
3183 String dialogName = (
char *)
"Existing Viewpoint";
3184 std::string msg =
"The viewpoint already exists.";
3197 float x, y, z,
angle;
3198 SoCamera * camera = getCamera();
3208 tmp.
position = camera->position.getValue();
3216 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
3217 tmp.
height = ((SoPerspectiveCamera *) camera)->heightAngle.getValue();
3219 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
3220 tmp.
height = ((SoOrthographicCamera *) camera)->height.getValue();
3223 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::saveViewPtCB",
3224 "Only Perspective and Orthographic cameras are supported.");
3231 std::string vpName =
name;
3236 fileOut << vpName << std::endl;
3238 fileOut << x <<
" " << y <<
" " << z << std::endl;
3242 axis.getValue(x, y, z);
3243 fileOut << x <<
" " << y <<
" " << z <<
" " << angle << std::endl;
3257 XtPointer client_data,
3274 std::ofstream out(
"temporaryFile.txt");
3280 XmString vpNameStr = XmStringCreateLocalized(vpName);
3283 XmStringFree(vpNameStr);
3287 out << line <<
"\n";
3289 while (getline(
fileIn, line)) {
3290 end = line.find_last_not_of(
' ');
3291 line = line.substr(0, end + 1);
3292 if (!strcmp(line.c_str(), vpName)) {
3293 while (line.size()) {
3297 while (getline(
fileIn, line))
3298 out << line <<
"\n";
3300 while (line.size()) {
3301 out << line <<
"\n";
3310 while (idx < size) {
3311 if (!strcmp(
viewPtList[idx].viewPtName, vpName)) {
3324 int istat =
remove(
fileName.c_str());
3326 char dialogName[] =
"Warning";
3330 istat = rename(
"temporaryFile.txt",
fileName.c_str());
3332 char dialogName[] =
"Warning";
3337 fileOut.seekp(0, std::ios::end);
3357 int idx = 0, end,
pos;
3359 std::string line, newName;
3368 while (getline(
fileIn, line)) {
3369 end = line.find_last_not_of(
' ');
3370 line = line.substr(0, end + 1);
3374 fileOut.seekp(0, std::ios::end);
3385 while (idx < size) {
3400 float x, y, z,
angle;
3401 int sortIdx = 0, unsortIdx = 0;
3410 int size = sortedViewPts.size();
3411 while (sortIdx < size) {
3412 while (strcmp(sortedViewPts[sortIdx].c_str(),
3416 std::string vpName =
viewPtList[unsortIdx].viewPtName;
3420 fileOut << vpName << std::endl;
3421 viewPtList[unsortIdx].position.getValue(x, y, z);
3422 fileOut << x <<
" " << y <<
" " << z << std::endl;
3425 viewPtList[unsortIdx].orientation.getValue(axis, angle);
3426 axis.getValue(x, y, z);
3427 fileOut << x <<
" " << y <<
" " << z <<
" " << angle << std::endl;
3430 <<
viewPtList[unsortIdx].height << std::endl;
3456 float x, y, z,
angle;
3463 while (getline(
fileIn, token)) {
3465 int end = token.find_last_not_of(
' ');
3466 token = token.substr(0, end + 1);
3468 char *vpName =
new char[token.size() + 1];
3469 strcpy(vpName, token.c_str());
3473 parseString<float>(x, token,
error);
3475 parseString<float>(y, token,
error);
3477 parseString<float>(z, token,
error);
3479 tmp.
position = axis.setValue(x, y, z);
3481 parseString<float>(x, token,
error);
3483 parseString<float>(y, token,
error);
3485 parseString<float>(z, token,
error);
3489 orient.setValue(axis.setValue(x, y, z),
angle);
3493 parseString<int>(camType, token,
error);
3530 std::istringstream str(s);
3531 if ((str >> t).fail())
3539 std::string dialogName,
3540 std::string buttonLabel,
3541 XtCallbackProc cbOK)
3545 Widget parent, scrollWidget;
3546 parent = SoXt::getShellWidget(getParentWidget());
3548 if (dialog == NULL) {
3551 XmString str = XmStringCreateLocalized((
char *) buttonLabel.c_str());
3554 XtSetArg(args[n], XmNokLabelString, str); n++;
3555 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3557 dialog = XmCreateFileSelectionDialog(parent,
3558 (
char *) dialogName.c_str(), args,
n);
3560 XtAddCallback(dialog, XmNokCallback, cbOK,
this);
3564 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_DIR_LIST);
3567 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_LIST);
3571 XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
3574 XtManageChild(dialog);
3591 XtPointer client_data,
3602 XtPointer client_data,
3603 XtPointer call_data)
3607 XmFileSelectionBoxCallbackStruct *cbs =
3608 (XmFileSelectionBoxCallbackStruct *) call_data;
3612 if (!(file = (
char *) XmStringUnparse(cbs->value,
3613 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3615 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::fileSelectedCB",
3616 "Internal error during file opening");
3621 if (!This->
fileIn.fail()) {
3625 String dialogName = (
char *)
"Error Loading File";
3626 std::string msg =
"Wrong or corrupted input file.";
3631 This->
fileOut.seekp(0, std::ios::end);
3638 std::string newDialogName = This->
fileName.substr(
3641 (
char *) newDialogName.c_str(), NULL);
3658 String dialogName = (
char *)
"Nonexistent File";
3659 std::string msg =
"Unable to open file.";
3679 viewPts = (XmString *) XtMalloc(size *
sizeof(XmString));
3680 for (
int i = 0; i < size; i++)
3681 viewPts[i] = XmStringCreateLocalized(
viewPtList[i].viewPtName);
3683 XmListAddItemsUnselected(
myViewPtList, viewPts, size, 1);
3685 if (viewPts != NULL) {
3686 for (
int i = 0; i < size; i++)
3687 XmStringFree(viewPts[i]);
3688 XtFree((
char *) viewPts);
3718 XmString warningMsg;
3720 warningMsg = XmStringCreateLocalized((
char *)msg.c_str());
3723 XtSetArg(args[n], XmNmessageString, warningMsg); n++;
3724 Widget warningDialog = XmCreateWarningDialog(getParentWidget(), dialogName, args, n);
3726 XtAddCallback(warningDialog, XmNokCallback, cb,
this);
3728 XmStringFree(warningMsg);
3730 XtVaSetValues (warningDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
3731 XtUnmanageChild(XtNameToWidget(warningDialog,
"Help"));
3732 XtUnmanageChild(XtNameToWidget(warningDialog,
"Cancel"));
3734 XtManageChild(warningDialog);
3739 XtPointer client_data,
3750 XtPointer client_data,
3751 XtPointer call_data)
3756 XmFileSelectionBoxCallbackStruct *cbs =
3757 (XmFileSelectionBoxCallbackStruct *) call_data;
3761 if (!(file = (
char *) XmStringUnparse(cbs->value,
3762 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3764 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::createNewVPFileCB",
3765 "Internal error during file opening");
3772 if (This->
fileIn.fail()) {
3786 String dialogName = (
char *)
"Existing File";
3787 std::string msg =
"'" + fName +
"' already exists. Do you want to overwrite it?";
3798 XtPointer client_data,
3818 XtPointer client_data,
3829 XtPointer client_data,
3830 XtPointer call_data)
3834 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
3839 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3840 XmCHARSET_TEXT, XmCHARSET_TEXT,
3841 NULL, 0, XmOUTPUT_ALL);
3843 std::ifstream ifs(file);
3847 while(ifs >> x >> y >> z){
3854 String dialogName = (
char *)
"Problem reading file";
3855 std::string msg =
"Problem reading file";
3867 XtPointer client_data,
3873 String dialogName = (
char *)
"No Reference Trajectory";
3874 std::string msg =
"You need to start a run or load a reference trajectory from a file";
3881 Widget parent, scrollWidget;
3882 parent = SoXt::getShellWidget(This->getParentWidget());
3887 XmString str = XmStringCreateLocalized((
char *)
"Save");
3890 XtSetArg(args[n], XmNokLabelString, str); n++;
3891 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3893 This->
saveRefCoordsDialog = XmCreateFileSelectionDialog(parent,(
char *)
"Save Ref Coords", args, n);
3918 XtPointer client_data,
3919 XtPointer call_data)
3923 XmFileSelectionBoxCallbackStruct *cbs =
3924 (XmFileSelectionBoxCallbackStruct *) call_data;
3929 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3930 XmCHARSET_TEXT, XmCHARSET_TEXT,
3931 NULL, 0, XmOUTPUT_ALL);
3933 std::ifstream ifile(file);
3938 Widget parent = This->getParentWidget();
3939 Widget confirmOverwriteDialog;
3942 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite", args, 0);
3943 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
3944 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
3949 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
3959 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
3960 XtManageChild(confirmOverwriteDialog);
3966 std::ofstream ofs(file);
3971 ofs << x <<
" " << y <<
" " << z <<
"\n";
3977 String dialogName = (
char *)
"Error opening file";
3978 std::string msg =
"There was a problem trying to open the file '";
3992 XtPointer client_data,
3993 XtPointer call_data)
3995 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
3998 switch (cbs->reason) {
4008 ofs << x <<
" " << y <<
" " << z <<
"\n";
4015 String dialogName = (
char *)
"Error opening file";
4016 std::string msg =
"There was a problem trying to open the file '";
4030 XmProcessTraversal(XtNameToWidget(This->
saveRefCoordsWidget,
"Text"), XmTRAVERSE_CURRENT);
4044 XtPointer client_data,
4056 XtPointer client_data,
4057 XtPointer call_data)
4061 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
4065 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4066 XmCHARSET_TEXT, XmCHARSET_TEXT,
4067 NULL, 0, XmOUTPUT_ALL);
4070 if (!sceneInput.openFile(file)) {
4071 String dialogName = (
char *)
"Problem opening file";
4072 std::string msg =
"Cannot open file ";
4076 sceneInput.closeFile();
4082 String dialogName = (
char *)
"Problem reading file";
4083 std::string msg =
"Problem reading file";
4097 XtPointer client_data,
4104 Widget parent, scrollWidget;
4105 parent = SoXt::getShellWidget(This->getParentWidget());
4110 XmString str = XmStringCreateLocalized((
char *)
"Save");
4113 XtSetArg(args[n], XmNokLabelString, str); n++;
4114 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
4116 This->
saveSceneGraphDialog = XmCreateFileSelectionDialog(parent,(
char *)
"Save Scene Graph", args, n);
4142 XtPointer client_data,
4143 XtPointer call_data)
4147 XmFileSelectionBoxCallbackStruct *cbs =
4148 (XmFileSelectionBoxCallbackStruct *) call_data;
4152 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4153 XmCHARSET_TEXT, XmCHARSET_TEXT,
4154 NULL, 0, XmOUTPUT_ALL);
4156 std::ifstream ifile(file);
4161 Widget parent = This->getParentWidget();
4162 Widget confirmOverwriteDialog;
4165 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite", args, 0);
4166 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
4167 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
4172 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
4182 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
4183 XtManageChild(confirmOverwriteDialog);
4189 SoWriteAction writeAction;
4190 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4192 SoOutput * out = writeAction.getOutput();
4194 if(out->openFile(file)){
4195 out->setBinary(
FALSE);
4196 writeAction.apply(root);
4202 String dialogName = (
char *)
"Error opening file";
4203 std::string msg =
"There was a problem trying to open the file '";
4219 XtPointer client_data,
4220 XtPointer call_data)
4222 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
4225 switch (cbs->reason) {
4230 SoWriteAction writeAction;
4231 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4233 SoOutput * out = writeAction.getOutput();
4235 out->setBinary(
FALSE);
4236 writeAction.apply(root);
4245 String dialogName = (
char *)
"Error opening file";
4246 std::string msg =
"There was a problem trying to open the file '";
4278 XtPointer client_data,
4279 XtPointer call_data)
4283 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
4285 vpName = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
4286 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4288 for (
int i = 0; i < (int) This->
viewPtList.size(); i++) {
4289 if (!strcmp(This->
viewPtList[i].viewPtName, vpName)) {
4304 XtPointer client_data,
4312 XmString vpNameStr = XmStringCreateLocalized(vpName);
4319 XmStringFree(vpNameStr);
4326 XtPointer client_data,
4329 std::string vpNameStr;
4331 int *pos_list, pos_cnt;
4336 if (!strlen(vpName) || !strcmp(This->
curViewPtName, vpName)) {
4343 int beg = vpNameStr.find_first_not_of(
' ');
4344 int end = vpNameStr.find_last_not_of(
' ');
4345 vpNameStr = vpNameStr.substr(beg, end - beg + 1);
4346 const int nVPName = vpNameStr.size() + 1;
4347 char* vpName1 =
new char[nVPName];
4348 strncpy(vpName1, vpNameStr.c_str(), nVPName);
4351 for (
int i = 0; i < size; i++) {
4352 if (!strcmp(vpName1, This->
viewPtList[i].viewPtName)) {
4354 String dialogName = (
char *)
"Existing Viewpoint";
4355 std::string msg =
"'";
4357 msg +=
"' already exists. Choose a different name";
4365 XmString vpNameXmStr = XmStringCreateLocalized(vpName1);
4367 if (XmListGetSelectedPos(This->
myViewPtList, &pos_list, &pos_cnt)) {
4368 XmListReplaceItemsPos(This->
myViewPtList, &vpNameXmStr, 1, pos_list[0]);
4370 XtFree((
char *) pos_list);
4374 This->scheduleRedraw();
4376 XmStringFree(vpNameXmStr);
4382 XtPointer client_data,
4387 XmString *strList, *newStrList;
4388 std::vector<std::string> charList;
4395 XtVaGetValues(This->
myViewPtList, XmNitemCount, &size, XmNitems, &strList,
4398 for (
int i = 0; i < size; i++) {
4399 vpName = (
char *) XmStringUnparse(strList[i], XmFONTLIST_DEFAULT_TAG,
4400 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4401 charList.push_back(vpName);
4405 std::sort(charList.begin(), charList.end());
4407 newStrList = (XmString *) XtMalloc(size *
sizeof(XmString));
4408 for (
int i = 0; i < size; i++) {
4412 const int nVPName = charList[i].size() + 1;
4413 char *vpName2 =
new char[nVPName];
4414 strncpy(vpName2, charList[i].c_str(), nVPName);
4415 newStrList[i] = XmStringCreateLocalized(vpName2);
4420 XmListAddItemsUnselected(This->
myViewPtList, newStrList, size, 1);
4424 if (newStrList != NULL) {
4425 for (
int i = 0; i < size; i++)
4426 XmStringFree(newStrList[i]);
4427 XtFree((
char *) newStrList);
4437 SbVec3f p1, p2, p3, dirNow, dirNxt, dir, p2_tmp, p_start, p_corner, p_nxt;
4438 float avgDistBtwPts = 0;
4439 float totalDistBtwPts = 0;
4440 std::vector<SbVec3f> newRefParticleTrajectory;
4444 for (
int i = 0; i < size; i++) {
4450 totalDistBtwPts += (p2 - p1).length();
4453 avgDistBtwPts = totalDistBtwPts / numOfPts;
4454 float minDistAllowed = 0.75 * avgDistBtwPts;
4464 p1.getValue(x, y, z);
4466 newRefParticleTrajectory.push_back(refPoint);
4469 while ((p2 - p1).length() < minDistAllowed && j < (size - 1)) {
4489 XtPointer client_data,
4508 SoCamera *cam = getCamera();
4517 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4519 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
4521 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4523 ((SoOrthographicCamera *) cam)->height.getValue();
4531 SoCamera *cam = getCamera();
4541 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4545 ((SoOrthographicCamera *) cam)->height.setValue(
4548 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4550 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4554 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4557 ((SoOrthographicCamera *) cam)->height.setValue(
4566 SbTime curTime = SbTime::getTimeOfDay();
4568 SoTimerSensor *
s = (SoTimerSensor *) sensor;
4570 float t = float((curTime - s->getBaseTime()).getValue())
4573 if ((t > 1.0f) || (t + s->getInterval().getValue() > 1.0f))
4575 SbBool end = (t == 1.0f);
4598 SbTime curTime = SbTime::getTimeOfDay();
4600 SoCamera *cam = This->getCamera();
4601 SoTimerSensor *
s = (SoTimerSensor *) sensor;
4603 float t = float((curTime - s->getBaseTime()).getValue())
4606 if ((t > 1.0f) || (t + s->getInterval().getValue() > 1.0f))
4608 SbBool end = (t == 1.0f);
4638 if (SoXtExaminerViewer::isAnimating())
4642 SbVec3f p1, p2, p2_tmp, camUpV, camD, camD_tmp, leftRightAxis;
4643 float x1, y1, z1, x2, y2, z2;
4660 p1.getValue(x1, y1, z1);
4661 p2.getValue(x2, y2, z2);
4666 p2_tmp.setValue(x2, y1, z2);
4667 camD_tmp = p2_tmp - p1;
4668 camD_tmp.normalize();
4670 camUpV.setValue(0, 1, 0);
4671 rot.setValue(camD_tmp, camD);
4672 rot.multVec(camUpV, camUpV);
4674 leftRightAxis = camD.cross(camUpV);
4676 myCam->position = p1;
4677 myCam->pointAt(p2, camUpV);
4681 myCam->position = p1;
4687 myCam->focalDistance = 0.1f;
4699 XtPointer client_data,
4705 String dialogName = (
char *)
"No Reference Trajectory";
4706 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4719 This->scheduleRedraw();
4726 if (This->SoXtExaminerViewer::isAnimating())
4727 This->stopAnimating();
4736 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
4739 This->scheduleRedraw();
4751 This->
distance = (pN - p1).length() / 10;
4758 XtPointer client_data,
4777 XtPointer client_data,
4784 String dialogName = (
char *)
"No Reference Trajectory";
4785 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4796 This->
axisSwitch->whichChild.setValue(SO_SWITCH_ALL);
4799 This->scheduleRedraw();
4802 SoCamera *cam = This->getCamera();
4815 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4816 This->toggleCameraType();
4817 cam = This->getCamera();
4825 cam->focalDistance = 0.1f;
4826 ((SoPerspectiveCamera *) cam)->heightAngle = 0.50f;
4833 cam->orientation = (This->
myCam)->orientation.getValue();
4840 SoCamera *cam = getCamera();
4862 void (*callback)(
void *),
void *
object)
SbRotation camStartOrient
#define SPEED_INDICATOR_STEP
void animateRefParticle()
static void loadSceneGraphDialogCB(Widget, XtPointer, XtPointer)
void updateSpeedIndicator(void)
static void constructListsDialog(Widget, XtPointer, XtPointer)
SoText2 * mouseOverTextLogName
static void saveRefCoordsOverWriteCB(Widget, XtPointer, XtPointer)
void renameViewPt(char *vpName)
static void loadBookmarkCB(Widget, XtPointer, XtPointer)
static void saveViewPtCB(Widget, XtPointer, XtPointer)
SoFont * mouseOverFontSolid
static constexpr double s
~G4OpenInventorXtExaminerViewer()
CLHEP::Hep3Vector G4ThreeVector
Widget saveRefCoordsDialog
Widget loadRefCoordsDialog
std::string viewPtAutoName()
std::vector< ExP01TrackerHit * > a
G4OpenInventorXtExaminerViewer * viewer
void setStartingPtForAnimation()
void setReferencePath(SoLineSet *, SoCoordinate3 *, bool append=false)
friend class HookEventProcState
SoTranslation * mouseOverTransZPos
std::vector< SbVec3f > refParticleTrajectory
void evenOutRefParticlePts()
static void sortBookmarksCB(Widget, XtPointer, XtPointer)
SoNodeSensor * sceneChangeSensor
SoText2 * mouseOverTextMaterial
void setReferencePathZPos()
static void pickRefPathCB(Widget, XtPointer, XtPointer)
SoText2 * mouseOverTextSolid
SoSwitch * animSpeedOutlineSwitch
const std::vector< const std::vector< G4AttValue > * > & GetAttValues() const
static void saveSceneGraphOverWriteCB(Widget, XtPointer, XtPointer)
static G4double angle[DIM]
bool viewingBeforePickRef
std::string saveScenegraphFileName
static void lookAtSceneElementCB(Widget, XtPointer, XtPointer)
Widget addMenu(std::string name)
static void overwriteFileCB(Widget, XtPointer, XtPointer)
const char * name(G4int ptype)
static void closeListsDialogCB(Widget, XtPointer, XtPointer)
std::vector< float > refZPositions
void parseString(T &t, const std::string &s, bool &error)
SoTranslation * mouseOverTransMaterial
void cleanUpAfterPrevFile()
SoNode * getSuperimpositionNode(SoNode *, const char *name)
static void mouseoverCB(void *aThis, SoEventCallback *eventCB)
void(* escapeCallback)(void *)
static void sceneChangeCB(void *, SoSensor *)
static G4OpenInventorXtExaminerViewer * viewer
void moveCamera(float dist=0, bool lookdown=false)
virtual void actualRedraw(void)
static void prevViewPtCB(Widget, XtPointer, XtPointer)
void createElementsList(Widget)
virtual G4bool Notify(G4ApplicationState requiredState)
SoCoordinate3 * getCoordsNode(SoFullPath *path)
G4OpenInventorXtExaminerViewer(Widget parent=NULL, const char *name=NULL, SbBool embed=TRUE, SoXtFullViewer::BuildFlag flag=BUILD_ALL, SoXtViewer::Type type=BROWSER)
static void animateSensorRotationCB(void *, SoSensor *)
static void invertRefPathCB(Widget, XtPointer, XtPointer)
static void abbrOutputCB(Widget, XtPointer, XtPointer)
static void saveSceneGraphDialogCB(Widget, XtPointer, XtPointer)
SoFont * mouseOverFontLogName
void saveViewPt(char *name)
SoTranslation * curInfoTrans
G4GLOB_DLL std::ostream G4cout
static void createNewVPFileCB(Widget, XtPointer, XtPointer)
float distanceToBeamlineStart
std::vector< viewPtData > viewPtList
void warningMsgDialog(std::string, String, XtCallbackProc)
static void saveSceneGraphCB(Widget, XtPointer, XtPointer)
static void superimpositionCB(void *closure, SoAction *action)
static void closeMainWindowCB(Widget, XtPointer, XtPointer)
static void gotoRefPathStartCB(Widget, XtPointer, XtPointer)
static void renameBookmarkCB(Widget, XtPointer, XtPointer)
HookEventProcState * hookBeamOn
SoCoordinate3 * sgeometry
static void animateRefParticleCB(Widget, XtPointer, XtPointer)
float sqrlen(const SbVec3f &)
void distanceToTrajectory(const SbVec3f &, float &, SbVec3f &, int &)
HookEventProcState(G4OpenInventorXtExaminerViewer *)
SoSearchAction * searcher
SoTimerSensor * animateSensor
static void saveRefCoordsDialogCB(Widget, XtPointer, XtPointer)
void popUpFileSelDialog(Widget &, std::string, std::string, XtCallbackProc)
void addButton(Widget menu, std::string name, XtCallbackProc)
static void viewPtFileSelectedCB(Widget, XtPointer, XtPointer)
static void cancelFileSelDialogCB(Widget, XtPointer, XtPointer)
static void newViewPtFileCB(Widget, XtPointer, XtPointer)
viewPtData camB4Animation
SoFont * mouseOverFontZPos
SoFont * mouseOverFontMaterial
static void deleteViewPtCB(Widget, XtPointer, XtPointer)
void xmAddMouseEventHandler(Widget w)
SoSwitch * animSpeedSwitch
SoTimerSensor * animateSensorRotation
static void animateSensorCB(void *, SoSensor *)
static const char * thisClassName
static void nextViewPtCB(Widget, XtPointer, XtPointer)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
void constructor(const SbBool build)
Widget buildWidget(Widget parent)
SoTranslation * stranslation
void superimpositionEvent(SoAction *action)
static void deleteBookmarkCB(Widget, XtPointer, XtPointer)
std::vector< sceneElement > sceneElements
double animateBtwPtsPeriod
SoText2 * mouseOverTextZPos
static void getViewPtNameCB(Widget, XtPointer, XtPointer)
static void openViewPtFileCB(Widget, XtPointer, XtPointer)
static PROLOG_HANDLER error
static void pickingCB(void *aThis, SoEventCallback *eventCB)
virtual SbBool processSoEvent(const SoEvent *const event)
Widget saveSceneGraphDialog
static void loadRefCoordsCB(Widget, XtPointer, XtPointer)
SoSeparator * newSceneGraph
virtual void afterRealizeHook()
void deleteViewPt(char *vpName=NULL)
SoTranslation * mouseOverTransSolid
void sortViewPts(std::vector< std::string >)
static void loadSceneGraphCB(Widget, XtPointer, XtPointer)
static void saveRefCoordsCB(Widget, XtPointer, XtPointer)
#define MAX_SPEED_INDICATOR
void addEscapeCallback(void(*cb)(void *), void *)
Widget saveRefCoordsWidget
static const G4double pos
const std::vector< const std::map< G4String, G4AttDef > * > & GetAttDefs() const
std::string saveRefCoordsFileName
SoTranslation * mouseOverTransLogName
Widget saveScenegraphWidget
static void loadRefCoordsDialogCB(Widget, XtPointer, XtPointer)
virtual void createViewerButtons(Widget parent, SbPList *buttonlist)
Widget loadSceneGraphDialog