From b0c9871722897738efb6db5acdbc868bf4bde653 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 2 May 2023 15:44:03 +0200 Subject: [PATCH] Use View3DInventorViewer::setSelectionEnabled instead of SoFCUnifiedSelection::selectionRole --- src/Gui/CommandView.cpp | 12 +++++------- src/Gui/ViewProviderDragger.cpp | 14 +++++++------- src/Mod/Part/Gui/BoxSelection.cpp | 7 ++----- src/Mod/Part/Gui/TaskFaceColors.cpp | 10 +++------- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 1 - src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h | 4 +--- src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h | 4 +--- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 10 +++------- 8 files changed, 22 insertions(+), 40 deletions(-) diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 15841a9505..111ad493a2 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -72,7 +72,6 @@ #include "SelectionObject.h" #include "SoAxisCrossKit.h" #include "SoFCOffscreenRenderer.h" -#include "SoFCUnifiedSelection.h" #include "TextureMapping.h" #include "Tools.h" #include "Tree.h" @@ -2831,8 +2830,7 @@ static void doSelect(void* ud, SoEventCallback * cb) bool selectElement = ud ? true : false; auto viewer = static_cast(cb->getUserData()); - SoNode* root = viewer->getSceneGraph(); - static_cast(root)->selectionRole.setValue(true); + viewer->setSelectionEnabled(true); SelectionMode selectionMode = CENTER; @@ -2897,9 +2895,9 @@ void StdBoxSelection::activated(int iMsg) SoKeyboardEvent ev; viewer->navigationStyle()->processEvent(&ev); } + SelectionCallbackHandler::Create(viewer, View3DInventorViewer::Rubberband, QCursor(QPixmap(cursor_box_select), 7, 7), doSelect, nullptr); - SoNode* root = viewer->getSceneGraph(); - static_cast(root)->selectionRole.setValue(false); + viewer->setSelectionEnabled(false); } } } @@ -2978,9 +2976,9 @@ void StdBoxElementSelection::activated(int iMsg) SoKeyboardEvent ev; viewer->navigationStyle()->processEvent(&ev); } + SelectionCallbackHandler::Create(viewer, View3DInventorViewer::Rubberband, QCursor(QPixmap(cursor_box_element_select), 7, 7), doSelect, this); - SoNode* root = viewer->getSceneGraph(); - static_cast(root)->selectionRole.setValue(false); + viewer->setSelectionEnabled(false); } } } diff --git a/src/Gui/ViewProviderDragger.cpp b/src/Gui/ViewProviderDragger.cpp index dcfaf0e2ab..3c40e1901f 100644 --- a/src/Gui/ViewProviderDragger.cpp +++ b/src/Gui/ViewProviderDragger.cpp @@ -189,9 +189,9 @@ void ViewProviderDragger::setEditViewer(Gui::View3DInventorViewer* viewer, int M { auto rootPickStyle = new SoPickStyle(); rootPickStyle->style = SoPickStyle::UNPICKABLE; - auto selection = static_cast(viewer->getSceneGraph()); + auto selection = static_cast(viewer->getSceneGraph()); selection->insertChild(rootPickStyle, 0); - selection->selectionRole.setValue(false); + viewer->setSelectionEnabled(false); csysDragger->setUpAutoScale(viewer->getSoRenderManager()->getCamera()); auto mat = viewer->getDocument()->getEditingTransform(); @@ -208,12 +208,12 @@ void ViewProviderDragger::setEditViewer(Gui::View3DInventorViewer* viewer, int M void ViewProviderDragger::unsetEditViewer(Gui::View3DInventorViewer* viewer) { - auto selection = static_cast(viewer->getSceneGraph()); + auto selection = static_cast(viewer->getSceneGraph()); SoNode *child = selection->getChild(0); - if (child && child->isOfType(SoPickStyle::getClassTypeId())) { - selection->removeChild(child); - selection->selectionRole.setValue(true); - } + if (child && child->isOfType(SoPickStyle::getClassTypeId())) { + selection->removeChild(child); + viewer->setSelectionEnabled(true); + } } void ViewProviderDragger::dragStartCallback(void *, SoDragger *) diff --git a/src/Mod/Part/Gui/BoxSelection.cpp b/src/Mod/Part/Gui/BoxSelection.cpp index 77bf3ef8e9..3463faf6e5 100644 --- a/src/Mod/Part/Gui/BoxSelection.cpp +++ b/src/Mod/Part/Gui/BoxSelection.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -96,8 +95,7 @@ void BoxSelection::selectionCallback(void * ud, SoEventCallback * cb) { Gui::View3DInventorViewer* view = static_cast(cb->getUserData()); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, ud); - SoNode* root = view->getSceneGraph(); - static_cast(root)->selectionRole.setValue(true); + view->setSelectionEnabled(true); std::vector picked = view->getGLPolygon(); SoCamera* cam = view->getSoRenderManager()->getCamera(); @@ -204,8 +202,7 @@ void BoxSelection::start(TopAbs_ShapeEnum shape) viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, this); // avoid that the selection node handles the event otherwise the callback function won't be // called immediately - SoNode* root = viewer->getSceneGraph(); - static_cast(root)->selectionRole.setValue(false); + viewer->setSelectionEnabled(false); shapeEnum = shape; } } diff --git a/src/Mod/Part/Gui/TaskFaceColors.cpp b/src/Mod/Part/Gui/TaskFaceColors.cpp index 96cc34aaa6..dd191f7e8c 100644 --- a/src/Mod/Part/Gui/TaskFaceColors.cpp +++ b/src/Mod/Part/Gui/TaskFaceColors.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -201,8 +200,7 @@ public: { Gui::View3DInventorViewer* view = static_cast(cb->getUserData()); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, ud); - SoNode* root = view->getSceneGraph(); - static_cast(root)->selectionRole.setValue(true); + view->setSelectionEnabled(true); std::vector picked = view->getGLPolygon(); SoCamera* cam = view->getSoRenderManager()->getCamera(); @@ -267,8 +265,7 @@ FaceColors::~FaceColors() d->view->stopSelection(); d->view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), Private::selectionCallback, this); - SoNode* root = d->view->getSceneGraph(); - static_cast(root)->selectionRole.setValue(true); + d->view->setSelectionEnabled(true); } Gui::Selection().rmvSelectionGate(); d->connectDelDoc.disconnect(); @@ -325,8 +322,7 @@ void FaceColors::onBoxSelectionToggled(bool checked) viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), Private::selectionCallback, this); // avoid that the selection node handles the event otherwise the callback function won't be // called immediately - SoNode* root = viewer->getSceneGraph(); - static_cast(root)->selectionRole.setValue(false); + viewer->setSelectionEnabled(false); d->view = viewer; } } diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index a894237e89..be09c0aa01 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h index af92e5b88c..c21307267f 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h @@ -159,9 +159,7 @@ private: Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView(); Gui::View3DInventorViewer *viewer; viewer = static_cast(mdi)->getViewer(); - - SoNode* root = viewer->getSceneGraph(); - static_cast(root)->selectionRole.setValue(true); + viewer->setSelectionEnabled(true); Gui::Selection().clearSelection(); Gui::Selection().rmvSelectionGate(); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h index 0512451a81..eec749b00c 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h @@ -169,9 +169,7 @@ private: Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView(); Gui::View3DInventorViewer *viewer; viewer = static_cast(mdi)->getViewer(); - - SoNode* root = viewer->getSceneGraph(); - static_cast(root)->selectionRole.setValue(true); + viewer->setSelectionEnabled(true); Gui::Selection().clearSelection(); Gui::Selection().rmvSelectionGate(); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index b6f359972a..67a55fddd9 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -418,9 +418,7 @@ void ViewProviderSketch::purgeHandler() Gui::MDIView *mdi = Gui::Application::Instance->editDocument()->getActiveView(); Gui::View3DInventorViewer *viewer; viewer = static_cast(mdi)->getViewer(); - - SoNode* root = viewer->getSceneGraph(); - static_cast(root)->selectionRole.setValue(false); + viewer->setSelectionEnabled(false); } void ViewProviderSketch::setAxisPickStyle(bool on) @@ -3183,8 +3181,7 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo viewer->setCameraOrientation(rot); viewer->setEditing(true); - SoNode* root = viewer->getSceneGraph(); - static_cast(root)->selectionRole.setValue(false); + viewer->setSelectionEnabled(false); viewer->addGraphicsItem(rubberband.get()); rubberband->setViewer(viewer); @@ -3204,8 +3201,7 @@ void ViewProviderSketch::unsetEditViewer(Gui::View3DInventorViewer* viewer) viewer->removeGraphicsItem(rubberband.get()); viewer->setEditing(false); - SoNode* root = viewer->getSceneGraph(); - static_cast(root)->selectionRole.setValue(true); + viewer->setSelectionEnabled(true); } void ViewProviderSketch::camSensCB(void *data, SoSensor *)