Use View3DInventorViewer::setSelectionEnabled instead of SoFCUnifiedSelection::selectionRole

This commit is contained in:
wmayer
2023-05-02 15:44:03 +02:00
committed by wwmayer
parent d668f12ffb
commit b0c9871722
8 changed files with 22 additions and 40 deletions

View File

@@ -72,7 +72,6 @@
#include "SelectionObject.h" #include "SelectionObject.h"
#include "SoAxisCrossKit.h" #include "SoAxisCrossKit.h"
#include "SoFCOffscreenRenderer.h" #include "SoFCOffscreenRenderer.h"
#include "SoFCUnifiedSelection.h"
#include "TextureMapping.h" #include "TextureMapping.h"
#include "Tools.h" #include "Tools.h"
#include "Tree.h" #include "Tree.h"
@@ -2831,8 +2830,7 @@ static void doSelect(void* ud, SoEventCallback * cb)
bool selectElement = ud ? true : false; bool selectElement = ud ? true : false;
auto viewer = static_cast<Gui::View3DInventorViewer*>(cb->getUserData()); auto viewer = static_cast<Gui::View3DInventorViewer*>(cb->getUserData());
SoNode* root = viewer->getSceneGraph(); viewer->setSelectionEnabled(true);
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(true);
SelectionMode selectionMode = CENTER; SelectionMode selectionMode = CENTER;
@@ -2897,9 +2895,9 @@ void StdBoxSelection::activated(int iMsg)
SoKeyboardEvent ev; SoKeyboardEvent ev;
viewer->navigationStyle()->processEvent(&ev); viewer->navigationStyle()->processEvent(&ev);
} }
SelectionCallbackHandler::Create(viewer, View3DInventorViewer::Rubberband, QCursor(QPixmap(cursor_box_select), 7, 7), doSelect, nullptr); SelectionCallbackHandler::Create(viewer, View3DInventorViewer::Rubberband, QCursor(QPixmap(cursor_box_select), 7, 7), doSelect, nullptr);
SoNode* root = viewer->getSceneGraph(); viewer->setSelectionEnabled(false);
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(false);
} }
} }
} }
@@ -2978,9 +2976,9 @@ void StdBoxElementSelection::activated(int iMsg)
SoKeyboardEvent ev; SoKeyboardEvent ev;
viewer->navigationStyle()->processEvent(&ev); viewer->navigationStyle()->processEvent(&ev);
} }
SelectionCallbackHandler::Create(viewer, View3DInventorViewer::Rubberband, QCursor(QPixmap(cursor_box_element_select), 7, 7), doSelect, this); SelectionCallbackHandler::Create(viewer, View3DInventorViewer::Rubberband, QCursor(QPixmap(cursor_box_element_select), 7, 7), doSelect, this);
SoNode* root = viewer->getSceneGraph(); viewer->setSelectionEnabled(false);
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(false);
} }
} }
} }

View File

