diff --git a/src/Gui/ActiveObjectList.cpp b/src/Gui/ActiveObjectList.cpp index 0c0a5693c6..e76882167a 100644 --- a/src/Gui/ActiveObjectList.cpp +++ b/src/Gui/ActiveObjectList.cpp @@ -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; +} diff --git a/src/Gui/ActiveObjectList.h b/src/Gui/ActiveObjectList.h index 8a75ce87bb..bd058d0607 100644 --- a/src/Gui/ActiveObjectList.h +++ b/src/Gui/ActiveObjectList.h @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -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); diff --git a/src/Gui/MDIView.h b/src/Gui/MDIView.h index f56a04578c..64c92ee4d8 100644 --- a/src/Gui/MDIView.h +++ b/src/Gui/MDIView.h @@ -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