Enable Approximation scale option for Elliptical arc.

This commit is contained in:
Roman Telezhynskyi 2022-08-27 17:57:08 +03:00
parent 1e344d6df0
commit 83e9a4c8f0
9 changed files with 81 additions and 4 deletions

View File

@ -21,6 +21,7 @@
- Fix export tiled pdf on Mac OS. - Fix export tiled pdf on Mac OS.
- Improve visualization for tools. - Improve visualization for tools.
- Fix calculating an elliptical arc. - Fix calculating an elliptical arc.
- Enable Approximation scale option for Elliptical arc.
# Valentina 0.7.51 April 18, 2022 # Valentina 0.7.51 April 18, 2022
- Z value change for a layout piece. - Z value change for a layout piece.

View File

@ -2668,6 +2668,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolEllipticalArc(VPE::VProperty *pr
case 59: // AttrPenStyle case 59: // AttrPenStyle
SetPenStyle<VToolEllipticalArc>(property); SetPenStyle<VToolEllipticalArc>(property);
break; break;
case 60: // AttrAScale
SetApproximationScale<VToolEllipticalArc>(property);
break;
case 61: // AttrNotes case 61: // AttrNotes
SetNotes<VToolEllipticalArc>(property); SetNotes<VToolEllipticalArc>(property);
break; break;
@ -3301,6 +3304,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolEllipticalArc(QGraphicsItem *it
AddPropertyFormula(tr("Rotation angle:"), i->GetFormulaRotationAngle(), AttrRotationAngle); AddPropertyFormula(tr("Rotation angle:"), i->GetFormulaRotationAngle(), AttrRotationAngle);
AddPropertyAlias(i, tr("Alias:")); AddPropertyAlias(i, tr("Alias:"));
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor); AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
AddPropertyApproximationScale(tr("Approximation scale:"), i->GetApproximationScale());
AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes); AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes);
} }
@ -4267,6 +4271,10 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolEllipticalArc()
valueCenterPoint.setValue(i->CenterPointName()); valueCenterPoint.setValue(i->CenterPointName());
m_idToProperty[AttrCenter]->setValue(valueCenterPoint); m_idToProperty[AttrCenter]->setValue(valueCenterPoint);
QVariant valueApproximationScale;
valueApproximationScale.setValue(i->GetApproximationScale());
m_idToProperty[AttrAScale]->setValue(valueApproximationScale);
m_idToProperty[AttrNotes]->setValue(i->GetNotes()); m_idToProperty[AttrNotes]->setValue(i->GetNotes());
m_idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); m_idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());

View File

