Gui: Add SoPickStyle node to make an object un-selectable if needed

This commit is contained in:
wmayer
2024-12-04 19:36:43 +01:00
committed by Yorik van Havre
parent 4c492621fc
commit 1cf2bacf1f
2 changed files with 10 additions and 0 deletions

View File

@@ -32,6 +32,7 @@
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoFont.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoPickStyle.h>
#include <Inventor/nodes/SoResetTransform.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoSwitch.h>
@@ -91,6 +92,10 @@ ViewProviderGeometryObject::ViewProviderGeometryObject()
App::Prop_None,
"Set if the object is selectable in the 3d view");
pickStyle = new SoPickStyle();
pickStyle->ref();
pickStyle->style.setValue(SoPickStyle::SHAPE);
pcRoot->insertChild(pickStyle, 1);
Selectable.setValue(isSelectionEnabled());
pcShapeMaterial = new SoMaterial;
@@ -111,6 +116,7 @@ ViewProviderGeometryObject::~ViewProviderGeometryObject()
pcShapeMaterial->unref();
pcBoundingBox->unref();
pcBoundColor->unref();
pickStyle->unref();
}
bool ViewProviderGeometryObject::isSelectionEnabled() const
@@ -348,6 +354,8 @@ void ViewProviderGeometryObject::setSelectable(bool selectable)
}
}
}
pickStyle->style.setValue(selectable ? SoPickStyle::SHAPE : SoPickStyle::UNPICKABLE);
}
PyObject* ViewProviderGeometryObject::getPyObject()