+ FEM: Support drag and drop for analysis object
This commit is contained in:
parent
bf2266aee3
commit
f460cec308
|
@ -34,6 +34,7 @@
|
|||
#include <Gui/Control.h>
|
||||
|
||||
#include <Mod/Fem/App/FemAnalysis.h>
|
||||
#include <Mod/Fem/App/FemMeshObject.h>
|
||||
|
||||
#include "TaskDlgAnalysis.h"
|
||||
|
||||
|
@ -159,6 +160,39 @@ bool ViewProviderFemAnalysis::onDelete(const std::vector<std::string> &)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ViewProviderFemAnalysis::canDragObjects() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderFemAnalysis::dragObject(App::DocumentObject* obj)
|
||||
{
|
||||
Fem::FemAnalysis* analyze = static_cast<Fem::FemAnalysis*>(getObject());
|
||||
std::vector<App::DocumentObject*> fem = analyze->Member.getValues();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = fem.begin(); it != fem.end(); ++it) {
|
||||
if (*it == obj) {
|
||||
fem.erase(it);
|
||||
analyze->Member.setValues(fem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderFemAnalysis::canDropObjects() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderFemAnalysis::dropObject(App::DocumentObject* obj)
|
||||
{
|
||||
if (!obj || !obj->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId()))
|
||||
return;
|
||||
Fem::FemAnalysis* analyze = static_cast<Fem::FemAnalysis*>(getObject());
|
||||
std::vector<App::DocumentObject*> fem = analyze->Member.getValues();
|
||||
fem.push_back(obj);
|
||||
analyze->Member.setValues(fem);
|
||||
}
|
||||
|
||||
// Python feature -----------------------------------------------------------------------
|
||||
|
||||
namespace Gui {
|
||||
|
|
|
@ -63,6 +63,18 @@ public:
|
|||
// shows solid in the tree
|
||||
virtual bool isShow(void) const{return true;}
|
||||
|
||||
/** @name Drag and drop */
|
||||
//@{
|
||||
/// Returns true if the view provider generally supports dragging objects
|
||||
bool canDragObjects() const;
|
||||
/// Starts to drag the object
|
||||
void dragObject(App::DocumentObject*);
|
||||
/// Returns true if the view provider generally accepts dropping of objects
|
||||
bool canDropObjects() const;
|
||||
/// If the dropped object type is accepted the object will be added as child
|
||||
void dropObject(App::DocumentObject*);
|
||||
//@}
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
|
Loading…
Reference in New Issue
Block a user