[PD] add feature to highlight references in some dialogs

- also fix some logic issues and avoid to break the feature (deleting the last item is now no longer possible)
This commit is contained in:
donovaly
2020-02-16 05:18:29 +01:00
parent a76bc63e4d
commit d40eb2dbfc
10 changed files with 769 additions and 452 deletions

View File

@@ -50,7 +50,7 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskChamferParameters */
TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView,QWidget *parent)
TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, QWidget *parent)
: TaskDressUpParameters(DressUpView, true, true, parent)
{
// we need a separate container widget to add all controls to
@@ -77,11 +77,11 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView,QW
QMetaObject::connectSlotsByName(this);
connect(ui->chamferDistance, SIGNAL(valueChanged(double)),
this, SLOT(onLengthChanged(double)));
this, SLOT(onLengthChanged(double)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool)));
this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefRemove(bool)));
this, SLOT(onButtonRefRemove(bool)));
// Create context menu
QAction* action = new QAction(tr("Remove"), this);
@@ -91,8 +91,20 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView,QW
action->setShortcutVisibleInContextMenu(true);
#endif
ui->listWidgetReferences->addAction(action);
// if there is only one item, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
}
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(doubleClicked(QListWidgetItem*)));
}
void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
@@ -102,10 +114,32 @@ void TaskChamferParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (referenceSelected(msg)) {
if (selectionMode == refAdd)
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
if (selectionMode == refAdd) {
ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName));
else
// it might be the second one so we can enable the context menu
if (ui->listWidgetReferences->count() > 1) {
action->setEnabled(true);
action->setStatusTip(QString());
ui->buttonRefRemove->setEnabled(true);
ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection"));
}
}
else {
removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName);
// remove its selection too
Gui::Selection().clearSelection();
// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
// we must also end the selection mode
exitSelectionMode();
clearButtons(none);
}
}
// highlight existing references for possible further selections
DressUpView->highlightReferences(true);
}
@@ -121,6 +155,13 @@ void TaskChamferParameters::clearButtons(const selectionModes notThis)
void TaskChamferParameters::onRefDeleted(void)
{
// assure we we are not in selection mode
exitSelectionMode();
clearButtons(none);
// delete any selections since the reference might be highlighted
Gui::Selection().clearSelection();
DressUpView->highlightReferences(false);
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(DressUpView->getObject());
App::DocumentObject* base = pcChamfer->Base.getValue();
std::vector<std::string> refs = pcChamfer->Base.getSubValues();
@@ -129,6 +170,15 @@ void TaskChamferParameters::onRefDeleted(void)
pcChamfer->Base.setValue(base, refs);
ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow());
pcChamfer->getDocument()->recomputeFeature(pcChamfer);
// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
}
}
void TaskChamferParameters::onLengthChanged(double len)
@@ -146,7 +196,13 @@ double TaskChamferParameters::getLength(void) const
TaskChamferParameters::~TaskChamferParameters()
{
// assure the fillets are shown
showObject();
// remove any highlights and selections
DressUpView->highlightReferences(false);
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
delete ui;
}

View File

