44#include <Inventor/Qt/SoQt.h> 
   45#include <Inventor/Qt/SoQtCursor.h> 
   46#include <Inventor/events/SoKeyboardEvent.h> 
   47#include <Inventor/events/SoMouseButtonEvent.h> 
   48#include <Inventor/events/SoLocation2Event.h> 
   49#include <Inventor/nodes/SoSeparator.h> 
   50#include <Inventor/nodes/SoOrthographicCamera.h> 
   51#include <Inventor/nodes/SoPerspectiveCamera.h> 
   55#include <Inventor/nodes/SoLineSet.h> 
   56#include <Inventor/nodes/SoMaterial.h> 
   57#include <Inventor/errors/SoDebugError.h> 
   58#include <Inventor/SoPickedPoint.h> 
   59#include <Inventor/actions/SoWriteAction.h> 
   60#include <Inventor/projectors/SbPlaneProjector.h> 
   62#include <Inventor/sensors/SoTimerSensor.h>    
   63#include <Inventor/sensors/SoNodeSensor.h>     
   70#include <Inventor/nodes/SoCallback.h> 
   71#include <Inventor/nodes/SoSwitch.h> 
   72#include <Inventor/nodes/SoScale.h> 
   73#include <Inventor/nodes/SoTranslation.h> 
   74#include <Inventor/actions/SoSearchAction.h> 
   75#include <Inventor/actions/SoGetBoundingBoxAction.h> 
   77#include <Inventor/nodes/SoCoordinate3.h> 
   79#include <Inventor/nodes/SoText2.h> 
   80#include <Inventor/nodes/SoFont.h> 
   81#include <Inventor/nodes/SoPointSet.h> 
   82#include <Inventor/nodes/SoDrawStyle.h> 
   83#include <Inventor/nodes/SoBaseColor.h> 
   86#include <Inventor/nodekits/SoBaseKit.h> 
   90#include <QRadioButton> 
   93#include <QListWidgetItem> 
   94#include <QInputDialog> 
   98#include <QCommonStyle> 
  102#include "moc_G4OpenInventorQtExaminerViewer.cpp" 
  108#define START_STEP 0.3 
  109#define SPEED_INDICATOR_STEP 0.045 
  110#define MAX_SPEED_INDICATOR  0.81 
  118                               SoQtFullViewer::BuildFlag flag,
 
  120   : SoQtExaminerViewer(parent, 
name, embed, flag, type),
 
  121     externalQtApp(0), processSoEventCount(0)
 
  171   myCam = 
