Merge with feature. Fixed case with duplicate names of curves if they connect

same points.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-02-16 15:42:47 +02:00
commit eafb843c85
38 changed files with 1007 additions and 380 deletions

View File

@ -1,4 +1,5 @@
# Version 0.5.0
- Fixed case with duplicate names of curves if they connect same points.
- [#216] Better powerful way creation curved path.
- Improved exporting to dxf. QPainterPath export as Polyline.
- Show additional message dialog if measurements was changed. Related to issue [#440].

View File

@ -445,11 +445,12 @@ void VToolOptionsPropertyBrowser::AddPropertyFormula(const QString &propertyName
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &propertyName)
void VToolOptionsPropertyBrowser::AddPropertyObjectName(Tool *i, const QString &propertyName, bool readOnly)
{
VStringProperty *itemName = new VStringProperty(propertyName);
auto itemName = new VStringProperty(propertyName);
itemName->setClearButtonEnable(true);
itemName->setValue(i->name());
itemName->setReadOnly(readOnly);
AddProperty(itemName, AttrName);
}
@ -1301,6 +1302,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSpline(VProperty *property)
SCASSERT(i != nullptr);
switch (PropertiesList().indexOf(id))
{
case 0: // AttrName
Q_UNREACHABLE();//The attribute is read only
break;
case 25: // AttrKCurve
{
VSpline spl = i->getSpline();
@ -1329,6 +1333,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSplinePath(VProperty *property)
SCASSERT(i != nullptr);
switch (PropertiesList().indexOf(id))
{
case 0: // AttrName
Q_UNREACHABLE();//The attribute is read only
break;
case 25: // AttrKCurve
{
VSplinePath splPath = i->getSplinePath();
@ -1431,7 +1438,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item
i->ShowVisualization(true);
formView->setTitle(tr("Base point"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
VPointFProperty* itemPosition = new VPointFProperty(tr("Position"));
itemPosition->setValue(i->pos());
@ -1445,7 +1452,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolEndLine(QGraphicsItem *item)
i->ShowVisualization(true);
formView->setTitle(tr("Point at distance and angle"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), AttrLineColor);
AddPropertyFormula(tr("Length"), i->GetFormulaLength(), AttrLength);
@ -1459,7 +1466,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolAlongLine(QGraphicsItem *item)
i->ShowVisualization(true);
formView->setTitle(tr("Point at distance along line"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), AttrLineColor);
AddPropertyFormula(tr("Length"), i->GetFormulaLength(), AttrLength);
@ -1498,7 +1505,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item)
i->ShowVisualization(true);
formView->setTitle(tr("Point along bisector"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), AttrLineColor);
AddPropertyFormula(tr("Length"), i->GetFormulaLength(), AttrLength);
@ -1522,7 +1529,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item)
i->ShowVisualization(true);
formView->setTitle(tr("Cut arc tool"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyFormula(tr("Length"), i->GetFormula(), AttrLength);
AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), AttrColor);
}
@ -1534,7 +1541,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSpline(QGraphicsItem *item)
i->ShowVisualization(true);
formView->setTitle(tr("Tool for segmenting a curve"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyFormula(tr("Length"), i->GetFormula(), AttrLength);
AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), AttrColor);
}
@ -1546,7 +1553,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSplinePath(QGraphicsItem *it
i->ShowVisualization(true);
formView->setTitle(tr("Tool segment a pathed curve"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyFormula(tr("Length"), i->GetFormula(), AttrLength);
AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), AttrColor);
}
@ -1558,7 +1565,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolHeight(QGraphicsItem *item)
i->ShowVisualization(true);
formView->setTitle(tr("Perpendicular point along line"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), AttrLineColor);
}
@ -1583,7 +1590,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersect(QGraphicsItem *it
i->ShowVisualization(true);
formView->setTitle(tr("Point at line intersection"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
}
//---------------------------------------------------------------------------------------------------------------------
@ -1594,7 +1601,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolNormal(QGraphicsItem *item)
formView->setTitle(tr("Point along perpendicular"));
AddPropertyFormula(tr("Length"), i->GetFormulaLength(), AttrLength);
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), AttrLineColor);
@ -1613,7 +1620,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfContact(QGraphicsItem *i
i->ShowVisualization(true);
formView->setTitle(tr("Point at intersection of arc and line"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyFormula(tr("Radius"), i->getArcRadius(), AttrRadius);
}
@ -1624,7 +1631,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersection(QGraphicsIt
i->ShowVisualization(true);
formView->setTitle(tr("Tool to make point from x & y of two other points"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
}
//---------------------------------------------------------------------------------------------------------------------
@ -1634,7 +1641,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersectionArcs(QGraphi
i->ShowVisualization(true);
formView->setTitle(tr("Tool to make point from intersection two arcs"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyCrossPoint(i, tr("Take"));
}
@ -1645,7 +1652,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersectionCircles(QGra
i->ShowVisualization(true);
formView->setTitle(tr("Tool to make point from intersection two circles"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyFormula(tr("First circle radius"), i->GetFirstCircleRadius(), AttrC1Radius);
AddPropertyFormula(tr("Second circle radius"), i->GetSecondCircleRadius(), AttrC2Radius);
AddPropertyCrossPoint(i, tr("Take"));
@ -1658,7 +1665,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersectionCurves(QGrap
i->ShowVisualization(true);
formView->setTitle(tr("Tool to make point from intersection two curves"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyVCrossPoint(i, tr("Vertical correction"));
AddPropertyHCrossPoint(i, tr("Horizontal correction"));
}
@ -1670,7 +1677,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointFromCircleAndTangent(QGrap
i->ShowVisualization(true);
formView->setTitle(tr("Tool to make point from circle and tangent"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyFormula(tr("Circle radius"), i->GetCircleRadius(), AttrCRadius);
AddPropertyCrossPoint(i, tr("Take"));
}
@ -1682,7 +1689,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointFromArcAndTangent(QGraphic
i->ShowVisualization(true);
formView->setTitle(tr("Tool to make point from arc and tangent"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyCrossPoint(i, tr("Take"));
}
@ -1693,7 +1700,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *it
i->ShowVisualization(true);
formView->setTitle(tr("Special point on shoulder"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), AttrLineColor);
AddPropertyFormula(tr("Length"), i->GetFormulaLength(), AttrLength);
@ -1706,6 +1713,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item)
i->ShowVisualization(true);
formView->setTitle(tr("Curve tool"));
AddPropertyObjectName(i, tr("Name"), true);
VDoubleProperty* itemFactor = new VDoubleProperty(tr("Curve factor"));
VSpline spl = i->getSpline();
itemFactor->setSetting("Min", 0.1);
@ -1724,6 +1733,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSplinePath(QGraphicsItem *item)
i->ShowVisualization(true);
formView->setTitle(tr("Tool for path curve"));
AddPropertyObjectName(i, tr("Name"), true);
VDoubleProperty* itemFactor = new VDoubleProperty(tr("Curve factor"));
VSplinePath splPath = i->getSplinePath();
itemFactor->setSetting("Min", 0.1);
@ -1742,7 +1753,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolTriangle(QGraphicsItem *item)
i->ShowVisualization(true);
formView->setTitle(tr("Tool triangle"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
}
//---------------------------------------------------------------------------------------------------------------------
@ -1752,7 +1763,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersectAxis(QGraphicsItem
i->ShowVisualization(true);
formView->setTitle(tr("Point intersection line and axis"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), AttrLineColor);
AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), AttrAngle);
@ -1765,7 +1776,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCurveIntersectAxis(QGraphicsIte
i->ShowVisualization(true);
formView->setTitle(tr("Point intersection curve and axis"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyObjectName(i, tr("Point label"));
AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics());
AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), AttrLineColor);
AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), AttrAngle);
@ -2112,25 +2123,21 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint()
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
{
VToolSpline *i = qgraphicsitem_cast<VToolSpline *>(currentItem);
auto i = qgraphicsitem_cast<VToolSpline *>(currentItem);
VSpline spl = i->getSpline();
idToProperty[AttrKCurve]->setValue(spl.GetKcurve());
const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor());
idToProperty[AttrColor]->setValue(index);
idToProperty[AttrName]->setValue(i->name());
idToProperty[AttrKCurve]->setValue(i->getSpline().GetKcurve());
idToProperty[AttrColor]->setValue(VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolSplinePath()
{
VToolSplinePath *i = qgraphicsitem_cast<VToolSplinePath *>(currentItem);
auto i = qgraphicsitem_cast<VToolSplinePath *>(currentItem);
VSplinePath splPath = i->getSplinePath();
idToProperty[AttrKCurve]->setValue(splPath.GetKCurve());
const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor());
idToProperty[AttrColor]->setValue(index);
idToProperty[AttrName]->setValue(i->name());
idToProperty[AttrKCurve]->setValue(i->getSplinePath().GetKCurve());
idToProperty[AttrColor]->setValue(VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -87,7 +87,7 @@ private:
void SetHCrossCurvesPoint(const QVariant &value);
template<class Tool>
void AddPropertyPointName(Tool *i, const QString &propertyName);
void AddPropertyObjectName(Tool *i, const QString &propertyName, bool readOnly = false);
template<class Tool>
void AddPropertyPointName1(Tool *i, const QString &propertyName);

View File

@ -1860,9 +1860,18 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, const QDomElement &dom
const qreal kAsm2 = GetParametrDouble(domElement, AttrKAsm2, "1.0");
const qreal kCurve = GetParametrDouble(domElement, AttrKCurve, "1.0");
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, color, scene, this, data,
parse, Source::FromFile);
const auto p1 = data->GeometricObject<VPointF>(point1);
const auto p4 = data->GeometricObject<VPointF>(point4);
VSpline spline(*p1, *p4, angle1, angle2, kAsm1, kAsm2, kCurve);
if (duplicate > 0)
{
spline.SetDuplicate(duplicate);
}
VToolSpline::Create(id, spline, color, scene, this, data, parse, Source::FromFile);
}
catch (const VExceptionBadId &e)
{
@ -1885,7 +1894,13 @@ void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement
ToolsCommonAttributes(domElement, id);
const qreal kCurve = GetParametrDouble(domElement, AttrKCurve, "1.0");
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
VSplinePath *path = new VSplinePath(kCurve);
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
auto path = new VSplinePath(kCurve);
if (duplicate > 0)
{
path->SetDuplicate(duplicate);
}
const QDomNodeList nodeList = domElement.childNodes();
const qint32 num = nodeList.size();

View File

@ -102,6 +102,7 @@ const QString AttrPoint4 = QStringLiteral("point4");
const QString AttrKAsm1 = QStringLiteral("kAsm1");
const QString AttrKAsm2 = QStringLiteral("kAsm2");
const QString AttrKCurve = QStringLiteral("kCurve");
const QString AttrDuplicate = QStringLiteral("duplicate");
const QString AttrPathPoint = QStringLiteral("pathPoint");
const QString AttrPSpline = QStringLiteral("pSpline");
const QString AttrAxisP1 = QStringLiteral("axisP1");

View File

@ -104,6 +104,7 @@ extern const QString AttrPoint4;
extern const QString AttrKAsm1;
extern const QString AttrKAsm2;
extern const QString AttrKCurve;
extern const QString AttrDuplicate;
extern const QString AttrPathPoint;
extern const QString AttrPSpline;
extern const QString AttrAxisP1;

View File

@ -11,6 +11,7 @@
<file>schema/pattern/v0.2.3.xsd</file>
<file>schema/pattern/v0.2.4.xsd</file>
<file>schema/pattern/v0.2.5.xsd</file>
<file>schema/pattern/v0.2.6.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>

View File

@ -0,0 +1,435 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- XML Schema Generated from XML Document-->
<xs:element name="pattern">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="version" type="formatVersion"></xs:element>
<xs:element name="unit" type="units"></xs:element>
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="gradation" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="heights">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="h92" type="xs:boolean"></xs:attribute>
<xs:attribute name="h98" type="xs:boolean"></xs:attribute>
<xs:attribute name="h104" type="xs:boolean"></xs:attribute>
<xs:attribute name="h110" type="xs:boolean"></xs:attribute>
<xs:attribute name="h116" type="xs:boolean"></xs:attribute>
<xs:attribute name="h122" type="xs:boolean"></xs:attribute>
<xs:attribute name="h128" type="xs:boolean"></xs:attribute>
<xs:attribute name="h134" type="xs:boolean"></xs:attribute>
<xs:attribute name="h140" type="xs:boolean"></xs:attribute>
<xs:attribute name="h146" type="xs:boolean"></xs:attribute>
<xs:attribute name="h152" type="xs:boolean"></xs:attribute>
<xs:attribute name="h158" type="xs:boolean"></xs:attribute>
<xs:attribute name="h164" type="xs:boolean"></xs:attribute>
<xs:attribute name="h170" type="xs:boolean"></xs:attribute>
<xs:attribute name="h176" type="xs:boolean"></xs:attribute>
<xs:attribute name="h182" type="xs:boolean"></xs:attribute>
<xs:attribute name="h188" type="xs:boolean"></xs:attribute>
<xs:attribute name="h194" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="sizes">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="s22" type="xs:boolean"></xs:attribute>
<xs:attribute name="s24" type="xs:boolean"></xs:attribute>
<xs:attribute name="s26" type="xs:boolean"></xs:attribute>
<xs:attribute name="s28" type="xs:boolean"></xs:attribute>
<xs:attribute name="s30" type="xs:boolean"></xs:attribute>
<xs:attribute name="s32" type="xs:boolean"></xs:attribute>
<xs:attribute name="s34" type="xs:boolean"></xs:attribute>
<xs:attribute name="s36" type="xs:boolean"></xs:attribute>
<xs:attribute name="s38" type="xs:boolean"></xs:attribute>
<xs:attribute name="s40" type="xs:boolean"></xs:attribute>
<xs:attribute name="s42" type="xs:boolean"></xs:attribute>
<xs:attribute name="s44" type="xs:boolean"></xs:attribute>
<xs:attribute name="s46" type="xs:boolean"></xs:attribute>
<xs:attribute name="s48" type="xs:boolean"></xs:attribute>
<xs:attribute name="s50" type="xs:boolean"></xs:attribute>
<xs:attribute name="s52" type="xs:boolean"></xs:attribute>
<xs:attribute name="s54" type="xs:boolean"></xs:attribute>
<xs:attribute name="s56" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="custom" type="xs:boolean"></xs:attribute>
<xs:attribute name="defHeight" type="baseHeight"></xs:attribute>
<xs:attribute name="defSize" type="baseSize"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="measurements" type="xs:string"></xs:element>
<xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="increment" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="description" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="name" type="shortName" use="required"></xs:attribute>
<xs:attribute name="formula" type="xs:string" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="incrementName">
<xs:selector xpath="increment"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="draw" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="calculation" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="x" type="xs:double"></xs:attribute>
<xs:attribute name="y" type="xs:double"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="name" type="shortName"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="thirdPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="basePoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="pShoulder" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="splinePath" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="spline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="axisP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="axisP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="arc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="firstArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="crossPoint" type="crossType"></xs:attribute>
<xs:attribute name="vCrossPoint" type="crossType"></xs:attribute>
<xs:attribute name="hCrossPoint" type="crossType"></xs:attribute>
<xs:attribute name="c1Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c2Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c1Radius" type="xs:string"></xs:attribute>
<xs:attribute name="c2Radius" type="xs:string"></xs:attribute>
<xs:attribute name="cRadius" type="xs:string"></xs:attribute>
<xs:attribute name="tangent" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="cCenter" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="name1" type="shortName"></xs:attribute>
<xs:attribute name="mx1" type="xs:double"></xs:attribute>
<xs:attribute name="my1" type="xs:double"></xs:attribute>
<xs:attribute name="name2" type="shortName"></xs:attribute>
<xs:attribute name="mx2" type="xs:double"></xs:attribute>
<xs:attribute name="my2" type="xs:double"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP3" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP2" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="pathPoint" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="kAsm2" type="xs:string"></xs:attribute>
<xs:attribute name="pSpline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="kCurve" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:double"></xs:attribute>
<xs:attribute name="kAsm2" type="xs:double"></xs:attribute>
<xs:attribute name="angle1" type="xs:double"></xs:attribute>
<xs:attribute name="angle2" type="xs:double"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point4" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="duplicate" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="modeling" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="tools" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="det" minOccurs="2" maxOccurs="2">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="children" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="indexD1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="indexD2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="details" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="detail" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="supplement" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="width" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="closed" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="readOnly" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^0-9*/^+\-=\s()?%:;!.,`'\&quot;]){1,1}([^*/^+\-=\s()?%:;!.,`'\&quot;]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">
<xs:restriction base="xs:string">
<xs:enumeration value="mm"/>
<xs:enumeration value="cm"/>
<xs:enumeration value="inch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="measurementsTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="standard"/>
<xs:enumeration value="individual"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="^(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="colors">
<xs:restriction base="xs:string">
<xs:enumeration value="black"/>
<xs:enumeration value="green"/>
<xs:enumeration value="blue"/>
<xs:enumeration value="darkRed"/>
<xs:enumeration value="darkGreen"/>
<xs:enumeration value="darkBlue"/>
<xs:enumeration value="yellow"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseHeight">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="92"/>
<xs:enumeration value="98"/>
<xs:enumeration value="104"/>
<xs:enumeration value="110"/>
<xs:enumeration value="116"/>
<xs:enumeration value="122"/>
<xs:enumeration value="128"/>
<xs:enumeration value="134"/>
<xs:enumeration value="140"/>
<xs:enumeration value="146"/>
<xs:enumeration value="152"/>
<xs:enumeration value="158"/>
<xs:enumeration value="164"/>
<xs:enumeration value="170"/>
<xs:enumeration value="176"/>
<xs:enumeration value="182"/>
<xs:enumeration value="188"/>
<xs:enumeration value="194"/>
<xs:enumeration value="920"/>
<xs:enumeration value="980"/>
<xs:enumeration value="1040"/>
<xs:enumeration value="1100"/>
<xs:enumeration value="1160"/>
<xs:enumeration value="1220"/>
<xs:enumeration value="1280"/>
<xs:enumeration value="1340"/>
<xs:enumeration value="1400"/>
<xs:enumeration value="1460"/>
<xs:enumeration value="1520"/>
<xs:enumeration value="1580"/>
<xs:enumeration value="1640"/>
<xs:enumeration value="1700"/>
<xs:enumeration value="1760"/>
<xs:enumeration value="1820"/>
<xs:enumeration value="1880"/>
<xs:enumeration value="1940"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseSize">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="22"/>
<xs:enumeration value="24"/>
<xs:enumeration value="26"/>
<xs:enumeration value="28"/>
<xs:enumeration value="30"/>
<xs:enumeration value="32"/>
<xs:enumeration value="34"/>
<xs:enumeration value="36"/>
<xs:enumeration value="38"/>
<xs:enumeration value="40"/>
<xs:enumeration value="42"/>
<xs:enumeration value="44"/>
<xs:enumeration value="46"/>
<xs:enumeration value="48"/>
<xs:enumeration value="50"/>
<xs:enumeration value="52"/>
<xs:enumeration value="54"/>
<xs:enumeration value="56"/>
<xs:enumeration value="220"/>
<xs:enumeration value="240"/>
<xs:enumeration value="260"/>
<xs:enumeration value="280"/>
<xs:enumeration value="300"/>
<xs:enumeration value="320"/>
<xs:enumeration value="340"/>
<xs:enumeration value="360"/>
<xs:enumeration value="380"/>
<xs:enumeration value="400"/>
<xs:enumeration value="420"/>
<xs:enumeration value="440"/>
<xs:enumeration value="460"/>
<xs:enumeration value="480"/>
<xs:enumeration value="500"/>
<xs:enumeration value="520"/>
<xs:enumeration value="540"/>
<xs:enumeration value="560"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="crossType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -43,8 +43,8 @@
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.5");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.5.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.6");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.6.xsd");
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName)
@ -107,6 +107,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000204):
return QStringLiteral("://schema/pattern/v0.2.4.xsd");
case (0x000205):
return QStringLiteral("://schema/pattern/v0.2.5.xsd");
case (0x000206):
return CurrentSchema;
default:
InvalidVersion(ver);
@ -192,6 +194,13 @@ void VPatternConverter::ApplyPatches()
V_FALLTHROUGH
}
case (0x000205):
{
ToV0_2_6();
const QString schema = XSDSchema(0x000206);
ValidateXML(schema, fileName);
V_FALLTHROUGH
}
case (0x000206):
break;
default:
break;
@ -299,6 +308,13 @@ void VPatternConverter::ToV0_2_5()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_2_6()
{
SetVersion(QStringLiteral("0.2.6"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -66,6 +66,7 @@ private:
void ToV0_2_3();
void ToV0_2_4();
void ToV0_2_5();
void ToV0_2_6();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -27,17 +27,18 @@
*************************************************************************/
#include "vabstractcurve.h"
#include "vabstractcurve_p.h"
#include <QPainterPath>
#include <QDebug>
VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode)
:VGObject(type, idObject, mode)
:VGObject(type, idObject, mode), d (new VAbstractCurveData())
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::VAbstractCurve(const VAbstractCurve &curve)
:VGObject(curve)
:VGObject(curve), d (curve.d)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -48,9 +49,14 @@ VAbstractCurve &VAbstractCurve::operator=(const VAbstractCurve &curve)
return *this;
}
VGObject::operator=(curve);
d = curve.d;
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::~VAbstractCurve()
{}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse) const
{
@ -165,6 +171,19 @@ bool VAbstractCurve::IsIntersectLine(const QLineF &line) const
return not points.isEmpty();
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VAbstractCurve::GetDuplicate() const
{
return d->duplicate;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractCurve::SetDuplicate(quint32 number)
{
d->duplicate = number;
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractCurve::CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line)
{

View File

@ -37,6 +37,7 @@ enum class PathDirection : char { Hide, Show };
class QPainterPath;
class QLineF;
class VAbstractCurveData;
class VAbstractCurve :public VGObject
{
@ -45,6 +46,7 @@ public:
const Draw &mode = Draw::Calculation);
explicit VAbstractCurve(const VAbstractCurve &curve);
VAbstractCurve& operator= (const VAbstractCurve &curve);
virtual ~VAbstractCurve() Q_DECL_OVERRIDE;
virtual QVector<QPointF> GetPoints() const =0;
QVector<QPointF> GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse = false) const;
@ -57,12 +59,20 @@ public:
virtual qreal GetStartAngle () const=0;
virtual qreal GetEndAngle () const=0;
quint32 GetDuplicate() const;
void SetDuplicate(quint32 number);
static QVector<QPointF> CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line);
protected:
QPainterPath ShowDirection(const QVector<QPointF> &points) const;
virtual void CreateName() =0;
private:
QSharedDataPointer<VAbstractCurveData> d;
static QVector<QPointF> FromBegin(const QVector<QPointF> &points, const QPointF &begin);
static QVector<QPointF> ToEnd(const QVector<QPointF> &points, const QPointF &end);
};
Q_DECLARE_TYPEINFO(VAbstractCurve, Q_MOVABLE_TYPE);
#endif // VABSTRACTCURVE_H

View File

@ -0,0 +1,67 @@
/************************************************************************
**
** @file vabstractcurve_p.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 15 2, 2016
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2016 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VABSTRACTCURVE_P_H
#define VABSTRACTCURVE_P_H
#include <QSharedData>
#ifdef Q_CC_GNU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#endif
class VAbstractCurveData : public QSharedData
{
public:
VAbstractCurveData ()
: duplicate(0)
{}
VAbstractCurveData(const VAbstractCurveData &curve)
: QSharedData(curve), duplicate(curve.duplicate)
{}
virtual ~VAbstractCurveData();
/** @brief duplicate helps create unique name for curves that connects the same start and finish points. */
quint32 duplicate;
private:
VAbstractCurveData &operator=(const VAbstractCurveData &) Q_DECL_EQ_DELETE;
};
VAbstractCurveData::~VAbstractCurveData()
{}
#ifdef Q_CC_GNU
#pragma GCC diagnostic pop
#endif
#endif // VABSTRACTCURVE_P_H

View File

@ -58,14 +58,14 @@ VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QStri
: VAbstractCurve(GOType::Arc, idObject, mode),
d (new VArcData(center, radius, formulaRadius, f1, formulaF1, f2, formulaF2))
{
ArcName();
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
VArc::VArc(VPointF center, qreal radius, qreal f1, qreal f2)
: VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1, f2))
{
ArcName();
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
@ -74,7 +74,7 @@ VArc::VArc(qreal length, QString formulaLength, VPointF center, qreal radius, QS
: VAbstractCurve(GOType::Arc, idObject, mode),
d (new VArcData(formulaLength, center, radius, formulaRadius, f1, formulaF1))
{
ArcName();
CreateName();
FindF2(length);
}
@ -82,7 +82,7 @@ VArc::VArc(qreal length, QString formulaLength, VPointF center, qreal radius, QS
VArc::VArc(qreal length, VPointF center, qreal radius, qreal f1)
: VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1))
{
ArcName();
CreateName();
FindF2(length);
}
@ -126,7 +126,7 @@ qreal VArc::GetLength() const
qreal length = (M_PI * d->radius)/180 * AngleArc();
if (d->isFlipped)
{
length = length * -1;
length *= -1;
}
return length;
@ -312,13 +312,25 @@ QPointF VArc::CutArc(const qreal &length) const
void VArc::setId(const quint32 &id)
{
VAbstractCurve::setId(id);
setName(ARC_ + QString("%1_%2").arg(d->center.name()).arg(id));
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::ArcName()
void VArc::CreateName()
{
setName(ARC_ + QString("%1").arg(this->GetCenter().name()));
QString name = ARC_ + QString("%1").arg(this->GetCenter().name());
if (VAbstractCurve::id() != NULL_ID)
{
name += QString("_%1").arg(VAbstractCurve::id());
}
if (GetDuplicate() > 0)
{
name += QString("_%1").arg(GetDuplicate());
}
setName(name);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -80,10 +80,11 @@ public:
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
QPointF CutArc (const qreal &length) const;
virtual void setId(const quint32 &id) Q_DECL_OVERRIDE;
protected:
virtual void CreateName() Q_DECL_OVERRIDE;
private:
QSharedDataPointer<VArcData> d;
void ArcName();
void FindF2(qreal length);
qreal MaxLength() const;

View File

@ -27,4 +27,5 @@ HEADERS += \
$$PWD/vsplinepath_p.h \
$$PWD/vsplinepoint.h \
$$PWD/vsplinepoint_p.h \
$$PWD/vgeometrydef.h
$$PWD/vgeometrydef.h \
$$PWD/vabstractcurve_p.h

View File

@ -600,7 +600,13 @@ qreal VSpline::CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2)
*/
void VSpline::CreateName()
{
setName(SPL_ + QString("%1_%2").arg(this->GetP1().name(), this->GetP4().name()));
QString name = SPL_ + QString("%1_%2").arg(this->GetP1().name()).arg(this->GetP4().name());
if (GetDuplicate() > 0)
{
name += QString("_%1").arg(GetDuplicate());
}
setName(name);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -76,13 +76,13 @@ public:
qreal ParamT(const QPointF &pBt) const;
protected:
static QVector<QPointF> GetPoints (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 );
virtual void CreateName() Q_DECL_OVERRIDE;
private:
QSharedDataPointer<VSplineData> d;
static qreal LengthBezier (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 );
static void PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4,
qint16 level, QVector<qreal> &px, QVector<qreal> &py);
static qreal CalcSqDistance ( qreal x1, qreal y1, qreal x2, qreal y2);
void CreateName();
QVector<qreal> CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4,
qreal pointCoord) const;
static qint32 Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c);

View File

@ -59,13 +59,7 @@ void VSplinePath::append(const VSplinePoint &point)
}
d->path.append(point);
QString name = splPath;
name.append(QString("_%1").arg(d->path.first().P().name()));
if (d->path.size() > 1)
{
name.append(QString("_%1").arg(d->path.last().P().name()));
}
setName(name);
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
@ -92,8 +86,8 @@ VSpline VSplinePath::GetSpline(qint32 index) const
{
throw VException(tr("This spline does not exist."));
}
const VSplinePoint &p1 = d->path.at(index-1);
const VSplinePoint &p2 = d->path.at(index);
const VSplinePoint &p1 = d->path.at(index-1);
const VSplinePoint &p2 = d->path.at(index);
VSpline spl(p1.P(), p2.P(), p1.Angle2(), p2.Angle1(), p1.KAsm2(), p2.KAsm1(), d->kCurve);
return spl;
}
@ -104,8 +98,8 @@ QPainterPath VSplinePath::GetPath(PathDirection direction) const
QPainterPath painterPath;
for (qint32 i = 1; i <= Count(); ++i)
{
const VSplinePoint &p1 = d->path.at(i-1);
const VSplinePoint &p2 = d->path.at(i);
const VSplinePoint &p1 = d->path.at(i-1);
const VSplinePoint &p2 = d->path.at(i);
VSpline spl(p1.P(), p2.P(), p1.Angle2(), p2.Angle1(), p1.KAsm2(), p2.KAsm1(), d->kCurve);
painterPath.addPath(spl.GetPath(direction));
}
@ -118,8 +112,8 @@ QVector<QPointF> VSplinePath::GetPoints() const
QVector<QPointF> pathPoints;
for (qint32 i = 1; i <= Count(); ++i)
{
const VSplinePoint &p1 = d->path.at(i-1);
const VSplinePoint &p2 = d->path.at(i);
const VSplinePoint &p1 = d->path.at(i-1);
const VSplinePoint &p2 = d->path.at(i);
VSpline spl(p1.P(), p2.P(), p1.Angle2(), p2.Angle1(), p1.KAsm2(), p2.KAsm1(), d->kCurve);
pathPoints += spl.GetPoints();
}
@ -132,8 +126,8 @@ qreal VSplinePath::GetLength() const
qreal length = 0;
for (qint32 i = 1; i <= Count(); ++i)
{
const VSplinePoint &p1 = d->path.at(i-1);
const VSplinePoint &p2 = d->path.at(i);
const VSplinePoint &p1 = d->path.at(i-1);
const VSplinePoint &p2 = d->path.at(i);
VSpline spl(p1.P(), p2.P(), p1.Angle2(), p2.Angle1(),
p1.KAsm2(), p2.KAsm1(), d->kCurve);
length += spl.GetLength();
@ -222,10 +216,10 @@ QPointF VSplinePath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF
fullLength = 0;
for (qint32 i = 1; i <= Count(); ++i)
{
const VSplinePoint &point1 = d->path.at(i-1);
const VSplinePoint &point2 = d->path.at(i);
VSpline spl = VSpline(point1.P(), point2.P(), point1.Angle2(), point2.Angle1(), point1.KAsm2(),
point2.KAsm1(), d->kCurve);
const VSplinePoint &point1 = d->path.at(i-1);
const VSplinePoint &point2 = d->path.at(i);
VSpline spl = VSpline(point1.P(), point2.P(), point1.Angle2(), point2.Angle1(), point1.KAsm2(),
point2.KAsm1(), d->kCurve);
fullLength += spl.GetLength();
if (fullLength > length)
{
@ -243,8 +237,8 @@ int VSplinePath::Segment(const QPointF &p) const
int index = -1;
for (qint32 i = 1; i <= Count(); ++i)
{
const VSplinePoint &p1 = d->path.at(i-1);
const VSplinePoint &p2 = d->path.at(i);
const VSplinePoint &p1 = d->path.at(i-1);
const VSplinePoint &p2 = d->path.at(i);
VSpline spl = VSpline(p1.P(), p2.P(), p1.Angle2(), p2.Angle1(), p1.KAsm2(), p2.KAsm1(), d->kCurve);
const qreal t = spl.ParamT(p);
@ -288,6 +282,27 @@ qreal VSplinePath::GetEndAngle() const
}
}
//---------------------------------------------------------------------------------------------------------------------
void VSplinePath::CreateName()
{
QString name;
if (not d->path.isEmpty())
{
name = splPath;
name.append(QString("_%1").arg(d->path.first().P().name()));
if (d->path.size() > 1)
{
name.append(QString("_%1").arg(d->path.last().P().name()));
}
if (GetDuplicate() > 0)
{
name += QString("_%1").arg(GetDuplicate());
}
}
setName(name);
}
//---------------------------------------------------------------------------------------------------------------------
qint32 VSplinePath::CountPoint() const
{
@ -304,6 +319,7 @@ QVector<VSplinePoint> VSplinePath::GetSplinePath() const
void VSplinePath::Clear()
{
d->path.clear();
SetDuplicate(0);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -178,6 +178,8 @@ public:
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
protected:
virtual void CreateName() Q_DECL_OVERRIDE;
private:
QSharedDataPointer<VSplinePathData> d;
};

View File

@ -43,7 +43,7 @@
* @param parent parent widget
*/
DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogSpline), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1)
:DialogTool(data, toolId, parent), ui(new Ui::DialogSpline), spl(), newDuplicate(-1)
{
ui->setupUi(this);
InitOkCancelApply(ui);
@ -52,6 +52,8 @@ DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidge
FillComboBoxPoints(ui->comboBoxP4);
FillComboBoxLineColors(ui->comboBoxColor);
CheckState();
connect(ui->comboBoxP1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogSpline::PointNameChanged);
connect(ui->comboBoxP4, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
@ -74,16 +76,6 @@ DialogSpline::~DialogSpline()
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetP1 return id first point of spline
* @return id
*/
quint32 DialogSpline::GetP1() const
{
return getCurrentObjectId(ui->comboBoxP1);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
@ -133,17 +125,22 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
//---------------------------------------------------------------------------------------------------------------------
void DialogSpline::SaveData()
{
angle1 = ui->spinBoxAngle1->value();
angle2 = ui->spinBoxAngle2->value();
kAsm1 = ui->doubleSpinBoxKasm1->value();
kAsm2 = ui->doubleSpinBoxKasm2->value();
kCurve = ui->doubleSpinBoxKcurve->value();
const qreal angle1 = ui->spinBoxAngle1->value();
const qreal angle2 = ui->spinBoxAngle2->value();
const qreal kAsm1 = ui->doubleSpinBoxKasm1->value();
const qreal kAsm2 = ui->doubleSpinBoxKasm2->value();
const qreal kCurve = ui->doubleSpinBoxKcurve->value();
const quint32 d = spl.GetDuplicate();//Save previous value
spl = VSpline(*GetP1(), *GetP4(), angle1, angle2, kAsm1, kAsm2, kCurve);
newDuplicate <= -1 ? spl.SetDuplicate(d) : spl.SetDuplicate(static_cast<quint32>(newDuplicate));
auto path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->setObject1Id(GetP1());
path->setObject4Id(GetP4());
path->setObject1Id(GetP1()->id());
path->setObject4Id(GetP4()->id());
path->SetAngle1(angle1);
path->SetAngle2(angle2);
path->SetKAsm1(kAsm1);
@ -153,6 +150,18 @@ void DialogSpline::SaveData()
path->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
const QSharedPointer<VPointF> DialogSpline::GetP1() const
{
return data->GeometricObject<VPointF>(getCurrentObjectId(ui->comboBoxP1));
}
//---------------------------------------------------------------------------------------------------------------------
const QSharedPointer<VPointF> DialogSpline::GetP4() const
{
return data->GeometricObject<VPointF>(getCurrentObjectId(ui->comboBoxP4));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSpline::PointNameChanged()
{
@ -165,12 +174,34 @@ void DialogSpline::PointNameChanged()
{
flagError = false;
color = errorColor;
ui->lineEditSplineName->setText(tr("Invalid spline"));
}
else
{
flagError = true;
color = okColor;
if (getCurrentObjectId(ui->comboBoxP1) == spl.GetP1().id() &&
getCurrentObjectId(ui->comboBoxP4) == spl.GetP4().id())
{
newDuplicate = -1;
ui->lineEditSplineName->setText(spl.name());
}
else
{
VSpline spline(*GetP1(), *GetP4(), spl.GetStartAngle(), spl.GetEndAngle(), spl.GetKasm1(), spl.GetKasm2(),
spl.GetKcurve());
if (not data->IsUnique(spline.name()))
{
newDuplicate = DNumber(spline.name());
spline.SetDuplicate(newDuplicate);
}
ui->lineEditSplineName->setText(spline.name());
}
}
ChangeColor(ui->labelName, color);
ChangeColor(ui->labelFirstPoint, color);
ChangeColor(ui->labelSecondPoint, color);
CheckState();
@ -181,22 +212,23 @@ void DialogSpline::ShowDialog(bool click)
{
if (prepare && click)
{
const auto p1 = data->GeometricObject<VPointF>(getCurrentObjectId(ui->comboBoxP1));
const auto p4 = data->GeometricObject<VPointF>(getCurrentObjectId(ui->comboBoxP4));
auto *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
const QPointF p2 = path->GetP2();
const QPointF p3 = path->GetP3();
spl = VSpline(*GetP1(), path->GetP2(), path->GetP3(), *GetP4(), ui->doubleSpinBoxKcurve->value());
VSpline spline(*p1, p2, p3, *p4, kCurve);
ui->spinBoxAngle1->setValue(static_cast<qint32>(spl.GetStartAngle()));
ui->spinBoxAngle2->setValue(static_cast<qint32>(spl.GetEndAngle()));
ui->spinBoxAngle1->setValue(static_cast<qint32>(spline.GetStartAngle()));
ui->spinBoxAngle2->setValue(static_cast<qint32>(spline.GetEndAngle()));
ui->doubleSpinBoxKasm1->setValue(spl.GetKasm1());
ui->doubleSpinBoxKasm2->setValue(spl.GetKasm2());
ui->doubleSpinBoxKasm1->setValue(spline.GetKasm1());
ui->doubleSpinBoxKasm2->setValue(spline.GetKasm2());
if (not data->IsUnique(spl.name()))
{
spl.SetDuplicate(DNumber(spl.name()));
}
ui->lineEditSplineName->setText(spl.name());
DialogAccepted();
}
@ -209,18 +241,36 @@ void DialogSpline::ShowVisualization()
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetKCurve set coefficient curve
* @param value value. Can be >= 0.
*/
void DialogSpline::SetKCurve(const qreal &value)
VSpline DialogSpline::GetSpline() const
{
kCurve = value;
ui->doubleSpinBoxKcurve->setValue(value);
return spl;
}
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
//---------------------------------------------------------------------------------------------------------------------
void DialogSpline::SetSpline(const VSpline &spline)
{
spl = spline;
setCurrentPointId(ui->comboBoxP1, spl.GetP1().id());
setCurrentPointId(ui->comboBoxP4, spl.GetP4().id());
ui->spinBoxAngle1->setValue(static_cast<qint32>(spl.GetStartAngle()));
ui->spinBoxAngle2->setValue(static_cast<qint32>(spl.GetEndAngle()));
ui->doubleSpinBoxKasm1->setValue(spl.GetKasm1());
ui->doubleSpinBoxKasm2->setValue(spl.GetKasm2());
ui->doubleSpinBoxKcurve->setValue(spl.GetKcurve());
ui->lineEditSplineName->setText(spl.name());
auto path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->SetKCurve(kCurve);
path->setObject1Id(spl.GetP1().id());
path->setObject4Id(spl.GetP4().id());
path->SetAngle1(spl.GetStartAngle());
path->SetAngle2(spl.GetEndAngle());
path->SetKAsm1(spl.GetKasm1());
path->SetKAsm2(spl.GetKasm2());
path->SetKCurve(spl.GetKcurve());
}
//---------------------------------------------------------------------------------------------------------------------
@ -234,151 +284,3 @@ void DialogSpline::SetColor(const QString &value)
{
ChangeCurrentData(ui->comboBoxColor, value);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetKAsm2 set second coefficient asymmetry
* @param value value. Can be >= 0.
*/
void DialogSpline::SetKAsm2(const qreal &value)
{
kAsm2 = value;
ui->doubleSpinBoxKasm2->setValue(value);
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->SetKAsm2(kAsm2);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetKAsm1 set first coefficient asymmetry
* @param value value. Can be >= 0.
*/
void DialogSpline::SetKAsm1(const qreal &value)
{
kAsm1 = value;
ui->doubleSpinBoxKasm1->setValue(value);
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->SetKAsm1(kAsm1);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetAngle2 set second angle of spline
* @param value angle in degree
*/
void DialogSpline::SetAngle2(const qreal &value)
{
angle2 = value;
ui->spinBoxAngle2->setValue(static_cast<qint32>(value));
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->SetAngle2(angle2);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetAngle1 set first angle of spline
* @param value angle in degree
*/
void DialogSpline::SetAngle1(const qreal &value)
{
angle1 = value;
ui->spinBoxAngle1->setValue(static_cast<qint32>(value));
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->SetAngle1(angle1);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetP4 set id fourth point of spline
* @param value id
*/
void DialogSpline::SetP4(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP4, value);
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->setObject4Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetP1 set id first point of spline
* @param value id
*/
void DialogSpline::SetP1(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP1, value);
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->setObject1Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetP4 return id fourth point of spline
* @return id
*/
quint32 DialogSpline::GetP4() const
{
return getCurrentObjectId(ui->comboBoxP4);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetAngle1 return first angle of spline
* @return angle in degree
*/
qreal DialogSpline::GetAngle1() const
{
return angle1;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetAngle2 return second angle of spline
* @return angle in degree
*/
qreal DialogSpline::GetAngle2() const
{
return angle2;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetKAsm1 return first coefficient asymmetry
* @return value. Can be >= 0.
*/
qreal DialogSpline::GetKAsm1() const
{
return kAsm1;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetKAsm2 return second coefficient asymmetry
* @return value. Can be >= 0.
*/
qreal DialogSpline::GetKAsm2() const
{
return kAsm2;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetKCurve return coefficient curve
* @return value. Can be >= 0.
*/
qreal DialogSpline::GetKCurve() const
{
return kCurve;
}

View File

@ -30,6 +30,7 @@
#define DIALOGSPLINE_H
#include "dialogtool.h"
#include "../vgeometry/vspline.h"
namespace Ui
{
@ -46,29 +47,11 @@ public:
DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
virtual ~DialogSpline() Q_DECL_OVERRIDE;
quint32 GetP1() const;
void SetP1(const quint32 &value);
VSpline GetSpline() const;
void SetSpline(const VSpline &spline);
quint32 GetP4() const;
void SetP4(const quint32 &value);
qreal GetAngle1() const;
void SetAngle1(const qreal &value);
qreal GetAngle2() const;
void SetAngle2(const qreal &value);
qreal GetKAsm1() const;
void SetKAsm1(const qreal &value);
qreal GetKAsm2() const;
void SetKAsm2(const qreal &value);
qreal GetKCurve() const;
void SetKCurve(const qreal &value);
QString GetColor() const;
void SetColor(const QString &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
virtual void PointNameChanged() Q_DECL_OVERRIDE;
@ -85,20 +68,13 @@ private:
/** @brief ui keeps information about user interface */
Ui::DialogSpline *ui;
/** @brief angle1 first angle of spline in degree */
qreal angle1;
/** @brief spl spline */
VSpline spl;
/** @brief angle2 second angle of spline in degree */
qreal angle2;
qint32 newDuplicate;
/** @brief kAsm1 first coefficient asymmetry */
qreal kAsm1;
/** @brief kAsm2 second coefficient asymmetry */
qreal kAsm2;
/** @brief kCurve coefficient curve */
qreal kCurve;
const QSharedPointer<VPointF> GetP1() const;
const QSharedPointer<VPointF> GetP4() const;
};
#endif // DIALOGSPLINE_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>540</width>
<height>233</height>
<height>273</height>
</rect>
</property>
<property name="windowTitle">
@ -207,6 +207,20 @@
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelName">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditSplineName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -39,7 +39,7 @@
* @param parent parent widget
*/
DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogSplinePath), path(VSplinePath())
:DialogTool(data, toolId, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()), newDuplicate(-1)
{
ui->setupUi(this);
InitOkCancelApply(ui);
@ -94,6 +94,7 @@ void DialogSplinePath::SetPath(const VSplinePath &value)
}
ui->listWidget->setFocus(Qt::OtherFocusReason);
ui->doubleSpinBoxKcurve->setValue(path.GetKCurve());
ui->lineEditSplPathName->setText(path.name());
auto visPath = qobject_cast<VisToolSplinePath *>(vis);
SCASSERT(visPath != nullptr);
@ -123,7 +124,7 @@ void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
if (path.CountPoint() >= 2 && path.at(path.CountPoint()-1).P().id() == id)
if (AllIds().contains(id))
{
return;
}
@ -153,7 +154,9 @@ void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type)
//---------------------------------------------------------------------------------------------------------------------
void DialogSplinePath::SaveData()
{
const quint32 d = path.GetDuplicate();//Save previous value
SavePath();
newDuplicate <= -1 ? path.SetDuplicate(d) : path.SetDuplicate(static_cast<quint32>(newDuplicate));
auto visPath = qobject_cast<VisToolSplinePath *>(vis);
SCASSERT(visPath != nullptr);
@ -195,6 +198,45 @@ void DialogSplinePath::currentPointChanged(int index)
DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
EnableFields();
item->setData(Qt::UserRole, QVariant::fromValue(p));
item->setText(p.P().name());
QColor color = okColor;
if (not IsPathValid())
{
flagError = false;
color = errorColor;
ui->lineEditSplPathName->setText(tr("Invalid spline path"));
}
else
{
flagError = true;
color = okColor;
auto first = qvariant_cast<VSplinePoint>(ui->listWidget->item(0)->data(Qt::UserRole));
auto last = qvariant_cast<VSplinePoint>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
if (first.P().id() == path.at(0).P().id() && last.P().id() == path.at(path.CountPoint()-1).P().id())
{
newDuplicate = -1;
ui->lineEditSplPathName->setText(path.name());
}
else
{
VSplinePath newPath = ExtractPath();
if (not data->IsUnique(newPath.name()))
{
newDuplicate = DNumber(newPath.name());
newPath.SetDuplicate(newDuplicate);
}
ui->lineEditSplPathName->setText(newPath.name());
}
}
ChangeColor(ui->labelName, color);
ChangeColor(ui->labelPoint, color);
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
@ -265,6 +307,12 @@ void DialogSplinePath::ShowDialog(bool click)
if (path.CountPoint() >= 3)
{
emit ToolTip("");
if (not data->IsUnique(path.name()))
{
path.SetDuplicate(DNumber(path.name()));
}
DialogAccepted();
}
}
@ -368,10 +416,39 @@ void DialogSplinePath::EnableFields()
void DialogSplinePath::SavePath()
{
path.Clear();
path = ExtractPath();
}
//---------------------------------------------------------------------------------------------------------------------
QSet<quint32> DialogSplinePath::AllIds() const
{
QSet<quint32> ids;
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
{
QListWidgetItem *item = ui->listWidget->item(i);
path.append( qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)));
ids.insert(qvariant_cast<VSplinePoint>(ui->listWidget->item(i)->data(Qt::UserRole)).P().id());
}
path.SetKCurve(ui->doubleSpinBoxKcurve->value());
return ids;
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogSplinePath::IsPathValid() const
{
if (path.CountPoint() < 3)
{
return false;
}
return (AllIds().size() == path.CountPoint());
}
//---------------------------------------------------------------------------------------------------------------------
VSplinePath DialogSplinePath::ExtractPath() const
{
VSplinePath path(ui->doubleSpinBoxKcurve->value());
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
{
path.append( qvariant_cast<VSplinePoint>(ui->listWidget->item(i)->data(Qt::UserRole)));
}
return path;
}

View File

@ -77,10 +77,15 @@ private:
/** @brief path spline path */
VSplinePath path;
qint32 newDuplicate;
void NewItem(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
void DataPoint(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
void EnableFields();
void SavePath();
QSet<quint32> AllIds() const;
bool IsPathValid() const;
VSplinePath ExtractPath() const;
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>528</width>
<height>322</height>
<height>353</height>
</rect>
</property>
<property name="windowTitle">
@ -28,7 +28,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="labelPoint">
<property name="text">
<string>Point of curve</string>
</property>
@ -196,6 +196,20 @@
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelName">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditSplPathName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -311,6 +311,20 @@ bool DialogTool::eventFilter(QObject *object, QEvent *event)
return false;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogTool::DNumber(const QString &baseName) const
{
quint32 num = 0;
QString name;
do
{
++num;
name = baseName + QString("_%1").arg(num);
} while (not data->IsUnique(name));
return num;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ValFormulaChanged handle change formula

View File

@ -255,6 +255,7 @@ protected:
virtual void SaveData() {}
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit);
bool eventFilter(QObject *object, QEvent *event);
quint32 DNumber(const QString &baseName) const;
private:
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;

View File

@ -266,3 +266,9 @@ void VAbstractSpline::setEnabled(bool enabled)
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractSpline::name() const
{
return ObjectName<VAbstractCurve>(id);
}

View File

@ -52,6 +52,8 @@ public:
void setEnabled(bool enabled);
QString name() const;
public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;

View File

@ -104,14 +104,8 @@ void VToolSpline::setDialog()
SCASSERT(dialog != nullptr);
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
dialogTool->SetP1(spl->GetP1().id());
dialogTool->SetP4(spl->GetP4().id());
dialogTool->SetAngle1(spl->GetStartAngle());
dialogTool->SetAngle2(spl->GetEndAngle());
dialogTool->SetKAsm1(spl->GetKasm1());
dialogTool->SetKAsm2(spl->GetKasm2());
dialogTool->SetKCurve(spl->GetKcurve());
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
dialogTool->SetSpline(*spl);
dialogTool->SetColor(lineColor);
}
@ -127,18 +121,12 @@ void VToolSpline::setDialog()
VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
auto dialogTool = qobject_cast<DialogSpline*>(dialog);
SCASSERT(dialogTool != nullptr);
const quint32 p1 = dialogTool->GetP1();
const quint32 p4 = dialogTool->GetP4();
const qreal kAsm1 = dialogTool->GetKAsm1();
const qreal kAsm2 = dialogTool->GetKAsm2();
const qreal angle1 = dialogTool->GetAngle1();
const qreal angle2 = dialogTool->GetAngle2();
const qreal kCurve = dialogTool->GetKCurve();
const QString color = dialogTool->GetColor();
VToolSpline *spl = Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, color, scene, doc, data,
Document::FullParse, Source::FromGui);
auto spl = Create(0, dialogTool->GetSpline(), dialogTool->GetColor(), scene, doc, data, Document::FullParse,
Source::FromGui);
if (spl != nullptr)
{
spl->dialog=dialogTool;
@ -150,13 +138,8 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
* @param p1 id first spline point.
* @param p4 id last spline point.
* @param kAsm1 coefficient of length first control line.
* @param kAsm2 coefficient of length second control line.
* @param angle1 angle from first point to first control point.
* @param angle2 angle from second point to second control point.
* @param kCurve coefficient of curvature spline.
* @param spl spline.
* @param color spline color.
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
@ -164,15 +147,11 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
* @param typeCreation way we create this tool.
* @return the created tool
*/
VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1,
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data,
const Document &parse, const Source &typeCreation)
VToolSpline* VToolSpline::Create(const quint32 _id, const VSpline &spl, const QString &color, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
{
VPointF point1 = *data->GeometricObject<VPointF>(p1);
VPointF point4 = *data->GeometricObject<VPointF>(p4);
VSpline *spline = new VSpline(point1, point4, angle1, angle2, kAsm1, kAsm2, kCurve);
auto spline = new VSpline(spl);
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
@ -191,17 +170,17 @@ VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const qui
VDrawTool::AddRecord(id, Tool::Spline, doc);
if (parse == Document::FullParse)
{
VToolSpline *spl = new VToolSpline(doc, data, id, color, typeCreation);
scene->addItem(spl);
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSpline::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSpline::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, spl, &VToolSpline::DetailsMode);
doc->AddTool(id, spl);
doc->IncrementReferens(point1.getIdTool());
doc->IncrementReferens(point4.getIdTool());
return spl;
auto _spl = new VToolSpline(doc, data, id, color, typeCreation);
scene->addItem(_spl);
connect(_spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, _spl, &VToolSpline::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, _spl, &VToolSpline::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, _spl, &VToolSpline::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, _spl, &VToolSpline::DetailsMode);
doc->AddTool(id, _spl);
doc->IncrementReferens(spline->GetP1().id());
doc->IncrementReferens(spline->GetP4().id());
return _spl;
}
return nullptr;
}
@ -297,13 +276,10 @@ void VToolSpline::RemoveReferens()
void VToolSpline::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
auto dialogTool = qobject_cast<DialogSpline*>(dialog);
SCASSERT(dialogTool != nullptr);
VPointF point1 = *VAbstractTool::data.GeometricObject<VPointF>(dialogTool->GetP1());
VPointF point4 = *VAbstractTool::data.GeometricObject<VPointF>(dialogTool->GetP4());
VSpline spl = VSpline (point1, point4, dialogTool->GetAngle1(), dialogTool->GetAngle2(),
dialogTool->GetKAsm1(), dialogTool->GetKAsm2(), dialogTool->GetKCurve());
const VSpline spl = dialogTool->GetSpline();
controlPoints[0]->blockSignals(true);
controlPoints[1]->blockSignals(true);
@ -314,8 +290,6 @@ void VToolSpline::SaveDialog(QDomElement &domElement)
controlPoints[0]->blockSignals(false);
controlPoints[1]->blockSignals(false);
spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogTool->GetKCurve());
doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id());
doc->SetAttribute(domElement, AttrPoint4, spl.GetP4().id());
doc->SetAttribute(domElement, AttrAngle1, spl.GetStartAngle());
@ -342,6 +316,18 @@ void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrKAsm1, spl->GetKasm1());
doc->SetAttribute(tag, AttrKAsm2, spl->GetKasm2());
doc->SetAttribute(tag, AttrKCurve, spl->GetKcurve());
if (spl->GetDuplicate() > 0)
{
doc->SetAttribute(tag, AttrDuplicate, spl->GetDuplicate());
}
else
{
if (tag.hasAttribute(AttrDuplicate))
{
tag.removeAttribute(AttrDuplicate);
}
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -44,12 +44,10 @@ public:
QGraphicsItem * parent = nullptr );
virtual ~VToolSpline() Q_DECL_OVERRIDE;
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data);
static VToolSpline *Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1,
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data,
const Document &parse, const Source &typeCreation);
static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data);
static VToolSpline *Create(const quint32 _id, const VSpline &spl, const QString &color, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Spline)};

View File

@ -404,6 +404,18 @@ void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &ob
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrKCurve, splPath->GetKCurve());
if (splPath->GetDuplicate() > 0)
{
doc->SetAttribute(tag, AttrDuplicate, splPath->GetDuplicate());
}
else
{
if (tag.hasAttribute(AttrDuplicate))
{
tag.removeAttribute(AttrDuplicate);
}
}
doc->RemoveAllChild(tag);
for (qint32 i = 0; i < splPath->CountPoint(); ++i)
{

View File

@ -76,7 +76,7 @@ void VToolDoublePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *
//---------------------------------------------------------------------------------------------------------------------
QString VToolDoublePoint::nameP1() const
{
return PointName(p1id);
return ObjectName<VPointF>(p1id);
}
//---------------------------------------------------------------------------------------------------------------------
@ -88,7 +88,7 @@ void VToolDoublePoint::setNameP1(const QString &name)
//---------------------------------------------------------------------------------------------------------------------
QString VToolDoublePoint::nameP2() const
{
return PointName(p2id);
return ObjectName<VPointF>(p2id);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -95,7 +95,7 @@ void VToolSinglePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *
//---------------------------------------------------------------------------------------------------------------------
QString VToolSinglePoint::name() const
{
return PointName(id);
return ObjectName<VPointF>(id);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -71,21 +71,6 @@ void VAbstractPoint::DeleteFromLabel()
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPoint::PointName(quint32 id) const
{
try
{
return VAbstractTool::data.GeometricObject<VPointF>(id)->name();
}
catch (const VExceptionBadId &e)
{
qCDebug(vTool, "Error! Couldn't get point name. %s %s", qUtf8Printable(e.ErrorMessage()),
qUtf8Printable(e.DetailedInformation()));
return QString("");// Return empty string for property browser
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPoint::SetPointName(quint32 id, const QString &name)
{

View File

@ -50,7 +50,6 @@ public slots:
void DeleteFromLabel();
protected:
QString PointName(quint32 id) const;
void SetPointName(quint32 id, const QString &name);
template <typename T>

View File

@ -112,6 +112,9 @@ protected:
template <typename Item>
void ShowItem(Item *item, quint32 id, bool enable);
template <typename T>
QString ObjectName(quint32 id) const;
private:
Q_DISABLE_COPY(VDrawTool)
};
@ -202,4 +205,25 @@ void VDrawTool::ShowItem(Item *item, quint32 id, bool enable)
}
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
/**
* @brief ObjectName get object (point, curve, arc) name.
* @param id object id in container.
*/
QString VDrawTool::ObjectName(quint32 id) const
{
try
{
return VAbstractTool::data.GeometricObject<T>(id)->name();
}
catch (const VExceptionBadId &e)
{
qCDebug(vTool, "Error! Couldn't get object name by id = %s. %s %s", qUtf8Printable(QString().setNum(id)),
qUtf8Printable(e.ErrorMessage()),
qUtf8Printable(e.DetailedInformation()));
return QString("");// Return empty string for property browser
}
}
#endif // VDRAWTOOL_H