Core: Add a possibility to extract active object based on extension

This commit is contained in:
tetektoza
2025-06-22 17:41:22 +02:00
committed by Benjamin Nauck
parent 2688f06dd1
commit b3c83df151
3 changed files with 20 additions and 0 deletions

View File

@@ -197,3 +197,15 @@ void ActiveObjectList::objectDeleted(const ViewProviderDocumentObject &vp)
}
}
}
App::DocumentObject* ActiveObjectList::getObjectWithExtension(const Base::Type extensionTypeId) const
{
for (const auto& pair : _ObjectMap) {
App::DocumentObject* obj = getObject(pair.second, true);
if (obj && obj->hasExtension(extensionTypeId)) {
return obj;
}
}
return nullptr;
}

View File

@@ -27,6 +27,7 @@
#include <map>
#include <string>
#include <Base/Type.h>
#include <Gui/TreeItemMode.h>
#include <FCGlobal.h>
@@ -67,6 +68,8 @@ namespace Gui
void objectDeleted(const ViewProviderDocumentObject& viewProviderIn);
bool hasObject(App::DocumentObject *obj, const char *, const char *subname=nullptr) const;
App::DocumentObject* getObjectWithExtension(Base::Type extensionTypeId) const;
private:
struct ObjectInfo;
void setHighlight(const ObjectInfo &info, Gui::HighlightMode mode, bool enable);

View File

@@ -147,6 +147,11 @@ public:
return ActiveObjects.hasObject(o,n,subname);
}
App::DocumentObject* getActiveObjectWithExtension(const Base::Type extensionTypeId) const
{
return ActiveObjects.getObjectWithExtension(extensionTypeId);
}
/*!
* \brief containsViewProvider
* Checks if the given view provider is part of this view. The default implementation