diff --git a/src/Mod/TechDraw/Gui/TaskCosmeticCircle.cpp b/src/Mod/TechDraw/Gui/TaskCosmeticCircle.cpp index f9aa011f31..0a145bc904 100644 --- a/src/Mod/TechDraw/Gui/TaskCosmeticCircle.cpp +++ b/src/Mod/TechDraw/Gui/TaskCosmeticCircle.cpp @@ -72,6 +72,8 @@ TaskCosmeticCircle::TaskCosmeticCircle(TechDraw::DrawViewPart* partFeat, connect(ui->qsbRadius, qOverload(&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(&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 (center, ui->qsbRadius->value().getValue()); } else { bg = std::make_shared(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 (p0, m_ce->permaRadius); } else { bg = std::make_shared(p0, ui->qsbRadius->value().getValue(), diff --git a/src/Mod/TechDraw/Gui/TaskCosmeticCircle.h b/src/Mod/TechDraw/Gui/TaskCosmeticCircle.h index 55ce1ecac9..c65597d77a 100644 --- a/src/Mod/TechDraw/Gui/TaskCosmeticCircle.h +++ b/src/Mod/TechDraw/Gui/TaskCosmeticCircle.h @@ -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; diff --git a/src/Mod/TechDraw/Gui/TaskCosmeticCircle.ui b/src/Mod/TechDraw/Gui/TaskCosmeticCircle.ui index 3e54cbf3d0..b238e20ad5 100644 --- a/src/Mod/TechDraw/Gui/TaskCosmeticCircle.ui +++ b/src/Mod/TechDraw/Gui/TaskCosmeticCircle.ui @@ -7,7 +7,7 @@ 0 0 350 - 390 + 409 @@ -103,7 +103,7 @@ - + @@ -117,7 +117,7 @@ - + @@ -131,7 +131,7 @@ - + @@ -149,14 +149,14 @@ - + - + 0.000000000000000 - + 10.000000000000000 @@ -166,7 +166,7 @@ - + Start angle (conventional) of arc in degrees. @@ -175,13 +175,6 @@ - - - - Arc of Circle - - - @@ -189,8 +182,18 @@ + + + + Check this box to make an arc from start angle to end angle in a clockwise direction. + + + Clockwise Angle + + + - + End angle (conventional) of arc in degrees. @@ -206,13 +209,13 @@ - - + + - Check this box to make an arc from start angle to end angle in a clockwise direction. + Select to enter angles and create a circular arc. - Clockwise Angle + Arc of Circle