From ee7f50a554acc7cda8d7b7c2a4426b9f7948dcb3 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Wed, 2 Oct 2013 21:35:40 +0200 Subject: [PATCH] Allow selecting and removing fillet and chamfer references in the dialog --- .../PartDesign/Gui/TaskChamferParameters.cpp | 115 +++++++++++------- .../PartDesign/Gui/TaskChamferParameters.h | 52 ++------ .../Gui/TaskChamferParameters.h.orig | 90 ++++++++++++++ .../PartDesign/Gui/TaskChamferParameters.ui | 35 +++++- .../PartDesign/Gui/TaskDressUpParameters.h | 7 +- .../PartDesign/Gui/TaskFilletParameters.cpp | 115 +++++++++++------- src/Mod/PartDesign/Gui/TaskFilletParameters.h | 54 ++------ .../Gui/TaskFilletParameters.h.orig | 90 ++++++++++++++ .../PartDesign/Gui/TaskFilletParameters.ui | 31 ++++- .../PartDesign/Gui/ViewProviderChamfer.cpp | 75 +++--------- src/Mod/PartDesign/Gui/ViewProviderChamfer.h | 15 +-- src/Mod/PartDesign/Gui/ViewProviderFillet.cpp | 74 +++-------- src/Mod/PartDesign/Gui/ViewProviderFillet.h | 18 +-- 13 files changed, 441 insertions(+), 330 deletions(-) create mode 100644 src/Mod/PartDesign/Gui/TaskChamferParameters.h.orig create mode 100644 src/Mod/PartDesign/Gui/TaskFilletParameters.h.orig diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index 58bda2c58..a0d53d1a7 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -50,8 +50,8 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskChamferParameters */ -TaskChamferParameters::TaskChamferParameters(ViewProviderChamfer *ChamferView,QWidget *parent) - : TaskBox(Gui::BitmapFactory().pixmap("Part_Chamfer"),tr("Chamfer parameters"),true, parent),ChamferView(ChamferView) +TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView,QWidget *parent) + : TaskDressUpParameters(DressUpView, parent) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -61,10 +61,14 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderChamfer *ChamferView,QW connect(ui->chamferDistance, SIGNAL(valueChanged(double)), this, SLOT(onLengthChanged(double))); + connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefAdd(bool))); + connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefRemove(bool))); this->groupLayout()->addWidget(proxy); - PartDesign::Chamfer* pcChamfer = static_cast(ChamferView->getObject()); + PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); double r = pcChamfer->Size.getValue(); ui->chamferDistance->setUnit(Base::Unit::Length); @@ -73,11 +77,55 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderChamfer *ChamferView,QW ui->chamferDistance->selectNumber(); ui->chamferDistance->bind(pcChamfer->Size); QMetaObject::invokeMethod(ui->chamferDistance, "setFocus", Qt::QueuedConnection); + std::vector strings = pcChamfer->Base.getSubValues(); + for (std::vector::const_iterator i = strings.begin(); i != strings.end(); i++) + { + ui->listWidgetReferences->insertItem(0, QString::fromStdString(*i)); + } + // Create context menu + QAction* action = new QAction(tr("Remove"), this); + ui->listWidgetReferences->addAction(action); + connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted())); + ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); +} + +void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg) +{ + if (selectionMode == none) + return; + + if (msg.Type == Gui::SelectionChanges::AddSelection) { + if (referenceSelected(msg)) { + if (selectionMode == refAdd) + ui->listWidgetReferences->insertItem(0, QString::fromStdString(msg.pSubName)); + else + removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName); + clearButtons(none); + exitSelectionMode(); + } + } +} + +void TaskChamferParameters::clearButtons(const selectionModes notThis) +{ + if (notThis != refAdd) ui->buttonRefAdd->setChecked(false); + if (notThis != refRemove) ui->buttonRefRemove->setChecked(false); +} + +void TaskChamferParameters::onRefDeleted(void) +{ + PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); + App::DocumentObject* base = pcChamfer->Base.getValue(); + std::vector refs = pcChamfer->Base.getSubValues(); + refs.erase(refs.begin() + ui->listWidgetReferences->currentRow()); + pcChamfer->Base.setValue(base, refs); + ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow()); + pcChamfer->getDocument()->recomputeFeature(pcChamfer); } void TaskChamferParameters::onLengthChanged(double len) { - PartDesign::Chamfer* pcChamfer = static_cast(ChamferView->getObject()); + PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); pcChamfer->Size.setValue(len); pcChamfer->getDocument()->recomputeFeature(pcChamfer); } @@ -89,6 +137,7 @@ double TaskChamferParameters::getLength(void) const TaskChamferParameters::~TaskChamferParameters() { + Gui::Selection().rmvSelectionGate(); delete ui; } @@ -102,12 +151,13 @@ void TaskChamferParameters::changeEvent(QEvent *e) void TaskChamferParameters::apply() { - std::string name = ChamferView->getObject()->getNameInDocument(); + std::string name = DressUpView->getObject()->getNameInDocument(); //Gui::Command::openCommand("Chamfer changed"); ui->chamferDistance->apply(); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); + Gui::Command::commitCommand(); } @@ -116,11 +166,10 @@ void TaskChamferParameters::apply() // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgChamferParameters::TaskDlgChamferParameters(ViewProviderChamfer *ChamferView) - : TaskDialog(),ChamferView(ChamferView) +TaskDlgChamferParameters::TaskDlgChamferParameters(ViewProviderChamfer *DressUpView) + : TaskDlgDressUpParameters(DressUpView) { - assert(ChamferView); - parameter = new TaskChamferParameters(ChamferView); + parameter = new TaskChamferParameters(DressUpView); Content.push_back(parameter); } @@ -133,48 +182,20 @@ TaskDlgChamferParameters::~TaskDlgChamferParameters() //==== calls from the TaskView =============================================================== -void TaskDlgChamferParameters::open() -{ - // a transaction is already open at creation time of the chamfer - if (!Gui::Command::hasPendingCommand()) { - QString msg = tr("Edit chamfer"); - Gui::Command::openCommand((const char*)msg.toUtf8()); - } -} - -void TaskDlgChamferParameters::clicked(int) -{ - -} - +//void TaskDlgChamferParameters::open() +//{ +// // a transaction is already open at creation time of the chamfer +// if (!Gui::Command::hasPendingCommand()) { +// QString msg = tr("Edit chamfer"); +// Gui::Command::openCommand((const char*)msg.toUtf8()); +// } +//} bool TaskDlgChamferParameters::accept() { + parameter->showObject(); parameter->apply(); - return true; + return TaskDlgDressUpParameters::accept(); } -bool TaskDlgChamferParameters::reject() -{ - // role back the done things - Gui::Command::abortCommand(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - - // Body housekeeping - if (ActivePartObject != NULL) { - // Make the new Tip and the previous solid feature visible again - App::DocumentObject* tip = ActivePartObject->Tip.getValue(); - App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature(); - if (tip != NULL) { - Gui::Application::Instance->getViewProvider(tip)->show(); - if ((tip != prev) && (prev != NULL)) - Gui::Application::Instance->getViewProvider(prev)->show(); - } - } - - return true; -} - - - #include "moc_TaskChamferParameters.cpp" diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.h b/src/Mod/PartDesign/Gui/TaskChamferParameters.h index 20d16bd39..5826c8fdf 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.h +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.h @@ -24,83 +24,49 @@ #ifndef GUI_TASKVIEW_TaskChamferParameters_H #define GUI_TASKVIEW_TaskChamferParameters_H -#include -#include -#include - +#include "TaskDressUpParameters.h" #include "ViewProviderChamfer.h" class Ui_TaskChamferParameters; -namespace App { -class Property; -} - -namespace Gui { -class ViewProvider; -} - - namespace PartDesignGui { -class TaskChamferParameters : public Gui::TaskView::TaskBox +class TaskChamferParameters : public TaskDressUpParameters { Q_OBJECT public: - TaskChamferParameters(ViewProviderChamfer *ChamferView, QWidget *parent=0); + TaskChamferParameters(ViewProviderDressUp *DressUpView, QWidget *parent=0); ~TaskChamferParameters(); - void apply(); + virtual void apply(); private Q_SLOTS: void onLengthChanged(double); + void onRefDeleted(void); protected: + virtual void clearButtons(const selectionModes notThis); void changeEvent(QEvent *e); + virtual void onSelectionChanged(const Gui::SelectionChanges& msg); double getLength(void) const; private: - -private: - QWidget* proxy; Ui_TaskChamferParameters* ui; - ViewProviderChamfer *ChamferView; }; /// simulation dialog for the TaskView -class TaskDlgChamferParameters : public Gui::TaskView::TaskDialog +class TaskDlgChamferParameters : public TaskDlgDressUpParameters { Q_OBJECT public: - TaskDlgChamferParameters(ViewProviderChamfer *ChamferView); + TaskDlgChamferParameters(ViewProviderChamfer *DressUpView); ~TaskDlgChamferParameters(); - ViewProviderChamfer* getChamferView() const - { return ChamferView; } - - public: - /// is called the TaskView when the dialog is opened - virtual void open(); - /// is called by the framework if an button is clicked which has no accept or reject role - virtual void clicked(int); /// 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) - virtual bool reject(); - virtual bool isAllowedAlterDocument(void) const - { return false; } - - /// returns for Close and Help button - virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const - { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; } - -protected: - ViewProviderChamfer *ChamferView; - - TaskChamferParameters *parameter; }; } //namespace PartDesignGui diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.h.orig b/src/Mod/PartDesign/Gui/TaskChamferParameters.h.orig new file mode 100644 index 000000000..517790999 --- /dev/null +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.h.orig @@ -0,0 +1,90 @@ +/*************************************************************************** + * Copyright (c) 2011 Juergen 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_TaskChamferParameters_H +#define GUI_TASKVIEW_TaskChamferParameters_H + +#include "TaskDressUpParameters.h" +#include "ViewProviderChamfer.h" + +class Ui_TaskChamferParameters; + +namespace PartDesignGui { + +class TaskChamferParameters : public TaskDressUpParameters +{ + Q_OBJECT + +public: + TaskChamferParameters(ViewProviderDressUp *DressUpView, QWidget *parent=0); + ~TaskChamferParameters(); + + virtual void apply(); + +private Q_SLOTS: + void onLengthChanged(double); + void onRefDeleted(void); + +protected: + virtual void clearButtons(const selectionModes notThis); + void changeEvent(QEvent *e); + virtual void onSelectionChanged(const Gui::SelectionChanges& msg); + double getLength(void) const; + +private: + Ui_TaskChamferParameters* ui; +}; + +/// simulation dialog for the TaskView +class TaskDlgChamferParameters : public TaskDlgDressUpParameters +{ + Q_OBJECT + +public: + TaskDlgChamferParameters(ViewProviderChamfer *DressUpView); + ~TaskDlgChamferParameters(); + +public: + /// is called by the framework if the dialog is accepted (Ok) + virtual bool accept(); +<<<<<<< 61d7568d0ff2d3e87f1abb738517f4294c5a6d2e + /// is called by the framework if the dialog is rejected (Cancel) + virtual bool reject(); + virtual bool isAllowedAlterDocument(void) const + { return false; } + + /// returns for Close and Help button + virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const + { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; } + +protected: + ViewProviderChamfer *ChamferView; + + TaskChamferParameters *parameter; +======= +>>>>>>> Allow selecting and removing fillet and chamfer references in the dialog +}; + +} //namespace PartDesignGui + +#endif // GUI_TASKVIEW_TaskChamferParameters_H diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.ui b/src/Mod/PartDesign/Gui/TaskChamferParameters.ui index bcb4314ca..9c958181f 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.ui @@ -6,8 +6,8 @@ 0 0 - 135 - 40 + 182 + 185 @@ -15,19 +15,42 @@ - + - + - Size: + Add ref + + + true - + + + Remove ref + + + true + + + + + + + + + + + + Size: + + + diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h index ce69f94a4..ccdaefefe 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h @@ -48,6 +48,9 @@ public: void hideObject(); void showObject(); + /// Apply the changes made to the object to it + virtual void apply() {}; + protected Q_SLOTS: void onButtonRefAdd(const bool checked); void onButtonRefRemove(const bool checked); @@ -63,11 +66,13 @@ protected: virtual void changeEvent(QEvent *e) = 0; static void removeItemFromListWidget(QListWidget* widget, const char* itemstr); + ViewProviderDressUp* getDressUpView() const + { return DressUpView; } + protected: QWidget* proxy; ViewProviderDressUp *DressUpView; - selectionModes selectionMode; }; diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 0e1045a7d..19ecbc715 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -50,8 +50,8 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskFilletParameters */ -TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidget *parent) - : TaskBox(Gui::BitmapFactory().pixmap("Part_Fillet"),tr("Fillet parameters"),true, parent),FilletView(FilletView) +TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView,QWidget *parent) + : TaskDressUpParameters(DressUpView, parent) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -61,10 +61,14 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidge connect(ui->filletRadius, SIGNAL(valueChanged(double)), this, SLOT(onLengthChanged(double))); + connect(ui->buttonRefAdd, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefAdd(bool))); + connect(ui->buttonRefRemove, SIGNAL(toggled(bool)), + this, SLOT(onButtonRefRemove(bool))); this->groupLayout()->addWidget(proxy); - PartDesign::Fillet* pcFillet = static_cast(FilletView->getObject()); + PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); double r = pcFillet->Radius.getValue(); ui->filletRadius->setUnit(Base::Unit::Length); @@ -73,11 +77,56 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidge ui->filletRadius->selectNumber(); ui->filletRadius->bind(pcFillet->Radius); QMetaObject::invokeMethod(ui->filletRadius, "setFocus", Qt::QueuedConnection); + std::vector strings = pcFillet->Base.getSubValues(); + for (std::vector::const_iterator i = strings.begin(); i != strings.end(); i++) + { + ui->listWidgetReferences->insertItem(0, QString::fromStdString(*i)); + } + // Create context menu + QAction* action = new QAction(tr("Remove"), this); + ui->listWidgetReferences->addAction(action); + connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted())); + ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); +} + +void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg) +{ + if (selectionMode == none) + return; + + if (msg.Type == Gui::SelectionChanges::AddSelection) { + if (referenceSelected(msg)) { + if (selectionMode == refAdd) + ui->listWidgetReferences->insertItem(0, QString::fromStdString(msg.pSubName)); + else + removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName); + clearButtons(none); + exitSelectionMode(); + } + } +} + +void TaskFilletParameters::clearButtons(const selectionModes notThis) +{ + if (notThis != refAdd) ui->buttonRefAdd->setChecked(false); + if (notThis != refRemove) ui->buttonRefRemove->setChecked(false); +} + +void TaskFilletParameters::onRefDeleted(void) +{ + PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); + App::DocumentObject* base = pcFillet->Base.getValue(); + std::vector refs = pcFillet->Base.getSubValues(); + refs.erase(refs.begin() + ui->listWidgetReferences->currentRow()); + pcFillet->Base.setValue(base, refs); + ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow()); + pcFillet->getDocument()->recomputeFeature(pcFillet); } void TaskFilletParameters::onLengthChanged(double len) { - PartDesign::Fillet* pcFillet = static_cast(FilletView->getObject()); + clearButtons(none); + PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); pcFillet->Radius.setValue(len); pcFillet->getDocument()->recomputeFeature(pcFillet); } @@ -89,6 +138,7 @@ double TaskFilletParameters::getLength(void) const TaskFilletParameters::~TaskFilletParameters() { + Gui::Selection().rmvSelectionGate(); delete ui; } @@ -102,7 +152,7 @@ void TaskFilletParameters::changeEvent(QEvent *e) void TaskFilletParameters::apply() { - std::string name = FilletView->getObject()->getNameInDocument(); + std::string name = getDressUpView()->getObject()->getNameInDocument(); //Gui::Command::openCommand("Fillet changed"); ui->filletRadius->apply(); @@ -116,11 +166,10 @@ void TaskFilletParameters::apply() // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgFilletParameters::TaskDlgFilletParameters(ViewProviderFillet *FilletView) - : TaskDialog(),FilletView(FilletView) +TaskDlgFilletParameters::TaskDlgFilletParameters(ViewProviderFillet *DressUpView) + : TaskDlgDressUpParameters(DressUpView) { - assert(FilletView); - parameter = new TaskFilletParameters(FilletView); + parameter = new TaskFilletParameters(DressUpView); Content.push_back(parameter); } @@ -133,48 +182,20 @@ TaskDlgFilletParameters::~TaskDlgFilletParameters() //==== calls from the TaskView =============================================================== -void TaskDlgFilletParameters::open() -{ - // a transaction is already open at creation time of the fillet - if (!Gui::Command::hasPendingCommand()) { - QString msg = tr("Edit fillet"); - Gui::Command::openCommand((const char*)msg.toUtf8()); - } -} - -void TaskDlgFilletParameters::clicked(int) -{ - -} - +//void TaskDlgFilletParameters::open() +//{ +// // a transaction is already open at creation time of the fillet +// if (!Gui::Command::hasPendingCommand()) { +// QString msg = tr("Edit fillet"); +// Gui::Command::openCommand((const char*)msg.toUtf8()); +// } +//} bool TaskDlgFilletParameters::accept() { + parameter->showObject(); parameter->apply(); - return true; + return TaskDlgDressUpParameters::accept(); } -bool TaskDlgFilletParameters::reject() -{ - // role back the done things - Gui::Command::abortCommand(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); - - // Body housekeeping - if (ActivePartObject != NULL) { - // Make the new Tip and the previous solid feature visible again - App::DocumentObject* tip = ActivePartObject->Tip.getValue(); - App::DocumentObject* prev = ActivePartObject->getPrevSolidFeature(); - if (tip != NULL) { - Gui::Application::Instance->getViewProvider(tip)->show(); - if ((tip != prev) && (prev != NULL)) - Gui::Application::Instance->getViewProvider(prev)->show(); - } - } - - return true; -} - - - #include "moc_TaskFilletParameters.cpp" diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.h b/src/Mod/PartDesign/Gui/TaskFilletParameters.h index e05fd9fd2..2b6966cf4 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.h +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.h @@ -24,85 +24,51 @@ #ifndef GUI_TASKVIEW_TaskFilletParameters_H #define GUI_TASKVIEW_TaskFilletParameters_H -#include -#include -#include - +#include "TaskDressUpParameters.h" #include "ViewProviderFillet.h" class Ui_TaskFilletParameters; -namespace App { -class Property; -} - -namespace Gui { -class ViewProvider; -} - - namespace PartDesignGui { -class TaskFilletParameters : public Gui::TaskView::TaskBox +class TaskFilletParameters : public TaskDressUpParameters { Q_OBJECT public: - TaskFilletParameters(ViewProviderFillet *FilletView, QWidget *parent=0); + TaskFilletParameters(ViewProviderDressUp *DressUpView, QWidget *parent=0); ~TaskFilletParameters(); - void apply(); + virtual void apply(); private Q_SLOTS: void onLengthChanged(double); + void onRefDeleted(void); protected: double getLength(void) const; + virtual void clearButtons(const selectionModes notThis); void changeEvent(QEvent *e); + virtual void onSelectionChanged(const Gui::SelectionChanges& msg); private: - -private: - QWidget* proxy; Ui_TaskFilletParameters* ui; - ViewProviderFillet *FilletView; }; /// simulation dialog for the TaskView -class TaskDlgFilletParameters : public Gui::TaskView::TaskDialog +class TaskDlgFilletParameters : public TaskDlgDressUpParameters { Q_OBJECT public: - TaskDlgFilletParameters(ViewProviderFillet *FilletView); + TaskDlgFilletParameters(ViewProviderFillet *DressUpView); ~TaskDlgFilletParameters(); - ViewProviderFillet* getFilletView() const - { return FilletView; } - - public: - /// is called the TaskView when the dialog is opened - virtual void open(); - /// is called by the framework if an button is clicked which has no accept or reject role - virtual void clicked(int); /// 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) - virtual bool reject(); - virtual bool isAllowedAlterDocument(void) const - { return false; } - - /// returns for Close and Help button - virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const - { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; } - -protected: - ViewProviderFillet *FilletView; - - TaskFilletParameters *parameter; }; } //namespace PartDesignGui -#endif // GUI_TASKVIEW_TASKAPPERANCE_H +#endif // GUI_TASKVIEW_TaskFilletParameters_H diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.h.orig b/src/Mod/PartDesign/Gui/TaskFilletParameters.h.orig new file mode 100644 index 000000000..17f2a4e7c --- /dev/null +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.h.orig @@ -0,0 +1,90 @@ +/*************************************************************************** + * Copyright (c) 2011 Juergen 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_TaskFilletParameters_H +#define GUI_TASKVIEW_TaskFilletParameters_H + +#include "TaskDressUpParameters.h" +#include "ViewProviderFillet.h" + +class Ui_TaskFilletParameters; + +namespace PartDesignGui { + +class TaskFilletParameters : public TaskDressUpParameters +{ + Q_OBJECT + +public: + TaskFilletParameters(ViewProviderDressUp *DressUpView, QWidget *parent=0); + ~TaskFilletParameters(); + + virtual void apply(); + +private Q_SLOTS: + void onLengthChanged(double); + void onRefDeleted(void); + +protected: + double getLength(void) const; + virtual void clearButtons(const selectionModes notThis); + void changeEvent(QEvent *e); + virtual void onSelectionChanged(const Gui::SelectionChanges& msg); + +private: + Ui_TaskFilletParameters* ui; +}; + +/// simulation dialog for the TaskView +class TaskDlgFilletParameters : public TaskDlgDressUpParameters +{ + Q_OBJECT + +public: + TaskDlgFilletParameters(ViewProviderFillet *DressUpView); + ~TaskDlgFilletParameters(); + +public: + /// is called by the framework if the dialog is accepted (Ok) + virtual bool accept(); +<<<<<<< 61d7568d0ff2d3e87f1abb738517f4294c5a6d2e + /// is called by the framework if the dialog is rejected (Cancel) + virtual bool reject(); + virtual bool isAllowedAlterDocument(void) const + { return false; } + + /// returns for Close and Help button + virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const + { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; } + +protected: + ViewProviderFillet *FilletView; + + TaskFilletParameters *parameter; +======= +>>>>>>> Allow selecting and removing fillet and chamfer references in the dialog +}; + +} //namespace PartDesignGui + +#endif // GUI_TASKVIEW_TaskFilletParameters_H diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.ui b/src/Mod/PartDesign/Gui/TaskFilletParameters.ui index 9d1597219..b6803af45 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.ui @@ -6,14 +6,41 @@ 0 0 - 135 - 40 + 208 + 164 Form + + + + + + Add ref + + + true + + + + + + + Remove ref + + + true + + + + + + + + diff --git a/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp b/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp index 7be0f498f..c375a8d1e 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp @@ -31,8 +31,6 @@ #include "ViewProviderChamfer.h" #include "TaskChamferParameters.h" -#include -#include #include #include #include @@ -40,73 +38,32 @@ using namespace PartDesignGui; -PROPERTY_SOURCE(PartDesignGui::ViewProviderChamfer,PartDesignGui::ViewProvider) - -ViewProviderChamfer::ViewProviderChamfer() -{ - sPixmap = "PartDesign_Chamfer.svg"; -} - -ViewProviderChamfer::~ViewProviderChamfer() -{ -} - - -void ViewProviderChamfer::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) -{ - QAction* act; - act = menu->addAction(QObject::tr("Edit chamfer"), receiver, member); - act->setData(QVariant((int)ViewProvider::Default)); - PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member); -} +PROPERTY_SOURCE(PartDesignGui::ViewProviderChamfer,PartDesignGui::ViewProviderDressUp) bool ViewProviderChamfer::setEdit(int ModNum) { if (ModNum == ViewProvider::Default ) { - // When double-clicking on the item for this chamfer the - // object unsets and sets its edit mode without closing - // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgChamferParameters *padDlg = qobject_cast(dlg); - if (padDlg && padDlg->getChamferView() != this) - padDlg = 0; // another pad left open its task panel - if (dlg && !padDlg) { - QMessageBox msgBox; - msgBox.setText(QObject::tr("A dialog is already open in the task panel")); - msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) - Gui::Control().reject(); + TaskDlgDressUpParameters *dressUpDlg = NULL; + + if (checkDlgOpen(dressUpDlg)) { + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); + + // start the edit dialog + if (dressUpDlg) + Gui::Control().showDialog(dressUpDlg); else - return false; + Gui::Control().showDialog(new TaskDlgChamferParameters(this)); + + return true; + } else { + return false; } - - // clear the selection (convenience) - Gui::Selection().clearSelection(); - - // always change to PartDesign WB, remember where we come from - oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); - - // start the edit dialog - if (padDlg) - Gui::Control().showDialog(padDlg); - else - Gui::Control().showDialog(new TaskDlgChamferParameters(this)); - - return true; } else { - return PartGui::ViewProviderPart::setEdit(ModNum); + return ViewProviderDressUp::setEdit(ModNum); } } -bool ViewProviderChamfer::onDelete(const std::vector &s) -{ - return ViewProvider::onDelete(s); -} - - diff --git a/src/Mod/PartDesign/Gui/ViewProviderChamfer.h b/src/Mod/PartDesign/Gui/ViewProviderChamfer.h index 507a7bb0e..2a9bab302 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderChamfer.h +++ b/src/Mod/PartDesign/Gui/ViewProviderChamfer.h @@ -24,25 +24,20 @@ #ifndef PARTGUI_ViewProviderChamfer_H #define PARTGUI_ViewProviderChamfer_H -#include "ViewProvider.h" +#include "ViewProviderDressUp.h" namespace PartDesignGui { -class PartDesignGuiExport ViewProviderChamfer : public ViewProvider +class PartDesignGuiExport ViewProviderChamfer : public ViewProviderDressUp { PROPERTY_HEADER(PartDesignGui::ViewProviderChamfer); public: /// constructor - ViewProviderChamfer(); - /// destructor - virtual ~ViewProviderChamfer(); - - /// grouping handling - void setupContextMenu(QMenu*, QObject*, const char*); - - virtual bool onDelete(const std::vector &); + ViewProviderChamfer() + { featureName = std::string("Chamfer"); + sPixmap = "PartDesign_Chamfer.svg"; } protected: virtual bool setEdit(int ModNum); diff --git a/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp b/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp index db604d595..24ad5d908 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp @@ -31,8 +31,6 @@ #include "ViewProviderFillet.h" #include "TaskFilletParameters.h" -#include -#include #include #include #include @@ -40,71 +38,31 @@ using namespace PartDesignGui; -PROPERTY_SOURCE(PartDesignGui::ViewProviderFillet,PartDesignGui::ViewProvider) - -ViewProviderFillet::ViewProviderFillet() -{ - sPixmap = "PartDesign_Fillet.svg"; -} - -ViewProviderFillet::~ViewProviderFillet() -{ -} - - -void ViewProviderFillet::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) -{ - QAction* act; - act = menu->addAction(QObject::tr("Edit fillet"), receiver, member); - act->setData(QVariant((int)ViewProvider::Default)); - PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member); -} +PROPERTY_SOURCE(PartDesignGui::ViewProviderFillet,PartDesignGui::ViewProviderDressUp) bool ViewProviderFillet::setEdit(int ModNum) { if (ModNum == ViewProvider::Default ) { - // When double-clicking on the item for this fillet the - // object unsets and sets its edit mode without closing - // the task panel - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - TaskDlgFilletParameters *padDlg = qobject_cast(dlg); - if (padDlg && padDlg->getFilletView() != this) - padDlg = 0; // another pad left open its task panel - if (dlg && !padDlg) { - QMessageBox msgBox; - msgBox.setText(QObject::tr("A dialog is already open in the task panel")); - msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) - Gui::Control().reject(); + TaskDlgDressUpParameters *dressUpDlg = NULL; + + if (checkDlgOpen(dressUpDlg)) { + // always change to PartDesign WB, remember where we come from + oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); + + // start the edit dialog + if (dressUpDlg) + Gui::Control().showDialog(dressUpDlg); else - return false; + Gui::Control().showDialog(new TaskDlgFilletParameters(this)); + + return true; + } else { + return false; } - - // clear the selection (convenience) - Gui::Selection().clearSelection(); - - // always change to PartDesign WB, remember where we come from - oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench"); - - // start the edit dialog - if (padDlg) - Gui::Control().showDialog(padDlg); - else - Gui::Control().showDialog(new TaskDlgFilletParameters(this)); - - return true; } else { - return PartGui::ViewProviderPart::setEdit(ModNum); + return ViewProviderDressUp::setEdit(ModNum); } } -bool ViewProviderFillet::onDelete(const std::vector &s) -{ - return ViewProvider::onDelete(s); -} - diff --git a/src/Mod/PartDesign/Gui/ViewProviderFillet.h b/src/Mod/PartDesign/Gui/ViewProviderFillet.h index f2f80df7c..240fffa36 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderFillet.h +++ b/src/Mod/PartDesign/Gui/ViewProviderFillet.h @@ -24,33 +24,25 @@ #ifndef PARTGUI_ViewProviderFillet_H #define PARTGUI_ViewProviderFillet_H -#include "ViewProvider.h" +#include "ViewProviderDressUp.h" namespace PartDesignGui { -class PartDesignGuiExport ViewProviderFillet : public ViewProvider +class PartDesignGuiExport ViewProviderFillet : public ViewProviderDressUp { PROPERTY_HEADER(PartDesignGui::ViewProviderFillet); public: /// constructor - ViewProviderFillet(); - /// destructor - virtual ~ViewProviderFillet(); - - /// grouping handling - void setupContextMenu(QMenu*, QObject*, const char*); - - virtual bool onDelete(const std::vector &); + ViewProviderFillet() + { featureName = std::string("Fillet"); + sPixmap = "PartDesign_Fillet.svg"; } protected: virtual bool setEdit(int ModNum); - }; - - } // namespace PartDesignGui