Core: Add a possibility to extract active object based on extension
This commit is contained in:
committed by
Benjamin Nauck
parent
2688f06dd1
commit
b3c83df151
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user