PartDesign: Center holes on sketch points as well as circles and arcs (#20583)

Co-authored-by: Kacper Donat <kadet1090@gmail.com>
This commit is contained in:
theo-vt
2025-04-21 17:30:57 -04:00
committed by GitHub
parent 75bc5eed1c
commit f2cc750250
9 changed files with 250 additions and 58 deletions

View File

@@ -183,6 +183,8 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole* HoleView, QWidget* pare
std::string(pcHole->ThreadDepthType.getValueAsString()) == "Dimension"
);
ui->BaseProfileType->setCurrentIndex(PartDesign::Hole::baseProfileOption_bitmaskToIdx(pcHole->BaseProfileType.getValue()));
setCutDiagram();
// clang-format off
@@ -240,6 +242,8 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole* HoleView, QWidget* pare
this, &TaskHoleParameters::threadDepthTypeChanged);
connect(ui->ThreadDepth, qOverload<double>(&Gui::QuantitySpinBox::valueChanged),
this, &TaskHoleParameters::threadDepthChanged);
connect(ui->BaseProfileType, qOverload<int>(&QComboBox::currentIndexChanged),
this, &TaskHoleParameters::baseProfileTypeChanged);
// clang-format on
getViewObject()->show();
@@ -321,7 +325,6 @@ void TaskHoleParameters::threadDepthTypeChanged(int index)
recomputeFeature();
}
}
void TaskHoleParameters::threadDepthChanged(double value)
{
if (auto hole = getObject<PartDesign::Hole>()) {
@@ -410,6 +413,13 @@ void TaskHoleParameters::holeCutTypeChanged(int index)
}
setCutDiagram();
}
void TaskHoleParameters::baseProfileTypeChanged(int index)
{
if (auto hole = getObject<PartDesign::Hole>()) {
hole->BaseProfileType.setValue(PartDesign::Hole::baseProfileOption_idxToBitmask(index));
recomputeFeature();
}
}
void TaskHoleParameters::setCutDiagram()
{
@@ -907,6 +917,9 @@ void TaskHoleParameters::changedObject(const App::Document&, const App::Property
else if (&Prop == &hole->ThreadDepth) {
ui->ThreadDepth->setEnabled(true);
updateSpinBox(ui->ThreadDepth, hole->ThreadDepth.getValue());
} else if (&Prop == &hole->BaseProfileType) {
ui->BaseProfileType->setEnabled(true);
updateComboBox(ui->BaseProfileType, PartDesign::Hole::baseProfileOption_bitmaskToIdx(hole->BaseProfileType.getValue()));
}
}
@@ -1056,7 +1069,10 @@ double TaskHoleParameters::getThreadDepth() const
{
return ui->ThreadDepth->value().getValue();
}
int TaskHoleParameters::getBaseProfileType() const
{
return PartDesign::Hole::baseProfileOption_idxToBitmask(ui->BaseProfileType->currentIndex());
}
void TaskHoleParameters::apply()
{
auto hole = getObject<PartDesign::Hole>();
@@ -1123,6 +1139,9 @@ void TaskHoleParameters::apply()
if (!hole->Tapered.isReadOnly()) {
FCMD_OBJ_CMD(hole, "Tapered = " << getTapered());
}
if (!hole->BaseProfileType.isReadOnly()) {
FCMD_OBJ_CMD(hole, "BaseProfileType = " << getBaseProfileType());
}
isApplying = false;
}

View File

@@ -79,6 +79,7 @@ public:
bool getModelThread() const;
long getThreadDepthType() const;
double getThreadDepth() const;
int getBaseProfileType() const;
private Q_SLOTS:
void threadedChanged();
@@ -108,6 +109,7 @@ private Q_SLOTS:
void updateViewChanged(bool isChecked);
void threadDepthTypeChanged(int index);
void threadDepthChanged(double value);
void baseProfileTypeChanged(int index);
void setCutDiagram();
private:

View File

@@ -33,7 +33,7 @@
<number>6</number>
</property>
<item>
<layout class="QGridLayout" name="headLayout" columnstretch="2,4">
<layout class="QGridLayout" name="headLayout" columnstretch="2,5">
<property name="topMargin">
<number>10</number>
</property>
@@ -918,7 +918,7 @@ Note that the calculation can take some time</string>
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<layout class="QHBoxLayout" name="horizontalLayout_11" stretch="2,5">
<property name="spacing">
<number>6</number>
</property>
@@ -967,7 +967,7 @@ Note that the calculation can take some time</string>
</item>
<item>
<widget class="QWidget" name="ThreadDepthDimensionWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="2,5">
<property name="leftMargin">
<number>0</number>
</property>
@@ -1011,7 +1011,7 @@ Note that the calculation can take some time</string>
</item>
<item>
<widget class="QWidget" name="CustomClearanceWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_13">
<layout class="QHBoxLayout" name="horizontalLayout_13" stretch="2,5">
<property name="spacing">
<number>6</number>
</property>
@@ -1074,6 +1074,36 @@ Note that the calculation can take some time</string>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="BaseProfileLayout" stretch="2,5">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Base profile types</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="BaseProfileType">
<item>
<property name="text">
<string>Circles and arcs</string>
</property>
</item>
<item>
<property name="text">
<string>Points, circles and arcs</string>
</property>
</item>
<item>
<property name="text">
<string>Points</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>