@@ -1,65 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskChamferParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskChamferParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>182</width>
<height>185</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="text">
<string>Add ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<widget class="Gui::QuantitySpinBox" name="chamferDistance"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskChamferParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskChamferParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>182</width>
<height>185</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="toolTip">
<string>Click button to enter selection mode,
click again to end selection</string>
</property>
<property name="text">
<string>Add ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="toolTip">
<string>Click button to enter selection mode,
click again to end selection</string>
</property>
<property name="text">
<string>Remove ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences">
<property name="toolTip">
<string>- select an item to highlight it
- double-click on an item to see the chamfers</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::QuantitySpinBox" name="chamferDistance" native="true"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -51,7 +51,7 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskDraftParameters */
TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView,QWidget *parent)
TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView, QWidget *parent)
: TaskDressUpParameters(DressUpView, false, true, parent)
{
// we need a separate container widget to add all controls to
@@ -85,17 +85,17 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView,QWidge
QMetaObject::connectSlotsByName(this);
connect(ui->draftAngle, SIGNAL(valueChanged(double)),
this, SLOT(onAngleChanged(double)));
this, SLOT(onAngleChanged(double)));
connect(ui->checkReverse, SIGNAL(toggled(bool)),
this, SLOT(onReversedChanged(bool)));
this, SLOT(onReversedChanged(bool)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool)));
this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefRemove(bool)));
this, SLOT(onButtonRefRemove(bool)));
connect(ui->buttonPlane, SIGNAL(toggled(bool)),
this, SLOT(onButtonPlane(bool)));
this, SLOT(onButtonPlane(bool)));
connect(ui->buttonLine, SIGNAL(toggled(bool)),
this, SLOT(onButtonLine(bool)));
this, SLOT(onButtonLine(bool)));
// Create context menu
QAction* action = new QAction(tr("Remove"), this);
@@ -105,9 +105,21 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView,QWidge
action->setShortcutVisibleInContextMenu(true);
#endif
ui->listWidgetReferences->addAction(action);
// if there is only one item, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
}
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(doubleClicked(QListWidgetItem*)));
App::DocumentObject* ref = pcDraft->NeutralPlane.getValue();
strings = pcDraft->NeutralPlane.getSubValues();
ui->linePlane->setText(getRefStr(ref, strings));
@@ -124,10 +136,32 @@ void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (referenceSelected(msg)) {
if (selectionMode == refAdd)
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
if (selectionMode == refAdd) {
ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName));
else
// it might be the second one so we can enable the context menu
if (ui->listWidgetReferences->count() > 1) {
action->setEnabled(true);
action->setStatusTip(QString());
ui->buttonRefRemove->setEnabled(true);
ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection"));
}
}
else {
removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName);
// remove its selection too
Gui::Selection().clearSelection();
// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
// we must also end the selection mode
exitSelectionMode();
clearButtons(none);
}
}
// highlight existing references for possible further selections
DressUpView->highlightReferences(true);
} else if (selectionMode == plane) {
@@ -195,6 +229,13 @@ void TaskDraftParameters::onButtonLine(bool checked)
void TaskDraftParameters::onRefDeleted(void)
{
// assure we we are not in selection mode
exitSelectionMode();
clearButtons(none);
// delete any selections since the reference might be highlighted
Gui::Selection().clearSelection();
DressUpView->highlightReferences(false);
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DressUpView->getObject());
App::DocumentObject* base = pcDraft->Base.getValue();
std::vector<std::string> faces = pcDraft->Base.getSubValues();
@@ -203,6 +244,15 @@ void TaskDraftParameters::onRefDeleted(void)
pcDraft->Base.setValue(base, faces);
ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow());
pcDraft->getDocument()->recomputeFeature(pcDraft);
// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
}
}
void TaskDraftParameters::getPlane(App::DocumentObject*& obj, std::vector<std::string>& sub) const
@@ -252,7 +302,13 @@ bool TaskDraftParameters::getReversed(void) const
TaskDraftParameters::~TaskDraftParameters()
{
// assure the fillets are shown
showObject();
// remove any highlights and selections
DressUpView->highlightReferences(false);
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
delete ui;
}

View File

