diff --git a/src/Gui/SplitView3DInventor.cpp b/src/Gui/SplitView3DInventor.cpp index cdd8d68054..d588274803 100644 --- a/src/Gui/SplitView3DInventor.cpp +++ b/src/Gui/SplitView3DInventor.cpp @@ -40,6 +40,7 @@ #include "SoFCSelectionAction.h" #include "View3DInventorViewer.h" #include "View3DPy.h" +#include "View3DSettings.h" using namespace Gui; @@ -56,7 +57,6 @@ AbstractSplitView::AbstractSplitView(Gui::Document* pcDocument, QWidget* parent, AbstractSplitView::~AbstractSplitView() { - hGrp->Detach(this); for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) { delete *it; } @@ -99,37 +99,17 @@ bool AbstractSplitView::containsViewProvider(const ViewProvider* vp) const void AbstractSplitView::setupSettings() { - // attach Parameter Observer - hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); - hGrp->Attach(this); - - // apply the user settings - OnChange(*hGrp,"EyeDistance"); - OnChange(*hGrp,"CornerCoordSystem"); - OnChange(*hGrp,"CornerCoordSystemSize"); - OnChange(*hGrp,"UseAutoRotation"); - OnChange(*hGrp,"Gradient"); - OnChange(*hGrp,"RadialGradient"); - OnChange(*hGrp,"BackgroundColor"); - OnChange(*hGrp,"BackgroundColor2"); - OnChange(*hGrp,"BackgroundColor3"); - OnChange(*hGrp,"BackgroundColor4"); - OnChange(*hGrp,"UseBackgroundColorMid"); - OnChange(*hGrp,"ShowFPS"); - OnChange(*hGrp,"UseVBO"); - OnChange(*hGrp,"Orthographic"); - OnChange(*hGrp,"HeadlightColor"); - OnChange(*hGrp,"HeadlightDirection"); - OnChange(*hGrp,"HeadlightIntensity"); - OnChange(*hGrp,"EnableBacklight"); - OnChange(*hGrp,"BacklightColor"); - OnChange(*hGrp,"BacklightDirection"); - OnChange(*hGrp,"BacklightIntensity"); - OnChange(*hGrp,"NavigationStyle"); - OnChange(*hGrp,"OrbitStyle"); - OnChange(*hGrp,"Sensitivity"); - OnChange(*hGrp,"ResetCursorPosition"); - OnChange(*hGrp,"PickRadius"); + viewSettings = std::make_unique(App::GetApplication().GetParameterGroupByPath + ("User parameter:BaseApp/Preferences/View"), _viewer); + // tmp. disabled will be activated after redesign of 3d viewer + // check whether the simple or the Full Mouse model is used + viewSettings->ignoreNavigationStyle = true; + // Disable VBO for split screen as this leads to random crashes + viewSettings->ignoreVBO = true; + viewSettings->ignoreTransparent = true; + viewSettings->ignoreRenderCache = true; + viewSettings->ignoreDimensions = true; + viewSettings->applySettings(); } View3DInventorViewer* AbstractSplitView::getViewer(unsigned int n) const @@ -137,184 +117,6 @@ View3DInventorViewer* AbstractSplitView::getViewer(unsigned int n) const return (_viewer.size() > n ? _viewer[n] : nullptr); } -/// Observer message from the ParameterGrp -void AbstractSplitView::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason) -{ - const ParameterGrp& rGrp = static_cast(rCaller); - if (strcmp(Reason,"HeadlightColor") == 0) { - unsigned long headlight = rGrp.GetUnsigned("HeadlightColor",ULONG_MAX); // default color (white) - float transparency; - SbColor headlightColor; - headlightColor.setPackedValue((uint32_t)headlight, transparency); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->getHeadlight()->color.setValue(headlightColor); - } - else if (strcmp(Reason,"HeadlightDirection") == 0) { - try { - std::string pos = rGrp.GetASCII("HeadlightDirection"); - Base::Vector3f dir = Base::to_vector(pos); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->getHeadlight()->direction.setValue(dir.x, dir.y, dir.z); - } - catch (const std::exception&) { - // ignore exception - } - } - else if (strcmp(Reason,"HeadlightIntensity") == 0) { - long value = rGrp.GetInt("HeadlightIntensity", 100); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->getHeadlight()->intensity.setValue((float)value/100.0f); - } - else if (strcmp(Reason,"EnableBacklight") == 0) { - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->setBacklight(rGrp.GetBool("EnableBacklight", false)); - } - else if (strcmp(Reason,"BacklightColor") == 0) { - unsigned long backlight = rGrp.GetUnsigned("BacklightColor",ULONG_MAX); // default color (white) - float transparency; - SbColor backlightColor; - backlightColor.setPackedValue((uint32_t)backlight, transparency); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->getBacklight()->color.setValue(backlightColor); - } - else if (strcmp(Reason,"BacklightDirection") == 0) { - try { - std::string pos = rGrp.GetASCII("BacklightDirection"); - Base::Vector3f dir = Base::to_vector(pos); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->getBacklight()->direction.setValue(dir.x, dir.y, dir.z); - } - catch (const std::exception&) { - // ignore exception - } - } - else if (strcmp(Reason,"BacklightIntensity") == 0) { - long value = rGrp.GetInt("BacklightIntensity", 100); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->getBacklight()->intensity.setValue((float)value/100.0f); - } - else if (strcmp(Reason,"EnablePreselection") == 0) { - SoFCEnableHighlightAction cAct(rGrp.GetBool("EnablePreselection", true)); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - cAct.apply((*it)->getSceneGraph()); - } - else if (strcmp(Reason,"EnableSelection") == 0) { - SoFCEnableSelectionAction cAct(rGrp.GetBool("EnableSelection", true)); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - cAct.apply((*it)->getSceneGraph()); - } - else if (strcmp(Reason,"HighlightColor") == 0) { - float transparency; - SbColor highlightColor(0.8f, 0.1f, 0.1f); - auto highlight = (unsigned long)(highlightColor.getPackedValue()); - highlight = rGrp.GetUnsigned("HighlightColor", highlight); - highlightColor.setPackedValue((uint32_t)highlight, transparency); - SoSFColor col; col.setValue(highlightColor); - SoFCHighlightColorAction cAct(col); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - cAct.apply((*it)->getSceneGraph()); - } - else if (strcmp(Reason,"SelectionColor") == 0) { - float transparency; - SbColor selectionColor(0.1f, 0.8f, 0.1f); - auto selection = (unsigned long)(selectionColor.getPackedValue()); - selection = rGrp.GetUnsigned("SelectionColor", selection); - selectionColor.setPackedValue((uint32_t)selection, transparency); - SoSFColor col; col.setValue(selectionColor); - SoFCSelectionColorAction cAct(col); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - cAct.apply((*it)->getSceneGraph()); - } - else if (strcmp(Reason,"NavigationStyle") == 0) { - // tmp. disabled will be activated after redesign of 3d viewer - // check whether the simple or the Full Mouse model is used - //std::string model = rGrp.GetASCII("NavigationStyle",CADNavigationStyle::getClassTypeId().getName()); - //Base::Type type = Base::Type::fromName(model.c_str()); - //for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - // (*it)->setNavigationType(type); - } - else if (strcmp(Reason,"OrbitStyle") == 0) { - int style = rGrp.GetInt("OrbitStyle",1); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->navigationStyle()->setOrbitStyle(NavigationStyle::OrbitStyle(style)); - } - else if (strcmp(Reason,"Sensitivity") == 0) { - float val = rGrp.GetFloat("Sensitivity",2.0f); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->navigationStyle()->setSensitivity(val); - } - else if (strcmp(Reason,"ResetCursorPosition") == 0) { - bool on = rGrp.GetBool("ResetCursorPosition",false); - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->navigationStyle()->setResetCursorPosition(on); - } - else if (strcmp(Reason,"EyeDistance") == 0) { - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->getSoRenderManager()->setStereoOffset(rGrp.GetFloat("EyeDistance",5.0)); - } - else if (strcmp(Reason,"CornerCoordSystem") == 0) { - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->setFeedbackVisibility(rGrp.GetBool("CornerCoordSystem",true)); - } - else if (strcmp(Reason,"CornerCoordSystemSize") == 0) { - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->setFeedbackSize(rGrp.GetInt("CornerCoordSystemSize",10)); - } - else if (strcmp(Reason,"UseAutoRotation") == 0) { - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->setAnimationEnabled(rGrp.GetBool("UseAutoRotation",false)); - } - else if ( strcmp(Reason,"Gradient") == 0 || strcmp(Reason, "RadialGradient") == 0 ) { - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->setGradientBackground(rGrp.GetBool("Gradient", true) || rGrp.GetBool("RadialGradient", false)); - } - else if (strcmp(Reason,"ShowFPS") == 0) { - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->setEnabledFPSCounter(rGrp.GetBool("ShowFPS",false)); - } - else if (strcmp(Reason,"UseVBO") == 0) { - // Disable VBO for split screen as this leads to random crashes - //for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - // (*it)->setEnabledVBO(rGrp.GetBool("UseVBO",false)); - } - - else if (strcmp(Reason,"Orthographic") == 0) { - // check whether a perspective or orthogrphic camera should be set - if (rGrp.GetBool("Orthographic", true)) { - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->setCameraType(SoOrthographicCamera::getClassTypeId()); - } - else { - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->setCameraType(SoPerspectiveCamera::getClassTypeId()); - } - } - else if (strcmp(Reason, "PickRadius") == 0) { - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) - (*it)->setPickRadius(rGrp.GetFloat("PickRadius", 5.0f)); - } - else { - unsigned long col1 = rGrp.GetUnsigned("BackgroundColor",3940932863UL); - unsigned long col2 = rGrp.GetUnsigned("BackgroundColor2",859006463UL); // default color (dark blue) - unsigned long col3 = rGrp.GetUnsigned("BackgroundColor3",2880160255UL); // default color (blue/grey) - unsigned long col4 = rGrp.GetUnsigned("BackgroundColor4",1869583359UL); // default color (blue/grey) - float r1,g1,b1,r2,g2,b2,r3,g3,b3,r4,g4,b4; - r1 = ((col1 >> 24) & 0xff) / 255.0; g1 = ((col1 >> 16) & 0xff) / 255.0; b1 = ((col1 >> 8) & 0xff) / 255.0; - r2 = ((col2 >> 24) & 0xff) / 255.0; g2 = ((col2 >> 16) & 0xff) / 255.0; b2 = ((col2 >> 8) & 0xff) / 255.0; - r3 = ((col3 >> 24) & 0xff) / 255.0; g3 = ((col3 >> 16) & 0xff) / 255.0; b3 = ((col3 >> 8) & 0xff) / 255.0; - r4 = ((col4 >> 24) & 0xff) / 255.0; g4 = ((col4 >> 16) & 0xff) / 255.0; b4 = ((col4 >> 8) & 0xff) / 255.0; - for (std::vector::iterator it = _viewer.begin(); it != _viewer.end(); ++it) { - (*it)->setBackgroundColor(QColor::fromRgbF(r1, g1, b1)); - if (!rGrp.GetBool("UseBackgroundColorMid",false)) - (*it)->setGradientBackgroundColor(SbColor(r2, g2, b2), SbColor(r3, g3, b3), - rGrp.GetBool("RadialGradient", false) ); - else - (*it)->setGradientBackgroundColor(SbColor(r2, g2, b2), SbColor(r3, g3, b3), SbColor(r4, g4, b4), - rGrp.GetBool("RadialGradient", false) ); - } - } -} - void AbstractSplitView::onUpdate() { update(); @@ -764,10 +566,6 @@ TYPESYSTEM_SOURCE_ABSTRACT(Gui::SplitView3DInventor, Gui::AbstractSplitView) SplitView3DInventor::SplitView3DInventor(int views, Gui::Document* pcDocument, QWidget* parent, Qt::WindowFlags wflags) : AbstractSplitView(pcDocument,parent, wflags) { - // attach parameter Observer - hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); - hGrp->Attach(this); - //anti-aliasing settings bool smoothing = false; bool glformat = false; diff --git a/src/Gui/SplitView3DInventor.h b/src/Gui/SplitView3DInventor.h index 8be0d400ce..9d241b6886 100644 --- a/src/Gui/SplitView3DInventor.h +++ b/src/Gui/SplitView3DInventor.h @@ -33,11 +33,12 @@ namespace Gui { class View3DInventorViewer; class AbstractSplitViewPy; +class View3DSettings; /** The SplitView3DInventor class allows to create a window with two or more Inventor views. * \author Werner Mayer */ -class GuiExport AbstractSplitView : public MDIView, public ParameterGrp::ObserverType +class GuiExport AbstractSplitView : public MDIView { Q_OBJECT @@ -52,7 +53,6 @@ public: /// Message handler bool onMsg(const char* pMsg, const char** ppReturn) override; bool onHasMsg(const char* pMsg) const override; - void OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason) override; void onUpdate() override; void deleteSelf() override; void viewAll() override; @@ -70,10 +70,9 @@ protected: void setupSettings(); protected: - /// handle to the viewer parameter group - ParameterGrp::handle hGrp; std::vector _viewer; PyObject *_viewerPy; + std::unique_ptr viewSettings; }; class AbstractSplitViewPy : public Py::PythonExtension diff --git a/src/Gui/View3DSettings.cpp b/src/Gui/View3DSettings.cpp index 7e3039f8a1..f33dda0b9c 100644 --- a/src/Gui/View3DSettings.cpp +++ b/src/Gui/View3DSettings.cpp @@ -43,7 +43,15 @@ using namespace Gui; View3DSettings::View3DSettings(ParameterGrp::handle hGrp, View3DInventorViewer* view) : hGrp(hGrp) - , _viewer(view) + , _viewers{view} +{ + hGrp->Attach(this); +} + +View3DSettings::View3DSettings(ParameterGrp::handle hGrp, + const std::vector& view) + : hGrp(hGrp) + , _viewers(view) { hGrp->Attach(this); } @@ -105,13 +113,17 @@ void View3DSettings::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M float transparency; SbColor headlightColor; headlightColor.setPackedValue((uint32_t)headlight, transparency); - _viewer->getHeadlight()->color.setValue(headlightColor); + for (auto _viewer : _viewers) { + _viewer->getHeadlight()->color.setValue(headlightColor); + } } else if (strcmp(Reason,"HeadlightDirection") == 0) { try { std::string pos = rGrp.GetASCII("HeadlightDirection"); Base::Vector3f dir = Base::to_vector(pos); - _viewer->getHeadlight()->direction.setValue(dir.x, dir.y, dir.z); + for (auto _viewer : _viewers) { + _viewer->getHeadlight()->direction.setValue(dir.x, dir.y, dir.z); + } } catch (const std::exception&) { // ignore exception @@ -119,23 +131,31 @@ void View3DSettings::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M } else if (strcmp(Reason,"HeadlightIntensity") == 0) { long value = rGrp.GetInt("HeadlightIntensity", 100); - _viewer->getHeadlight()->intensity.setValue((float)value/100.0f); + for (auto _viewer : _viewers) { + _viewer->getHeadlight()->intensity.setValue((float)value/100.0f); + } } else if (strcmp(Reason,"EnableBacklight") == 0) { - _viewer->setBacklight(rGrp.GetBool("EnableBacklight", false)); + for (auto _viewer : _viewers) { + _viewer->setBacklight(rGrp.GetBool("EnableBacklight", false)); + } } else if (strcmp(Reason,"BacklightColor") == 0) { unsigned long backlight = rGrp.GetUnsigned("BacklightColor",ULONG_MAX); // default color (white) float transparency; SbColor backlightColor; backlightColor.setPackedValue((uint32_t)backlight, transparency); - _viewer->getBacklight()->color.setValue(backlightColor); + for (auto _viewer : _viewers) { + _viewer->getBacklight()->color.setValue(backlightColor); + } } else if (strcmp(Reason,"BacklightDirection") == 0) { try { std::string pos = rGrp.GetASCII("BacklightDirection"); Base::Vector3f dir = Base::to_vector(pos); - _viewer->getBacklight()->direction.setValue(dir.x, dir.y, dir.z); + for (auto _viewer : _viewers) { + _viewer->getBacklight()->direction.setValue(dir.x, dir.y, dir.z); + } } catch (const std::exception&) { // ignore exception @@ -143,17 +163,23 @@ void View3DSettings::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M } else if (strcmp(Reason,"BacklightIntensity") == 0) { long value = rGrp.GetInt("BacklightIntensity", 100); - _viewer->getBacklight()->intensity.setValue((float)value/100.0f); + for (auto _viewer : _viewers) { + _viewer->getBacklight()->intensity.setValue((float)value/100.0f); + } } else if (strcmp(Reason,"EnablePreselection") == 0) { const ParameterGrp& rclGrp = ((ParameterGrp&)rCaller); SoFCEnableHighlightAction cAct(rclGrp.GetBool("EnablePreselection", true)); - cAct.apply(_viewer->getSceneGraph()); + for (auto _viewer : _viewers) { + cAct.apply(_viewer->getSceneGraph()); + } } else if (strcmp(Reason,"EnableSelection") == 0) { const ParameterGrp& rclGrp = ((ParameterGrp&)rCaller); SoFCEnableSelectionAction cAct(rclGrp.GetBool("EnableSelection", true)); - cAct.apply(_viewer->getSceneGraph()); + for (auto _viewer : _viewers) { + cAct.apply(_viewer->getSceneGraph()); + } } else if (strcmp(Reason,"HighlightColor") == 0) { float transparency; @@ -163,7 +189,9 @@ void View3DSettings::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M highlightColor.setPackedValue((uint32_t)highlight, transparency); SoSFColor col; col.setValue(highlightColor); SoFCHighlightColorAction cAct(col); - cAct.apply(_viewer->getSceneGraph()); + for (auto _viewer : _viewers) { + cAct.apply(_viewer->getSceneGraph()); + } } else if (strcmp(Reason,"SelectionColor") == 0) { float transparency; @@ -173,119 +201,203 @@ void View3DSettings::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M selectionColor.setPackedValue((uint32_t)selection, transparency); SoSFColor col; col.setValue(selectionColor); SoFCSelectionColorAction cAct(col); - cAct.apply(_viewer->getSceneGraph()); + for (auto _viewer : _viewers) { + cAct.apply(_viewer->getSceneGraph()); + } } else if (strcmp(Reason,"NavigationStyle") == 0) { - // check whether the simple or the full mouse model is used - std::string model = rGrp.GetASCII("NavigationStyle",CADNavigationStyle::getClassTypeId().getName()); - Base::Type type = Base::Type::fromName(model.c_str()); - _viewer->setNavigationType(type); + if (!ignoreNavigationStyle) { + // check whether the simple or the full mouse model is used + std::string model = rGrp.GetASCII("NavigationStyle",CADNavigationStyle::getClassTypeId().getName()); + Base::Type type = Base::Type::fromName(model.c_str()); + for (auto _viewer : _viewers) { + _viewer->setNavigationType(type); + } + } } else if (strcmp(Reason,"OrbitStyle") == 0) { int style = rGrp.GetInt("OrbitStyle",1); - _viewer->navigationStyle()->setOrbitStyle(NavigationStyle::OrbitStyle(style)); + for (auto _viewer : _viewers) { + _viewer->navigationStyle()->setOrbitStyle(NavigationStyle::OrbitStyle(style)); + } } else if (strcmp(Reason,"Sensitivity") == 0) { float val = rGrp.GetFloat("Sensitivity",2.0f); - _viewer->navigationStyle()->setSensitivity(val); + for (auto _viewer : _viewers) { + _viewer->navigationStyle()->setSensitivity(val); + } } else if (strcmp(Reason,"ResetCursorPosition") == 0) { bool on = rGrp.GetBool("ResetCursorPosition",false); - _viewer->navigationStyle()->setResetCursorPosition(on); + for (auto _viewer : _viewers) { + _viewer->navigationStyle()->setResetCursorPosition(on); + } } else if (strcmp(Reason,"InvertZoom") == 0) { bool on = rGrp.GetBool("InvertZoom", true); - _viewer->navigationStyle()->setZoomInverted(on); + for (auto _viewer : _viewers) { + _viewer->navigationStyle()->setZoomInverted(on); + } } else if (strcmp(Reason,"ZoomAtCursor") == 0) { bool on = rGrp.GetBool("ZoomAtCursor", true); - _viewer->navigationStyle()->setZoomAtCursor(on); + for (auto _viewer : _viewers) { + _viewer->navigationStyle()->setZoomAtCursor(on); + } } else if (strcmp(Reason,"ZoomStep") == 0) { float val = rGrp.GetFloat("ZoomStep", 0.0f); - _viewer->navigationStyle()->setZoomStep(val); + for (auto _viewer : _viewers) { + _viewer->navigationStyle()->setZoomStep(val); + } } else if (strcmp(Reason,"RotationMode") == 0) { long mode = rGrp.GetInt("RotationMode", 1); - if (mode == 0) { - _viewer->navigationStyle()->setRotationCenterMode(NavigationStyle::RotationCenterMode::WindowCenter); - } - else if (mode == 1) { - _viewer->navigationStyle()->setRotationCenterMode(NavigationStyle::RotationCenterMode::ScenePointAtCursor | - NavigationStyle::RotationCenterMode::FocalPointAtCursor); - } - else if (mode == 2) { - _viewer->navigationStyle()->setRotationCenterMode(NavigationStyle::RotationCenterMode::ScenePointAtCursor | - NavigationStyle::RotationCenterMode::BoundingBoxCenter); + for (auto _viewer : _viewers) { + if (mode == 0) { + _viewer->navigationStyle()->setRotationCenterMode(NavigationStyle::RotationCenterMode::WindowCenter); + } + else if (mode == 1) { + _viewer->navigationStyle()->setRotationCenterMode(NavigationStyle::RotationCenterMode::ScenePointAtCursor | + NavigationStyle::RotationCenterMode::FocalPointAtCursor); + } + else if (mode == 2) { + _viewer->navigationStyle()->setRotationCenterMode(NavigationStyle::RotationCenterMode::ScenePointAtCursor | + NavigationStyle::RotationCenterMode::BoundingBoxCenter); + } } } else if (strcmp(Reason,"EyeDistance") == 0) { - _viewer->getSoRenderManager()->setStereoOffset(rGrp.GetFloat("EyeDistance", 5.0)); + for (auto _viewer : _viewers) { + _viewer->getSoRenderManager()->setStereoOffset(rGrp.GetFloat("EyeDistance", 5.0)); + } } else if (strcmp(Reason,"CornerCoordSystem") == 0) { - _viewer->setFeedbackVisibility(rGrp.GetBool("CornerCoordSystem", true)); + for (auto _viewer : _viewers) { + _viewer->setFeedbackVisibility(rGrp.GetBool("CornerCoordSystem", true)); + } } else if (strcmp(Reason,"CornerCoordSystemSize") == 0) { - _viewer->setFeedbackSize(rGrp.GetInt("CornerCoordSystemSize", 10)); + for (auto _viewer : _viewers) { + _viewer->setFeedbackSize(rGrp.GetInt("CornerCoordSystemSize", 10)); + } } else if (strcmp(Reason,"ShowAxisCross") == 0) { - _viewer->setAxisCross(rGrp.GetBool("ShowAxisCross", false)); + for (auto _viewer : _viewers) { + _viewer->setAxisCross(rGrp.GetBool("ShowAxisCross", false)); + } } else if (strcmp(Reason,"UseAutoRotation") == 0) { - _viewer->setAnimationEnabled(rGrp.GetBool("UseAutoRotation", false)); + for (auto _viewer : _viewers) { + _viewer->setAnimationEnabled(rGrp.GetBool("UseAutoRotation", false)); + } } else if (strcmp(Reason,"Gradient") == 0 || strcmp(Reason,"RadialGradient") == 0) { - _viewer->setGradientBackground(rGrp.GetBool("Gradient", true) || rGrp.GetBool("RadialGradient", false)); + for (auto _viewer : _viewers) { + _viewer->setGradientBackground(rGrp.GetBool("Gradient", true) || + rGrp.GetBool("RadialGradient", false)); + } } else if (strcmp(Reason,"ShowFPS") == 0) { - _viewer->setEnabledFPSCounter(rGrp.GetBool("ShowFPS", false)); + for (auto _viewer : _viewers) { + _viewer->setEnabledFPSCounter(rGrp.GetBool("ShowFPS", false)); + } } else if (strcmp(Reason,"ShowNaviCube") == 0) { - _viewer->setEnabledNaviCube(rGrp.GetBool("ShowNaviCube", true)); + for (auto _viewer : _viewers) { + _viewer->setEnabledNaviCube(rGrp.GetBool("ShowNaviCube", true)); + } } else if (strcmp(Reason,"UseVBO") == 0) { - _viewer->setEnabledVBO(rGrp.GetBool("UseVBO", false)); + if (!ignoreVBO) { + for (auto _viewer : _viewers) { + _viewer->setEnabledVBO(rGrp.GetBool("UseVBO", false)); + } + } } else if (strcmp(Reason,"RenderCache") == 0) { - _viewer->setRenderCache(rGrp.GetInt("RenderCache", 0)); + if (!ignoreRenderCache) { + for (auto _viewer : _viewers) { + _viewer->setRenderCache(rGrp.GetInt("RenderCache", 0)); + } + } } else if (strcmp(Reason,"Orthographic") == 0) { // check whether a perspective or orthogrphic camera should be set - if (rGrp.GetBool("Orthographic", true)) - _viewer->setCameraType(SoOrthographicCamera::getClassTypeId()); - else - _viewer->setCameraType(SoPerspectiveCamera::getClassTypeId()); + if (rGrp.GetBool("Orthographic", true)) { + for (auto _viewer : _viewers) { + _viewer->setCameraType(SoOrthographicCamera::getClassTypeId()); + } + } + else { + for (auto _viewer : _viewers) { + _viewer->setCameraType(SoPerspectiveCamera::getClassTypeId()); + } + } } else if (strcmp(Reason, "DimensionsVisible") == 0) { - if (rGrp.GetBool("DimensionsVisible", true)) - _viewer->turnAllDimensionsOn(); - else - _viewer->turnAllDimensionsOff(); + if (!ignoreDimensions) { + if (rGrp.GetBool("DimensionsVisible", true)) { + for (auto _viewer : _viewers) { + _viewer->turnAllDimensionsOn(); + } + } + else { + for (auto _viewer : _viewers) { + _viewer->turnAllDimensionsOff(); + } + } + } } else if (strcmp(Reason, "Dimensions3dVisible") == 0) { - if (rGrp.GetBool("Dimensions3dVisible", true)) - _viewer->turn3dDimensionsOn(); - else - _viewer->turn3dDimensionsOff(); + if (!ignoreDimensions) { + if (rGrp.GetBool("Dimensions3dVisible", true)) { + for (auto _viewer : _viewers) { + _viewer->turn3dDimensionsOn(); + } + } + else { + for (auto _viewer : _viewers) { + _viewer->turn3dDimensionsOff(); + } + } + } } else if (strcmp(Reason, "DimensionsDeltaVisible") == 0) { - if (rGrp.GetBool("DimensionsDeltaVisible", true)) - _viewer->turnDeltaDimensionsOn(); - else - _viewer->turnDeltaDimensionsOff(); + if (!ignoreDimensions) { + if (rGrp.GetBool("DimensionsDeltaVisible", true)) { + for (auto _viewer : _viewers) { + _viewer->turnDeltaDimensionsOn(); + } + } + else { + for (auto _viewer : _viewers) { + _viewer->turnDeltaDimensionsOff(); + } + } + } } else if (strcmp(Reason, "PickRadius") == 0) { - _viewer->setPickRadius(rGrp.GetFloat("PickRadius", 5.0f)); + for (auto _viewer : _viewers) { + _viewer->setPickRadius(rGrp.GetFloat("PickRadius", 5.0f)); + } } else if (strcmp(Reason, "TransparentObjectRenderType") == 0) { - long renderType = rGrp.GetInt("TransparentObjectRenderType", 0); - if (renderType == 0) { - _viewer->getSoRenderManager()->getGLRenderAction() - ->setTransparentDelayedObjectRenderType(SoGLRenderAction::ONE_PASS); - } - else if (renderType == 1) { - _viewer->getSoRenderManager()->getGLRenderAction() - ->setTransparentDelayedObjectRenderType(SoGLRenderAction::NONSOLID_SEPARATE_BACKFACE_PASS); + if (!ignoreTransparent) { + long renderType = rGrp.GetInt("TransparentObjectRenderType", 0); + if (renderType == 0) { + for (auto _viewer : _viewers) { + _viewer->getSoRenderManager()->getGLRenderAction() + ->setTransparentDelayedObjectRenderType(SoGLRenderAction::ONE_PASS); + } + } + else if (renderType == 1) { + for (auto _viewer : _viewers) { + _viewer->getSoRenderManager()->getGLRenderAction() + ->setTransparentDelayedObjectRenderType(SoGLRenderAction:: + NONSOLID_SEPARATE_BACKFACE_PASS); + } + } } } else { @@ -298,11 +410,18 @@ void View3DSettings::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M r2 = ((col2 >> 24) & 0xff) / 255.0; g2 = ((col2 >> 16) & 0xff) / 255.0; b2 = ((col2 >> 8) & 0xff) / 255.0; r3 = ((col3 >> 24) & 0xff) / 255.0; g3 = ((col3 >> 16) & 0xff) / 255.0; b3 = ((col3 >> 8) & 0xff) / 255.0; r4 = ((col4 >> 24) & 0xff) / 255.0; g4 = ((col4 >> 16) & 0xff) / 255.0; b4 = ((col4 >> 8) & 0xff) / 255.0; - _viewer->setBackgroundColor(QColor::fromRgbF(r1, g1, b1)); - if (!rGrp.GetBool("UseBackgroundColorMid",false)) - _viewer->setGradientBackgroundColor(SbColor(r2, g2, b2), SbColor(r3, g3, b3), rGrp.GetBool("RadialGradient", false)); - else - _viewer->setGradientBackgroundColor(SbColor(r2, g2, b2), SbColor(r3, g3, b3), SbColor(r4, g4, b4), rGrp.GetBool("RadialGradient", false)); + for (auto _viewer : _viewers) { + _viewer->setBackgroundColor(QColor::fromRgbF(r1, g1, b1)); + if (!rGrp.GetBool("UseBackgroundColorMid",false)) + _viewer->setGradientBackgroundColor(SbColor(r2, g2, b2), + SbColor(r3, g3, b3), + rGrp.GetBool("RadialGradient", false)); + else + _viewer->setGradientBackgroundColor(SbColor(r2, g2, b2), + SbColor(r3, g3, b3), + SbColor(r4, g4, b4), + rGrp.GetBool("RadialGradient", false)); + } } } diff --git a/src/Gui/View3DSettings.h b/src/Gui/View3DSettings.h index a78e5e2b2d..dd8a224c41 100644 --- a/src/Gui/View3DSettings.h +++ b/src/Gui/View3DSettings.h @@ -32,6 +32,7 @@ class View3DSettings : public ParameterGrp::ObserverType { public: View3DSettings(ParameterGrp::handle hGrp, View3DInventorViewer *); + View3DSettings(ParameterGrp::handle hGrp, const std::vector&); ~View3DSettings() override; /// Observer message from the ParameterGrp @@ -39,9 +40,15 @@ public: void applySettings(); int stopAnimatingIfDeactivated() const; + bool ignoreNavigationStyle = false; + bool ignoreVBO = false; + bool ignoreDimensions = false; + bool ignoreRenderCache = false; + bool ignoreTransparent = false; + private: ParameterGrp::handle hGrp; - View3DInventorViewer * _viewer; + std::vector _viewers; }; class NaviCubeSettings : public ParameterGrp::ObserverType