@@ -189,9 +189,9 @@ void ViewProviderDragger::setEditViewer(Gui::View3DInventorViewer* viewer, int M
{ {
auto rootPickStyle = new SoPickStyle(); auto rootPickStyle = new SoPickStyle();
rootPickStyle->style = SoPickStyle::UNPICKABLE; rootPickStyle->style = SoPickStyle::UNPICKABLE;
auto selection = static_cast<SoFCUnifiedSelection*>(viewer->getSceneGraph()); auto selection = static_cast<SoGroup*>(viewer->getSceneGraph());
selection->insertChild(rootPickStyle, 0); selection->insertChild(rootPickStyle, 0);
selection->selectionRole.setValue(false); viewer->setSelectionEnabled(false);
csysDragger->setUpAutoScale(viewer->getSoRenderManager()->getCamera()); csysDragger->setUpAutoScale(viewer->getSoRenderManager()->getCamera());
auto mat = viewer->getDocument()->getEditingTransform(); auto mat = viewer->getDocument()->getEditingTransform();
@@ -208,12 +208,12 @@ void ViewProviderDragger::setEditViewer(Gui::View3DInventorViewer* viewer, int M
void ViewProviderDragger::unsetEditViewer(Gui::View3DInventorViewer* viewer) void ViewProviderDragger::unsetEditViewer(Gui::View3DInventorViewer* viewer)
{ {
auto selection = static_cast<SoFCUnifiedSelection*>(viewer->getSceneGraph()); auto selection = static_cast<SoGroup*>(viewer->getSceneGraph());
SoNode *child = selection->getChild(0); SoNode *child = selection->getChild(0);
if (child && child->isOfType(SoPickStyle::getClassTypeId())) { if (child && child->isOfType(SoPickStyle::getClassTypeId())) {
selection->removeChild(child); selection->removeChild(child);
selection->selectionRole.setValue(true); viewer->setSelectionEnabled(true);
} }
} }
void ViewProviderDragger::dragStartCallback(void *, SoDragger *) void ViewProviderDragger::dragStartCallback(void *, SoDragger *)

View File

@@ -40,7 +40,6 @@
#include <Gui/MainWindow.h> #include <Gui/MainWindow.h>
#include <Gui/Selection.h> #include <Gui/Selection.h>
#include <Gui/SelectionFilter.h> #include <Gui/SelectionFilter.h>
#include <Gui/SoFCUnifiedSelection.h>
#include <Gui/Utilities.h> #include <Gui/Utilities.h>
#include <Gui/View3DInventor.h> #include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h> #include <Gui/View3DInventorViewer.h>
@@ -96,8 +95,7 @@ void BoxSelection::selectionCallback(void * ud, SoEventCallback * cb)
{ {
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(cb->getUserData()); Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(cb->getUserData());
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, ud); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, ud);
SoNode* root = view->getSceneGraph(); view->setSelectionEnabled(true);
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(true);
std::vector<SbVec2f> picked = view->getGLPolygon(); std::vector<SbVec2f> picked = view->getGLPolygon();
SoCamera* cam = view->getSoRenderManager()->getCamera(); SoCamera* cam = view->getSoRenderManager()->getCamera();
@@ -204,8 +202,7 @@ void BoxSelection::start(TopAbs_ShapeEnum shape)
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, this); viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, this);
// avoid that the selection node handles the event otherwise the callback function won't be // avoid that the selection node handles the event otherwise the callback function won't be
// called immediately // called immediately
SoNode* root = viewer->getSceneGraph(); viewer->setSelectionEnabled(false);
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(false);
shapeEnum = shape; shapeEnum = shape;
} }
} }

View File

@@ -49,7 +49,6 @@
#include <Gui/Document.h> #include <Gui/Document.h>
#include <Gui/MainWindow.h> #include <Gui/MainWindow.h>
#include <Gui/Selection.h> #include <Gui/Selection.h>
#include <Gui/SoFCUnifiedSelection.h>
#include <Gui/Tools.h> #include <Gui/Tools.h>
#include <Gui/Utilities.h> #include <Gui/Utilities.h>
#include <Gui/View3DInventor.h> #include <Gui/View3DInventor.h>
@@ -201,8 +200,7 @@ public:
{ {
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(cb->getUserData()); Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(cb->getUserData());
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, ud); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, ud);
SoNode* root = view->getSceneGraph(); view->setSelectionEnabled(true);
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(true);
std::vector<SbVec2f> picked = view->getGLPolygon(); std::vector<SbVec2f> picked = view->getGLPolygon();
SoCamera* cam = view->getSoRenderManager()->getCamera(); SoCamera* cam = view->getSoRenderManager()->getCamera();
@@ -267,8 +265,7 @@ FaceColors::~FaceColors()
d->view->stopSelection(); d->view->stopSelection();
d->view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), d->view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(),
Private::selectionCallback, this); Private::selectionCallback, this);
SoNode* root = d->view->getSceneGraph(); d->view->setSelectionEnabled(true);
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(true);
} }
Gui::Selection().rmvSelectionGate(); Gui::Selection().rmvSelectionGate();
d->connectDelDoc.disconnect(); d->connectDelDoc.disconnect();
@@ -325,8 +322,7 @@ void FaceColors::onBoxSelectionToggled(bool checked)
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), Private::selectionCallback, this); viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), Private::selectionCallback, this);
// avoid that the selection node handles the event otherwise the callback function won't be // avoid that the selection node handles the event otherwise the callback function won't be
// called immediately // called immediately
SoNode* root = viewer->getSceneGraph(); viewer->setSelectionEnabled(false);
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(false);
d->view = viewer; d->view = viewer;
} }
} }

