GUI: Add UI for Up To Shape feature

Add UI for Up To Shape feature and overall refactor of Pad / Pocket.
This commit is contained in:
Kacper Donat
2024-05-31 12:10:17 +02:00
parent 3f6f8c0172
commit b68da9d844
18 changed files with 684 additions and 118 deletions

View File

@@ -73,6 +73,7 @@ void TaskPocketParameters::translateModeList(int index)
ui->changeMode->addItem(tr("To first"));
ui->changeMode->addItem(tr("Up to face"));
ui->changeMode->addItem(tr("Two dimensions"));
ui->changeMode->addItem(tr("Up to shape"));
ui->changeMode->setCurrentIndex(index);
}
@@ -81,15 +82,15 @@ void TaskPocketParameters::updateUI(int index)
// update direction combobox
fillDirectionCombo();
// set and enable checkboxes
setCheckboxes(static_cast<Modes>(index), Type::Pocket);
setCheckboxes(static_cast<Mode>(index), Type::Pocket);
}
void TaskPocketParameters::onModeChanged(int index)
{
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
switch (static_cast<Modes>(index)) {
case Modes::Dimension:
switch (static_cast<Mode>(index)) {
case Mode::Dimension:
// Why? See below for "UpToFace"
if (oldLength < Precision::Confusion())
oldLength = 5.0;
@@ -97,15 +98,15 @@ void TaskPocketParameters::onModeChanged(int index)
ui->lengthEdit->setValue(oldLength);
pcPocket->Type.setValue("Length");
break;
case Modes::ThroughAll:
case Mode::ThroughAll:
oldLength = pcPocket->Length.getValue();
pcPocket->Type.setValue("ThroughAll");
break;
case Modes::ToFirst:
case Mode::ToFirst:
oldLength = pcPocket->Length.getValue();
pcPocket->Type.setValue("UpToFirst");
break;
case Modes::ToFace:
case Mode::ToFace:
// Note: ui->checkBoxReversed is purposely enabled because the selected face
// could be a circular one around the sketch
// Also note: Because of the code at the beginning of Pocket::execute() which is used
@@ -119,10 +120,13 @@ void TaskPocketParameters::onModeChanged(int index)
handleLineFaceNameClick(); // sets placeholder text
}
break;
case Modes::TwoDimensions:
case Mode::TwoDimensions:
oldLength = pcPocket->Length.getValue();
pcPocket->Type.setValue("TwoLengths");
break;
case Mode::ToShape:
pcPocket->Type.setValue("UpToShape");
break;
}
updateUI(index);
@@ -132,7 +136,7 @@ void TaskPocketParameters::onModeChanged(int index)
void TaskPocketParameters::apply()
{
QString facename = QString::fromLatin1("None");
if (static_cast<Modes>(getMode()) == Modes::ToFace) {
if (static_cast<Mode>(getMode()) == Mode::ToFace) {
facename = getFaceName();
}
applyParameters(facename);
@@ -144,10 +148,9 @@ void TaskPocketParameters::apply()
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgPocketParameters::TaskDlgPocketParameters(ViewProviderPocket *PocketView)
: TaskDlgSketchBasedParameters(PocketView)
: TaskDlgExtrudeParameters(PocketView), parameters(new TaskPocketParameters(PocketView))
{
assert(vp);
Content.push_back ( new TaskPocketParameters(PocketView ) );
Content.push_back(parameters);
}
#include "moc_TaskPocketParameters.cpp"