[TD]fix cosmetic circle arc handling

This commit is contained in:
wandererfan
2025-01-24 17:29:22 -05:00
parent dbf2e85f6f
commit add93323d7
3 changed files with 68 additions and 26 deletions

View File

@@ -72,6 +72,8 @@ TaskCosmeticCircle::TaskCosmeticCircle(TechDraw::DrawViewPart* partFeat,
connect(ui->qsbRadius, qOverload<double>(&QuantitySpinBox::valueChanged),
this, &TaskCosmeticCircle::radiusChanged);
connect(ui->rbArc, &QRadioButton::clicked, this, &TaskCosmeticCircle::arcButtonClicked);
}
@@ -91,6 +93,11 @@ TaskCosmeticCircle::TaskCosmeticCircle(TechDraw::DrawViewPart* partFeat,
ui->setupUi(this);
setUiPrimary();
connect(ui->qsbRadius, qOverload<double>(&QuantitySpinBox::valueChanged),
this, &TaskCosmeticCircle::radiusChanged);
connect(ui->rbArc, &QRadioButton::clicked, this, &TaskCosmeticCircle::arcButtonClicked);
}
TaskCosmeticCircle::~TaskCosmeticCircle()
@@ -154,8 +161,13 @@ void TaskCosmeticCircle::setUiPrimary()
double radius = (mathPoints[1] - mathPoints[0]).Length() / m_partFeat->getScale();
ui->qsbRadius->setValue(radius);
ui->qsbStartAngle->setValue(Base::toDegrees(DU::angleWithX(mathPoints[1] - mathPoints[0])));
ui->qsbEndAngle->setValue(Base::toDegrees(DU::angleWithX(mathPoints[2] - mathPoints[0])));
ui->qsbStartAngle->setValue(0);
ui->qsbEndAngle->setValue(360);
enableArcWidgets(false);
ui->qsbStartAngle->setEnabled(false);
ui->qsbEndAngle->setEnabled(false);
ui->cbClockwise->setEnabled(false);
}
void TaskCosmeticCircle::setUiEdit()
@@ -174,6 +186,15 @@ void TaskCosmeticCircle::setUiEdit()
ui->qsbStartAngle->setValue(Base::toDegrees(m_ce->m_geometry->getStartAngle()));
ui->qsbEndAngle->setValue(Base::toDegrees(m_ce->m_geometry->getEndAngle()));
if (m_ce->m_geometry->getGeomType() == GeomType::ARCOFCIRCLE) {
ui->rbArc->setChecked(true);
enableArcWidgets(true);
} else {
ui->rbArc->setChecked(false);
enableArcWidgets(false);
}
}
void TaskCosmeticCircle::radiusChanged()
@@ -184,6 +205,23 @@ void TaskCosmeticCircle::radiusChanged()
}
}
void TaskCosmeticCircle::arcButtonClicked()
{
if (ui->rbArc->isChecked()) {
enableArcWidgets(true);
} else {
enableArcWidgets(false);
}
}
void TaskCosmeticCircle::enableArcWidgets(bool newState)
{
ui->qsbStartAngle->setEnabled(newState);
ui->qsbEndAngle->setEnabled(newState);
ui->cbClockwise->setEnabled(newState);
}
//******************************************************************************
void TaskCosmeticCircle::createCosmeticCircle(void)
@@ -205,8 +243,7 @@ void TaskCosmeticCircle::createCosmeticCircle(void)
}
TechDraw::BaseGeomPtr bg;
if (ui->qsbStartAngle->value().getValue() == 0.0 &&
ui->qsbEndAngle->value().getValue() == 0.0) {
if (!ui->rbArc->isChecked()) {
bg = std::make_shared<TechDraw::Circle> (center, ui->qsbRadius->value().getValue());
} else {
bg = std::make_shared<TechDraw::AOC>(center, ui->qsbRadius->value().getValue(),
@@ -234,8 +271,7 @@ void TaskCosmeticCircle::updateCosmeticCircle(void)
m_ce->permaRadius = ui->qsbRadius->value().getValue();
TechDraw::BaseGeomPtr bg;
if (ui->qsbStartAngle->value().getValue() == 0.0 &&
ui->qsbEndAngle->value().getValue() == 0.0) {
if (!ui->rbArc->isChecked()) {
bg = std::make_shared<TechDraw::Circle> (p0, m_ce->permaRadius);
} else {
bg = std::make_shared<TechDraw::AOC>(p0, ui->qsbRadius->value().getValue(),

View File

@@ -66,6 +66,7 @@ public:
protected Q_SLOTS:
void radiusChanged();
void arcButtonClicked();
protected:
void changeEvent(QEvent *e) override;
@@ -76,6 +77,8 @@ protected:
void createCosmeticCircle();
void updateCosmeticCircle();
void enableArcWidgets(bool newState);
private:
std::unique_ptr<Ui_TaskCosmeticCircle> ui;

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>350</width>
<height>390</height>
<height>409</height>
</rect>
</property>
<property name="sizePolicy">
@@ -103,7 +103,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbCenterX">
<widget class="Gui::QuantitySpinBox" name="qsbCenterX" native="true">
<property name="unit" stdset="0">
<string notr="true"/>
</property>
@@ -117,7 +117,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbCenterY">
<widget class="Gui::QuantitySpinBox" name="qsbCenterY" native="true">
<property name="unit" stdset="0">
<string notr="true"/>
</property>
@@ -131,7 +131,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbCenterZ">
<widget class="Gui::QuantitySpinBox" name="qsbCenterZ" native="true">
<property name="unit" stdset="0">
<string notr="true"/>
</property>
@@ -149,14 +149,14 @@
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbRadius">
<widget class="Gui::QuantitySpinBox" name="qsbRadius" native="true">
<property name="unit" stdset="0">
<string notr="true"/>
</property>
<property name="minimum">
<property name="minimum" stdset="0">
<double>0.000000000000000</double>
</property>
<property name="value">
<property name="value" stdset="0">
<double>10.000000000000000</double>
</property>
</widget>
@@ -166,7 +166,7 @@
<item>
<layout class="QGridLayout" name="gridLayout_5" columnstretch="1,0">
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbStartAngle">
<widget class="Gui::QuantitySpinBox" name="qsbStartAngle" native="true">
<property name="toolTip">
<string>Start angle (conventional) of arc in degrees.</string>
</property>
@@ -175,13 +175,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Arc of Circle</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
@@ -189,8 +182,18 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cbClockwise">
<property name="toolTip">
<string>Check this box to make an arc from start angle to end angle in a clockwise direction.</string>
</property>
<property name="text">
<string>Clockwise Angle</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbEndAngle">
<widget class="Gui::QuantitySpinBox" name="qsbEndAngle" native="true">
<property name="toolTip">
<string>End angle (conventional) of arc in degrees.</string>
</property>
@@ -206,13 +209,13 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cbClockwise">
<item row="0" column="0">
<widget class="QRadioButton" name="rbArc">
<property name="toolTip">
<string>Check this box to make an arc from start angle to end angle in a clockwise direction.</string>
<string>Select to enter angles and create a circular arc.</string>
</property>
<property name="text">
<string>Clockwise Angle</string>
<string>Arc of Circle</string>
</property>
</widget>
</item>