[PD] improve face selection for Pad/Pocket

- this PR extends PR #7191 as described in this forum thread: https://forum.freecadweb.org/viewtopic.php?f=3&t=70327
This commit is contained in:
Uwe
2022-07-17 15:47:09 +02:00
parent 35f75064a0
commit e4dfc42f33
5 changed files with 44 additions and 15 deletions

View File

@@ -220,7 +220,7 @@ void TaskExtrudeParameters::connectSlots()
this, &TaskExtrudeParameters::onReversedChanged);
connect(ui->changeMode, qOverload<int>(&QComboBox::currentIndexChanged),
this, &TaskExtrudeParameters::onModeChanged);
connect(ui->buttonFace, &QPushButton::clicked,
connect(ui->buttonFace, &QPushButton::toggled,
this, &TaskExtrudeParameters::onButtonFace);
connect(ui->lineFaceName, &QLineEdit::textEdited,
this, &TaskExtrudeParameters::onFaceName);
@@ -255,7 +255,7 @@ void TaskExtrudeParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
ui->lineFaceName->setProperty("FeatureName", QByteArray(msg.pObjectName));
ui->lineFaceName->setProperty("FaceName", QByteArray(msg.pSubName));
// Turn off reference selection mode
onButtonFace(false);
ui->buttonFace->setChecked(false);
}
else {
clearFaceName();
@@ -468,7 +468,7 @@ void TaskExtrudeParameters::setCheckboxes(Modes mode, Type type)
QMetaObject::invokeMethod(ui->lineFaceName, "setFocus", Qt::QueuedConnection);
// Go into reference selection mode if no face has been selected yet
if (ui->lineFaceName->property("FeatureName").isNull())
onButtonFace(true);
ui->buttonFace->setChecked(true);
}
else if (mode == Modes::TwoDimensions) {
isLengthEditVisible = true;
@@ -507,7 +507,7 @@ void TaskExtrudeParameters::setCheckboxes(Modes mode, Type type)
ui->buttonFace->setEnabled(isFaceEditEnabled);
ui->lineFaceName->setEnabled(isFaceEditEnabled);
if (!isFaceEditEnabled) {
onButtonFace(false);
ui->buttonFace->setChecked(false);
}
}
@@ -681,16 +681,18 @@ void TaskExtrudeParameters::getReferenceAxis(App::DocumentObject*& obj, std::vec
}
}
void TaskExtrudeParameters::onButtonFace(const bool pressed)
void TaskExtrudeParameters::onButtonFace(const bool checked)
{
if (!checked && ui->lineFaceName->text().isEmpty())
ui->lineFaceName->setPlaceholderText(tr("No face selected"));
else if (checked && ui->lineFaceName->text().isEmpty())
handleLineFaceName(); // sets placeholder text
// to distinguish that this is the direction selection
selectionFace = true;
// only faces are allowed
TaskSketchBasedParameters::onSelectReference(pressed ? AllowSelection::FACE : AllowSelection::NONE);
// Update button if onButtonFace() is called explicitly
ui->buttonFace->setChecked(pressed);
TaskSketchBasedParameters::onSelectReference(checked ? AllowSelection::FACE : AllowSelection::NONE);
}
void TaskExtrudeParameters::onFaceName(const QString& text)
@@ -890,4 +892,9 @@ void TaskExtrudeParameters::translateModeList(int)
// implement in sub-class
}
void TaskExtrudeParameters::handleLineFaceName(void)
{
ui->lineFaceName->setPlaceholderText(tr("Click on a face in the model"));
}
#include "moc_TaskExtrudeParameters.cpp"

View File

@@ -90,7 +90,7 @@ protected Q_SLOTS:
void onZDirectionEditChanged(double);
void onMidplaneChanged(bool);
void onReversedChanged(bool);
void onButtonFace(const bool pressed = true);
void onButtonFace(const bool checked = true);
void onFaceName(const QString& text);
virtual void onModeChanged(int);
@@ -118,6 +118,7 @@ protected:
virtual void updateUI(int index);
void updateDirectionEdits(void);
void setDirectionMode(int index);
void handleLineFaceName(void);
private:
void tryRecomputeFeature();

View File

@@ -104,6 +104,10 @@ void TaskPadParameters::onModeChanged(int index)
break;
case Modes::ToFace:
pcPad->Type.setValue("UpToFace");
if (ui->lineFaceName->text().isEmpty()) {
ui->buttonFace->setChecked(true);
handleLineFaceName(); // sets placeholder text
}
break;
case Modes::TwoDimensions:
pcPad->Type.setValue("TwoLengths");

View File

@@ -141,7 +141,7 @@ the sketch plane's normal vector will be used</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="1">
<widget class="Gui::DoubleSpinBox" name="XDirectionEdit">
<property name="toolTip">
<string>x-component of direction vector</string>
@@ -224,7 +224,7 @@ the sketch plane's normal vector will be used</string>
</property>
</widget>
</item>
</layout>
</layout>
</widget>
</item>
<item row="3" column="0">
@@ -336,14 +336,27 @@ measured along the specified direction</string>
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QPushButton" name="buttonFace">
<widget class="QToolButton" name="buttonFace">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="text">
<string>Face</string>
<string>Select face</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineFaceName"/>
<widget class="QLineEdit" name="lineFaceName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>

View File

@@ -114,6 +114,10 @@ void TaskPocketParameters::onModeChanged(int index)
pcPocket->Type.setValue("UpToFace");
pcPocket->Length.setValue(0.0);
ui->lengthEdit->setValue(0.0);
if (ui->lineFaceName->text().isEmpty()) {
ui->buttonFace->setChecked(true);
handleLineFaceName(); // sets placeholder text
}
break;
case Modes::TwoDimensions:
oldLength = pcPocket->Length.getValue();