From 266a36bb941a1b30420dc2053ffc22eba2d214b4 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Fri, 11 Sep 2015 05:53:22 +0300 Subject: [PATCH] PartDesign/TaskLoftParameters: Added UpdateView checkbox +cleanup --- src/Mod/PartDesign/Gui/TaskLoftParameters.cpp | 85 +++++-------------- src/Mod/PartDesign/Gui/TaskLoftParameters.h | 10 +-- src/Mod/PartDesign/Gui/TaskLoftParameters.ui | 21 ++++- 3 files changed, 43 insertions(+), 73 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp index 7d49cd5fd3..e6dd7d4733 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp @@ -71,6 +71,8 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool newObj, Q this, SLOT(onRuled(bool))); connect(ui->checkBoxClosed, SIGNAL(toggled(bool)), this, SLOT(onClosed(bool))); + connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)), + this, SLOT(onUpdateView(bool))); this->groupLayout()->addWidget(proxy); @@ -78,12 +80,10 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft *LoftView,bool newObj, Q for(QWidget* child : proxy->findChildren()) child->blockSignals(true); - - // activate and de-activate dialog elements as appropriate for(QWidget* child : proxy->findChildren()) child->blockSignals(false); - + updateUI(0); } @@ -106,12 +106,12 @@ void TaskLoftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) else if (selectionMode == refRemove) { QString objn = QString::fromStdString(msg.pObjectName); if(!objn.isEmpty()) - removeFromListWidget(ui->listWidgetReferences, objn); + removeFromListWidget(ui->listWidgetReferences, objn); } clearButtons(); //static_cast(vp)->highlightReferences(false, true); recomputeFeature(); - } + } clearButtons(); exitSelectionMode(); } @@ -120,7 +120,6 @@ void TaskLoftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) bool TaskLoftParameters::referenceSelected(const Gui::SelectionChanges& msg) const { - if ((msg.Type == Gui::SelectionChanges::AddSelection) && ( (selectionMode == refAdd) || (selectionMode == refRemove))) { @@ -128,14 +127,14 @@ bool TaskLoftParameters::referenceSelected(const Gui::SelectionChanges& msg) con return false; // not allowed to reference ourself - const char* fname = vp->getObject()->getNameInDocument(); + const char* fname = vp->getObject()->getNameInDocument(); if (strcmp(msg.pObjectName, fname) == 0) return false; - - //every selection needs to be a profile in itself, hence currently only full objects are + + //every selection needs to be a profile in itself, hence currently only full objects are //supported, not individual edges of a part - - //change the references + + //change the references std::vector refs = static_cast(vp->getObject())->Sections.getValues(); App::DocumentObject* obj = vp->getObject()->getDocument()->getObject(msg.pObjectName); std::vector::iterator f = std::find(refs.begin(), refs.end(), obj); @@ -150,7 +149,7 @@ bool TaskLoftParameters::referenceSelected(const Gui::SelectionChanges& msg) con refs.erase(f); else return false; - } + } static_cast(vp->getObject())->Sections.setValues(refs); return true; @@ -239,7 +238,7 @@ void TaskLoftParameters::onRuled(bool val) { void TaskLoftParameters::onRefButtonAdd(bool checked) { if (checked) { - Gui::Selection().clearSelection(); + Gui::Selection().clearSelection(); selectionMode = refAdd; //static_cast(vp)->highlightReferences(true, true); } @@ -248,13 +247,14 @@ void TaskLoftParameters::onRefButtonAdd(bool checked) { void TaskLoftParameters::onRefButtonRemvove(bool checked) { if (checked) { - Gui::Selection().clearSelection(); + Gui::Selection().clearSelection(); selectionMode = refRemove; //static_cast(vp)->highlightReferences(true, true); } } + //************************************************************************** //************************************************************************** // TaskDialog @@ -271,60 +271,17 @@ TaskDlgLoftParameters::TaskDlgLoftParameters(ViewProviderLoft *LoftView,bool new TaskDlgLoftParameters::~TaskDlgLoftParameters() { +} + +bool TaskDlgLoftParameters::accept() +{ + // TODO Fill this with commands (2015-09-11, Fat-Zer) + + return TaskDlgSketchBasedParameters::accept (); } //==== calls from the TaskView =============================================================== -bool TaskDlgLoftParameters::accept() -{ - std::string name = vp->getObject()->getNameInDocument(); - - try { - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); - if (!vp->getObject()->isValid()) - throw Base::Exception(vp->getObject()->getStatusString()); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - Gui::Command::commitCommand(); - } - catch (const Base::Exception& e) { - QMessageBox::warning(parameter, tr("Input error"), QString::fromUtf8(e.what())); - return false; - } - - return true; -} - -//bool TaskDlgLoftParameters::reject() -//{ -// // get the support and Sketch -// PartDesign::Loft* pcLoft = static_cast(LoftView->getObject()); -// Sketcher::SketchObject *pcSketch = 0; -// App::DocumentObject *pcSupport = 0; -// if (pcLoft->Sketch.getValue()) { -// pcSketch = static_cast(pcLoft->Sketch.getValue()); -// pcSupport = pcSketch->Support.getValue(); -// } -// -// // roll back the done things -// Gui::Command::abortCommand(); -// Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); -// -// // if abort command deleted the object the support is visible again -// if (!Gui::Application::Instance->getViewProvider(pcLoft)) { -// if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch)) -// Gui::Application::Instance->getViewProvider(pcSketch)->show(); -// if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport)) -// Gui::Application::Instance->getViewProvider(pcSupport)->show(); -// } -// -// //Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); -// //Gui::Command::commitCommand(); -// -// return true; -//} - - - #include "moc_TaskLoftParameters.cpp" diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.h b/src/Mod/PartDesign/Gui/TaskLoftParameters.h index db1e808147..42bb147145 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.h +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.h @@ -42,8 +42,7 @@ namespace Gui { class ViewProvider; } -namespace PartDesignGui { - +namespace PartDesignGui { class TaskLoftParameters : public TaskSketchBasedParameters @@ -59,7 +58,7 @@ private Q_SLOTS: void onRefButtonRemvove(bool); void onClosed(bool); void onRuled(bool); - + protected: void changeEvent(QEvent *e); @@ -74,7 +73,7 @@ private: private: QWidget* proxy; Ui_TaskLoftParameters* ui; - + enum selectionModes { none, refAdd, refRemove }; selectionModes selectionMode = none; }; @@ -91,11 +90,8 @@ public: ViewProviderLoft* getLoftView() const { return static_cast(vp); } - -public: /// is called by the framework if the dialog is accepted (Ok) virtual bool accept(); - /// is called by the framework if the dialog is rejected (Cancel) protected: TaskLoftParameters *parameter; diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.ui b/src/Mod/PartDesign/Gui/TaskLoftParameters.ui index e4d464a4ef..ce9d7c8bbf 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.ui @@ -6,8 +6,8 @@ 0 0 - 285 - 305 + 262 + 270 @@ -74,6 +74,23 @@ + + + + Qt::Horizontal + + + + + + + Update view + + + true + + +