From e7d8a1a9a441e0dc936df8400c9a0e92fbc2314a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Thu, 11 Feb 2016 17:41:09 +0100 Subject: [PATCH] Remove ShapeBinder2D As profile based features can work with faces and wires now ShapeBinder can do everything that needed ShapeBinder2D before. --- src/Mod/PartDesign/App/AppPartDesign.cpp | 1 - src/Mod/PartDesign/App/ShapeBinder.cpp | 26 +------------------ src/Mod/PartDesign/App/ShapeBinder.h | 26 +++---------------- src/Mod/PartDesign/Gui/Command.cpp | 14 +++------- src/Mod/PartDesign/Gui/TaskFeaturePick.cpp | 11 +------- src/Mod/PartDesign/Gui/TaskShapeBinder.cpp | 19 ++++---------- .../Gui/ViewProviderShapeBinder.cpp | 2 -- 7 files changed, 14 insertions(+), 85 deletions(-) diff --git a/src/Mod/PartDesign/App/AppPartDesign.cpp b/src/Mod/PartDesign/App/AppPartDesign.cpp index 0673475d5..f701cb500 100644 --- a/src/Mod/PartDesign/App/AppPartDesign.cpp +++ b/src/Mod/PartDesign/App/AppPartDesign.cpp @@ -111,7 +111,6 @@ PyMODINIT_FUNC init_PartDesign() PartDesign::AdditiveLoft ::init(); PartDesign::SubtractiveLoft ::init(); PartDesign::ShapeBinder ::init(); - PartDesign::ShapeBinder2D ::init(); PartDesign::Plane ::init(); PartDesign::Line ::init(); PartDesign::Point ::init(); diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index 96a233104..5de9cc8f8 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -148,28 +148,4 @@ TopoShape ShapeBinder::buildShapeFromReferences( Part::Feature* obj, std::vector return base; } return base; -} - - -PROPERTY_SOURCE(PartDesign::ShapeBinder2D, Part::Part2DObject) - -ShapeBinder2D::ShapeBinder2D() { - -} - -ShapeBinder2D::~ShapeBinder2D() { - -} - -App::DocumentObjectExecReturn* ShapeBinder2D::execute(void) { - - if(! this->isRestoring()){ - - Part::Feature* obj = nullptr; - std::vector subs; - - ShapeBinder::getFilterdReferences(&Support, obj, subs); - Shape.setValue(ShapeBinder::buildShapeFromReferences(obj, subs)._Shape); - } - return Part::Part2DObject::execute(); -} +} \ No newline at end of file diff --git a/src/Mod/PartDesign/App/ShapeBinder.h b/src/Mod/PartDesign/App/ShapeBinder.h index ed1b3d76f..9aaddf70e 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.h +++ b/src/Mod/PartDesign/App/ShapeBinder.h @@ -27,15 +27,14 @@ #include #include #include -#include namespace PartDesign { -/*Those two feature are not realy a classical datum. They are fully defined shapes and not - *infinit geometries like planes and lines. Also they are not calculated by references and hence - *are not "attaced" to anything. Furthermore real shapes must be visualized. This makes it hard - *to reuse the existing datum infrastructure and a special handling foor those two types is +/*This feature is not realy a classical datum. It is a fully defined shape and not + *infinit geometrie like a plane and a line. Also it is not calculated by references and hence + *is not "attaced" to anything. Furthermore real shapes must be visualized. This makes it hard + *to reuse the existing datum infrastructure and a special handling for this type is *created. */ // TODO Add a better documentation (2015-09-11, Fat-Zer) @@ -62,23 +61,6 @@ protected: virtual App::DocumentObjectExecReturn* execute(void); }; -//this class is needed as long as sketch-based features can only work with Part2DObjects -class PartDesignExport ShapeBinder2D : public Part::Part2DObject -{ - PROPERTY_HEADER(PartDesign::ShapeBinder2D); - -public: - ShapeBinder2D(); - virtual ~ShapeBinder2D(); - - const char* getViewProviderName(void) const { - return "PartDesignGui::ViewProviderShapeBinder"; - } - -protected: - virtual App::DocumentObjectExecReturn* execute(void); -}; - } //namespace PartDesign diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 1bd32cc6b..c4c74a31b 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -245,8 +245,7 @@ void CmdPartDesignShapeBinder::activated(int iMsg) bool bEditSelected = false; if (support.getSize() == 1 && support.getValue() ){ - if (support.getValue()->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()) || - support.getValue()->isDerivedFrom(PartDesign::ShapeBinder2D::getClassTypeId())) + if (support.getValue()->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId())) bEditSelected = true; } @@ -266,16 +265,9 @@ void CmdPartDesignShapeBinder::activated(int iMsg) openCommand(tmp.c_str()); - if ( support.getValue() && - ( support.getValue()->isDerivedFrom(PartDesign::ShapeBinder2D::getClassTypeId()) || - support.getValue()->isDerivedFrom(Part::Part2DObject::getClassTypeId()) ) ) { - doCommand(Gui::Command::Doc,"App.activeDocument().addObject('%s','%s')", - "PartDesign::ShapeBinder2D",FeatName.c_str()); - } else { - doCommand(Gui::Command::Doc,"App.activeDocument().addObject('%s','%s')", + doCommand(Gui::Command::Doc,"App.activeDocument().addObject('%s','%s')", "PartDesign::ShapeBinder",FeatName.c_str()); - } - + //test if current selection fits a mode. if (support.getSize() > 0) { doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = %s", diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index 412a3189a..b7c7a7ab1 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -261,6 +261,7 @@ std::vector TaskFeaturePick::buildFeatures() { } App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::string sub, bool independent) { + App::DocumentObject* copy = nullptr; if( independent && (obj->isDerivedFrom(Sketcher::SketchObject::getClassTypeId()) || @@ -356,15 +357,6 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st datumCopy->Shape.setValue(static_cast(obj)->Shape.getValue()); } } - else if(obj->isDerivedFrom(Part::Part2DObject::getClassTypeId()) || - obj->getTypeId() == PartDesign::ShapeBinder2D::getClassTypeId()) { - copy = App::GetApplication().getActiveDocument()->addObject("PartDesign::ShapeBinder2D", name.c_str()); - - if(!independent) - static_cast(copy)->Support.setValue(obj, entity.c_str()); - else - shapeProp = &static_cast(copy)->Shape; - } else if(obj->getTypeId() == PartDesign::ShapeBinder::getClassTypeId() || obj->isDerivedFrom(Part::Feature::getClassTypeId())) { @@ -387,7 +379,6 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st return copy; } - void TaskFeaturePick::onSelectionChanged(const Gui::SelectionChanges& msg) { ui->listWidget->clearSelection(); diff --git a/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp b/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp index dd013451e..4513cef95 100644 --- a/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp @@ -82,11 +82,8 @@ TaskShapeBinder::TaskShapeBinder(ViewProviderShapeBinder *view,bool newObj, QWid Part::Feature* obj = nullptr; std::vector subs; - if(vp->getObject()->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId())) - PartDesign::ShapeBinder::getFilterdReferences(&static_cast(vp->getObject())->Support, obj, subs); - else - PartDesign::ShapeBinder::getFilterdReferences(&static_cast(vp->getObject())->Support, obj, subs); - + PartDesign::ShapeBinder::getFilterdReferences(&static_cast(vp->getObject())->Support, obj, subs); + if(obj) ui->baseEdit->setText(QString::fromUtf8(obj->getNameInDocument())); @@ -232,10 +229,7 @@ bool TaskShapeBinder::referenceSelected(const SelectionChanges& msg) const { Part::Feature* obj = nullptr; std::vector refs; - if(vp->getObject()->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId())) - PartDesign::ShapeBinder::getFilterdReferences(&static_cast(vp->getObject())->Support, obj, refs); - else - PartDesign::ShapeBinder::getFilterdReferences(&static_cast(vp->getObject())->Support, obj, refs); + PartDesign::ShapeBinder::getFilterdReferences(&static_cast(vp->getObject())->Support, obj, refs); //if we already have a object we need to ensure th new selected subref belongs to it if(obj && strcmp(msg.pObjectName, obj->getNameInDocument()) != 0) @@ -260,11 +254,8 @@ bool TaskShapeBinder::referenceSelected(const SelectionChanges& msg) const { refs.clear(); } - if(vp->getObject()->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId())) - static_cast(vp->getObject())->Support.setValue(obj, refs); - else - static_cast(vp->getObject())->Support.setValue( obj, refs); - + static_cast(vp->getObject())->Support.setValue(obj, refs); + return true; } diff --git a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp index e690da04f..003a21432 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp @@ -124,8 +124,6 @@ void ViewProviderShapeBinder::highlightReferences(const bool on, bool auxillery) if(getObject()->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId())) PartDesign::ShapeBinder::getFilterdReferences(&static_cast(getObject())->Support, obj, subs); - else if(getObject()->isDerivedFrom(PartDesign::ShapeBinder2D::getClassTypeId())) - PartDesign::ShapeBinder::getFilterdReferences(&static_cast(getObject())->Support, obj, subs); else return;