39 #include <X11/keysym.h> 44 #include <Xm/MessageB.h> 46 #include <Xm/ToggleB.h> 47 #include <Xm/CascadeB.h> 48 #include <Xm/ArrowBG.h> 50 #include <Xm/RowColumn.h> 51 #include <Xm/FileSB.h> 52 #include <Xm/SelectioB.h> 53 #include <Xm/Protocols.h> 54 #include <Xm/SeparatoG.h> 55 #include <Xm/DialogS.h> 56 #include <Xm/PanedW.h> 57 #include <Xm/LabelG.h> 59 #include <Xm/DrawingA.h> 61 #include <Inventor/Xt/SoXt.h> 63 #include <Inventor/Xt/SoXtCursor.h> 64 #include <Inventor/events/SoKeyboardEvent.h> 65 #include <Inventor/events/SoMouseButtonEvent.h> 66 #include <Inventor/events/SoLocation2Event.h> 67 #include <Inventor/nodes/SoSeparator.h> 68 #include <Inventor/nodes/SoOrthographicCamera.h> 69 #include <Inventor/nodes/SoPerspectiveCamera.h> 72 #include <Inventor/nodes/SoLineSet.h> 73 #include <Inventor/nodes/SoMaterial.h> 74 #include <Inventor/errors/SoDebugError.h> 75 #include <Inventor/SoPickedPoint.h> 76 #include <Inventor/actions/SoWriteAction.h> 81 #include <Inventor/sensors/SoTimerSensor.h> 82 #include <Inventor/sensors/SoNodeSensor.h> 94 #include <Inventor/nodes/SoCallback.h> 95 #include <Inventor/nodes/SoSwitch.h> 96 #include <Inventor/nodes/SoScale.h> 97 #include <Inventor/nodes/SoTranslation.h> 98 #include <Inventor/actions/SoSearchAction.h> 99 #include <Inventor/actions/SoGetBoundingBoxAction.h> 101 #include <Inventor/nodes/SoCoordinate3.h> 103 #include <Inventor/nodes/SoText2.h> 104 #include <Inventor/nodes/SoFont.h> 105 #include <Inventor/nodes/SoPointSet.h> 106 #include <Inventor/nodes/SoDrawStyle.h> 107 #include <Inventor/nodes/SoBaseColor.h> 110 #include <Inventor/nodekits/SoBaseKit.h> 113 #include <Inventor/SbVec3f.h> 119 #define MIN_SPEED 2.1 // Lower number means faster 120 #define START_STEP 0.3 121 #define SPEED_INDICATOR_STEP 0.045 122 #define MAX_SPEED_INDICATOR 0.81 128 const char *
name, SbBool embed,
129 SoXtFullViewer::BuildFlag flag, SoXtViewer::Type type) :
130 SoXtExaminerViewer(parent, name, embed, flag, type,
FALSE)
138 const char *
name, SbBool embed,
139 SoXtFullViewer::BuildFlag flag, SoXtViewer::Type type,
141 SoXtExaminerViewer(parent, name, embed, flag, type,
FALSE)
162 myCam =
new SoPerspectiveCamera;
198 static const char * superimposed[] = {
199 "#Inventor V2.1 ascii",
"",
206 " OrthographicCamera ",
212 " DEF soxt->callback Callback { }",
215 " DEF soxt->translation Translation ",
217 " translation 0 0 0",
219 " DEF soxt->scale Scale ",
221 " scaleFactor 1 1 1",
223 " DEF soxt->geometry Coordinate3 ",
227 " -0.81 -0.04 0, -0.81 0 0,",
228 " -0.81 0.04 0, 0 -0.04 0,",
230 " 0.81 -0.04 0, 0.81 0 0,",
233 " 0.81 0.02 0, 0.81 -0.02 0,",
236 " 0.4 0.01 0, 0.4 -0.01 0,",
241 " DEF soxt->animSpeedOutlineSwitch Switch ",
246 " emissiveColor 0 0 0",
252 " 12, 11, 10, 9, -1",
257 " DEF soxt->axisSwitch Switch ",
276 " DEF soxt->animSpeedSwitch Switch ",
281 " emissiveColor 0 1 0",
287 " 16, 15, 14, 13, -1",
293 " DEF soxt->curInfoSwitch Switch ",
296 " DEF soxt->curInfoTrans Translation ",
298 " translation 10 20 30 ",
300 " DEF soxt->curInfoFont Font ",
302 " name defaultFont:Bold",
305 " DEF soxt->curInfoText Text2 ",
314 " DEF soxt->mouseOverTransLogName Translation ",
316 " translation 0 0 0 ",
318 " DEF soxt->mouseOverFontLogName Font ",
320 " name defaultFont:Bold",
323 " DEF soxt->mouseOverTextLogName Text2 { } ",
327 " DEF soxt->mouseOverTransSolid Translation ",
329 " translation 0 0 0 ",
331 " DEF soxt->mouseOverFontSolid Font ",
333 " name defaultFont:Bold",
336 " DEF soxt->mouseOverTextSolid Text2 { } ",
340 " DEF soxt->mouseOverTransMaterial Translation ",
342 " translation 0 0 0 ",
344 " DEF soxt->mouseOverFontMaterial Font ",
346 " name defaultFont:Bold",
349 " DEF soxt->mouseOverTextMaterial Text2 { } ",
353 " DEF soxt->mouseOverTransZPos Translation ",
355 " translation 0 0 0 ",
357 " DEF soxt->mouseOverFontZPos Font ",
359 " name defaultFont:Bold",
362 " DEF soxt->mouseOverTextZPos Text2 { } ",
368 for (i = bufsize = 0; superimposed[i]; i++)
369 bufsize += strlen(superimposed[i]) + 1;
370 char * buf =
new char[bufsize + 1];
371 for (i = bufsize = 0; superimposed[i]; i++) {
372 strcpy(buf + bufsize, superimposed[i]);
373 bufsize += strlen(superimposed[i]);
377 SoInput * input =
new SoInput;
378 input->setBuffer(buf, bufsize);
437 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
472 this->
searcher =
new SoSearchAction;
475 searcher->setInterest(SoSearchAction::FIRST);
479 return searcher->getPath()->getTail();
496 if (!action->isOfType(SoGLRenderAction::getClassTypeId()))
498 SbViewportRegion vpRegion =
499 ((SoGLRenderAction *) action)->getViewportRegion();
500 SbVec2s viewportSize = vpRegion.getViewportSizePixels();
502 float aspect = float(viewportSize[0]) / float(viewportSize[1]);
503 float factorx = 1.0f / float(viewportSize[1]) * 220.0f;
504 float factory = factorx;
510 SbVec3f(0.0
f, -0.4
f / aspect, 0.0
f));
514 if (viewportSize[0] > 500)
515 factorx *= 500.0f / 400.0f;
517 factorx *= float(viewportSize[0]) / 400.0f;
518 this->
sscale->scaleFactor.setValue(SbVec3f(factorx, factory, 1.0
f));
520 float xInfo, yInfo, xMouseLogName, yMouseLogName, xMouseSolid, yMouseSolid,
521 xMouseMaterial, yMouseMaterial, xMouseZPos, yMouseZPos;
525 yMouseLogName = -.75;
528 xMouseMaterial = 0.0;
529 yMouseMaterial = -.81;
535 xMouseSolid *= aspect;
536 xMouseMaterial *= aspect;
537 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
539 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
541 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
543 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
545 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
548 yMouseSolid /= aspect;
549 yMouseMaterial /= aspect;
550 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
552 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
554 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
556 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
558 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
563 this->
curInfoFont->name.setValue(
"defaultFont:Italic");
568 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
574 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
577 this->
curInfoText->string.setValue(SbString(zPos));
606 Atom WM_DELETE_WINDOW;
609 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::buildWidget",
"Error: Parent is null.");
612 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
613 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
614 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
615 XtSetArg(args[3], XmNbottomAttachment, XmATTACH_FORM);
616 Widget form = XmCreateForm(parent, (
char *)
"Form", args, 4);
619 shell = XtParent(form);
620 WM_DELETE_WINDOW = XInternAtom(XtDisplay(parent),
"WM_DELETE_WINDOW",
622 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW,
625 XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
626 XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
627 XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
628 menuBar = XmCreateMenuBar(form, (
char *)
"MenuBar", args, 3);
639 XmCreateSeparatorGadget(
fileMenu, (
char *)
"Separator", NULL, 0));
641 Widget menu =
addMenu(
"Tools");
646 Widget viewerBase = SoXtFullViewer::buildWidget(form);
648 XtSetArg(args[0], XmNtopAttachment, XmATTACH_WIDGET);
649 XtSetArg(args[1], XmNtopWidget,
menuBar);
650 XtSetArg(args[2], XmNleftAttachment, XmATTACH_FORM);
651 XtSetArg(args[3], XmNrightAttachment, XmATTACH_FORM);
652 XtSetArg(args[4], XmNbottomAttachment, XmATTACH_FORM);
653 XtSetValues(viewerBase, args, 5);
663 Widget menu = XmCreatePulldownMenu(
menuBar, (
char *) name.c_str(), NULL, 0);
665 XtSetArg(args[0], XmNsubMenuId, menu);
666 Widget
w = XmCreateCascadeButton(
menuBar, (
char *) name.c_str(), args, 1);
677 Widget button = XmCreatePushButton(menu, (
char *) name.c_str(), NULL, 0);
678 XtManageChild(button);
679 XtAddCallback(button, XmNactivateCallback, cb,
this);
685 SbPList * buttonlist)
689 Widget saveViewPtButton, abbrOutputButton, pickRefPathButton;
692 SoXtExaminerViewer::createViewerButtons(parent, buttonlist);
695 Widget emptyButton = XtVaCreateManagedWidget(
"", xmPushButtonWidgetClass,
697 buttonlist->append(emptyButton);
701 XtSetArg(args[n], XmNtopPosition, 1); n++;
702 XtSetArg(args[n], XmNbottomPosition, 2); n++;
703 XtSetArg(args[n], XmNleftPosition, 0); n++;
704 XtSetArg(args[n], XmNrightPosition, 1); n++;
705 XtSetArg(args[n], XmNarrowDirection, XmARROW_LEFT); n++;
706 XtSetArg(args[n], XmNsensitive, False); n++;
716 XtSetArg(args[n], XmNtopPosition, 1); n++;
717 XtSetArg(args[n], XmNbottomPosition, 2); n++;
718 XtSetArg(args[n], XmNleftPosition, 0); n++;
719 XtSetArg(args[n], XmNrightPosition, 1); n++;
720 XtSetArg(args[n], XmNarrowDirection, XmARROW_RIGHT); n++;
721 XtSetArg(args[n], XmNsensitive, False); n++;
730 saveViewPtButton = XtVaCreateManagedWidget(
"Save", xmPushButtonWidgetClass,
732 XtAddCallback(saveViewPtButton, XmNactivateCallback,
734 Pixmap saveVP, saveVP_ins;
739 XtVaSetValues(saveViewPtButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
740 saveVP, XmNselectPixmap, saveVP, XmNlabelInsensitivePixmap,
741 saveVP_ins, XmNselectInsensitivePixmap, saveVP_ins, NULL);
742 buttonlist->append(saveViewPtButton);
745 abbrOutputButton = XtVaCreateManagedWidget(
"Abbr",
746 xmToggleButtonWidgetClass, parent, XmNindicatorOn, False, NULL);
749 Pixmap consolexpm, consolexpm_ins;
754 XtVaSetValues(abbrOutputButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
755 consolexpm, XmNselectPixmap, consolexpm, XmNlabelInsensitivePixmap,
756 consolexpm_ins, XmNselectInsensitivePixmap, consolexpm_ins, NULL);
757 buttonlist->append(abbrOutputButton);
760 pickRefPathButton = XtVaCreateManagedWidget(
"Refpath", xmPushButtonWidgetClass,
762 XtAddCallback(pickRefPathButton, XmNactivateCallback,
764 Pixmap favoritesxpm, favoritesxpm_ins;
769 XtVaSetValues(pickRefPathButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
770 favoritesxpm, XmNselectPixmap, favoritesxpm, XmNlabelInsensitivePixmap,
771 favoritesxpm_ins, XmNselectInsensitivePixmap, favoritesxpm_ins, NULL);
772 buttonlist->append(pickRefPathButton);
781 SoXtExaminerViewer::afterRealizeHook();
785 SoCamera *cam = getCamera();
787 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
789 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
792 ((SoOrthographicCamera *) cam)->height.getValue();
796 ((SoOrthographicCamera *) cam)->height.getValue();
799 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
801 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
810 String dialogName = (
char *)
"Error Loading File";
811 std::string msg =
"Wrong or corrupted input file.";
816 fileOut.seekp(0, std::ios::end);
837 SoSeparator *root = (SoSeparator *) (getSceneManager()->getSceneGraph());
839 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::afterRealizeHook",
"Root is null.");
841 root->addChild(
myCam);
853 SoEventCallback *moCB =
new SoEventCallback;
854 moCB->addEventCallback(
855 SoLocation2Event::getClassTypeId(),
857 root->addChild(moCB);
861 SoEventCallback *pickCB =
new SoEventCallback;
862 pickCB->addEventCallback(
863 SoMouseButtonEvent::getClassTypeId(),
865 root->addChild(pickCB);
874 SoCamera *cam = getCamera();
881 cam->position = camPosNew;
883 cam->focalDistance = (
prevPt - camPosNew).length();
902 SoCamera *cam = getCamera();
915 cam->focalDistance = (cam->position.getValue() -
center).length();
924 dist = (
prevPt - cam->position.getValue()).length();
931 dist = (
prevPt - cam->position.getValue()).length();
940 particleDir = p2 - p1;
941 particleDir.normalize();
954 SbRotation rot(SbVec3f(0,0,1), particleDir);
968 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
975 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
987 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
990 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
991 camPosNew = p2 - (
camDir);
994 cam->position = camPosNew;
1001 camPosNew.getValue(x,y,z);
1012 SoEventCallback *eventCB)
1014 SoHandleEventAction* action = eventCB->getAction();
1015 const SoPickedPoint *
pp = action->getPickedPoint();
1020 SoPath* path = pp->getPath();
1021 SoNode* node = ((SoFullPath*)path)->getTail();
1023 if(node->getTypeId() == SoLineSet::getClassTypeId()){
1030 This->setComponentCursor(SoXtCursor(SoXtCursor::DEFAULT));
1033 SoLineSet * trajectory = (SoLineSet *)node;
1039 SoSeparator * grpNode =
1040 (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
1045 int nodeIndex = grpNode->findChild(trajectory);
1048 SoCoordinate3 * coords = 0;
1052 for(
int i = 0; i < 100; ++i) {
1055 tmpNode = grpNode->getChild(nodeIndex);
1056 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
1058 coords = (SoCoordinate3 *)tmpNode;
1064 String dialogName = (
char *)
"No coordinates";
1065 std::string msg =
"Could not find the coordinates node" 1066 " for the picked trajectory." 1067 " Reference trajectory not set";
1084 if(attHolder && attHolder->
GetAttDefs().size()) {
1086 std::string strTrajPoint =
"G4TrajectoryPoint:";
1087 std::ostringstream oss;
1088 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1093 if(oss.str().find(strTrajPoint) != std::string::npos) {
1108 G4String cls((
char*)node->getTypeId().getName().getString());
1109 G4cout <<
"SoNode : " << node
1110 <<
" SoType : " << cls
1111 <<
" name : " <<
name 1128 if(attHolder && attHolder->
GetAttDefs().size()) {
1129 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1135 G4String cls((
char*)node->getTypeId().getName().getString());
1136 G4cout <<
"SoNode : " << node
1137 <<
" SoType : " << cls
1138 <<
" name : " <<
name 1144 eventCB->setHandled();
1151 SoHandleEventAction* action = eventCB->getAction();
1152 const SoPickedPoint*
pp = action->getPickedPoint();
1160 const SbViewportRegion & viewportRegion = action->getViewportRegion();
1162 std::string sLogName;
1164 std::stringstream ssZPos;
1165 std::stringstream ssSolids;
1166 std::stringstream ssMaterials;
1167 SoPath * path = pp->getPath();
1168 SoNode* node = ((SoFullPath*)path)->getTail();
1170 if(node->getTypeId() == Geant4_SoPolyhedron::getClassTypeId()) {
1172 sLogName =
"Logical Volume: ";
1175 SoGetBoundingBoxAction bAction(viewportRegion);
1176 bAction.apply((SoFullPath*)path);
1177 SbBox3f bBox = bAction.getBoundingBox();
1178 SbVec3f
center = bBox.getCenter();
1179 center.getValue(x,y,z);
1180 ssZPos <<
"Pos: " << x <<
" " << y <<
" " <<
z;
1183 if(attHolder && attHolder->
GetAttDefs().size()) {
1185 std::vector<const std::map<G4String,G4AttDef>*> vecDefs =
1187 std::vector<const std::vector<G4AttValue>*> vecVals =
1189 for (
size_t i = 0; i < vecDefs.size(); ++i) {
1190 const std::vector<G4AttValue> * vals = vecVals[i];
1192 std::vector<G4AttValue>::const_iterator iValue;
1194 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1195 const G4String& valueName = iValue->GetName();
1196 const G4String& value = iValue->GetValue();
1198 if(valueName ==
"Solid") {
1199 if(ssSolids.str() ==
"")
1200 ssSolids <<
"Solid Name: " << value;
1202 ssSolids <<
", " << value;
1205 if(valueName ==
"Material") {
1206 if(ssMaterials.str() ==
"")
1207 ssMaterials <<
"Material Name: " << value;
1209 ssMaterials <<
", " << value;
1216 else if(node->getTypeId() == SoLineSet::getClassTypeId()) {
1219 if(attHolder && attHolder->
GetAttDefs().size()) {
1220 std::string strTrajPoint =
"G4TrajectoryPoint:";
1221 std::ostringstream oss;
1223 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1226 const std::vector<G4AttValue>* vals = attHolder->
GetAttValues()[i];
1227 std::vector<G4AttValue>::const_iterator iValue;
1228 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1229 const G4String& valueName = iValue->GetName();
1230 const G4String& value = iValue->GetValue();
1234 if (valueName ==
"PN") t1 = value;
1235 if (valueName ==
"Ch") {
1236 if (atof(value.c_str()) > 0)
1242 if (valueName ==
"PDG") {
1249 if (valueName ==
"EventID") t2 =
"Evt " + value;
1250 if (valueName ==
"ID") t2 +=
" Trk " + value;
1251 if (valueName ==
"PID") {
1252 t2 +=
" Prt " + value;
1256 if (valueName ==
"IKE") t3 =
"KE " + value;
1257 if (valueName ==
"IMom") {
1259 unsigned ipos = value.rfind(
" ");
1262 t3 +=
" P (" + value1 +
")";
1264 if (valueName ==
"IMag") {
1269 if (valueName ==
"NTP") {
1270 std::ostringstream t4oss;
1271 t4oss <<
"TrjPts " << value;
1272 t4oss <<
" Pos " << pp->getPoint()[0] <<
" " << pp->getPoint()[1] <<
1273 " " << pp->getPoint()[2];
1296 This->scheduleRedraw();
1297 eventCB->setHandled();
1301 bool redraw =
false;
1306 if(std::string(This->
mouseOverTextSolid->string.getValues(0)->getString()) != ssSolids.str()) {
1310 if(std::string(This->
mouseOverTextMaterial->string.getValues(0)->getString()) != ssMaterials.str()){
1314 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) != ssZPos.str()) {
1321 This->scheduleRedraw();
1324 eventCB->setHandled();
1329 This->scheduleRedraw();
1333 This->scheduleRedraw();
1337 This->scheduleRedraw();
1339 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) !=
"") {
1341 This->scheduleRedraw();
1348 SoCamera *cam = getCamera();
1349 const SoType type(ev->getTypeId());
1351 if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
1352 SoMouseButtonEvent * me = (SoMouseButtonEvent *) ev;
1356 switch (me->getButton()) {
1357 case SoMouseButtonEvent::BUTTON4:
1358 if (me->getState() == SoButtonEvent::DOWN) {
1359 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1361 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1362 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1365 }
else if (cam->isOfType(
1366 SoOrthographicCamera::getClassTypeId())) {
1368 ((SoOrthographicCamera *) cam)->height.getValue();
1369 ((SoOrthographicCamera *) cam)->height = height + 5;
1374 case SoMouseButtonEvent::BUTTON5:
1375 if (me->getState() == SoButtonEvent::DOWN) {
1376 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1378 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1380 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1383 }
else if (cam->isOfType(
1384 SoOrthographicCamera::getClassTypeId())) {
1386 ((SoOrthographicCamera *) cam)->height.getValue();
1388 ((SoOrthographicCamera *) cam)->height = height - 5;
1402 if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
1403 SoKeyboardEvent * ke = (SoKeyboardEvent *) ev;
1405 if (SoKeyboardEvent::isKeyPressEvent(ev, ke->getKey())) {
1406 switch (ke->getKey()) {
1407 case SoKeyboardEvent::LEFT_SHIFT:
1410 case SoKeyboardEvent::RIGHT_SHIFT:
1413 case SoKeyboardEvent::LEFT_CONTROL:
1416 case SoKeyboardEvent::RIGHT_CONTROL:
1419 case SoKeyboardEvent::SPACE:
1441 case SoKeyboardEvent::ESCAPE:
1457 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
1468 case SoKeyboardEvent::DELETE:
1473 String dialogName = (
char *)
"Delete Viewpoint";
1474 std::string msg =
"Are you sure you want to delete current viewpoint?";
1479 case SoKeyboardEvent::LEFT_ARROW:
1487 if (SoXtExaminerViewer::isAnimating())
1503 if (SoXtExaminerViewer::isAnimating())
1528 cam->position =
myCam->position;
1535 this->bottomWheelMotion(
1536 this->getBottomWheelValue() + 0.1
f);
1546 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1547 "Unhandled viewer state");
1552 case SoKeyboardEvent::RIGHT_ARROW:
1560 if (SoXtExaminerViewer::isAnimating())
1574 if (SoXtExaminerViewer::isAnimating())
1596 cam->position =
myCam->position;
1603 this->bottomWheelMotion(
1604 this->getBottomWheelValue() - 0.1
f);
1613 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1614 "Unhandled viewer state");
1619 case SoKeyboardEvent::DOWN_ARROW:
1628 if (SoXtExaminerViewer::isAnimating())
1651 cam->position =
myCam->position;
1658 this->leftWheelMotion(this->getLeftWheelValue() - 0.1
f);
1667 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1668 "Unhandled viewer state");
1673 case SoKeyboardEvent::UP_ARROW:
1681 if (SoXtExaminerViewer::isAnimating())
1704 cam->position =
myCam->position;
1711 this->leftWheelMotion(this->getLeftWheelValue() + 0.1
f);
1720 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1721 "Unhandled viewer state");
1726 case SoKeyboardEvent::PAGE_UP:
1777 case SoKeyboardEvent::PAGE_DOWN:
1833 if (SoKeyboardEvent::isKeyReleaseEvent(ev, ke->getKey())) {
1834 switch (ke->getKey()) {
1835 case SoKeyboardEvent::LEFT_SHIFT:
1838 case SoKeyboardEvent::RIGHT_SHIFT:
1841 case SoKeyboardEvent::LEFT_CONTROL:
1844 case SoKeyboardEvent::RIGHT_CONTROL:
1857 return SoXtExaminerViewer::processSoEvent(ev);
1873 if (refParticleIdx < lastIdx && !animateSensor->isScheduled())
1899 SbVec3f * points = this->
sgeometry->point.startEditing();
1901 if (points[10][0] == 0.0
f)
1903 if (points[14][0] == 0.0
f)
1923 SoXtExaminerViewer::actualRedraw();
1926 SoXtExaminerViewer::actualRedraw();
1972 SbVec3f refParticlePt;
1977 for(
int i = 0; i < lineset->numVertices.getNum(); ++i){
1978 for(
int j = 0; j < lineset->numVertices[i]; ++j){
1979 refParticlePt = coords->point[j];
2005 SoSearchAction action;
2006 action.setType(SoLineSet::getClassTypeId(),
false);
2008 action.apply(this->getSceneGraph());
2010 SoPathList &pathList = action.getPaths();
2012 if(pathList.getLength() != 0){
2014 SoCoordinate3 * coords = NULL;
2015 std::vector<SoCoordinate3 *> coordvec;
2016 std::vector<SoLineSet *> linevec;
2018 bool refPathFound =
false;
2019 for(
int i = 0; i < pathList.getLength(); ++i) {
2020 SoFullPath *path = (SoFullPath *)pathList[i];
2023 for (
size_t j = 0; j < attHolder->
GetAttDefs().size(); ++j) {
2024 std::ostringstream oss;
2027 std::string findStr =
"Type of trajectory (Type): ";
2028 std::string compareValue =
"REFERENCE";
2029 size_t idx = oss.str().find(findStr);
2031 if(idx != std::string::npos) {
2032 if(oss.str().substr(idx + findStr.size(), compareValue.size()) == compareValue) {
2035 refPathFound =
true;
2036 coordvec.push_back(coords);
2037 linevec.push_back((SoLineSet *)path->getTail());
2043 findStr =
"Track ID (ID): ";
2044 idx = oss.str().find(findStr);
2045 if(idx != std::string::npos) {
2047 std::string tmpstr = oss.str().substr(idx + findStr.size(),1);
2048 std::istringstream
buffer(tmpstr);
2055 const char * nextChar =
2056 oss.str().substr(idx + findStr.size() + 1,1).c_str();
2057 if(std::isdigit(nextChar[0]))
2062 coordvec.push_back(coords);
2063 linevec.push_back((SoLineSet *)path->getTail());
2079 if(coordvec.empty())
2090 float longestLength = 0.0;
2092 for(
unsigned int i=0;i < linevec.size(); ++i){
2095 std::vector<SbVec3f> trajectory;
2097 for(
int j=0; j < linevec[i]->numVertices.getNum(); ++j){
2099 for(
int k=0; k < linevec[i]->numVertices[j]; ++k){
2100 trajectory.push_back(coordvec[i]->point[k]);
2105 float tmpLength=0.0;
2106 for(
unsigned int j=0; j < trajectory.size() - 1; ++j){
2107 tmpLength += (trajectory[j] - trajectory[j + 1]).length();
2110 if(tmpLength > longestLength){
2112 longestLength = tmpLength;
2124 SoLineSet *trajectory = (SoLineSet *)path->getTail();
2125 SoSeparator * grpNode = (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
2126 int nodeIndex = grpNode->findChild(trajectory);
2131 for(
int i = 0; i < 100; ++i){
2134 tmpNode = grpNode->getChild(nodeIndex);
2135 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
2137 return (SoCoordinate3 *)tmpNode;
2148 std::string field, eltName;
2150 std::map<std::string, int> duplicates;
2151 std::map<std::string, int> sceneElts;
2152 SoSearchAction search;
2154 SoGroup *root = (SoGroup *)getSceneManager()->getSceneGraph();
2156 SoBaseKit::setSearchingChildren(
TRUE);
2159 search.setSearchingAll(
TRUE);
2161 search.setType(Geant4_SoPolyhedron::getClassTypeId(), 0);
2164 SoPathList &
pl = search.getPaths();
2168 for(
int i = 0; i < pl.getLength(); i++) {
2169 SoFullPath *path = (SoFullPath *)pl[i];
2171 eltName = node->getName();
2172 if(duplicates.count(eltName))
2173 duplicates[eltName]++;
2175 duplicates[eltName] = 1;
2178 for(
int i = 0; i < pl.getLength(); i++) {
2180 std::stringstream ssCount;
2181 SoFullPath *path = (SoFullPath *)pl[i];
2183 eltName = node->getName();
2185 if(duplicates[eltName] == 1)
2188 if(sceneElts.count(eltName))
2189 sceneElts[eltName]++;
2191 sceneElts[eltName] = 1;
2193 ssCount << sceneElts[eltName];
2197 field += ssCount.str();
2199 SoGetBoundingBoxAction bAction(getViewportRegion());
2200 bAction.apply(path);
2201 SbBox3f bBox = bAction.getBoundingBox();
2203 SbVec3f centr = bBox.getCenter();
2204 centr.getValue(x,y,z);
2217 return x*x + y*y + z*
z;
2223 SbVec3f &closestPoint,
2262 SbVec3f dbq = b - q;
2263 float sqrDist =
sqrlen(dbq);
2266 for (
size_t i = 1; i < count; ++i) {
2267 const SbVec3f
a =
b;
2268 const SbVec3f daq = dbq;
2271 const SbVec3f dab = a -
b;
2273 float dab_x, dab_y, dab_z;
2274 dab.getValue(dab_x,dab_y,dab_z);
2275 float daq_x, daq_y, daq_z;
2276 daq.getValue(daq_x, daq_y, daq_z);
2277 float dbq_x, dbq_y, dbq_z;
2278 dbq.getValue(dbq_x, dbq_y, dbq_z);
2280 const float inv_sqrlen = 1./
sqrlen(dab);
2281 const float t = (dab_x*daq_x + dab_y*daq_y + dab_z*daq_z)*inv_sqrlen;
2292 current_dist = daq_x*daq_x + daq_y*daq_y + daq_z*daq_z
2293 - t*(daq_x*dab_x + daq_y*dab_y + daq_z*dab_z)
2294 + t*t*(dab_x*dab_x + dab_y*dab_y + dab_z*dab_z);
2299 current_dist =
sqrlen(dbq);
2302 if (current_dist < sqrDist){
2303 sqrDist = current_dist;
2304 closestPoint = a + t*(b-
a);
2309 dist = std::sqrt(sqrDist);
2319 typedef std::map<elementForSorting, sceneElement> sortedMap;
2328 trajLength[trajIndex] = 0.0;
2332 trajLength[trajIndex] = trajLength[trajIndex-1] + (*itRef - prevPoint).length();
2340 SoGetBoundingBoxAction bAction(this->getViewportRegion());
2341 SbVec3f elementCoord;
2342 std::vector<sceneElement>::iterator itEl;
2347 bAction.apply(itEl->path);
2348 elementCoord = bAction.getBoundingBox().getCenter();
2360 sorted.insert(std::make_pair(el,*itEl));
2366 sortedMap::iterator itSorted = sorted.begin();
2367 for(; itSorted != sorted.end(); itSorted++)
2373 Widget formTop = XtNameToWidget(this->
listsDialog,
"FormTop");
2374 Widget formTopRight = XtNameToWidget(formTop,
"FormTopRight");
2378 delete[] trajLength;
2388 XmString *elements = (XmString *) XtMalloc(size *
sizeof(XmString));
2390 std::vector<sceneElement>::const_iterator it;
2392 std::stringstream ss;
2396 ss <<
" [" << it->closestPointZCoord <<
"]";
2397 elements[count] = XmStringCreateLocalized((
char *)ss.str().c_str());
2408 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2410 labelRight = XmCreateLabelGadget(formTopRight, (
char*)
"Element [S mm]",
2412 XtManageChild(labelRight);
2416 XtSetArg(args[n], XmNvisibleItemCount, 7); n++;
2417 XtSetArg(args[n], XmNitemCount, size); n++;
2418 XtSetArg(args[n], XmNitems, elements); n++;
2419 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2420 XtSetArg(args[n], XmNtopWidget, labelRight); n++;
2421 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2422 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2424 XtSetArg(args[n], XmNwidth, 240); n++;
2428 this->
myElementList = XmCreateScrolledList(formTopRight, (
char *)
"ListRight", args, n);
2430 XtAddCallback(this->
myElementList, XmNbrowseSelectionCallback,
2435 if (elements != NULL) {
2436 for (
int i = 0; i < size; i++)
2437 XmStringFree(elements[i]);
2438 XtFree((
char *) elements);
2447 XtPointer client_data,
2450 G4cout <<
"DEBUG constructListsDialog w = " << w <<
G4endl;
2474 Atom WM_DELETE_WINDOW;
2483 G4cout <<
"DEBUG PARENT (topShell) FOR AUX WINDOW = " << topShell <<
G4endl;
2486 std::string dialogNameStr = This->
fileName.substr(This->
fileName.rfind(
'/') + 1);
2487 const int nDialog = dialogNameStr.size() + 1;
2488 char *dialogName =
new char[nDialog];
2489 strncpy(dialogName, dialogNameStr.c_str(), nDialog);
2492 XtSetArg(args[n], XmNx, 610); n++;
2493 This->
myShellDialog = XmCreateDialogShell(topShell, dialogName, args, n);
2495 delete[] dialogName;
2496 WM_DELETE_WINDOW = XInternAtom(XtDisplay(w),
"WM_DELETE_WINDOW", False);
2497 XmAddWMProtocolCallback(This->
myShellDialog, WM_DELETE_WINDOW,
2502 XtSetArg(args[n], XmNsashWidth, 1); n++;
2503 XtSetArg(args[n], XmNsashHeight, 1); n++;
2504 XtSetArg(args[n], XmNseparatorOn, False); n++;
2514 Widget formTop = XmCreateForm(This->
listsDialog, (
char *)
"FormTop", args, n);
2517 XtSetArg(args[n], XmNmarginWidth, 8); n++;
2518 XtSetArg(args[n], XmNmarginHeight, 8); n++;
2519 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2520 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2521 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2522 Widget formTopRight = XmCreateForm(formTop, (
char *)
"FormTopRight", args,
2526 XtSetArg(args[n], XmNmarginWidth, 8); n++;
2527 XtSetArg(args[n], XmNmarginHeight, 8); n++;
2528 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2529 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2530 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2531 XtSetArg(args[n], XmNrightWidget, formTopRight); n++;
2532 XtSetArg(args[n], XmNrightOffset, 10); n++;
2533 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2534 Widget formTopLeft = XmCreateForm(formTop, (
char *)
"FormTopLeft", args, n);
2539 XtManageChild(formTopRight);
2545 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2546 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2547 Widget labelLeft = XmCreateLabelGadget(formTopLeft, (
char *)
"ViewPoints",
2549 XtManageChild(labelLeft);
2553 XtSetArg(args[n], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); n++;
2554 XtSetArg(args[n], XmNvisibleItemCount, 7); n++;
2556 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2557 XtSetArg(args[n], XmNtopWidget, labelLeft); n++;
2558 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2559 XtSetArg(args[n], XmNrightWidget, This->
myElementList); n++;
2560 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2561 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
2563 XtSetArg(args[n], XmNwidth, 160); n++;
2566 This->
myViewPtList = XmCreateScrolledList(formTopLeft, (
char *)
"ListLeft",
2570 XtAddCallback(This->
myViewPtList, XmNbrowseSelectionCallback,
2576 XtManageChild(formTopLeft);
2578 XtManageChild(formTop);
2582 XtSetArg(args[n], XmNmarginWidth, 6); n++;
2585 Widget formMiddle = XmCreateForm(This->
listsDialog, (
char *)
"MiddleForm", args, n);
2589 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2590 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2591 XtSetArg(args[n], XmNtopWidget, This->
myViewPtList); n++;
2592 Widget label = XmCreateLabelGadget(formMiddle, (
char *)
"Selection", args,
2594 XtManageChild(label);
2598 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2599 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2600 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2601 XtSetArg(args[n], XmNtopWidget, label); n++;
2602 XtSetArg(args[n], XmNtopOffset, 3); n++;
2603 XtSetArg(args[n], XmNmaxLength, This->
MAX_VP_NAME); n++;
2604 This->
viewPtSelection = XmCreateText(formMiddle, (
char *)
"Txt", args, n);
2607 Dimension
h1,
h2, h;
2608 XtVaGetValues(label, XmNheight, &h1, NULL);
2611 h = (Dimension) (1.1 * (h1 + h2));
2613 XtVaSetValues(formMiddle, XmNpaneMaximum, h, XmNpaneMinimum, h, NULL);
2614 XtManageChild(formMiddle);
2619 XtSetArg(args[n], XmNfractionBase, 4); n++;
2620 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2624 Widget formAction = XmCreateForm(This->
listsDialog, (
char *)
"ActionForm", args, n);
2627 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
2628 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
2629 XtSetArg(args[n], XmNtopOffset, 3); n++;
2630 XtSetArg(args[n], XmNbottomOffset, 5); n++;
2631 Widget separator = XmCreateSeparatorGadget(formAction, (
char *)
"Sep", args, n);
2633 XtManageChild(separator);
2635 Widget button = XmCreatePushButton(formAction, (
char *)
"Delete", NULL, 0);
2636 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2637 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2638 XmATTACH_POSITION, XmNleftPosition, 0, XmNrightAttachment,
2639 XmATTACH_POSITION, XmNrightPosition, 1,
2640 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2643 XtAddCallback(button, XmNactivateCallback,
2645 XtManageChild(button);
2647 button = XmCreatePushButton(formAction, (
char *)
"Rename", NULL, 0);
2648 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2649 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2650 XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment,
2651 XmATTACH_POSITION, XmNrightPosition, 2,
2652 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2655 XtAddCallback(button, XmNactivateCallback,
2657 XtManageChild(button);
2659 button = XmCreatePushButton(formAction, (
char *)
"Sort", NULL, 0);
2660 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2661 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2662 XmATTACH_POSITION, XmNleftPosition, 2, XmNrightAttachment,
2663 XmATTACH_POSITION, XmNrightPosition, 3,
2664 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2667 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)
sortBookmarksCB, This);
2668 XtManageChild(button);
2670 button = XmCreatePushButton(formAction, (
char *)
"Close", NULL, 0);
2671 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2672 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2673 XmATTACH_POSITION, XmNleftPosition, 3, XmNrightAttachment,
2674 XmATTACH_POSITION, XmNrightPosition, 4,
2675 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2678 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc) closeListsDialogCB, This);
2679 XtManageChild(button);
2681 XtManageChild(formAction);
2682 XtVaGetValues(button, XmNheight, &h1, NULL);
2683 XtVaSetValues(formAction, XmNpaneMaximum, h1, XmNpaneMinimum, h1, NULL);
2694 XtPointer client_data,
2695 XtPointer call_data)
2698 std::string elementField;
2700 SoCamera * cam = This->getCamera();
2702 if (This->SoXtExaminerViewer::isAnimating())
2703 This->stopAnimating();
2705 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
2707 value = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
2708 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
2715 This->scheduleRedraw();
2721 elementField = value;
2723 int idx = elementField.find_last_of(
"[");
2725 idx = elementField.size();
2731 SoSearchAction search;
2732 SoNode *root = This->getSceneManager()->getSceneGraph();
2733 int counter, idxUnderscore = elementField.find_last_of(
"_");
2735 This->
parseString<
int>(counter, elementField.substr(idxUnderscore + 1, idx),
error);
2737 SoBaseKit::setSearchingChildren(
TRUE);
2739 search.setSearchingAll(
TRUE);
2742 This->
curEltName = elementField.substr(0, idx);
2746 path = (SoFullPath *)search.getPath();
2749 This->
curEltName = elementField.substr(0, idxUnderscore);
2754 SoPathList &
pl = search.getPaths();
2755 path = (SoFullPath *)pl[counter - 1];
2760 if ((idx > 0) && (path)) {
2764 SoGetBoundingBoxAction bAction(This->getViewportRegion());
2765 bAction.apply(path);
2766 SbBox3f bBox = bAction.getBoundingBox();
2767 SbVec3f elementCoord = bBox.getCenter();
2772 float absLengthNow, absLengthMin;
2778 absLengthMin = (p - elementCoord).length();
2784 absLengthNow = (p - elementCoord).length();
2786 if (absLengthNow < absLengthMin) {
2787 absLengthMin = absLengthNow;
2800 This->
distance = (pN - p1).length() / 10;
2803 if (cam->isOfType(SoOrthographicCamera::getClassTypeId()))
2804 ((SoOrthographicCamera *) cam)->height.setValue(This->
defaultHeight);
2806 else if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2807 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
2810 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2811 This->
distance = (This->
prevPt - cam->position.getValue()).length();
2817 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
2820 This->scheduleRedraw();
2833 cam->viewAll(path, This->getViewportRegion());
2844 XtPointer client_data,
2891 std::stringstream out;
2894 fileOut.seekp(0, std::ios::beg);
2902 fileOut.seekp(0, std::ios::end);
2920 SoCamera * camera = getCamera();
2921 if (camera == NULL) {
2922 String dialogName = (
char *)
"Missing Camera Node";
2923 std::string msg =
"Camera is null. Unable to set the viewpoint.";
2929 String dialogName = (
char *)
"Missing Viewpoints";
2930 std::string msg =
"There are no viewpoints to load.";
2935 if (SoXtExaminerViewer::isAnimating())
2942 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
2960 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
2963 camera = getCamera();
2964 ((SoOrthographicCamera *) camera)->height.setValue(
2967 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
2969 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
2972 camera = getCamera();
2973 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
2976 ((SoOrthographicCamera *) camera)->height.setValue(
2979 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::setViewPt",
2980 "Only Perspective and Orthographic cameras are supported.");
2990 XtPointer client_data,
3003 Widget nameViewPtDialog;
3004 Widget parent = This->getParentWidget();
3005 XmString label = XmStringCreateLocalized((
char *)
"Name the viewpoint:");
3007 XtSetArg(args[n], XmNselectionLabelString, label); n++;
3008 XtSetArg(args[n], XmNautoUnmanage, False); n++;
3012 nameViewPtDialog = XmCreatePromptDialog(parent, (
char *)
"Save Viewpoint",
3015 XmStringFree(label);
3016 XtAddCallback(nameViewPtDialog, XmNokCallback,
getViewPtNameCB, This);
3017 XtAddCallback(nameViewPtDialog, XmNcancelCallback,
3018 (XtCallbackProc) XtDestroyWidget, NULL);
3020 Widget text = XtNameToWidget(nameViewPtDialog,
"Text");
3021 XtVaSetValues(text, XmNmaxLength, This->
MAX_VP_NAME, NULL);
3022 std::string autoName =
"";
3027 XmTextSetString(text, (
char *) autoName.c_str());
3028 XmTextSetInsertionPosition(text, autoName.length());
3030 XtUnmanageChild(XtNameToWidget(nameViewPtDialog,
"Help"));
3031 XtManageChild(nameViewPtDialog);
3038 std::stringstream sstream;
3039 std::vector<int> existingViewPts;
3043 for (
unsigned int i = 0; i < this->
viewPtList.size(); ++i) {
3045 if (viewPt.find(
"viewpoint_") != std::string::npos) {
3046 tmp = atoi(viewPt.substr(10).c_str());
3049 if (!viewPt.compare(
"viewpoint_0"))
3050 existingViewPts.push_back(0);
3052 existingViewPts.push_back(tmp);
3060 if (existingViewPts.size() > 0) {
3063 if (std::find(existingViewPts.begin(), existingViewPts.end(), vpNum)
3064 == existingViewPts.end()) {
3065 sstream <<
"viewpoint_" << vpNum;
3066 return sstream.str();
3071 return "viewpoint_0";
3078 XtPointer client_data,
3088 XtPointer client_data,
3095 if(This->isViewing())
3096 This->setViewing(
false);
3097 This->setComponentCursor(SoXtCursor(SoXtCursor::CROSSHAIR));
3105 XtPointer client_data,
3106 XtPointer call_data)
3109 std::string strName;
3111 XmSelectionBoxCallbackStruct *cbs =
3112 (XmSelectionBoxCallbackStruct *) call_data;
3113 XmStringGetLtoR(cbs->value, XmFONTLIST_DEFAULT_TAG, &name);
3126 int beg = strName.find_first_not_of(
' ');
3127 int end = strName.find_last_not_of(
' ');
3128 strName = strName.substr(beg, end - beg + 1);
3130 bool nameExists =
false;
3132 for (
int i = 0; i < size; i++) {
3133 if (!strcmp(This->
viewPtList[i].viewPtName, strName.c_str())) {
3141 name =
new char[nVPName];
3142 strncpy(name, strName.c_str(), nVPName);
3147 XmListAddItemUnselected(This->
myViewPtList, cbs->value, 0);
3152 String dialogName = (
char *)
"Existing Viewpoint";
3153 std::string msg =
"The viewpoint already exists.";
3167 SoCamera * camera = getCamera();
3177 tmp.
position = camera->position.getValue();
3185 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
3186 tmp.
height = ((SoPerspectiveCamera *) camera)->heightAngle.getValue();
3188 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
3189 tmp.
height = ((SoOrthographicCamera *) camera)->height.getValue();
3192 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::saveViewPtCB",
3193 "Only Perspective and Orthographic cameras are supported.");
3200 std::string vpName =
name;
3205 fileOut << vpName << std::endl;
3207 fileOut << x <<
" " << y <<
" " << z << std::endl;
3211 axis.getValue(x, y, z);
3212 fileOut << x <<
" " << y <<
" " << z <<
" " << angle << std::endl;
3226 XtPointer client_data,
3243 std::ofstream out(
"temporaryFile.txt");
3249 XmString vpNameStr = XmStringCreateLocalized(vpName);
3252 XmStringFree(vpNameStr);
3256 out << line <<
"\n";
3258 while (getline(
fileIn, line)) {
3259 end = line.find_last_not_of(
' ');
3260 line = line.substr(0, end + 1);
3261 if (!strcmp(line.c_str(), vpName)) {
3262 while (line.size()) {
3266 while (getline(
fileIn, line))
3267 out << line <<
"\n";
3269 while (line.size()) {
3270 out << line <<
"\n";
3279 while (idx < size) {
3280 if (!strcmp(
viewPtList[idx].viewPtName, vpName)) {
3293 rename(
"temporaryFile.txt",
fileName.c_str());
3296 fileOut.seekp(0, std::ios::end);
3316 int idx = 0, end,
pos;
3318 std::string line, newName;
3327 while (getline(
fileIn, line)) {
3328 end = line.find_last_not_of(
' ');
3329 line = line.substr(0, end + 1);
3333 fileOut.seekp(0, std::ios::end);
3344 while (idx < size) {
3360 int sortIdx = 0, unsortIdx = 0;
3369 int size = sortedViewPts.size();
3370 while (sortIdx < size) {
3371 while (strcmp(sortedViewPts[sortIdx].c_str(),
3375 std::string vpName =
viewPtList[unsortIdx].viewPtName;
3379 fileOut << vpName << std::endl;
3380 viewPtList[unsortIdx].position.getValue(x, y, z);
3381 fileOut << x <<
" " << y <<
" " << z << std::endl;
3384 viewPtList[unsortIdx].orientation.getValue(axis, angle);
3385 axis.getValue(x, y, z);
3386 fileOut << x <<
" " << y <<
" " << z <<
" " << angle << std::endl;
3389 <<
viewPtList[unsortIdx].height << std::endl;
3422 while (getline(
fileIn, token)) {
3424 int end = token.find_last_not_of(
' ');
3425 token = token.substr(0, end + 1);
3427 char *vpName =
new char[token.size() + 1];
3428 strcpy(vpName, token.c_str());
3432 parseString<float>(
x, token,
error);
3434 parseString<float>(
y, token,
error);
3436 parseString<float>(
z, token,
error);
3438 tmp.
position = axis.setValue(x, y, z);
3440 parseString<float>(
x, token,
error);
3442 parseString<float>(
y, token,
error);
3444 parseString<float>(
z, token,
error);
3448 orient.setValue(axis.setValue(x, y, z),
angle);
3452 parseString<int>(camType, token,
error);
3489 std::istringstream str(s);
3490 if ((str >> t).fail())
3498 std::string dialogName,
3499 std::string buttonLabel,
3500 XtCallbackProc cbOK)
3504 Widget parent, scrollWidget;
3505 parent = SoXt::getShellWidget(getParentWidget());
3507 if (dialog == NULL) {
3510 XmString str = XmStringCreateLocalized((
char *) buttonLabel.c_str());
3513 XtSetArg(args[n], XmNokLabelString, str); n++;
3514 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3516 dialog = XmCreateFileSelectionDialog(parent,
3517 (
char *) dialogName.c_str(), args,
n);
3519 XtAddCallback(dialog, XmNokCallback, cbOK,
this);
3523 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_DIR_LIST);
3526 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_LIST);
3530 XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
3533 XtManageChild(dialog);
3550 XtPointer client_data,
3561 XtPointer client_data,
3562 XtPointer call_data)
3566 XmFileSelectionBoxCallbackStruct *cbs =
3567 (XmFileSelectionBoxCallbackStruct *) call_data;
3571 if (!(file = (
char *) XmStringUnparse(cbs->value,
3572 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3574 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::fileSelectedCB",
3575 "Internal error during file opening");
3580 if (!This->
fileIn.fail()) {
3584 String dialogName = (
char *)
"Error Loading File";
3585 std::string msg =
"Wrong or corrupted input file.";
3590 This->
fileOut.seekp(0, std::ios::end);
3597 std::string newDialogName = This->
fileName.substr(
3600 (
char *) newDialogName.c_str(), NULL);
3617 String dialogName = (
char *)
"Nonexistent File";
3618 std::string msg =
"Unable to open file.";
3638 viewPts = (XmString *) XtMalloc(size *
sizeof(XmString));
3639 for (
int i = 0; i < size; i++)
3640 viewPts[i] = XmStringCreateLocalized(
viewPtList[i].viewPtName);
3642 XmListAddItemsUnselected(
myViewPtList, viewPts, size, 1);
3644 if (viewPts != NULL) {
3645 for (
int i = 0; i < size; i++)
3646 XmStringFree(viewPts[i]);
3647 XtFree((
char *) viewPts);
3677 XmString warningMsg;
3679 warningMsg = XmStringCreateLocalized((
char *)msg.c_str());
3682 XtSetArg(args[n], XmNmessageString, warningMsg); n++;
3683 Widget warningDialog = XmCreateWarningDialog(getParentWidget(), dialogName, args, n);
3685 XtAddCallback(warningDialog, XmNokCallback, cb,
this);
3687 XmStringFree(warningMsg);
3689 XtVaSetValues (warningDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
3690 XtUnmanageChild(XtNameToWidget(warningDialog,
"Help"));
3691 XtUnmanageChild(XtNameToWidget(warningDialog,
"Cancel"));
3693 XtManageChild(warningDialog);
3698 XtPointer client_data,
3709 XtPointer client_data,
3710 XtPointer call_data)
3715 XmFileSelectionBoxCallbackStruct *cbs =
3716 (XmFileSelectionBoxCallbackStruct *) call_data;
3720 if (!(file = (
char *) XmStringUnparse(cbs->value,
3721 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3723 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::createNewVPFileCB",
3724 "Internal error during file opening");
3731 if (This->
fileIn.fail()) {
3745 String dialogName = (
char *)
"Existing File";
3746 std::string msg =
"'" + fName +
"' already exists. Do you want to overwrite it?";
3757 XtPointer client_data,
3777 XtPointer client_data,
3788 XtPointer client_data,
3789 XtPointer call_data)
3793 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
3798 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3799 XmCHARSET_TEXT, XmCHARSET_TEXT,
3800 NULL, 0, XmOUTPUT_ALL);
3802 std::ifstream ifs(file);
3806 while(ifs >> x >> y >> z){
3813 String dialogName = (
char *)
"Problem reading file";
3814 std::string msg =
"Problem reading file";
3826 XtPointer client_data,
3832 String dialogName = (
char *)
"No Reference Trajectory";
3833 std::string msg =
"You need to start a run or load a reference trajectory from a file";
3840 Widget parent, scrollWidget;
3841 parent = SoXt::getShellWidget(This->getParentWidget());
3846 XmString str = XmStringCreateLocalized((
char *)
"Save");
3849 XtSetArg(args[n], XmNokLabelString, str); n++;
3850 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
3852 This->
saveRefCoordsDialog = XmCreateFileSelectionDialog(parent,(
char *)
"Save Ref Coords", args, n);
3877 XtPointer client_data,
3878 XtPointer call_data)
3882 XmFileSelectionBoxCallbackStruct *cbs =
3883 (XmFileSelectionBoxCallbackStruct *) call_data;
3888 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3889 XmCHARSET_TEXT, XmCHARSET_TEXT,
3890 NULL, 0, XmOUTPUT_ALL);
3892 std::ifstream ifile(file);
3897 Widget parent = This->getParentWidget();
3898 Widget confirmOverwriteDialog;
3901 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite", args, 0);
3902 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
3903 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
3908 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
3918 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
3919 XtManageChild(confirmOverwriteDialog);
3925 std::ofstream ofs(file);
3930 ofs << x <<
" " << y <<
" " << z <<
"\n";
3936 String dialogName = (
char *)
"Error opening file";
3937 std::string msg =
"There was a problem trying to open the file '";
3951 XtPointer client_data,
3952 XtPointer call_data)
3954 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
3957 switch (cbs->reason) {
3967 ofs << x <<
" " << y <<
" " << z <<
"\n";
3974 String dialogName = (
char *)
"Error opening file";
3975 std::string msg =
"There was a problem trying to open the file '";
3989 XmProcessTraversal(XtNameToWidget(This->
saveRefCoordsWidget,
"Text"), XmTRAVERSE_CURRENT);
4003 XtPointer client_data,
4015 XtPointer client_data,
4016 XtPointer call_data)
4020 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
4024 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4025 XmCHARSET_TEXT, XmCHARSET_TEXT,
4026 NULL, 0, XmOUTPUT_ALL);
4029 if (!sceneInput.openFile(file)) {
4030 String dialogName = (
char *)
"Problem opening file";
4031 std::string msg =
"Cannot open file ";
4035 sceneInput.closeFile();
4041 String dialogName = (
char *)
"Problem reading file";
4042 std::string msg =
"Problem reading file";
4056 XtPointer client_data,
4063 Widget parent, scrollWidget;
4064 parent = SoXt::getShellWidget(This->getParentWidget());
4069 XmString str = XmStringCreateLocalized((
char *)
"Save");
4072 XtSetArg(args[n], XmNokLabelString, str); n++;
4073 XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
4075 This->
saveSceneGraphDialog = XmCreateFileSelectionDialog(parent,(
char *)
"Save Scene Graph", args, n);
4101 XtPointer client_data,
4102 XtPointer call_data)
4106 XmFileSelectionBoxCallbackStruct *cbs =
4107 (XmFileSelectionBoxCallbackStruct *) call_data;
4111 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4112 XmCHARSET_TEXT, XmCHARSET_TEXT,
4113 NULL, 0, XmOUTPUT_ALL);
4115 std::ifstream ifile(file);
4120 Widget parent = This->getParentWidget();
4121 Widget confirmOverwriteDialog;
4124 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite", args, 0);
4125 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
4126 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
4131 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
4141 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
4142 XtManageChild(confirmOverwriteDialog);
4148 SoWriteAction writeAction;
4149 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4151 SoOutput * out = writeAction.getOutput();
4153 if(out->openFile(file)){
4154 out->setBinary(
FALSE);
4155 writeAction.apply(root);
4161 String dialogName = (
char *)
"Error opening file";
4162 std::string msg =
"There was a problem trying to open the file '";
4178 XtPointer client_data,
4179 XtPointer call_data)
4181 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
4184 switch (cbs->reason) {
4189 SoWriteAction writeAction;
4190 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4192 SoOutput * out = writeAction.getOutput();
4194 out->setBinary(
FALSE);
4195 writeAction.apply(root);
4204 String dialogName = (
char *)
"Error opening file";
4205 std::string msg =
"There was a problem trying to open the file '";
4237 XtPointer client_data,
4238 XtPointer call_data)
4242 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
4244 vpName = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
4245 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4247 for (
int i = 0; i < (int) This->
viewPtList.size(); i++) {
4248 if (!strcmp(This->
viewPtList[i].viewPtName, vpName)) {
4263 XtPointer client_data,
4271 XmString vpNameStr = XmStringCreateLocalized(vpName);
4278 XmStringFree(vpNameStr);
4285 XtPointer client_data,
4288 std::string vpNameStr;
4290 int *pos_list, pos_cnt;
4295 if (!strlen(vpName) || !strcmp(This->
curViewPtName, vpName)) {
4302 int beg = vpNameStr.find_first_not_of(
' ');
4303 int end = vpNameStr.find_last_not_of(
' ');
4304 vpNameStr = vpNameStr.substr(beg, end - beg + 1);
4305 const int nVPName = vpNameStr.size() + 1;
4306 vpName =
new char[nVPName];
4307 strncpy(vpName, vpNameStr.c_str(), nVPName);
4310 for (
int i = 0; i < size; i++) {
4311 if (!strcmp(vpName, This->
viewPtList[i].viewPtName)) {
4313 String dialogName = (
char *)
"Existing Viewpoint";
4314 std::string msg =
"'";
4316 msg +=
"' already exists. Choose a different name";
4323 XmString vpNameXmStr = XmStringCreateLocalized(vpName);
4325 if (XmListGetSelectedPos(This->
myViewPtList, &pos_list, &pos_cnt)) {
4326 XmListReplaceItemsPos(This->
myViewPtList, &vpNameXmStr, 1, pos_list[0]);
4328 XtFree((
char *) pos_list);
4332 This->scheduleRedraw();
4334 XmStringFree(vpNameXmStr);
4339 XtPointer client_data,
4344 XmString *strList, *newStrList;
4345 std::vector<std::string> charList;
4352 XtVaGetValues(This->
myViewPtList, XmNitemCount, &size, XmNitems, &strList,
4355 for (
int i = 0; i < size; i++) {
4356 vpName = (
char *) XmStringUnparse(strList[i], XmFONTLIST_DEFAULT_TAG,
4357 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4358 charList.push_back(vpName);
4362 std::sort(charList.begin(), charList.end());
4364 newStrList = (XmString *) XtMalloc(size *
sizeof(XmString));
4365 for (
int i = 0; i < size; i++) {
4369 const int nVPName = charList[i].size() + 1;
4370 char *vpName2 =
new char[nVPName];
4371 strncpy(vpName2, charList[i].c_str(), nVPName);
4372 newStrList[i] = XmStringCreateLocalized(vpName2);
4377 XmListAddItemsUnselected(This->
myViewPtList, newStrList, size, 1);
4381 if (newStrList != NULL) {
4382 for (
int i = 0; i < size; i++)
4383 XmStringFree(newStrList[i]);
4384 XtFree((
char *) newStrList);
4394 SbVec3f p1, p2, p3, dirNow, dirNxt,
dir, p2_tmp, p_start, p_corner, p_nxt;
4395 float avgDistBtwPts = 0;
4396 float totalDistBtwPts = 0;
4397 std::vector<SbVec3f> newRefParticleTrajectory;
4401 for (
int i = 0; i < size; i++) {
4407 totalDistBtwPts += (p2 - p1).length();
4410 avgDistBtwPts = totalDistBtwPts / numOfPts;
4411 float minDistAllowed = 0.75 * avgDistBtwPts;
4421 p1.getValue(x, y, z);
4423 newRefParticleTrajectory.push_back(refPoint);
4426 while ((p2 - p1).length() < minDistAllowed && j < (size - 1)) {
4446 XtPointer client_data,
4465 SoCamera *cam = getCamera();
4474 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4476 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
4478 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4480 ((SoOrthographicCamera *) cam)->height.getValue();
4488 SoCamera *cam = getCamera();
4498 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4502 ((SoOrthographicCamera *) cam)->height.setValue(
4505 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4507 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4511 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4514 ((SoOrthographicCamera *) cam)->height.setValue(
4523 SbTime curTime = SbTime::getTimeOfDay();
4525 SoTimerSensor *
s = (SoTimerSensor *) sensor;
4527 float t = float((curTime - s->getBaseTime()).getValue())
4530 if ((t > 1.0
f) || (t + s->getInterval().getValue() > 1.0f))
4532 SbBool end = (t == 1.0f);
4555 SbTime curTime = SbTime::getTimeOfDay();
4557 SoCamera *cam = This->getCamera();
4558 SoTimerSensor *
s = (SoTimerSensor *) sensor;
4560 float t = float((curTime - s->getBaseTime()).getValue())
4563 if ((t > 1.0
f) || (t + s->getInterval().getValue() > 1.0f))
4565 SbBool end = (t == 1.0f);
4595 if (SoXtExaminerViewer::isAnimating())
4599 SbVec3f p1, p2, p2_tmp, camUpV, camD, camD_tmp, leftRightAxis;
4617 p1.getValue(x1, y1, z1);
4618 p2.getValue(x2, y2, z2);
4623 p2_tmp.setValue(x2, y1, z2);
4624 camD_tmp = p2_tmp - p1;
4625 camD_tmp.normalize();
4627 camUpV.setValue(0, 1, 0);
4628 rot.setValue(camD_tmp, camD);
4629 rot.multVec(camUpV, camUpV);
4631 leftRightAxis = camD.cross(camUpV);
4633 myCam->position = p1;
4634 myCam->pointAt(p2, camUpV);
4638 myCam->position = p1;
4644 myCam->focalDistance = 0.1f;
4656 XtPointer client_data,
4662 String dialogName = (
char *)
"No Reference Trajectory";
4663 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4676 This->scheduleRedraw();
4683 if (This->SoXtExaminerViewer::isAnimating())
4684 This->stopAnimating();
4693 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
4696 This->scheduleRedraw();
4708 This->
distance = (pN - p1).length() / 10;
4715 XtPointer client_data,
4734 XtPointer client_data,
4741 String dialogName = (
char *)
"No Reference Trajectory";
4742 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4753 This->
axisSwitch->whichChild.setValue(SO_SWITCH_ALL);
4756 This->scheduleRedraw();
4759 SoCamera *cam = This->getCamera();
4772 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4773 This->toggleCameraType();
4774 cam = This->getCamera();
4782 cam->focalDistance = 0.1f;
4783 ((SoPerspectiveCamera *) cam)->heightAngle = 0.50f;
4790 cam->orientation = (This->
myCam)->orientation.getValue();
4797 SoCamera *cam = getCamera();
4819 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
const std::vector< const std::vector< G4AttValue > * > & GetAttValues() const
static void saveRefCoordsOverWriteCB(Widget, XtPointer, XtPointer)
void xmAddMouseEventHandler(Widget w)
void renameViewPt(char *vpName)
static void loadBookmarkCB(Widget, XtPointer, XtPointer)
static void saveViewPtCB(Widget, XtPointer, XtPointer)
SoFont * mouseOverFontSolid
~G4OpenInventorXtExaminerViewer()
Widget saveRefCoordsDialog
Widget loadRefCoordsDialog
std::string viewPtAutoName()
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
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)
static void closeListsDialogCB(Widget, XtPointer, XtPointer)
std::vector< float > refZPositions
void parseString(T &t, const std::string &s, bool &error)
SoTranslation * mouseOverTransMaterial
void cleanUpAfterPrevFile()
const std::vector< const std::map< G4String, G4AttDef > * > & GetAttDefs() const
SoNode * getSuperimpositionNode(SoNode *, const char *name)
static void mouseoverCB(void *aThis, SoEventCallback *eventCB)
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 const char * console_xpm[]
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)
static const char * favorites_xpm[]
HookEventProcState * hookBeamOn
SoCoordinate3 * sgeometry
static void animateRefParticleCB(Widget, XtPointer, XtPointer)
float sqrlen(const SbVec3f &)
void distanceToTrajectory(const SbVec3f &, float &, SbVec3f &, int &)
void(* escapeCallback)(void *)
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 Pixmap createPixmapFromXpm(Widget button, const char **xpm, SbBool ghost=FALSE)
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)
SoSwitch * animSpeedSwitch
SoTimerSensor * animateSensorRotation
static void animateSensorCB(void *, SoSensor *)
static const char * thisClassName
static void nextViewPtCB(Widget, XtPointer, XtPointer)
void constructor(const SbBool build)
Widget buildWidget(Widget parent)
SoTranslation * stranslation
void superimpositionEvent(SoAction *action)
static void deleteBookmarkCB(Widget, XtPointer, XtPointer)
std::vector< sceneElement > sceneElements
double animateBtwPtsPeriod
SoText2 * mouseOverTextZPos
static void getViewPtNameCB(Widget, XtPointer, XtPointer)
static void openViewPtFileCB(Widget, XtPointer, XtPointer)
static PROLOG_HANDLER error
static void pickingCB(void *aThis, SoEventCallback *eventCB)
virtual SbBool processSoEvent(const SoEvent *const event)
Widget saveSceneGraphDialog
static void loadRefCoordsCB(Widget, XtPointer, XtPointer)
static const char * saveViewPt_xpm[]
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
std::string saveRefCoordsFileName
SoTranslation * mouseOverTransLogName
Widget saveScenegraphWidget
static void loadRefCoordsDialogCB(Widget, XtPointer, XtPointer)
virtual void createViewerButtons(Widget parent, SbPList *buttonlist)
Widget loadSceneGraphDialog