33 #include <Inventor/nodes/SoSphere.h>
34 #include <Inventor/nodes/SoGroup.h>
35 #include <Inventor/nodes/SoPerspectiveCamera.h>
36 #include <Inventor/nodes/SoSeparator.h>
37 #include <Inventor/Qt/widgets/SoQtPopupMenu.h>
38 #include <Inventor/events/SoKeyboardEvent.h>
39 #include <Inventor/events/SoMouseButtonEvent.h>
40 #include <Inventor/nodes/SoEnvironment.h>
41 #include <Inventor/actions/SoSearchAction.h>
42 #include <Inventor/nodekits/SoBaseKit.h>
43 #include <Inventor/SoSceneManager.h>
49 #include <QColorDialog>
50 #include <QFileDialog>
51 #include <QInputDialog>
52 #include <QPushButton>
178 case VERTEX:
return "VERTEX";
179 case INDET:
return "INDET";
181 case CALO:
return "CALO";
182 case MUON:
return "MUON";
183 default:
return "Unknown(ERROR)";
276 environmentNode->ambientIntensity = (al==0?0.0f:(al==100?1.0f:al/100.0f));
303 void rotateCamera(SoCamera * cam,
const SbVec3f & aroundaxis,
const float delta);
372 QString
n = QString(perspective?
"Perspective":
"Orthographic")+
"View"+
QString::number(
i++);
411 QByteArray byteArray;
412 QBuffer
buffer(&byteArray);
413 buffer.open(QIODevice::WriteOnly);
430 : m_camPerspective(true)
436 buffer.open(QIODevice::ReadOnly);
437 QDataStream state(&
buffer);
443 "Attempt to depersistify stored view ignored due to bad version!");
473 SbVec3f
pos = camera->position.getValue();
476 SbBool oldsearch = SoBaseKit::isSearchingChildren();
477 SoBaseKit::setSearchingChildren(
TRUE);
479 action.setSearchingAll(
true);
480 action.setType(SoCamera::getClassTypeId());
484 SoBaseKit::setSearchingChildren(oldsearch);
486 SoPathList &cameras =
action.getPaths();
488 for (
int i = 0,
e = cameras.getLength();
i !=
e; ++
i) {
489 auto*
tail = cameras[
i]->getTail();
490 std::cerr <<
"Camera #" <<
i <<
" = " << (
void *)
tail <<
"(" <<
typeid(*tail).name() <<
")\n";
493 std::cerr <<
"Calculated clip-planes. Near: " << nearfar[0] <<
". Far: " << nearfar[1] <<
"\n"
494 <<
"Current camera clip-planes. Near: " << camera->nearDistance.getValue() <<
", Far: " << camera->farDistance.getValue() <<
"\n"
495 <<
"Camera ptr: " << (
void *) camera <<
"\n"
496 <<
"Camera name: " << camera->getName() <<
"\n"
497 <<
"Camera type: " <<
typeid(*camera).name() <<
"\n"
498 <<
"Camera position:(" <<
pos[0] <<
", " <<
pos[1] <<
", " <<
pos[2] <<
")\n"
499 <<
"Number of cameras in the scene: " << cameras.getLength() <<
"\n"
500 <<
"Focal distance: " << camera->focalDistance.getValue() << std::endl;
517 if (camera->nearDistance.getValue() != nearfar[0])
518 camera->nearDistance = nearfar[0];
519 if (camera->farDistance.getValue() != nearfar[1])
520 camera->farDistance = nearfar[1];
530 SoQtFullViewer::BuildFlag
flag,
537 QWidget * widget = buildWidget(getParentWidget());
539 rightWheelLabel->setVisible(
false);
540 setBaseWidget(widget);
541 setLeftWheelString(
"Rotz");
544 setRightWheelString(
"Zoom test");
545 leftWheel->setMinimumHeight(20);
546 rightWheel->setMinimumHeight(20);
575 SoQtExaminerViewer::setStereoOffset(
offset);
578 return SoQtExaminerViewer::getStereoOffset();
582 return SoQtExaminerViewer::setStereoType(
type);
585 return SoQtExaminerViewer::getStereoType();
588 SoQtExaminerViewer::setAnaglyphStereoColorMasks(left, right);
591 SoQtExaminerViewer::getAnaglyphStereoColorMasks(left, right);
600 case VIEW_AS_IS:
return 0;
601 case VIEW_HIDDEN_LINE:
return 1;
602 case VIEW_NO_TEXTURE:
return 2;
603 case VIEW_LOW_COMPLEXITY:
return 3;
604 case VIEW_LINE:
return 4;
605 case VIEW_POINT:
return 5;
606 case VIEW_BBOX:
return 6;
607 case VIEW_LOW_RES_LINE:
return 7;
608 case VIEW_LOW_RES_POINT:
return 8;
609 case VIEW_SAME_AS_STILL:
return 9;
610 case VIEW_WIREFRAME_OVERLAY :
return 10;
620 case 0:
return SoQtViewer::VIEW_AS_IS;
621 case 1:
return SoQtViewer::VIEW_HIDDEN_LINE;
622 case 2:
return SoQtViewer::VIEW_NO_TEXTURE;
623 case 3:
return SoQtViewer::VIEW_LOW_COMPLEXITY;
624 case 4:
return SoQtViewer::VIEW_LINE;
625 case 5:
return SoQtViewer::VIEW_POINT;
626 case 6:
return SoQtViewer::VIEW_BBOX;
627 case 7:
return SoQtViewer::VIEW_LOW_RES_LINE;
628 case 8:
return SoQtViewer::VIEW_LOW_RES_POINT;
629 case 9:
return SoQtViewer::VIEW_SAME_AS_STILL;
630 case 10:
return SoQtViewer::VIEW_WIREFRAME_OVERLAY;
633 return SoQtViewer::VIEW_AS_IS;
643 QByteArray byteArray;
644 QBuffer
buffer(&byteArray);
645 buffer.open(QIODevice::WriteOnly);
659 if (getBufferingType()==BUFFER_SINGLE)
661 else if (getBufferingType()==BUFFER_INTERACTIVE)
668 out << isperspective;
673 const bool isdeco(isDecoration()), isheadlight(isHeadlight()),isviewing(isViewing());
694 out << idrawstyle_still;
695 out << idrawstyle_interactive;
739 QList<QByteArray> persistifiedViews;
741 persistifiedViews <<
sv.persistifiedState();
742 out << persistifiedViews;
769 QBuffer
buffer(&ba_state);
770 buffer.open(QIODevice::ReadOnly);
771 QDataStream state(&
buffer);
775 if (version<0||version>6) {
776 VP1Msg::messageDebug(
"VP1ExaminerViewer Warning: Input state data is in wrong format - ignoring!");
784 if (bgdcol.isValid())
798 state >> isperspective;
803 if (getCamera()&&ba_cam!=QByteArray())
808 bool isdeco, isheadlight, isviewing, decoremoved;
809 state >> isdeco;
if (isdeco!=isDecoration()) setDecoration(isdeco);
810 state >> isheadlight;
if (isheadlight!=isHeadlight()) setHeadlight(isheadlight);
811 state >> isviewing;
if (isviewing!=isViewing())
setViewing(isviewing);
814 +
str(isdeco)+
", "+
str(isheadlight)+
", "+
str(isviewing)+
", "+
str(decoremoved)+
")");
818 SbBool smoothing;
int numPasses;
836 int idrawstyle_still, idrawstyle_interactive;
837 state >> idrawstyle_still;
838 state >> idrawstyle_interactive;
887 QList<QByteArray> persistifiedViews;
888 state >> persistifiedViews;
889 for(
const QByteArray& ba_pv : persistifiedViews) {
903 if (ba!=QByteArray()) {
922 #if SOQT_MAJOR_VERSION <= 1 && SOQT_MINOR_VERSION <= 4 && SOQT_MICRO_VERSION <= 1
927 SoQtExaminerViewer::setSceneGraph(0);
935 SoQtExaminerViewer::createViewerButtons(
parent,buttonlist);
938 if (buttonlist->getLength()==7) {
948 m_d->
button_interact->setToolTip(
"Pick mode (ESC/M toggles). Use this in order to select objects.");
949 m_d->
button_examine->setToolTip(
"Navigation mode (ESC/M toggles). Use to ROTATE (left click), ZOOM (wheel or SHIFT+CTRL+left click) or PAN (middle click or SHIFT+left click or CTRL+left click).");
953 m_d->
button_seek->setToolTip(
"Seek to point (S). Sets cameras rotation centre to the clicked point and zooms towards it.");
954 m_d->
button_togglecamera->setToolTip(
"Toggle (C) camera between perspective (P) and orthographic (O) mode.");
959 VP1Msg::message(
"VP1ExaminerViewer::createViewerButtons ERROR: Did not get list of exactly 7 buttons from base.");
968 QPushButton * button =
new QPushButton(tempparent);
969 if (iconname.isEmpty()) {
970 button->setText(
text);
972 button->setIcon( QIcon(iconname) );
974 button->setToolTip(tooltip);
975 detectorbuttons[button] = std::make_pair(region,
view);
976 button->setFocusPolicy(Qt::NoFocus);
979 QObject::connect(button,SIGNAL(clicked()),signalcatcher,SLOT(catchSignal()));
980 theclass->addAppPushButton(button);
988 animationSequencer.sequence().clearAllFrames();
993 if (popup_tourSpeedVerySlow->isChecked())
995 else if (popup_tourSpeedSlow->isChecked())
997 else if (popup_tourSpeedFast->isChecked())
999 else if (popup_tourSpeedVeryFast->isChecked())
1003 tourLoopsForever = popup_tourLoopForever->isChecked();
1005 if (popup_tourLoopTwice->isChecked())
1007 else if (popup_tourLoopThrice->isChecked())
1011 tourLoopsForeverSkipFirstFrame =
false;
1012 double firstfact(action_movieenabled->isChecked()?0.0:0.25);
1015 for (
int iloop = 0; iloop < nloops; ++iloop) {
1016 if (popup_tourPartsMuon->isChecked()) {
1018 if (
first||latestRegion!=region)
1019 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), (
first?firstfact:1.0)*steptime);
1020 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(10*
M_PI/6), 0,
cos(10*
M_PI/6)), steptime);
1021 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(2*
M_PI/6), 0,
cos(2*
M_PI/6)), steptime);
1022 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), steptime);
1023 latestRegion=region;
1025 firstRegion = region;
1030 if (popup_tourPartsCalo->isChecked()) {
1032 if (
first||latestRegion!=region)
1033 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), (
first?firstfact:1.0)*steptime);
1034 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(10*
M_PI/6), 0,
cos(10*
M_PI/6)), steptime);
1035 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(2*
M_PI/6), 0,
cos(2*
M_PI/6)), steptime);
1036 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), steptime);
1037 latestRegion=region;
1039 firstRegion = region;
1044 if (popup_tourPartsInDet->isChecked()) {
1046 if (
first||latestRegion!=region)
1047 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), (
first?firstfact:1.0)*steptime);
1048 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(10*
M_PI/6), 0,
cos(10*
M_PI/6)), steptime);
1049 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(2*
M_PI/6), 0,
cos(2*
M_PI/6)), steptime);
1050 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), steptime);
1051 latestRegion=region;
1053 firstRegion = region;
1058 if (popup_tourPartsVertex->isChecked()) {
1060 if (
first||latestRegion!=region)
1061 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), (
first?firstfact:1.0)*steptime);
1062 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(10*
M_PI/6), 0,
cos(10*
M_PI/6)), steptime);
1063 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(2*
M_PI/6), 0,
cos(2*
M_PI/6)), steptime);
1064 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), steptime);
1065 latestRegion=region;
1067 firstRegion = region;
1075 if (tourLoopsForever && nregions==1)
1076 tourLoopsForeverSkipFirstFrame =
true;
1078 if (!tourLoopsForever&&latestRegion!=firstRegion)
1079 animationSequencer.sequence().addFrame(firstRegion, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), steptime);
1080 if (firstfact>0.0&&!tourLoopsForever)
1081 animationSequencer.sequence().addFrame(theclass->currentCameraState(),firstfact*steptime);
1091 QWidget * tempparent =
new QWidget();
1095 tempparent->setVisible(
false);
1096 if (detectorViewButtons) {
1100 addNewButton(
"IA",
"View inner detector from positive Z axis",INDET,
ASIDE,tempparent);
1101 addNewButton(
"IC",
"View inner detector from negative Z axis",INDET,
CSIDE,tempparent);
1103 addNewButton(
"CA",
"View calorimeters from positive Z axis",
CALO,
ASIDE,tempparent);
1104 addNewButton(
"CC",
"View calorimeters from negative Z axis",
CALO,
CSIDE,tempparent);
1106 addNewButton(
"MA",
"View muon spectrometer from positive Z axis",
MUON,
ASIDE,tempparent);
1107 addNewButton(
"MC",
"View muon spectrometer from negative Z axis",
MUON,
CSIDE,tempparent);
1109 addNewButton(
"FA",
"View forward region from positive Z axis",FORWARDREGION,
ASIDE,tempparent);
1110 addNewButton(
"FC",
"View forward region from negative Z axis",FORWARDREGION,
CSIDE,tempparent);
1112 addNewButton(
"MB",
"View muon spectrometer from barrel",
MUON,
BARREL,tempparent,
":icons/icons/rphi.png");
1117 QPushButton *button =
new QPushButton(tempparent);
1118 button->setText(
"XT");
1119 button->setToolTip(
"Execute a tour of the detector (configure in context menu)");
1120 button->setFocusPolicy(Qt::NoFocus);
1121 takeTourButton=button;
1122 QObject::connect(button,SIGNAL(clicked()), signalcatcher, SLOT(catchSignal()));
1123 theclass->addAppPushButton(button);
1124 QObject::connect(&animationSequencer,SIGNAL(animationFinishedSuccessfully()),signalcatcher,SLOT(catchSignal()));
1127 QWidget * w_spacer =
new QWidget(tempparent);
1128 QSizePolicy sp_spacer(w_spacer->sizePolicy());
1129 unsigned vertStretch = 99999;
1130 sp_spacer.setVerticalStretch(vertStretch);
1131 w_spacer->setSizePolicy(sp_spacer);
1132 theclass->addAppPushButton(w_spacer);
1134 tempparent->deleteLater();
1147 QPushButton* button =
dynamic_cast<QPushButton*
>(sender());
1155 QMenu*
menu =
dynamic_cast<QMenu*
>(sender());
1160 VP1Msg::messageDebug(
"VP1ExaminerViewer_SignalCatcher::catchSignal ERROR: Received unknown signal");
1182 sphere =
new SoSphere;
1194 r = perspective ? 13 : 7;
1198 r = perspective ? 35 : 27;
1208 r = perspective ? 95 : 73;
1211 sphere->radius =
r * 1000.0;
1219 QWidget *
w = theclass->getGLWidget();
1221 w->setFocus(Qt::OtherFocusReason);
1230 if (action_movieenabled->isChecked()) {
1231 int width = action_moviewidth->data().toInt();
1232 int height = action_movieheight->data().toInt();
1233 int fps = action_moviefps->data().toInt();
1234 QString
outdir = action_movieoutdir->data().toString();
1236 animationSequencer.setMovie(
true);
1237 animationSequencer.setMovieParameters(
outdir,movieFrameFileNamePrefix,fps,
width,height);
1239 animationSequencer.setMovie(
false);
1270 if (theclass->isAnimating())
1271 theclass->stopAnimating();
1272 if (updateAnimationSequence()) {
1273 applyMovieSettingsToAnimationSequencer();
1275 animationSequencer.startAnimating();
1289 SoNode * rootnode = theclass->getSceneGraph();
1291 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::detectorZoomButtonClicked WARNING: No scenegraph set. Ignoring.");
1294 if ( ! ( rootnode->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) ) {
1295 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::detectorZoomButtonClicked WARNING: Root node does not derive from SoGroup. Ignoring.");
1298 if (theclass->currentCamIsPerspective()) {
1300 theclass->toggleCameraType();
1301 theclass->toggleCameraType();
1303 SoCamera * camera = theclass->getCamera();
1305 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::detectorZoomButtonClicked WARNING: Could not get camera. Ignoring.");
1311 SoGroup *
root =
static_cast<SoGroup*
>(rootnode);
1314 SoSphere * regionsphere = getRegionSphere(
p.first,
1315 theclass->currentCamIsPerspective());
1324 theclass->setLeftWheelString(
"Rotz");
1331 theclass->setLeftWheelString(
"Rotz");
1338 theclass->setLeftWheelString(
"Rotx");
1341 SbVec3f lookat(xDir,0,zDir), upvec(0,1,0);
1343 bool notifyenabled =
root->enableNotify(
false);
1345 root->insertChild(regionsphere,0);
1347 if (theclass->isAnimating())
1348 theclass->stopAnimating();
1349 camera->unrefNoDelete();
1355 root->removeChild(regionsphere);
1356 if (notifyenabled) {
1357 root->enableNotify(
true);
1361 rootnode->unrefNoDelete();
1384 int id = prefmenu->getMenuItem(
"decoration");
1386 prefmenu->removeMenuItem(
id);
1396 if (
evt->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
1407 if (SO_KEY_PRESS_EVENT(
evt,SoKeyboardEvent::V)) {
1411 if (SO_KEY_PRESS_EVENT(
evt,SoKeyboardEvent::Q))
1422 if (SO_KEY_PRESS_EVENT(
evt,SoKeyboardEvent::O)) {
1427 if (SO_KEY_PRESS_EVENT(
evt,SoKeyboardEvent::M)) {
1440 }
else if (
evt->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
1443 const SoMouseButtonEvent * ev_mouse =
static_cast<const SoMouseButtonEvent*
>(
evt);
1444 if ((ev_mouse->getButton() == SoMouseButtonEvent::BUTTON2)) {
1445 if (ev_mouse->getState() == SoButtonEvent::DOWN) {
1453 return SoQtExaminerViewer::processSoEvent(
evt);
1467 SoQtExaminerViewer::viewAll();
1476 SoQtExaminerViewer::toggleCameraType();
1484 if (rightWheelLabel)
1485 rightWheelLabel->setUpdatesEnabled(
false);
1486 SoQtExaminerViewer::setCameraType(
type);
1487 setRightWheelString(
"Zoom");
1488 if (rightWheelLabel) {
1489 rightWheelLabel->setVisible(
true);
1490 rightWheelLabel->setUpdatesEnabled(
true);
1506 SoQtExaminerViewer::setSeekMode(enable);
1514 SoQtExaminerViewer::setViewing(enable);
1522 SoQtExaminerViewer::bottomWheelFinish();
1530 SoQtExaminerViewer::bottomWheelMotion(
val);
1538 SoQtExaminerViewer::bottomWheelStart();
1545 SoQtExaminerViewer::leftWheelFinish();
1562 SoQtFullViewer::leftWheelMotion(newval);
1569 SoQtExaminerViewer::leftWheelStart();
1576 SoQtExaminerViewer::rightWheelFinish();
1583 SoQtExaminerViewer::rightWheelMotion(
val);
1590 SoQtExaminerViewer::rightWheelStart();
1596 SoCamera * cam = theclass->getCamera();
1601 rotateCamera(cam, SbVec3f(0, 0, -1),
value - oldvalue);
1602 cam->unrefNoDelete();
1609 SoCamera * cam = theclass->getCamera();
1614 rotateCamera(cam, SbVec3f(-1, 0, 0),
value - oldvalue);
1615 cam->unrefNoDelete();
1621 const SbVec3f & aroundaxis,
1624 const SbVec3f DEFAULTDIRECTION(0, 0, -1);
1625 const SbRotation currentorientation = cam->orientation.getValue();
1628 currentorientation.multVec(DEFAULTDIRECTION,
currentdir);
1630 const SbVec3f focalpoint = cam->position.getValue() +
1634 cam->orientation = SbRotation(aroundaxis, delta) * currentorientation;
1637 cam->orientation.getValue().multVec(DEFAULTDIRECTION, newdir);
1638 cam->position = focalpoint - cam->focalDistance.getValue() * newdir;
1644 SoQtExaminerViewer::setBufferingType(bt);
1652 SoQtExaminerViewer::setAntialiasing(smoothing, numPasses);
1668 bool printWarning =
false;
1670 #ifndef BUILDVP1LIGHT
1671 env_aa =
std::getenv(
"VP1_ADVANCED_ANTIALIASING");
1674 if(antialiasingIsOn){
1680 if (env_aa != NULL) {
1681 std::string env_aa_string( env_aa );
1682 if(env_aa_string ==
"1") {
1685 if ( !
std::getenv(
"VP1_ADVANCED_ANTIALIASING_PRINTMSG")) {
1686 VP1Msg::messageWarningRed(
"You switched ON advanced anti-aliasing. That's very good, but please notice that this method DOES NOT WORK on LXPLUS machines, currently, because of their old graphics drivers! If you are on LXPLUS, this will likely freeze VP1... If that's the case, please restart VP1 without the '-advanced-aa' flag.");
1688 ::setenv(
"VP1_ADVANCED_ANTIALIASING_PRINTMSG",
"1", 1);
1694 VP1Msg::message(
"Sep 2017: AA is now done using a new technique so please let hn-atlas-vp1-help@cern.ch know of any problems.");
1697 if (getGLRenderAction()->isSmoothing() != smoothing)
1698 getGLRenderAction()->setSmoothing(smoothing);
1701 #if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 5)
1702 if (getSampleBuffers() != buffers)
1703 setSampleBuffers(buffers);
1706 VP1Msg::message(
"Multisampling is not supported by SoQT < 1.5, this anti-aliasing mode is disabled");
1711 getGLRenderAction()->setSmoothing(smoothing);
1712 setSampleBuffers(0);
1716 printWarning =
true;
1720 printWarning =
true;
1724 VP1Msg::messageWarningRed(
"Anti-aliasing is using low-quality mode only, because of problems with the graphic drivers installed on LXPLUS machines. If you are not running VP1 on LXPLUS machine (for example, if you are running it on a custom SLC6 machine), you can start VP1 again using the command-line flag '-advanced-aa'.");
1733 SoQtExaminerViewer::setTransparencyType(
t);
1739 SoQtExaminerViewer::setDrawStyle(
t,
s);
1756 std::cout <<
"antiAliasing set." << std::endl;
1777 return getCameraType() == SoPerspectiveCamera::getClassTypeId();
1783 SoCamera * cam(getCamera());
1789 int width,
int height,
bool transp )
1791 SoCamera * cam = getCamera();
1794 bool notifyenabled = cam->enableNotify(
false);
1798 if (currentPersp!=camStateIsPerspective)
1802 if (currentPersp!=camStateIsPerspective)
1806 if (notifyenabled) {
1807 cam->enableNotify(
true);
1832 int width = action_moviewidth->data().toInt();
1833 int height = action_movieheight->data().toInt();
1834 int fps = action_moviefps->data().toInt();
1835 QString
outdir = action_movieoutdir->data().toString();
1837 action_movieheight->setText(
"Change output &height [current: "+
QString::number(height)+
"]");
1838 action_moviefps->setText(
"Change output &FPS [current: "+
QString::number(fps)+
"]");
1839 action_movieoutdir->setText(
"Change output &dir [current: "+
outdir+
"]");
1841 bool c(action_movieenabled->isChecked());
1842 action_moviewidth->setEnabled(
c);
1843 action_movieheight->setEnabled(
c);
1844 action_moviefps->setEnabled(
c);
1845 action_movieoutdir->setEnabled(
c);
1854 QWidget *
w = theclass->getWidget();
1857 popup_menu =
new QMenu (
w);
1859 popup_bgdColAction = popup_menu->addAction(
"&Background Colour");
1860 popup_antiAliasAction = popup_menu->addAction(
"&Anti aliasing [A]");
1861 popup_resetCameraAction = popup_menu->addAction(
"&Reset camera");
1863 if (detectorViewButtons) {
1865 QMenu * tourmenu = popup_menu->addMenu(
"&Tour");
1866 popup_tourStartEachEvent = tourmenu->addAction(
"Start tour on new event");
1867 popup_tourStartEachEvent->setCheckable(
true);
1868 popup_tourReturnToStartAction = tourmenu->addAction(
"Tour ends at &original view");
1869 popup_tourReturnToStartAction->setCheckable(
true);
1870 popup_tourReturnToStartAction->setVisible(
false);
1871 QMenu * tourspeedmenu = tourmenu->addMenu(
"&Speed");
1872 QMenu * tourpartsmenu = tourmenu->addMenu(
"&Parts");
1873 QMenu * tourloopmenu = tourmenu->addMenu(
"&Looping");
1874 popup_tourExecute = tourmenu->addAction(
"E&xecute");
1877 popup_tourSpeedVerySlow = tourspeedmenu->addAction(
"Very s&low");
1878 popup_tourSpeedSlow = tourspeedmenu->addAction(
"&Slow");
1879 popup_tourSpeedMedium = tourspeedmenu->addAction(
"&Medium");
1880 popup_tourSpeedFast = tourspeedmenu->addAction(
"&Fast");
1881 popup_tourSpeedVeryFast = tourspeedmenu->addAction(
"Very f&ast");
1882 popup_tourSpeedVerySlow->setCheckable(
true);
1883 popup_tourSpeedSlow->setCheckable(
true);
1884 popup_tourSpeedMedium->setCheckable(
true);
1885 popup_tourSpeedFast->setCheckable(
true);
1886 popup_tourSpeedVeryFast->setCheckable(
true);
1887 QActionGroup * tour_speed_group =
new QActionGroup(tourspeedmenu);
1888 tour_speed_group->addAction(popup_tourSpeedVerySlow);
1889 tour_speed_group->addAction(popup_tourSpeedSlow);
1890 tour_speed_group->addAction(popup_tourSpeedMedium);
1891 tour_speed_group->addAction(popup_tourSpeedFast);
1892 tour_speed_group->addAction(popup_tourSpeedVeryFast);
1893 popup_tourSpeedMedium->setChecked(
true);
1896 popup_tourPartsVertex = tourpartsmenu->addAction(
"&Vertex region");
1897 popup_tourPartsInDet = tourpartsmenu->addAction(
"&Inner Detector");
1898 popup_tourPartsCalo = tourpartsmenu->addAction(
"&Calorimeters");
1899 popup_tourPartsMuon = tourpartsmenu->addAction(
"&Muon systems");
1900 popup_tourPartsVertex->setCheckable(
true);
1901 popup_tourPartsInDet->setCheckable(
true);
1902 popup_tourPartsCalo->setCheckable(
true);
1903 popup_tourPartsMuon->setCheckable(
true);
1904 popup_tourPartsInDet->setChecked(
true);
1905 popup_tourPartsMuon->setChecked(
true);
1908 popup_tourLoopOnce = tourloopmenu->addAction(
"&Once");
1909 popup_tourLoopTwice = tourloopmenu->addAction(
"&Twice");
1910 popup_tourLoopThrice = tourloopmenu->addAction(
"T&hrice");
1911 popup_tourLoopForever = tourloopmenu->addAction(
"&Indefinitely");
1912 popup_tourLoopOnce->setCheckable(
true);
1913 popup_tourLoopTwice->setCheckable(
true);
1914 popup_tourLoopThrice->setCheckable(
true);
1915 popup_tourLoopForever->setCheckable(
true);
1916 QActionGroup * tour_loop_group =
new QActionGroup(tourloopmenu);
1917 tour_loop_group->addAction(popup_tourLoopOnce);
1918 tour_loop_group->addAction(popup_tourLoopTwice);
1919 tour_loop_group->addAction(popup_tourLoopThrice);
1920 tour_loop_group->addAction(popup_tourLoopForever);
1921 popup_tourLoopOnce->setChecked(
true);
1925 QMenu * advancedmenu = popup_menu->addMenu(
"&More");
1927 popup_hidedecorationsaction = advancedmenu->addAction(
"Hide &controls");
1928 popup_headLightAction = advancedmenu->addAction(
"&Headlight");
1929 popup_ambientLightAction = advancedmenu->addAction(
"dummy");
1930 popup_dumpSceneAction = advancedmenu->addAction(
"Dump &scene to file");
1931 popup_dumpSceneVRMLAction = advancedmenu->addAction(
"Dump &scene to VRML file");
1932 popup_toSVGAction = advancedmenu->addAction(
"Produce SV&G image");
1933 popup_toEPSAction = advancedmenu->addAction(
"Produce &EPS image");
1935 if (detectorViewButtons) {
1937 QMenu * viewsmenu = advancedmenu->addMenu(
"Stored &views");
1938 viewmenu_zoomtoview = viewsmenu->addMenu(
"Animated &zoom to view");
1939 viewmenu_restoreview = viewsmenu->addMenu(
"&Restore view");
1940 viewmenu_storecurrentview = viewsmenu->addMenu(
"Store ¤t view");
1941 viewmenu_deleteview = viewsmenu->addMenu(
"&Delete view");
1942 QObject::connect(viewmenu_storecurrentview,SIGNAL(aboutToShow()),signalcatcher,SLOT(catchSignal()));
1943 QObject::connect(viewmenu_deleteview,SIGNAL(aboutToShow()),signalcatcher,SLOT(catchSignal()));
1944 QObject::connect(viewmenu_restoreview,SIGNAL(aboutToShow()),signalcatcher,SLOT(catchSignal()));
1945 QObject::connect(viewmenu_zoomtoview,SIGNAL(aboutToShow()),signalcatcher,SLOT(catchSignal()));
1946 storedViewsChanged();
1949 if (detectorViewButtons) {
1951 QMenu * customtourmenu = advancedmenu->addMenu(
"Custom &tour");
1952 customtour_launcheditor = customtourmenu->addAction(
"Launch &editor");
1953 customtour_execute = customtourmenu->addAction(
"E&xecute");
1954 customtour_execute->setEnabled(
false);
1957 QMenu * moviesmenu = advancedmenu->addMenu(
"&Movie settings");
1958 action_movieenabled = moviesmenu->addAction(
"&Enable movie output when executing tours (one image file per frame)");
1959 action_movieenabled->setCheckable(
true);
1960 action_movieenabled->setChecked(
false);
1961 action_moviewidth = moviesmenu->addAction(
"dummy");
1962 action_moviewidth->setData(1024);
1963 action_movieheight = moviesmenu->addAction(
"dummy");
1964 action_movieheight->setData(768);
1965 action_moviefps = moviesmenu->addAction(
"dummy");
1966 action_moviefps->setData(24);
1967 action_movieoutdir = moviesmenu->addAction(
"dummy");
1969 action_movieoutdir->setData(username.isEmpty() ?
"/tmp/vp1frames" :
"/tmp/"+username+
"/vp1frames");
1970 action_moviefadetocurrentview = moviesmenu->addAction(
"Fade last frame to current view (1s)");
1971 updateMovieMenuVisuals();
1975 updateAmbientLightText();
1976 popup_headLightAction->setCheckable(
true);
1977 popup_antiAliasAction->setCheckable(
true);
1978 popup_hidedecorationsaction->setCheckable(
true);
1982 QMenu * drawstylemenu = advancedmenu->addMenu(
"&Draw styles");
1984 QMenu * drawstyle_still_menu = drawstylemenu->addMenu(
"&Still draw style");
1985 QMenu * drawstyle_interactive_menu = drawstylemenu->addMenu(
"&Interactive draw style");
1986 QMenu * drawstyle_transptype_menu = drawstylemenu->addMenu(
"&Transparency Type");
1989 QActionGroup * ds_still_group =
new QActionGroup(drawstyle_still_menu);
1990 QActionGroup * ds_interactive_group =
new QActionGroup(drawstyle_interactive_menu);
1991 for(SoQtViewer::DrawStyle
ds : getAllViewerDrawStyles()) {
1992 int ids = viewerDrawStyleToInt(
ds);
1993 QString
pretty = viewerDrawStyle2PrettyString(
ds);
1994 if (
ds!=SoQtViewer::VIEW_SAME_AS_STILL) {
1996 QAction * act = drawstyle_still_menu->addAction(
pretty);
1998 popup_drawstyle_still_actions << act;
1999 ds_still_group->addAction(act);
2000 act->setCheckable(
true);
2002 if (
ds!=SoQtViewer::VIEW_AS_IS) {
2004 QAction * act = drawstyle_interactive_menu->addAction(
pretty);
2006 popup_drawstyle_interactive_actions << act;
2007 ds_interactive_group->addAction(act);
2008 act->setCheckable(
true);
2013 QActionGroup * transptype_group =
new QActionGroup(drawstyle_transptype_menu);
2017 popup_transptype_actions << act;
2018 transptype_group->addAction(act);
2019 act->setCheckable(
true);
2024 QMenu * stereoviewmenu_main = advancedmenu->addMenu(
"&Stereographic view");
2025 stereo_launcheditor = stereoviewmenu_main->addAction(
"Launch &editor");
2028 popup_focal_value_action = advancedmenu->addAction(
"dummy");
2029 SoCamera *camera = theclass->getCamera();
2030 float default_focal_camera = camera->focalDistance.getValue();
2031 popup_focal_value_action->setData(default_focal_camera);
2032 popup_focal_value_action->setText(
"Change camera FOCAL LENGTH [current: "+
QString::number(default_focal_camera)+
"]");
2151 if (viewmenu_storecurrentview==
menu) {
2152 viewmenu_storecurrentview->clear();
2153 storeViewActions.clear();
2154 QString
fs = firstAvailableStoredViewName();
2155 QAction * act = viewmenu_storecurrentview->addAction(
"Store as "+
fs);
2157 storeViewActions << act;
2158 if (!storedViews.isEmpty()) {
2159 viewmenu_storecurrentview->addSeparator();
2161 act = viewmenu_storecurrentview->addAction(
"Overwrite "+
sv.name());
2162 act->setIcon(
sv.icon());
2163 if (!fitsCurrentCamType(
sv)) {
2164 act->setEnabled(
false);
2166 act->setData(
sv.name());
2167 storeViewActions << act;
2174 if (viewmenu_zoomtoview==
menu) {
2175 viewmenu_zoomtoview->clear();
2176 zoomToViewActions.clear();
2178 QAction * act = viewmenu_zoomtoview->addAction(
sv.name());
2179 act->setIcon(
sv.icon());
2180 if (!fitsCurrentCamType(
sv)) {
2181 act->setEnabled(
false);
2183 act->setData(
sv.name());
2184 zoomToViewActions << act;
2189 if (viewmenu_restoreview==
menu) {
2190 viewmenu_restoreview->clear();
2191 restoreViewActions.clear();
2193 QAction * act = viewmenu_restoreview->addAction(
sv.name());
2194 act->setIcon(
sv.icon());
2195 act->setData(
sv.name());
2196 restoreViewActions << act;
2200 if (viewmenu_deleteview==
menu) {
2201 viewmenu_deleteview->clear();
2202 deleteViewActions.clear();
2204 QAction * act = viewmenu_deleteview->addAction(
sv.name());
2205 act->setIcon(
sv.icon());
2206 act->setData(
sv.name());
2207 deleteViewActions << act;
2219 if (!popup_headLightAction)
2221 popup_headLightAction->setChecked(theclass->isHeadlight());
2222 popup_antiAliasAction->setChecked(theclass->isAntiAlias());
2223 popup_hidedecorationsaction->setChecked(! theclass->isDecoration());
2225 int idrawstyle_still = viewerDrawStyleToInt(theclass->getDrawStyle(SoQtViewer::STILL));
2226 for (QAction * act : popup_drawstyle_still_actions) {
2227 if (act->data().toInt() == idrawstyle_still) {
2228 act->setChecked(
true);
2233 int idrawstyle_interactive = viewerDrawStyleToInt(theclass->getDrawStyle(SoQtViewer::INTERACTIVE));
2234 for (QAction * act : popup_drawstyle_interactive_actions) {
2235 if (act->data().toInt() == idrawstyle_interactive) {
2236 act->setChecked(
true);
2242 for (QAction * act : popup_transptype_actions) {
2243 if (act->data().toInt() == itransptype) {
2244 act->setChecked(
true);
2249 popup_resetCameraAction->setVisible(resetCamera_state!=QByteArray());
2262 QWidget *
w = getWidget();
2269 filename = QFileDialog::getSaveFileName(
w,
"Select output file",
2271 "Inventor files (*.iv)",0,QFileDialog::DontResolveSymlinks);
2279 SoGroup * standardisedRoot(0);
2280 if ( rootnode->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
2297 QWidget *
w = getWidget();
2304 filename = QFileDialog::getSaveFileName(
w,
"Select output file",
2306 "VRML2.0/X3D files (*.wrl)",0,QFileDialog::DontResolveSymlinks);
2314 SoGroup * standardisedRoot(0);
2315 if ( rootnode->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
2328 QWidget *
w = getWidget();
2334 filename = QFileDialog::getSaveFileName(
w,
"Select output file",
2336 "Scalable Vector Graphics files (*.svg)",0,QFileDialog::DontResolveSymlinks);
2351 SoNode *rootA =
static_cast<SoNode*
>(SoQtRenderArea::getSceneGraph());
2352 if (!rootA )
return;
2353 SoNode *cam =
static_cast<SoNode*
>(this->getCamera());
2354 if ( ! cam )
return;
2358 assert(
search.getPath());
2359 SoNode* hiddenRoot =
2360 static_cast<SoFullPath *
>(
search.getPath())->getNodeFromTail(1);
2362 const SbViewportRegion& vpRegion = getViewportRegion();
2366 action->enableFileWriting();
2367 action->apply(hiddenRoot);
2368 action->disableFileWriting();
2376 QWidget *
w = getWidget();
2382 filename = QFileDialog::getSaveFileName(
w,
"Select output file",
2384 "Encapsulated Postscript files (*.eps)",0,QFileDialog::DontResolveSymlinks);
2402 buffsize += 1024*1024;
2410 GL_RGBA, 0, NULL,0, 0, 0,
2468 int newamb = QInputDialog::getInt(getWidget(),
"Change ambient light",
2469 "New ambient light percentage:",
2525 if (
ds!=getDrawStyle(STILL))
2534 if (
ds!=getDrawStyle(INTERACTIVE))
2548 QString
name = selAct->data().toString();
2558 bool replaced(
false);
2574 QString
name = selAct->data().toString();
2576 SoCamera * camera = getCamera();
2588 " to stored view, but can't get root and camera pointers");
2596 QString
name = selAct->data().toString();
2598 SoCamera * camera = getCamera();
2606 QByteArray ba =
sv.camState();
2613 " to stored view, but can't get root and camera pointers");
2620 QString
name = selAct->data().toString();
2665 int newwidth = QInputDialog::getInt(getWidget(),
"Change movie width",
2666 "New movie width:",
old,1,4000,1,&ok);
2667 if (ok&&
old!=newwidth) {
2678 int newheight = QInputDialog::getInt(getWidget(),
"Change movie height",
2679 "New movie height:",
old,1,4000,1,&ok);
2680 if (ok&&
old!=newheight) {
2691 int newfps = QInputDialog::getInt(getWidget(),
"Change movie FPS",
2692 "New movie frames per second:",
old,1,4000,1,&ok);
2693 if (ok&&
old!=newfps) {
2702 QString newoutdir = QFileDialog::getExistingDirectory ( getWidget(),
"Select movie frame output directory",
old);
2703 if (!newoutdir.isEmpty()&&
old!=newoutdir) {
2799 SoPerspectiveCamera * camera =
dynamic_cast<SoPerspectiveCamera*
>(getCamera());
2800 if (! (camera==NULL) ) {
2801 float current_value = camera->focalDistance.getValue();
2802 int newfocal = QInputDialog::getDouble(getWidget(),
2803 "Change focal length",
2804 "New focal length: ",
2810 if (ok && current_value != newfocal) {
2814 camera->focalDistance.setValue(newfocal);
2966 QList<SoQtViewer::StereoType>
l;
2969 l << SoQtViewer::STEREO_NONE;
2970 l<< SoQtViewer::STEREO_ANAGLYPH;
2975 l << SoQtViewer::STEREO_QUADBUFFER;
2977 l << SoQtViewer::STEREO_INTERLEAVED_ROWS;
2979 l << SoQtViewer::STEREO_INTERLEAVED_COLUMNS;
2988 case SoQtViewer::STEREO_NONE:
return "NO Stereo";
2989 case SoQtViewer::STEREO_ANAGLYPH:
return "Anaglyph Stereo (Red-Cyan 3D mode)";
2990 case SoQtViewer::STEREO_QUADBUFFER:
return "QUADBUFFER";
2991 case SoQtViewer::STEREO_INTERLEAVED_ROWS:
return "INTERLEAVED_ROWS";
2992 case SoQtViewer::STEREO_INTERLEAVED_COLUMNS:
return "INTERLEAVED_COLUMNS";
2994 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::viewerStereoType2PrettyString ERROR: Unknown viewer draw style");
3002 case SoQtViewer::STEREO_NONE:
return 0;
3003 case SoQtViewer::STEREO_ANAGLYPH:
return 1;
3004 case SoQtViewer::STEREO_QUADBUFFER:
return 2;
3005 case SoQtViewer::STEREO_INTERLEAVED_ROWS:
return 3;
3006 case SoQtViewer::STEREO_INTERLEAVED_COLUMNS:
return 4;
3008 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::viewerStereoTypeToInt ERROR: Unknown viewer draw style");
3017 case 0:
return SoQtViewer::STEREO_NONE;
3018 case 1:
return SoQtViewer::STEREO_ANAGLYPH;
3019 case 2:
return SoQtViewer::STEREO_QUADBUFFER;
3020 case 3:
return SoQtViewer::STEREO_INTERLEAVED_ROWS;
3021 case 4:
return SoQtViewer::STEREO_INTERLEAVED_COLUMNS;
3024 return SoQtViewer::STEREO_NONE;
3036 QList<SoQtViewer::DrawStyle>
l;
3037 l << SoQtViewer::VIEW_SAME_AS_STILL
3038 << SoQtViewer::VIEW_AS_IS
3039 << SoQtViewer::VIEW_HIDDEN_LINE
3040 << SoQtViewer::VIEW_NO_TEXTURE
3041 << SoQtViewer::VIEW_LOW_COMPLEXITY
3042 << SoQtViewer::VIEW_LINE
3043 << SoQtViewer::VIEW_POINT
3044 << SoQtViewer::VIEW_BBOX
3045 << SoQtViewer::VIEW_LOW_RES_LINE
3046 << SoQtViewer::VIEW_LOW_RES_POINT
3047 << SoQtViewer::VIEW_WIREFRAME_OVERLAY;
3055 case SoQtViewer::VIEW_AS_IS:
return 0;
3056 case SoQtViewer::VIEW_HIDDEN_LINE:
return 1;
3057 case SoQtViewer::VIEW_NO_TEXTURE:
return 2;
3058 case SoQtViewer::VIEW_LOW_COMPLEXITY:
return 3;
3059 case SoQtViewer::VIEW_LINE:
return 4;
3060 case SoQtViewer::VIEW_POINT:
return 5;
3061 case SoQtViewer::VIEW_BBOX:
return 6;
3062 case SoQtViewer::VIEW_LOW_RES_LINE:
return 7;
3063 case SoQtViewer::VIEW_LOW_RES_POINT:
return 8;
3064 case SoQtViewer::VIEW_SAME_AS_STILL:
return 9;
3065 case SoQtViewer::VIEW_WIREFRAME_OVERLAY:
return 10;
3067 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::viewerDrawStyleToInt ERROR: Unknown viewer draw style");
3076 case 0:
return SoQtViewer::VIEW_AS_IS;
3077 case 1:
return SoQtViewer::VIEW_HIDDEN_LINE;
3078 case 2:
return SoQtViewer::VIEW_NO_TEXTURE;
3079 case 3:
return SoQtViewer::VIEW_LOW_COMPLEXITY;
3080 case 4:
return SoQtViewer::VIEW_LINE;
3081 case 5:
return SoQtViewer::VIEW_POINT;
3082 case 6:
return SoQtViewer::VIEW_BBOX;
3083 case 7:
return SoQtViewer::VIEW_LOW_RES_LINE;
3084 case 8:
return SoQtViewer::VIEW_LOW_RES_POINT;
3085 case 9:
return SoQtViewer::VIEW_SAME_AS_STILL;
3086 case 10:
return SoQtViewer::VIEW_WIREFRAME_OVERLAY;
3089 return SoQtViewer::VIEW_AS_IS;
3097 case SoQtViewer::VIEW_AS_IS:
return "As is";
3098 case SoQtViewer::VIEW_HIDDEN_LINE:
return "Hidden line";
3099 case SoQtViewer::VIEW_NO_TEXTURE:
return "No texture";
3100 case SoQtViewer::VIEW_LOW_COMPLEXITY:
return "Low complexity";
3101 case SoQtViewer::VIEW_LINE:
return "Line";
3102 case SoQtViewer::VIEW_POINT:
return "Point";
3103 case SoQtViewer::VIEW_BBOX:
return "Bounding boxes";
3104 case SoQtViewer::VIEW_LOW_RES_LINE:
return "Low resolution lines";
3105 case SoQtViewer::VIEW_LOW_RES_POINT:
return "Low resolution points";
3106 case SoQtViewer::VIEW_SAME_AS_STILL:
return "Same as still";
3107 case SoQtViewer::VIEW_WIREFRAME_OVERLAY:
return "Wireframe overlay";
3109 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::viewerDrawStyleToInt ERROR: Unknown viewer draw style");
3148 QString lastfile, nextfile;
3152 lastfile, nextfile );
3154 QImage img0(lastfile);
3156 if (lastfile.isEmpty()||img0.isNull()) {
3160 if (nextfile.isEmpty())
3170 for (
int i = 0;
i < nTransitionFrames; ++
i) {
3171 double fadefact((
i+1.0)/(nTransitionFrames+1.0));