Core: ViewProvider: Add claimChildrenRecursive
This commit is contained in:
@@ -882,12 +882,28 @@ std::vector< App::DocumentObject* > ViewProvider::claimChildren() const
|
||||
auto vector = getExtensionsDerivedFromType<Gui::ViewProviderExtension>();
|
||||
for (Gui::ViewProviderExtension* ext : vector) {
|
||||
std::vector< App::DocumentObject* > nvec = ext->extensionClaimChildren();
|
||||
if (!nvec.empty())
|
||||
if (!nvec.empty()){
|
||||
vec.insert(std::end(vec), std::begin(nvec), std::end(nvec));
|
||||
}
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
std::vector< App::DocumentObject* > ViewProvider::claimChildrenRecursive() const
|
||||
{
|
||||
std::vector<App::DocumentObject*> children = claimChildren();
|
||||
for (auto* child : claimChildren()) {
|
||||
auto* vp = Application::Instance->getViewProvider(child);
|
||||
if (!vp) { continue; }
|
||||
|
||||
std::vector<App::DocumentObject*> nvec = vp->claimChildrenRecursive();
|
||||
if (!nvec.empty()){
|
||||
children.insert(std::end(children), std::begin(nvec), std::end(nvec));
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
std::vector< App::DocumentObject* > ViewProvider::claimChildren3D() const
|
||||
{
|
||||
std::vector< App::DocumentObject* > vec;
|
||||
|
||||
@@ -264,6 +264,11 @@ public:
|
||||
virtual std::vector<App::DocumentObject*> claimChildren() const;
|
||||
//@}
|
||||
|
||||
/** deliver the children belonging to this object recursively.
|
||||
*/
|
||||
virtual std::vector<App::DocumentObject*> claimChildrenRecursive() const;
|
||||
//@}
|
||||
|
||||
/** @name Drag and drop
|
||||
* To enable drag and drop you have to re-implement \ref canDragObjects() and
|
||||
* \ref canDropObjects() to return true. For finer control you can also re-implement
|
||||
|
||||
@@ -201,6 +201,13 @@ trans : Base.Placement, Base.Matrix</UserDocu>
|
||||
Returns list of objects that are to be grouped in tree under this object.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="claimChildrenRecursive" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>claimChildrenRecursive() -> list
|
||||
|
||||
Returns list of objects that are to be grouped in tree under this object recursively.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="partialRender">
|
||||
<Documentation>
|
||||
<UserDocu>partialRender(sub=None, clear=False) -> int
|
||||
|
||||
@@ -393,7 +393,23 @@ PyObject* ViewProviderPy::claimChildren(PyObject* args)
|
||||
|
||||
std::vector<App::DocumentObject*> children = this->getViewProviderPtr()->claimChildren();
|
||||
Py::List ret;
|
||||
for(App::DocumentObject* child: children){
|
||||
for(auto* child: children){
|
||||
if (child)
|
||||
ret.append(Py::asObject(child->getPyObject()));
|
||||
else
|
||||
ret.append(Py::None());
|
||||
}
|
||||
return Py::new_reference_to(ret);
|
||||
}
|
||||
|
||||
PyObject* ViewProviderPy::claimChildrenRecursive(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
std::vector<App::DocumentObject*> children = this->getViewProviderPtr()->claimChildrenRecursive();
|
||||
Py::List ret;
|
||||
for(auto* child: children){
|
||||
if (child)
|
||||
ret.append(Py::asObject(child->getPyObject()));
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user