diff --git a/src/Mod/Assembly/Gui/ViewProvider.h b/src/Mod/Assembly/Gui/ViewProvider.h
index fd76f56ab2..7cc1a3a7f9 100644
--- a/src/Mod/Assembly/Gui/ViewProvider.h
+++ b/src/Mod/Assembly/Gui/ViewProvider.h
@@ -48,6 +48,7 @@ public:
virtual bool doubleClicked(void);
private:
+ /// group node for all children collected through claimChildren3D(), reused by all Assembly ViewProviders
SoGroup *pcChildren;
};
diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp
index 0b5bbb8308..0af02620ef 100644
--- a/src/Mod/PartDesign/App/Body.cpp
+++ b/src/Mod/PartDesign/App/Body.cpp
@@ -27,6 +27,7 @@
#include
+#include "Feature.h"
#include "Body.h"
#include "BodyPy.h"
@@ -52,7 +53,23 @@ short Body::mustExecute() const
App::DocumentObjectExecReturn *Body::execute(void)
{
-
+ // TODO right selection for Body
+ App::DocumentObject* link = Tip.getValue();
+ if (!link)
+ //return new App::DocumentObjectExecReturn("No object!");
+ return App::DocumentObject::StdReturn;
+ if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
+ return new App::DocumentObjectExecReturn("Linked object is not a PartDesign object");
+ //return App::DocumentObject::StdReturn;
+ // get the shape of the tip
+ const Part::TopoShape& TipShape = static_cast(link)->Shape.getShape();
+ if (TipShape._Shape.IsNull())
+ //return new App::DocumentObjectExecReturn("empty shape");
+ return App::DocumentObject::StdReturn;
+
+ Shape.setValue(TipShape);
+
+
return App::DocumentObject::StdReturn;
}
diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp
index 94c6c83c3c..868229ea5b 100644
--- a/src/Mod/PartDesign/Gui/Command.cpp
+++ b/src/Mod/PartDesign/Gui/Command.cpp
@@ -75,21 +75,22 @@ void validateSketches(std::vector& sketches, const bool su
std::vector::iterator s = sketches.begin();
while (s != sketches.end()) {
- // Check whether this sketch is already being used by another feature
- std::vector ref = (*s)->getInList();
- std::vector::iterator r = ref.begin();
- while (r != ref.end()) {
- if (!(*r)->getTypeId().isDerivedFrom(PartDesign::SketchBased().getClassTypeId())) {
- r = ref.erase(r);
- continue;
- }
- ++r;
- }
- if (!ref.empty()) {
- // TODO: Display some information message that this sketch was removed?
- s = sketches.erase(s);
- continue;
- }
+ // sketch is allways part of the body first.
+ //// Check whether this sketch is already being used by another feature
+ //std::vector ref = (*s)->getInList();
+ //std::vector::iterator r = ref.begin();
+ //while (r != ref.end()) {
+ // if (!(*r)->getTypeId().isDerivedFrom(PartDesign::SketchBased().getClassTypeId())) {
+ // r = ref.erase(r);
+ // continue;
+ // }
+ // ++r;
+ //}
+ //if (!ref.empty()) {
+ // // TODO: Display some information message that this sketch was removed?
+ // s = sketches.erase(s);
+ // continue;
+ //}
// Check whether the sketch shape is valid
Part::Part2DObject* sketch = static_cast(*s);
diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp
index 0d2eb1412f..1374d26397 100644
--- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp
+++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp
@@ -41,15 +41,56 @@ ViewProviderBody::ViewProviderBody()
{
pcBodyChildren = new SoGroup();
pcBodyChildren->ref();
-
+ pcBodyTip = new SoGroup();
+ pcBodyTip->ref();
}
ViewProviderBody::~ViewProviderBody()
{
pcBodyChildren->unref();
pcBodyChildren = 0;
+ pcBodyTip->unref();
+ pcBodyTip = 0;
}
+
+void ViewProviderBody::attach(App::DocumentObject *pcFeat)
+{
+ // call parent attach method
+ ViewProviderPart::attach(pcFeat);
+
+
+ // putting all together with the switch
+ addDisplayMaskMode(pcBodyTip, "Body");
+ addDisplayMaskMode(pcBodyChildren, "Through");
+}
+
+void ViewProviderBody::setDisplayMode(const char* ModeName)
+{
+ if ( strcmp("Body",ModeName)==0 )
+ setDisplayMaskMode("Body");
+ if ( strcmp("Main",ModeName)==0 )
+ setDisplayMaskMode("Main");
+ if ( strcmp("Through",ModeName)==0 )
+ setDisplayMaskMode("Through");
+
+ ViewProviderGeometryObject::setDisplayMode( ModeName );
+}
+
+std::vector ViewProviderBody::getDisplayModes(void) const
+{
+ // get the modes of the father
+ std::vector StrList = ViewProviderGeometryObject::getDisplayModes();
+
+ // add your own modes
+ StrList.push_back("Through");
+ StrList.push_back("Body");
+
+ return StrList;
+}
+
+
+
bool ViewProviderBody::doubleClicked(void)
{
// assure the PartDesign workbench
diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.h b/src/Mod/PartDesign/Gui/ViewProviderBody.h
index d416d01298..667baf7522 100644
--- a/src/Mod/PartDesign/Gui/ViewProviderBody.h
+++ b/src/Mod/PartDesign/Gui/ViewProviderBody.h
@@ -29,6 +29,12 @@
namespace PartDesignGui {
+/** ViewProvider of the Body feature
+ * This class manage the visual apperance of the features in the
+ * Body feature. That mean while editing only the tip feature is
+ * visible. If the Body is not active it shows only the result shape (tip).
+ * \author jriegel
+ */
class PartDesignGuiExport ViewProviderBody : public PartGui::ViewProviderPart
{
PROPERTY_HEADER(PartGui::ViewProviderBody);
@@ -38,6 +44,11 @@ public:
ViewProviderBody();
/// destructor
virtual ~ViewProviderBody();
+
+ virtual void attach(App::DocumentObject *);
+ virtual void setDisplayMode(const char* ModeName);
+ /// returns a list of all possible modes
+ virtual std::vector getDisplayModes(void) const;
virtual bool doubleClicked(void);
std::vector claimChildren(void)const;
@@ -47,7 +58,10 @@ public:
std::vector claimChildren3D(void)const;
private:
+ /// group used to store children collected by claimChildren3D()
SoGroup *pcBodyChildren;
+ /// group used to show the tip element in "edit" mode
+ SoGroup *pcBodyTip;
};