Merge pull request #25009 from tetektoza/fix/24290_respect_selectable_option_if_nested_objs
Gui: Respect Selectable property for objects inside Part containers
This commit is contained in:
@@ -455,8 +455,30 @@ void SoFCUnifiedSelection::doAction(SoAction* action)
|
||||
App::Document* doc = App::GetApplication().getDocument(selectionAction->SelChange.pDocName);
|
||||
App::DocumentObject* obj = doc->getObject(selectionAction->SelChange.pObjectName);
|
||||
ViewProvider* vp = Application::Instance->getViewProvider(obj);
|
||||
if (vp && (useNewSelection.getValue() || vp->useNewSelectionModel())
|
||||
&& vp->isSelectable()) {
|
||||
|
||||
// check if the subobject and all its parent containers are selectable
|
||||
bool isSelectable = false;
|
||||
if (vp) {
|
||||
if (selectionAction->SelChange.pSubName && selectionAction->SelChange.pSubName[0]) {
|
||||
// get the entire object hierarchy from root to leaf
|
||||
auto objList = obj->getSubObjectList(selectionAction->SelChange.pSubName);
|
||||
|
||||
isSelectable = true;
|
||||
for (auto* checkObj : objList) {
|
||||
if (auto checkVp = Application::Instance->getViewProvider(checkObj)) {
|
||||
if (!checkVp->isSelectable()) {
|
||||
isSelectable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
isSelectable = vp->isSelectable();
|
||||
}
|
||||
}
|
||||
|
||||
if (vp && (useNewSelection.getValue() || vp->useNewSelectionModel()) && isSelectable) {
|
||||
SoDetail* detail = nullptr;
|
||||
detailPath->truncate(0);
|
||||
auto subName = selectionAction->SelChange.pSubName;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
using namespace Gui;
|
||||
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(Gui::ViewProviderPart, Gui::ViewProviderDragger)
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(Gui::ViewProviderPart, Gui::ViewProviderGeometryObject)
|
||||
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ ViewProviderPart::~ViewProviderPart() = default;
|
||||
*/
|
||||
void ViewProviderPart::onChanged(const App::Property* prop)
|
||||
{
|
||||
ViewProviderDragger::onChanged(prop);
|
||||
ViewProviderGeometryObject::onChanged(prop);
|
||||
}
|
||||
|
||||
void ViewProviderPart::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
@@ -74,7 +74,7 @@ void ViewProviderPart::setupContextMenu(QMenu* menu, QObject* receiver, const ch
|
||||
act->setChecked(isActivePart());
|
||||
func->trigger(act, [this]() { this->toggleActivePart(); });
|
||||
|
||||
ViewProviderDragger::setupContextMenu(menu, receiver, member);
|
||||
ViewProviderGeometryObject::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderPart::isActivePart()
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifndef GUI_VIEWPROVIDER_ViewProviderPart_H
|
||||
#define GUI_VIEWPROVIDER_ViewProviderPart_H
|
||||
|
||||
#include "ViewProviderDragger.h"
|
||||
#include "ViewProviderGeometryObject.h"
|
||||
#include "ViewProviderOriginGroup.h"
|
||||
#include "ViewProviderFeaturePython.h"
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
class GuiExport ViewProviderPart: public ViewProviderDragger, public ViewProviderOriginGroupExtension
|
||||
class GuiExport ViewProviderPart: public ViewProviderGeometryObject,
|
||||
public ViewProviderOriginGroupExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(Gui::ViewProviderPart);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user