View File

@@ -37,7 +37,6 @@
#include <Gui/Document.h> #include <Gui/Document.h>
#include <Gui/MainWindow.h> #include <Gui/MainWindow.h>
#include <Gui/SelectionFilter.h> #include <Gui/SelectionFilter.h>
#include <Gui/SoFCUnifiedSelection.h>
#include <Gui/View3DInventor.h> #include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h> #include <Gui/View3DInventorViewer.h>
#include <Mod/Part/App/DatumFeature.h> #include <Mod/Part/App/DatumFeature.h>

View File

@@ -159,9 +159,7 @@ private:
Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView(); Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView();
Gui::View3DInventorViewer *viewer; Gui::View3DInventorViewer *viewer;
viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer(); viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer();
viewer->setSelectionEnabled(true);
SoNode* root = viewer->getSceneGraph();
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(true);
Gui::Selection().clearSelection(); Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate(); Gui::Selection().rmvSelectionGate();

View File

@@ -169,9 +169,7 @@ private:
Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView(); Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView();
Gui::View3DInventorViewer *viewer; Gui::View3DInventorViewer *viewer;
viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer(); viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer();
viewer->setSelectionEnabled(true);
SoNode* root = viewer->getSceneGraph();
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(true);
Gui::Selection().clearSelection(); Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate(); Gui::Selection().rmvSelectionGate();

View File

@@ -418,9 +418,7 @@ void ViewProviderSketch::purgeHandler()
Gui::MDIView *mdi = Gui::Application::Instance->editDocument()->getActiveView(); Gui::MDIView *mdi = Gui::Application::Instance->editDocument()->getActiveView();
Gui::View3DInventorViewer *viewer; Gui::View3DInventorViewer *viewer;
viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer(); viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer();
viewer->setSelectionEnabled(false);
SoNode* root = viewer->getSceneGraph();
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(false);
} }
void ViewProviderSketch::setAxisPickStyle(bool on) void ViewProviderSketch::setAxisPickStyle(bool on)
@@ -3183,8 +3181,7 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo
viewer->setCameraOrientation(rot); viewer->setCameraOrientation(rot);
viewer->setEditing(true); viewer->setEditing(true);
SoNode* root = viewer->getSceneGraph(); viewer->setSelectionEnabled(false);
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(false);
viewer->addGraphicsItem(rubberband.get()); viewer->addGraphicsItem(rubberband.get());
rubberband->setViewer(viewer); rubberband->setViewer(viewer);
@@ -3204,8 +3201,7 @@ void ViewProviderSketch::unsetEditViewer(Gui::View3DInventorViewer* viewer)
viewer->removeGraphicsItem(rubberband.get()); viewer->removeGraphicsItem(rubberband.get());
viewer->setEditing(false); viewer->setEditing(false);
SoNode* root = viewer->getSceneGraph(); viewer->setSelectionEnabled(true);
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(true);
} }
void ViewProviderSketch::camSensCB(void *data, SoSensor *) void ViewProviderSketch::camSensCB(void *data, SoSensor *)