new SoPerspectiveCamera;
 
  202   static const char * superimposed[] = {
 
  203      "#Inventor V2.1 ascii", 
"",
 
  210      "         OrthographicCamera ",
 
  216      "         DEF soxt->callback Callback { }",
 
  219      "         DEF soxt->translation Translation ",
 
  221      "                 translation 0 0 0",
 
  223      "     DEF soxt->scale Scale ",
 
  225      "                 scaleFactor 1 1 1",
 
  227      "         DEF soxt->geometry Coordinate3 ",
 
  231      "                         -0.81   -0.04   0,      -0.81   0             0,",
 
  232      "                 -0.81   0.04    0,      0       -0.04   0,",
 
  234      "                 0.81    -0.04   0,  0.81        0           0,",
 
  237      "                 0.81    0.02    0,  0.81        -0.02   0,",
 
  240      "                 0.4     0.01    0,  0.4         -0.01   0,",
 
  245      "         DEF soxt->animSpeedOutlineSwitch Switch ",
 
  250      "                    emissiveColor 0 0 0",
 
  256      "                                 12, 11, 10, 9, -1",
 
  261      "         DEF soxt->axisSwitch Switch ",
 
  280      "         DEF soxt->animSpeedSwitch Switch ",
 
  285      "                 emissiveColor 0 1 0",
 
  291      "                                 16, 15, 14, 13, -1",
 
  297      " DEF soxt->curInfoSwitch Switch ",
 
  300      "         DEF soxt->curInfoTrans Translation ",
 
  302      "                 translation 0 0 0    ",
 
  305      "         DEF soxt->curInfoFont Font ",
 
  307      "                 name defaultFont:Bold",
 
  310      "         DEF soxt->curInfoText Text2 ",
 
  319      "         DEF soxt->mouseOverTransLogName Translation ",
 
  321      "                 translation 0 0 0    ",
 
  323      "         DEF soxt->mouseOverFontLogName Font ",
 
  325      "                 name defaultFont:Bold",
 
  328      "         DEF soxt->mouseOverTextLogName Text2 { } ",
 
  332      "         DEF soxt->mouseOverTransSolid Translation ",
 
  334      "                 translation 0 0 0    ",
 
  336      "         DEF soxt->mouseOverFontSolid Font ",
 
  338      "                 name defaultFont:Bold",
 
  341      "         DEF soxt->mouseOverTextSolid Text2 { } ",
 
  345      "         DEF soxt->mouseOverTransMaterial Translation ",
 
  347      "                 translation 0 0 0    ",
 
  349      "         DEF soxt->mouseOverFontMaterial Font ",
 
  351      "                 name defaultFont:Bold",
 
  354      "         DEF soxt->mouseOverTextMaterial Text2 { } ",
 
  358      "         DEF soxt->mouseOverTransZPos Translation ",
 
  360      "                 translation 0 0 0    ",
 
  362      "         DEF soxt->mouseOverFontZPos Font ",
 
  364      "                 name defaultFont:Bold",
 
  367      "         DEF soxt->mouseOverTextZPos Text2 { } ",
 
  373   for (i = bufsize = 0; superimposed[i]; i++)
 
  374      bufsize += strlen(superimposed[i]) + 1;
 
  375   char * buf = 
new char[bufsize + 1];
 
  376   for (i = bufsize = 0; superimposed[i]; i++) {
 
  377      strcpy(buf + bufsize, superimposed[i]);
 
  378      bufsize += strlen(superimposed[i]);
 
  382   SoInput * input = 
new SoInput;
 
  383   input->setBuffer(buf, bufsize);
 
  419   axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
 
  432      SoDebugError::post(
"G4OpenInventorQtExaminerViewer::buildWidget",
 
  433                         "Error: Parent is null.");
 
  437   font->setPointSize(12);
 
  439   parent->setFont(*
font);
 
  445   menubar = 
new QMenuBar(getRenderAreaWidget());
 
  593   detachButton->setIcon(style.standardIcon(QStyle::SP_CommandLink));
 
  602   helpmsgbox = 
new QMessageBox(getParentWidget());
 
  606"\nVIEWING mode (Hand cursor):\n\n\ 
  607   Left-button + pointer move:  rotate\n\ 
  608   Shift+Left-button + pointer move:  pan\n\ 
  609   Middle-button + pointer move:  pan\n\ 
  610   Ctrl+Shift+Left-button + pointer move:  zoom\n\ 
  612   Right-button:  popup menu\n\n\ 
  613PICKING mode (Arrow cursor):\n\n\ 
  614   Click on a volume:  geometry readout\n\ 
  615   Click on a trajectory:  particle & trajectory readout\n\ 
  616   Ctrl + click on a volume:  see daughters.\n\ 
  617   Shift + click on a volume:  see mother.\n\n\ 
  618EXTENDED PICKING mode (Arrow+ viewer button):\n\n\ 
  619   Hover the mouse over a volume or trajectory for\n\ 
  620   overlayed readout.\n\n\ 
  621ELEMENT NAVIGATION (requires Reference Path):\n\n\ 
  622   Click on element in list:  centers view on element\n\ 
  623   Arrow keys:  rotate in 90 degree steps around element  \n\ 
  624   Shift + Right Arrow:  move to next element\n\ 
  625   Shift + Left Arrow:  move to previous element\n\n\ 
  626FLY mode (requires Reference Path):\n\n\ 
  627   Page Up:  Increase speed\n\ 
  628   Page Down:  Decrease speed (& reverse if wanted)\n\ 
  629   Up Arrow:  raise camera above path\n\ 
  630   Down Arror:  lower camera below path\n\ 
  631   Escape:  Exit fly mode";
 
  666   SoQtExaminerViewer::afterRealizeHook();
 
  670   SoCamera *cam = getCamera();
 
  672      if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
 
  674            ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
 
  677            ((SoOrthographicCamera *) cam)->height.getValue();
 
  681            ((SoOrthographicCamera *) cam)->height.getValue();
 
  684         if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
 
  686               ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
 
  696         msgbox.setFont(*
font);
 
  697         QString messagetxt = 
"Error reading bookmark file ";
 
  698         messagetxt.append(QString(
fileName.c_str()));
 
  699         msgbox.setText(messagetxt);
 
  704         fileOut.seekp(0, std::ios::end); 
 
  725   SoSeparator* root = (SoSeparator*) (getSceneManager()->getSceneGraph());
 
  727      SoDebugError::post(
"G4OpenInventorQtExaminerViewer::afterRealizeHook", 
"Root is null.");
 
  729      root->addChild(
myCam); 
 
  743   SoEventCallback *moCB = 
new SoEventCallback;
 
  744   moCB->addEventCallback(
 
  745                          SoLocation2Event::getClassTypeId(),
 
  747   root->addChild(moCB);
 
  751   SoEventCallback *pickCB = 
new SoEventCallback;
 
  752   pickCB->addEventCallback(
 
  753                            SoMouseButtonEvent::getClassTypeId(),
 
  755   root->addChild(pickCB);
 
  764   uiQt = 
dynamic_cast<G4UIQt*
>(UI->GetG4UIWindow());
 
  787   searcher->setInterest(SoSearchAction::FIRST);
 
  791   return searcher->getPath()->getTail();
 
  810   if (!
action->isOfType(SoGLRenderAction::getClassTypeId()))
 
  812   SbViewportRegion vpRegion =
 
  813      ((SoGLRenderAction*)
action)->getViewportRegion();
 
  814   SbVec2s viewportSize = vpRegion.getViewportSizePixels();
 
  817   float aspect = float(viewportSize[0]) / float(viewportSize[1]);
 
  828   float factorx = 1.0f / float(viewportSize[1]) * 220.0f;
 
  832      stranslation->translation.setValue(SbVec3f(0.0f, -0.4f, 0.0f));
 
  834      stranslation->translation.setValue(SbVec3f(0.0f, -0.4f / aspect, 0.0f));
 
  838   if (viewportSize[0] > 500)
 
  839      factorx *= 500.0f / 400.0f;
 
  841      factorx *= float(viewportSize[0]) / 400.0f;
 
  843   sscale->scaleFactor.setValue(SbVec3f(factorx, 
factory, 1.0f));
 
  851   float xInfo, yInfo, xLogName, yLogName, xSolid, ySolid,
 
  852      xMaterial, yMaterial, xZPos, yZPos;
 
  860   if (aspect > 1.) xInfo = xInfo*aspect;
 
  861   if (aspect < 1.) yInfo = yInfo/aspect;
 
  862   yInfo = yInfo - mbgap*aspect;
 
  866   yLogName = -.88 + mbgap*aspect;
 
  868   ySolid = -.91 + mbgap*aspect;
 
  870   yMaterial = -.94 + mbgap*aspect;
 
  872   yZPos = -.97 + mbgap*aspect;
 
  875   curInfoTrans->translation.setValue(SbVec3f(xInfo, yInfo, 0.0));
 
  916   float x, y, z, 
angle;
 
  923   while (getline(
fileIn, token)) {
 
  925      int end = token.find_last_not_of(
' '); 
 
  926      token = token.substr(0, end + 1);
 
  928      char *vpName = 
new char[token.size() + 1];
 
  929      strcpy(vpName, token.c_str());
 
  933      parseString<float>(x, token, 
error);
 
  935      parseString<float>(y, token, 
error);
 
  937      parseString<float>(z, token, 
error);
 
  939      tmp.
position = axis.setValue(x, y, z);
 
  941      parseString<float>(x, token, 
error);
 
  943      parseString<float>(y, token, 
error);
 
  945      parseString<float>(z, token, 
error);
 
  949      orient.setValue(axis.setValue(x, y, z), 
angle);
 
  953      parseString<int>(camType, token, 
error);
 
  988   SoCamera *cam = getCamera();
 
  995   cam->position = camPosNew;
 
  997   cam->focalDistance = (
prevPt - camPosNew).length();
 
 1016   SoCamera *cam = getCamera();
 
 1018   SbVec3f particleDir;  
 
 1029      cam->focalDistance = (cam->position.getValue() - 
center).length();
 
 1038         dist = (
prevPt - cam->position.getValue()).length();
 
 1045         dist = (
prevPt - cam->position.getValue()).length();
 
 1054      particleDir = p2 - p1;
 
 1055      particleDir.normalize();
 
 1068         SbRotation rot(SbVec3f(0,0,1), particleDir);
 
 1082      if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
 
 1102      if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
 
 1105      if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
 
 1107         camPosNew = p2 - (
camDir*cam->focalDistance.getValue());
 
 1111      cam->position = camPosNew;
 
 1113      cam->focalDistance = (p2 - camPosNew).length();
 
 1116      camPosNew.getValue(x,y,z);
 
 1127                                               SoEventCallback *eventCB)
 
 1129   SoHandleEventAction* 
action = eventCB->getAction();
 
 1130   const SoPickedPoint *
pp = 
action->getPickedPoint();
 
 1135      SoPath* path = 
pp->getPath();
 
 1136      SoNode* node = ((SoFullPath*)path)->getTail();
 
 1138      if(node->getTypeId() == SoLineSet::getClassTypeId()) {
 
 1148            SoLineSet * trajectory = (SoLineSet *)node;
 
 1156            SoSeparator * grpNode = 
 
 1157               (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
 
 1162            int nodeIndex = grpNode->findChild(trajectory);
 
 1165            SoCoordinate3 * coords = 0;
 
 1169            for(
int i = 0; i < 100; ++i) {
 
 1172               tmpNode = grpNode->getChild(nodeIndex);
 
 1173               if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()) {
 
 1175                  coords = (SoCoordinate3 *)tmpNode;
 
 1180            if(coords == NULL) {
 
 1181               G4cout << 
"Could not find the coordinates node" 
 1182                  " for the picked trajectory." << 
G4endl;
 
 1201            if(attHolder && attHolder->
GetAttDefs().size()) {
 
 1203               std::string strTrajPoint = 
"G4TrajectoryPoint:";
 
 1204               std::ostringstream oss;
 
 1205               for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
 
 1210                  if(oss.str().find(strTrajPoint) != std::string::npos) {
 
 1225               G4String cls((
char*)node->getTypeId().getName().getString());
 
 1226               G4cout << 
"SoNode : " << node
 
 1227                      << 
" SoType : " << cls
 
 1228                      << 
" name : " << 
name 
 1245      if(attHolder && attHolder->
GetAttDefs().size()) {
 
 1246         for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
 
 1252         G4String cls((
char*)node->getTypeId().getName().getString());
 
 1253         G4cout << 
"SoNode : " << node
 
 1254                << 
" SoType : " << cls
 
 1255                << 
" name : " << 
name 
 1261      eventCB->setHandled();
 
 1268   SoHandleEventAction* 
action = eventCB->getAction();
 
 1269   const SoPickedPoint* 
pp = 
action->getPickedPoint();
 
 1277      const SbViewportRegion & viewportRegion = 
action->getViewportRegion();
 
 1279      std::string sLogName;
 
 1281      std::stringstream ssZPos;
 
 1282      std::stringstream ssSolids;
 
 1283      std::stringstream ssMaterials;
 
 1284      SoPath * path = 
pp->getPath();
 
 1285      SoNode* node = ((SoFullPath*)path)->getTail();
 
 1287      if(node->getTypeId() == Geant4_SoPolyhedron::getClassTypeId()) {
 
 1289         sLogName = 
"Logical Volume:  ";
 
 1292         SoGetBoundingBoxAction bAction(viewportRegion);
 
 1293         bAction.apply((SoFullPath*)path);
 
 1294         SbBox3f bBox = bAction.getBoundingBox();
 
 1295         SbVec3f 
center = bBox.getCenter();
 
 1297         ssZPos << 
"Pos:  " << x << 
"  " << y << 
"  " << z;
 
 1300         if(attHolder && attHolder->
GetAttDefs().size()) {
 
 1302            std::vector<const std::map<G4String,G4AttDef>*> vecDefs =
 
 1304            std::vector<const std::vector<G4AttValue>*> vecVals =
 
 1306            for (
size_t i = 0; i < vecDefs.size(); ++i) {
 
 1307               const std::vector<G4AttValue> * vals = vecVals[i];
 
 1309               std::vector<G4AttValue>::const_iterator iValue;
 
 1311               for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
 
 1312                  const G4String& valueName = iValue->GetName();
 
 1313                  const G4String& value = iValue->GetValue();
 
 1315                  if(valueName == 
"Solid") {
 
 1316                     if(ssSolids.str() == 
"")
 
 1317                        ssSolids << 
"Solid Name:  " << value;
 
 1319                        ssSolids << 
", " << value;
 
 1322                  if(valueName == 
"Material") {
 
 1323                     if(ssMaterials.str() == 
"")
 
 1324                        ssMaterials << 
"Material Name:  " << value;
 
 1326                        ssMaterials << 
", " << value;
 
 1333      else if(node->getTypeId() == SoLineSet::getClassTypeId()) {
 
 1336         if(attHolder && attHolder->
GetAttDefs().size()) {
 
 1337            std::string strTrajPoint = 
"G4TrajectoryPoint:";
 
 1338            std::ostringstream oss;
 
 1340            for (
size_t i = 0; i < attHolder->
GetAttDefs().size(); ++i) {
 
 1344               const std::vector<G4AttValue>* vals = attHolder->
GetAttValues()[i];
 
 1345               std::vector<G4AttValue>::const_iterator iValue;
 
 1346               for (iValue = vals->begin(); iValue != vals->end(); ++iValue) {
 
 1347                  const G4String& valueName = iValue->GetName();
 
 1348                  const G4String& value = iValue->GetValue();
 
 1352                  if (valueName == 
"PN") t1 = value;
 
 1353                  if (valueName == 
"Ch") {
 
 1354                     if (atof(value.c_str()) > 0)
 
 1360                  if (valueName == 
"PDG") {
 
 1368                  if (valueName == 
"EventID") t2 = 
"Evt " + value;
 
 1369                  if (valueName == 
"ID") t2 += 
"    Trk " + value;
 
 1370                  if (valueName == 
"PID") {
 
 1371                     t2 += 
"    Prt " + value;
 
 1375                  if (valueName == 
"IKE") t3 = 
"KE " + value;
 
 1376                  if (valueName == 
"IMom") {
 
 1378                     unsigned ipos = value.rfind(
" ");
 
 1381                     t3 += 
"    P (" + value1 + 
")";
 
 1383                  if (valueName == 
"IMag") {
 
 1384                     t3 += 
" " + value + 
"/c";
 
 1389                  if (valueName == 
"NTP") {
 
 1390                     std::ostringstream t4oss;
 
 1391                     t4oss << 
"TrjPts " <<  value;
 
 1392                     t4oss << 
"    Pos " << 
pp->getPoint()[0] << 
" " << 
pp->getPoint()[1] <<
 
 1393                        " " << 
pp->getPoint()[2];
 
 1416         This->scheduleRedraw();
 
 1417         eventCB->setHandled();
 
 1421      bool redraw = 
false;
 
 1426      if(std::string(This->
mouseOverTextSolid->string.getValues(0)->getString()) != ssSolids.str()) {
 
 1430      if(std::string(This->
mouseOverTextMaterial->string.getValues(0)->getString()) != ssMaterials.str()) {
 
 1434      if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) != ssZPos.str()) {
 
 1441         This->scheduleRedraw();
 
 1444      eventCB->setHandled();
 
 1449         This->scheduleRedraw();
 
 1453         This->scheduleRedraw();
 
 1457         This->scheduleRedraw();
 
 1459      if(std::string(This->
mouseOverTextZPos->string.getValues(0)->getString()) != 
"") {
 
 1461         This->scheduleRedraw();
 
 1480      if (refParticleIdx < lastIdx && !animateSensor->isScheduled())
 
 1509   SbVec3f * points = this->
sgeometry->point.startEditing();
 
 1511   if (points[10][0] == 0.0f)
 
 1513   if (points[14][0] == 0.0f)
 
 1534        SoQtExaminerViewer::actualRedraw();
 
 1537        SoQtExaminerViewer::actualRedraw();
 
 1544       SoCoordinate3 *coords, 
bool append)
 
 1555   SbVec3f refParticlePt;
 
 1560   for(
int i = 0; i < lineset->numVertices.getNum(); ++i) {
 
 1561      for(
int j = 0; j < lineset->numVertices[i]; ++j) {
 
 1562         refParticlePt = coords->point[j];
 
 1590   action.setType(SoLineSet::getClassTypeId(),
false);
 
 1592   action.apply(getSceneGraph());
 
 1594   SoPathList &pathList = 
action.getPaths();
 
 1596   if(pathList.getLength() != 0) {
 
 1598      SoCoordinate3 * coords = NULL;
 
 1599      std::vector<SoCoordinate3 *> coordvec;
 
 1600      std::vector<SoLineSet *> linevec;
 
 1602      bool refPathFound = 
false;
 
 1603      for(
int i = 0; i < pathList.getLength(); ++i) {
 
 1604         SoFullPath *path = (SoFullPath *)pathList[i];
 
 1607         for (
size_t j = 0; j < attHolder->
GetAttDefs().size(); ++j) {
 
 1608            std::ostringstream oss;
 
 1612            std::string findStr = 
"Type of trajectory (Type): ";
 
 1613            std::string compareValue = 
"REFERENCE";
 
 1614            size_t idx = oss.str().find(findStr);
 
 1616            if(idx != std::string::npos) {
 
 1617               if(oss.str().substr(idx + findStr.size(),
 
 1618                                   compareValue.size()) == compareValue) {
 
 1620                  if(coords != NULL) {
 
 1621                     refPathFound = 
true;
 
 1622                     coordvec.push_back(coords);
 
 1623                     linevec.push_back((SoLineSet *)path->getTail());
 
 1629            findStr = 
"Track ID (ID): ";
 
 1630            idx = oss.str().find(findStr);
 
 1631            if(idx != std::string::npos) {
 
 1633               std::string tmpstr = oss.str().substr(idx + findStr.size(),1);
 
 1634               std::istringstream 
buffer(tmpstr);
 
 1642                  char nextChar = oss.str().at(idx+findStr.size()+1);
 
 1645                  if(std::isdigit(nextChar))
 
 1649                  if(coords != NULL) {
 
 1650                     coordvec.push_back(coords);
 
 1651                     linevec.push_back((SoLineSet *)path->getTail());
 
 1667      if(coordvec.empty())
 
 1678      float longestLength = 0.0;
 
 1680      for(
unsigned int i=0;i < linevec.size(); ++i) {
 
 1683         std::vector<SbVec3f> trajectory;
 
 1685         for(
int j=0; j < linevec[i]->numVertices.getNum(); ++j) {
 
 1687            for(
int k=0; k < linevec[i]->numVertices[j]; ++k) {
 
 1688               trajectory.push_back(coordvec[i]->point[k]);
 
 1693         float tmpLength=0.0;
 
 1694         for(
unsigned int j=0; j < trajectory.size() - 1; ++j) {
 
 1695            tmpLength += (trajectory[j] - trajectory[j + 1]).length();
 
 1698         if(tmpLength > longestLength) {
 
 1700            longestLength = tmpLength;
 
 1712   SoLineSet *trajectory = (SoLineSet *)path->getTail();
 
 1713   SoSeparator * grpNode = (SoSeparator*)(((SoFullPath*)path)->getNodeFromTail(1));
 
 1714   int nodeIndex = grpNode->findChild(trajectory);
 
 1719   for (
int i = 0; i < 100; ++i) {
 
 1722      tmpNode = grpNode->getChild(nodeIndex);
 
 1723      if(tmpNode->getTypeId() == SoCoordinate3::getClassTypeId()) {
 
 1725         return (SoCoordinate3 *)tmpNode;
 
 1736   std::string field, eltName;
 
 1738   std::map<std::string, int> duplicates;
 
 1739   std::map<std::string, int> sceneElts;
 
 1740   SoSearchAction search;
 
 1742   SoGroup *root = (SoGroup *)getSceneManager()->getSceneGraph();
 
 1744   SoBaseKit::setSearchingChildren(
TRUE);
 
 1747   search.setSearchingAll(
TRUE);
 
 1749   search.setType(Geant4_SoPolyhedron::getClassTypeId(), 0);
 
 1755   SoPathList &pl = search.getPaths();
 
 1759   for (
int i = 0; i < pl.getLength(); i++) {
 
 1760      SoFullPath *path = (SoFullPath *)pl[i];
 
 1762      eltName = node->getName();
 
 1764      if(duplicates.count(eltName))
 
 1765         duplicates[eltName]++;
 
 1767         duplicates[eltName] = 1;
 
 1770   for(
int i = 0; i < pl.getLength(); i++) {
 
 1772      std::stringstream ssCount;
 
 1773      SoFullPath *path = (SoFullPath *)pl[i];
 
 1775      eltName = node->getName();
 
 1777      if(duplicates[eltName] == 1)
 
 1780         if(sceneElts.count(eltName))
 
 1781            sceneElts[eltName]++;
 
 1783            sceneElts[eltName] = 1;
 
 1785         ssCount << sceneElts[eltName];
 
 1789      field += ssCount.str();
 
 1791      SoGetBoundingBoxAction bAction(getViewportRegion());
 
 1792      bAction.apply(path);
 
 1793      SbBox3f bBox = bAction.getBoundingBox();
 
 1795      SbVec3f centr = bBox.getCenter();
 
 1796      centr.getValue(x,y,z);
 
 1809   return x*x + y*y + z*z;
 
 1815                                                SbVec3f &closestPoint,
 
 1854   SbVec3f dbq = b - q;
 
 1855   float sqrDist = 
sqrlen(dbq);
 
 1858   for (
size_t i = 1; i < count; ++i) {
 
 1859      const SbVec3f a = b;
 
 1860      const SbVec3f daq = dbq;
 
 1863      const SbVec3f dab = a - b;
 
 1865      float dab_x, dab_y, dab_z;
 
 1866      dab.getValue(dab_x,dab_y,dab_z);
 
 1867      float daq_x, daq_y, daq_z;
 
 1868      daq.getValue(daq_x, daq_y, daq_z);
 
 1869      float dbq_x, dbq_y, dbq_z;
 
 1870      dbq.getValue(dbq_x, dbq_y, dbq_z);
 
 1872      const float inv_sqrlen = 1./
sqrlen(dab);
 
 1873      const float t = (dab_x*daq_x + dab_y*daq_y + dab_z*daq_z)*inv_sqrlen;
 
 1884         current_dist = daq_x*daq_x + daq_y*daq_y + daq_z*daq_z
 
 1885            - t*(daq_x*dab_x + daq_y*dab_y + daq_z*dab_z)
 
 1886            + t*t*(dab_x*dab_x + dab_y*dab_y + dab_z*dab_z);
 
 1891         current_dist = 
sqrlen(dbq);
 
 1894      if (current_dist < sqrDist) {
 
 1895         sqrDist = current_dist;
 
 1896         closestPoint = a + t*(b-a);
 
 1901   dist = std::sqrt(sqrDist);
 
 1911   typedef std::map<elementForSorting, sceneElement> sortedMap;
 
 1920   trajLength[trajIndex] = 0.0;
 
 1924      trajLength[trajIndex] = trajLength[trajIndex-1] + (*itRef - prevPoint).length();
 
 1932   SoGetBoundingBoxAction bAction(getViewportRegion());
 
 1933   SbVec3f elementCoord;
 
 1934   std::vector<sceneElement>::iterator itEl;
 
 1939      bAction.apply(itEl->path);
 
 1942      elementCoord = itEl->center;
 
 1960      sorted.insert(std::make_pair(el,*itEl));
 
 1966   sortedMap::iterator itSorted = sorted.begin();
 
 1967   for(; itSorted != sorted.end(); itSorted++)
 
 1974   delete[] trajLength;
 
 1986   std::vector<sceneElement>::const_iterator it;
 
 1987   std::stringstream ss;
 
 1992         ss << 
" [" << it->closestPointZCoord << 
"]";
 
 2006   std::string elementField;
 
 2011   SoCamera * cam = getCamera();
 
 2013   if (SoQtExaminerViewer::isAnimating())
 
 2016   value = strdup(qPrintable(item->text()));
 
 2031   elementField = value;
 
 2033   int idx = elementField.find_last_of(
"[");
 
 2035      idx = elementField.size(); 
 
 2041   SoSearchAction search;
 
 2042   SoNode *root = getSceneManager()->getSceneGraph();
 
 2043   int counter, idxUnderscore = elementField.find_last_of(
"_");
 
 2045   parseString<int>(counter, 
 
 2046                          elementField.substr(idxUnderscore + 1, idx), 
error);
 
 2048   SoBaseKit::setSearchingChildren(
TRUE);
 
 2050   search.setSearchingAll(
TRUE);
 
 2060      path = (SoFullPath *)search.getPath();
 
 2063      curEltName = elementField.substr(0, idxUnderscore);
 
 2068      SoPathList &pl = search.getPaths();
 
 2069      path = (SoFullPath *)pl[counter - 1]; 
 
 2075   if ((idx > 0) && (path)) {
 
 2079         SoGetBoundingBoxAction bAction(getViewportRegion());
 
 2080         bAction.apply(path);
 
 2081         SbBox3f bBox = bAction.getBoundingBox();
 
 2082         SbVec3f elementCoord = bBox.getCenter();
 
 2087         float absLengthNow, absLengthMin;
 
 2093         absLengthMin = (p - elementCoord).length();
 
 2099            absLengthNow = (p - elementCoord).length();
 
 2101            if (absLengthNow < absLengthMin) {
 
 2102               absLengthMin = absLengthNow;
 
 2115            distance = (pN - p1).length() / 10;
 
 2127            if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
 
 2131            if (cam->isOfType(SoPerspectiveCamera::getClassTypeId()))
 
 2138         axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
 
 2153         cam->viewAll(path, getViewportRegion());
 
 2164   QFileDialog filedialog(getParentWidget(), tr(
"Load Reference Path"));
 
 2165   filedialog.setFileMode(QFileDialog::AnyFile);
 
 2166   filedialog.setFont(*
font);
 
 2167   if (!filedialog.exec()) 
return;
 
 2168   QStringList filenameinlist = filedialog.selectedFiles();
 
 2169   QString filenamein = filenameinlist[0];
 
 2173   char* filename = 
new char[filenamein.size()+1];
 
 2174   filename = strdup(qPrintable(filenamein));
 
 2177   std::ifstream ifs(filename);
 
 2181      while(ifs >> x >> y >> z) {
 
 2187      msgbox.setFont(*
font);
 
 2188      QString messagetxt = 
"Reference Path file not found: ";
 
 2189      messagetxt.append(filenamein);
 
 2190      msgbox.setText(messagetxt);
 
 2196      msgbox.setFont(*
font);
 
 2197      QString messagetxt = 
"Invalid Reference Path";
 
 2198      msgbox.setText(messagetxt);
 
 2214   QFileDialog filedialog(getParentWidget(), tr(
"Save Reference Path"));
 
 2215   filedialog.setFileMode(QFileDialog::AnyFile);
 
 2217   filedialog.setAcceptMode(QFileDialog::AcceptSave);
 
 2218   filedialog.setFont(*
font);
 
 2219   if (!filedialog.exec()) 
return;
 
 2220   QStringList filenameinlist = filedialog.selectedFiles();
 
 2221   QString filenamein = filenameinlist[0];
 
 2225   char* filename = 
new char[filenamein.size()+1];
 
 2226   filename = strdup(qPrintable(filenamein));
 
 2229   std::ofstream ofs(filename);
 
 2230   if (ofs.is_open()) {
 
 2234         ofs << x << 
" " << y << 
" " << z << 
"\n";
 
 2239      msgbox.setFont(*
font);
 
 2240      QString messagetxt = 
"Error opening file ";
 
 2241      messagetxt.append(filenamein);
 
 2242      msgbox.setText(messagetxt);
 
 2253   SbVec3f p1, p2, p3, dirNow, dirNxt, dir, p2_tmp, p_start, p_corner, p_nxt;
 
 2254   float avgDistBtwPts = 0;
 
 2255   float totalDistBtwPts = 0;
 
 2256   std::vector<SbVec3f> newRefParticleTrajectory;
 
 2260   for (
int i = 0; i < size; i++) {
 
 2266      totalDistBtwPts += (p2 - p1).length();
 
 2269   if (numOfPts <= 2) 
return;
 
 2271   avgDistBtwPts = totalDistBtwPts / numOfPts;
 
 2272   float minDistAllowed = 0.75 * avgDistBtwPts;
 
 2282      p1.getValue(x, y, z);
 
 2284      newRefParticleTrajectory.push_back(refPoint);
 
 2287      while ((p2 - p1).length() < minDistAllowed && j < (size - 1)) {
 
 2306   SoCamera *cam = getCamera();
 
 2315   if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
 
 2317         ((SoPerspectiveCamera *) cam)->heightAngle.getValue();
 
 2319   } 
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
 
 2321         ((SoOrthographicCamera *) cam)->height.getValue();
 
 2329   SoCamera *cam = getCamera();
 
 2339   if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
 
 2343         ((SoOrthographicCamera *) cam)->height.setValue(
 
 2346         ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
 
 2348   } 
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
 
 2352         ((SoPerspectiveCamera *) cam)->heightAngle.setValue(
 
 2355         ((SoOrthographicCamera *) cam)->height.setValue(
 
 2364   SbTime curTime = SbTime::getTimeOfDay();
 
 2367   SoTimerSensor* 
s = (SoTimerSensor*) sensor;
 
 2369   float t = float((curTime - 
s->getBaseTime()).getValue())
 
 2372   if ((t > 1.0f) || (t + 
s->getInterval().getValue() > 1.0f))
 
 2374   SbBool end = (t == 1.0f);
 
 2397   SbTime curTime = SbTime::getTimeOfDay();
 
 2399   SoCamera *cam = This->getCamera();
 
 2400   SoTimerSensor* 
s = (SoTimerSensor*) sensor;
 
 2402   float t = float((curTime - 
s->getBaseTime()).getValue())
 
 2405   if ((t > 1.0f) || (t + 
s->getInterval().getValue() > 1.0f))
 
 2407   SbBool end = (t == 1.0f);
 
 2437   if (SoQtExaminerViewer::isAnimating())
 
 2441   SbVec3f p1, p2, p2_tmp, camUpV, camD, camD_tmp, leftRightAxis;
 
 2442   float x1, y1, z1, x2, y2, z2;
 
 2459   p1.getValue(x1, y1, z1);
 
 2460   p2.getValue(x2, y2, z2);
 
 2465   p2_tmp.setValue(x2, y1, z2);
 
 2466   camD_tmp = p2_tmp - p1;
 
 2467   camD_tmp.normalize();
 
 2469   camUpV.setValue(0, 1, 0);
 
 2470   rot.setValue(camD_tmp, camD);
 
 2471   rot.multVec(camUpV, camUpV);
 
 2473   leftRightAxis = camD.cross(camUpV);
 
 2475   myCam->position = p1;
 
 2476   myCam->pointAt(p2, camUpV);
 
 2480   myCam->position = p1;
 
 2486   myCam->focalDistance = 0.1f;
 
 2500      msgbox.setFont(*
font);
 
 2501      QString messagetxt = 
"No current reference path";
 
 2502      msgbox.setText(messagetxt);
 
 2522   if (SoQtExaminerViewer::isAnimating())
 
 2532   axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
 
 2547   distance = (pN - p1).length() / 10;
 
 2570   SoCamera *cam = getCamera();
 
 2621   for (
int i = 0; i < size; i++) {
 
 2622      new QListWidgetItem(
viewPtList[i].viewPtName,
 
 2634   std::istringstream str(
s);
 
 2635   if ((str >> t).
fail())
 
 2645   QFileDialog filedialog(getParentWidget(), tr(
"Open bookmark file"));
 
 2646   filedialog.setFileMode(QFileDialog::ExistingFile);
 
 2647   filedialog.setFont(*
font);
 
 2648   if (!filedialog.exec()) 
return;
 
 2649   QStringList filenameinlist = filedialog.selectedFiles();
 
 2650   QString filenamein = filenameinlist[0];
 
 2652   char* filename = 
new char[filenamein.size()+1];
 
 2653   filename = strdup(qPrintable(filenamein));
 
 2660      msgbox.setFont(*
font);
 
 2661      QString messagetxt = 
"Error opening file: ";
 
 2662      messagetxt.append(filenamein);
 
 2663      msgbox.setText(messagetxt);
 
 2674      msgbox.setFont(*
font);
 
 2675      QString messagetxt = 
"Error reading bookmark file: ";
 
 2676      messagetxt.append(filenamein);
 
 2677      msgbox.setText(messagetxt);
 
 2686   fileOut.seekp(0, std::ios::end);
 
 2717   QFileDialog filedialog(getParentWidget(), tr(
"Open new bookmark file"));
 
 2718   filedialog.setFileMode(QFileDialog::AnyFile);
 
 2720   filedialog.setAcceptMode(QFileDialog::AcceptSave);
 
 2722   filedialog.setLabelText(QFileDialog::Accept, QString(
"New"));
 
 2723   filedialog.setFont(*
font);
 
 2724   if (!filedialog.exec()) 
return;
 
 2725   QStringList filenameinlist = filedialog.selectedFiles();
 
 2726   QString filenamein = filenameinlist[0];
 
 2730   char* filename = 
new char[filenamein.size()+1];
 
 2731   filename = strdup(qPrintable(filenamein));
 
 2739      msgbox.setFont(*
font);
 
 2740      QString messagetxt = 
"Error opening new bookmark file: ";
 
 2741      messagetxt.append(filenamein);
 
 2742      msgbox.setText(messagetxt);
 
 2762   axisSwitch->whichChild.setValue(SO_SWITCH_ALL);
 
 2768   SoCamera *cam = getCamera();
 
 2781      if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
 
 2791      cam->focalDistance = 0.1f;
 
 2792      ((SoPerspectiveCamera *) cam)->heightAngle = 0.50f;
 
 2799   cam->orientation = (
myCam)->orientation.getValue();
 
 2814   QInputDialog* inputdialog = 
new QInputDialog(getParentWidget());
 
 2815   inputdialog->setFont(*
font);
 
 2816   inputdialog->setWindowTitle(tr(
"Enter a name for the bookmark"));
 
 2817   inputdialog->setLabelText(
"Bookmark name");
 
 2819   inputdialog->adjustSize();
 
 2821   if (inputdialog->exec() == QDialog::Accepted)
 
 2822      namein=inputdialog->textValue().trimmed();
 
 2825   if (namein.isEmpty()) 
return;
 
 2835   char* 
name = 
new char[nVPName];
 
 2839   QByteArray ba = namein.toLocal8Bit();
 
 2840   name = strdup(ba.constData());
 
 2847   for (
int i = 0; i < (int)
viewPtList.size(); i++) {
 
 2850         msgbox.setText(
"Bookmark name is already in use");
 
 2872   float x, y, z, 
angle;
 
 2873   SoCamera* camera = getCamera();
 
 2888   tmp.
position = camera->position.getValue();
 
 2896   if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
 
 2897      tmp.
height = ((SoPerspectiveCamera *) camera)->heightAngle.getValue();
 
 2899   } 
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
 
 2900      tmp.
height = ((SoOrthographicCamera *) camera)->height.getValue();
 
 2903      SoDebugError::post(
"G4OpenInventorQtExaminerViewer::saveViewPtCB",
 
 2904                         "Only Perspective and Orthographic cameras are supported.");
 
 2914   std::string vpName = 
name;
 
 2919   fileOut << vpName << std::endl;
 
 2921   fileOut << x << 
" " << y << 
" " << z << std::endl;
 
 2925   axis.getValue(x, y, z);
 
 2926   fileOut << x << 
" " << y << 
" " << z << 
" " << 
angle << std::endl;
 
 2949   std::stringstream out;
 
 2953   fileOut.seekp(0, std::ios::beg);
 
 2963   fileOut.seekp(0, std::ios::end);
 
 2975   char* vpName = 
new char[nVPName];
 
 2977   vpName = strdup(qPrintable(item->text()));
 
 2980   for (
int i = 0; i < (int)
viewPtList.size(); i++) {
 
 2981      if (!strcmp(
viewPtList[i].viewPtName, vpName)) {
 
 3006   SoCamera * camera = getCamera();
 
 3007   if (camera == NULL) {
 
 3008      G4cout << 
"setViewPt: Camera is null. Unable to set the viewpoint." <<
 
 3017      G4cout << 
"setViewPt: There are no viewpoints to load." << 
G4endl;
 
 3024   if (SoQtExaminerViewer::isAnimating()) stopAnimating();
 
 3030      axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
 
 3047   if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
 
 3050         camera = getCamera();
 
 3051         ((SoOrthographicCamera *) camera)->height.setValue(
 
 3054         ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
 
 3056   } 
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
 
 3059         camera = getCamera();
 
 3060         ((SoPerspectiveCamera *) camera)->heightAngle.setValue(
 
 3063         ((SoOrthographicCamera *) camera)->height.setValue(
 
 3066      SoDebugError::post(
"G4OpenInventorQtExaminerViewer::setViewPt",
 
 3067                         "Only Perspective and Orthographic cameras are supported.");
 
 3127   setComponentCursor(SoQtCursor(SoQtCursor::CROSSHAIR));
 
 3139      setDrawStyle(SoQtViewer::STILL, SoQtViewer::VIEW_LINE);
 
 3140      setDrawStyle(SoQtViewer::INTERACTIVE, SoQtViewer::VIEW_LINE);
 
 3142      setDrawStyle(SoQtViewer::STILL, SoQtViewer::VIEW_AS_IS);
 
 3143      setDrawStyle(SoQtViewer::INTERACTIVE,
 
 3144                         SoQtViewer::VIEW_SAME_AS_STILL);
 
 3153   setFeedbackVisibility(checked);
 
 3180   if (!listitem) 
return;
 
 3181   if (!(listitem->isSelected())) 
return;
 
 3183   QString vpnamein = listitem->text();
 
 3186   char* vpName = 
new char[nVPName];
 
 3187   vpName = strdup(qPrintable(vpnamein));
 
 3202   std::ofstream out(
"temporaryFile.txt");
 
 3208   out << line << 
"\n";
 
 3210   while (getline(
fileIn, line)) {
 
 3211      end = line.find_last_not_of(
' ');
 
 3212      line = line.substr(0, end + 1);
 
 3213      if (!strcmp(line.c_str(), vpName)) { 
 
 3214         while (line.size()) {
 
 3218         while (getline(
fileIn, line))
 
 3219            out << line << 
"\n";
 
 3221         while (line.size()) {
 
 3222            out << line << 
"\n";
 
 3231   while (idx < size) {
 
 3232      if (!strcmp(
viewPtList[idx].viewPtName, vpName)) {
 
 3245   int istat = remove(
fileName.c_str());
 
 3248      msgbox.setFont(*
font);
 
 3249      QString messagetxt = 
"Error removing bookmarks file";
 
 3251      msgbox.setText(messagetxt);
 
 3255   istat = rename(
"temporaryFile.txt", 
fileName.c_str());
 
 3258      msgbox.setFont(*
font);
 
 3259      QString messagetxt = 
"Error renaming bookmarks file";
 
 3261      msgbox.setText(messagetxt);
 
 3266   fileOut.seekp(0, std::ios::end);
 
 3286   if (!listitem) 
return;
 
 3287   if (!(listitem->isSelected())) 
return;
 
 3289   QString vpnamein = listitem->text();
 
 3296   QInputDialog* inputdialog = 
new QInputDialog(getParentWidget());
 
 3297   inputdialog->setFont(*
font);
 
 3298   inputdialog->setWindowTitle(tr(
"Enter"));
 
 3299   inputdialog->setLabelText(
"New bookmark name");
 
 3300   inputdialog->adjustSize();
 
 3302   if (inputdialog->exec() == QDialog::Accepted)
 
 3303      newnamein=inputdialog->textValue().trimmed();
 
 3306   if (newnamein.isEmpty()) 
return;
 
 3308   char* newname = 
new char[nVPName];
 
 3309   newname = strdup(qPrintable(newnamein));
 
 3312   for (
int i = 0; i < size; i++) {
 
 3313      if (!strcmp(newname, 
viewPtList[i].viewPtName)) {
 
 3315         msgbox.setFont(*
font);
 
 3316         msgbox.setText(
"Bookmark name is already in use");
 
 3323   listitem->setText(QString(newname));
 
 3335   int idx = 0, end, 
pos;
 
 3337   std::string line, newName;
 
 3346   while (getline(
fileIn, line)) {
 
 3347      end = line.find_last_not_of(
' ');
 
 3348      line = line.substr(0, end + 1);
 
 3352         fileOut.seekp(0, std::ios::end); 
 
 3363   while (idx < size) {
 
 3383   std::vector<std::string> charList;
 
 3389   for (
int i = 0; i < (int)
viewPtList.size(); i++) {
 
 3391      charList.push_back(
viewPtList[i].viewPtName);
 
 3395   std::sort(charList.begin(), charList.end());
 
 3401   for (
int i = 0; i < (int)
viewPtList.size(); i++) {
 
 3418   float x, y, z, 
angle;
 
 3419   int sortIdx = 0, unsortIdx = 0;
 
 3428   int size = sortedViewPts.size();
 
 3429   while (sortIdx < size) {
 
 3430      while (strcmp(sortedViewPts[sortIdx].c_str(),
 
 3434      std::string vpName = 
viewPtList[unsortIdx].viewPtName;
 
 3438      fileOut << vpName << std::endl;
 
 3439      viewPtList[unsortIdx].position.getValue(x, y, z);
 
 3440      fileOut << x << 
" " << y << 
" " << z << std::endl;
 
 3444      axis.getValue(x, y, z);
 
 3445      fileOut << x << 
" " << y << 
" " << z << 
" " << 
angle << std::endl;
 
 3448              << 
viewPtList[unsortIdx].height << std::endl;
 
 3469   float multiplicator = float(std::exp(diffvalue));
 
 3470   SoCamera *cam = getCamera();
 
 3472   if (cam->isOfType(SoPerspectiveCamera::getClassTypeId())) {
 
 3473      const float oldfocaldist = cam->focalDistance.getValue();
 
 3474      const float newfocaldist = oldfocaldist * multiplicator;
 
 3477      cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction);
 
 3479      const SbVec3f oldpos = cam->position.getValue();
 
 3480      const SbVec3f newpos = oldpos + (newfocaldist - oldfocaldist) * -direction;
 
 3481      cam->position = newpos;
 
 3482      cam->focalDistance = newfocaldist;
 
 3483   } 
else if (cam->isOfType(SoOrthographicCamera::getClassTypeId())) {
 
 3484      SoOrthographicCamera * oc = (SoOrthographicCamera *)cam;
 
 3485      oc->height = oc->height.getValue() * multiplicator;
 
 3499   SoCamera *cam = getCamera();
 
 3500   const SoType type(ev->getTypeId());
 
 3502   if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
 
 3503      SoMouseButtonEvent * me = (SoMouseButtonEvent *) ev;
 
 3508      switch (me->getButton()) {
 
 3510         case SoMouseButtonEvent::BUTTON4: 
 
 3511            if (me->getState() == SoButtonEvent::DOWN) {
 
 3518         case SoMouseButtonEvent::BUTTON5: 
 
 3519            if (me->getState() == SoButtonEvent::DOWN) {
 
 3535   if (type.isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
 
 3536      SoKeyboardEvent* ke = (SoKeyboardEvent*)ev;
 
 3538      if (SoKeyboardEvent::isKeyPressEvent(ev, ke->getKey())) {
 
 3539         switch (ke->getKey()) {
 
 3540         case SoKeyboardEvent::E:
 
 3546                  "E KEY PRESSED, EXITING OIQT VIEWER SECONDARY LOOP" <<
 
 3548               SoQt::exitMainLoop();
 
 3552         case SoKeyboardEvent::LEFT_SHIFT:
 
 3555         case SoKeyboardEvent::RIGHT_SHIFT:
 
 3558         case SoKeyboardEvent::LEFT_CONTROL:
 
 3561         case SoKeyboardEvent::RIGHT_CONTROL:
 
 3564         case SoKeyboardEvent::SPACE:
 
 3586         case SoKeyboardEvent::ESCAPE:
 
 3602                  axisSwitch->whichChild.setValue(SO_SWITCH_NONE);
 
 3613         case SoKeyboardEvent::DELETE:
 
 3625         case SoKeyboardEvent::LEFT_ARROW:
 
 3633                  if (SoQtExaminerViewer::isAnimating())
 
 3648                  if (SoQtExaminerViewer::isAnimating())
 
 3672               cam->position = 
myCam->position;
 
 3679                  this->bottomWheelMotion(
 
 3680                                          this->getBottomWheelValue() + 0.1f);
 
 3690               SoDebugError::post(
"G4OpenInventorQtExaminerViewer::processSoEvent",
 
 3691                                  "Unhandled viewer state");
 
 3696         case SoKeyboardEvent::RIGHT_ARROW:
 
 3704                  if (SoQtExaminerViewer::isAnimating())
 
 3717                  if (SoQtExaminerViewer::isAnimating())
 
 3738               cam->position = 
myCam->position;
 
 3745                  this->bottomWheelMotion(
 
 3746                                          this->getBottomWheelValue() - 0.1f);
 
 3755               SoDebugError::post(
"G4OpenInventorQtExaminerViewer::processSoEvent",
 
 3756                                  "Unhandled viewer state");
 
 3761         case SoKeyboardEvent::DOWN_ARROW:
 
 3770                  if (SoQtExaminerViewer::isAnimating())
 
 3792               cam->position = 
myCam->position;
 
 3799                  this->leftWheelMotion(this->getLeftWheelValue() - 0.1f);
 
 3808               SoDebugError::post(
"G4OpenInventorQtExaminerViewer::processSoEvent",
 
 3809                                  "Unhandled viewer state");
 
 3814         case SoKeyboardEvent::UP_ARROW:
 
 3822                  if (SoQtExaminerViewer::isAnimating())
 
 3845               cam->position = 
myCam->position;
 
 3852                  this->leftWheelMotion(this->getLeftWheelValue() + 0.1f);
 
 3861               SoDebugError::post(
"G4OpenInventorQtExaminerViewer::processSoEvent",
 
 3862                                  "Unhandled viewer state");
 
 3867         case SoKeyboardEvent::PAGE_UP:
 
 3918         case SoKeyboardEvent::PAGE_DOWN:
 
 3975      if (SoKeyboardEvent::isKeyReleaseEvent(ev, ke->getKey())) {
 
 3976         switch (ke->getKey()) {
 
 3977         case SoKeyboardEvent::LEFT_SHIFT:
 
 3980         case SoKeyboardEvent::RIGHT_SHIFT:
 
 3983         case SoKeyboardEvent::LEFT_CONTROL:
 
 3986         case SoKeyboardEvent::RIGHT_CONTROL:
 
 4002      return SoQtExaminerViewer::processSoEvent(ev);
 
 4013   QFileDialog filedialog(getParentWidget(), tr(
"Load Scene Graph"));
 
 4014   filedialog.setFileMode(QFileDialog::AnyFile);
 
 4015   filedialog.setFont(*
font);
 
 4016   if (!filedialog.exec()) 
return;
 
 4017   QStringList filenameinlist = filedialog.selectedFiles();
 
 4018   QString filenamein = filenameinlist[0];
 
 4022   char* filename = 
new char[filenamein.size()+1];
 
 4023   filename = strdup(qPrintable(filenamein));
 
 4028   if (sceneInput.openFile(filename)) {
 
 4033         msgbox.setFont(*
font);
 
 4034         QString messagetxt = 
"Error reading scene graph file ";
 
 4035         messagetxt.append(filenamein);
 
 4036         msgbox.setText(messagetxt);
 
 4038         sceneInput.closeFile();
 
 4043      msgbox.setFont(*
font);
 
 4044      QString messagetxt = 
"Error opening scene graph file ";
 
 4045      messagetxt.append(filenamein);
 
 4046      msgbox.setText(messagetxt);
 
 4051   SoSeparator* root = (SoSeparator*)getSceneGraph();
 
 4061   QFileDialog filedialog(getParentWidget(), tr(
"Save scene graph"));
 
 4062   filedialog.setFileMode(QFileDialog::AnyFile);
 
 4064   filedialog.setAcceptMode(QFileDialog::AcceptSave);
 
 4065   filedialog.setFont(*
font);
 
 4066   if (!filedialog.exec()) 
return;
 
 4067   QStringList filenameinlist = filedialog.selectedFiles();
 
 4068   QString filenamein = filenameinlist[0];
 
 4072   char* filename = 
new char[filenamein.size()+1];
 
 4073   filename = strdup(qPrintable(filenamein));
 
 4076   SoWriteAction writeAction;
 
 4077   SoSeparator* root = (SoSeparator*)getSceneGraph();
 
 4079   SoOutput* out = writeAction.getOutput();
 
 4081   if (out->openFile(filename)) {
 
 4082      out->setBinary(
FALSE);
 
 4083      writeAction.apply(root);
 
 4087      msgbox.setFont(*
font);
 
 4088      QString messagetxt = 
"Error opening file ";
 
 4089      messagetxt.append(filenamein);
 
 4090      msgbox.setText(messagetxt);
 
static const G4double pos
#define MAX_SPEED_INDICATOR
#define SPEED_INDICATOR_STEP
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 mouseoverCB(void *aThis, SoEventCallback *eventCB)
SoTranslation * mouseOverTransMaterial
void SwitchWireFrameCB(bool)
SoCoordinate3 * getCoordsNode(SoFullPath *path)
static void superimpositionCB(void *closure, SoAction *action)
static void animateSensorRotationCB(void *, SoSensor *)
SoText2 * mouseOverTextMaterial
QListWidgetItem * saveViewPtItem
SoSearchAction * searcher
void moveCamera(float dist=0, bool lookdown=false)
virtual void afterRealizeHook()
QAction * FileSaveSceneGraph
SoSwitch * animSpeedSwitch
SoNode * getSuperimpositionNode(SoNode *, const char *name)
void animateRefParticle()
QAction * FileLoadRefPath
SoSeparator * newSceneGraph
SoTranslation * curInfoTrans
~G4OpenInventorQtExaminerViewer()
SoTranslation * mouseOverTransZPos
void addEscapeCallback(void(*cb)())
void buildWidget(QWidget *parent)
void parseString(T &t, const std::string &s, bool &error)
void ToolsRefPathStartCB()
QPushButton * abbrOutputButton
SoTranslation * mouseOverTransSolid
void setReferencePathZPos()
SbRotation camStartOrient
static void pickingCB(void *aThis, SoEventCallback *eventCB)
SoFont * mouseOverFontZPos
static void sceneChangeCB(void *, SoSensor *)
friend class HookEventProcState
SbBool processSoEvent(const SoEvent *const event)
void renameViewPt(char *vpName)
SoFont * mouseOverFontMaterial
std::vector< float > refZPositions
G4OpenInventorQtExaminerViewer(QWidget *parent=NULL, const char *name=NULL, SbBool embed=TRUE, SoQtFullViewer::BuildFlag flag=BUILD_ALL, SoQtViewer::Type type=BROWSER)
static G4OpenInventorQtExaminerViewer * viewer
SoTranslation * stranslation
SoTranslation * mouseOverTransLogName
void sortViewPts(std::vector< std::string >)
void deleteViewPt(char *vpName=NULL)
QPushButton * prevViewPtButton
SoNodeSensor * sceneChangeSensor
bool viewingBeforePickRef
void cleanUpAfterPrevFile()
QAction * FileNewBookmark
QPushButton * switchWireFrameButton
void FileLoadSceneGraphCB()
SoTimerSensor * animateSensor
virtual void actualRedraw(void)
void createElementsList()
Ui_Dialog * AuxWindowDialog
QAction * FileSaveRefPath
void setReferencePath(SoLineSet *, SoCoordinate3 *, bool append=false)
void saveViewPt(char *name)
void updateSpeedIndicator(void)
void construct(const SbBool build)
QPushButton * switchAxesButton
SoFont * mouseOverFontLogName
void ToolsAnimateRefParticleCB()
void superimpositionEvent(SoAction *action)
SoText2 * mouseOverTextZPos
SoTimerSensor * animateSensorRotation
QAction * ToolsRefPathInvert
void LoadBookmarkCB(QListWidgetItem *)
QPushButton * nextViewPtButton
std::vector< sceneElement > sceneElements
QAction * FileOpenBookmark
void distanceToTrajectory(const SbVec3f &, float &, SbVec3f &, int &)
void evenOutRefParticlePts()
QAction * FileLoadSceneGraph
viewPtData camB4Animation
double animateBtwPtsPeriod
SoSwitch * animSpeedOutlineSwitch
void LookAtSceneElementCB(QListWidgetItem *)
std::vector< viewPtData > viewPtList
SoFont * mouseOverFontSolid
std::vector< SbVec3f > refParticleTrajectory
QAction * ToolsAnimateRefParticle
SoText2 * mouseOverTextSolid
QPushButton * pickRefPathButton
QPushButton * detachButton
static void animateSensorCB(void *, SoSensor *)
void ToolsRefPathInvertCB()
float sqrlen(const SbVec3f &)
SoText2 * mouseOverTextLogName
SoCoordinate3 * sgeometry
QAction * ToolsRefPathStart
void setStartingPtForAnimation()
void FileOpenBookmarkCB()
HookEventProcState * hookBeamOn
void FileSaveSceneGraphCB()
QPushButton * saveViewPtButton
QTabWidget * GetViewerTabWidget()
bool AddTabWidget(QWidget *, QString)
static G4UImanager * GetUIpointer()
virtual G4bool Notify(G4ApplicationState requestedState)
HookEventProcState(G4OpenInventorQtExaminerViewer *)
G4OpenInventorQtExaminerViewer * viewer
QPushButton * pushButton_2
QPushButton * pushButton_3
void setupUi(QDialog *Dialog)
QListWidget * listWidget1
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)
def connect(endpoint="tcp://127.0.0.1:5555")
static const char * pickext_xpm[]
static const char * pickref_xpm[]
static const char * saveViewPt_xpm[]
float distanceToBeamlineStart
static const char * wireframe_xpm[]
static PROLOG_HANDLER error