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>
52#include <Xm/SelectioB.h>
53#include <Xm/Protocols.h>
54#include <Xm/SeparatoG.h>
55#include <Xm/DialogS.h>
59#include <Xm/DrawingA.h>
61#include <Inventor/Xt/SoXt.h>
63#include <Inventor/Xt/SoXtCursor.h>
64#include <Inventor/events/SoKeyboardEvent.h>
65#include <Inventor/events/SoMouseButtonEvent.h>
66#include <Inventor/events/SoLocation2Event.h>
67#include <Inventor/nodes/SoSeparator.h>
68#include <Inventor/nodes/SoOrthographicCamera.h>
69#include <Inventor/nodes/SoPerspectiveCamera.h>
72#include <Inventor/nodes/SoLineSet.h>
73#include <Inventor/nodes/SoMaterial.h>
74#include <Inventor/errors/SoDebugError.h>
75#include <Inventor/SoPickedPoint.h>
76#include <Inventor/actions/SoWriteAction.h>
81#include <Inventor/sensors/SoTimerSensor.h>
82#include <Inventor/sensors/SoNodeSensor.h>
97#include <Inventor/nodes/SoCallback.h>
98#include <Inventor/nodes/SoSwitch.h>
99#include <Inventor/nodes/SoScale.h>
100#include <Inventor/nodes/SoTranslation.h>
101#include <Inventor/actions/SoSearchAction.h>
102#include <Inventor/actions/SoGetBoundingBoxAction.h>
104#include <Inventor/nodes/SoCoordinate3.h>
106#include <Inventor/nodes/SoText2.h>
107#include <Inventor/nodes/SoFont.h>
108#include <Inventor/nodes/SoPointSet.h>
109#include <Inventor/nodes/SoDrawStyle.h>
110#include <Inventor/nodes/SoBaseColor.h>
113#include <Inventor/nodekits/SoBaseKit.h>
116#include <Inventor/SbVec3f.h>
123#define START_STEP 0.3
124#define SPEED_INDICATOR_STEP 0.045
125#define MAX_SPEED_INDICATOR 0.81
131 const char *
name, SbBool embed,
133 SoXtExaminerViewer(parent,
name, embed, flag, type,
FALSE)
141 const char *
name, SbBool embed,
144 SoXtExaminerViewer(parent,
name, embed, flag, type,
FALSE)
165 myCam =
new SoPerspectiveCamera;
201 static const char * superimposed[] = {
202 "#Inventor V2.1 ascii",
"",
209 " OrthographicCamera ",
215 " DEF soxt->callback Callback { }",
218 " DEF soxt->translation Translation ",
220 " translation 0 0 0",
222 " DEF soxt->scale Scale ",
224 " scaleFactor 1 1 1",
226 " DEF soxt->geometry Coordinate3 ",
230 " -0.81 -0.04 0, -0.81 0 0,",
231 " -0.81 0.04 0, 0 -0.04 0,",
233 " 0.81 -0.04 0, 0.81 0 0,",
236 " 0.81 0.02 0, 0.81 -0.02 0,",
239 " 0.4 0.01 0, 0.4 -0.01 0,",
244 " DEF soxt->animSpeedOutlineSwitch Switch ",
249 " emissiveColor 0 0 0",
255 " 12, 11, 10, 9, -1",
260 " DEF soxt->axisSwitch Switch ",
279 " DEF soxt->animSpeedSwitch Switch ",
284 " emissiveColor 0 1 0",
290 " 16, 15, 14, 13, -1",
296 " DEF soxt->curInfoSwitch Switch ",
299 " DEF soxt->curInfoTrans Translation ",
301 " translation 10 20 30 ",
303 " DEF soxt->curInfoFont Font ",
305 " name defaultFont:Bold",
308 " DEF soxt->curInfoText Text2 ",
317 " DEF soxt->mouseOverTransLogName Translation ",
319 " translation 0 0 0 ",
321 " DEF soxt->mouseOverFontLogName Font ",
323 " name defaultFont:Bold",
326 " DEF soxt->mouseOverTextLogName Text2 { } ",
330 " DEF soxt->mouseOverTransSolid Translation ",
332 " translation 0 0 0 ",
334 " DEF soxt->mouseOverFontSolid Font ",
336 " name defaultFont:Bold",
339 " DEF soxt->mouseOverTextSolid Text2 { } ",
343 " DEF soxt->mouseOverTransMaterial Translation ",
345 " translation 0 0 0 ",
347 " DEF soxt->mouseOverFontMaterial Font ",
349 " name defaultFont:Bold",
352 " DEF soxt->mouseOverTextMaterial Text2 { } ",
356 " DEF soxt->mouseOverTransZPos Translation ",
358 " translation 0 0 0 ",
360 " DEF soxt->mouseOverFontZPos Font ",
362 " name defaultFont:Bold",
365 " DEF soxt->mouseOverTextZPos Text2 { } ",
371 for (i = bufsize = 0; superimposed[i]; i++)
372 bufsize += strlen(superimposed[i]) + 1;
373 char * buf =
new char[bufsize + 1];
374 for (i = bufsize = 0; superimposed[i]; i++) {
375 strcpy(buf + bufsize, superimposed[i]);
376 bufsize += strlen(superimposed[i]);
380 SoInput * input =
new SoInput;
381 input->setBuffer(buf, bufsize);
440 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
475 this->
searcher =
new SoSearchAction;
478 searcher->setInterest(SoSearchAction::FIRST);
482 return searcher->getPath()->getTail();
499 if (!
action->isOfType(SoGLRenderAction::getClassTypeId()))
501 SbViewportRegion vpRegion =
502 ((SoGLRenderAction *)
action)->getViewportRegion();
503 SbVec2s viewportSize = vpRegion.getViewportSizePixels();
505 float aspect = float(viewportSize[0]) / float(viewportSize[1]);
506 float factorx = 1.0f / float(viewportSize[1]) * 220.0f;
510 this->
stranslation->translation.setValue(SbVec3f(0.0f, -0.4f, 0.0f));
513 SbVec3f(0.0f, -0.4f / aspect, 0.0f));
517 if (viewportSize[0] > 500)
518 factorx *= 500.0f / 400.0f;
520 factorx *= float(viewportSize[0]) / 400.0f;
521 this->
sscale->scaleFactor.setValue(SbVec3f(factorx,
factory, 1.0f));
523 float xInfo, yInfo, xMouseLogName, yMouseLogName, xMouseSolid, yMouseSolid,
524 xMouseMaterial, yMouseMaterial, xMouseZPos, yMouseZPos;
528 yMouseLogName = -.75;
531 xMouseMaterial = 0.0;
532 yMouseMaterial = -.81;
538 xMouseSolid *= aspect;
539 xMouseMaterial *= aspect;
540 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
542 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
544 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
546 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
548 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
551 yMouseSolid /= aspect;
552 yMouseMaterial /= aspect;
553 this->
curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
555 SbVec3f(xMouseLogName, yMouseLogName, 0.0));
557 SbVec3f(xMouseSolid, yMouseSolid, 0.0));
559 SbVec3f(xMouseMaterial, yMouseMaterial, 0.0));
561 SbVec3f(xMouseZPos, yMouseZPos, 0.0));
566 this->
curInfoFont->name.setValue(
"defaultFont:Italic");
571 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
577 this->
curInfoFont->name.setValue(
"defaultFont:Bold");
580 this->
curInfoText->string.setValue(SbString(zPos));
609 Atom WM_DELETE_WINDOW;
612 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::buildWidget",
"Error: Parent is null.");
615 XtSetArg(
args[0], XmNtopAttachment, XmATTACH_FORM);
616 XtSetArg(
args[1], XmNleftAttachment, XmATTACH_FORM);
617 XtSetArg(
args[2], XmNrightAttachment, XmATTACH_FORM);
618 XtSetArg(
args[3], XmNbottomAttachment, XmATTACH_FORM);
619 Widget form = XmCreateForm(parent, (
char *)
"Form",
args, 4);
622 shell = XtParent(form);
623 WM_DELETE_WINDOW = XInternAtom(XtDisplay(parent),
"WM_DELETE_WINDOW",
625 XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW,
628 XtSetArg(
args[0], XmNtopAttachment, XmATTACH_FORM);
629 XtSetArg(
args[1], XmNleftAttachment, XmATTACH_FORM);
630 XtSetArg(
args[2], XmNrightAttachment, XmATTACH_FORM);
631 menuBar = XmCreateMenuBar(form, (
char *)
"MenuBar",
args, 3);
642 XmCreateSeparatorGadget(
fileMenu, (
char *)
"Separator", NULL, 0));
644 Widget menu =
addMenu(
"Tools");
649 Widget viewerBase = SoXtFullViewer::buildWidget(form);
651 XtSetArg(
args[0], XmNtopAttachment, XmATTACH_WIDGET);
653 XtSetArg(
args[2], XmNleftAttachment, XmATTACH_FORM);
654 XtSetArg(
args[3], XmNrightAttachment, XmATTACH_FORM);
655 XtSetArg(
args[4], XmNbottomAttachment, XmATTACH_FORM);
656 XtSetValues(viewerBase,
args, 5);
666 Widget menu = XmCreatePulldownMenu(
menuBar, (
char *)
name.c_str(), NULL, 0);
668 XtSetArg(
args[0], XmNsubMenuId, menu);
669 Widget w = XmCreateCascadeButton(
menuBar, (
char *)
name.c_str(),
args, 1);
680 Widget button = XmCreatePushButton(menu, (
char *)
name.c_str(), NULL, 0);
681 XtManageChild(button);
682 XtAddCallback(button, XmNactivateCallback, cb,
this);
688 SbPList * buttonlist)
692 Widget saveViewPtButton, abbrOutputButton, pickRefPathButton;
693 Widget switchWireFrameButton;
696 SoXtExaminerViewer::createViewerButtons(parent, buttonlist);
699 Widget emptyButton = XtVaCreateManagedWidget(
"", xmPushButtonWidgetClass,
701 buttonlist->append(emptyButton);
705 XtSetArg(
args[
n], XmNtopPosition, 1);
n++;
706 XtSetArg(
args[
n], XmNbottomPosition, 2);
n++;
707 XtSetArg(
args[
n], XmNleftPosition, 0);
n++;
708 XtSetArg(
args[
n], XmNrightPosition, 1);
n++;
709 XtSetArg(
args[
n], XmNarrowDirection, XmARROW_LEFT);
n++;
710 XtSetArg(
args[
n], XmNsensitive, False);
n++;
720 XtSetArg(
args[
n], XmNtopPosition, 1);
n++;
721 XtSetArg(
args[
n], XmNbottomPosition, 2);
n++;
722 XtSetArg(
args[
n], XmNleftPosition, 0);
n++;
723 XtSetArg(
args[
n], XmNrightPosition, 1);
n++;
724 XtSetArg(
args[
n], XmNarrowDirection, XmARROW_RIGHT);
n++;
725 XtSetArg(
args[
n], XmNsensitive, False);
n++;
734 saveViewPtButton = XtVaCreateManagedWidget(
"Save", xmPushButtonWidgetClass,
736 XtAddCallback(saveViewPtButton, XmNactivateCallback,
738 Pixmap saveVP, saveVP_ins;
743 XtVaSetValues(saveViewPtButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
744 saveVP, XmNselectPixmap, saveVP, XmNlabelInsensitivePixmap,
745 saveVP_ins, XmNselectInsensitivePixmap, saveVP_ins, NULL);
746 buttonlist->append(saveViewPtButton);
749 abbrOutputButton = XtVaCreateManagedWidget(
"Abbr",
750 xmToggleButtonWidgetClass, parent, XmNindicatorOn, False, NULL);
753 Pixmap pickextxpm, pickextxpm_ins;
758 XtVaSetValues(abbrOutputButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
759 pickextxpm, XmNselectPixmap, pickextxpm, XmNlabelInsensitivePixmap,
760 pickextxpm_ins, XmNselectInsensitivePixmap, pickextxpm_ins, NULL);
769 buttonlist->append(abbrOutputButton);
772 pickRefPathButton = XtVaCreateManagedWidget(
"Refpath", xmPushButtonWidgetClass,
774 XtAddCallback(pickRefPathButton, XmNactivateCallback,
776 Pixmap pickrefxpm, pickrefxpm_ins;
781 XtVaSetValues(pickRefPathButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
782 pickrefxpm, XmNselectPixmap, pickrefxpm, XmNlabelInsensitivePixmap,
783 pickrefxpm_ins, XmNselectInsensitivePixmap, pickrefxpm_ins, NULL);
785 buttonlist->append(pickRefPathButton);
788 switchWireFrameButton = XtVaCreateManagedWidget(
"Wireframe",
789 xmToggleButtonWidgetClass, parent, XmNindicatorOn, False, NULL);
790 XtAddCallback(switchWireFrameButton, XmNvalueChangedCallback,
792 Pixmap wireframe, wireframe_ins;
797 XtVaSetValues(switchWireFrameButton, XmNlabelType, XmPIXMAP, XmNlabelPixmap,
798 wireframe, XmNselectPixmap, wireframe, XmNlabelInsensitivePixmap,
799 wireframe_ins, XmNselectInsensitivePixmap, wireframe_ins, NULL);
800 buttonlist->append(switchWireFrameButton);
808 SoXtExaminerViewer::afterRealizeHook();
812 SoCamera *cam = getCamera();
814 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
816 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
819 ((SoOrthographicCamera *) cam)->height.getValue();
823 ((SoOrthographicCamera *) cam)->height.getValue();
826 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
828 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
837 String dialogName = (
char *)
"Error Loading File";
838 std::string msg =
"Wrong or corrupted input file.";
843 fileOut.seekp(0, std::ios::end);
862 SoSeparator *root = (SoSeparator *) (getSceneManager()->getSceneGraph());
864 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::afterRealizeHook",
"Root is null.");
866 root->addChild(
myCam);
878 SoEventCallback *moCB =
new SoEventCallback;
879 moCB->addEventCallback(
880 SoLocation2Event::getClassTypeId(),
882 root->addChild(moCB);
886 SoEventCallback *pickCB =
new SoEventCallback;
887 pickCB->addEventCallback(
888 SoMouseButtonEvent::getClassTypeId(),
890 root->addChild(pickCB);
899 SoCamera *cam = getCamera();
906 cam->position = camPosNew;
908 cam->focalDistance = (
prevPt - camPosNew).length();
927 SoCamera *cam = getCamera();
940 cam->focalDistance = (cam->position.getValue() -
center).length();
949 dist = (
prevPt - cam->position.getValue()).length();
956 dist = (
prevPt - cam->position.getValue()).length();
965 particleDir = p2 - p1;
966 particleDir.normalize();
979 SbRotation rot(SbVec3f(0,0,1), particleDir);
993 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1013 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1016 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
1018 camPosNew = p2 - (
camDir*cam->focalDistance.getValue());
1022 cam->position = camPosNew;
1024 cam->focalDistance = (p2 - camPosNew).length();
1027 camPosNew.getValue(x,y,z);
1038 SoEventCallback *eventCB)
1040 SoHandleEventAction*
action = eventCB->getAction();
1041 const SoPickedPoint *
pp =
action->getPickedPoint();
1046 SoPath* path =
pp->getPath();
1047 SoNode* node = ((SoFullPath*)path)->getTail();
1049 if(node->getTypeId() == SoLineSet::getClassTypeId()){
1059 SoLineSet * trajectory = (SoLineSet *)node;
1065 SoSeparator * grpNode =
1066 (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
1071 int nodeIndex = grpNode->findChild(trajectory);
1074 SoCoordinate3 * coords = 0;
1078 for(
int i = 0; i < 100; ++i) {
1081 tmpNode = grpNode->getChild(nodeIndex);
1082 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
1084 coords = (SoCoordinate3 *)tmpNode;
1090 String dialogName = (
char *)
"No coordinates";
1091 std::string msg =
"Could not find the coordinates node"
1092 " for the picked trajectory."
1093 " Reference trajectory not set";
1110 if(attHolder && attHolder->
GetAttDefs().size()) {
1112 std::string strTrajPoint =
"G4TrajectoryPoint:";
1113 std::ostringstream oss;
1114 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1119 if(oss.str().find(strTrajPoint) != std::string::npos) {
1134 G4String cls((
char*)node->getTypeId().getName().getString());
1135 G4cout <<
"SoNode : " << node
1136 <<
" SoType : " << cls
1137 <<
" name : " <<
name
1154 if(attHolder && attHolder->
GetAttDefs().size()) {
1155 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1161 G4String cls((
char*)node->getTypeId().getName().getString());
1162 G4cout <<
"SoNode : " << node
1163 <<
" SoType : " << cls
1164 <<
" name : " <<
name
1170 eventCB->setHandled();
1177 SoHandleEventAction*
action = eventCB->getAction();
1178 const SoPickedPoint*
pp =
action->getPickedPoint();
1186 const SbViewportRegion & viewportRegion =
action->getViewportRegion();
1188 std::string sLogName;
1190 std::stringstream ssZPos;
1191 std::stringstream ssSolids;
1192 std::stringstream ssMaterials;
1193 SoPath * path =
pp->getPath();
1194 SoNode* node = ((SoFullPath*)path)->getTail();
1196 if(node->getTypeId() == Geant4_SoPolyhedron::getClassTypeId()) {
1198 sLogName =
"Logical Volume: ";
1201 SoGetBoundingBoxAction bAction(viewportRegion);
1202 bAction.apply((SoFullPath*)path);
1203 SbBox3f bBox = bAction.getBoundingBox();
1204 SbVec3f
center = bBox.getCenter();
1206 ssZPos <<
"Pos: " << x <<
" " << y <<
" " << z;
1209 if(attHolder && attHolder->
GetAttDefs().size()) {
1211 std::vector<const std::map<G4String,G4AttDef>*> vecDefs =
1213 std::vector<const std::vector<G4AttValue>*> vecVals =
1215 for (
size_t i = 0; i < vecDefs.size(); ++i) {
1216 const std::vector<G4AttValue> * vals = vecVals[i];
1218 std::vector<G4AttValue>::const_iterator iValue;
1220 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1221 const G4String& valueName = iValue->GetName();
1222 const G4String& value = iValue->GetValue();
1224 if(valueName ==
"Solid") {
1225 if(ssSolids.str() ==
"")
1226 ssSolids <<
"Solid Name: " << value;
1228 ssSolids <<
", " << value;
1231 if(valueName ==
"Material") {
1232 if(ssMaterials.str() ==
"")
1233 ssMaterials <<
"Material Name: " << value;
1235 ssMaterials <<
", " << value;
1242 else if(node->getTypeId() == SoLineSet::getClassTypeId()) {
1245 if(attHolder && attHolder->
GetAttDefs().size()) {
1246 std::string strTrajPoint =
"G4TrajectoryPoint:";
1247 std::ostringstream oss;
1249 for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
1252 const std::vector<G4AttValue>* vals = attHolder->
GetAttValues()[i];
1253 std::vector<G4AttValue>::const_iterator iValue;
1254 for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
1255 const G4String& valueName = iValue->GetName();
1256 const G4String& value = iValue->GetValue();
1260 if (valueName ==
"PN") t1 = value;
1261 if (valueName ==
"Ch") {
1262 if (atof(value.c_str()) > 0)
1268 if (valueName ==
"PDG") {
1276 if (valueName ==
"EventID") t2 =
"Evt " + value;
1277 if (valueName ==
"ID") t2 +=
" Trk " + value;
1278 if (valueName ==
"PID") {
1279 t2 +=
" Prt " + value;
1283 if (valueName ==
"IKE") t3 =
"KE " + value;
1284 if (valueName ==
"IMom") {
1286 unsigned ipos = value.rfind(
" ");
1289 t3 +=
" P (" + value1 +
")";
1291 if (valueName ==
"IMag") {
1292 t3 +=
" " + value +
"/c";
1297 if (valueName ==
"NTP") {
1298 std::ostringstream t4oss;
1299 t4oss <<
"TrjPts " << value;
1300 t4oss <<
" Pos " <<
pp->getPoint()[0] <<
" " <<
pp->getPoint()[1] <<
1301 " " <<
pp->getPoint()[2];
1324 This->scheduleRedraw();
1325 eventCB->setHandled();
1329 bool redraw =
false;
1334 if(std::string(This->
mouseOverTextSolid->string.getValues(0)->getString()) != ssSolids.str()) {
1338 if(std::string(This->
mouseOverTextMaterial->string.getValues(0)->getString()) != ssMaterials.str()){
1342 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) != ssZPos.str()) {
1349 This->scheduleRedraw();
1352 eventCB->setHandled();
1357 This->scheduleRedraw();
1361 This->scheduleRedraw();
1365 This->scheduleRedraw();
1367 if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) !=
"") {
1369 This->scheduleRedraw();
1376 SoCamera *cam = getCamera();
1377 const SoType type(ev->getTypeId());
1379 if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
1380 SoMouseButtonEvent * me = (SoMouseButtonEvent *) ev;
1384 switch (me->getButton()) {
1385 case SoMouseButtonEvent::BUTTON4:
1386 if (me->getState() == SoButtonEvent::DOWN) {
1387 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1389 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1390 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1393 }
else if (cam->isOfType(
1394 SoOrthographicCamera::getClassTypeId())) {
1396 ((SoOrthographicCamera *) cam)->height.getValue();
1397 ((SoOrthographicCamera *) cam)->height = height + 5;
1402 case SoMouseButtonEvent::BUTTON5:
1403 if (me->getState() == SoButtonEvent::DOWN) {
1404 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
1406 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
1408 ((SoPerspectiveCamera *) cam)->heightAngle = hAngle
1411 }
else if (cam->isOfType(
1412 SoOrthographicCamera::getClassTypeId())) {
1414 ((SoOrthographicCamera *) cam)->height.getValue();
1416 ((SoOrthographicCamera *) cam)->height = height - 5;
1430 if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
1431 SoKeyboardEvent * ke = (SoKeyboardEvent *) ev;
1433 if (SoKeyboardEvent::isKeyPressEvent(ev, ke->getKey())) {
1434 switch (ke->getKey()) {
1435 case SoKeyboardEvent::LEFT_SHIFT:
1438 case SoKeyboardEvent::RIGHT_SHIFT:
1441 case SoKeyboardEvent::LEFT_CONTROL:
1444 case SoKeyboardEvent::RIGHT_CONTROL:
1447 case SoKeyboardEvent::SPACE:
1469 case SoKeyboardEvent::ESCAPE:
1485 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
1496 case SoKeyboardEvent::DELETE:
1501 String dialogName = (
char *)
"Delete Viewpoint";
1502 std::string msg =
"Are you sure you want to delete current viewpoint?";
1507 case SoKeyboardEvent::LEFT_ARROW:
1515 if (SoXtExaminerViewer::isAnimating())
1531 if (SoXtExaminerViewer::isAnimating())
1556 cam->position =
myCam->position;
1563 this->bottomWheelMotion(
1564 this->getBottomWheelValue() + 0.1f);
1574 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1575 "Unhandled viewer state");
1580 case SoKeyboardEvent::RIGHT_ARROW:
1588 if (SoXtExaminerViewer::isAnimating())
1602 if (SoXtExaminerViewer::isAnimating())
1624 cam->position =
myCam->position;
1631 this->bottomWheelMotion(
1632 this->getBottomWheelValue() - 0.1f);
1641 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1642 "Unhandled viewer state");
1647 case SoKeyboardEvent::DOWN_ARROW:
1656 if (SoXtExaminerViewer::isAnimating())
1679 cam->position =
myCam->position;
1686 this->leftWheelMotion(this->getLeftWheelValue() - 0.1f);
1695 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1696 "Unhandled viewer state");
1701 case SoKeyboardEvent::UP_ARROW:
1709 if (SoXtExaminerViewer::isAnimating())
1732 cam->position =
myCam->position;
1739 this->leftWheelMotion(this->getLeftWheelValue() + 0.1f);
1748 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::processSoEvent",
1749 "Unhandled viewer state");
1754 case SoKeyboardEvent::PAGE_UP:
1805 case SoKeyboardEvent::PAGE_DOWN:
1853 case SoKeyboardEvent::E:
1861 if (SoKeyboardEvent::isKeyReleaseEvent(ev, ke->getKey())) {
1862 switch (ke->getKey()) {
1863 case SoKeyboardEvent::LEFT_SHIFT:
1866 case SoKeyboardEvent::RIGHT_SHIFT:
1869 case SoKeyboardEvent::LEFT_CONTROL:
1872 case SoKeyboardEvent::RIGHT_CONTROL:
1885 return SoXtExaminerViewer::processSoEvent(ev);
1901 if (refParticleIdx < lastIdx && !animateSensor->isScheduled())
1927 SbVec3f * points = this->
sgeometry->point.startEditing();
1929 if (points[10][0] == 0.0f)
1931 if (points[14][0] == 0.0f)
1951 SoXtExaminerViewer::actualRedraw();
1954 SoXtExaminerViewer::actualRedraw();
2000 SbVec3f refParticlePt;
2005 for(
int i = 0; i < lineset->numVertices.getNum(); ++i){
2006 for(
int j = 0; j < lineset->numVertices[i]; ++j){
2007 refParticlePt = coords->point[j];
2034 action.setType(SoLineSet::getClassTypeId(),
false);
2036 action.apply(this->getSceneGraph());
2038 SoPathList &pathList =
action.getPaths();
2040 if(pathList.getLength() != 0){
2042 SoCoordinate3 * coords = NULL;
2043 std::vector<SoCoordinate3 *> coordvec;
2044 std::vector<SoLineSet *> linevec;
2046 bool refPathFound =
false;
2047 for(
int i = 0; i < pathList.getLength(); ++i) {
2048 SoFullPath *path = (SoFullPath *)pathList[i];
2051 for (
size_t j = 0; j < attHolder->
GetAttDefs().size(); ++j) {
2052 std::ostringstream oss;
2055 std::string findStr =
"Type of trajectory (Type): ";
2056 std::string compareValue =
"REFERENCE";
2057 size_t idx = oss.str().find(findStr);
2059 if(idx != std::string::npos) {
2060 if(oss.str().substr(idx + findStr.size(), compareValue.size()) == compareValue) {
2063 refPathFound =
true;
2064 coordvec.push_back(coords);
2065 linevec.push_back((SoLineSet *)path->getTail());
2071 findStr =
"Track ID (ID): ";
2072 idx = oss.str().find(findStr);
2073 if(idx != std::string::npos) {
2075 std::string tmpstr = oss.str().substr(idx + findStr.size(),1);
2076 std::istringstream
buffer(tmpstr);
2084 char nextChar = oss.str().at(idx+findStr.size()+1);
2087 if(std::isdigit(nextChar))
2093 coordvec.push_back(coords);
2094 linevec.push_back((SoLineSet *)path->getTail());
2110 if(coordvec.empty())
2121 float longestLength = 0.0;
2123 for(
unsigned int i=0;i < linevec.size(); ++i){
2126 std::vector<SbVec3f> trajectory;
2128 for(
int j=0; j < linevec[i]->numVertices.getNum(); ++j){
2130 for(
int k=0; k < linevec[i]->numVertices[j]; ++k){
2131 trajectory.push_back(coordvec[i]->point[k]);
2136 float tmpLength=0.0;
2137 for(
unsigned int j=0; j < trajectory.size() - 1; ++j){
2138 tmpLength += (trajectory[j] - trajectory[j + 1]).length();
2141 if(tmpLength > longestLength){
2143 longestLength = tmpLength;
2155 SoLineSet *trajectory = (SoLineSet *)path->getTail();
2156 SoSeparator * grpNode = (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
2157 int nodeIndex = grpNode->findChild(trajectory);
2162 for(
int i = 0; i < 100; ++i){
2165 tmpNode = grpNode->getChild(nodeIndex);
2166 if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()){
2168 return (SoCoordinate3 *)tmpNode;
2179 std::string field, eltName;
2181 std::map<std::string, int> duplicates;
2182 std::map<std::string, int> sceneElts;
2183 SoSearchAction search;
2185 SoGroup *root = (SoGroup *)getSceneManager()->getSceneGraph();
2187 SoBaseKit::setSearchingChildren(
TRUE);
2190 search.setSearchingAll(
TRUE);
2192 search.setType(Geant4_SoPolyhedron::getClassTypeId(), 0);
2195 SoPathList &pl = search.getPaths();
2199 for(
int i = 0; i < pl.getLength(); i++) {
2200 SoFullPath *path = (SoFullPath *)pl[i];
2202 eltName = node->getName();
2203 if(duplicates.count(eltName))
2204 duplicates[eltName]++;
2206 duplicates[eltName] = 1;
2209 for(
int i = 0; i < pl.getLength(); i++) {
2211 std::stringstream ssCount;
2212 SoFullPath *path = (SoFullPath *)pl[i];
2214 eltName = node->getName();
2216 if(duplicates[eltName] == 1)
2219 if(sceneElts.count(eltName))
2220 sceneElts[eltName]++;
2222 sceneElts[eltName] = 1;
2224 ssCount << sceneElts[eltName];
2228 field += ssCount.str();
2230 SoGetBoundingBoxAction bAction(getViewportRegion());
2231 bAction.apply(path);
2232 SbBox3f bBox = bAction.getBoundingBox();
2234 SbVec3f centr = bBox.getCenter();
2235 centr.getValue(x,y,z);
2248 return x*x + y*y + z*z;
2254 SbVec3f &closestPoint,
2293 SbVec3f dbq = b - q;
2294 float sqrDist =
sqrlen(dbq);
2297 for (
size_t i = 1; i < count; ++i) {
2298 const SbVec3f a = b;
2299 const SbVec3f daq = dbq;
2302 const SbVec3f dab = a - b;
2304 float dab_x, dab_y, dab_z;
2305 dab.getValue(dab_x,dab_y,dab_z);
2306 float daq_x, daq_y, daq_z;
2307 daq.getValue(daq_x, daq_y, daq_z);
2308 float dbq_x, dbq_y, dbq_z;
2309 dbq.getValue(dbq_x, dbq_y, dbq_z);
2311 const float inv_sqrlen = 1./
sqrlen(dab);
2312 const float t = (dab_x*daq_x + dab_y*daq_y + dab_z*daq_z)*inv_sqrlen;
2323 current_dist = daq_x*daq_x + daq_y*daq_y + daq_z*daq_z
2324 - t*(daq_x*dab_x + daq_y*dab_y + daq_z*dab_z)
2325 + t*t*(dab_x*dab_x + dab_y*dab_y + dab_z*dab_z);
2330 current_dist =
sqrlen(dbq);
2333 if (current_dist < sqrDist){
2334 sqrDist = current_dist;
2335 closestPoint = a + t*(b-a);
2340 dist = std::sqrt(sqrDist);
2350 typedef std::map<elementForSorting, sceneElement> sortedMap;
2359 trajLength[trajIndex] = 0.0;
2363 trajLength[trajIndex] = trajLength[trajIndex-1] + (*itRef - prevPoint).length();
2371 SoGetBoundingBoxAction bAction(this->getViewportRegion());
2372 SbVec3f elementCoord;
2373 std::vector<sceneElement>::iterator itEl;
2377 itEl != this->sceneElements.end(); ++itEl, ++elementIndex){
2378 bAction.apply(itEl->path);
2381 elementCoord = itEl->center;
2399 sorted.insert(std::make_pair(el,*itEl));
2405 sortedMap::iterator itSorted = sorted.begin();
2406 for(; itSorted != sorted.end(); itSorted++)
2412 Widget formTop = XtNameToWidget(this->
listsDialog,
"FormTop");
2413 Widget formTopRight = XtNameToWidget(formTop,
"FormTopRight");
2417 delete[] trajLength;
2427 XmString *elements = (XmString *) XtMalloc(size *
sizeof(XmString));
2429 std::vector<sceneElement>::const_iterator it;
2431 std::stringstream ss;
2435 ss <<
" [" << it->closestPointZCoord <<
"]";
2436 elements[count] = XmStringCreateLocalized((
char *)ss.str().c_str());
2447 XtSetArg(
args[
n], XmNtopAttachment, XmATTACH_FORM);
n++;
2449 labelRight = XmCreateLabelGadget(formTopRight, (
char*)
"Element [S mm]",
2451 XtManageChild(labelRight);
2455 XtSetArg(
args[
n], XmNvisibleItemCount, 7);
n++;
2456 XtSetArg(
args[
n], XmNitemCount, size);
n++;
2457 XtSetArg(
args[
n], XmNitems, elements);
n++;
2458 XtSetArg(
args[
n], XmNtopAttachment, XmATTACH_WIDGET);
n++;
2459 XtSetArg(
args[
n], XmNtopWidget, labelRight);
n++;
2460 XtSetArg(
args[
n], XmNrightAttachment, XmATTACH_FORM);
n++;
2461 XtSetArg(
args[
n], XmNbottomAttachment, XmATTACH_FORM);
n++;
2463 XtSetArg(
args[
n], XmNwidth, 240);
n++;
2467 this->
myElementList = XmCreateScrolledList(formTopRight, (
char *)
"ListRight",
args,
n);
2469 XtAddCallback(this->
myElementList, XmNbrowseSelectionCallback,
2474 if (elements != NULL) {
2475 for (
int i = 0; i < size; i++)
2476 XmStringFree(elements[i]);
2477 XtFree((
char *) elements);
2486 XtPointer client_data,
2513 Atom WM_DELETE_WINDOW;
2525 std::string dialogNameStr = This->
fileName.substr(This->
fileName.rfind(
'/') + 1);
2526 const int nDialog = dialogNameStr.size() + 1;
2527 char *dialogName =
new char[nDialog];
2528 strncpy(dialogName, dialogNameStr.c_str(), nDialog);
2531 XtSetArg(
args[
n], XmNx, 610);
n++;
2534 delete[] dialogName;
2535 WM_DELETE_WINDOW = XInternAtom(XtDisplay(w),
"WM_DELETE_WINDOW", False);
2536 XmAddWMProtocolCallback(This->
myShellDialog, WM_DELETE_WINDOW,
2541 XtSetArg(
args[
n], XmNsashWidth, 1);
n++;
2542 XtSetArg(
args[
n], XmNsashHeight, 1);
n++;
2543 XtSetArg(
args[
n], XmNseparatorOn, False);
n++;
2553 Widget formTop = XmCreateForm(This->
listsDialog, (
char *)
"FormTop",
args,
n);
2556 XtSetArg(
args[
n], XmNmarginWidth, 8);
n++;
2557 XtSetArg(
args[
n], XmNmarginHeight, 8);
n++;
2558 XtSetArg(
args[
n], XmNtopAttachment, XmATTACH_FORM);
n++;
2559 XtSetArg(
args[
n], XmNrightAttachment, XmATTACH_FORM);
n++;
2560 XtSetArg(
args[
n], XmNbottomAttachment, XmATTACH_FORM);
n++;
2561 Widget formTopRight = XmCreateForm(formTop, (
char *)
"FormTopRight",
args,
2565 XtSetArg(
args[
n], XmNmarginWidth, 8);
n++;
2566 XtSetArg(
args[
n], XmNmarginHeight, 8);
n++;
2567 XtSetArg(
args[
n], XmNtopAttachment, XmATTACH_FORM);
n++;
2568 XtSetArg(
args[
n], XmNleftAttachment, XmATTACH_FORM);
n++;
2569 XtSetArg(
args[
n], XmNrightAttachment, XmATTACH_WIDGET);
n++;
2570 XtSetArg(
args[
n], XmNrightWidget, formTopRight);
n++;
2571 XtSetArg(
args[
n], XmNrightOffset, 10);
n++;
2572 XtSetArg(
args[
n], XmNbottomAttachment, XmATTACH_FORM);
n++;
2573 Widget formTopLeft = XmCreateForm(formTop, (
char *)
"FormTopLeft",
args,
n);
2578 XtManageChild(formTopRight);
2584 XtSetArg(
args[
n], XmNtopAttachment, XmATTACH_FORM);
n++;
2585 XtSetArg(
args[
n], XmNleftAttachment, XmATTACH_FORM);
n++;
2586 Widget labelLeft = XmCreateLabelGadget(formTopLeft, (
char *)
"ViewPoints",
2588 XtManageChild(labelLeft);
2592 XtSetArg(
args[
n], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE);
n++;
2593 XtSetArg(
args[
n], XmNvisibleItemCount, 7);
n++;
2595 XtSetArg(
args[
n], XmNtopAttachment, XmATTACH_WIDGET);
n++;
2596 XtSetArg(
args[
n], XmNtopWidget, labelLeft);
n++;
2597 XtSetArg(
args[
n], XmNrightAttachment, XmATTACH_WIDGET);
n++;
2599 XtSetArg(
args[
n], XmNleftAttachment, XmATTACH_FORM);
n++;
2600 XtSetArg(
args[
n], XmNbottomAttachment, XmATTACH_FORM);
n++;
2602 XtSetArg(
args[
n], XmNwidth, 160);
n++;
2605 This->
myViewPtList = XmCreateScrolledList(formTopLeft, (
char *)
"ListLeft",
2609 XtAddCallback(This->
myViewPtList, XmNbrowseSelectionCallback,
2615 XtManageChild(formTopLeft);
2617 XtManageChild(formTop);
2621 XtSetArg(
args[
n], XmNmarginWidth, 6);
n++;
2624 Widget formMiddle = XmCreateForm(This->
listsDialog, (
char *)
"MiddleForm",
args,
n);
2628 XtSetArg(
args[
n], XmNleftAttachment, XmATTACH_FORM);
n++;
2629 XtSetArg(
args[
n], XmNtopAttachment, XmATTACH_WIDGET);
n++;
2631 Widget label = XmCreateLabelGadget(formMiddle, (
char *)
"Selection",
args,
2633 XtManageChild(label);
2637 XtSetArg(
args[
n], XmNleftAttachment, XmATTACH_FORM);
n++;
2638 XtSetArg(
args[
n], XmNrightAttachment, XmATTACH_FORM);
n++;
2639 XtSetArg(
args[
n], XmNtopAttachment, XmATTACH_WIDGET);
n++;
2640 XtSetArg(
args[
n], XmNtopWidget, label);
n++;
2641 XtSetArg(
args[
n], XmNtopOffset, 3);
n++;
2646 Dimension h1, h2, h;
2647 XtVaGetValues(label, XmNheight, &h1, NULL);
2650 h = (Dimension) (1.1 * (h1 + h2));
2652 XtVaSetValues(formMiddle, XmNpaneMaximum, h, XmNpaneMinimum, h, NULL);
2653 XtManageChild(formMiddle);
2658 XtSetArg(
args[
n], XmNfractionBase, 4);
n++;
2659 XtSetArg(
args[
n], XmNtopAttachment, XmATTACH_WIDGET);
n++;
2663 Widget formAction = XmCreateForm(This->
listsDialog, (
char *)
"ActionForm",
args,
n);
2666 XtSetArg(
args[
n], XmNleftAttachment, XmATTACH_FORM);
n++;
2667 XtSetArg(
args[
n], XmNrightAttachment, XmATTACH_FORM);
n++;
2668 XtSetArg(
args[
n], XmNtopOffset, 3);
n++;
2669 XtSetArg(
args[
n], XmNbottomOffset, 5);
n++;
2670 Widget separator = XmCreateSeparatorGadget(formAction, (
char *)
"Sep",
args,
n);
2672 XtManageChild(separator);
2674 Widget button = XmCreatePushButton(formAction, (
char *)
"Delete", NULL, 0);
2675 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2676 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2677 XmATTACH_POSITION, XmNleftPosition, 0, XmNrightAttachment,
2678 XmATTACH_POSITION, XmNrightPosition, 1,
2679 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2682 XtAddCallback(button, XmNactivateCallback,
2684 XtManageChild(button);
2686 button = XmCreatePushButton(formAction, (
char *)
"Rename", NULL, 0);
2687 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2688 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2689 XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment,
2690 XmATTACH_POSITION, XmNrightPosition, 2,
2691 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2694 XtAddCallback(button, XmNactivateCallback,
2696 XtManageChild(button);
2698 button = XmCreatePushButton(formAction, (
char *)
"Sort", NULL, 0);
2699 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2700 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2701 XmATTACH_POSITION, XmNleftPosition, 2, XmNrightAttachment,
2702 XmATTACH_POSITION, XmNrightPosition, 3,
2703 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2706 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)
sortBookmarksCB, This);
2707 XtManageChild(button);
2709 button = XmCreatePushButton(formAction, (
char *)
"Close", NULL, 0);
2710 XtVaSetValues(button, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget,
2711 separator, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment,
2712 XmATTACH_POSITION, XmNleftPosition, 3, XmNrightAttachment,
2713 XmATTACH_POSITION, XmNrightPosition, 4,
2714 XmNdefaultButtonShadowThickness, 2, XmNwidth, 40, XmNheight, 30,
2717 XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)
closeListsDialogCB, This);
2718 XtManageChild(button);
2720 XtManageChild(formAction);
2721 XtVaGetValues(button, XmNheight, &h1, NULL);
2722 XtVaSetValues(formAction, XmNpaneMaximum, h1, XmNpaneMinimum, h1, NULL);
2733 XtPointer client_data,
2734 XtPointer call_data)
2737 std::string elementField;
2739 SoCamera * cam = This->getCamera();
2741 if (This->SoXtExaminerViewer::isAnimating())
2742 This->stopAnimating();
2744 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
2746 value = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
2747 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
2754 This->scheduleRedraw();
2760 elementField = value;
2762 int idx = elementField.find_last_of(
"[");
2764 idx = elementField.size();
2770 SoSearchAction search;
2771 SoNode *root = This->getSceneManager()->getSceneGraph();
2772 int counter, idxUnderscore = elementField.find_last_of(
"_");
2774 This->
parseString<
int>(counter, elementField.substr(idxUnderscore + 1, idx),
error);
2776 SoBaseKit::setSearchingChildren(
TRUE);
2778 search.setSearchingAll(
TRUE);
2781 This->
curEltName = elementField.substr(0, idx);
2785 path = (SoFullPath *)search.getPath();
2788 This->
curEltName = elementField.substr(0, idxUnderscore);
2793 SoPathList &pl = search.getPaths();
2794 path = (SoFullPath *)pl[counter - 1];
2799 if ((idx > 0) && (path)) {
2803 SoGetBoundingBoxAction bAction(This->getViewportRegion());
2804 bAction.apply(path);
2805 SbBox3f bBox = bAction.getBoundingBox();
2806 SbVec3f elementCoord = bBox.getCenter();
2811 float absLengthNow, absLengthMin;
2817 absLengthMin = (p - elementCoord).length();
2823 absLengthNow = (p - elementCoord).length();
2825 if (absLengthNow < absLengthMin) {
2826 absLengthMin = absLengthNow;
2839 This->
distance = (pN - p1).length() / 10;
2851 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2855 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
2856 This->
distance = (This->
prevPt - cam->position.getValue()).length();
2862 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
2865 This->scheduleRedraw();
2878 cam->viewAll(path, This->getViewportRegion());
2889 XtPointer client_data,
2936 std::stringstream out;
2939 fileOut.seekp(0, std::ios::beg);
2947 fileOut.seekp(0, std::ios::end);
2965 SoCamera * camera = getCamera();
2966 if (camera == NULL) {
2967 String dialogName = (
char *)
"Missing Camera Node";
2968 std::string msg =
"Camera is null. Unable to set the viewpoint.";
2974 String dialogName = (
char *)
"Missing Viewpoints";
2975 std::string msg =
"There are no viewpoints to load.";
2980 if (SoXtExaminerViewer::isAnimating())
2987 axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
3005 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
3008 camera = getCamera();
3009 ((SoOrthographicCamera *) camera)->height.setValue(
3012 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
3014 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
3017 camera = getCamera();
3018 ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
3021 ((SoOrthographicCamera *) camera)->height.setValue(
3024 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::setViewPt",
3025 "Only Perspective and Orthographic cameras are supported.");
3035 XtPointer client_data,
3048 Widget nameViewPtDialog;
3049 Widget parent = This->getParentWidget();
3050 XmString label = XmStringCreateLocalized((
char *)
"Name the viewpoint:");
3052 XtSetArg(
args[
n], XmNselectionLabelString, label);
n++;
3054 XtSetArg(
args[
n], XmNautoUnmanage, False);
n++;
3056 XtSetArg(
args[
n], XmNtitle,
"Save Bookmark");
n++;
3057 nameViewPtDialog = XmCreatePromptDialog(parent, String(
"Save Bookmark"),
3060 XmStringFree(label);
3061 XtAddCallback(nameViewPtDialog, XmNokCallback,
getViewPtNameCB, This);
3062 XtAddCallback(nameViewPtDialog, XmNcancelCallback,
3067 Widget text = XtNameToWidget(nameViewPtDialog,
"Text");
3068 XtVaSetValues(text, XmNmaxLength, This->
MAX_VP_NAME, NULL);
3069 std::string autoName =
"";
3074 XmTextSetString(text, (
char *) autoName.c_str());
3075 XmTextSetInsertionPosition(text, autoName.length());
3077 XtUnmanageChild(XtNameToWidget(nameViewPtDialog,
"Help"));
3078 XtManageChild(nameViewPtDialog);
3085 std::stringstream sstream;
3086 std::vector<int> existingViewPts;
3090 for (
unsigned int i = 0; i < this->
viewPtList.size(); ++i) {
3092 if (viewPt.find(
"viewpoint_") != std::string::npos) {
3093 tmp = atoi(viewPt.substr(10).c_str());
3096 if (!viewPt.compare(
"viewpoint_0"))
3097 existingViewPts.push_back(0);
3099 existingViewPts.push_back(tmp);
3107 if (existingViewPts.size() > 0) {
3110 if (std::find(existingViewPts.begin(), existingViewPts.end(), vpNum)
3111 == existingViewPts.end()) {
3112 sstream <<
"viewpoint_" << vpNum;
3113 return sstream.str();
3118 return "viewpoint_0";
3125 XtPointer client_data,
3136 XtPointer client_data,
3143 if(This->isViewing())
3144 This->setViewing(
false);
3145 This->setComponentCursor(SoXtCursor(SoXtCursor::CROSSHAIR));
3151 XtPointer client_data,
3157 if (XmToggleButtonGetState(w)) {
3158 This->setDrawStyle(SoXtViewer::STILL, SoXtViewer::VIEW_LINE);
3159 This->setDrawStyle(SoXtViewer::INTERACTIVE, SoXtViewer::VIEW_LINE);
3161 This->setDrawStyle(SoXtViewer::STILL, SoXtViewer::VIEW_AS_IS);
3162 This->setDrawStyle(SoXtViewer::INTERACTIVE,
3163 SoXtViewer::VIEW_SAME_AS_STILL);
3171 XtPointer client_data,
3172 XtPointer call_data)
3175 std::string strName;
3177 XmSelectionBoxCallbackStruct *cbs =
3178 (XmSelectionBoxCallbackStruct *) call_data;
3179 XmStringGetLtoR(cbs->value, XmFONTLIST_DEFAULT_TAG, &
name);
3192 int beg = strName.find_first_not_of(
' ');
3193 int end = strName.find_last_not_of(
' ');
3194 strName = strName.substr(beg, end - beg + 1);
3196 bool nameExists =
false;
3198 for (
int i = 0; i < size; i++) {
3199 if (!strcmp(This->
viewPtList[i].viewPtName, strName.c_str())) {
3207 name =
new char[nVPName];
3208 strncpy(
name, strName.c_str(), nVPName);
3213 XmListAddItemUnselected(This->
myViewPtList, cbs->value, 0);
3218 String dialogName = (
char *)
"Existing Viewpoint";
3219 std::string msg =
"The viewpoint already exists.";
3239 float x, y, z,
angle;
3240 SoCamera * camera = getCamera();
3250 tmp.
position = camera->position.getValue();
3258 if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
3259 tmp.
height = ((SoPerspectiveCamera *) camera)->heightAngle.getValue();
3261 }
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
3262 tmp.
height = ((SoOrthographicCamera *) camera)->height.getValue();
3265 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::saveViewPtCB",
3266 "Only Perspective and Orthographic cameras are supported.");
3273 std::string vpName =
name;
3278 fileOut << vpName << std::endl;
3280 fileOut << x <<
" " << y <<
" " << z << std::endl;
3284 axis.getValue(x, y, z);
3285 fileOut << x <<
" " << y <<
" " << z <<
" " <<
angle << std::endl;
3299 XtPointer client_data,
3316 std::ofstream out(
"temporaryFile.txt");
3322 XmString vpNameStr = XmStringCreateLocalized(vpName);
3325 XmStringFree(vpNameStr);
3329 out << line <<
"\n";
3331 while (getline(
fileIn, line)) {
3332 end = line.find_last_not_of(
' ');
3333 line = line.substr(0, end + 1);
3334 if (!strcmp(line.c_str(), vpName)) {
3335 while (line.size()) {
3339 while (getline(
fileIn, line))
3340 out << line <<
"\n";
3342 while (line.size()) {
3343 out << line <<
"\n";
3352 while (idx < size) {
3353 if (!strcmp(
viewPtList[idx].viewPtName, vpName)) {
3366 int istat = remove(
fileName.c_str());
3368 char dialogName[] =
"Warning";
3372 istat = rename(
"temporaryFile.txt",
fileName.c_str());
3374 char dialogName[] =
"Warning";
3379 fileOut.seekp(0, std::ios::end);
3399 int idx = 0, end,
pos;
3401 std::string line, newName;
3410 while (getline(
fileIn, line)) {
3411 end = line.find_last_not_of(
' ');
3412 line = line.substr(0, end + 1);
3416 fileOut.seekp(0, std::ios::end);
3427 while (idx < size) {
3442 float x, y, z,
angle;
3443 int sortIdx = 0, unsortIdx = 0;
3452 int size = sortedViewPts.size();
3453 while (sortIdx < size) {
3454 while (strcmp(sortedViewPts[sortIdx].c_str(),
3458 std::string vpName =
viewPtList[unsortIdx].viewPtName;
3462 fileOut << vpName << std::endl;
3463 viewPtList[unsortIdx].position.getValue(x, y, z);
3464 fileOut << x <<
" " << y <<
" " << z << std::endl;
3468 axis.getValue(x, y, z);
3469 fileOut << x <<
" " << y <<
" " << z <<
" " <<
angle << std::endl;
3472 <<
viewPtList[unsortIdx].height << std::endl;
3498 float x, y, z,
angle;
3505 while (getline(
fileIn, token)) {
3507 int end = token.find_last_not_of(
' ');
3508 token = token.substr(0, end + 1);
3510 char *vpName =
new char[token.size() + 1];
3511 strcpy(vpName, token.c_str());
3515 parseString<float>(x, token,
error);
3517 parseString<float>(y, token,
error);
3519 parseString<float>(z, token,
error);
3521 tmp.
position = axis.setValue(x, y, z);
3523 parseString<float>(x, token,
error);
3525 parseString<float>(y, token,
error);
3527 parseString<float>(z, token,
error);
3531 orient.setValue(axis.setValue(x, y, z),
angle);
3535 parseString<int>(camType, token,
error);
3572 std::istringstream str(
s);
3573 if ((str >> t).
fail())
3581 std::string dialogName,
3582 std::string buttonLabel,
3583 XtCallbackProc cbOK)
3587 Widget parent, scrollWidget;
3588 parent = SoXt::getShellWidget(getParentWidget());
3590 if (dialog == NULL) {
3593 XmString str = XmStringCreateLocalized((
char *) buttonLabel.c_str());
3596 XtSetArg(
args[
n], XmNokLabelString, str);
n++;
3597 XtSetArg(
args[
n], XmNresizePolicy, XmRESIZE_NONE);
n++;
3599 dialog = XmCreateFileSelectionDialog(parent,
3600 (
char *) dialogName.c_str(),
args,
n);
3602 XtAddCallback(dialog, XmNokCallback, cbOK,
this);
3606 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_DIR_LIST);
3609 scrollWidget = XmFileSelectionBoxGetChild(dialog, XmDIALOG_LIST);
3613 XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
3616 XtManageChild(dialog);
3633 XtPointer client_data,
3644 XtPointer client_data,
3645 XtPointer call_data)
3649 XmFileSelectionBoxCallbackStruct *cbs =
3650 (XmFileSelectionBoxCallbackStruct *) call_data;
3654 if (!(
file = (
char *) XmStringUnparse(cbs->value,
3655 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3657 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::fileSelectedCB",
3658 "Internal error during file opening");
3663 if (!This->
fileIn.fail()) {
3667 String dialogName = (
char *)
"Error Loading File";
3668 std::string msg =
"Wrong or corrupted input file.";
3673 This->
fileOut.seekp(0, std::ios::end);
3680 std::string newDialogName = This->
fileName.substr(
3683 (
char *) newDialogName.c_str(), NULL);
3700 String dialogName = (
char *)
"Nonexistent File";
3701 std::string msg =
"Unable to open file.";
3721 viewPts = (XmString *) XtMalloc(size *
sizeof(XmString));
3722 for (
int i = 0; i < size; i++)
3723 viewPts[i] = XmStringCreateLocalized(
viewPtList[i].viewPtName);
3725 XmListAddItemsUnselected(
myViewPtList, viewPts, size, 1);
3727 if (viewPts != NULL) {
3728 for (
int i = 0; i < size; i++)
3729 XmStringFree(viewPts[i]);
3730 XtFree((
char *) viewPts);
3760 XmString warningMsg;
3762 warningMsg = XmStringCreateLocalized((
char *)msg.c_str());
3765 XtSetArg(
args[
n], XmNmessageString, warningMsg);
n++;
3766 Widget warningDialog = XmCreateWarningDialog(getParentWidget(), dialogName,
args,
n);
3768 XtAddCallback(warningDialog, XmNokCallback, cb,
this);
3770 XmStringFree(warningMsg);
3772 XtVaSetValues (warningDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
3773 XtUnmanageChild(XtNameToWidget(warningDialog,
"Help"));
3774 XtUnmanageChild(XtNameToWidget(warningDialog,
"Cancel"));
3776 XtManageChild(warningDialog);
3781 XtPointer client_data,
3792 XtPointer client_data,
3793 XtPointer call_data)
3798 XmFileSelectionBoxCallbackStruct *cbs =
3799 (XmFileSelectionBoxCallbackStruct *) call_data;
3803 if (!(
file = (
char *) XmStringUnparse(cbs->value,
3804 XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0,
3806 SoDebugError::post(
"G4OpenInventorXtExaminerViewer::createNewVPFileCB",
3807 "Internal error during file opening");
3814 if (This->
fileIn.fail()) {
3828 String dialogName = (
char *)
"Existing File";
3829 std::string msg =
"'" + fName +
"' already exists. Do you want to overwrite it?";
3840 XtPointer client_data,
3860 XtPointer client_data,
3871 XtPointer client_data,
3872 XtPointer call_data)
3876 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
3881 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3882 XmCHARSET_TEXT, XmCHARSET_TEXT,
3883 NULL, 0, XmOUTPUT_ALL);
3885 std::ifstream ifs(
file);
3889 while(ifs >> x >> y >> z){
3896 String dialogName = (
char *)
"Problem reading file";
3897 std::string msg =
"Problem reading file";
3909 XtPointer client_data,
3915 String dialogName = (
char *)
"No Reference Trajectory";
3916 std::string msg =
"You need to start a run or load a reference trajectory from a file";
3923 Widget parent, scrollWidget;
3924 parent = SoXt::getShellWidget(This->getParentWidget());
3929 XmString str = XmStringCreateLocalized((
char *)
"Save");
3932 XtSetArg(
args[
n], XmNokLabelString, str);
n++;
3933 XtSetArg(
args[
n], XmNresizePolicy, XmRESIZE_NONE);
n++;
3960 XtPointer client_data,
3961 XtPointer call_data)
3965 XmFileSelectionBoxCallbackStruct *cbs =
3966 (XmFileSelectionBoxCallbackStruct *) call_data;
3971 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
3972 XmCHARSET_TEXT, XmCHARSET_TEXT,
3973 NULL, 0, XmOUTPUT_ALL);
3975 std::ifstream ifile(
file);
3980 Widget parent = This->getParentWidget();
3981 Widget confirmOverwriteDialog;
3984 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite",
args, 0);
3985 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
3986 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
3991 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
4001 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
4002 XtManageChild(confirmOverwriteDialog);
4008 std::ofstream ofs(
file);
4013 ofs << x <<
" " << y <<
" " << z <<
"\n";
4019 String dialogName = (
char *)
"Error opening file";
4020 std::string msg =
"There was a problem trying to open the file '";
4034 XtPointer client_data,
4035 XtPointer call_data)
4037 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
4040 switch (cbs->reason) {
4050 ofs << x <<
" " << y <<
" " << z <<
"\n";
4057 String dialogName = (
char *)
"Error opening file";
4058 std::string msg =
"There was a problem trying to open the file '";
4072 XmProcessTraversal(XtNameToWidget(This->
saveRefCoordsWidget,
"Text"), XmTRAVERSE_CURRENT);
4086 XtPointer client_data,
4098 XtPointer client_data,
4099 XtPointer call_data)
4103 XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *)call_data;
4107 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4108 XmCHARSET_TEXT, XmCHARSET_TEXT,
4109 NULL, 0, XmOUTPUT_ALL);
4112 if (!sceneInput.openFile(
file)) {
4113 String dialogName = (
char *)
"Problem opening file";
4114 std::string msg =
"Cannot open file ";
4118 sceneInput.closeFile();
4124 String dialogName = (
char *)
"Problem reading file";
4125 std::string msg =
"Problem reading file";
4139 XtPointer client_data,
4146 Widget parent, scrollWidget;
4147 parent = SoXt::getShellWidget(This->getParentWidget());
4152 XmString str = XmStringCreateLocalized((
char *)
"Save");
4155 XtSetArg(
args[
n], XmNokLabelString, str);
n++;
4156 XtSetArg(
args[
n], XmNresizePolicy, XmRESIZE_NONE);
n++;
4184 XtPointer client_data,
4185 XtPointer call_data)
4189 XmFileSelectionBoxCallbackStruct *cbs =
4190 (XmFileSelectionBoxCallbackStruct *) call_data;
4194 file = (
char *)XmStringUnparse(cbs->value, XmFONTLIST_DEFAULT_TAG,
4195 XmCHARSET_TEXT, XmCHARSET_TEXT,
4196 NULL, 0, XmOUTPUT_ALL);
4198 std::ifstream ifile(
file);
4203 Widget parent = This->getParentWidget();
4204 Widget confirmOverwriteDialog;
4207 confirmOverwriteDialog = XmCreateQuestionDialog (parent, (
char *)
"Confirm overwrite",
args, 0);
4208 msg = XmStringCreateLocalized ((
char *)
"File exists. Overwrite?");
4209 XtVaSetValues (confirmOverwriteDialog, XmNmessageString, msg, NULL);
4214 XtVaSetValues (confirmOverwriteDialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL);
4224 XtUnmanageChild(XtNameToWidget(confirmOverwriteDialog,
"Help"));
4225 XtManageChild(confirmOverwriteDialog);
4231 SoWriteAction writeAction;
4232 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4234 SoOutput * out = writeAction.getOutput();
4236 if(out->openFile(
file)){
4237 out->setBinary(
FALSE);
4238 writeAction.apply(root);
4244 String dialogName = (
char *)
"Error opening file";
4245 std::string msg =
"There was a problem trying to open the file '";
4261 XtPointer client_data,
4262 XtPointer call_data)
4264 XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
4267 switch (cbs->reason) {
4272 SoWriteAction writeAction;
4273 SoSeparator *root = (SoSeparator *) (This->getSceneGraph());
4275 SoOutput * out = writeAction.getOutput();
4277 out->setBinary(
FALSE);
4278 writeAction.apply(root);
4287 String dialogName = (
char *)
"Error opening file";
4288 std::string msg =
"There was a problem trying to open the file '";
4320 XtPointer client_data,
4321 XtPointer call_data)
4325 XmListCallbackStruct *cbs = (XmListCallbackStruct *) call_data;
4327 vpName = (
char *) XmStringUnparse(cbs->item, XmFONTLIST_DEFAULT_TAG,
4328 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4330 for (
int i = 0; i < (int) This->
viewPtList.size(); i++) {
4331 if (!strcmp(This->
viewPtList[i].viewPtName, vpName)) {
4346 XtPointer client_data,
4354 XmString vpNameStr = XmStringCreateLocalized(vpName);
4361 XmStringFree(vpNameStr);
4368 XtPointer client_data,
4371 std::string vpNameStr;
4373 int *pos_list, pos_cnt;
4378 if (!strlen(vpName) || !strcmp(This->
curViewPtName, vpName)) {
4385 int beg = vpNameStr.find_first_not_of(
' ');
4386 int end = vpNameStr.find_last_not_of(
' ');
4387 vpNameStr = vpNameStr.substr(beg, end - beg + 1);
4388 const int nVPName = vpNameStr.size() + 1;
4389 char* vpName1 =
new char[nVPName];
4390 strncpy(vpName1, vpNameStr.c_str(), nVPName);
4393 for (
int i = 0; i < size; i++) {
4394 if (!strcmp(vpName1, This->
viewPtList[i].viewPtName)) {
4396 String dialogName = (
char *)
"Existing Viewpoint";
4397 std::string msg =
"'";
4399 msg +=
"' already exists. Choose a different name";
4407 XmString vpNameXmStr = XmStringCreateLocalized(vpName1);
4409 if (XmListGetSelectedPos(This->
myViewPtList, &pos_list, &pos_cnt)) {
4410 XmListReplaceItemsPos(This->
myViewPtList, &vpNameXmStr, 1, pos_list[0]);
4412 XtFree((
char *) pos_list);
4416 This->scheduleRedraw();
4418 XmStringFree(vpNameXmStr);
4424 XtPointer client_data,
4429 XmString *strList, *newStrList;
4430 std::vector<std::string> charList;
4437 XtVaGetValues(This->
myViewPtList, XmNitemCount, &size, XmNitems, &strList,
4440 for (
int i = 0; i < size; i++) {
4441 vpName = (
char *) XmStringUnparse(strList[i], XmFONTLIST_DEFAULT_TAG,
4442 XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
4443 charList.push_back(vpName);
4447 std::sort(charList.begin(), charList.end());
4449 newStrList = (XmString *) XtMalloc(size *
sizeof(XmString));
4450 for (
int i = 0; i < size; i++) {
4454 const int nVPName = charList[i].size() + 1;
4455 char *vpName2 =
new char[nVPName];
4456 strncpy(vpName2, charList[i].c_str(), nVPName);
4457 newStrList[i] = XmStringCreateLocalized(vpName2);
4462 XmListAddItemsUnselected(This->
myViewPtList, newStrList, size, 1);
4466 if (newStrList != NULL) {
4467 for (
int i = 0; i < size; i++)
4468 XmStringFree(newStrList[i]);
4469 XtFree((
char *) newStrList);
4479 SbVec3f p1, p2, p3, dirNow, dirNxt, dir, p2_tmp, p_start, p_corner, p_nxt;
4480 float avgDistBtwPts = 0;
4481 float totalDistBtwPts = 0;
4482 std::vector<SbVec3f> newRefParticleTrajectory;
4486 for (
int i = 0; i < size; i++) {
4492 totalDistBtwPts += (p2 - p1).length();
4495 if (numOfPts <= 2)
return;
4497 avgDistBtwPts = totalDistBtwPts / numOfPts;
4498 float minDistAllowed = 0.75 * avgDistBtwPts;
4508 p1.getValue(x, y, z);
4510 newRefParticleTrajectory.push_back(refPoint);
4513 while ((p2 - p1).length() < minDistAllowed && j < (size - 1)) {
4533 XtPointer client_data,
4552 SoCamera *cam = getCamera();
4561 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4563 ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
4565 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4567 ((SoOrthographicCamera *) cam)->height.getValue();
4575 SoCamera *cam = getCamera();
4585 if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
4589 ((SoOrthographicCamera *) cam)->height.setValue(
4592 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4594 }
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4598 ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
4601 ((SoOrthographicCamera *) cam)->height.setValue(
4610 SbTime curTime = SbTime::getTimeOfDay();
4612 SoTimerSensor *
s = (SoTimerSensor *) sensor;
4614 float t = float((curTime -
s->getBaseTime()).getValue())
4617 if ((t > 1.0f) || (t +
s->getInterval().getValue() > 1.0f))
4619 SbBool end = (t == 1.0f);
4642 SbTime curTime = SbTime::getTimeOfDay();
4644 SoCamera *cam = This->getCamera();
4645 SoTimerSensor *
s = (SoTimerSensor *) sensor;
4647 float t = float((curTime -
s->getBaseTime()).getValue())
4650 if ((t > 1.0f) || (t +
s->getInterval().getValue() > 1.0f))
4652 SbBool end = (t == 1.0f);
4682 if (SoXtExaminerViewer::isAnimating())
4686 SbVec3f p1, p2, p2_tmp, camUpV, camD, camD_tmp, leftRightAxis;
4687 float x1, y1, z1, x2, y2, z2;
4704 p1.getValue(x1, y1, z1);
4705 p2.getValue(x2, y2, z2);
4710 p2_tmp.setValue(x2, y1, z2);
4711 camD_tmp = p2_tmp - p1;
4712 camD_tmp.normalize();
4714 camUpV.setValue(0, 1, 0);
4715 rot.setValue(camD_tmp, camD);
4716 rot.multVec(camUpV, camUpV);
4718 leftRightAxis = camD.cross(camUpV);
4720 myCam->position = p1;
4721 myCam->pointAt(p2, camUpV);
4725 myCam->position = p1;
4731 myCam->focalDistance = 0.1f;
4743 XtPointer client_data,
4749 String dialogName = (
char *)
"No Reference Trajectory";
4750 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4763 This->scheduleRedraw();
4770 if (This->SoXtExaminerViewer::isAnimating())
4771 This->stopAnimating();
4780 This->
axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
4783 This->scheduleRedraw();
4795 This->
distance = (pN - p1).length() / 10;
4802 XtPointer client_data,
4814 this->refParticleTrajectory.end());
4821 XtPointer client_data,
4828 String dialogName = (
char *)
"No Reference Trajectory";
4829 std::string msg =
"You need to start a run or load a reference trajectory from a file";
4840 This->
axisSwitch->whichChild.setValue(SO_SWITCH_ALL);
4843 This->scheduleRedraw();
4846 SoCamera *cam = This->getCamera();
4859 if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
4860 This->toggleCameraType();
4861 cam = This->getCamera();
4869 cam->focalDistance = 0.1f;
4870 ((SoPerspectiveCamera *) cam)->heightAngle = 0.50f;
4877 cam->orientation = (This->
myCam)->orientation.getValue();
4884 SoCamera *cam = getCamera();
4906 void (*callback)(
void *),
void *
object)
static const G4double pos
#define MAX_SPEED_INDICATOR
#define SPEED_INDICATOR_STEP
static const char * thisClassName
static constexpr double s
static const G4double angle[DIMMOTT]
G4GLOB_DLL std::ostream G4cout
const std::vector< const std::vector< G4AttValue > * > & GetAttValues() const
const std::vector< const std::map< G4String, G4AttDef > * > & GetAttDefs() const
static void viewPtFileSelectedCB(Widget, XtPointer, XtPointer)
static void saveSceneGraphDialogCB(Widget, XtPointer, XtPointer)
static void loadRefCoordsDialogCB(Widget, XtPointer, XtPointer)
static void closeListsDialogCB(Widget, XtPointer, XtPointer)
void warningMsgDialog(std::string, String, XtCallbackProc)
std::vector< float > refZPositions
static void animateRefParticleCB(Widget, XtPointer, XtPointer)
static void saveSceneGraphCB(Widget, XtPointer, XtPointer)
static void closeMainWindowCB(Widget, XtPointer, XtPointer)
static void loadSceneGraphCB(Widget, XtPointer, XtPointer)
static void loadRefCoordsCB(Widget, XtPointer, XtPointer)
SoFont * mouseOverFontSolid
static void constructListsDialog(Widget, XtPointer, XtPointer)
static void mouseoverCB(void *aThis, SoEventCallback *eventCB)
static void saveViewPtCB(Widget, XtPointer, XtPointer)
void cleanUpAfterPrevFile()
void sortViewPts(std::vector< std::string >)
SoFont * mouseOverFontZPos
void setReferencePathZPos()
virtual SbBool processSoEvent(const SoEvent *const event)
void distanceToTrajectory(const SbVec3f &, float &, SbVec3f &, int &)
HookEventProcState * hookBeamOn
SoSeparator * newSceneGraph
static void animateSensorCB(void *, SoSensor *)
SoTimerSensor * animateSensorRotation
float sqrlen(const SbVec3f &)
void createElementsList(Widget)
static void deleteViewPtCB(Widget, XtPointer, XtPointer)
SoText2 * mouseOverTextLogName
void renameViewPt(char *vpName)
void deleteViewPt(char *vpName=NULL)
Widget loadRefCoordsDialog
SoCoordinate3 * getCoordsNode(SoFullPath *path)
static void lookAtSceneElementCB(Widget, XtPointer, XtPointer)
static void renameBookmarkCB(Widget, XtPointer, XtPointer)
SoFont * mouseOverFontMaterial
static void invertRefPathCB(Widget, XtPointer, XtPointer)
static void openViewPtFileCB(Widget, XtPointer, XtPointer)
static void gotoRefPathStartCB(Widget, XtPointer, XtPointer)
friend class HookEventProcState
static void prevViewPtCB(Widget, XtPointer, XtPointer)
std::vector< sceneElement > sceneElements
static void sortBookmarksCB(Widget, XtPointer, XtPointer)
void animateRefParticle()
Widget saveSceneGraphDialog
SoSwitch * animSpeedOutlineSwitch
viewPtData camB4Animation
void setReferencePath(SoLineSet *, SoCoordinate3 *, bool append=false)
void addButton(Widget menu, std::string name, XtCallbackProc)
static void pickingCB(void *aThis, SoEventCallback *eventCB)
static void superimpositionCB(void *closure, SoAction *action)
static void getViewPtNameCB(Widget, XtPointer, XtPointer)
static void saveSceneGraphOverWriteCB(Widget, XtPointer, XtPointer)
std::string viewPtAutoName()
bool viewingBeforePickRef
SbRotation camStartOrient
void saveViewPt(char *name)
std::string saveRefCoordsFileName
Widget saveRefCoordsDialog
Widget loadSceneGraphDialog
G4OpenInventorXtExaminerViewer(Widget parent=NULL, const char *name=NULL, SbBool embed=TRUE, SoXtFullViewer::BuildFlag flag=BUILD_ALL, SoXtViewer::Type type=BROWSER)
~G4OpenInventorXtExaminerViewer()
SoTranslation * mouseOverTransSolid
SoTimerSensor * animateSensor
SoNodeSensor * sceneChangeSensor
virtual void createViewerButtons(Widget parent, SbPList *buttonlist)
static void abbrOutputCB(Widget, XtPointer, XtPointer)
SoText2 * mouseOverTextSolid
void(* escapeCallback)(void *)
SoText2 * mouseOverTextMaterial
SoTranslation * curInfoTrans
static void saveRefCoordsOverWriteCB(Widget, XtPointer, XtPointer)
static void switchWireFrameCB(Widget, XtPointer, XtPointer)
static void getViewPtNameCancelCB(Widget, XtPointer, XtPointer)
static void overwriteFileCB(Widget, XtPointer, XtPointer)
void addEscapeCallback(void(*cb)(void *), void *)
static void createNewVPFileCB(Widget, XtPointer, XtPointer)
void evenOutRefParticlePts()
static void loadBookmarkCB(Widget, XtPointer, XtPointer)
void moveCamera(float dist=0, bool lookdown=false)
static void deleteBookmarkCB(Widget, XtPointer, XtPointer)
std::vector< viewPtData > viewPtList
SoTranslation * stranslation
static void animateSensorRotationCB(void *, SoSensor *)
SoText2 * mouseOverTextZPos
void constructor(const SbBool build)
static void sceneChangeCB(void *, SoSensor *)
static void nextViewPtCB(Widget, XtPointer, XtPointer)
Widget saveRefCoordsWidget
static void saveRefCoordsDialogCB(Widget, XtPointer, XtPointer)
Widget addMenu(std::string name)
double animateBtwPtsPeriod
SoTranslation * mouseOverTransZPos
std::vector< SbVec3f > refParticleTrajectory
SoTranslation * mouseOverTransMaterial
static G4OpenInventorXtExaminerViewer * viewer
SoNode * getSuperimpositionNode(SoNode *, const char *name)
static void newViewPtFileCB(Widget, XtPointer, XtPointer)
void parseString(T &t, const std::string &s, bool &error)
virtual void afterRealizeHook()
static void saveRefCoordsCB(Widget, XtPointer, XtPointer)
static void loadSceneGraphDialogCB(Widget, XtPointer, XtPointer)
void popUpFileSelDialog(Widget &, std::string, std::string, XtCallbackProc)
std::string saveScenegraphFileName
static void pickRefPathCB(Widget, XtPointer, XtPointer)
SoFont * mouseOverFontLogName
SoTranslation * mouseOverTransLogName
SoCoordinate3 * sgeometry
void superimpositionEvent(SoAction *action)
virtual void actualRedraw(void)
static void cancelFileSelDialogCB(Widget, XtPointer, XtPointer)
Widget saveScenegraphWidget
Widget buildWidget(Widget parent)
SoSwitch * animSpeedSwitch
SoSearchAction * searcher
void updateSpeedIndicator(void)
void setStartingPtForAnimation()
virtual G4bool Notify(G4ApplicationState requestedState)
HookEventProcState(G4OpenInventorQtExaminerViewer *)
G4OpenInventorQtExaminerViewer * viewer
static Pixmap createPixmapFromXpm(Widget button, const char **xpm, SbBool ghost=FALSE)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
const char * name(G4int ptype)
static void fail(const std::string &_prefix, const std::string &_name, const std::set< std::string > &_opts, G4int _num)
static const char * pickext_xpm[]
static const char * pickref_xpm[]
static const char * saveViewPt_xpm[]
float distanceToBeamlineStart
void xmAddMouseEventHandler(Widget w)
static const char * wireframe_xpm[]
static PROLOG_HANDLER error