diff --git a/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp b/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp index d7e2f1ddb2..2a84a9b3df 100644 --- a/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp @@ -128,8 +128,7 @@ void TaskGrooveParameters::onAngleChanged(double len) { PartDesign::Groove* pcGroove = static_cast(vp->getObject()); pcGroove->Angle.setValue(len); - if (updateView()) - pcGroove->getDocument()->recomputeFeature(pcGroove); + recomputeFeature(); } void TaskGrooveParameters::onAxisChanged(int num) @@ -166,24 +165,21 @@ void TaskGrooveParameters::onAxisChanged(int num) } } } - if (updateView()) - pcGroove->getDocument()->recomputeFeature(pcGroove); + recomputeFeature(); } void TaskGrooveParameters::onMidplane(bool on) { PartDesign::Groove* pcGroove = static_cast(vp->getObject()); pcGroove->Midplane.setValue(on); - if (updateView()) - pcGroove->getDocument()->recomputeFeature(pcGroove); + recomputeFeature(); } void TaskGrooveParameters::onReversed(bool on) { PartDesign::Groove* pcGroove = static_cast(vp->getObject()); pcGroove->Reversed.setValue(on); - if (updateView()) - pcGroove->getDocument()->recomputeFeature(pcGroove); + recomputeFeature(); } double TaskGrooveParameters::getAngle(void) const @@ -226,11 +222,6 @@ bool TaskGrooveParameters::getReversed(void) const return ui->checkBoxReversed->isChecked(); } -const bool TaskGrooveParameters::updateView() const -{ - return ui->checkBoxUpdateView->isChecked(); -} - TaskGrooveParameters::~TaskGrooveParameters() { delete ui; diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index 2d5e503eb4..529e553d4d 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -243,8 +243,7 @@ void TaskPadParameters::onLengthChanged(double len) { PartDesign::Pad* pcPad = static_cast(vp->getObject()); pcPad->Length.setValue(len); - if (updateView()) - pcPad->getDocument()->recomputeFeature(pcPad); + recomputeFeature(); } void TaskPadParameters::onMidplane(bool on) @@ -252,24 +251,21 @@ void TaskPadParameters::onMidplane(bool on) PartDesign::Pad* pcPad = static_cast(vp->getObject()); pcPad->Midplane.setValue(on); ui->checkBoxReversed->setEnabled(!on); - if (updateView()) - pcPad->getDocument()->recomputeFeature(pcPad); + recomputeFeature(); } void TaskPadParameters::onReversed(bool on) { PartDesign::Pad* pcPad = static_cast(vp->getObject()); pcPad->Reversed.setValue(on); - if (updateView()) - pcPad->getDocument()->recomputeFeature(pcPad); + recomputeFeature(); } void TaskPadParameters::onLength2Changed(double len) { PartDesign::Pad* pcPad = static_cast(vp->getObject()); pcPad->Length2.setValue(len); - if (updateView()) - pcPad->getDocument()->recomputeFeature(pcPad); + recomputeFeature(); } void TaskPadParameters::onModeChanged(int index) @@ -290,13 +286,12 @@ void TaskPadParameters::onModeChanged(int index) } updateUI(index); - - if (updateView()) - pcPad->getDocument()->recomputeFeature(pcPad); + recomputeFeature(); } void TaskPadParameters::onButtonFace(const bool pressed) { + TaskSketchBasedParameters::onSelectReference(pressed, false, true, false); // Update button if onButtonFace() is called explicitly ui->buttonFace->setChecked(pressed); @@ -340,11 +335,6 @@ QByteArray TaskPadParameters::getFaceName(void) const return ""; } -const bool TaskPadParameters::updateView() const -{ - return ui->checkBoxUpdateView->isChecked(); -} - TaskPadParameters::~TaskPadParameters() { delete ui; diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.h b/src/Mod/PartDesign/Gui/TaskPadParameters.h index 0c28b73747..575032319c 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.h @@ -53,7 +53,6 @@ public: TaskPadParameters(ViewProviderPad *PadView,bool newObj=false,QWidget *parent = 0); ~TaskPadParameters(); - const bool updateView() const; void saveHistory(void); void apply(); diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp index 77b2436818..c0cc3008de 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp @@ -225,8 +225,7 @@ void TaskPocketParameters::onLengthChanged(double len) { PartDesign::Pocket* pcPocket = static_cast(vp->getObject()); pcPocket->Length.setValue(len); - if (updateView()) - pcPocket->getDocument()->recomputeFeature(pcPocket); + recomputeFeature(); } void TaskPocketParameters::onMidplaneChanged(bool on) @@ -234,16 +233,14 @@ void TaskPocketParameters::onMidplaneChanged(bool on) PartDesign::Pocket* pcPocket = static_cast(vp->getObject()); pcPocket->Midplane.setValue(on); ui->checkBoxReversed->setEnabled(!on); - if (updateView()) - pcPocket->getDocument()->recomputeFeature(pcPocket); + recomputeFeature(); } void TaskPocketParameters::onReversedChanged(bool on) { PartDesign::Pocket* pcPocket = static_cast(vp->getObject()); pcPocket->Reversed.setValue(on); - if (updateView()) - pcPocket->getDocument()->recomputeFeature(pcPocket); + recomputeFeature(); } void TaskPocketParameters::onModeChanged(int index) @@ -280,13 +277,11 @@ void TaskPocketParameters::onModeChanged(int index) } updateUI(index); - - if (updateView()) - pcPocket->getDocument()->recomputeFeature(pcPocket); + recomputeFeature(); } void TaskPocketParameters::onButtonFace(const bool pressed) { - TaskSketchBasedParameters::onButtonFace(pressed); + TaskSketchBasedParameters::onSelectReference(pressed, false, true, false); // Update button if onButtonFace() is called explicitly ui->buttonFace->setChecked(pressed); @@ -320,11 +315,6 @@ QByteArray TaskPocketParameters::getFaceName(void) const return ""; } -const bool TaskPocketParameters::updateView() const -{ - return ui->checkBoxUpdateView->isChecked(); -} - TaskPocketParameters::~TaskPocketParameters() { delete ui; diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.h b/src/Mod/PartDesign/Gui/TaskPocketParameters.h index 749129e66c..77cd96d8ec 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.h @@ -55,7 +55,6 @@ public: bool getReversed(void) const; QByteArray getFaceName(void) const; - const bool updateView() const; void apply(); private Q_SLOTS: diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp index dcf9ddc85c..669f440e11 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp @@ -58,27 +58,10 @@ using namespace Gui; TaskSketchBasedParameters::TaskSketchBasedParameters(ViewProvider *vp, QWidget *parent, const std::string& pixmapname, const QString& parname) : TaskBox(Gui::BitmapFactory().pixmap(pixmapname.c_str()),parname,true, parent), - vp(vp) + vp(vp), blockUpdate(false) { } -/* -App::DocumentObject* TaskSketchBasedParameters::getBaseFeature() -{ - PartDesign::SketchBased* pcSketchBased = static_cast(vp->getObject()); - App::DocumentObject* baseFeature = pcSketchBased->BaseFeature.getValue(); - if (baseFeature == NULL) { - if (ActivePartObject != NULL) { - baseFeature = ActivePartObject->getPrevSolidFeature(pcSketchBased, false); - } - if (baseFeature == NULL) { - // For legacy features - baseFeature = pcSketchBased->getSupport(); - } - } - - return baseFeature; -}*/ const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChanges& msg) { @@ -101,13 +84,12 @@ const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChan std::vector upToFaces(1,subname); pcSketchBased->UpToFace.setValue(selObj, upToFaces); - if (updateView()) - pcSketchBased->getDocument()->recomputeFeature(pcSketchBased); + recomputeFeature(); return refStr; } -void TaskSketchBasedParameters::onButtonFace(const bool pressed) { +void TaskSketchBasedParameters::onSelectReference(const bool pressed, const bool edge, const bool face, const bool planar) { // Note: Even if there is no solid, App::Plane and Part::Datum can still be selected App::DocumentObject* solid = PartDesignGui::ActivePartObject->getPrevSolidFeature(NULL, false); PartDesign::SketchBased* pcSketchBased = static_cast(vp->getObject()); @@ -120,7 +102,7 @@ void TaskSketchBasedParameters::onButtonFace(const bool pressed) { } Gui::Selection().clearSelection(); Gui::Selection().addSelectionGate - (new ReferenceSelection(solid, false, true, false)); + (new ReferenceSelection(solid, edge, face, planar)); } else { Gui::Selection().rmvSelectionGate(); Gui::Document* doc = Gui::Application::Instance->activeDocument(); @@ -168,8 +150,7 @@ const QByteArray TaskSketchBasedParameters::onFaceName(const QString& text) std::vector upToFaces(1,ss.str()); PartDesign::SketchBased* pcSketchBased = static_cast(vp->getObject()); pcSketchBased->UpToFace.setValue(obj, upToFaces); - if (updateView()) - pcSketchBased->getDocument()->recomputeFeature(pcSketchBased); + recomputeFeature(); return QByteArray(ss.str().c_str()); } @@ -188,7 +169,13 @@ QString TaskSketchBasedParameters::getFaceReference(const QString& obj, const QS void TaskSketchBasedParameters::onUpdateView(bool on) { - if (on) { + blockUpdate = !on; + recomputeFeature(); +} + +void TaskSketchBasedParameters::recomputeFeature() +{ + if (!blockUpdate) { PartDesign::SketchBased* pcSketchBased = static_cast(vp->getObject()); pcSketchBased->getDocument()->recomputeFeature(pcSketchBased); } diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.h b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.h index 757b818256..f72fe4cf23 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.h +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.h @@ -46,21 +46,21 @@ public: const std::string& pixmapname, const QString& parname); ~TaskSketchBasedParameters(); - //App::DocumentObject* getBaseFeature(); - protected: void onSelectionChanged(const Gui::SelectionChanges& msg)=0; const QString onAddSelection(const Gui::SelectionChanges& msg); - void onButtonFace(const bool pressed = true); + void onSelectReference(const bool pressed, const bool edge, const bool face, const bool planar); const QByteArray onFaceName(const QString& text); QString getFaceReference(const QString& obj, const QString& sub) const; - virtual const bool updateView() const=0; + void recomputeFeature(); protected Q_SLOTS: void onUpdateView(bool on); protected: ViewProvider *vp; + /// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature() + bool blockUpdate; }; class TaskDlgSketchBasedParameters : public Gui::TaskView::TaskDialog