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();
743 out << persistifiedViews;
770 QBuffer
buffer(&ba_state);
771 buffer.open(QIODevice::ReadOnly);
772 QDataStream state(&
buffer);
776 if (version<0||version>6) {
777 VP1Msg::messageDebug(
"VP1ExaminerViewer Warning: Input state data is in wrong format - ignoring!");
785 if (bgdcol.isValid())
799 state >> isperspective;
804 if (getCamera()&&ba_cam!=QByteArray())
809 bool isdeco, isheadlight, isviewing, decoremoved;
810 state >> isdeco;
if (isdeco!=isDecoration()) setDecoration(isdeco);
811 state >> isheadlight;
if (isheadlight!=isHeadlight()) setHeadlight(isheadlight);
812 state >> isviewing;
if (isviewing!=isViewing())
setViewing(isviewing);
815 +
str(isdeco)+
", "+
str(isheadlight)+
", "+
str(isviewing)+
", "+
str(decoremoved)+
")");
819 SbBool smoothing;
int numPasses;
837 int idrawstyle_still, idrawstyle_interactive;
838 state >> idrawstyle_still;
839 state >> idrawstyle_interactive;
888 QList<QByteArray> persistifiedViews;
889 state >> persistifiedViews;
890 for(
const QByteArray& ba_pv : persistifiedViews) {
904 if (ba!=QByteArray()) {
923 #if SOQT_MAJOR_VERSION <= 1 && SOQT_MINOR_VERSION <= 4 && SOQT_MICRO_VERSION <= 1
928 SoQtExaminerViewer::setSceneGraph(0);
936 SoQtExaminerViewer::createViewerButtons(
parent,buttonlist);
939 if (buttonlist->getLength()==7) {
949 m_d->
button_interact->setToolTip(
"Pick mode (ESC/M toggles). Use this in order to select objects.");
950 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).");
954 m_d->
button_seek->setToolTip(
"Seek to point (S). Sets cameras rotation centre to the clicked point and zooms towards it.");
955 m_d->
button_togglecamera->setToolTip(
"Toggle (C) camera between perspective (P) and orthographic (O) mode.");
960 VP1Msg::message(
"VP1ExaminerViewer::createViewerButtons ERROR: Did not get list of exactly 7 buttons from base.");
969 QPushButton * button =
new QPushButton(tempparent);
970 if (iconname.isEmpty()) {
971 button->setText(
text);
973 button->setIcon( QIcon(iconname) );
975 button->setToolTip(tooltip);
976 detectorbuttons[button] = std::make_pair(region,
view);
977 button->setFocusPolicy(Qt::NoFocus);
980 QObject::connect(button,SIGNAL(clicked()),signalcatcher,SLOT(catchSignal()));
981 theclass->addAppPushButton(button);
989 animationSequencer.sequence().clearAllFrames();
994 if (popup_tourSpeedVerySlow->isChecked())
996 else if (popup_tourSpeedSlow->isChecked())
998 else if (popup_tourSpeedFast->isChecked())
1000 else if (popup_tourSpeedVeryFast->isChecked())
1004 tourLoopsForever = popup_tourLoopForever->isChecked();
1006 if (popup_tourLoopTwice->isChecked())
1008 else if (popup_tourLoopThrice->isChecked())
1012 tourLoopsForeverSkipFirstFrame =
false;
1013 double firstfact(action_movieenabled->isChecked()?0.0:0.25);
1016 for (
int iloop = 0; iloop < nloops; ++iloop) {
1017 if (popup_tourPartsMuon->isChecked()) {
1019 if (
first||latestRegion!=region)
1020 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), (
first?firstfact:1.0)*steptime);
1021 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(10*
M_PI/6), 0,
cos(10*
M_PI/6)), steptime);
1022 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(2*
M_PI/6), 0,
cos(2*
M_PI/6)), steptime);
1023 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), steptime);
1024 latestRegion=region;
1026 firstRegion = region;
1031 if (popup_tourPartsCalo->isChecked()) {
1033 if (
first||latestRegion!=region)
1034 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), (
first?firstfact:1.0)*steptime);
1035 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(10*
M_PI/6), 0,
cos(10*
M_PI/6)), steptime);
1036 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(2*
M_PI/6), 0,
cos(2*
M_PI/6)), steptime);
1037 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), steptime);
1038 latestRegion=region;
1040 firstRegion = region;
1045 if (popup_tourPartsInDet->isChecked()) {
1047 if (
first||latestRegion!=region)
1048 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), (
first?firstfact:1.0)*steptime);
1049 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(10*
M_PI/6), 0,
cos(10*
M_PI/6)), steptime);
1050 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(2*
M_PI/6), 0,
cos(2*
M_PI/6)), steptime);
1051 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), steptime);
1052 latestRegion=region;
1054 firstRegion = region;
1059 if (popup_tourPartsVertex->isChecked()) {
1061 if (
first||latestRegion!=region)
1062 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), (
first?firstfact:1.0)*steptime);
1063 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(10*
M_PI/6), 0,
cos(10*
M_PI/6)), steptime);
1064 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(2*
M_PI/6), 0,
cos(2*
M_PI/6)), steptime);
1065 animationSequencer.sequence().addFrame(region, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), steptime);
1066 latestRegion=region;
1068 firstRegion = region;
1076 if (tourLoopsForever && nregions==1)
1077 tourLoopsForeverSkipFirstFrame =
true;
1079 if (!tourLoopsForever&&latestRegion!=firstRegion)
1080 animationSequencer.sequence().addFrame(firstRegion, SbVec3f(
sin(6*
M_PI/6), 0,
cos(6*
M_PI/6)), steptime);
1081 if (firstfact>0.0&&!tourLoopsForever)
1082 animationSequencer.sequence().addFrame(theclass->currentCameraState(),firstfact*steptime);
1092 QWidget * tempparent =
new QWidget();
1096 tempparent->setVisible(
false);
1097 if (detectorViewButtons) {
1101 addNewButton(
"IA",
"View inner detector from positive Z axis",INDET,
ASIDE,tempparent);
1102 addNewButton(
"IC",
"View inner detector from negative Z axis",INDET,
CSIDE,tempparent);
1104 addNewButton(
"CA",
"View calorimeters from positive Z axis",
CALO,
ASIDE,tempparent);
1105 addNewButton(
"CC",
"View calorimeters from negative Z axis",
CALO,
CSIDE,tempparent);
1107 addNewButton(
"MA",
"View muon spectrometer from positive Z axis",
MUON,
ASIDE,tempparent);
1108 addNewButton(
"MC",
"View muon spectrometer from negative Z axis",
MUON,
CSIDE,tempparent);
1110 addNewButton(
"FA",
"View forward region from positive Z axis",FORWARDREGION,
ASIDE,tempparent);
1111 addNewButton(
"FC",
"View forward region from negative Z axis",FORWARDREGION,
CSIDE,tempparent);
1113 addNewButton(
"MB",
"View muon spectrometer from barrel",
MUON,
BARREL,tempparent,
":icons/icons/rphi.png");
1118 QPushButton *button =
new QPushButton(tempparent);
1119 button->setText(
"XT");
1120 button->setToolTip(
"Execute a tour of the detector (configure in context menu)");
1121 button->setFocusPolicy(Qt::NoFocus);
1122 takeTourButton=button;
1123 QObject::connect(button,SIGNAL(clicked()), signalcatcher, SLOT(catchSignal()));
1124 theclass->addAppPushButton(button);
1125 QObject::connect(&animationSequencer,SIGNAL(animationFinishedSuccessfully()),signalcatcher,SLOT(catchSignal()));
1128 QWidget * w_spacer =
new QWidget(tempparent);
1129 QSizePolicy sp_spacer(w_spacer->sizePolicy());
1130 unsigned vertStretch = 99999;
1131 sp_spacer.setVerticalStretch(vertStretch);
1132 w_spacer->setSizePolicy(sp_spacer);
1133 theclass->addAppPushButton(w_spacer);
1135 tempparent->deleteLater();
1148 QPushButton* button =
dynamic_cast<QPushButton*
>(sender());
1156 QMenu*
menu =
dynamic_cast<QMenu*
>(sender());
1161 VP1Msg::messageDebug(
"VP1ExaminerViewer_SignalCatcher::catchSignal ERROR: Received unknown signal");
1183 sphere =
new SoSphere;
1195 r = perspective ? 13 : 7;
1199 r = perspective ? 35 : 27;
1209 r = perspective ? 95 : 73;
1212 sphere->radius =
r * 1000.0;
1220 QWidget *
w = theclass->getGLWidget();
1222 w->setFocus(Qt::OtherFocusReason);
1231 if (action_movieenabled->isChecked()) {
1232 int width = action_moviewidth->data().toInt();
1233 int height = action_movieheight->data().toInt();
1234 int fps = action_moviefps->data().toInt();
1235 QString
outdir = action_movieoutdir->data().toString();
1237 animationSequencer.setMovie(
true);
1238 animationSequencer.setMovieParameters(
outdir,movieFrameFileNamePrefix,fps,
width,height);
1240 animationSequencer.setMovie(
false);
1271 if (theclass->isAnimating())
1272 theclass->stopAnimating();
1273 if (updateAnimationSequence()) {
1274 applyMovieSettingsToAnimationSequencer();
1276 animationSequencer.startAnimating();
1290 SoNode * rootnode = theclass->getSceneGraph();
1292 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::detectorZoomButtonClicked WARNING: No scenegraph set. Ignoring.");
1295 if ( ! ( rootnode->getTypeId().isDerivedFrom(SoGroup::getClassTypeId())) ) {
1296 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::detectorZoomButtonClicked WARNING: Root node does not derive from SoGroup. Ignoring.");
1299 if (theclass->currentCamIsPerspective()) {
1301 theclass->toggleCameraType();
1302 theclass->toggleCameraType();
1304 SoCamera * camera = theclass->getCamera();
1306 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::detectorZoomButtonClicked WARNING: Could not get camera. Ignoring.");
1312 SoGroup *
root =
static_cast<SoGroup*
>(rootnode);
1315 SoSphere * regionsphere = getRegionSphere(
p.first,
1316 theclass->currentCamIsPerspective());
1325 theclass->setLeftWheelString(
"Rotz");
1332 theclass->setLeftWheelString(
"Rotz");
1339 theclass->setLeftWheelString(
"Rotx");
1342 SbVec3f lookat(xDir,0,zDir), upvec(0,1,0);
1344 bool notifyenabled =
root->enableNotify(
false);
1346 root->insertChild(regionsphere,0);
1348 if (theclass->isAnimating())
1349 theclass->stopAnimating();
1350 camera->unrefNoDelete();
1356 root->removeChild(regionsphere);
1357 if (notifyenabled) {
1358 root->enableNotify(
true);
1362 rootnode->unrefNoDelete();
1385 int id = prefmenu->getMenuItem(
"decoration");
1387 prefmenu->removeMenuItem(
id);
1397 if (
evt->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) {
1408 if (SO_KEY_PRESS_EVENT(
evt,SoKeyboardEvent::V)) {
1412 if (SO_KEY_PRESS_EVENT(
evt,SoKeyboardEvent::Q))
1423 if (SO_KEY_PRESS_EVENT(
evt,SoKeyboardEvent::O)) {
1428 if (SO_KEY_PRESS_EVENT(
evt,SoKeyboardEvent::M)) {
1441 }
else if (
evt->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
1444 const SoMouseButtonEvent * ev_mouse =
static_cast<const SoMouseButtonEvent*
>(
evt);
1445 if ((ev_mouse->getButton() == SoMouseButtonEvent::BUTTON2)) {
1446 if (ev_mouse->getState() == SoButtonEvent::DOWN) {
1454 return SoQtExaminerViewer::processSoEvent(
evt);
1468 SoQtExaminerViewer::viewAll();
1477 SoQtExaminerViewer::toggleCameraType();
1485 if (rightWheelLabel)
1486 rightWheelLabel->setUpdatesEnabled(
false);
1487 SoQtExaminerViewer::setCameraType(
type);
1488 setRightWheelString(
"Zoom");
1489 if (rightWheelLabel) {
1490 rightWheelLabel->setVisible(
true);
1491 rightWheelLabel->setUpdatesEnabled(
true);
1507 SoQtExaminerViewer::setSeekMode(enable);
1515 SoQtExaminerViewer::setViewing(enable);
1523 SoQtExaminerViewer::bottomWheelFinish();
1531 SoQtExaminerViewer::bottomWheelMotion(
val);
1539 SoQtExaminerViewer::bottomWheelStart();
1546 SoQtExaminerViewer::leftWheelFinish();
1563 SoQtFullViewer::leftWheelMotion(newval);
1570 SoQtExaminerViewer::leftWheelStart();
1577 SoQtExaminerViewer::rightWheelFinish();
1584 SoQtExaminerViewer::rightWheelMotion(
val);
1591 SoQtExaminerViewer::rightWheelStart();
1597 SoCamera * cam = theclass->getCamera();
1602 rotateCamera(cam, SbVec3f(0, 0, -1),
value - oldvalue);
1603 cam->unrefNoDelete();
1610 SoCamera * cam = theclass->getCamera();
1615 rotateCamera(cam, SbVec3f(-1, 0, 0),
value - oldvalue);
1616 cam->unrefNoDelete();
1622 const SbVec3f & aroundaxis,
1625 const SbVec3f DEFAULTDIRECTION(0, 0, -1);
1626 const SbRotation currentorientation = cam->orientation.getValue();
1629 currentorientation.multVec(DEFAULTDIRECTION,
currentdir);
1631 const SbVec3f focalpoint = cam->position.getValue() +
1635 cam->orientation = SbRotation(aroundaxis, delta) * currentorientation;
1638 cam->orientation.getValue().multVec(DEFAULTDIRECTION, newdir);
1639 cam->position = focalpoint - cam->focalDistance.getValue() * newdir;
1645 SoQtExaminerViewer::setBufferingType(bt);
1653 SoQtExaminerViewer::setAntialiasing(smoothing, numPasses);
1669 bool printWarning =
false;
1671 #ifndef BUILDVP1LIGHT
1672 env_aa =
std::getenv(
"VP1_ADVANCED_ANTIALIASING");
1675 if(antialiasingIsOn){
1681 if (env_aa != NULL) {
1682 std::string env_aa_string( env_aa );
1683 if(env_aa_string ==
"1") {
1686 if ( !
std::getenv(
"VP1_ADVANCED_ANTIALIASING_PRINTMSG")) {
1687 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.");
1689 ::setenv(
"VP1_ADVANCED_ANTIALIASING_PRINTMSG",
"1", 1);
1695 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.");
1698 if (getGLRenderAction()->isSmoothing() != smoothing)
1699 getGLRenderAction()->setSmoothing(smoothing);
1702 #if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 5)
1703 if (getSampleBuffers() != buffers)
1704 setSampleBuffers(buffers);
1707 VP1Msg::message(
"Multisampling is not supported by SoQT < 1.5, this anti-aliasing mode is disabled");
1712 getGLRenderAction()->setSmoothing(smoothing);
1713 setSampleBuffers(0);
1717 printWarning =
true;
1721 printWarning =
true;
1725 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'.");
1734 SoQtExaminerViewer::setTransparencyType(
t);
1740 SoQtExaminerViewer::setDrawStyle(
t,
s);
1757 std::cout <<
"antiAliasing set." << std::endl;
1778 return getCameraType() == SoPerspectiveCamera::getClassTypeId();
1784 SoCamera * cam(getCamera());
1790 int width,
int height,
bool transp )
1792 SoCamera * cam = getCamera();
1795 bool notifyenabled = cam->enableNotify(
false);
1799 if (currentPersp!=camStateIsPerspective)
1803 if (currentPersp!=camStateIsPerspective)
1807 if (notifyenabled) {
1808 cam->enableNotify(
true);
1833 int width = action_moviewidth->data().toInt();
1834 int height = action_movieheight->data().toInt();
1835 int fps = action_moviefps->data().toInt();
1836 QString
outdir = action_movieoutdir->data().toString();
1838 action_movieheight->setText(
"Change output &height [current: "+
QString::number(height)+
"]");
1839 action_moviefps->setText(
"Change output &FPS [current: "+
QString::number(fps)+
"]");
1840 action_movieoutdir->setText(
"Change output &dir [current: "+
outdir+
"]");
1842 bool c(action_movieenabled->isChecked());
1843 action_moviewidth->setEnabled(
c);
1844 action_movieheight->setEnabled(
c);
1845 action_moviefps->setEnabled(
c);
1846 action_movieoutdir->setEnabled(
c);
1855 QWidget *
w = theclass->getWidget();
1858 popup_menu =
new QMenu (
w);
1860 popup_bgdColAction = popup_menu->addAction(
"&Background Colour");
1861 popup_antiAliasAction = popup_menu->addAction(
"&Anti aliasing [A]");
1862 popup_resetCameraAction = popup_menu->addAction(
"&Reset camera");
1864 if (detectorViewButtons) {
1866 QMenu * tourmenu = popup_menu->addMenu(
"&Tour");
1867 popup_tourStartEachEvent = tourmenu->addAction(
"Start tour on new event");
1868 popup_tourStartEachEvent->setCheckable(
true);
1869 popup_tourReturnToStartAction = tourmenu->addAction(
"Tour ends at &original view");
1870 popup_tourReturnToStartAction->setCheckable(
true);
1871 popup_tourReturnToStartAction->setVisible(
false);
1872 QMenu * tourspeedmenu = tourmenu->addMenu(
"&Speed");
1873 QMenu * tourpartsmenu = tourmenu->addMenu(
"&Parts");
1874 QMenu * tourloopmenu = tourmenu->addMenu(
"&Looping");
1875 popup_tourExecute = tourmenu->addAction(
"E&xecute");
1878 popup_tourSpeedVerySlow = tourspeedmenu->addAction(
"Very s&low");
1879 popup_tourSpeedSlow = tourspeedmenu->addAction(
"&Slow");
1880 popup_tourSpeedMedium = tourspeedmenu->addAction(
"&Medium");
1881 popup_tourSpeedFast = tourspeedmenu->addAction(
"&Fast");
1882 popup_tourSpeedVeryFast = tourspeedmenu->addAction(
"Very f&ast");
1883 popup_tourSpeedVerySlow->setCheckable(
true);
1884 popup_tourSpeedSlow->setCheckable(
true);
1885 popup_tourSpeedMedium->setCheckable(
true);
1886 popup_tourSpeedFast->setCheckable(
true);
1887 popup_tourSpeedVeryFast->setCheckable(
true);
1888 QActionGroup * tour_speed_group =
new QActionGroup(tourspeedmenu);
1889 tour_speed_group->addAction(popup_tourSpeedVerySlow);
1890 tour_speed_group->addAction(popup_tourSpeedSlow);
1891 tour_speed_group->addAction(popup_tourSpeedMedium);
1892 tour_speed_group->addAction(popup_tourSpeedFast);
1893 tour_speed_group->addAction(popup_tourSpeedVeryFast);
1894 popup_tourSpeedMedium->setChecked(
true);
1897 popup_tourPartsVertex = tourpartsmenu->addAction(
"&Vertex region");
1898 popup_tourPartsInDet = tourpartsmenu->addAction(
"&Inner Detector");
1899 popup_tourPartsCalo = tourpartsmenu->addAction(
"&Calorimeters");
1900 popup_tourPartsMuon = tourpartsmenu->addAction(
"&Muon systems");
1901 popup_tourPartsVertex->setCheckable(
true);
1902 popup_tourPartsInDet->setCheckable(
true);
1903 popup_tourPartsCalo->setCheckable(
true);
1904 popup_tourPartsMuon->setCheckable(
true);
1905 popup_tourPartsInDet->setChecked(
true);
1906 popup_tourPartsMuon->setChecked(
true);
1909 popup_tourLoopOnce = tourloopmenu->addAction(
"&Once");
1910 popup_tourLoopTwice = tourloopmenu->addAction(
"&Twice");
1911 popup_tourLoopThrice = tourloopmenu->addAction(
"T&hrice");
1912 popup_tourLoopForever = tourloopmenu->addAction(
"&Indefinitely");
1913 popup_tourLoopOnce->setCheckable(
true);
1914 popup_tourLoopTwice->setCheckable(
true);
1915 popup_tourLoopThrice->setCheckable(
true);
1916 popup_tourLoopForever->setCheckable(
true);
1917 QActionGroup * tour_loop_group =
new QActionGroup(tourloopmenu);
1918 tour_loop_group->addAction(popup_tourLoopOnce);
1919 tour_loop_group->addAction(popup_tourLoopTwice);
1920 tour_loop_group->addAction(popup_tourLoopThrice);
1921 tour_loop_group->addAction(popup_tourLoopForever);
1922 popup_tourLoopOnce->setChecked(
true);
1926 QMenu * advancedmenu = popup_menu->addMenu(
"&More");
1928 popup_hidedecorationsaction = advancedmenu->addAction(
"Hide &controls");
1929 popup_headLightAction = advancedmenu->addAction(
"&Headlight");
1930 popup_ambientLightAction = advancedmenu->addAction(
"dummy");
1931 popup_dumpSceneAction = advancedmenu->addAction(
"Dump &scene to file");
1932 popup_dumpSceneVRMLAction = advancedmenu->addAction(
"Dump &scene to VRML file");
1933 popup_toSVGAction = advancedmenu->addAction(
"Produce SV&G image");
1934 popup_toEPSAction = advancedmenu->addAction(
"Produce &EPS image");
1936 if (detectorViewButtons) {
1938 QMenu * viewsmenu = advancedmenu->addMenu(
"Stored &views");
1939 viewmenu_zoomtoview = viewsmenu->addMenu(
"Animated &zoom to view");
1940 viewmenu_restoreview = viewsmenu->addMenu(
"&Restore view");
1941 viewmenu_storecurrentview = viewsmenu->addMenu(
"Store ¤t view");
1942 viewmenu_deleteview = viewsmenu->addMenu(
"&Delete view");
1943 QObject::connect(viewmenu_storecurrentview,SIGNAL(aboutToShow()),signalcatcher,SLOT(catchSignal()));
1944 QObject::connect(viewmenu_deleteview,SIGNAL(aboutToShow()),signalcatcher,SLOT(catchSignal()));
1945 QObject::connect(viewmenu_restoreview,SIGNAL(aboutToShow()),signalcatcher,SLOT(catchSignal()));
1946 QObject::connect(viewmenu_zoomtoview,SIGNAL(aboutToShow()),signalcatcher,SLOT(catchSignal()));
1947 storedViewsChanged();
1950 if (detectorViewButtons) {
1952 QMenu * customtourmenu = advancedmenu->addMenu(
"Custom &tour");
1953 customtour_launcheditor = customtourmenu->addAction(
"Launch &editor");
1954 customtour_execute = customtourmenu->addAction(
"E&xecute");
1955 customtour_execute->setEnabled(
false);
1958 QMenu * moviesmenu = advancedmenu->addMenu(
"&Movie settings");
1959 action_movieenabled = moviesmenu->addAction(
"&Enable movie output when executing tours (one image file per frame)");
1960 action_movieenabled->setCheckable(
true);
1961 action_movieenabled->setChecked(
false);
1962 action_moviewidth = moviesmenu->addAction(
"dummy");
1963 action_moviewidth->setData(1024);
1964 action_movieheight = moviesmenu->addAction(
"dummy");
1965 action_movieheight->setData(768);
1966 action_moviefps = moviesmenu->addAction(
"dummy");
1967 action_moviefps->setData(24);
1968 action_movieoutdir = moviesmenu->addAction(
"dummy");
1970 action_movieoutdir->setData(username.isEmpty() ?
"/tmp/vp1frames" :
"/tmp/"+username+
"/vp1frames");
1971 action_moviefadetocurrentview = moviesmenu->addAction(
"Fade last frame to current view (1s)");
1972 updateMovieMenuVisuals();
1976 updateAmbientLightText();
1977 popup_headLightAction->setCheckable(
true);
1978 popup_antiAliasAction->setCheckable(
true);
1979 popup_hidedecorationsaction->setCheckable(
true);
1983 QMenu * drawstylemenu = advancedmenu->addMenu(
"&Draw styles");
1985 QMenu * drawstyle_still_menu = drawstylemenu->addMenu(
"&Still draw style");
1986 QMenu * drawstyle_interactive_menu = drawstylemenu->addMenu(
"&Interactive draw style");
1987 QMenu * drawstyle_transptype_menu = drawstylemenu->addMenu(
"&Transparency Type");
1990 QActionGroup * ds_still_group =
new QActionGroup(drawstyle_still_menu);
1991 QActionGroup * ds_interactive_group =
new QActionGroup(drawstyle_interactive_menu);
1992 for(SoQtViewer::DrawStyle
ds : getAllViewerDrawStyles()) {
1993 int ids = viewerDrawStyleToInt(
ds);
1994 QString
pretty = viewerDrawStyle2PrettyString(
ds);
1995 if (
ds!=SoQtViewer::VIEW_SAME_AS_STILL) {
1997 QAction * act = drawstyle_still_menu->addAction(
pretty);
1999 popup_drawstyle_still_actions << act;
2000 ds_still_group->addAction(act);
2001 act->setCheckable(
true);
2003 if (
ds!=SoQtViewer::VIEW_AS_IS) {
2005 QAction * act = drawstyle_interactive_menu->addAction(
pretty);
2007 popup_drawstyle_interactive_actions << act;
2008 ds_interactive_group->addAction(act);
2009 act->setCheckable(
true);
2014 QActionGroup * transptype_group =
new QActionGroup(drawstyle_transptype_menu);
2018 popup_transptype_actions << act;
2019 transptype_group->addAction(act);
2020 act->setCheckable(
true);
2025 QMenu * stereoviewmenu_main = advancedmenu->addMenu(
"&Stereographic view");
2026 stereo_launcheditor = stereoviewmenu_main->addAction(
"Launch &editor");
2029 popup_focal_value_action = advancedmenu->addAction(
"dummy");
2030 SoCamera *camera = theclass->getCamera();
2031 float default_focal_camera = camera->focalDistance.getValue();
2032 popup_focal_value_action->setData(default_focal_camera);
2033 popup_focal_value_action->setText(
"Change camera FOCAL LENGTH [current: "+
QString::number(default_focal_camera)+
"]");
2152 if (viewmenu_storecurrentview==
menu) {
2153 viewmenu_storecurrentview->clear();
2154 storeViewActions.clear();
2155 QString
fs = firstAvailableStoredViewName();
2156 QAction * act = viewmenu_storecurrentview->addAction(
"Store as "+
fs);
2158 storeViewActions << act;
2159 if (!storedViews.isEmpty()) {
2160 viewmenu_storecurrentview->addSeparator();
2162 act = viewmenu_storecurrentview->addAction(
"Overwrite "+
sv.name());
2163 act->setIcon(
sv.icon());
2164 if (!fitsCurrentCamType(
sv)) {
2165 act->setEnabled(
false);
2167 act->setData(
sv.name());
2168 storeViewActions << act;
2175 if (viewmenu_zoomtoview==
menu) {
2176 viewmenu_zoomtoview->clear();
2177 zoomToViewActions.clear();
2179 QAction * act = viewmenu_zoomtoview->addAction(
sv.name());
2180 act->setIcon(
sv.icon());
2181 if (!fitsCurrentCamType(
sv)) {
2182 act->setEnabled(
false);
2184 act->setData(
sv.name());
2185 zoomToViewActions << act;
2190 if (viewmenu_restoreview==
menu) {
2191 viewmenu_restoreview->clear();
2192 restoreViewActions.clear();
2194 QAction * act = viewmenu_restoreview->addAction(
sv.name());
2195 act->setIcon(
sv.icon());
2196 act->setData(
sv.name());
2197 restoreViewActions << act;
2201 if (viewmenu_deleteview==
menu) {
2202 viewmenu_deleteview->clear();
2203 deleteViewActions.clear();
2205 QAction * act = viewmenu_deleteview->addAction(
sv.name());
2206 act->setIcon(
sv.icon());
2207 act->setData(
sv.name());
2208 deleteViewActions << act;
2220 if (!popup_headLightAction)
2222 popup_headLightAction->setChecked(theclass->isHeadlight());
2223 popup_antiAliasAction->setChecked(theclass->isAntiAlias());
2224 popup_hidedecorationsaction->setChecked(! theclass->isDecoration());
2226 int idrawstyle_still = viewerDrawStyleToInt(theclass->getDrawStyle(SoQtViewer::STILL));
2227 for (QAction * act : popup_drawstyle_still_actions) {
2228 if (act->data().toInt() == idrawstyle_still) {
2229 act->setChecked(
true);
2234 int idrawstyle_interactive = viewerDrawStyleToInt(theclass->getDrawStyle(SoQtViewer::INTERACTIVE));
2235 for (QAction * act : popup_drawstyle_interactive_actions) {
2236 if (act->data().toInt() == idrawstyle_interactive) {
2237 act->setChecked(
true);
2243 for (QAction * act : popup_transptype_actions) {
2244 if (act->data().toInt() == itransptype) {
2245 act->setChecked(
true);
2250 popup_resetCameraAction->setVisible(resetCamera_state!=QByteArray());
2263 QWidget *
w = getWidget();
2270 filename = QFileDialog::getSaveFileName(
w,
"Select output file",
2272 "Inventor files (*.iv)",0,QFileDialog::DontResolveSymlinks);
2280 SoGroup * standardisedRoot(0);
2281 if ( rootnode->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
2298 QWidget *
w = getWidget();
2305 filename = QFileDialog::getSaveFileName(
w,
"Select output file",
2307 "VRML2.0/X3D files (*.wrl)",0,QFileDialog::DontResolveSymlinks);
2315 SoGroup * standardisedRoot(0);
2316 if ( rootnode->getTypeId().isDerivedFrom(SoGroup::getClassTypeId()))
2329 QWidget *
w = getWidget();
2335 filename = QFileDialog::getSaveFileName(
w,
"Select output file",
2337 "Scalable Vector Graphics files (*.svg)",0,QFileDialog::DontResolveSymlinks);
2352 SoNode *rootA =
static_cast<SoNode*
>(SoQtRenderArea::getSceneGraph());
2353 if (!rootA )
return;
2354 SoNode *cam =
static_cast<SoNode*
>(this->getCamera());
2355 if ( ! cam )
return;
2359 assert(
search.getPath());
2360 SoNode* hiddenRoot =
2361 static_cast<SoFullPath *
>(
search.getPath())->getNodeFromTail(1);
2363 const SbViewportRegion& vpRegion = getViewportRegion();
2367 action->enableFileWriting();
2368 action->apply(hiddenRoot);
2369 action->disableFileWriting();
2377 QWidget *
w = getWidget();
2383 filename = QFileDialog::getSaveFileName(
w,
"Select output file",
2385 "Encapsulated Postscript files (*.eps)",0,QFileDialog::DontResolveSymlinks);
2403 buffsize += 1024*1024;
2411 GL_RGBA, 0, NULL,0, 0, 0,
2469 int newamb = QInputDialog::getInt(getWidget(),
"Change ambient light",
2470 "New ambient light percentage:",
2526 if (
ds!=getDrawStyle(STILL))
2535 if (
ds!=getDrawStyle(INTERACTIVE))
2549 QString
name = selAct->data().toString();
2559 bool replaced(
false);
2575 QString
name = selAct->data().toString();
2577 SoCamera * camera = getCamera();
2589 " to stored view, but can't get root and camera pointers");
2597 QString
name = selAct->data().toString();
2599 SoCamera * camera = getCamera();
2607 QByteArray ba =
sv.camState();
2614 " to stored view, but can't get root and camera pointers");
2621 QString
name = selAct->data().toString();
2666 int newwidth = QInputDialog::getInt(getWidget(),
"Change movie width",
2667 "New movie width:",
old,1,4000,1,&ok);
2668 if (ok&&
old!=newwidth) {
2679 int newheight = QInputDialog::getInt(getWidget(),
"Change movie height",
2680 "New movie height:",
old,1,4000,1,&ok);
2681 if (ok&&
old!=newheight) {
2692 int newfps = QInputDialog::getInt(getWidget(),
"Change movie FPS",
2693 "New movie frames per second:",
old,1,4000,1,&ok);
2694 if (ok&&
old!=newfps) {
2703 QString newoutdir = QFileDialog::getExistingDirectory ( getWidget(),
"Select movie frame output directory",
old);
2704 if (!newoutdir.isEmpty()&&
old!=newoutdir) {
2800 SoPerspectiveCamera * camera =
dynamic_cast<SoPerspectiveCamera*
>(getCamera());
2801 if (! (camera==NULL) ) {
2802 float current_value = camera->focalDistance.getValue();
2803 int newfocal = QInputDialog::getDouble(getWidget(),
2804 "Change focal length",
2805 "New focal length: ",
2811 if (ok && current_value != newfocal) {
2815 camera->focalDistance.setValue(newfocal);
2967 QList<SoQtViewer::StereoType>
l;
2970 l << SoQtViewer::STEREO_NONE;
2971 l<< SoQtViewer::STEREO_ANAGLYPH;
2976 l << SoQtViewer::STEREO_QUADBUFFER;
2978 l << SoQtViewer::STEREO_INTERLEAVED_ROWS;
2980 l << SoQtViewer::STEREO_INTERLEAVED_COLUMNS;
2989 case SoQtViewer::STEREO_NONE:
return "NO Stereo";
2990 case SoQtViewer::STEREO_ANAGLYPH:
return "Anaglyph Stereo (Red-Cyan 3D mode)";
2991 case SoQtViewer::STEREO_QUADBUFFER:
return "QUADBUFFER";
2992 case SoQtViewer::STEREO_INTERLEAVED_ROWS:
return "INTERLEAVED_ROWS";
2993 case SoQtViewer::STEREO_INTERLEAVED_COLUMNS:
return "INTERLEAVED_COLUMNS";
2995 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::viewerStereoType2PrettyString ERROR: Unknown viewer draw style");
3003 case SoQtViewer::STEREO_NONE:
return 0;
3004 case SoQtViewer::STEREO_ANAGLYPH:
return 1;
3005 case SoQtViewer::STEREO_QUADBUFFER:
return 2;
3006 case SoQtViewer::STEREO_INTERLEAVED_ROWS:
return 3;
3007 case SoQtViewer::STEREO_INTERLEAVED_COLUMNS:
return 4;
3009 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::viewerStereoTypeToInt ERROR: Unknown viewer draw style");
3018 case 0:
return SoQtViewer::STEREO_NONE;
3019 case 1:
return SoQtViewer::STEREO_ANAGLYPH;
3020 case 2:
return SoQtViewer::STEREO_QUADBUFFER;
3021 case 3:
return SoQtViewer::STEREO_INTERLEAVED_ROWS;
3022 case 4:
return SoQtViewer::STEREO_INTERLEAVED_COLUMNS;
3025 return SoQtViewer::STEREO_NONE;
3037 QList<SoQtViewer::DrawStyle>
l;
3038 l << SoQtViewer::VIEW_SAME_AS_STILL
3039 << SoQtViewer::VIEW_AS_IS
3040 << SoQtViewer::VIEW_HIDDEN_LINE
3041 << SoQtViewer::VIEW_NO_TEXTURE
3042 << SoQtViewer::VIEW_LOW_COMPLEXITY
3043 << SoQtViewer::VIEW_LINE
3044 << SoQtViewer::VIEW_POINT
3045 << SoQtViewer::VIEW_BBOX
3046 << SoQtViewer::VIEW_LOW_RES_LINE
3047 << SoQtViewer::VIEW_LOW_RES_POINT
3048 << SoQtViewer::VIEW_WIREFRAME_OVERLAY;
3056 case SoQtViewer::VIEW_AS_IS:
return 0;
3057 case SoQtViewer::VIEW_HIDDEN_LINE:
return 1;
3058 case SoQtViewer::VIEW_NO_TEXTURE:
return 2;
3059 case SoQtViewer::VIEW_LOW_COMPLEXITY:
return 3;
3060 case SoQtViewer::VIEW_LINE:
return 4;
3061 case SoQtViewer::VIEW_POINT:
return 5;
3062 case SoQtViewer::VIEW_BBOX:
return 6;
3063 case SoQtViewer::VIEW_LOW_RES_LINE:
return 7;
3064 case SoQtViewer::VIEW_LOW_RES_POINT:
return 8;
3065 case SoQtViewer::VIEW_SAME_AS_STILL:
return 9;
3066 case SoQtViewer::VIEW_WIREFRAME_OVERLAY:
return 10;
3068 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::viewerDrawStyleToInt ERROR: Unknown viewer draw style");
3077 case 0:
return SoQtViewer::VIEW_AS_IS;
3078 case 1:
return SoQtViewer::VIEW_HIDDEN_LINE;
3079 case 2:
return SoQtViewer::VIEW_NO_TEXTURE;
3080 case 3:
return SoQtViewer::VIEW_LOW_COMPLEXITY;
3081 case 4:
return SoQtViewer::VIEW_LINE;
3082 case 5:
return SoQtViewer::VIEW_POINT;
3083 case 6:
return SoQtViewer::VIEW_BBOX;
3084 case 7:
return SoQtViewer::VIEW_LOW_RES_LINE;
3085 case 8:
return SoQtViewer::VIEW_LOW_RES_POINT;
3086 case 9:
return SoQtViewer::VIEW_SAME_AS_STILL;
3087 case 10:
return SoQtViewer::VIEW_WIREFRAME_OVERLAY;
3090 return SoQtViewer::VIEW_AS_IS;
3098 case SoQtViewer::VIEW_AS_IS:
return "As is";
3099 case SoQtViewer::VIEW_HIDDEN_LINE:
return "Hidden line";
3100 case SoQtViewer::VIEW_NO_TEXTURE:
return "No texture";
3101 case SoQtViewer::VIEW_LOW_COMPLEXITY:
return "Low complexity";
3102 case SoQtViewer::VIEW_LINE:
return "Line";
3103 case SoQtViewer::VIEW_POINT:
return "Point";
3104 case SoQtViewer::VIEW_BBOX:
return "Bounding boxes";
3105 case SoQtViewer::VIEW_LOW_RES_LINE:
return "Low resolution lines";
3106 case SoQtViewer::VIEW_LOW_RES_POINT:
return "Low resolution points";
3107 case SoQtViewer::VIEW_SAME_AS_STILL:
return "Same as still";
3108 case SoQtViewer::VIEW_WIREFRAME_OVERLAY:
return "Wireframe overlay";
3110 VP1Msg::messageDebug(
"VP1ExaminerViewer::Imp::viewerDrawStyleToInt ERROR: Unknown viewer draw style");
3149 QString lastfile, nextfile;
3153 lastfile, nextfile );
3155 QImage img0(lastfile);
3157 if (lastfile.isEmpty()||img0.isNull()) {
3161 if (nextfile.isEmpty())
3171 for (
int i = 0;
i < nTransitionFrames; ++
i) {
3172 double fadefact((
i+1.0)/(nTransitionFrames+1.0));