@ -46,7 +46,7 @@
namespace namespace
{ {
constexpr qreal tolerance = accuracyPointOnLine/32; constexpr qreal tolerance = accuracyPointOnLine/8;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLen(fpm::fixed_16_16 x, fpm::fixed_16_16 y) -> fpm::fixed_16_16 auto VLen(fpm::fixed_16_16 x, fpm::fixed_16_16 y) -> fpm::fixed_16_16
{ {

View File

@ -374,6 +374,22 @@ void DialogEllipticalArc::SetColor(const QString &value)
ChangeCurrentData(ui->comboBoxColor, value); ChangeCurrentData(ui->comboBoxColor, value);
} }
//---------------------------------------------------------------------------------------------------------------------
qreal DialogEllipticalArc::GetApproximationScale() const
{
return ui->doubleSpinBoxApproximationScale->value();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEllipticalArc::SetApproximationScale(qreal value)
{
ui->doubleSpinBoxApproximationScale->setValue(value);
auto *path = qobject_cast<VisToolEllipticalArc *>(vis);
SCASSERT(path != nullptr)
path->SetApproximationScale(value);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief EvalRadiuses calculate value of radiuses * @brief EvalRadiuses calculate value of radiuses
@ -682,6 +698,7 @@ void DialogEllipticalArc::SaveData()
path->SetF1(m_f1); path->SetF1(m_f1);
path->SetF2(m_f2); path->SetF2(m_f2);
path->SetRotationAngle(m_rotationAngle); path->SetRotationAngle(m_rotationAngle);
path->SetApproximationScale(ui->doubleSpinBoxApproximationScale->value());
path->RefreshGeometry(); path->RefreshGeometry();
} }

View File

@ -74,6 +74,9 @@ public:
auto GetColor() const -> QString; auto GetColor() const -> QString;
void SetColor(const QString &value); void SetColor(const QString &value);
auto GetApproximationScale() const -> qreal;
void SetApproximationScale(qreal value);
void SetNotes(const QString &notes); void SetNotes(const QString &notes);
auto GetNotes() const -> QString; auto GetNotes() const -> QString;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>396</width> <width>396</width>
<height>595</height> <height>633</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -1026,16 +1026,39 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="4" column="0">
<widget class="QLabel" name="labelAlias"> <widget class="QLabel" name="labelAlias">
<property name="text"> <property name="text">
<string>Alias:</string> <string>Alias:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="4" column="1">
<widget class="QLineEdit" name="lineEditAlias"/> <widget class="QLineEdit" name="lineEditAlias"/>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Approximation scale:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxApproximationScale">
<property name="toolTip">
<string>Set approximation scale for this curve, 0 - use global value</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -125,6 +125,7 @@ VToolEllipticalArc* VToolEllipticalArc::Create(const QPointer<DialogTool> &dialo
initData.data = data; initData.data = data;
initData.parse = Document::FullParse; initData.parse = Document::FullParse;
initData.typeCreation = Source::FromGui; initData.typeCreation = Source::FromGui;
initData.approximationScale = dialogTool->GetApproximationScale();
initData.notes = dialogTool->GetNotes(); initData.notes = dialogTool->GetNotes();
initData.aliasSuffix = dialogTool->GetAliasSuffix(); initData.aliasSuffix = dialogTool->GetAliasSuffix();
//initData.approximationScale = dialogTool->GetApproximationScale(); // For future use //initData.approximationScale = dialogTool->GetApproximationScale(); // For future use
@ -333,6 +334,24 @@ void VToolEllipticalArc::SetFormulaRotationAngle(const VFormula &value)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
qreal VToolEllipticalArc::GetApproximationScale() const
{
QSharedPointer<VEllipticalArc> arc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
SCASSERT(arc.isNull() == false)
return arc->GetApproximationScale();
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEllipticalArc::SetApproximationScale(qreal value)
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
QSharedPointer<VEllipticalArc> arc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
arc->SetApproximationScale(value);
SaveOption(obj);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolEllipticalArc::ShowVisualization(bool show) void VToolEllipticalArc::ShowVisualization(bool show)
{ {
@ -388,6 +407,7 @@ void VToolEllipticalArc::SaveDialog(QDomElement &domElement, QList<quint32> &old
doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle()); doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle());
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle()); doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle());
doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale());
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias, dialogTool->GetAliasSuffix(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias, dialogTool->GetAliasSuffix(),
[](const QString &suffix) noexcept {return suffix.isEmpty();}); [](const QString &suffix) noexcept {return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
@ -430,6 +450,7 @@ void VToolEllipticalArc::SetVisualization()
visual->SetF2(trVars->FormulaToUser(elArc->GetFormulaF2(), osSeparator)); visual->SetF2(trVars->FormulaToUser(elArc->GetFormulaF2(), osSeparator));
visual->SetRotationAngle(trVars->FormulaToUser(elArc->GetFormulaRotationAngle(), osSeparator)); visual->SetRotationAngle(trVars->FormulaToUser(elArc->GetFormulaRotationAngle(), osSeparator));
visual->SetLineStyle(LineStyleToPenStyle(elArc->GetPenStyle())); visual->SetLineStyle(LineStyleToPenStyle(elArc->GetPenStyle()));
visual->SetApproximationScale(elArc->GetApproximationScale());
visual->SetMode(Mode::Show); visual->SetMode(Mode::Show);
visual->RefreshGeometry(); visual->RefreshGeometry();
} }

View File

@ -94,6 +94,9 @@ public:
VFormula GetFormulaRotationAngle() const; VFormula GetFormulaRotationAngle() const;
void SetFormulaRotationAngle(const VFormula &value); void SetFormulaRotationAngle(const VFormula &value);
qreal GetApproximationScale() const;
void SetApproximationScale(qreal value);
virtual void ShowVisualization(bool show) override; virtual void ShowVisualization(bool show) override;
protected slots: protected slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override; virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override;

View File

@ -236,6 +236,7 @@ auto VisToolEllipticalArc::DrawElArc(const VPointF &center, qreal radius1, qreal
qreal rotationAngle) -> VEllipticalArc qreal rotationAngle) -> VEllipticalArc
{ {
VEllipticalArc elArc(center, radius1, radius2, f1, f2, rotationAngle); VEllipticalArc elArc(center, radius1, radius2, f1, f2, rotationAngle);
elArc.SetApproximationScale(ApproximationScale());
DrawPath(this, elArc.GetPath(), elArc.DirectionArrows(), Color(VColor::MainColor), LineStyle(), Qt::RoundCap); DrawPath(this, elArc.GetPath(), elArc.DirectionArrows(), Color(VColor::MainColor), LineStyle(), Qt::RoundCap);
return elArc; return elArc;