FEM: Correctly implement Drag/Drop for post objects
This commit is contained in:
committed by
Benjamin Nauck
parent
3f87627484
commit
f90b7a5755
@@ -143,6 +143,13 @@ void FemPostGroupExtension::onExtendedUnsetupObject()
|
||||
}
|
||||
}
|
||||
|
||||
bool FemPostGroupExtension::allowObject(App::DocumentObject* obj)
|
||||
{
|
||||
// only filters may be added
|
||||
return obj->isDerivedFrom(Fem::FemPostFilter::getClassTypeId());
|
||||
}
|
||||
|
||||
|
||||
void FemPostGroupExtension::recomputeChildren()
|
||||
{
|
||||
for (const auto& obj : Group.getValues()) {
|
||||
|
||||
@@ -59,6 +59,7 @@ public:
|
||||
protected:
|
||||
void extensionOnChanged(const App::Property* p) override;
|
||||
void onExtendedUnsetupObject() override;
|
||||
bool allowObject(App::DocumentObject* obj) override;
|
||||
|
||||
private:
|
||||
bool m_blockChange = false;
|
||||
|
||||
@@ -245,6 +245,18 @@ Fem::FemPostFunctionProvider* FemPostPipeline::getFunctionProvider() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool FemPostPipeline::allowObject(App::DocumentObject* obj)
|
||||
{
|
||||
// we additionally allow FunctionPRoviders to be added
|
||||
if (obj->isDerivedFrom(FemPostFunctionProvider::getClassTypeId())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// and all standart Post objects the group can handle
|
||||
return FemPostGroupExtension::allowObject(obj);
|
||||
}
|
||||
|
||||
|
||||
bool FemPostPipeline::canRead(Base::FileInfo File)
|
||||
{
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ public:
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop) override;
|
||||
bool allowObject(App::DocumentObject* obj) override;
|
||||
|
||||
private:
|
||||
App::Enumeration m_frameEnum;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "TaskPostBoxes.h"
|
||||
#include "ViewProviderFemPostBranchFilter.h"
|
||||
#include <Mod/Fem/App/FemPostGroupExtension.h>
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
@@ -51,3 +52,17 @@ void ViewProviderFemPostBranchFilter::setupTaskDialog(TaskDlgPost* dlg)
|
||||
FemGui::ViewProviderFemPostObject::setupTaskDialog(dlg);
|
||||
}
|
||||
|
||||
bool ViewProviderFemPostBranchFilter::acceptReorderingObjects() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ViewProviderFemPostBranchFilter::canDragObjectToTarget(App::DocumentObject* obj, App::DocumentObject* target) const {
|
||||
|
||||
// allow drag only to other post groups
|
||||
if (target) {
|
||||
return target->hasExtension(Fem::FemPostGroupExtension::getExtensionClassTypeId());
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ public:
|
||||
protected:
|
||||
virtual void setupTaskDialog(TaskDlgPost* dlg) override;
|
||||
|
||||
// change default group drag/drop behaviour sligthly
|
||||
bool acceptReorderingObjects() const override;
|
||||
bool canDragObjectToTarget(App::DocumentObject* obj, App::DocumentObject* target) const override;
|
||||
|
||||
// override, to not show/hide children as the parent is shown/hidden like normal groups
|
||||
void extensionHide() override {};
|
||||
void extensionShow() override {};
|
||||
|
||||
@@ -229,6 +229,22 @@ void ViewProviderFemPostPipeline::setupTaskDialog(TaskDlgPost* dlg)
|
||||
}
|
||||
|
||||
|
||||
bool ViewProviderFemPostPipeline::acceptReorderingObjects() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ViewProviderFemPostPipeline::canDragObjectToTarget(App::DocumentObject* obj, App::DocumentObject* target) const {
|
||||
|
||||
// allow drag only to other post groups
|
||||
if (target) {
|
||||
return target->hasExtension(Fem::FemPostGroupExtension::getExtensionClassTypeId());
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PyObject* ViewProviderFemPostPipeline::getPyObject()
|
||||
{
|
||||
if (!pyViewObject) {
|
||||
|
||||
@@ -55,6 +55,10 @@ protected:
|
||||
void updateFunctionSize();
|
||||
virtual void setupTaskDialog(TaskDlgPost* dlg) override;
|
||||
|
||||
// change default group drag/drop behaviour sligthly
|
||||
bool acceptReorderingObjects() const override;
|
||||
bool canDragObjectToTarget(App::DocumentObject* obj, App::DocumentObject* target) const override;
|
||||
|
||||
// override, to not show/hide children as the parent is shown/hidden like normal groups
|
||||
void extensionHide() override {};
|
||||
void extensionShow() override {};
|
||||
|
||||
Reference in New Issue
Block a user