Merge branch 'master' of github.com:FreeCAD/FreeCAD

This commit is contained in:
Yorik van Havre
2018-11-30 10:03:45 -02:00
20 changed files with 338 additions and 173 deletions

View File

@@ -152,6 +152,18 @@ bool ViewProviderBoolean::onDelete(const std::vector<std::string> &)
return true;
}
void ViewProviderBoolean::replaceObject(App::DocumentObject* oldValue, App::DocumentObject* newValue)
{
Part::Boolean* pBool = static_cast<Part::Boolean*>(getObject());
if (oldValue == pBool->Base.getValue()) {
pBool->Base.setValue(newValue);
}
else if (oldValue == pBool->Tool.getValue()) {
pBool->Tool.setValue(newValue);
}
}
PROPERTY_SOURCE(PartGui::ViewProviderMultiFuse,PartGui::ViewProviderPart)
ViewProviderMultiFuse::ViewProviderMultiFuse()
@@ -279,6 +291,13 @@ void ViewProviderMultiFuse::dropObject(App::DocumentObject* obj)
pBool->Shapes.setValues(pShapes);
}
void ViewProviderMultiFuse::replaceObject(App::DocumentObject* oldValue, App::DocumentObject* newValue)
{
Part::MultiFuse* pBool = static_cast<Part::MultiFuse*>(getObject());
std::vector<App::DocumentObject*> pShapes = pBool->Shapes.getValues();
std::replace(pShapes.begin(), pShapes.end(), oldValue, newValue);
pBool->Shapes.setValues(pShapes);
}
PROPERTY_SOURCE(PartGui::ViewProviderMultiCommon,PartGui::ViewProviderPart)
@@ -406,3 +425,11 @@ void ViewProviderMultiCommon::dropObject(App::DocumentObject* obj)
pShapes.push_back(obj);
pBool->Shapes.setValues(pShapes);
}
void ViewProviderMultiCommon::replaceObject(App::DocumentObject* oldValue, App::DocumentObject* newValue)
{
Part::MultiFuse* pBool = static_cast<Part::MultiFuse*>(getObject());
std::vector<App::DocumentObject*> pShapes = pBool->Shapes.getValues();
std::replace(pShapes.begin(), pShapes.end(), oldValue, newValue);
pBool->Shapes.setValues(pShapes);
}

View File

@@ -44,6 +44,7 @@ public:
QIcon getIcon(void) const;
void updateData(const App::Property*);
bool onDelete(const std::vector<std::string> &);
virtual void replaceObject(App::DocumentObject*, App::DocumentObject*);
};
/// ViewProvider for the MultiFuse feature
@@ -70,6 +71,8 @@ public:
bool canDropObjects() const;
bool canDropObject(App::DocumentObject*) const;
void dropObject(App::DocumentObject*);
/** Replace an object to the view provider by drag and drop */
virtual void replaceObject(App::DocumentObject*, App::DocumentObject*);
};
/// ViewProvider for the MultiFuse feature
@@ -96,6 +99,8 @@ public:
bool canDropObjects() const;
bool canDropObject(App::DocumentObject*) const;
void dropObject(App::DocumentObject*);
/** Replace an object to the view provider by drag and drop */
virtual void replaceObject(App::DocumentObject*, App::DocumentObject*);
};

View File

@@ -154,3 +154,11 @@ void ViewProviderCompound::dropObject(App::DocumentObject* obj)
pShapes.push_back(obj);
pComp->Links.setValues(pShapes);
}
void ViewProviderCompound::replaceObject(App::DocumentObject* oldValue, App::DocumentObject* newValue)
{
Part::Compound* pBool = static_cast<Part::Compound*>(getObject());
std::vector<App::DocumentObject*> pShapes = pBool->Links.getValues();
std::replace(pShapes.begin(), pShapes.end(), oldValue, newValue);
pBool->Links.setValues(pShapes);
}

View File

@@ -48,6 +48,8 @@ public:
bool canDropObjects() const;
bool canDropObject(App::DocumentObject*) const;
void dropObject(App::DocumentObject*);
/** Replace an object to the view provider by drag and drop */
virtual void replaceObject(App::DocumentObject*, App::DocumentObject*);
protected:
void updateData(const App::Property*);