@@ -1,128 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskDraftParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskDraftParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>257</width>
<height>285</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="text">
<string>Add face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Draft angle</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::QuantitySpinBox" name="draftAngle">
<property name="unit" stdset="0">
<string notr="true">deg</string>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>89.999999999999986</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.500000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QToolButton" name="buttonPlane">
<property name="text">
<string>Neutral plane</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linePlane"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QToolButton" name="buttonLine">
<property name="text">
<string>Pull direction</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineLine"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkReverse">
<property name="text">
<string>Reverse pull direction</string>
</property>
</widget>
</item>
</layout>
<zorder>checkReverse</zorder>
<zorder>listWidgetReferences</zorder>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskDraftParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskDraftParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>257</width>
<height>285</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="toolTip">
<string>Click button to enter selection mode,
click again to end selection</string>
</property>
<property name="text">
<string>Add face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="toolTip">
<string>Click button to enter selection mode,
click again to end selection</string>
</property>
<property name="text">
<string>Remove face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences">
<property name="toolTip">
<string>- select an item to highlight it
- double-click on an item to see the drafts</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Draft angle</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::QuantitySpinBox" name="draftAngle" native="true">
<property name="unit" stdset="0">
<string notr="true">deg</string>
</property>
<property name="minimum" stdset="0">
<double>0.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>89.999999999999986</double>
</property>
<property name="singleStep" stdset="0">
<double>0.100000000000000</double>
</property>
<property name="value" stdset="0">
<double>1.500000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QToolButton" name="buttonPlane">
<property name="text">
<string>Neutral plane</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linePlane"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QToolButton" name="buttonLine">
<property name="text">
<string>Pull direction</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineLine"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkReverse">
<property name="text">
<string>Reverse pull direction</string>
</property>
</widget>
</item>
</layout>
<zorder>checkReverse</zorder>
<zorder>listWidgetReferences</zorder>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -41,6 +41,7 @@
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Gui/MainWindow.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/PartDesign/App/FeatureDressUp.h>
#include <Mod/PartDesign/Gui/ReferenceSelection.h>
@@ -153,6 +154,44 @@ void TaskDressUpParameters::onButtonRefRemove(const bool checked)
}
}
void TaskDressUpParameters::doubleClicked(QListWidgetItem* item) {
// executed when the user selected a new item in the list
// shows the fillets as they are -> useful to switch out of selection mode
// assure we are not in selection mode
exitSelectionMode();
clearButtons(none);
// assure the fillets are shown
showObject();
// remove any highlights andd selections
DressUpView->highlightReferences(false);
Gui::Selection().clearSelection();
}
void TaskDressUpParameters::setSelection(QListWidgetItem* current) {
// executed when the user selected a new item in the list
// highlights the currently selected item
// name of the item
std::string subName = current->text().toStdString();
// get the document name
std::string docName = DressUpView->getObject()->getDocument()->getName();
// get the name of the body we are in
Part::BodyBase* body = PartDesign::Body::findBodyOf(DressUpView->getObject());
std::string objName = body->getNameInDocument();
// hide fillet to see the original edge
// (a fillet creates new edges so that the original one is not available)
hideObject();
// highlight all objects in the list
DressUpView->highlightReferences(true);
// clear existing selections
Gui::Selection().clearSelection();
// highligh the selected item
Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0);
}
const std::vector<std::string> TaskDressUpParameters::getReferences() const
{
PartDesign::DressUp* pcDressUp = static_cast<PartDesign::DressUp*>(DressUpView->getObject());

View File

@@ -60,6 +60,8 @@ public:
protected Q_SLOTS:
void onButtonRefAdd(const bool checked);
void onButtonRefRemove(const bool checked);
void doubleClicked(QListWidgetItem* item);
void setSelection(QListWidgetItem* current);
virtual void onRefDeleted(void) = 0;
protected:

View File

@@ -49,7 +49,7 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskFilletParameters */
TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView,QWidget *parent)
TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWidget *parent)
: TaskDressUpParameters(DressUpView, true, true, parent)
{
// we need a separate container widget to add all controls to
@@ -77,11 +77,11 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView,QWid
QMetaObject::connectSlotsByName(this);
connect(ui->filletRadius, SIGNAL(valueChanged(double)),
this, SLOT(onLengthChanged(double)));
this, SLOT(onLengthChanged(double)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool)));
this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefRemove(bool)));
this, SLOT(onButtonRefRemove(bool)));
// Create context menu
QAction* action = new QAction(tr("Remove"), this);
@@ -91,8 +91,20 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView,QWid
action->setShortcutVisibleInContextMenu(true);
#endif
ui->listWidgetReferences->addAction(action);
// if there is only one item, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
}
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(doubleClicked(QListWidgetItem*)));
}
void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
@@ -102,10 +114,32 @@ void TaskFilletParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (referenceSelected(msg)) {
if (selectionMode == refAdd)
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
if (selectionMode == refAdd) {
ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName));
else
// it might be the second one so we can enable the context menu
if (ui->listWidgetReferences->count() > 1) {
action->setEnabled(true);
action->setStatusTip(QString());
ui->buttonRefRemove->setEnabled(true);
ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection"));
}
}
else {
removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName);
// remove its selection too
Gui::Selection().clearSelection();
// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
// we must also end the selection mode
exitSelectionMode();
clearButtons(none);
}
}
// highlight existing references for possible further selections
DressUpView->highlightReferences(true);
}
@@ -121,6 +155,13 @@ void TaskFilletParameters::clearButtons(const selectionModes notThis)
void TaskFilletParameters::onRefDeleted(void)
{
// assure we we are not in selection mode
exitSelectionMode();
clearButtons(none);
// delete any selections since the reference might be highlighted
Gui::Selection().clearSelection();
DressUpView->highlightReferences(false);
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(DressUpView->getObject());
App::DocumentObject* base = pcFillet->Base.getValue();
std::vector<std::string> refs = pcFillet->Base.getSubValues();
@@ -129,6 +170,15 @@ void TaskFilletParameters::onRefDeleted(void)
pcFillet->Base.setValue(base, refs);
ui->listWidgetReferences->model()->removeRow(ui->listWidgetReferences->currentRow());
pcFillet->getDocument()->recomputeFeature(pcFillet);
// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
}
}
void TaskFilletParameters::onLengthChanged(double len)
@@ -147,7 +197,13 @@ double TaskFilletParameters::getLength(void) const
TaskFilletParameters::~TaskFilletParameters()
{
// assure the fillets are shown
showObject();
// remove any highlights and selections
DressUpView->highlightReferences(false);
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
delete ui;
}

