diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index ce89f36fd..e4cc9d177 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -322,6 +322,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions() case VToolMove::Type: UpdateOptionsToolMove(); break; + case VToolEllipticalArc::Type: + UpdateOptionsToolEllipticalArc(); + break; default: break; } @@ -460,6 +463,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) case VToolMove::Type: ChangeDataToolMove(prop); break; + case VToolEllipticalArc::Type: + ChangeDataToolEllipticalArc(prop); + break; default: break; } @@ -1728,6 +1734,42 @@ void VToolOptionsPropertyBrowser::ChangeDataToolFlippingByAxis(VProperty *proper } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ChangeDataToolEllipticalArc(VProperty *property) +{ + SCASSERT(property != nullptr) + + QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolEllipticalArc *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 40://AttrRadius1 + i->SetFormulaRadius1(value.value()); + break; + case 41://AttrRadius2 + i->SetFormulaRadius2(value.value()); + break; + case 9://AttrAngle1 + i->SetFormulaF1(value.value()); + break; + case 10://AttrAngle2 + i->SetFormulaF2(value.value()); + break; + case 42://AttrRotationAngle + i->SetFormulaRotationAngle(value.value()); + break; + case 27://AttrColor + i->SetLineColor(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<setValue(i->Suffix()); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolEllipticalArc() +{ + VToolEllipticalArc *i = qgraphicsitem_cast(currentItem); + + QVariant valueFormulaRadius1; + valueFormulaRadius1.setValue(i->GetFormulaRadius1()); + idToProperty[AttrRadius1]->setValue(valueFormulaRadius1); + + QVariant valueFormulaRadius2; + valueFormulaRadius2.setValue(i->GetFormulaRadius2()); + idToProperty[AttrRadius2]->setValue(valueFormulaRadius2); + + QVariant valueFormulaF1; + valueFormulaF1.setValue(i->GetFormulaF1()); + idToProperty[AttrAngle1]->setValue(valueFormulaF1); + + QVariant valueFormulaF2; + valueFormulaF2.setValue(i->GetFormulaF2()); + idToProperty[AttrAngle2]->setValue(valueFormulaF2); + + QVariant valueFormulaRotationAngle; + valueFormulaRotationAngle.setValue(i->GetFormulaRotationAngle()); + idToProperty[AttrRotationAngle]->setValue(valueFormulaRotationAngle); + + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[AttrColor]->setValue(index); +} + //--------------------------------------------------------------------------------------------------------------------- QStringList VToolOptionsPropertyBrowser::PropertiesList() const { diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.h b/src/app/valentina/core/vtooloptionspropertybrowser.h index e5d74f23d..117fd3618 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.h +++ b/src/app/valentina/core/vtooloptionspropertybrowser.h @@ -161,6 +161,7 @@ private: void ChangeDataToolMove(VPE::VProperty *property); void ChangeDataToolFlippingByLine(VPE::VProperty *property); void ChangeDataToolFlippingByAxis(VPE::VProperty *property); + void ChangeDataToolEllipticalArc(VPE::VProperty *property); void ShowOptionsToolSinglePoint(QGraphicsItem *item); void ShowOptionsToolEndLine(QGraphicsItem *item); @@ -230,6 +231,7 @@ private: void UpdateOptionsToolMove(); void UpdateOptionsToolFlippingByLine(); void UpdateOptionsToolFlippingByAxis(); + void UpdateOptionsToolEllipticalArc(); }; #endif // VTOOLOPTIONSPROPERTYBROWSER_H diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index c3170d409..e4f5e9616 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -270,25 +270,25 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::Spline: { const QSharedPointer spl = data->GeometricObject(tool.getId()); - SCASSERT(spl != nullptr); + SCASSERT(not spl.isNull()); return spl->NameForHistory(tr("Curve")); } case Tool::CubicBezier: { const QSharedPointer spl = data->GeometricObject(tool.getId()); - SCASSERT(spl != nullptr); + SCASSERT(not spl.isNull()); return spl->NameForHistory(tr("Cubic bezier curve")); } case Tool::Arc: { const QSharedPointer arc = data->GeometricObject(tool.getId()); - SCASSERT(arc != nullptr); + SCASSERT(not arc.isNull()); return arc->NameForHistory(tr("Arc")); } case Tool::ArcWithLength: { const QSharedPointer arc = data->GeometricObject(tool.getId()); - SCASSERT(arc != nullptr); + SCASSERT(not arc.isNull()); return tr("%1 with length %2") .arg(arc->NameForHistory(tr("Arc"))) .arg(arc->GetLength()); @@ -296,13 +296,13 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::SplinePath: { const QSharedPointer splPath = data->GeometricObject(tool.getId()); - SCASSERT(splPath != nullptr); + SCASSERT(not splPath.isNull()); return splPath->NameForHistory(tr("Spline path")); } case Tool::CubicBezierPath: { const QSharedPointer splPath = data->GeometricObject(tool.getId()); - SCASSERT(splPath != nullptr); + SCASSERT(not splPath.isNull()); return splPath->NameForHistory(tr("Cubic bezier curve path")); } case Tool::PointOfContact: @@ -330,7 +330,7 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::CutArc: { const QSharedPointer arc = data->GeometricObject(AttrUInt(domElem, AttrArc)); - SCASSERT(arc != nullptr); + SCASSERT(not arc.isNull()); return tr("%1 - cut %2") .arg(PointName(tool.getId())) .arg(arc->NameForHistory(tr("arc"))); @@ -339,7 +339,7 @@ QString DialogHistory::Record(const VToolRecord &tool) { const quint32 splineId = AttrUInt(domElem, VToolCutSpline::AttrSpline); const QSharedPointer spl = data->GeometricObject(splineId); - SCASSERT(spl != nullptr); + SCASSERT(not spl.isNull()); return tr("%1 - cut %2") .arg(PointName(tool.getId())) .arg(spl->NameForHistory(tr("curve"))); @@ -349,7 +349,7 @@ QString DialogHistory::Record(const VToolRecord &tool) const quint32 splinePathId = AttrUInt(domElem, VToolCutSplinePath::AttrSplinePath); const QSharedPointer splPath = data->GeometricObject(splinePathId); - SCASSERT(splPath != nullptr); + SCASSERT(not splPath.isNull()); return tr("%1 - cut %2") .arg(PointName(tool.getId())) .arg(splPath->NameForHistory(tr("curve path"))); @@ -382,8 +382,10 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::EllipticalArc: { const QSharedPointer elArc = data->GeometricObject(tool.getId()); - SCASSERT(elArc != nullptr); - return elArc->NameForHistory(tr("Elliptical arc")); + SCASSERT(not elArc.isNull()); + return tr("%1 with length %2") + .arg(elArc->NameForHistory(tr("Elliptical arc"))) + .arg(elArc->GetLength()); } //Because "history" not only show history of pattern, but help restore current data for each pattern's //piece, we need add record about details and nodes, but don't show them. diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index 0b44070b6..473be076f 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -427,7 +427,7 @@ 0 0 - 117 + 130 110 @@ -536,7 +536,7 @@ 0 0 - 117 + 130 248 @@ -798,7 +798,7 @@ 0 0 - 117 + 130 248 @@ -1064,7 +1064,7 @@ 0 0 130 - 56 + 58 @@ -1078,7 +1078,7 @@ - :/icon/16x16/toolsectionelarc@2x.png:/icon/16x16/toolsectionelarc@2x.png + :/icon/16x16/toolsectionelarc.png:/icon/16x16/toolsectionelarc.png Elliptical Arc @@ -1116,7 +1116,7 @@ false - Arc + Elliptical Arc ... @@ -1144,7 +1144,7 @@ 0 0 130 - 356 + 326 @@ -1321,7 +1321,7 @@ 0 0 - 117 + 130 104 @@ -1431,7 +1431,7 @@ 0 0 130 - 356 + 326 diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 770590cbb..50b5d4de9 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -22,6 +22,7 @@ schema/pattern/v0.3.6.xsd schema/pattern/v0.3.7.xsd schema/pattern/v0.3.8.xsd + schema/pattern/v0.3.9.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd @@ -32,6 +33,5 @@ schema/individual_measurements/v0.3.1.xsd schema/individual_measurements/v0.3.2.xsd schema/individual_measurements/v0.3.3.xsd - schema/pattern/v0.3.9.xsd diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 20a153bc0..65882a7cd 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1409,8 +1409,10 @@ QStringList VAbstractPattern::ListExpressions() const { QStringList list; + // If new tool bring absolutely new type and has formula(s) create new method to cover it. list << ListPointExpressions(); list << ListArcExpressions(); + list << ListElArcExpressions(); list << ListSplineExpressions(); list << ListIncrementExpressions(); list << ListOperationExpressions(); @@ -1422,7 +1424,8 @@ QStringList VAbstractPattern::ListExpressions() const QStringList VAbstractPattern::ListPointExpressions() const { // Check if new tool doesn't bring new attribute with a formula. - // If no just increment number + // If no just increment a number. + // If new tool bring absolutely new type and has formula(s) create new method to cover it. Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49); QStringList expressions; @@ -1493,7 +1496,8 @@ QStringList VAbstractPattern::ListPointExpressions() const QStringList VAbstractPattern::ListArcExpressions() const { // Check if new tool doesn't bring new attribute with a formula. - // If no just increment number + // If no just increment number. + // If new tool bring absolutely new type and has formula(s) create new method to cover it. Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49); QStringList expressions; @@ -1542,6 +1546,69 @@ QStringList VAbstractPattern::ListArcExpressions() const return expressions; } +//--------------------------------------------------------------------------------------------------------------------- +QStringList VAbstractPattern::ListElArcExpressions() const +{ + // Check if new tool doesn't bring new attribute with a formula. + // If no just increment number. + // If new tool bring absolutely new type and has formula(s) create new method to cover it. + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49); + + QStringList expressions; + const QDomNodeList list = elementsByTagName(TagElArc); + for (int i=0; i < list.size(); ++i) + { + const QDomElement dom = list.at(i).toElement(); + + try + { + expressions.append(GetParametrString(dom, AttrRadius1)); + } + catch (VExceptionEmptyParameter &e) + { + Q_UNUSED(e) + } + + try + { + expressions.append(GetParametrString(dom, AttrRadius2)); + } + catch (VExceptionEmptyParameter &e) + { + Q_UNUSED(e) + } + + try + { + expressions.append(GetParametrString(dom, AttrAngle1)); + } + catch (VExceptionEmptyParameter &e) + { + Q_UNUSED(e) + } + + try + { + expressions.append(GetParametrString(dom, AttrAngle2)); + } + catch (VExceptionEmptyParameter &e) + { + Q_UNUSED(e) + } + + try + { + expressions.append(GetParametrString(dom, AttrRotationAngle)); + } + catch (VExceptionEmptyParameter &e) + { + Q_UNUSED(e) + } + } + + return expressions; +} + //--------------------------------------------------------------------------------------------------------------------- QStringList VAbstractPattern::ListSplineExpressions() const { @@ -1554,7 +1621,8 @@ QStringList VAbstractPattern::ListSplineExpressions() const QStringList VAbstractPattern::ListPathPointExpressions() const { // Check if new tool doesn't bring new attribute with a formula. - // If no just increment number + // If no just increment number. + // If new tool bring absolutely new type and has formula(s) create new method to cover it. Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49); QStringList expressions; @@ -1620,7 +1688,8 @@ QStringList VAbstractPattern::ListIncrementExpressions() const QStringList VAbstractPattern::ListOperationExpressions() const { // Check if new tool doesn't bring new attribute with a formula. - // If no just increment number + // If no just increment number. + // If new tool bring absolutely new type and has formula(s) create new method to cover it. Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49); QStringList expressions; diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 086ed7445..213479757 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -351,6 +351,7 @@ private: QStringList ListExpressions() const; QStringList ListPointExpressions() const; QStringList ListArcExpressions() const; + QStringList ListElArcExpressions() const; QStringList ListSplineExpressions() const; QStringList ListPathPointExpressions() const; QStringList ListIncrementExpressions() const; diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 96ea1b8ea..6fff85b5a 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -175,6 +175,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000307): return QStringLiteral("://schema/pattern/v0.3.7.xsd"); case (0x000308): + return QStringLiteral("://schema/pattern/v0.3.8.xsd"); + case (0x000309): return CurrentSchema; default: InvalidVersion(ver); @@ -274,6 +276,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(0x000308), fileName); V_FALLTHROUGH case (0x000308): + ToV0_3_9(); + ValidateXML(XSDSchema(0x000309), fileName); + V_FALLTHROUGH + case (0x000309): break; default: break; @@ -462,6 +468,13 @@ void VPatternConverter::ToV0_3_8() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_3_9() +{ + SetVersion(QStringLiteral("0.3.9")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 267bbbfd5..2a3676c25 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -55,10 +55,10 @@ public: // GCC 4.6 doesn't allow constexpr and const together #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406 static Q_DECL_CONSTEXPR int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 8); + static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 9); #else static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); - static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 8); + static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 9); #endif protected: @@ -97,6 +97,7 @@ private: void ToV0_3_6(); void ToV0_3_7(); void ToV0_3_8(); + void ToV0_3_9(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp b/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp index 50327af3f..841768ca2 100644 --- a/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp @@ -58,7 +58,31 @@ class VContainer; * @param parent parent widget */ DialogEllipticalArc::DialogEllipticalArc(const VContainer *data, const quint32 &toolId, QWidget *parent) -:DialogTool(data, toolId, parent), ui(new Ui::DialogEllipticalArc) + : DialogTool(data, toolId, parent), + ui(new Ui::DialogEllipticalArc), + flagRadius1(false), + flagRadius2(false), + flagF1(false), + flagF2(false), + flagRotationAngle(false), + timerRadius1(nullptr), + timerRadius2(nullptr), + timerF1(nullptr), + timerF2(nullptr), + timerRotationAngle(nullptr), + radius1(), + radius2(), + f1(), + f2(), + rotationAngle(), + formulaBaseHeightRadius1(0), + formulaBaseHeightRadius2(0), + formulaBaseHeightF1(0), + formulaBaseHeightF2(0), + formulaBaseHeightRotationAngle(0), + angleF1(INT_MIN), + angleF2(INT_MIN), + angleRotation(INT_MIN) { ui->setupUi(this); @@ -372,7 +396,7 @@ void DialogEllipticalArc::EvalAngles() angleF2 = Eval(ui->plainTextEditF2->toPlainText(), flagF2, ui->labelResultF2, degreeSymbol, false); labelEditFormula = ui->labelEditRotationAngle; - rotationAngle = Eval(ui->plainTextEditRotationAngle->toPlainText(), flagRotationAngle, + angleRotation = Eval(ui->plainTextEditRotationAngle->toPlainText(), flagRotationAngle, ui->labelResultRotationAngle, degreeSymbol, false); CheckAngles(); diff --git a/src/libs/vtools/visualization/path/vistoolarc.cpp b/src/libs/vtools/visualization/path/vistoolarc.cpp index 10588beaf..66af87d4d 100644 --- a/src/libs/vtools/visualization/path/vistoolarc.cpp +++ b/src/libs/vtools/visualization/path/vistoolarc.cpp @@ -61,7 +61,7 @@ void VisToolArc::RefreshGeometry() const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(arcCenter, *first, supportColor); - if (not qFuzzyIsNull(radius) && f1 >= 0 && f2 >= 0 && not VFuzzyComparePossibleNulls(f1, f2)) + if (not qFuzzyIsNull(radius) && f1 >= 0 && f2 >= 0) { VArc arc = VArc (*first, radius, f1, f2); DrawPath(this, arc.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap); diff --git a/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp b/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp index 5e636367e..381db5763 100644 --- a/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp +++ b/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp @@ -58,8 +58,7 @@ void VisToolEllipticalArc::RefreshGeometry() const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(arcCenter, *first, supportColor); - if (not qFuzzyIsNull(radius1) && not qFuzzyIsNull(radius2) && f1 >= 0 && f2 >= 0 && rotationAngle >= 0 - && not VFuzzyComparePossibleNulls(f1, f2)) + if (not qFuzzyIsNull(radius1) && not qFuzzyIsNull(radius2) && f1 >= 0 && f2 >= 0 && rotationAngle >= 0) { VEllipticalArc elArc = VEllipticalArc(*first, radius1, radius2, f1, f2, rotationAngle); DrawPath(this, elArc.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap);