diff --git a/src/Mod/Sketcher/Gui/CMakeLists.txt b/src/Mod/Sketcher/Gui/CMakeLists.txt index e9168eba33..3320d06710 100644 --- a/src/Mod/Sketcher/Gui/CMakeLists.txt +++ b/src/Mod/Sketcher/Gui/CMakeLists.txt @@ -32,7 +32,6 @@ generate_from_xml(ViewProviderSketchGeometryExtensionPy) set(SketcherGui_UIC_SRCS TaskSketcherConstraints.ui TaskSketcherElements.ui - TaskSketcherGeneral.ui TaskSketcherMessages.ui TaskSketcherSolverAdvanced.ui TaskSketcherValidation.ui @@ -100,9 +99,6 @@ SET(SketcherGui_SRCS TaskSketcherElements.h TaskSketcherCreateCommands.cpp TaskSketcherCreateCommands.h - TaskSketcherGeneral.ui - TaskSketcherGeneral.cpp - TaskSketcherGeneral.h TaskSketcherMessages.ui TaskSketcherMessages.cpp TaskSketcherMessages.h diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp index 4e62c41cfb..bf9a7390ef 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.cpp +++ b/src/Mod/Sketcher/Gui/SketcherSettings.cpp @@ -38,7 +38,6 @@ #include "ui_SketcherSettingsDisplay.h" #include "ui_SketcherSettingsColors.h" #include "ui_SketcherSettingsDisplay.h" -#include "TaskSketcherGeneral.h" using namespace SketcherGui; @@ -49,11 +48,6 @@ SketcherSettings::SketcherSettings(QWidget* parent) : PreferencePage(parent), ui(new Ui_SketcherSettings) { ui->setupUi(this); - QGridLayout* gridLayout = new QGridLayout(ui->placeholder); - gridLayout->setSpacing(0); - gridLayout->setContentsMargins(0, 0, 0, 0); - form = new SketcherGeneralWidget(ui->placeholder); - gridLayout->addWidget(form, 0, 0, 1, 1); } /** @@ -73,7 +67,6 @@ void SketcherSettings::saveSettings() ui->checkBoxEnableEscape->onSave(); ui->checkBoxNotifyConstraintSubstitutions->onSave(); ui->checkBoxAutoRemoveRedundants->onSave(); - form->saveSettings(); } void SketcherSettings::loadSettings() @@ -85,7 +78,6 @@ void SketcherSettings::loadSettings() ui->checkBoxEnableEscape->onRestore(); ui->checkBoxNotifyConstraintSubstitutions->onRestore(); ui->checkBoxAutoRemoveRedundants->onRestore(); - form->loadSettings(); } /** diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.ui b/src/Mod/Sketcher/Gui/SketcherSettings.ui index 2d0378d903..c846dd9d90 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.ui +++ b/src/Mod/Sketcher/Gui/SketcherSettings.ui @@ -15,13 +15,6 @@ - - - Sketcher - - - - Task Panel Widgets @@ -67,7 +60,7 @@ - + Dragging performance @@ -96,7 +89,7 @@ Requires to re-enter edit mode to take effect. - + true @@ -189,7 +182,7 @@ Requires to re-enter edit mode to take effect. - + Qt::Vertical diff --git a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp index e322522560..108831ed4d 100644 --- a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp +++ b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp @@ -41,7 +41,6 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView) assert(sketchView); Constraints = new TaskSketcherConstraints(sketchView); Elements = new TaskSketcherElements(sketchView); - General = new TaskSketcherGeneral(sketchView); Messages = new TaskSketcherMessages(sketchView); SolverAdvanced = new TaskSketcherSolverAdvanced(sketchView); @@ -54,10 +53,6 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView) Content.push_back(SolverAdvanced); } - if (hGrp->GetBool("ShowSettingsWidget", true)) { - Content.push_back(General); - } - Content.push_back(Constraints); Content.push_back(Elements); @@ -65,8 +60,6 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView) Messages->hideGroupBox(); if (!hGrp->GetBool("ExpandedSolverAdvancedWidget",false)) SolverAdvanced->hideGroupBox(); - if (!hGrp->GetBool("ExpandedEditControlWidget",false)) - General->hideGroupBox(); if (!hGrp->GetBool("ExpandedConstraintsWidget",true)) Constraints->hideGroupBox(); if (!hGrp->GetBool("ExpandedElementsWidget",true)) @@ -80,10 +73,6 @@ TaskDlgEditSketch::~TaskDlgEditSketch() std::vector::iterator it = std::find(Content.begin(), Content.end(), SolverAdvanced); if (it == Content.end()) Content.push_back(SolverAdvanced); - // same thing for edit control panel - it = std::find(Content.begin(), Content.end(), General); - if (it == Content.end()) - Content.push_back(General); } //==== calls from the TaskView =============================================================== @@ -109,7 +98,6 @@ bool TaskDlgEditSketch::reject() ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); hGrp->SetBool("ExpandedMessagesWidget",Messages->isGroupVisible()); hGrp->SetBool("ExpandedSolverAdvancedWidget",SolverAdvanced->isGroupVisible()); - hGrp->SetBool("ExpandedEditControlWidget",General->isGroupVisible()); hGrp->SetBool("ExpandedConstraintsWidget",Constraints->isGroupVisible()); hGrp->SetBool("ExpandedElementsWidget",Elements->isGroupVisible()); diff --git a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h index c360af92e9..e29cc35c7e 100644 --- a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h +++ b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h @@ -29,7 +29,6 @@ #include "TaskSketcherConstraints.h" #include "TaskSketcherElements.h" -#include "TaskSketcherGeneral.h" #include "TaskSketcherMessages.h" #include "TaskSketcherSolverAdvanced.h" #include "ViewProviderSketch.h" @@ -75,7 +74,6 @@ protected: ViewProviderSketch *sketchView; TaskSketcherConstraints *Constraints; TaskSketcherElements *Elements; - TaskSketcherGeneral *General; TaskSketcherMessages *Messages; TaskSketcherSolverAdvanced *SolverAdvanced; }; diff --git a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp b/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp deleted file mode 100644 index afcec7c818..0000000000 --- a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Jürgen Riegel * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" - -#include - -#include -#include -#include -#include - -#include "ui_TaskSketcherGeneral.h" -#include "TaskSketcherGeneral.h" -#include "ViewProviderSketch.h" - - -using namespace SketcherGui; -using namespace Gui::TaskView; -namespace bp = boost::placeholders; - -SketcherGeneralWidget::SketcherGeneralWidget(QWidget *parent) - : QWidget(parent), ui(new Ui_TaskSketcherGeneral) -{ - ui->setupUi(this); - ui->renderingOrder->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); - - // connecting the needed signals - connect(ui->checkBoxAutoconstraints, &QCheckBox::toggled, - this, &SketcherGeneralWidget::emitToggleAutoconstraints); - connect(ui->checkBoxRedundantAutoconstraints, &QCheckBox::toggled, - this, &SketcherGeneralWidget::emitToggleAvoidRedundant); - ui->renderingOrder->installEventFilter(this); -} - -SketcherGeneralWidget::~SketcherGeneralWidget() -{ -} - -bool SketcherGeneralWidget::eventFilter(QObject *object, QEvent *event) -{ - if (object == ui->renderingOrder && event->type() == QEvent::ChildRemoved) { - Q_EMIT emitRenderOrderChanged(); - } - return false; -} - -void SketcherGeneralWidget::saveSettings() -{ - ui->checkBoxAutoconstraints->onSave(); - ui->checkBoxRedundantAutoconstraints->onSave(); - - saveOrderingOrder(); -} - -void SketcherGeneralWidget::saveOrderingOrder() -{ - int topid = ui->renderingOrder->item(0)->data(Qt::UserRole).toInt(); - int midid = ui->renderingOrder->item(1)->data(Qt::UserRole).toInt(); - int lowid = ui->renderingOrder->item(2)->data(Qt::UserRole).toInt(); - - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General"); - hGrp->SetInt("TopRenderGeometryId",topid); - hGrp->SetInt("MidRenderGeometryId",midid); - hGrp->SetInt("LowRenderGeometryId",lowid); -} - -void SketcherGeneralWidget::loadSettings() -{ - ui->checkBoxAutoconstraints->onRestore(); - ui->checkBoxRedundantAutoconstraints->onRestore(); - - loadOrderingOrder(); -} - -void SketcherGeneralWidget::loadOrderingOrder() -{ - ParameterGrp::handle hGrpp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General"); - - // 1->Normal Geometry, 2->Construction, 3->External - int topid = hGrpp->GetInt("TopRenderGeometryId",1); - int midid = hGrpp->GetInt("MidRenderGeometryId",2); - int lowid = hGrpp->GetInt("LowRenderGeometryId",3); - - { - QSignalBlocker block(ui->renderingOrder); - ui->renderingOrder->clear(); - - QListWidgetItem *newItem = new QListWidgetItem; - newItem->setData(Qt::UserRole, QVariant(topid)); - newItem->setText( topid==1?tr("Normal Geometry"):topid==2?tr("Construction Geometry"):tr("External Geometry")); - ui->renderingOrder->insertItem(0,newItem); - - newItem = new QListWidgetItem; - newItem->setData(Qt::UserRole, QVariant(midid)); - newItem->setText(midid==1?tr("Normal Geometry"):midid==2?tr("Construction Geometry"):tr("External Geometry")); - ui->renderingOrder->insertItem(1,newItem); - - newItem = new QListWidgetItem; - newItem->setData(Qt::UserRole, QVariant(lowid)); - newItem->setText(lowid==1?tr("Normal Geometry"):lowid==2?tr("Construction Geometry"):tr("External Geometry")); - ui->renderingOrder->insertItem(2,newItem); - } -} - -void SketcherGeneralWidget::checkAutoconstraints(bool on) -{ - ui->checkBoxAutoconstraints->setChecked(on); -} - -void SketcherGeneralWidget::checkAvoidRedundant(bool on) -{ - ui->checkBoxRedundantAutoconstraints->setChecked(on); -} - -void SketcherGeneralWidget::enableAvoidRedundant(bool on) -{ - ui->checkBoxRedundantAutoconstraints->setEnabled(on); -} - -void SketcherGeneralWidget::changeEvent(QEvent *e) -{ - QWidget::changeEvent(e); - if (e->type() == QEvent::LanguageChange) { - ui->retranslateUi(this); - } -} - -// ---------------------------------------------------------------------------- - -TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView) - : TaskBox(Gui::BitmapFactory().pixmap("document-new"),tr("Edit controls"),true, nullptr) - , sketchView(sketchView) -{ - // we need a separate container widget to add all controls to - widget = new SketcherGeneralWidget(this); - this->groupLayout()->addWidget(widget); - - { - //Blocker probably not needed as signals aren't connected yet - QSignalBlocker block(widget); - //Load default settings to get ordering order & avoid redundant values - widget->loadSettings(); - widget->checkAutoconstraints(sketchView->Autoconstraints.getValue()); - widget->checkAvoidRedundant(sketchView->AvoidRedundant.getValue()); - widget->enableAvoidRedundant(sketchView->Autoconstraints.getValue()); - } - - // connecting the needed signals - QObject::connect( - widget, &SketcherGeneralWidget::emitToggleAutoconstraints, - this , &TaskSketcherGeneral::onToggleAutoconstraints - ); - - QObject::connect( - widget, &SketcherGeneralWidget::emitToggleAvoidRedundant, - this , &TaskSketcherGeneral::onToggleAvoidRedundant - ); - - QObject::connect( - widget, &SketcherGeneralWidget::emitRenderOrderChanged, - this , &TaskSketcherGeneral::onRenderOrderChanged - ); - - Gui::Selection().Attach(this); - - Gui::Application* app = Gui::Application::Instance; - changedSketchView = app->signalChangedObject.connect(boost::bind - (&TaskSketcherGeneral::onChangedSketchView, this, bp::_1, bp::_2)); -} - -TaskSketcherGeneral::~TaskSketcherGeneral() -{ - Gui::Selection().Detach(this); -} - -void TaskSketcherGeneral::onChangedSketchView(const Gui::ViewProvider& vp, - const App::Property& prop) -{ - if (sketchView == &vp) { - if (&sketchView->Autoconstraints == &prop) { - QSignalBlocker block(widget); - widget->checkAutoconstraints(sketchView->Autoconstraints.getValue()); - widget->enableAvoidRedundant(sketchView->Autoconstraints.getValue()); - } - else if (&sketchView->AvoidRedundant == &prop) { - QSignalBlocker block(widget); - widget->checkAvoidRedundant(sketchView->AvoidRedundant.getValue()); - } - } -} - -void TaskSketcherGeneral::onToggleAutoconstraints(bool on) -{ - Base::ConnectionBlocker block(changedSketchView); - sketchView->Autoconstraints.setValue(on); - widget->enableAvoidRedundant(on); -} - -void TaskSketcherGeneral::onToggleAvoidRedundant(bool on) -{ - Base::ConnectionBlocker block(changedSketchView); - sketchView->AvoidRedundant.setValue(on); -} - -/// @cond DOXERR -void TaskSketcherGeneral::OnChange(Gui::SelectionSingleton::SubjectType &rCaller, - Gui::SelectionSingleton::MessageType Reason) -{ - Q_UNUSED(rCaller); - Q_UNUSED(Reason); - //if (Reason.Type == SelectionChanges::AddSelection || - // Reason.Type == SelectionChanges::RmvSelection || - // Reason.Type == SelectionChanges::SetSelection || - // Reason.Type == SelectionChanges::ClrSelection) { - //} -} -/// @endcond DOXERR - -void TaskSketcherGeneral::onRenderOrderChanged() -{ - widget->saveOrderingOrder(); - sketchView->updateColor(); -} - -#include "moc_TaskSketcherGeneral.cpp" diff --git a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.h b/src/Mod/Sketcher/Gui/TaskSketcherGeneral.h deleted file mode 100644 index 3e5325cb69..0000000000 --- a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.h +++ /dev/null @@ -1,104 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2009 Jürgen Riegel * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#ifndef GUI_TASKVIEW_TaskSketcherGerneral_H -#define GUI_TASKVIEW_TaskSketcherGerneral_H - -#include - -#include -#include - - -namespace App { -class Property; -} - -namespace Gui { -class ViewProvider; -} - -namespace SketcherGui { - -class Ui_TaskSketcherGeneral; -class ViewProviderSketch; - -class SketcherGeneralWidget : public QWidget -{ - Q_OBJECT - -public: - explicit SketcherGeneralWidget(QWidget *parent=nullptr); - ~SketcherGeneralWidget() override; - - bool eventFilter(QObject *object, QEvent *event) override; - - void saveSettings(); - void saveOrderingOrder(); - void loadSettings(); - void loadOrderingOrder(); - void checkAutoconstraints(bool); - void checkAvoidRedundant(bool); - void enableAvoidRedundant(bool); - -Q_SIGNALS: - void emitToggleAutoconstraints(bool); - void emitToggleAvoidRedundant(bool); - void emitRenderOrderChanged(); - -protected: - void changeEvent(QEvent *e) override; - -private: - std::unique_ptr ui; -}; - -class TaskSketcherGeneral : public Gui::TaskView::TaskBox, - public Gui::SelectionSingleton::ObserverType -{ - Q_OBJECT - -public: - explicit TaskSketcherGeneral(ViewProviderSketch *sketchView); - ~TaskSketcherGeneral() override; - /// Observer message from the Selection - void OnChange(Gui::SelectionSingleton::SubjectType &rCaller, - Gui::SelectionSingleton::MessageType Reason) override; - -public Q_SLOTS: - void onToggleAutoconstraints(bool on); - void onToggleAvoidRedundant(bool); - void onRenderOrderChanged(); - -private: - void onChangedSketchView(const Gui::ViewProvider&, - const App::Property&); - -private: - ViewProviderSketch *sketchView; - SketcherGeneralWidget* widget; - boost::signals2::scoped_connection changedSketchView; -}; - -} //namespace SketcherGui - -#endif // GUI_TASKVIEW_TaskSketcherGerneral_H diff --git a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.ui b/src/Mod/Sketcher/Gui/TaskSketcherGeneral.ui deleted file mode 100644 index 505bb417e4..0000000000 --- a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.ui +++ /dev/null @@ -1,117 +0,0 @@ - - - SketcherGui::TaskSketcherGeneral - - - - 0 - 0 - 312 - 254 - - - - Form - - - - - - true - - - Sketcher proposes automatically sensible constraints. - - - Auto constraints - - - true - - - AutoConstraints - - - Mod/Sketcher/General - - - - - - - Sketcher tries not to propose redundant auto constraints - - - Avoid redundant auto constraints - - - true - - - AvoidRedundantAutoconstraints - - - Mod/Sketcher/General - - - - - - - Rendering order (global): - - - - - - - - 0 - 0 - - - - - 12 - 60 - - - - To change, drag and drop a geometry type to top or bottom - - - true - - - QAbstractItemView::InternalMove - - - QListView::Fixed - - - false - - - - - - - - Gui::QuantitySpinBox - QWidget -
Gui/QuantitySpinBox.h
-
- - Gui::PrefCheckBox - QCheckBox -
Gui/PrefWidgets.h
-
- - Gui::PrefQuantitySpinBox - Gui::QuantitySpinBox -
Gui/PrefWidgets.h
-
-
- - -