View File

@@ -1,69 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskFilletParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskFilletParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>208</width>
<height>164</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="text">
<string>Add ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Radius:</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::QuantitySpinBox" name="filletRadius"/>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskFilletParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskFilletParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>208</width>
<height>164</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="toolTip">
<string>Click button to enter selection mode,
click again to end selection</string>
</property>
<property name="text">
<string>Add ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="toolTip">
<string>Click button to enter selection mode,
click again to end selection</string>
</property>
<property name="text">
<string>Remove ref</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences">
<property name="toolTip">
<string>- select an item to highlight it
- double-click on an item to see the fillets</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Radius:</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::QuantitySpinBox" name="filletRadius" native="true"/>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -49,7 +49,7 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskThicknessParameters */
TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpView,QWidget *parent)
TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpView, QWidget *parent)
: TaskDressUpParameters(DressUpView, false, true, parent)
{
// we need a separate container widget to add all controls to
@@ -85,19 +85,19 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie
QMetaObject::connectSlotsByName(this);
connect(ui->Value, SIGNAL(valueChanged(double)),
this, SLOT(onValueChanged(double)));
this, SLOT(onValueChanged(double)));
connect(ui->checkReverse, SIGNAL(toggled(bool)),
this, SLOT(onReversedChanged(bool)));
this, SLOT(onReversedChanged(bool)));
connect(ui->checkIntersection, SIGNAL(toggled(bool)),
this, SLOT(onIntersectionChanged(bool)));
this, SLOT(onIntersectionChanged(bool)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool)));
this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefRemove(bool)));
this, SLOT(onButtonRefRemove(bool)));
connect(ui->modeComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(onModeChanged(int)));
this, SLOT(onModeChanged(int)));
connect(ui->joinComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(onJoinTypeChanged(int)));
this, SLOT(onJoinTypeChanged(int)));
// Create context menu
QAction* action = new QAction(tr("Remove"), this);
@@ -107,9 +107,21 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie
action->setShortcutVisibleInContextMenu(true);
#endif
ui->listWidgetReferences->addAction(action);
// if there is only one item, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
}
connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted()));
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(doubleClicked(QListWidgetItem*)));
int mode = pcThickness->Mode.getValue();
ui->modeComboBox->setCurrentIndex(mode);
@@ -124,10 +136,32 @@ void TaskThicknessParameters::onSelectionChanged(const Gui::SelectionChanges& ms
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (referenceSelected(msg)) {
if (selectionMode == refAdd)
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
if (selectionMode == refAdd) {
ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName));
else
// it might be the second one so we can enable the context menu
if (ui->listWidgetReferences->count() > 1) {
action->setEnabled(true);
action->setStatusTip(QString());
ui->buttonRefRemove->setEnabled(true);
ui->buttonRefRemove->setToolTip(tr("Click button to enter selection mode,\nclick again to end selection"));
}
}
else {
removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName);
// remove its selection too
Gui::Selection().clearSelection();
// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
// we must also end the selection mode
exitSelectionMode();
clearButtons(none);
}
}
// highlight existing references for possible further selections
DressUpView->highlightReferences(true);
}
@@ -143,6 +177,13 @@ void TaskThicknessParameters::clearButtons(const selectionModes notThis)
void TaskThicknessParameters::onRefDeleted(void)
{
// assure we we are not in selection mode
exitSelectionMode();
clearButtons(none);
// delete any selections since the reference might be highlighted
Gui::Selection().clearSelection();
DressUpView->highlightReferences(false);
PartDesign::Thickness* pcThickness = static_cast<PartDesign::Thickness*>(DressUpView->getObject());
App::DocumentObject* base = pcThickness->Base.getValue();
std::vector<std::string> faces = pcThickness->Base.getSubValues();
@@ -153,6 +194,15 @@ void TaskThicknessParameters::onRefDeleted(void)
pcThickness->getDocument()->recomputeFeature(pcThickness);
clearButtons(none);
exitSelectionMode();
// if there is only one item left, it cannot be deleted
if (ui->listWidgetReferences->count() == 1) {
QAction *action = ui->listWidgetReferences->actions().at(0); // we have only one action
action->setEnabled(false);
action->setStatusTip(tr("There must be at least one item"));
ui->buttonRefRemove->setEnabled(false);
ui->buttonRefRemove->setToolTip(tr("There must be at least one item"));
}
}
void TaskThicknessParameters::onValueChanged(double angle)
@@ -226,7 +276,13 @@ int TaskThicknessParameters::getMode(void) const {
TaskThicknessParameters::~TaskThicknessParameters()
{
// assure the fillets are shown
showObject();
// remove any highlights and selections
DressUpView->highlightReferences(false);
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
delete ui;
}

View File

@@ -1,159 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskThicknessParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskThicknessParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>321</width>
<height>509</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="text">
<string>Add face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Thickness</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="Value" native="true">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
<property name="minimum" stdset="0">
<double>0.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>999999999.000000000000000</double>
</property>
<property name="singleStep" stdset="0">
<double>0.100000000000000</double>
</property>
<property name="value" stdset="0">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Join Type</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="modeComboBox">
<item>
<property name="text">
<string>Skin</string>
</property>
</item>
<item>
<property name="text">
<string>Pipe</string>
</property>
</item>
<item>
<property name="text">
<string>Recto Verso</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="joinComboBox">
<item>
<property name="text">
<string>Arc</string>
</property>
</item>
<item>
<property name="text">
<string>Intersection</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkIntersection">
<property name="text">
<string>Intersection</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkReverse">
<property name="text">
<string>Make thickness inwards</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>Value</tabstop>
<tabstop>modeComboBox</tabstop>
<tabstop>joinComboBox</tabstop>
<tabstop>checkIntersection</tabstop>
<tabstop>checkReverse</tabstop>
<tabstop>buttonRefAdd</tabstop>
<tabstop>buttonRefRemove</tabstop>
<tabstop>listWidgetReferences</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskThicknessParameters</class>
<widget class="QWidget" name="PartDesignGui::TaskThicknessParameters">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>321</width>
<height>509</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="toolTip">
<string>Click button to enter selection mode,
click again to end selection</string>
</property>
<property name="text">
<string>Add face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="toolTip">
<string>Click button to enter selection mode,
click again to end selection</string>
</property>
<property name="text">
<string>Remove face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences">
<property name="toolTip">
<string>- select an item to highlight it
- double-click on an item to see the features</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Thickness</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="Value" native="true">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="unit" stdset="0">
<string notr="true">mm</string>
</property>
<property name="minimum" stdset="0">
<double>0.000000000000000</double>
</property>
<property name="maximum" stdset="0">
<double>999999999.000000000000000</double>
</property>
<property name="singleStep" stdset="0">
<double>0.100000000000000</double>
</property>
<property name="value" stdset="0">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Join Type</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="modeComboBox">
<item>
<property name="text">
<string>Skin</string>
</property>
</item>
<item>
<property name="text">
<string>Pipe</string>
</property>
</item>
<item>
<property name="text">
<string>Recto Verso</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="joinComboBox">
<item>
<property name="text">
<string>Arc</string>
</property>
</item>
<item>
<property name="text">
<string>Intersection</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkIntersection">
<property name="text">
<string>Intersection</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkReverse">
<property name="text">
<string>Make thickness inwards</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>Value</tabstop>
<tabstop>modeComboBox</tabstop>
<tabstop>joinComboBox</tabstop>
<tabstop>checkIntersection</tabstop>
<tabstop>checkReverse</tabstop>
<tabstop>buttonRefAdd</tabstop>
<tabstop>buttonRefRemove</tabstop>
<tabstop>listWidgetReferences</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>