Resolved issue #755. New feature. Toggle point label.
--HG-- branch : develop
This commit is contained in:
commit
20ba7161a3
|
@ -263,9 +263,19 @@ void MainWindow::AddPP(const QString &PPName)
|
|||
ui->view->itemClicked(nullptr);//hide options previous tool
|
||||
const QString label = doc->GenerateLabel(LabelType::NewPatternPiece);
|
||||
const QPointF startPosition = StartPositionNewPP();
|
||||
VPointF *point = new VPointF(startPosition.x(), startPosition.y(), label, 5, 10);
|
||||
auto spoint = VToolBasePoint::Create(0, PPName, point, sceneDraw, doc, pattern, Document::FullParse,
|
||||
Source::FromGui);
|
||||
|
||||
VToolBasePointInitData initData;
|
||||
initData.scene = sceneDraw;
|
||||
initData.doc = doc;
|
||||
initData.data = pattern;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
initData.x = startPosition.x();
|
||||
initData.y = startPosition.y();
|
||||
initData.name = label;
|
||||
initData.nameActivPP = PPName;
|
||||
|
||||
auto spoint = VToolBasePoint::Create(initData);
|
||||
ui->view->itemClicked(spoint);
|
||||
|
||||
SetEnableTool(true);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -36,6 +36,8 @@
|
|||
|
||||
class VMainGraphicsScene;
|
||||
class VNodeDetail;
|
||||
class VToolSinglePointInitData;
|
||||
class VToolLinePointInitData;
|
||||
|
||||
/**
|
||||
* @brief The VPattern class working with pattern file.
|
||||
|
@ -155,10 +157,8 @@ private:
|
|||
void ParseIncrementsElement(const QDomNode& node);
|
||||
void PrepareForParse(const Document &parse);
|
||||
void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id);
|
||||
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx,
|
||||
qreal &my, QString &typeLine, QString &lineColor);
|
||||
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx,
|
||||
qreal &my);
|
||||
void PointsWithLineCommonAttributes(const QDomElement &domElement, VToolLinePointInitData &initData);
|
||||
void PointsCommonAttributes(const QDomElement &domElement, VToolSinglePointInitData &initData);
|
||||
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my);
|
||||
void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject,
|
||||
quint32 &idTool);
|
||||
|
|
|
@ -122,6 +122,9 @@ const QString AttrIdObject = QStringLiteral("idObject");
|
|||
const QString AttrInLayout = QStringLiteral("inLayout");
|
||||
const QString AttrRotationAngle = QStringLiteral("rotationAngle");
|
||||
const QString AttrClosed = QStringLiteral("closed");
|
||||
const QString AttrShowLabel = QStringLiteral("showLabel");
|
||||
const QString AttrShowLabel1 = QStringLiteral("showLabel1");
|
||||
const QString AttrShowLabel2 = QStringLiteral("showLabel2");
|
||||
|
||||
const QString TypeLineNone = QStringLiteral("none");
|
||||
const QString TypeLineLine = QStringLiteral("hair");
|
||||
|
|
|
@ -141,6 +141,9 @@ extern const QString AttrSuffix;
|
|||
extern const QString AttrIdObject;
|
||||
extern const QString AttrInLayout;
|
||||
extern const QString AttrClosed;
|
||||
extern const QString AttrShowLabel;
|
||||
extern const QString AttrShowLabel1;
|
||||
extern const QString AttrShowLabel2;
|
||||
|
||||
extern const QString TypeLineNone;
|
||||
extern const QString TypeLineLine;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
<file>schema/pattern/v0.6.0.xsd</file>
|
||||
<file>schema/pattern/v0.6.1.xsd</file>
|
||||
<file>schema/pattern/v0.6.2.xsd</file>
|
||||
<file>schema/pattern/v0.6.3.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>
|
||||
|
|
972
src/libs/ifc/schema/pattern/v0.6.3.xsd
Normal file
972
src/libs/ifc/schema/pattern/v0.6.3.xsd
Normal file
|
@ -0,0 +1,972 @@
|
|||
<?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 name="unit" type="units"/>
|
||||
<xs:element name="image" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute name="extension" type="imageExtension"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||
<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 name="h50" type="xs:boolean"/>
|
||||
<xs:attribute name="h56" type="xs:boolean"/>
|
||||
<xs:attribute name="h62" type="xs:boolean"/>
|
||||
<xs:attribute name="h68" type="xs:boolean"/>
|
||||
<xs:attribute name="h74" type="xs:boolean"/>
|
||||
<xs:attribute name="h80" type="xs:boolean"/>
|
||||
<xs:attribute name="h86" type="xs:boolean"/>
|
||||
<xs:attribute name="h92" type="xs:boolean"/>
|
||||
<xs:attribute name="h98" type="xs:boolean"/>
|
||||
<xs:attribute name="h104" type="xs:boolean"/>
|
||||
<xs:attribute name="h110" type="xs:boolean"/>
|
||||
<xs:attribute name="h116" type="xs:boolean"/>
|
||||
<xs:attribute name="h122" type="xs:boolean"/>
|
||||
<xs:attribute name="h128" type="xs:boolean"/>
|
||||
<xs:attribute name="h134" type="xs:boolean"/>
|
||||
<xs:attribute name="h140" type="xs:boolean"/>
|
||||
<xs:attribute name="h146" type="xs:boolean"/>
|
||||
<xs:attribute name="h152" type="xs:boolean"/>
|
||||
<xs:attribute name="h158" type="xs:boolean"/>
|
||||
<xs:attribute name="h164" type="xs:boolean"/>
|
||||
<xs:attribute name="h170" type="xs:boolean"/>
|
||||
<xs:attribute name="h176" type="xs:boolean"/>
|
||||
<xs:attribute name="h182" type="xs:boolean"/>
|
||||
<xs:attribute name="h188" type="xs:boolean"/>
|
||||
<xs:attribute name="h194" type="xs:boolean"/>
|
||||
<xs:attribute name="h200" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="sizes">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="all" type="xs:boolean" use="required"/>
|
||||
<xs:attribute name="s22" type="xs:boolean"/>
|
||||
<xs:attribute name="s24" type="xs:boolean"/>
|
||||
<xs:attribute name="s26" type="xs:boolean"/>
|
||||
<xs:attribute name="s28" type="xs:boolean"/>
|
||||
<xs:attribute name="s30" type="xs:boolean"/>
|
||||
<xs:attribute name="s32" type="xs:boolean"/>
|
||||
<xs:attribute name="s34" type="xs:boolean"/>
|
||||
<xs:attribute name="s36" type="xs:boolean"/>
|
||||
<xs:attribute name="s38" type="xs:boolean"/>
|
||||
<xs:attribute name="s40" type="xs:boolean"/>
|
||||
<xs:attribute name="s42" type="xs:boolean"/>
|
||||
<xs:attribute name="s44" type="xs:boolean"/>
|
||||
<xs:attribute name="s46" type="xs:boolean"/>
|
||||
<xs:attribute name="s48" type="xs:boolean"/>
|
||||
<xs:attribute name="s50" type="xs:boolean"/>
|
||||
<xs:attribute name="s52" type="xs:boolean"/>
|
||||
<xs:attribute name="s54" type="xs:boolean"/>
|
||||
<xs:attribute name="s56" type="xs:boolean"/>
|
||||
<xs:attribute name="s58" type="xs:boolean"/>
|
||||
<xs:attribute name="s60" type="xs:boolean"/>
|
||||
<xs:attribute name="s62" type="xs:boolean"/>
|
||||
<xs:attribute name="s64" type="xs:boolean"/>
|
||||
<xs:attribute name="s66" type="xs:boolean"/>
|
||||
<xs:attribute name="s68" type="xs:boolean"/>
|
||||
<xs:attribute name="s70" type="xs:boolean"/>
|
||||
<xs:attribute name="s72" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="custom" type="xs:boolean"/>
|
||||
<xs:attribute name="defHeight" type="baseHeight"/>
|
||||
<xs:attribute name="defSize" type="baseSize"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="patternName" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||
<xs:element name="patternNumber" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||
<xs:element name="company" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||
<xs:element name="customer" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||
<xs:element name="patternLabel" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="text" type="xs:string" use="required"/>
|
||||
<xs:attribute name="bold" type="xs:boolean"/>
|
||||
<xs:attribute name="italic" type="xs:boolean"/>
|
||||
<xs:attribute name="alignment" type="alignmentType"/>
|
||||
<xs:attribute name="sfIncrement" type="xs:unsignedInt"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="dateFormat" type="xs:string"/>
|
||||
<xs:attribute name="timeFormat" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="patternMaterials" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="material" minOccurs="0" maxOccurs="9">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="number" type="userMaterialType" use="required"/>
|
||||
<xs:attribute name="name" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="measurements" type="xs:string"/>
|
||||
<xs:element name="increments">
|
||||
<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 name="name" type="shortName" use="required"/>
|
||||
<xs:attribute name="formula" type="xs:string" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="previewCalculations">
|
||||
<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 name="name" type="shortName" use="required"/>
|
||||
<xs:attribute name="formula" type="xs:string" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</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 name="x" type="xs:double"/>
|
||||
<xs:attribute name="y" type="xs:double"/>
|
||||
<xs:attribute name="mx" type="xs:double"/>
|
||||
<xs:attribute name="my" type="xs:double"/>
|
||||
<xs:attribute name="type" type="xs:string"/>
|
||||
<xs:attribute name="name" type="shortName"/>
|
||||
<xs:attribute name="firstPoint" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="secondPoint" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="thirdPoint" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="basePoint" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="pShoulder" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="p1Line" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="p2Line" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="length" type="xs:string"/>
|
||||
<xs:attribute name="angle" type="xs:string"/>
|
||||
<xs:attribute name="typeLine" type="linePenStyle"/>
|
||||
<xs:attribute name="splinePath" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="spline" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="p1Line1" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="p1Line2" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="p2Line1" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="p2Line2" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="center" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="radius" type="xs:string"/>
|
||||
<xs:attribute name="axisP1" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="axisP2" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="arc" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="elArc" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="curve" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="curve1" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="curve2" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="lineColor" type="colors"/>
|
||||
<xs:attribute name="color" type="colors"/>
|
||||
<xs:attribute name="firstArc" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="secondArc" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="crossPoint" type="crossType"/>
|
||||
<xs:attribute name="vCrossPoint" type="crossType"/>
|
||||
<xs:attribute name="hCrossPoint" type="crossType"/>
|
||||
<xs:attribute name="c1Center" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="c2Center" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="c1Radius" type="xs:string"/>
|
||||
<xs:attribute name="c2Radius" type="xs:string"/>
|
||||
<xs:attribute name="cRadius" type="xs:string"/>
|
||||
<xs:attribute name="tangent" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="cCenter" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="name1" type="shortName"/>
|
||||
<xs:attribute name="mx1" type="xs:double"/>
|
||||
<xs:attribute name="my1" type="xs:double"/>
|
||||
<xs:attribute name="name2" type="shortName"/>
|
||||
<xs:attribute name="mx2" type="xs:double"/>
|
||||
<xs:attribute name="my2" type="xs:double"/>
|
||||
<xs:attribute name="point1" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="point2" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="dartP1" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="dartP2" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="dartP3" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="baseLineP1" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="baseLineP2" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="showLabel" type="xs:boolean"/>
|
||||
<xs:attribute name="showLabel1" type="xs:boolean"/>
|
||||
<xs:attribute name="showLabel2" type="xs:boolean"/>
|
||||
</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 name="firstPoint" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="secondPoint" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="typeLine" type="linePenStyle"/>
|
||||
<xs:attribute name="lineColor" type="colors"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="operation" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="source" minOccurs="1" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="destination" minOccurs="1" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="mx" type="xs:double"/>
|
||||
<xs:attribute name="my" type="xs:double"/>
|
||||
<xs:attribute name="showLabel" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="center" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="angle" type="xs:string"/>
|
||||
<xs:attribute name="length" type="xs:string"/>
|
||||
<xs:attribute name="suffix" type="xs:string"/>
|
||||
<xs:attribute name="type" type="xs:string" use="required"/>
|
||||
<xs:attribute name="p1Line" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="p2Line" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="axisType" type="axisType"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="angle1" type="xs:string"/>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="angle2" type="xs:string"/>
|
||||
<xs:attribute name="radius" type="xs:string"/>
|
||||
<xs:attribute name="center" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="type" type="xs:string"/>
|
||||
<xs:attribute name="color" type="colors"/>
|
||||
<xs:attribute name="penStyle" type="curvePenStyle"/>
|
||||
<xs:attribute name="length" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="elArc" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="angle1" type="xs:string"/>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="angle2" type="xs:string"/>
|
||||
<xs:attribute name="rotationAngle" type="xs:string"/>
|
||||
<xs:attribute name="radius1" type="xs:string"/>
|
||||
<xs:attribute name="radius2" type="xs:string"/>
|
||||
<xs:attribute name="center" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="type" type="xs:string"/>
|
||||
<xs:attribute name="color" type="colors"/>
|
||||
<xs:attribute name="penStyle" type="curvePenStyle"/>
|
||||
<xs:attribute name="length" type="xs:string"/>
|
||||
</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 name="pSpline" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="angle" type="xs:string"/>
|
||||
<xs:attribute name="angle1" type="xs:string"/>
|
||||
<xs:attribute name="angle2" type="xs:string"/>
|
||||
<xs:attribute name="length1" type="xs:string"/>
|
||||
<xs:attribute name="length2" type="xs:string"/>
|
||||
<xs:attribute name="kAsm1" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="kCurve" type="xs:double"/>
|
||||
<xs:attribute name="type" type="xs:string"/>
|
||||
<xs:attribute name="kAsm1" type="xs:double"/>
|
||||
<xs:attribute name="kAsm2" type="xs:double"/>
|
||||
<xs:attribute name="angle1" type="xs:string"/>
|
||||
<xs:attribute name="angle2" type="xs:string"/>
|
||||
<xs:attribute name="length1" type="xs:string"/>
|
||||
<xs:attribute name="length2" type="xs:string"/>
|
||||
<xs:attribute name="point1" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="point2" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="point3" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="point4" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="color" type="colors"/>
|
||||
<xs:attribute name="penStyle" type="curvePenStyle"/>
|
||||
<xs:attribute name="duplicate" type="xs:unsignedInt"/>
|
||||
</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 name="idObject" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="mx" type="xs:double"/>
|
||||
<xs:attribute name="my" type="xs:double"/>
|
||||
<xs:attribute name="type" type="xs:string"/>
|
||||
<xs:attribute name="idTool" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="inUse" type="xs:boolean"/>
|
||||
</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 name="idObject" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="type" type="xs:string"/>
|
||||
<xs:attribute name="idTool" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="inUse" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="elArc" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="type" type="xs:string"/>
|
||||
<xs:attribute name="idTool" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="inUse" type="xs:boolean"/>
|
||||
</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 name="idObject" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="type" type="xs:string"/>
|
||||
<xs:attribute name="idTool" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="inUse" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="path" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="nodes" minOccurs="1" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="node" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="type" type="xs:string" use="required"/>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="reverse" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="excluded" type="xs:boolean"/>
|
||||
<xs:attribute name="before" type="xs:double"/>
|
||||
<xs:attribute name="after" type="xs:double"/>
|
||||
<xs:attribute name="angle" type="nodeAngle"/>
|
||||
<xs:attribute name="passmark" type="xs:boolean"/>
|
||||
<xs:attribute name="passmarkLine" type="passmarkLineType"/>
|
||||
<xs:attribute name="passmarkAngle" type="passmarkAngleType"/>
|
||||
<xs:attribute name="showSecondPassmark" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="type" type="piecePathType"/>
|
||||
<xs:attribute name="idTool" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="inUse" type="xs:boolean"/>
|
||||
<xs:attribute name="name" type="xs:string"/>
|
||||
<xs:attribute name="typeLine" type="curvePenStyle"/>
|
||||
<xs:attribute name="cut" type="xs:boolean"/>
|
||||
</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="nodes" minOccurs="1" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="node" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="type" type="xs:string" use="required"/>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="reverse" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="excluded" type="xs:boolean"/>
|
||||
<xs:attribute name="before" type="xs:string"/>
|
||||
<xs:attribute name="after" type="xs:string"/>
|
||||
<xs:attribute name="angle" type="nodeAngle"/>
|
||||
<xs:attribute name="passmark" type="xs:boolean"/>
|
||||
<xs:attribute name="passmarkLine" type="passmarkLineType"/>
|
||||
<xs:attribute name="passmarkAngle" type="passmarkAngleType"/>
|
||||
<xs:attribute name="showSecondPassmark" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="csa" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="record" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="start" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="path" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="end" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="reverse" type="xs:boolean"/>
|
||||
<xs:attribute name="includeAs" type="piecePathIncludeType"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="iPaths" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="record" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="path" type="xs:unsignedInt" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="pins" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="record" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="children" minOccurs="1" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="nodes" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="csa" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="child" type="xs:unsignedInt" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="iPaths" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="child" type="xs:unsignedInt" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="pins" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="child" type="xs:unsignedInt" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="type" type="xs:string"/>
|
||||
<xs:attribute name="indexD1" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="indexD2" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="inUse" type="xs:boolean"/>
|
||||
</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="data" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="text" type="xs:string" use="required"/>
|
||||
<xs:attribute name="bold" type="xs:boolean"/>
|
||||
<xs:attribute name="italic" type="xs:boolean"/>
|
||||
<xs:attribute name="alignment" type="alignmentType"/>
|
||||
<xs:attribute name="sfIncrement" type="xs:unsignedInt"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="letter" type="xs:string"/>
|
||||
<xs:attribute name="annotation" type="xs:string"/>
|
||||
<xs:attribute name="orientation" type="xs:string"/>
|
||||
<xs:attribute name="rotationWay" type="xs:string"/>
|
||||
<xs:attribute name="tilt" type="xs:string"/>
|
||||
<xs:attribute name="foldPosition" type="xs:string"/>
|
||||
<xs:attribute name="visible" type="xs:boolean"/>
|
||||
<xs:attribute name="onFold" type="xs:boolean"/>
|
||||
<xs:attribute name="fontSize" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="mx" type="xs:double"/>
|
||||
<xs:attribute name="my" type="xs:double"/>
|
||||
<xs:attribute name="width" type="xs:string"/>
|
||||
<xs:attribute name="height" type="xs:string"/>
|
||||
<xs:attribute name="rotation" type="xs:string"/>
|
||||
<xs:attribute name="centerPin" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="topLeftPin" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="quantity" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="bottomRightPin" type="xs:unsignedInt"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="patternInfo" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="visible" type="xs:boolean"/>
|
||||
<xs:attribute name="fontSize" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="mx" type="xs:double"/>
|
||||
<xs:attribute name="my" type="xs:double"/>
|
||||
<xs:attribute name="width" type="xs:string"/>
|
||||
<xs:attribute name="height" type="xs:string"/>
|
||||
<xs:attribute name="rotation" type="xs:string"/>
|
||||
<xs:attribute name="centerPin" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="topLeftPin" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="bottomRightPin" type="xs:unsignedInt"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="grainline" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="visible" type="xs:boolean"/>
|
||||
<xs:attribute name="mx" type="xs:double"/>
|
||||
<xs:attribute name="my" type="xs:double"/>
|
||||
<xs:attribute name="length" type="xs:string"/>
|
||||
<xs:attribute name="rotation" type="xs:string"/>
|
||||
<xs:attribute name="arrows" type="arrowType"/>
|
||||
<xs:attribute name="centerPin" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="topPin" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="bottomPin" type="xs:unsignedInt"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="nodes" minOccurs="1" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="node" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="type" type="xs:string" use="required"/>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="reverse" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="excluded" type="xs:boolean"/>
|
||||
<xs:attribute name="before" type="xs:string"/>
|
||||
<xs:attribute name="after" type="xs:string"/>
|
||||
<xs:attribute name="angle" type="nodeAngle"/>
|
||||
<xs:attribute name="mx" type="xs:double"/>
|
||||
<xs:attribute name="my" type="xs:double"/>
|
||||
<xs:attribute name="passmark" type="xs:boolean"/>
|
||||
<xs:attribute name="passmarkLine" type="passmarkLineType"/>
|
||||
<xs:attribute name="passmarkAngle" type="passmarkAngleType"/>
|
||||
<xs:attribute name="showSecondPassmark" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="csa" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="record" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="start" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="path" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="end" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="reverse" type="xs:boolean"/>
|
||||
<xs:attribute name="includeAs" type="piecePathIncludeType"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="iPaths" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="record" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="path" type="xs:unsignedInt" use="required"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="pins" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="record" type="xs:unsignedInt" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="version" type="pieceVersion"/>
|
||||
<xs:attribute name="mx" type="xs:double"/>
|
||||
<xs:attribute name="my" type="xs:double"/>
|
||||
<xs:attribute name="name" type="xs:string"/>
|
||||
<xs:attribute name="inLayout" type="xs:boolean"/>
|
||||
<xs:attribute name="forbidFlipping" type="xs:boolean"/>
|
||||
<xs:attribute name="width" type="xs:string"/>
|
||||
<xs:attribute name="seamAllowance" type="xs:boolean"/>
|
||||
<xs:attribute name="seamAllowanceBuiltIn" type="xs:boolean"/>
|
||||
<xs:attribute name="united" type="xs:boolean"/>
|
||||
<xs:attribute name="closed" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="hideMainPath" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="groups" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="group" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="item" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="object" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="tool" type="xs:unsignedInt"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
|
||||
<xs:attribute name="name" type="xs:string"/>
|
||||
<xs:attribute name="visible" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="readOnly" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
<xs:unique name="incrementName">
|
||||
<xs:selector xpath=".//increment"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:unique>
|
||||
</xs:element>
|
||||
<xs:simpleType name="shortName">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="^([^\p{Nd}\p{Zs}*/&|!<>^\()\-−+.,٫, ٬.’=?:;'\"]){1,1}([^\p{Zs}*/&|!<>^\()\-−+.,٫, ٬.’=?:;\"]){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="imageExtension">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="PNG"/>
|
||||
<xs:enumeration value="JPG"/>
|
||||
<xs:enumeration value="BMP"/>
|
||||
</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:enumeration value="lightsalmon"/>
|
||||
<xs:enumeration value="goldenrod"/>
|
||||
<xs:enumeration value="orange"/>
|
||||
<xs:enumeration value="deeppink"/>
|
||||
<xs:enumeration value="violet"/>
|
||||
<xs:enumeration value="darkviolet"/>
|
||||
<xs:enumeration value="mediumseagreen"/>
|
||||
<xs:enumeration value="lime"/>
|
||||
<xs:enumeration value="deepskyblue"/>
|
||||
<xs:enumeration value="cornflowerblue"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="linePenStyle">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="none"/>
|
||||
<xs:enumeration value="hair"/>
|
||||
<xs:enumeration value="dashLine"/>
|
||||
<xs:enumeration value="dotLine"/>
|
||||
<xs:enumeration value="dashDotLine"/>
|
||||
<xs:enumeration value="dashDotDotLine"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="curvePenStyle">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="hair"/>
|
||||
<xs:enumeration value="dashLine"/>
|
||||
<xs:enumeration value="dotLine"/>
|
||||
<xs:enumeration value="dashDotLine"/>
|
||||
<xs:enumeration value="dashDotDotLine"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="baseHeight">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="50"/>
|
||||
<xs:enumeration value="56"/>
|
||||
<xs:enumeration value="62"/>
|
||||
<xs:enumeration value="68"/>
|
||||
<xs:enumeration value="74"/>
|
||||
<xs:enumeration value="80"/>
|
||||
<xs:enumeration value="86"/>
|
||||
<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="200"/>
|
||||
<xs:enumeration value="500"/>
|
||||
<xs:enumeration value="560"/>
|
||||
<xs:enumeration value="620"/>
|
||||
<xs:enumeration value="680"/>
|
||||
<xs:enumeration value="740"/>
|
||||
<xs:enumeration value="800"/>
|
||||
<xs:enumeration value="860"/>
|
||||
<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:enumeration value="2000"/>
|
||||
</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="58"/>
|
||||
<xs:enumeration value="60"/>
|
||||
<xs:enumeration value="62"/>
|
||||
<xs:enumeration value="64"/>
|
||||
<xs:enumeration value="66"/>
|
||||
<xs:enumeration value="68"/>
|
||||
<xs:enumeration value="70"/>
|
||||
<xs:enumeration value="72"/>
|
||||
<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:enumeration value="580"/>
|
||||
<xs:enumeration value="600"/>
|
||||
<xs:enumeration value="620"/>
|
||||
<xs:enumeration value="640"/>
|
||||
<xs:enumeration value="660"/>
|
||||
<xs:enumeration value="680"/>
|
||||
<xs:enumeration value="700"/>
|
||||
<xs:enumeration value="720"/>
|
||||
</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:simpleType name="axisType">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="1"/>
|
||||
<xs:enumeration value="2"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="arrowType">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="0"/>
|
||||
<!--Both-->
|
||||
<xs:enumeration value="1"/>
|
||||
<!--Front-->
|
||||
<xs:enumeration value="2"/>
|
||||
<!--Rear-->
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="pieceVersion">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="1"/>
|
||||
<!--Old version-->
|
||||
<xs:enumeration value="2"/>
|
||||
<!--New version-->
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="nodeAngle">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="0"/>
|
||||
<!--by length-->
|
||||
<xs:enumeration value="1"/>
|
||||
<!--by points intersections-->
|
||||
<xs:enumeration value="2"/>
|
||||
<!--by second edge symmetry-->
|
||||
<xs:enumeration value="3"/>
|
||||
<!--by first edge symmetry-->
|
||||
<xs:enumeration value="4"/>
|
||||
<!--by first edge right angle-->
|
||||
<xs:enumeration value="5"/>
|
||||
<!--by first edge right angle-->
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="piecePathType">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="1"/>
|
||||
<!--custom seam allowance-->
|
||||
<xs:enumeration value="2"/>
|
||||
<!--internal path-->
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="piecePathIncludeType">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="0"/>
|
||||
<!--as main path-->
|
||||
<xs:enumeration value="1"/>
|
||||
<!--as custom seam allowance-->
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="passmarkLineType">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="one"/>
|
||||
<xs:enumeration value="two"/>
|
||||
<xs:enumeration value="three"/>
|
||||
<xs:enumeration value="tMark"/>
|
||||
<xs:enumeration value="vMark"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="passmarkAngleType">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="straightforward"/>
|
||||
<xs:enumeration value="bisector"/>
|
||||
<xs:enumeration value="intersection"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="alignmentType">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="0"/><!--default (no aligns)-->
|
||||
<xs:enumeration value="1"/><!--aligns with the left edge-->
|
||||
<xs:enumeration value="2"/><!--aligns with the right edge-->
|
||||
<xs:enumeration value="4"/><!--Centers horizontally in the available space-->
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="userMaterialType">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:minInclusive value="1"/>
|
||||
<xs:maxInclusive value="9"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:schema>
|
|
@ -58,8 +58,8 @@ class QDomElement;
|
|||
*/
|
||||
|
||||
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.6.2");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.6.2.xsd");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.6.3");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.6.3.xsd");
|
||||
|
||||
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
@ -248,6 +248,8 @@ QString VPatternConverter::XSDSchema(int ver) const
|
|||
case (0x000601):
|
||||
return QStringLiteral("://schema/pattern/v0.6.1.xsd");
|
||||
case (0x000602):
|
||||
return QStringLiteral("://schema/pattern/v0.6.2.xsd");
|
||||
case (0x000603):
|
||||
return CurrentSchema;
|
||||
default:
|
||||
InvalidVersion(ver);
|
||||
|
@ -406,6 +408,10 @@ void VPatternConverter::ApplyPatches()
|
|||
ValidateXML(XSDSchema(0x000602), m_convertedFileName);
|
||||
V_FALLTHROUGH
|
||||
case (0x000602):
|
||||
ToV0_6_3();
|
||||
ValidateXML(XSDSchema(0x000603), m_convertedFileName);
|
||||
V_FALLTHROUGH
|
||||
case (0x000603):
|
||||
break;
|
||||
default:
|
||||
InvalidVersion(m_ver);
|
||||
|
@ -424,7 +430,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
|
|||
bool VPatternConverter::IsReadOnly() const
|
||||
{
|
||||
// Check if attribute readOnly was not changed in file format
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 6, 2),
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 6, 3),
|
||||
"Check attribute readOnly.");
|
||||
|
||||
// Possibly in future attribute readOnly will change position etc.
|
||||
|
@ -848,6 +854,16 @@ void VPatternConverter::ToV0_6_2()
|
|||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::ToV0_6_3()
|
||||
{
|
||||
// TODO. Delete if minimal supported version is 0.6.3
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 3),
|
||||
"Time to refactor the code.");
|
||||
SetVersion(QStringLiteral("0.6.3"));
|
||||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::TagUnitToV0_2_0()
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
static const QString PatternMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
|
||||
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 6, 2);
|
||||
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 6, 3);
|
||||
|
||||
protected:
|
||||
virtual int MinVer() const Q_DECL_OVERRIDE;
|
||||
|
@ -108,6 +108,7 @@ private:
|
|||
void ToV0_6_0();
|
||||
void ToV0_6_1();
|
||||
void ToV0_6_2();
|
||||
void ToV0_6_3();
|
||||
|
||||
void TagUnitToV0_2_0();
|
||||
void TagIncrementToV0_2_0();
|
||||
|
|
|
@ -111,21 +111,27 @@ VPointF::operator QPointF() const
|
|||
VPointF VPointF::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
|
||||
{
|
||||
const QPointF p = RotatePF(originPoint, toQPointF(), degrees);
|
||||
return VPointF(p, name() + prefix, mx(), my());
|
||||
VPointF rotated(p, name() + prefix, mx(), my());
|
||||
rotated.SetShowLabel(IsShowLabel());
|
||||
return rotated;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPointF VPointF::Flip(const QLineF &axis, const QString &prefix) const
|
||||
{
|
||||
const QPointF p = FlipPF(axis, toQPointF());
|
||||
return VPointF(p, name() + prefix, mx(), my());
|
||||
VPointF flipped(p, name() + prefix, mx(), my());
|
||||
flipped.SetShowLabel(IsShowLabel());
|
||||
return flipped;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPointF VPointF::Move(qreal length, qreal angle, const QString &prefix) const
|
||||
{
|
||||
const QPointF p = MovePF(toQPointF(), length, angle);
|
||||
return VPointF(p, name() + prefix, mx(), my());
|
||||
VPointF moved(p, name() + prefix, mx(), my());
|
||||
moved.SetShowLabel(IsShowLabel());
|
||||
return moved;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -214,6 +220,18 @@ void VPointF::setY(const qreal &value)
|
|||
d->_y = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VPointF::IsShowLabel() const
|
||||
{
|
||||
return d->m_showLabel;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPointF::SetShowLabel(bool hide)
|
||||
{
|
||||
d->m_showLabel = hide;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VPointF::RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees)
|
||||
{
|
||||
|
|
|
@ -82,6 +82,9 @@ public:
|
|||
qreal y() const;
|
||||
void setY(const qreal &value);
|
||||
|
||||
bool IsShowLabel() const;
|
||||
void SetShowLabel(bool hide);
|
||||
|
||||
static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees);
|
||||
static QPointF FlipPF(const QLineF &axis, const QPointF &point);
|
||||
static QPointF MovePF(const QPointF &originPoint, qreal length, qreal angle);
|
||||
|
|
|
@ -43,23 +43,23 @@ class VPointFData : public QSharedData
|
|||
public:
|
||||
|
||||
VPointFData()
|
||||
: _mx(0), _my(0), _x(0), _y(0)
|
||||
: _mx(0), _my(0), _x(0), _y(0), m_showLabel(true)
|
||||
{}
|
||||
|
||||
VPointFData(const VPointFData &point)
|
||||
:QSharedData(point), _mx(point._mx), _my(point._my), _x(point._x), _y(point._y)
|
||||
:QSharedData(point), _mx(point._mx), _my(point._my), _x(point._x), _y(point._y), m_showLabel(point.m_showLabel)
|
||||
{}
|
||||
|
||||
explicit VPointFData(const QPointF &point)
|
||||
:_mx(0), _my(0), _x(point.x()), _y(point.y())
|
||||
:_mx(0), _my(0), _x(point.x()), _y(point.y()), m_showLabel(true)
|
||||
{}
|
||||
|
||||
VPointFData(qreal x, qreal y, qreal mx, qreal my)
|
||||
:_mx(mx), _my(my), _x(x), _y(y)
|
||||
:_mx(mx), _my(my), _x(x), _y(y), m_showLabel(true)
|
||||
{}
|
||||
|
||||
VPointFData(const QPointF &point, qreal mx, qreal my)
|
||||
:_mx(mx), _my(my), _x(point.x()), _y(point.y())
|
||||
:_mx(mx), _my(my), _x(point.x()), _y(point.y()), m_showLabel(true)
|
||||
{}
|
||||
|
||||
virtual ~VPointFData();
|
||||
|
@ -76,6 +76,9 @@ public:
|
|||
/** @brief _y y coordinate */
|
||||
qreal _y;
|
||||
|
||||
/** @brief m_hideLabel show or not label for this point */
|
||||
bool m_showLabel;
|
||||
|
||||
private:
|
||||
VPointFData &operator=(const VPointFData &) Q_DECL_EQ_DELETE;
|
||||
};
|
||||
|
|
|
@ -245,21 +245,16 @@ void VContainer::UpdateId(quint32 newId)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief UpdateObject update object in container
|
||||
* @param obj container
|
||||
* @param id id of existing object
|
||||
* @param point object
|
||||
*/
|
||||
template <typename val>
|
||||
void VContainer::UpdateObject(QHash<quint32, val> &obj, const quint32 &id, val point)
|
||||
void VContainer::UpdateObject(const quint32 &id, val point)
|
||||
{
|
||||
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
|
||||
SCASSERT(point.isNull() == false)
|
||||
point->setId(id);
|
||||
if (d->gObjects.contains(id))
|
||||
{
|
||||
d->gObjects[id].clear();
|
||||
}
|
||||
obj[id] = point;
|
||||
d->gObjects.insert(id, point);
|
||||
UpdateId(id);
|
||||
}
|
||||
|
||||
|
@ -505,7 +500,14 @@ void VContainer::UpdateGObject(quint32 id, VGObject* obj)
|
|||
{
|
||||
SCASSERT(obj != nullptr)
|
||||
QSharedPointer<VGObject> pointer(obj);
|
||||
UpdateObject(d->gObjects, id, pointer);
|
||||
UpdateGObject(id, pointer);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VContainer::UpdateGObject(quint32 id, const QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
SCASSERT(not obj.isNull())
|
||||
UpdateObject(id, obj);
|
||||
uniqueNames.insert(obj->name());
|
||||
}
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ public:
|
|||
void RemovePiece(quint32 id);
|
||||
|
||||
void UpdateGObject(quint32 id, VGObject* obj);
|
||||
void UpdateGObject(quint32 id, const QSharedPointer<VGObject> &obj);
|
||||
void UpdatePiece(quint32 id, const VPiece &detail);
|
||||
void UpdatePiecePath(quint32 id, const VPiecePath &path);
|
||||
|
||||
|
@ -220,7 +221,7 @@ private:
|
|||
const val GetObject(const QHash<key, val> &obj, key id) const;
|
||||
|
||||
template <typename val>
|
||||
void UpdateObject(QHash<quint32, val > &obj, const quint32 &id, val point);
|
||||
void UpdateObject(const quint32 &id, val point);
|
||||
|
||||
template <typename key, typename val>
|
||||
static quint32 AddObject(QHash<key, val> &obj, val value);
|
||||
|
@ -239,6 +240,11 @@ Q_DECLARE_TYPEINFO(VContainer, Q_MOVABLE_TYPE);
|
|||
template <typename T>
|
||||
const QSharedPointer<T> VContainer::GeometricObject(const quint32 &id) const
|
||||
{
|
||||
if (id == NULL_ID)
|
||||
{
|
||||
throw VExceptionBadId(tr("Can't find object"), id);
|
||||
}
|
||||
|
||||
QSharedPointer<VGObject> gObj = QSharedPointer<VGObject>();
|
||||
if (d->gObjects.contains(id))
|
||||
{
|
||||
|
|
|
@ -46,21 +46,19 @@ VAbstractFlipping::VAbstractFlipping(VAbstractPattern *doc, VContainer *data, qu
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractFlipping::CreateDestination(Source typeCreation, quint32 &id, QVector<DestinationItem> &dest,
|
||||
const QVector<quint32> &source, const QPointF &fPoint, const QPointF &sPoint,
|
||||
const QString &suffix, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse)
|
||||
void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint,
|
||||
const QPointF &sPoint)
|
||||
{
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
dest.clear();// Try to avoid mistake, value must be empty
|
||||
initData.destination.clear();// Try to avoid mistake, value must be empty
|
||||
|
||||
id = VContainer::getNextId();//Just reserve id for tool
|
||||
initData.id = VContainer::getNextId();//Just reserve id for tool
|
||||
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
for (int i = 0; i < initData.source.size(); ++i)
|
||||
{
|
||||
const quint32 idObject = source.at(i);
|
||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
||||
const quint32 idObject = initData.source.at(i);
|
||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||
|
||||
// This check helps to find missed objects in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||
|
@ -70,25 +68,34 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
switch(static_cast<GOType>(obj->getType()))
|
||||
{
|
||||
case GOType::Point:
|
||||
dest.append(CreatePoint(id, idObject, fPoint, sPoint, suffix, data));
|
||||
initData.destination.append(CreatePoint(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
||||
initData.data));
|
||||
break;
|
||||
case GOType::Arc:
|
||||
dest.append(CreateArc<VArc>(id, idObject, fPoint, sPoint, suffix, data));
|
||||
initData.destination.append(CreateArc<VArc>(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
||||
initData.data));
|
||||
break;
|
||||
case GOType::EllipticalArc:
|
||||
dest.append(CreateArc<VEllipticalArc>(id, idObject, fPoint, sPoint, suffix, data));
|
||||
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, idObject, fPoint, sPoint,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::Spline:
|
||||
dest.append(CreateCurve<VSpline>(id, idObject, fPoint, sPoint, suffix, data));
|
||||
initData.destination.append(CreateCurve<VSpline>(initData.id, idObject, fPoint, sPoint,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::SplinePath:
|
||||
dest.append(CreateCurveWithSegments<VSplinePath>(id, idObject, fPoint, sPoint, suffix, data));
|
||||
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, fPoint,
|
||||
sPoint, initData.suffix,
|
||||
initData.data));
|
||||
break;
|
||||
case GOType::CubicBezier:
|
||||
dest.append(CreateCurve<VCubicBezier>(id, idObject, fPoint, sPoint, suffix, data));
|
||||
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, idObject, fPoint, sPoint,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::CubicBezierPath:
|
||||
dest.append(CreateCurveWithSegments<VCubicBezierPath>(id, idObject, fPoint, sPoint, suffix, data));
|
||||
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, fPoint,
|
||||
sPoint, initData.suffix,
|
||||
initData.data));
|
||||
break;
|
||||
case GOType::Unknown:
|
||||
break;
|
||||
|
@ -98,10 +105,10 @@ QT_WARNING_POP
|
|||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
for (int i = 0; i < initData.source.size(); ++i)
|
||||
{
|
||||
const quint32 idObject = source.at(i);
|
||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
||||
const quint32 idObject = initData.source.at(i);
|
||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||
|
||||
// This check helps to find missed objects in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||
|
@ -111,36 +118,43 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
switch(static_cast<GOType>(obj->getType()))
|
||||
{
|
||||
case GOType::Point:
|
||||
UpdatePoint(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id, dest.at(i).mx,
|
||||
dest.at(i).my);
|
||||
{
|
||||
const DestinationItem &item = initData.destination.at(i);
|
||||
UpdatePoint(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data, item);
|
||||
break;
|
||||
}
|
||||
case GOType::Arc:
|
||||
UpdateArc<VArc>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
|
||||
UpdateArc<VArc>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::EllipticalArc:
|
||||
UpdateArc<VEllipticalArc>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
|
||||
UpdateArc<VEllipticalArc>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::Spline:
|
||||
UpdateCurve<VSpline>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
|
||||
UpdateCurve<VSpline>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::SplinePath:
|
||||
UpdateCurveWithSegments<VSplinePath>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
|
||||
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
||||
initData.data, initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::CubicBezier:
|
||||
UpdateCurve<VCubicBezier>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
|
||||
UpdateCurve<VCubicBezier>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::CubicBezierPath:
|
||||
UpdateCurveWithSegments<VCubicBezierPath>(id, idObject, fPoint, sPoint, suffix, data,
|
||||
dest.at(i).id);
|
||||
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
||||
initData.data, initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::Unknown:
|
||||
break;
|
||||
}
|
||||
QT_WARNING_POP
|
||||
}
|
||||
if (parse != Document::FullParse)
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,6 +170,7 @@ DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, quint32 idItem, c
|
|||
DestinationItem item;
|
||||
item.mx = rotated.mx();
|
||||
item.my = rotated.my();
|
||||
item.showLabel = rotated.IsShowLabel();
|
||||
item.id = data->AddGObject(new VPointF(rotated));
|
||||
return item;
|
||||
}
|
||||
|
@ -172,15 +187,16 @@ DestinationItem VAbstractFlipping::CreateArc(quint32 idTool, quint32 idItem, con
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractFlipping::UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id,
|
||||
qreal mx, qreal my)
|
||||
const QPointF &secondPoint, const QString &suffix, VContainer *data,
|
||||
const DestinationItem &item)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
||||
VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix);
|
||||
rotated.setIdObject(idTool);
|
||||
rotated.setMx(mx);
|
||||
rotated.setMy(my);
|
||||
data->UpdateGObject(id, new VPointF(rotated));
|
||||
rotated.setMx(item.mx);
|
||||
rotated.setMy(item.my);
|
||||
rotated.SetShowLabel(item.showLabel);
|
||||
data->UpdateGObject(item.id, new VPointF(rotated));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -43,10 +43,7 @@ protected:
|
|||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
|
||||
static void CreateDestination(Source typeCreation, quint32 &id, QVector<DestinationItem> &dest,
|
||||
const QVector<quint32> &source, const QPointF &fPoint, const QPointF &sPoint,
|
||||
const QString &suffix, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse);
|
||||
static void CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint, const QPointF &sPoint);
|
||||
|
||||
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
||||
|
@ -65,7 +62,7 @@ protected:
|
|||
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
||||
|
||||
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
|
||||
const QString &suffix, VContainer *data, quint32 id, qreal mx, qreal my);
|
||||
const QString &suffix, VContainer *data, const DestinationItem &item);
|
||||
template <class Item>
|
||||
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
|
||||
const QString &suffix, VContainer *data, quint32 id);
|
||||
|
|
|
@ -84,12 +84,19 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(QSharedPointer<DialogTool> dial
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogFlippingByAxis> dialogTool = dialog.objectCast<DialogFlippingByAxis>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 originPointId = dialogTool->GetOriginPointId();
|
||||
const AxisType axisType = dialogTool->GetAxisType();
|
||||
const QString suffix = dialogTool->GetSuffix();
|
||||
const QVector<quint32> source = dialogTool->GetObjects();
|
||||
VToolFlippingByAxis* operation = Create(0, originPointId, axisType, suffix, source, QVector<DestinationItem>(),
|
||||
scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolFlippingByAxisInitData initData;
|
||||
initData.originPointId = dialogTool->GetOriginPointId();
|
||||
initData.axisType = dialogTool->GetAxisType();
|
||||
initData.suffix = dialogTool->GetSuffix();
|
||||
initData.source = dialogTool->GetObjects();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolFlippingByAxis* operation = Create(initData);
|
||||
if (operation != nullptr)
|
||||
{
|
||||
operation->m_dialog = dialogTool;
|
||||
|
@ -98,17 +105,13 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(QSharedPointer<DialogTool> dial
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolFlippingByAxis *VToolFlippingByAxis::Create(const quint32 _id, quint32 originPointId, AxisType axisType,
|
||||
const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData initData)
|
||||
{
|
||||
const auto originPoint = *data->GeometricObject<VPointF>(originPointId);
|
||||
const auto originPoint = *initData.data->GeometricObject<VPointF>(initData.originPointId);
|
||||
const QPointF fPoint = static_cast<QPointF>(originPoint);
|
||||
|
||||
QPointF sPoint;
|
||||
if (axisType == AxisType::VerticalAxis)
|
||||
if (initData.axisType == AxisType::VerticalAxis)
|
||||
{
|
||||
sPoint = QPointF(fPoint.x(), fPoint.y() + 100);
|
||||
}
|
||||
|
@ -117,23 +120,19 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(const quint32 _id, quint32 orig
|
|||
sPoint = QPointF(fPoint.x() + 100, fPoint.y());
|
||||
}
|
||||
|
||||
QVector<DestinationItem> dest = destination;
|
||||
CreateDestination(initData, fPoint, sPoint);
|
||||
|
||||
quint32 id = _id;
|
||||
CreateDestination(typeCreation, id, dest, source, fPoint, sPoint, suffix, doc, data, parse);
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::FlippingByAxis, doc);
|
||||
VToolFlippingByAxis *tool = new VToolFlippingByAxis(doc, data, id, originPointId, axisType, suffix, source,
|
||||
dest, typeCreation);
|
||||
scene->addItem(tool);
|
||||
InitOperationToolConnections(scene, tool);
|
||||
VAbstractPattern::AddTool(id, tool);
|
||||
doc->IncrementReferens(originPoint.getIdTool());
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
VAbstractTool::AddRecord(initData.id, Tool::FlippingByAxis, initData.doc);
|
||||
VToolFlippingByAxis *tool = new VToolFlippingByAxis(initData);
|
||||
initData.scene->addItem(tool);
|
||||
InitOperationToolConnections(initData.scene, tool);
|
||||
VAbstractPattern::AddTool(initData.id, tool);
|
||||
initData.doc->IncrementReferens(originPoint.getIdTool());
|
||||
for (int i = 0; i < initData.source.size(); ++i)
|
||||
{
|
||||
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
|
||||
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool());
|
||||
}
|
||||
return tool;
|
||||
}
|
||||
|
@ -151,7 +150,7 @@ void VToolFlippingByAxis::SetAxisType(AxisType value)
|
|||
{
|
||||
m_axisType = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
|
@ -167,6 +166,20 @@ void VToolFlippingByAxis::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolFlippingByAxis>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogFlippingByAxis>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByAxis::SetVisualization()
|
||||
{
|
||||
|
@ -216,29 +229,22 @@ void VToolFlippingByAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
QString VToolFlippingByAxis::MakeToolTip() const
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogFlippingByAxis>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
const QString toolTip = QString("<tr> <td><b>%1:</b> %2</td> </tr>")
|
||||
.arg(tr("Origin point"))
|
||||
.arg(OriginPointName());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolFlippingByAxis::VToolFlippingByAxis(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 originPointId,
|
||||
AxisType axisType, const QString &suffix,
|
||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
: VAbstractFlipping(doc, data, id, suffix, source, destination, parent),
|
||||
m_originPointId(originPointId),
|
||||
m_axisType(axisType)
|
||||
VToolFlippingByAxis::VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent)
|
||||
: VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
||||
initData.destination, parent),
|
||||
m_originPointId(initData.originPointId),
|
||||
m_axisType(initData.axisType)
|
||||
{
|
||||
InitOperatedObjects();
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,18 @@
|
|||
|
||||
#include "vabstractflipping.h"
|
||||
|
||||
struct VToolFlippingByAxisInitData : public VAbstractOperationInitData
|
||||
{
|
||||
VToolFlippingByAxisInitData()
|
||||
: VAbstractOperationInitData(),
|
||||
originPointId(NULL_ID),
|
||||
axisType(AxisType::VerticalAxis)
|
||||
{}
|
||||
|
||||
quint32 originPointId;
|
||||
AxisType axisType;
|
||||
};
|
||||
|
||||
class VToolFlippingByAxis : public VAbstractFlipping
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -41,11 +53,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolFlippingByAxis* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolFlippingByAxis* Create(const quint32 _id, quint32 originPointId, AxisType axisType,
|
||||
const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolFlippingByAxis* Create(VToolFlippingByAxisInitData initData);
|
||||
|
||||
static const QString ToolType;
|
||||
|
||||
|
@ -58,22 +66,21 @@ public:
|
|||
QString OriginPointName() const;
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolFlippingByAxis)
|
||||
|
||||
quint32 m_originPointId;
|
||||
AxisType m_axisType;
|
||||
|
||||
VToolFlippingByAxis(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 originPointId,
|
||||
AxisType axisType, const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLFLIPPINGBYAXIS_H
|
||||
|
|
|
@ -84,13 +84,19 @@ VToolFlippingByLine *VToolFlippingByLine::Create(QSharedPointer<DialogTool> dial
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogFlippingByLine> dialogTool = dialog.objectCast<DialogFlippingByLine>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 firstLinePointId = dialogTool->GetFirstLinePointId();
|
||||
const quint32 secondLinePointId = dialogTool->GetSecondLinePointId();
|
||||
const QString suffix = dialogTool->GetSuffix();
|
||||
const QVector<quint32> source = dialogTool->GetObjects();
|
||||
VToolFlippingByLine* operation = Create(0, firstLinePointId, secondLinePointId, suffix, source,
|
||||
QVector<DestinationItem>(), scene, doc, data, Document::FullParse,
|
||||
Source::FromGui);
|
||||
|
||||
VToolFlippingByLineInitData initData;
|
||||
initData.firstLinePointId = dialogTool->GetFirstLinePointId();
|
||||
initData.secondLinePointId = dialogTool->GetSecondLinePointId();
|
||||
initData.suffix = dialogTool->GetSuffix();
|
||||
initData.source = dialogTool->GetObjects();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolFlippingByLine* operation = Create(initData);
|
||||
if (operation != nullptr)
|
||||
{
|
||||
operation->m_dialog = dialogTool;
|
||||
|
@ -99,36 +105,28 @@ VToolFlippingByLine *VToolFlippingByLine::Create(QSharedPointer<DialogTool> dial
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolFlippingByLine *VToolFlippingByLine::Create(const quint32 _id, quint32 firstLinePointId, quint32 secondLinePointId,
|
||||
const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData initData)
|
||||
{
|
||||
const auto firstPoint = *data->GeometricObject<VPointF>(firstLinePointId);
|
||||
const auto firstPoint = *initData.data->GeometricObject<VPointF>(initData.firstLinePointId);
|
||||
const QPointF fPoint = static_cast<QPointF>(firstPoint);
|
||||
|
||||
const auto secondPoint = *data->GeometricObject<VPointF>(secondLinePointId);
|
||||
const auto secondPoint = *initData.data->GeometricObject<VPointF>(initData.secondLinePointId);
|
||||
const QPointF sPoint = static_cast<QPointF>(secondPoint);
|
||||
|
||||
QVector<DestinationItem> dest = destination;
|
||||
CreateDestination(initData, fPoint, sPoint);
|
||||
|
||||
quint32 id = _id;
|
||||
CreateDestination(typeCreation, id, dest, source, fPoint, sPoint, suffix, doc, data, parse);
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::FlippingByLine, doc);
|
||||
VToolFlippingByLine *tool = new VToolFlippingByLine(doc, data, id, firstLinePointId, secondLinePointId, suffix,
|
||||
source, dest, typeCreation);
|
||||
scene->addItem(tool);
|
||||
InitOperationToolConnections(scene, tool);
|
||||
VAbstractPattern::AddTool(id, tool);
|
||||
doc->IncrementReferens(firstPoint.getIdTool());
|
||||
doc->IncrementReferens(secondPoint.getIdTool());
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
VAbstractTool::AddRecord(initData.id, Tool::FlippingByLine, initData.doc);
|
||||
VToolFlippingByLine *tool = new VToolFlippingByLine(initData);
|
||||
initData.scene->addItem(tool);
|
||||
InitOperationToolConnections(initData.scene, tool);
|
||||
VAbstractPattern::AddTool(initData.id, tool);
|
||||
initData.doc->IncrementReferens(firstPoint.getIdTool());
|
||||
initData.doc->IncrementReferens(secondPoint.getIdTool());
|
||||
for (int i = 0; i < initData.source.size(); ++i)
|
||||
{
|
||||
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
|
||||
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool());
|
||||
}
|
||||
return tool;
|
||||
}
|
||||
|
@ -153,6 +151,20 @@ void VToolFlippingByLine::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolFlippingByLine>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogFlippingByLine>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByLine::SetVisualization()
|
||||
{
|
||||
|
@ -202,28 +214,24 @@ void VToolFlippingByLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
QString VToolFlippingByLine::MakeToolTip() const
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogFlippingByLine>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
const QString toolTip = QString("<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"<tr> <td><b>%3:</b> %4</td> </tr>")
|
||||
.arg(tr("First line point"))
|
||||
.arg(FirstLinePointName())
|
||||
.arg(tr("Second line point"))
|
||||
.arg(SecondLinePointName());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolFlippingByLine::VToolFlippingByLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstLinePointId,
|
||||
quint32 secondLinePointId, const QString &suffix,
|
||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
: VAbstractFlipping(doc, data, id, suffix, source, destination, parent),
|
||||
m_firstLinePointId(firstLinePointId),
|
||||
m_secondLinePointId(secondLinePointId)
|
||||
VToolFlippingByLine::VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent)
|
||||
: VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
||||
initData.destination, parent),
|
||||
m_firstLinePointId(initData.firstLinePointId),
|
||||
m_secondLinePointId(initData.secondLinePointId)
|
||||
{
|
||||
InitOperatedObjects();
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,19 @@
|
|||
|
||||
#include "vabstractflipping.h"
|
||||
|
||||
struct VToolFlippingByLineInitData : public VAbstractOperationInitData
|
||||
{
|
||||
VToolFlippingByLineInitData()
|
||||
: VAbstractOperationInitData(),
|
||||
firstLinePointId(NULL_ID),
|
||||
secondLinePointId(NULL_ID)
|
||||
{}
|
||||
|
||||
quint32 firstLinePointId;
|
||||
quint32 secondLinePointId;
|
||||
};
|
||||
|
||||
|
||||
class VToolFlippingByLine : public VAbstractFlipping
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -41,11 +54,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolFlippingByLine* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolFlippingByLine* Create(const quint32 _id, quint32 firstLinePointId, quint32 secondLinePointId,
|
||||
const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolFlippingByLine* Create(VToolFlippingByLineInitData initData);
|
||||
|
||||
static const QString ToolType;
|
||||
|
||||
|
@ -56,22 +65,21 @@ public:
|
|||
QString SecondLinePointName() const;
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolFlippingByLine)
|
||||
|
||||
quint32 m_firstLinePointId;
|
||||
quint32 m_secondLinePointId;
|
||||
|
||||
VToolFlippingByLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstLinePointId,
|
||||
quint32 secondLinePointId, const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLFLIPPINGBYLINE_H
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "vabstractoperation.h"
|
||||
#include "../../../undocommands/label/operationmovelabel.h"
|
||||
#include "../../../undocommands/label/operationshowlabel.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
const QString VAbstractOperation::TagItem = QStringLiteral("item");
|
||||
|
@ -51,7 +52,7 @@ void VAbstractOperation::SetSuffix(const QString &suffix)
|
|||
{
|
||||
// Don't know if need check name here.
|
||||
this->suffix = suffix;
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
|
@ -85,8 +86,39 @@ void VAbstractOperation::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::ExtractData(const QDomElement &domElement, QVector<quint32> &source,
|
||||
QVector<DestinationItem> &destination)
|
||||
bool VAbstractOperation::IsLabelVisible(quint32 id) const
|
||||
{
|
||||
if (operatedObjects.contains(id))
|
||||
{
|
||||
VAbstractSimple *obj = operatedObjects.value(id);
|
||||
if (obj && obj->GetType() == GOType::Point)
|
||||
{
|
||||
return VAbstractTool::data.GeometricObject<VPointF>(id)->IsShowLabel();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::SetLabelVisible(quint32 id, bool visible)
|
||||
{
|
||||
if (operatedObjects.contains(id))
|
||||
{
|
||||
VAbstractSimple *obj = operatedObjects.value(id);
|
||||
if (obj && obj->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
|
||||
SCASSERT(item != nullptr)
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
point->SetShowLabel(visible);
|
||||
item->RefreshPointGeometry(*point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData)
|
||||
{
|
||||
const QDomNodeList nodeList = domElement.childNodes();
|
||||
for (qint32 i = 0; i < nodeList.size(); ++i)
|
||||
|
@ -94,21 +126,21 @@ void VAbstractOperation::ExtractData(const QDomElement &domElement, QVector<quin
|
|||
const QDomElement dataElement = nodeList.at(i).toElement();
|
||||
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
|
||||
{
|
||||
source.clear();
|
||||
initData.source.clear();
|
||||
const QDomNodeList srcList = dataElement.childNodes();
|
||||
for (qint32 j = 0; j < srcList.size(); ++j)
|
||||
{
|
||||
const QDomElement element = srcList.at(j).toElement();
|
||||
if (not element.isNull())
|
||||
{
|
||||
source.append(VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR));
|
||||
initData.source.append(VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
|
||||
{
|
||||
destination.clear();
|
||||
initData.destination.clear();
|
||||
const QDomNodeList srcList = dataElement.childNodes();
|
||||
for (qint32 j = 0; j < srcList.size(); ++j)
|
||||
{
|
||||
|
@ -119,7 +151,8 @@ void VAbstractOperation::ExtractData(const QDomElement &domElement, QVector<quin
|
|||
d.id = VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
|
||||
d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
|
||||
d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
|
||||
destination.append(d);
|
||||
d.showLabel = VDomDocument::GetParametrBool(element, AttrShowLabel, trueStr);
|
||||
initData.destination.append(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,12 +171,14 @@ void VAbstractOperation::FullUpdateFromFile()
|
|||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr)
|
||||
item->setToolTip(ComplexPointToolTip(i.key()));
|
||||
item->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr)
|
||||
item->setToolTip(ComplexCurveToolTip(i.key()));
|
||||
item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +406,7 @@ void VAbstractOperation::Disable(bool disable, const QString &namePP)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::ObjectSelected(bool selected, quint32 objId)
|
||||
{
|
||||
emit ChangedToolSelection(selected, objId, id);
|
||||
emit ChangedToolSelection(selected, objId, m_id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -420,16 +455,29 @@ VAbstractOperation::VAbstractOperation(VAbstractPattern *doc, VContainer *data,
|
|||
void VAbstractOperation::AddToFile()
|
||||
{
|
||||
QDomElement domElement = doc->createElement(getTagName());
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOptions(domElement, obj);
|
||||
AddToCalculation(domElement);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::ChangeLabelVisibility(quint32 id, bool visible)
|
||||
{
|
||||
if (operatedObjects.contains(id))
|
||||
{
|
||||
VAbstractSimple *obj = operatedObjects.value(id);
|
||||
if (obj && obj->GetType() == GOType::Point)
|
||||
{
|
||||
qApp->getUndoStack()->push(new OperationShowLabel(doc, m_id, id, visible));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::UpdateNamePosition(quint32 id)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
auto moveLabel = new OperationMoveLabel(this->id, doc, point->mx(), point->my(), id);
|
||||
auto moveLabel = new OperationMoveLabel(m_id, doc, point->mx(), point->my(), id);
|
||||
connect(moveLabel, &OperationMoveLabel::ChangePosition, this, &VAbstractOperation::DoChangePosition);
|
||||
qApp->getUndoStack()->push(moveLabel);
|
||||
}
|
||||
|
@ -459,6 +507,7 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
|
|||
{
|
||||
doc->SetAttribute(item, AttrMx, qApp->fromPixel(destination.at(i).mx));
|
||||
doc->SetAttribute(item, AttrMy, qApp->fromPixel(destination.at(i).my));
|
||||
doc->SetAttribute<bool>(item, AttrShowLabel, destination.at(i).showLabel);
|
||||
}
|
||||
|
||||
tagObjects.appendChild(item);
|
||||
|
@ -473,10 +522,11 @@ void VAbstractOperation::InitCurve(quint32 id, VContainer *data, GOType curveTyp
|
|||
VSimpleCurve *curve = new VSimpleCurve(id, initCurve);
|
||||
curve->setParentItem(this);
|
||||
curve->SetType(curveType);
|
||||
curve->setToolTip(ComplexCurveToolTip(id));
|
||||
connect(curve, &VSimpleCurve::Selected, this, &VAbstractOperation::ObjectSelected);
|
||||
connect(curve, &VSimpleCurve::ShowContextMenu, this, [this](QGraphicsSceneContextMenuEvent * event)
|
||||
connect(curve, &VSimpleCurve::ShowContextMenu, this, [this](QGraphicsSceneContextMenuEvent * event, quint32 id)
|
||||
{
|
||||
contextMenuEvent(event);
|
||||
ShowContextMenu(event, id);
|
||||
});
|
||||
connect(curve, &VSimpleCurve::Choosed, this, [this, sceneType](quint32 id)
|
||||
{
|
||||
|
@ -570,15 +620,16 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
VSimplePoint *point = new VSimplePoint(object.id, QColor(Qt::black));
|
||||
point->setParentItem(this);
|
||||
point->SetType(GOType::Point);
|
||||
point->setToolTip(ComplexPointToolTip(object.id));
|
||||
connect(point, &VSimplePoint::Choosed, this, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Point);
|
||||
});
|
||||
connect(point, &VSimplePoint::Selected, this, &VAbstractOperation::ObjectSelected);
|
||||
connect(point, &VSimplePoint::ShowContextMenu,
|
||||
this, [this](QGraphicsSceneContextMenuEvent * event)
|
||||
this, [this](QGraphicsSceneContextMenuEvent * event, quint32 id)
|
||||
{
|
||||
contextMenuEvent(event);
|
||||
ShowContextMenu(event, id);
|
||||
});
|
||||
connect(point, &VSimplePoint::Delete, this, &VAbstractOperation::DeleteFromLabel);
|
||||
connect(point, &VSimplePoint::NameChangedPosition, this, &VAbstractOperation::LabelChangePosition);
|
||||
|
@ -606,3 +657,35 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
QT_WARNING_POP
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractOperation::ComplexPointToolTip(quint32 itemId) const
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(itemId);
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"%3"
|
||||
"</table>")
|
||||
.arg(tr("Label"), point->name(), MakeToolTip());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractOperation::ComplexCurveToolTip(quint32 itemId) const
|
||||
{
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(itemId);
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"<tr> <td><b>%3:</b> %4 %5</td> </tr>"
|
||||
"%6"
|
||||
"</table>")
|
||||
.arg(tr("Label"))
|
||||
.arg(curve->name())
|
||||
.arg(tr("Length"))
|
||||
.arg(qApp->fromPixel(curve->GetLength()))
|
||||
.arg(UnitsToStr(qApp->patternUnit(), true))
|
||||
.arg(MakeToolTip());
|
||||
return toolTip;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,21 @@ struct DestinationItem
|
|||
quint32 id;
|
||||
qreal mx;
|
||||
qreal my;
|
||||
bool showLabel;
|
||||
};
|
||||
|
||||
struct VAbstractOperationInitData : public VAbstractToolInitData
|
||||
{
|
||||
VAbstractOperationInitData()
|
||||
: VAbstractToolInitData(),
|
||||
suffix(),
|
||||
source(),
|
||||
destination()
|
||||
{}
|
||||
|
||||
QString suffix;
|
||||
QVector<quint32> source;
|
||||
QVector<DestinationItem> destination;
|
||||
};
|
||||
|
||||
// FIXME. I don't know how to use QGraphicsItem properly, so just took first available finished class.
|
||||
|
@ -73,8 +88,10 @@ public:
|
|||
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
|
||||
|
||||
static void ExtractData(const QDomElement &domElement, QVector<quint32> &source,
|
||||
QVector<DestinationItem> &destination);
|
||||
virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE;
|
||||
virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||
|
||||
static void ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
||||
|
||||
|
@ -118,6 +135,7 @@ protected:
|
|||
QGraphicsItem *parent = nullptr);
|
||||
|
||||
virtual void AddToFile() Q_DECL_OVERRIDE;
|
||||
virtual void ChangeLabelVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||
|
||||
void UpdateNamePosition(quint32 id);
|
||||
void SaveSourceDestination(QDomElement &tag);
|
||||
|
@ -131,6 +149,9 @@ protected:
|
|||
static void InitOperationToolConnections(VMainGraphicsScene *scene, T *tool);
|
||||
|
||||
void InitOperatedObjects();
|
||||
|
||||
QString ComplexPointToolTip(quint32 itemId) const;
|
||||
QString ComplexCurveToolTip(quint32 itemId) const;
|
||||
protected slots:
|
||||
void DoChangePosition(quint32 id, qreal mx, qreal my);
|
||||
private:
|
||||
|
|
|
@ -92,12 +92,19 @@ VToolMove *VToolMove::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsSce
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogMove> dialogTool = dialog.objectCast<DialogMove>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
QString angle = dialogTool->GetAngle();
|
||||
QString length = dialogTool->GetLength();
|
||||
const QString suffix = dialogTool->GetSuffix();
|
||||
const QVector<quint32> source = dialogTool->GetObjects();
|
||||
VToolMove* operation = Create(0, angle, length, suffix, source, QVector<DestinationItem>(), scene, doc, data,
|
||||
Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolMoveInitData initData;
|
||||
initData.formulaAngle = dialogTool->GetAngle();
|
||||
initData.formulaLength = dialogTool->GetLength();
|
||||
initData.suffix = dialogTool->GetSuffix();
|
||||
initData.source = dialogTool->GetObjects();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolMove* operation = Create(initData);
|
||||
if (operation != nullptr)
|
||||
{
|
||||
operation->m_dialog = dialogTool;
|
||||
|
@ -106,31 +113,24 @@ VToolMove *VToolMove::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsSce
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolMove *VToolMove::Create(quint32 _id, QString &formulaAngle, QString &formulaLength,
|
||||
const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolMove *VToolMove::Create(VToolMoveInitData &initData)
|
||||
{
|
||||
qreal calcAngle = 0;
|
||||
qreal calcLength = 0;
|
||||
|
||||
calcAngle = CheckFormula(_id, formulaAngle, data);
|
||||
calcLength = qApp->toPixel(CheckFormula(_id, formulaLength, data));
|
||||
calcAngle = CheckFormula(initData.id, initData.formulaAngle, initData.data);
|
||||
calcLength = qApp->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data));
|
||||
|
||||
QVector<DestinationItem> dest = destination;
|
||||
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
dest.clear();// Try to avoid mistake, value must be empty
|
||||
initData.destination.clear();// Try to avoid mistake, value must be empty
|
||||
|
||||
id = VContainer::getNextId();//Just reserve id for tool
|
||||
initData.id = VContainer::getNextId();//Just reserve id for tool
|
||||
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
for (int i = 0; i < initData.source.size(); ++i)
|
||||
{
|
||||
const quint32 idObject = source.at(i);
|
||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
||||
const quint32 idObject = initData.source.at(i);
|
||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||
|
||||
// This check helps to find missed objects in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||
|
@ -140,27 +140,35 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
switch(static_cast<GOType>(obj->getType()))
|
||||
{
|
||||
case GOType::Point:
|
||||
dest.append(CreatePoint(id, idObject, calcAngle, calcLength, suffix, data));
|
||||
initData.destination.append(CreatePoint(initData.id, idObject, calcAngle, calcLength,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::Arc:
|
||||
dest.append(CreateArc<VArc>(id, idObject, calcAngle, calcLength, suffix, data));
|
||||
initData.destination.append(CreateArc<VArc>(initData.id, idObject, calcAngle, calcLength,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::EllipticalArc:
|
||||
dest.append(CreateArc<VEllipticalArc>(id, idObject, calcAngle, calcLength, suffix, data));
|
||||
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, idObject, calcAngle, calcLength,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::Spline:
|
||||
dest.append(CreateCurve<VSpline>(id, idObject, calcAngle, calcLength, suffix, data));
|
||||
initData.destination.append(CreateCurve<VSpline>(initData.id, idObject, calcAngle, calcLength,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::SplinePath:
|
||||
dest.append(CreateCurveWithSegments<VSplinePath>(id, idObject, calcAngle, calcLength, suffix,
|
||||
data));
|
||||
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, calcAngle,
|
||||
calcLength, initData.suffix,
|
||||
initData.data));
|
||||
break;
|
||||
case GOType::CubicBezier:
|
||||
dest.append(CreateCurve<VCubicBezier>(id, idObject, calcAngle, calcLength, suffix, data));
|
||||
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, idObject, calcAngle, calcLength,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::CubicBezierPath:
|
||||
dest.append(CreateCurveWithSegments<VCubicBezierPath>(id, idObject, calcAngle, calcLength, suffix,
|
||||
data));
|
||||
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject,
|
||||
calcAngle, calcLength,
|
||||
initData.suffix,
|
||||
initData.data));
|
||||
break;
|
||||
case GOType::Unknown:
|
||||
break;
|
||||
|
@ -170,10 +178,10 @@ QT_WARNING_POP
|
|||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
for (int i = 0; i < initData.source.size(); ++i)
|
||||
{
|
||||
const quint32 idObject = source.at(i);
|
||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
||||
const quint32 idObject = initData.source.at(i);
|
||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||
|
||||
// This check helps to find missed objects in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||
|
@ -183,51 +191,55 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
switch(static_cast<GOType>(obj->getType()))
|
||||
{
|
||||
case GOType::Point:
|
||||
UpdatePoint(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id, dest.at(i).mx,
|
||||
dest.at(i).my);
|
||||
UpdatePoint(initData.id, idObject, calcAngle, calcLength, initData.suffix, initData.data,
|
||||
initData.destination.at(i));
|
||||
break;
|
||||
case GOType::Arc:
|
||||
UpdateArc<VArc>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
|
||||
UpdateArc<VArc>(initData.id, idObject, calcAngle, calcLength, initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::EllipticalArc:
|
||||
UpdateArc<VEllipticalArc>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
|
||||
UpdateArc<VEllipticalArc>(initData.id, idObject, calcAngle, calcLength, initData.suffix,
|
||||
initData.data, initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::Spline:
|
||||
UpdateCurve<VSpline>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
|
||||
UpdateCurve<VSpline>(initData.id, idObject, calcAngle, calcLength, initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::SplinePath:
|
||||
UpdateCurveWithSegments<VSplinePath>(id, idObject, calcAngle, calcLength, suffix, data,
|
||||
dest.at(i).id);
|
||||
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, calcAngle, calcLength, initData.suffix,
|
||||
initData.data, initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::CubicBezier:
|
||||
UpdateCurve<VCubicBezier>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
|
||||
UpdateCurve<VCubicBezier>(initData.id, idObject, calcAngle, calcLength, initData.suffix,
|
||||
initData.data, initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::CubicBezierPath:
|
||||
UpdateCurveWithSegments<VCubicBezierPath>(id, idObject, calcAngle, calcLength, suffix, data,
|
||||
dest.at(i).id);
|
||||
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, calcAngle, calcLength,
|
||||
initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::Unknown:
|
||||
break;
|
||||
}
|
||||
QT_WARNING_POP
|
||||
}
|
||||
if (parse != Document::FullParse)
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::Move, doc);
|
||||
VToolMove *tool = new VToolMove(doc, data, id, formulaAngle, formulaLength, suffix, source, dest,
|
||||
typeCreation);
|
||||
scene->addItem(tool);
|
||||
InitOperationToolConnections(scene, tool);
|
||||
VAbstractPattern::AddTool(id, tool);
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
VAbstractTool::AddRecord(initData.id, Tool::Move, initData.doc);
|
||||
VToolMove *tool = new VToolMove(initData);
|
||||
initData.scene->addItem(tool);
|
||||
InitOperationToolConnections(initData.scene, tool);
|
||||
VAbstractPattern::AddTool(initData.id, tool);
|
||||
for (int i = 0; i < initData.source.size(); ++i)
|
||||
{
|
||||
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
|
||||
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool());
|
||||
}
|
||||
return tool;
|
||||
}
|
||||
|
@ -239,7 +251,7 @@ VFormula VToolMove::GetFormulaAngle() const
|
|||
{
|
||||
VFormula fAngle(formulaAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(id);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
return fAngle;
|
||||
}
|
||||
|
@ -251,7 +263,7 @@ void VToolMove::SetFormulaAngle(const VFormula &value)
|
|||
{
|
||||
formulaAngle = value.GetFormula(FormulaType::FromUser);
|
||||
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +273,7 @@ VFormula VToolMove::GetFormulaLength() const
|
|||
{
|
||||
VFormula fLength(formulaLength, getData());
|
||||
fLength.setCheckZero(true);
|
||||
fLength.setToolId(id);
|
||||
fLength.setToolId(m_id);
|
||||
fLength.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
return fLength;
|
||||
}
|
||||
|
@ -273,7 +285,7 @@ void VToolMove::SetFormulaLength(const VFormula &value)
|
|||
{
|
||||
formulaLength = value.GetFormula(FormulaType::FromUser);
|
||||
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -284,6 +296,20 @@ void VToolMove::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolMove>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolMove::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogMove>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolMove::SetVisualization()
|
||||
{
|
||||
|
@ -334,30 +360,27 @@ void VToolMove::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolMove::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
QString VToolMove::MakeToolTip() const
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogMove>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
const QString toolTip = QString("<tr> <td><b>%1:</b> %2°</td> </tr>"
|
||||
"<tr> <td><b>%3:</b> %4 %5</td> </tr>")
|
||||
.arg(tr("Rotation angle"))
|
||||
.arg(GetFormulaAngle().getDoubleValue())
|
||||
.arg(tr("Length"))
|
||||
.arg(GetFormulaLength().getDoubleValue())
|
||||
.arg(UnitsToStr(qApp->patternUnit(), true));
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolMove::VToolMove(VAbstractPattern *doc, VContainer *data, quint32 id,
|
||||
const QString &formulaAngle, const QString &formulaLength, const QString &suffix,
|
||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
: VAbstractOperation(doc, data, id, suffix, source, destination, parent),
|
||||
formulaAngle(formulaAngle),
|
||||
formulaLength(formulaLength)
|
||||
VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent)
|
||||
: VAbstractOperation(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
||||
initData.destination, parent),
|
||||
formulaAngle(initData.formulaAngle),
|
||||
formulaLength(initData.formulaLength)
|
||||
{
|
||||
InitOperatedObjects();
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -371,6 +394,7 @@ DestinationItem VToolMove::CreatePoint(quint32 idTool, quint32 idItem, qreal ang
|
|||
DestinationItem item;
|
||||
item.mx = moved.mx();
|
||||
item.my = moved.my();
|
||||
item.showLabel = moved.IsShowLabel();
|
||||
item.id = data->AddGObject(new VPointF(moved));
|
||||
return item;
|
||||
}
|
||||
|
@ -387,14 +411,15 @@ DestinationItem VToolMove::CreateArc(quint32 idTool, quint32 idItem, qreal angle
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolMove::UpdatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
|
||||
VContainer *data, quint32 id, qreal mx, qreal my)
|
||||
VContainer *data, const DestinationItem &item)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
||||
VPointF moved = point->Move(length, angle, suffix);
|
||||
moved.setIdObject(idTool);
|
||||
moved.setMx(mx);
|
||||
moved.setMy(my);
|
||||
data->UpdateGObject(id, new VPointF(moved));
|
||||
moved.setMx(item.mx);
|
||||
moved.setMy(item.my);
|
||||
moved.SetShowLabel(item.showLabel);
|
||||
data->UpdateGObject(item.id, new VPointF(moved));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -45,6 +45,18 @@
|
|||
template <class T> class QSharedPointer;
|
||||
class VFormula;
|
||||
|
||||
struct VToolMoveInitData : public VAbstractOperationInitData
|
||||
{
|
||||
VToolMoveInitData()
|
||||
: VAbstractOperationInitData(),
|
||||
formulaAngle(),
|
||||
formulaLength()
|
||||
{}
|
||||
|
||||
QString formulaAngle;
|
||||
QString formulaLength;
|
||||
};
|
||||
|
||||
class VToolMove : public VAbstractOperation
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -53,10 +65,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolMove* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolMove* Create(quint32 _id, QString &formulaAngle, QString &formulaLength, const QString &suffix,
|
||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolMove* Create(VToolMoveInitData &initData);
|
||||
|
||||
static const QString ToolType;
|
||||
|
||||
|
@ -70,23 +79,20 @@ public:
|
|||
void SetFormulaLength(const VFormula &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolMove)
|
||||
QString formulaAngle;
|
||||
QString formulaLength;
|
||||
|
||||
VToolMove(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &formulaAngle,
|
||||
const QString &formulaLength, const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
|
||||
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
|
||||
VContainer *data);
|
||||
|
@ -105,7 +111,7 @@ private:
|
|||
const QString &suffix, VContainer *data);
|
||||
|
||||
static void UpdatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
|
||||
VContainer *data, quint32 id, qreal mx, qreal my);
|
||||
VContainer *data, const DestinationItem &item);
|
||||
template <class Item>
|
||||
static void UpdateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
|
||||
VContainer *data, quint32 id);
|
||||
|
|
|
@ -80,16 +80,14 @@ template <class T> class QSharedPointer;
|
|||
const QString VToolRotation::ToolType = QStringLiteral("rotation");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolRotation::VToolRotation(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 origPointId,
|
||||
const QString &angle, const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
: VAbstractOperation(doc, data, id, suffix, source, destination, parent),
|
||||
origPointId(origPointId),
|
||||
formulaAngle(angle)
|
||||
VToolRotation::VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent)
|
||||
: VAbstractOperation(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
||||
initData.destination, parent),
|
||||
origPointId(initData.origin),
|
||||
formulaAngle(initData.angle)
|
||||
{
|
||||
InitOperatedObjects();
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -110,12 +108,19 @@ VToolRotation *VToolRotation::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogRotation> dialogTool = dialog.objectCast<DialogRotation>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 originPointId = dialogTool->GetOrigPointId();
|
||||
QString angle = dialogTool->GetAngle();
|
||||
const QString suffix = dialogTool->GetSuffix();
|
||||
const QVector<quint32> source = dialogTool->GetObjects();
|
||||
VToolRotation* operation = Create(0, originPointId, angle, suffix, source, QVector<DestinationItem>(),
|
||||
scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolRotationInitData initData;
|
||||
initData.origin = dialogTool->GetOrigPointId();
|
||||
initData.angle = dialogTool->GetAngle();
|
||||
initData.suffix = dialogTool->GetSuffix();
|
||||
initData.source = dialogTool->GetObjects();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolRotation* operation = Create(initData);
|
||||
if (operation != nullptr)
|
||||
{
|
||||
operation->m_dialog = dialogTool;
|
||||
|
@ -124,32 +129,25 @@ VToolRotation *VToolRotation::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolRotation *VToolRotation::Create(const quint32 _id, const quint32 &origin, QString &angle, const QString &suffix,
|
||||
const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolRotation *VToolRotation::Create(VToolRotationInitData &initData)
|
||||
{
|
||||
qreal calcAngle = 0;
|
||||
|
||||
calcAngle = CheckFormula(_id, angle, data);
|
||||
calcAngle = CheckFormula(initData.id, initData.angle, initData.data);
|
||||
|
||||
const auto originPoint = *data->GeometricObject<VPointF>(origin);
|
||||
const auto originPoint = *initData.data->GeometricObject<VPointF>(initData.origin);
|
||||
const QPointF oPoint = static_cast<QPointF>(originPoint);
|
||||
|
||||
QVector<DestinationItem> dest = destination;
|
||||
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
dest.clear();// Try to avoid mistake, value must be empty
|
||||
initData.destination.clear();// Try to avoid mistake, value must be empty
|
||||
|
||||
id = VContainer::getNextId();//Just reserve id for tool
|
||||
initData.id = VContainer::getNextId();//Just reserve id for tool
|
||||
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
for (int i = 0; i < initData.source.size(); ++i)
|
||||
{
|
||||
const quint32 idObject = source.at(i);
|
||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
||||
const quint32 idObject = initData.source.at(i);
|
||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||
|
||||
// This check helps to find missed objects in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||
|
@ -159,26 +157,34 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
switch(static_cast<GOType>(obj->getType()))
|
||||
{
|
||||
case GOType::Point:
|
||||
dest.append(CreatePoint(id, idObject, oPoint, calcAngle, suffix, data));
|
||||
initData.destination.append(CreatePoint(initData.id, idObject, oPoint, calcAngle, initData.suffix,
|
||||
initData.data));
|
||||
break;
|
||||
case GOType::Arc:
|
||||
dest.append(CreateArc<VArc>(id, idObject, oPoint, calcAngle, suffix, data));
|
||||
initData.destination.append(CreateArc<VArc>(initData.id, idObject, oPoint, calcAngle,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::EllipticalArc:
|
||||
dest.append(CreateArc<VEllipticalArc>(id, idObject, oPoint, calcAngle, suffix, data));
|
||||
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, idObject, oPoint, calcAngle,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::Spline:
|
||||
dest.append(CreateCurve<VSpline>(id, idObject, oPoint, calcAngle, suffix, data));
|
||||
initData.destination.append(CreateCurve<VSpline>(initData.id, idObject, oPoint, calcAngle,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::SplinePath:
|
||||
dest.append(CreateCurveWithSegments<VSplinePath>(id, idObject, oPoint, calcAngle, suffix, data));
|
||||
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, oPoint,
|
||||
calcAngle, initData.suffix,
|
||||
initData.data));
|
||||
break;
|
||||
case GOType::CubicBezier:
|
||||
dest.append(CreateCurve<VCubicBezier>(id, idObject, oPoint, calcAngle, suffix, data));
|
||||
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, idObject, oPoint, calcAngle,
|
||||
initData.suffix, initData.data));
|
||||
break;
|
||||
case GOType::CubicBezierPath:
|
||||
dest.append(CreateCurveWithSegments<VCubicBezierPath>(id, idObject, oPoint, calcAngle, suffix,
|
||||
data));
|
||||
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, oPoint,
|
||||
calcAngle, initData.suffix,
|
||||
initData.data));
|
||||
break;
|
||||
case GOType::Unknown:
|
||||
break;
|
||||
|
@ -188,10 +194,10 @@ QT_WARNING_POP
|
|||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
for (int i = 0; i < initData.source.size(); ++i)
|
||||
{
|
||||
const quint32 idObject = source.at(i);
|
||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
||||
const quint32 idObject = initData.source.at(i);
|
||||
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||
|
||||
// This check helps to find missed objects in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||
|
@ -201,50 +207,57 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
switch(static_cast<GOType>(obj->getType()))
|
||||
{
|
||||
case GOType::Point:
|
||||
UpdatePoint(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id, dest.at(i).mx,
|
||||
dest.at(i).my);
|
||||
{
|
||||
UpdatePoint(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
||||
initData.destination.at(i));
|
||||
break;
|
||||
}
|
||||
case GOType::Arc:
|
||||
UpdateArc<VArc>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
||||
UpdateArc<VArc>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::EllipticalArc:
|
||||
UpdateArc<VEllipticalArc>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
||||
UpdateArc<VEllipticalArc>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::Spline:
|
||||
UpdateCurve<VSpline>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
||||
UpdateCurve<VSpline>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::SplinePath:
|
||||
UpdateCurveWithSegments<VSplinePath>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
||||
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, oPoint, calcAngle, initData.suffix,
|
||||
initData.data, initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::CubicBezier:
|
||||
UpdateCurve<VCubicBezier>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
||||
UpdateCurve<VCubicBezier>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
||||
initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::CubicBezierPath:
|
||||
UpdateCurveWithSegments<VCubicBezierPath>(id, idObject, oPoint, calcAngle, suffix, data,
|
||||
dest.at(i).id);
|
||||
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, oPoint, calcAngle, initData.suffix,
|
||||
initData.data, initData.destination.at(i).id);
|
||||
break;
|
||||
case GOType::Unknown:
|
||||
break;
|
||||
}
|
||||
QT_WARNING_POP
|
||||
}
|
||||
if (parse != Document::FullParse)
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::Rotation, doc);
|
||||
VToolRotation *tool = new VToolRotation(doc, data, id, origin, angle, suffix, source, dest, typeCreation);
|
||||
scene->addItem(tool);
|
||||
InitOperationToolConnections(scene, tool);
|
||||
VAbstractPattern::AddTool(id, tool);
|
||||
doc->IncrementReferens(originPoint.getIdTool());
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
VAbstractTool::AddRecord(initData.id, Tool::Rotation, initData.doc);
|
||||
VToolRotation *tool = new VToolRotation(initData);
|
||||
initData.scene->addItem(tool);
|
||||
InitOperationToolConnections(initData.scene, tool);
|
||||
VAbstractPattern::AddTool(initData.id, tool);
|
||||
initData.doc->IncrementReferens(originPoint.getIdTool());
|
||||
for (int i = 0; i < initData.source.size(); ++i)
|
||||
{
|
||||
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
|
||||
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool());
|
||||
}
|
||||
return tool;
|
||||
}
|
||||
|
@ -262,7 +275,7 @@ VFormula VToolRotation::GetFormulaAngle() const
|
|||
{
|
||||
VFormula fAngle(formulaAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(id);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
return fAngle;
|
||||
}
|
||||
|
@ -274,7 +287,7 @@ void VToolRotation::SetFormulaAngle(const VFormula &value)
|
|||
{
|
||||
formulaAngle = value.GetFormula(FormulaType::FromUser);
|
||||
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -285,6 +298,20 @@ void VToolRotation::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolRotation>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogRotation>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::SetVisualization()
|
||||
{
|
||||
|
@ -334,17 +361,15 @@ void VToolRotation::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
QString VToolRotation::MakeToolTip() const
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogRotation>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
const QString toolTip = QString("<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"<tr> <td><b>%3:</b> %4°</td> </tr>")
|
||||
.arg(tr("Origin point"))
|
||||
.arg(OriginPointName())
|
||||
.arg(tr("Rotation angle"))
|
||||
.arg(GetFormulaAngle().getDoubleValue());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -358,6 +383,7 @@ DestinationItem VToolRotation::CreatePoint(quint32 idTool, quint32 idItem, const
|
|||
DestinationItem item;
|
||||
item.mx = rotated.mx();
|
||||
item.my = rotated.my();
|
||||
item.showLabel = rotated.IsShowLabel();
|
||||
item.id = data->AddGObject(new VPointF(rotated));
|
||||
return item;
|
||||
}
|
||||
|
@ -410,14 +436,15 @@ DestinationItem VToolRotation::CreateCurveWithSegments(quint32 idTool, quint32 i
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||
const QString &suffix, VContainer *data, quint32 id, qreal mx, qreal my)
|
||||
const QString &suffix, VContainer *data, const DestinationItem &item)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
||||
VPointF rotated = point->Rotate(origin, angle, suffix);
|
||||
rotated.setIdObject(idTool);
|
||||
rotated.setMx(mx);
|
||||
rotated.setMy(my);
|
||||
data->UpdateGObject(id, new VPointF(rotated));
|
||||
rotated.setMx(item.mx);
|
||||
rotated.setMy(item.my);
|
||||
rotated.SetShowLabel(item.showLabel);
|
||||
data->UpdateGObject(item.id, new VPointF(rotated));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -45,6 +45,18 @@
|
|||
template <class T> class QSharedPointer;
|
||||
class VFormula;
|
||||
|
||||
struct VToolRotationInitData : public VAbstractOperationInitData
|
||||
{
|
||||
VToolRotationInitData()
|
||||
: VAbstractOperationInitData(),
|
||||
origin(NULL_ID),
|
||||
angle()
|
||||
{}
|
||||
|
||||
quint32 origin;
|
||||
QString angle;
|
||||
};
|
||||
|
||||
class VToolRotation : public VAbstractOperation
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -53,10 +65,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolRotation* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolRotation* Create(const quint32 _id, const quint32 &origin, QString &angle, const QString &suffix,
|
||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolRotation* Create(VToolRotationInitData &initData);
|
||||
|
||||
static const QString ToolType;
|
||||
|
||||
|
@ -69,23 +78,21 @@ public:
|
|||
void SetFormulaAngle(const VFormula &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolRotation)
|
||||
quint32 origPointId;
|
||||
QString formulaAngle;
|
||||
|
||||
VToolRotation(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 origPointId,
|
||||
const QString &angle, const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
|
||||
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||
const QString &suffix, VContainer *data);
|
||||
|
@ -104,7 +111,7 @@ private:
|
|||
qreal angle, const QString &suffix, VContainer *data);
|
||||
|
||||
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||
const QString &suffix, VContainer *data, quint32 id, qreal mx, qreal my);
|
||||
const QString &suffix, VContainer *data, const DestinationItem &item);
|
||||
template <class Item>
|
||||
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||
const QString &suffix, VContainer *data, quint32 id);
|
||||
|
|
|
@ -69,7 +69,7 @@ VAbstractSpline::VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint3
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPainterPath VAbstractSpline::shape() const
|
||||
{
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||
const QVector<QPointF> points = curve->GetPoints();
|
||||
|
||||
QPainterPath path;
|
||||
|
@ -94,7 +94,7 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
|||
{
|
||||
const qreal width = ScaleWidth(m_isHovered ? widthMainLine : widthHairLine, SceneScale(scene()));
|
||||
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||
setPen(QPen(CorrectColor(this, curve->GetColor()), width, LineStyleToPenStyle(curve->GetPenStyle()), Qt::RoundCap));
|
||||
|
||||
RefreshCtrlPoints();
|
||||
|
@ -166,14 +166,17 @@ void VAbstractSpline::AllowSelecting(bool enabled)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractSpline::MakeToolTip() const
|
||||
{
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%4:</b> %5</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"</table>")
|
||||
.arg(tr("Length"))
|
||||
.arg(qApp->fromPixel(curve->GetLength()))
|
||||
.arg(UnitsToStr(qApp->patternUnit(), true));
|
||||
.arg(UnitsToStr(qApp->patternUnit(), true))
|
||||
.arg(tr("Label"))
|
||||
.arg(curve->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
|
@ -232,7 +235,7 @@ QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, c
|
|||
{
|
||||
if (change == QGraphicsItem::ItemSelectedChange)
|
||||
{
|
||||
emit ChangedToolSelection(value.toBool(), id, id);
|
||||
emit ChangedToolSelection(value.toBool(), m_id, m_id);
|
||||
}
|
||||
|
||||
return QGraphicsPathItem::itemChange(change, value);
|
||||
|
@ -288,7 +291,7 @@ void VAbstractSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
emit ChoosedTool(id, sceneType);
|
||||
emit ChoosedTool(m_id, sceneType);
|
||||
}
|
||||
QGraphicsPathItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
@ -315,6 +318,12 @@ void VAbstractSpline::RefreshCtrlPoints()
|
|||
// do nothing
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
ShowContextMenu(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePointPosition &position,
|
||||
const QPointF &pos) const
|
||||
|
@ -386,7 +395,7 @@ VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePoin
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractSpline::InitDefShape()
|
||||
{
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||
this->setPath(curve->GetPath());
|
||||
}
|
||||
|
||||
|
@ -402,14 +411,14 @@ void VAbstractSpline::ShowHandles(bool show)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractSpline::GetLineColor() const
|
||||
{
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||
return curve->GetColor();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractSpline::SetLineColor(const QString &value)
|
||||
{
|
||||
QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
|
||||
QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||
curve->SetColor(value);
|
||||
QSharedPointer<VGObject> obj = qSharedPointerCast<VGObject>(curve);
|
||||
SaveOption(obj);
|
||||
|
@ -418,14 +427,14 @@ void VAbstractSpline::SetLineColor(const QString &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractSpline::GetPenStyle() const
|
||||
{
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||
return curve->GetPenStyle();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractSpline::SetPenStyle(const QString &value)
|
||||
{
|
||||
QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
|
||||
QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||
curve->SetPenStyle(value);
|
||||
QSharedPointer<VGObject> obj = qSharedPointerCast<VGObject>(curve);
|
||||
SaveOption(obj);
|
||||
|
@ -434,7 +443,7 @@ void VAbstractSpline::SetPenStyle(const QString &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractSpline::name() const
|
||||
{
|
||||
return ObjectName<VAbstractCurve>(id);
|
||||
return ObjectName<VAbstractCurve>(m_id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -54,6 +54,18 @@
|
|||
class VControlPointSpline;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VAbstractSplineInitData : public VAbstractToolInitData
|
||||
{
|
||||
VAbstractSplineInitData()
|
||||
: VAbstractToolInitData(),
|
||||
color(ColorBlack),
|
||||
penStyle(TypeLineLine)
|
||||
{}
|
||||
|
||||
QString color;
|
||||
QString penStyle;
|
||||
};
|
||||
|
||||
class VAbstractSpline:public VDrawTool, public QGraphicsPathItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -83,7 +95,6 @@ public slots:
|
|||
virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE;
|
||||
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
||||
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
||||
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
|
||||
signals:
|
||||
/**
|
||||
* @brief setEnabledPoint disable control points.
|
||||
|
@ -112,6 +123,8 @@ protected:
|
|||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void RefreshCtrlPoints();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
|
||||
|
||||
VSpline CorrectedSpline(const VSpline &spline, const SplinePointPosition &position, const QPointF &pos) const;
|
||||
|
||||
|
|
|
@ -61,21 +61,16 @@ const QString VToolArc::ToolType = QStringLiteral("simple");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolArc constuctor.
|
||||
* @param doc dom document container
|
||||
* @param data container with variables
|
||||
* @param id object id in container
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param parent parent object
|
||||
* @param initData init data
|
||||
*/
|
||||
VToolArc::VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
: VAbstractSpline(doc, data, id, parent)
|
||||
VToolArc::VToolArc(const VToolArcInitData &initData, QGraphicsItem *parent)
|
||||
: VAbstractSpline(initData.doc, initData.data, initData.id, parent)
|
||||
{
|
||||
sceneType = SceneObject::Arc;
|
||||
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -87,7 +82,7 @@ void VToolArc::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogArc> dialogTool = m_dialog.objectCast<DialogArc>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
dialogTool->SetCenter(arc->GetCenter().id());
|
||||
dialogTool->SetF1(arc->GetFormulaF1());
|
||||
dialogTool->SetF2(arc->GetFormulaF2());
|
||||
|
@ -110,14 +105,21 @@ VToolArc* VToolArc::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogArc> dialogTool = dialog.objectCast<DialogArc>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 center = dialogTool->GetCenter();
|
||||
QString radius = dialogTool->GetRadius();
|
||||
QString f1 = dialogTool->GetF1();
|
||||
QString f2 = dialogTool->GetF2();
|
||||
const QString color = dialogTool->GetColor();
|
||||
const QString penStyle = dialogTool->GetPenStyle();
|
||||
VToolArc* point = Create(0, center, radius, f1, f2, color, penStyle, scene, doc, data, Document::FullParse,
|
||||
Source::FromGui);
|
||||
|
||||
VToolArcInitData initData;
|
||||
initData.center = dialogTool->GetCenter();
|
||||
initData.radius = dialogTool->GetRadius();
|
||||
initData.f1 = dialogTool->GetF1();
|
||||
initData.f2 = dialogTool->GetF2();
|
||||
initData.color = dialogTool->GetColor();
|
||||
initData.penStyle = dialogTool->GetPenStyle();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolArc* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -128,56 +130,45 @@ VToolArc* VToolArc::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool form GUI.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param center id arc center point.
|
||||
* @param radius arc radius.
|
||||
* @param f1 start angle of arc.
|
||||
* @param f2 end angle of arc.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2,
|
||||
const QString &color, const QString &penStyle, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation)
|
||||
VToolArc* VToolArc::Create(VToolArcInitData &initData)
|
||||
{
|
||||
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
|
||||
|
||||
calcRadius = qApp->toPixel(CheckFormula(_id, radius, data));
|
||||
calcRadius = qApp->toPixel(CheckFormula(initData.id, initData.radius, initData.data));
|
||||
|
||||
calcF1 = CheckFormula(_id, f1, data);
|
||||
calcF2 = CheckFormula(_id, f2, data);
|
||||
calcF1 = CheckFormula(initData.id, initData.f1, initData.data);
|
||||
calcF2 = CheckFormula(initData.id, initData.f2, initData.data);
|
||||
|
||||
const VPointF c = *data->GeometricObject<VPointF>(center);
|
||||
VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 );
|
||||
arc->SetColor(color);
|
||||
arc->SetPenStyle(penStyle);
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
const VPointF c = *initData.data->GeometricObject<VPointF>(initData.center);
|
||||
VArc *arc = new VArc(c, calcRadius, initData.radius, calcF1, initData.f1, calcF2, initData.f2 );
|
||||
arc->SetColor(initData.color);
|
||||
arc->SetPenStyle(initData.penStyle);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(arc);
|
||||
data->AddArc(data->GeometricObject<VArc>(id), id);
|
||||
initData.id = initData.data->AddGObject(arc);
|
||||
initData.data->AddArc(initData.data->GeometricObject<VArc>(initData.id), initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, arc);
|
||||
data->AddArc(data->GeometricObject<VArc>(id), id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, arc);
|
||||
initData.data->AddArc(initData.data->GeometricObject<VArc>(initData.id), initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::Arc, doc);
|
||||
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
|
||||
scene->addItem(toolArc);
|
||||
InitArcToolConnections(scene, toolArc);
|
||||
VAbstractPattern::AddTool(id, toolArc);
|
||||
doc->IncrementReferens(c.getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::Arc, initData.doc);
|
||||
VToolArc *toolArc = new VToolArc(initData);
|
||||
initData.scene->addItem(toolArc);
|
||||
InitArcToolConnections(initData.scene, toolArc);
|
||||
VAbstractPattern::AddTool(initData.id, toolArc);
|
||||
initData.doc->IncrementReferens(c.getIdTool());
|
||||
return toolArc;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -198,7 +189,7 @@ QString VToolArc::CenterPointName() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolArc::getCenter() const
|
||||
{
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
return arc->GetCenter().id();
|
||||
|
@ -209,7 +200,7 @@ void VToolArc::setCenter(const quint32 &value)
|
|||
{
|
||||
if (value != NULL_ID)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
|
||||
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(value);
|
||||
|
@ -221,12 +212,12 @@ void VToolArc::setCenter(const quint32 &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolArc::GetFormulaRadius() const
|
||||
{
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
VFormula radius(arc->GetFormulaRadius(), getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(id);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
return radius;
|
||||
}
|
||||
|
@ -238,7 +229,7 @@ void VToolArc::SetFormulaRadius(const VFormula &value)
|
|||
{
|
||||
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
arc->SetFormulaRadius(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
|
@ -249,12 +240,12 @@ void VToolArc::SetFormulaRadius(const VFormula &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolArc::GetFormulaF1() const
|
||||
{
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
VFormula f1(arc->GetFormulaF1(), getData());
|
||||
f1.setCheckZero(false);
|
||||
f1.setToolId(id);
|
||||
f1.setToolId(m_id);
|
||||
f1.setPostfix(degreeSymbol);
|
||||
return f1;
|
||||
}
|
||||
|
@ -264,7 +255,7 @@ void VToolArc::SetFormulaF1(const VFormula &value)
|
|||
{
|
||||
if (value.error() == false)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
|
||||
if (not VFuzzyComparePossibleNulls(value.getDoubleValue(), arc->GetEndAngle()))// Angles can't be equal
|
||||
|
@ -278,12 +269,12 @@ void VToolArc::SetFormulaF1(const VFormula &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolArc::GetFormulaF2() const
|
||||
{
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
VFormula f2(arc->GetFormulaF2(), getData());
|
||||
f2.setCheckZero(false);
|
||||
f2.setToolId(id);
|
||||
f2.setToolId(m_id);
|
||||
f2.setPostfix(degreeSymbol);
|
||||
return f2;
|
||||
}
|
||||
|
@ -293,7 +284,7 @@ void VToolArc::SetFormulaF2(const VFormula &value)
|
|||
{
|
||||
if (value.error() == false)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
if (not VFuzzyComparePossibleNulls(value.getDoubleValue(), arc->GetStartAngle()))// Angles can't be equal
|
||||
{
|
||||
|
@ -310,15 +301,12 @@ void VToolArc::ShowVisualization(bool show)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolArc::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogArc>(this, event);
|
||||
ContextMenu<DialogArc>(event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
@ -333,7 +321,7 @@ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
*/
|
||||
void VToolArc::RemoveReferens()
|
||||
{
|
||||
const auto arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
const auto arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
doc->DecrementReferens(arc->GetCenter().getIdTool());
|
||||
}
|
||||
|
||||
|
@ -374,7 +362,7 @@ void VToolArc::SetVisualization()
|
|||
{
|
||||
if (not vis.isNull())
|
||||
{
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
VisToolArc *visual = qobject_cast<VisToolArc *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
|
@ -391,9 +379,10 @@ void VToolArc::SetVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolArc::MakeToolTip() const
|
||||
{
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%10:</b> %11</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7°</td> </tr>"
|
||||
|
@ -407,6 +396,8 @@ QString VToolArc::MakeToolTip() const
|
|||
.arg(tr("Start angle"))
|
||||
.arg(qApp->fromPixel(arc->GetStartAngle()))
|
||||
.arg(tr("End angle"))
|
||||
.arg(qApp->fromPixel(arc->GetEndAngle()));
|
||||
.arg(qApp->fromPixel(arc->GetEndAngle()))
|
||||
.arg(tr("Label"))
|
||||
.arg(arc->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,22 @@
|
|||
class VFormula;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolArcInitData : public VAbstractSplineInitData
|
||||
{
|
||||
VToolArcInitData()
|
||||
: VAbstractSplineInitData(),
|
||||
center(NULL_ID),
|
||||
radius("0"),
|
||||
f1("0"),
|
||||
f2("0")
|
||||
{}
|
||||
|
||||
quint32 center;
|
||||
QString radius;
|
||||
QString f1;
|
||||
QString f2;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolArc class tool for creation arc.
|
||||
*/
|
||||
|
@ -53,9 +69,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolArc* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolArc* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2,
|
||||
const QString &color, const QString &penStyle, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation);
|
||||
static VToolArc* Create(VToolArcInitData &initData);
|
||||
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
@ -77,8 +91,9 @@ public:
|
|||
void SetFormulaF2(const VFormula &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -87,8 +102,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolArc)
|
||||
|
||||
VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
VToolArc(const VToolArcInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLARC_H
|
||||
|
|
|
@ -59,15 +59,14 @@
|
|||
const QString VToolArcWithLength::ToolType = QStringLiteral("arcWithLength");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolArcWithLength::VToolArcWithLength(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VAbstractSpline(doc, data, id, parent)
|
||||
VToolArcWithLength::VToolArcWithLength(const VToolArcWithLengthInitData &initData, QGraphicsItem *parent)
|
||||
:VAbstractSpline(initData.doc, initData.data, initData.id, parent)
|
||||
{
|
||||
sceneType = SceneObject::Arc;
|
||||
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -76,7 +75,7 @@ void VToolArcWithLength::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogArcWithLength> dialogTool = m_dialog.objectCast<DialogArcWithLength>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
dialogTool->SetCenter(arc->GetCenter().id());
|
||||
dialogTool->SetF1(arc->GetFormulaF1());
|
||||
dialogTool->SetLength(arc->GetFormulaLength());
|
||||
|
@ -92,14 +91,21 @@ VToolArcWithLength *VToolArcWithLength::Create(QSharedPointer<DialogTool> dialog
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogArcWithLength> dialogTool = dialog.objectCast<DialogArcWithLength>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 center = dialogTool->GetCenter();
|
||||
QString radius = dialogTool->GetRadius();
|
||||
QString f1 = dialogTool->GetF1();
|
||||
QString length = dialogTool->GetLength();
|
||||
const QString color = dialogTool->GetColor();
|
||||
const QString penStyle = dialogTool->GetPenStyle();
|
||||
VToolArcWithLength* point = Create(0, center, radius, f1, length, color, penStyle, scene, doc, data,
|
||||
Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolArcWithLengthInitData initData;
|
||||
initData.center = dialogTool->GetCenter();
|
||||
initData.radius = dialogTool->GetRadius();
|
||||
initData.f1 = dialogTool->GetF1();
|
||||
initData.length = dialogTool->GetLength();
|
||||
initData.color = dialogTool->GetColor();
|
||||
initData.penStyle = dialogTool->GetPenStyle();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolArcWithLength* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -108,45 +114,42 @@ VToolArcWithLength *VToolArcWithLength::Create(QSharedPointer<DialogTool> dialog
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1,
|
||||
QString &length, const QString &color, const QString &penStyle,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolArcWithLength *VToolArcWithLength::Create(VToolArcWithLengthInitData &initData)
|
||||
{
|
||||
qreal calcRadius = 0, calcF1 = 0, calcLength = 0;
|
||||
|
||||
calcRadius = qApp->toPixel(CheckFormula(_id, radius, data));
|
||||
calcLength = qApp->toPixel(CheckFormula(_id, length, data));
|
||||
calcF1 = CheckFormula(_id, f1, data);
|
||||
calcRadius = qApp->toPixel(CheckFormula(initData.id, initData.radius, initData.data));
|
||||
calcLength = qApp->toPixel(CheckFormula(initData.id, initData.length, initData.data));
|
||||
calcF1 = CheckFormula(initData.id, initData.f1, initData.data);
|
||||
|
||||
const VPointF c = *data->GeometricObject<VPointF>(center);
|
||||
VArc *arc = new VArc(calcLength, length, c, calcRadius, radius, calcF1, f1);
|
||||
arc->SetColor(color);
|
||||
arc->SetPenStyle(penStyle);
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
const VPointF c = *initData.data->GeometricObject<VPointF>(initData.center);
|
||||
VArc *arc = new VArc(calcLength, initData.length, c, calcRadius, initData.radius, calcF1, initData.f1);
|
||||
arc->SetColor(initData.color);
|
||||
arc->SetPenStyle(initData.penStyle);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(arc);
|
||||
data->AddArc(data->GeometricObject<VArc>(id), id);
|
||||
initData.id = initData.data->AddGObject(arc);
|
||||
initData.data->AddArc(initData.data->GeometricObject<VArc>(initData.id), initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, arc);
|
||||
data->AddArc(data->GeometricObject<VArc>(id), id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, arc);
|
||||
initData.data->AddArc(initData.data->GeometricObject<VArc>(initData.id), initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::ArcWithLength, doc);
|
||||
VToolArcWithLength *toolArc = new VToolArcWithLength(doc, data, id, typeCreation);
|
||||
scene->addItem(toolArc);
|
||||
InitArcToolConnections(scene, toolArc);
|
||||
VAbstractPattern::AddTool(id, toolArc);
|
||||
doc->IncrementReferens(c.getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::ArcWithLength, initData.doc);
|
||||
VToolArcWithLength *toolArc = new VToolArcWithLength(initData);
|
||||
initData.scene->addItem(toolArc);
|
||||
InitArcToolConnections(initData.scene, toolArc);
|
||||
VAbstractPattern::AddTool(initData.id, toolArc);
|
||||
initData.doc->IncrementReferens(c.getIdTool());
|
||||
return toolArc;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -167,7 +170,7 @@ QString VToolArcWithLength::CenterPointName() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolArcWithLength::getCenter() const
|
||||
{
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
return arc->GetCenter().id();
|
||||
|
@ -178,7 +181,7 @@ void VToolArcWithLength::setCenter(const quint32 &value)
|
|||
{
|
||||
if (value != NULL_ID)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
|
||||
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(value);
|
||||
|
@ -190,12 +193,12 @@ void VToolArcWithLength::setCenter(const quint32 &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolArcWithLength::GetFormulaRadius() const
|
||||
{
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
VFormula radius(arc->GetFormulaRadius(), getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(id);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
return radius;
|
||||
}
|
||||
|
@ -207,7 +210,7 @@ void VToolArcWithLength::SetFormulaRadius(const VFormula &value)
|
|||
{
|
||||
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
arc->SetFormulaRadius(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
|
@ -218,12 +221,12 @@ void VToolArcWithLength::SetFormulaRadius(const VFormula &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolArcWithLength::GetFormulaF1() const
|
||||
{
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
VFormula f1(arc->GetFormulaF1(), getData());
|
||||
f1.setCheckZero(false);
|
||||
f1.setToolId(id);
|
||||
f1.setToolId(m_id);
|
||||
f1.setPostfix(degreeSymbol);
|
||||
return f1;
|
||||
}
|
||||
|
@ -233,7 +236,7 @@ void VToolArcWithLength::SetFormulaF1(const VFormula &value)
|
|||
{
|
||||
if (value.error() == false)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
|
||||
if (not VFuzzyComparePossibleNulls(value.getDoubleValue(), arc->GetEndAngle()))// Angles can't be equal
|
||||
|
@ -247,12 +250,12 @@ void VToolArcWithLength::SetFormulaF1(const VFormula &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolArcWithLength::GetFormulaLength() const
|
||||
{
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
SCASSERT(arc.isNull() == false)
|
||||
|
||||
VFormula radius(arc->GetFormulaLength(), getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(id);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
return radius;
|
||||
}
|
||||
|
@ -262,7 +265,7 @@ void VToolArcWithLength::SetFormulaLength(const VFormula &value)
|
|||
{
|
||||
if (value.error() == false)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
|
||||
arc->SetFormulaLength(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
|
@ -276,11 +279,12 @@ void VToolArcWithLength::ShowVisualization(bool show)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolArcWithLength::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolArcWithLength::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogArcWithLength>(this, event);
|
||||
ContextMenu<DialogArcWithLength>(event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
@ -292,7 +296,7 @@ void VToolArcWithLength::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolArcWithLength::RemoveReferens()
|
||||
{
|
||||
const auto arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
const auto arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
doc->DecrementReferens(arc->GetCenter().getIdTool());
|
||||
}
|
||||
|
||||
|
@ -330,7 +334,7 @@ void VToolArcWithLength::SetVisualization()
|
|||
{
|
||||
if (not vis.isNull())
|
||||
{
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
VisToolArcWithLength *visual = qobject_cast<VisToolArcWithLength *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
|
@ -347,9 +351,10 @@ void VToolArcWithLength::SetVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolArcWithLength::MakeToolTip() const
|
||||
{
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%10:</b> %11</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7°</td> </tr>"
|
||||
|
@ -363,6 +368,8 @@ QString VToolArcWithLength::MakeToolTip() const
|
|||
.arg(tr("Start angle"))
|
||||
.arg(qApp->fromPixel(arc->GetStartAngle()))
|
||||
.arg(tr("End angle"))
|
||||
.arg(qApp->fromPixel(arc->GetEndAngle()));
|
||||
.arg(qApp->fromPixel(arc->GetEndAngle()))
|
||||
.arg(tr("Label"))
|
||||
.arg(arc->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,22 @@
|
|||
class VFormula;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolArcWithLengthInitData : public VAbstractSplineInitData
|
||||
{
|
||||
VToolArcWithLengthInitData()
|
||||
: VAbstractSplineInitData(),
|
||||
center(NULL_ID),
|
||||
radius("0"),
|
||||
f1("0"),
|
||||
length("0")
|
||||
{}
|
||||
|
||||
quint32 center;
|
||||
QString radius;
|
||||
QString f1;
|
||||
QString length;
|
||||
};
|
||||
|
||||
class VToolArcWithLength : public VAbstractSpline
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -50,10 +66,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolArcWithLength* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolArcWithLength* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1,
|
||||
QString &length, const QString &color, const QString &penStyle,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolArcWithLength* Create(VToolArcWithLengthInitData &initData);
|
||||
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
@ -75,8 +88,9 @@ public:
|
|||
void SetFormulaLength(const VFormula &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -85,8 +99,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolArcWithLength)
|
||||
|
||||
VToolArcWithLength(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
VToolArcWithLength(const VToolArcWithLengthInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLARCWITHLENGTH_H
|
||||
|
|
|
@ -57,15 +57,14 @@
|
|||
const QString VToolCubicBezier::ToolType = QStringLiteral("cubicBezier");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolCubicBezier::VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quint32 id,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VAbstractSpline(doc, data, id, parent)
|
||||
VToolCubicBezier::VToolCubicBezier(const VToolCubicBezierInitData &initData, QGraphicsItem *parent)
|
||||
:VAbstractSpline(initData.doc, initData.data, initData.id, parent)
|
||||
{
|
||||
sceneType = SceneObject::Spline;
|
||||
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -74,7 +73,7 @@ void VToolCubicBezier::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
auto dialogTool = qobject_cast<DialogCubicBezier*>(m_dialog);
|
||||
SCASSERT(dialogTool != nullptr)
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VCubicBezier>(m_id);
|
||||
dialogTool->SetSpline(*spl);
|
||||
dialogTool->SetColor(spl->GetColor());
|
||||
dialogTool->SetPenStyle(spl->GetPenStyle());
|
||||
|
@ -88,11 +87,17 @@ VToolCubicBezier *VToolCubicBezier::Create(QSharedPointer<DialogTool> dialog, VM
|
|||
QSharedPointer<DialogCubicBezier> dialogTool = dialog.objectCast<DialogCubicBezier>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
VCubicBezier *spline = new VCubicBezier(dialogTool->GetSpline());
|
||||
spline->SetColor(dialogTool->GetColor());
|
||||
spline->SetPenStyle(dialogTool->GetPenStyle());
|
||||
VToolCubicBezierInitData initData;
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
initData.spline = new VCubicBezier(dialogTool->GetSpline());
|
||||
initData.spline->SetColor(dialogTool->GetColor());
|
||||
initData.spline->SetPenStyle(dialogTool->GetPenStyle());
|
||||
|
||||
auto spl = Create(0, spline, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
auto spl = Create(initData);
|
||||
|
||||
if (spl != nullptr)
|
||||
{
|
||||
|
@ -102,37 +107,34 @@ VToolCubicBezier *VToolCubicBezier::Create(QSharedPointer<DialogTool> dialog, VM
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolCubicBezier *VToolCubicBezier::Create(const quint32 _id, VCubicBezier *spline, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolCubicBezier *VToolCubicBezier::Create(VToolCubicBezierInitData initData)
|
||||
{
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(spline);
|
||||
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
|
||||
initData.id = initData.data->AddGObject(initData.spline);
|
||||
initData.data->AddSpline(initData.data->GeometricObject<VAbstractBezier>(initData.id), initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, spline);
|
||||
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, initData.spline);
|
||||
initData.data->AddSpline(initData.data->GeometricObject<VAbstractBezier>(initData.id), initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::CubicBezier, doc);
|
||||
auto _spl = new VToolCubicBezier(doc, data, id, typeCreation);
|
||||
scene->addItem(_spl);
|
||||
InitSplineToolConnections(scene, _spl);
|
||||
VAbstractPattern::AddTool(id, _spl);
|
||||
doc->IncrementReferens(spline->GetP1().getIdTool());
|
||||
doc->IncrementReferens(spline->GetP1().getIdTool());
|
||||
doc->IncrementReferens(spline->GetP1().getIdTool());
|
||||
doc->IncrementReferens(spline->GetP4().getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::CubicBezier, initData.doc);
|
||||
auto _spl = new VToolCubicBezier(initData);
|
||||
initData.scene->addItem(_spl);
|
||||
InitSplineToolConnections(initData.scene, _spl);
|
||||
VAbstractPattern::AddTool(initData.id, _spl);
|
||||
initData.doc->IncrementReferens(initData.spline->GetP1().getIdTool());
|
||||
initData.doc->IncrementReferens(initData.spline->GetP1().getIdTool());
|
||||
initData.doc->IncrementReferens(initData.spline->GetP1().getIdTool());
|
||||
initData.doc->IncrementReferens(initData.spline->GetP4().getIdTool());
|
||||
return _spl;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -141,42 +143,42 @@ VToolCubicBezier *VToolCubicBezier::Create(const quint32 _id, VCubicBezier *spli
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCubicBezier::FirstPointName() const
|
||||
{
|
||||
auto spline = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
|
||||
auto spline = VAbstractTool::data.GeometricObject<VCubicBezier>(m_id);
|
||||
return spline->GetP1().name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCubicBezier::SecondPointName() const
|
||||
{
|
||||
auto spline = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
|
||||
auto spline = VAbstractTool::data.GeometricObject<VCubicBezier>(m_id);
|
||||
return spline->GetP2().name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCubicBezier::ThirdPointName() const
|
||||
{
|
||||
auto spline = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
|
||||
auto spline = VAbstractTool::data.GeometricObject<VCubicBezier>(m_id);
|
||||
return spline->GetP3().name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCubicBezier::ForthPointName() const
|
||||
{
|
||||
auto spline = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
|
||||
auto spline = VAbstractTool::data.GeometricObject<VCubicBezier>(m_id);
|
||||
return spline->GetP4().name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCubicBezier VToolCubicBezier::getSpline() const
|
||||
{
|
||||
auto spline = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
|
||||
auto spline = VAbstractTool::data.GeometricObject<VCubicBezier>(m_id);
|
||||
return *spline.data();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCubicBezier::setSpline(const VCubicBezier &spl)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VCubicBezier> spline = qSharedPointerDynamicCast<VCubicBezier>(obj);
|
||||
*spline.data() = spl;
|
||||
SaveOption(obj);
|
||||
|
@ -189,11 +191,12 @@ void VToolCubicBezier::ShowVisualization(bool show)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCubicBezier::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolCubicBezier::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogCubicBezier>(this, event);
|
||||
ContextMenu<DialogCubicBezier>(event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
@ -205,7 +208,7 @@ void VToolCubicBezier::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCubicBezier::RemoveReferens()
|
||||
{
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VCubicBezier>(m_id);
|
||||
doc->DecrementReferens(spl->GetP1().getIdTool());
|
||||
doc->DecrementReferens(spl->GetP2().getIdTool());
|
||||
doc->DecrementReferens(spl->GetP3().getIdTool());
|
||||
|
@ -244,7 +247,7 @@ void VToolCubicBezier::SetVisualization()
|
|||
auto visual = qobject_cast<VisToolCubicBezier *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
const QSharedPointer<VCubicBezier> spl = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
|
||||
const QSharedPointer<VCubicBezier> spl = VAbstractTool::data.GeometricObject<VCubicBezier>(m_id);
|
||||
visual->setObject1Id(spl->GetP1().id());
|
||||
visual->setObject2Id(spl->GetP2().id());
|
||||
visual->setObject3Id(spl->GetP3().id());
|
||||
|
@ -258,7 +261,7 @@ void VToolCubicBezier::SetVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCubicBezier::RefreshGeometry()
|
||||
{
|
||||
const QSharedPointer<VCubicBezier> spl = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
|
||||
const QSharedPointer<VCubicBezier> spl = VAbstractTool::data.GeometricObject<VCubicBezier>(m_id);
|
||||
this->setPath(spl->GetPath());
|
||||
|
||||
SetVisualization();
|
||||
|
|
|
@ -43,6 +43,16 @@
|
|||
class VCubicBezier;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolCubicBezierInitData : public VAbstractToolInitData
|
||||
{
|
||||
VToolCubicBezierInitData()
|
||||
: VAbstractToolInitData(),
|
||||
spline(nullptr)
|
||||
{}
|
||||
|
||||
VCubicBezier *spline;
|
||||
};
|
||||
|
||||
class VToolCubicBezier : public VAbstractSpline
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -51,9 +61,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolCubicBezier *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolCubicBezier *Create(const quint32 _id, VCubicBezier *spline, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolCubicBezier *Create(VToolCubicBezierInitData initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::CubicBezier)};
|
||||
|
@ -67,8 +75,9 @@ public:
|
|||
void setSpline(const VCubicBezier &spl);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -77,8 +86,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolCubicBezier)
|
||||
|
||||
VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
VToolCubicBezier(const VToolCubicBezierInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
|
||||
void SetSplineAttributes(QDomElement &domElement, const VCubicBezier &spl);
|
||||
};
|
||||
|
|
|
@ -59,15 +59,14 @@
|
|||
const QString VToolCubicBezierPath::ToolType = QStringLiteral("cubicBezierPath");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolCubicBezierPath::VToolCubicBezierPath(VAbstractPattern *doc, VContainer *data, quint32 id,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
: VAbstractSpline(doc, data, id, parent)
|
||||
VToolCubicBezierPath::VToolCubicBezierPath(const VToolCubicBezierPathInitData &initData, QGraphicsItem *parent)
|
||||
: VAbstractSpline(initData.doc, initData.data, initData.id, parent)
|
||||
{
|
||||
sceneType = SceneObject::SplinePath;
|
||||
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -76,7 +75,7 @@ void VToolCubicBezierPath::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
auto dialogTool = qobject_cast<DialogCubicBezierPath*>(m_dialog);
|
||||
SCASSERT(dialogTool != nullptr)
|
||||
const QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(id);
|
||||
const QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(m_id);
|
||||
dialogTool->SetPath(*splPath);
|
||||
dialogTool->SetColor(splPath->GetColor());
|
||||
dialogTool->SetPenStyle(splPath->GetPenStyle());
|
||||
|
@ -89,17 +88,25 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(QSharedPointer<DialogTool> di
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogCubicBezierPath> dialogTool = dialog.objectCast<DialogCubicBezierPath>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
auto path = new VCubicBezierPath(dialogTool->GetPath());
|
||||
|
||||
VToolCubicBezierPathInitData initData;
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
initData.path = new VCubicBezierPath(dialogTool->GetPath());
|
||||
const QString color = dialogTool->GetColor();
|
||||
const QString penStyle = dialogTool->GetPenStyle();
|
||||
for (qint32 i = 0; i < path->CountPoints(); ++i)
|
||||
for (qint32 i = 0; i < initData.path->CountPoints(); ++i)
|
||||
{
|
||||
doc->IncrementReferens((*path)[i].getIdTool());
|
||||
doc->IncrementReferens((*initData.path)[i].getIdTool());
|
||||
}
|
||||
path->SetColor(color);
|
||||
path->SetPenStyle(penStyle);
|
||||
initData.path->SetColor(color);
|
||||
initData.path->SetPenStyle(penStyle);
|
||||
|
||||
VToolCubicBezierPath* spl = Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
VToolCubicBezierPath* spl = Create(initData);
|
||||
if (spl != nullptr)
|
||||
{
|
||||
spl->m_dialog = dialogTool;
|
||||
|
@ -108,33 +115,32 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(QSharedPointer<DialogTool> di
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolCubicBezierPath *VToolCubicBezierPath::Create(const quint32 _id, VCubicBezierPath *path, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolCubicBezierPath *VToolCubicBezierPath::Create(VToolCubicBezierPathInitData initData)
|
||||
{
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(path);
|
||||
data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
|
||||
initData.id = initData.data->AddGObject(initData.path);
|
||||
initData.data->AddCurveWithSegments(initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.id),
|
||||
initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, path);
|
||||
data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, initData.path);
|
||||
initData.data->AddCurveWithSegments(initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.id),
|
||||
initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::CubicBezierPath, doc);
|
||||
VToolCubicBezierPath *spl = new VToolCubicBezierPath(doc, data, id, typeCreation);
|
||||
scene->addItem(spl);
|
||||
InitSplinePathToolConnections(scene, spl);
|
||||
VAbstractPattern::AddTool(id, spl);
|
||||
VAbstractTool::AddRecord(initData.id, Tool::CubicBezierPath, initData.doc);
|
||||
VToolCubicBezierPath *spl = new VToolCubicBezierPath(initData);
|
||||
initData.scene->addItem(spl);
|
||||
InitSplinePathToolConnections(initData.scene, spl);
|
||||
VAbstractPattern::AddTool(initData.id, spl);
|
||||
return spl;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -153,14 +159,14 @@ void VToolCubicBezierPath::UpdatePathPoints(VAbstractPattern *doc, QDomElement &
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCubicBezierPath VToolCubicBezierPath::getSplinePath() const
|
||||
{
|
||||
QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(id);
|
||||
QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(m_id);
|
||||
return *splPath.data();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCubicBezierPath::setSplinePath(const VCubicBezierPath &splPath)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VCubicBezierPath> splinePath = qSharedPointerDynamicCast<VCubicBezierPath>(obj);
|
||||
*splinePath.data() = splPath;
|
||||
SaveOption(obj);
|
||||
|
@ -173,11 +179,12 @@ void VToolCubicBezierPath::ShowVisualization(bool show)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCubicBezierPath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolCubicBezierPath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogCubicBezierPath>(this, event);
|
||||
ContextMenu<DialogCubicBezierPath>(event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
@ -189,7 +196,7 @@ void VToolCubicBezierPath::contextMenuEvent(QGraphicsSceneContextMenuEvent *even
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCubicBezierPath::RemoveReferens()
|
||||
{
|
||||
const QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(id);
|
||||
const QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(m_id);
|
||||
for (qint32 i = 0; i < splPath->CountSubSpl(); ++i)
|
||||
{
|
||||
doc->DecrementReferens(splPath->at(i).getIdTool());
|
||||
|
@ -227,7 +234,7 @@ void VToolCubicBezierPath::SetVisualization()
|
|||
auto visual = qobject_cast<VisToolCubicBezierPath *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(id);
|
||||
QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(m_id);
|
||||
visual->setPath(*splPath.data());
|
||||
visual->setLineStyle(LineStyleToPenStyle(splPath->GetPenStyle()));
|
||||
visual->SetMode(Mode::Show);
|
||||
|
@ -238,7 +245,7 @@ void VToolCubicBezierPath::SetVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCubicBezierPath::RefreshGeometry()
|
||||
{
|
||||
QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(id);
|
||||
QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(m_id);
|
||||
setPath(splPath->GetPath());
|
||||
|
||||
SetVisualization();
|
||||
|
|
|
@ -43,6 +43,16 @@
|
|||
class VCubicBezierPath;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolCubicBezierPathInitData : public VAbstractToolInitData
|
||||
{
|
||||
VToolCubicBezierPathInitData()
|
||||
: VAbstractToolInitData(),
|
||||
path(nullptr)
|
||||
{}
|
||||
|
||||
VCubicBezierPath *path;
|
||||
};
|
||||
|
||||
class VToolCubicBezierPath:public VAbstractSpline
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -51,9 +61,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolCubicBezierPath *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolCubicBezierPath *Create(const quint32 _id, VCubicBezierPath *path, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolCubicBezierPath *Create(VToolCubicBezierPathInitData initData);
|
||||
|
||||
static const QString ToolType;
|
||||
static void UpdatePathPoints(VAbstractPattern *doc, QDomElement &element, const VCubicBezierPath &path);
|
||||
|
@ -64,8 +72,9 @@ public:
|
|||
void setSplinePath(const VCubicBezierPath &splPath);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -74,8 +83,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolCubicBezierPath)
|
||||
|
||||
VToolCubicBezierPath(VAbstractPattern *doc, VContainer *data, quint32 id,
|
||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolCubicBezierPath(const VToolCubicBezierPathInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
|
||||
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VPointF &splPoint);
|
||||
void SetSplinePathAttributes(QDomElement &domElement, const VCubicBezierPath &path);
|
||||
|
|
|
@ -61,21 +61,17 @@ const QString VToolEllipticalArc::ToolType = QStringLiteral("simple");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolEllipticalArc constuctor.
|
||||
* @param doc dom document container
|
||||
* @param data container with variables
|
||||
* @param id object id in container
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data
|
||||
* @param parent parent object
|
||||
*/
|
||||
VToolEllipticalArc::VToolEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VAbstractSpline(doc, data, id, parent)
|
||||
VToolEllipticalArc::VToolEllipticalArc(const VToolEllipticalArcInitData &initData, QGraphicsItem *parent)
|
||||
:VAbstractSpline(initData.doc, initData.data, initData.id, parent)
|
||||
{
|
||||
sceneType = SceneObject::ElArc;
|
||||
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -87,7 +83,7 @@ void VToolEllipticalArc::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogEllipticalArc> dialogTool = m_dialog.objectCast<DialogEllipticalArc>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
|
||||
const QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
|
||||
dialogTool->SetCenter(elArc->GetCenter().id());
|
||||
dialogTool->SetF1(elArc->GetFormulaF1());
|
||||
dialogTool->SetF2(elArc->GetFormulaF2());
|
||||
|
@ -113,16 +109,22 @@ VToolEllipticalArc* VToolEllipticalArc::Create(QSharedPointer<DialogTool> dialog
|
|||
QSharedPointer<DialogEllipticalArc> dialogTool = dialog.objectCast<DialogEllipticalArc>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
const quint32 center = dialogTool->GetCenter();
|
||||
QString radius1 = dialogTool->GetRadius1();
|
||||
QString radius2 = dialogTool->GetRadius2();
|
||||
QString f1 = dialogTool->GetF1();
|
||||
QString f2 = dialogTool->GetF2();
|
||||
QString rotationAngle = dialogTool->GetRotationAngle();
|
||||
const QString color = dialogTool->GetColor();
|
||||
const QString penStyle = dialogTool->GetPenStyle();
|
||||
VToolEllipticalArc* point = Create(0, center, radius1, radius2, f1, f2, rotationAngle, color, penStyle, scene, doc,
|
||||
data, Document::FullParse, Source::FromGui);
|
||||
VToolEllipticalArcInitData initData;
|
||||
initData.center = dialogTool->GetCenter();
|
||||
initData.radius1 = dialogTool->GetRadius1();
|
||||
initData.radius2 = dialogTool->GetRadius2();
|
||||
initData.f1 = dialogTool->GetF1();
|
||||
initData.f2 = dialogTool->GetF2();
|
||||
initData.rotationAngle = dialogTool->GetRotationAngle();
|
||||
initData.color = dialogTool->GetColor();
|
||||
initData.penStyle = dialogTool->GetPenStyle();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolEllipticalArc* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -134,63 +136,49 @@ VToolEllipticalArc* VToolEllipticalArc::Create(QSharedPointer<DialogTool> dialog
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool form GUI.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param center id elliptical arc center point.
|
||||
* @param radius1 elliptical arc radius1.
|
||||
* @param radius2 elliptical arc radius2.
|
||||
* @param f1 start angle of elliptical arc.
|
||||
* @param f2 end angle of elliptical arc.
|
||||
* @param rotationAngle rotation angle of elliptical arc.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolEllipticalArc* VToolEllipticalArc::Create(const quint32 _id, const quint32 ¢er, QString &radius1,
|
||||
QString &radius2, QString &f1, QString &f2, QString &rotationAngle,
|
||||
const QString &color, const QString &penStyle, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolEllipticalArc* VToolEllipticalArc::Create(VToolEllipticalArcInitData &initData)
|
||||
{
|
||||
qreal calcRadius1 = 0, calcRadius2 = 0, calcF1 = 0, calcF2 = 0, calcRotationAngle = 0;
|
||||
|
||||
calcRadius1 = qApp->toPixel(CheckFormula(_id, radius1, data));
|
||||
calcRadius2 = qApp->toPixel(CheckFormula(_id, radius2, data));
|
||||
calcRadius1 = qApp->toPixel(CheckFormula(initData.id, initData.radius1, initData.data));
|
||||
calcRadius2 = qApp->toPixel(CheckFormula(initData.id, initData.radius2, initData.data));
|
||||
|
||||
calcF1 = CheckFormula(_id, f1, data);
|
||||
calcF2 = CheckFormula(_id, f2, data);
|
||||
calcRotationAngle = CheckFormula(_id, rotationAngle, data);
|
||||
calcF1 = CheckFormula(initData.id, initData.f1, initData.data);
|
||||
calcF2 = CheckFormula(initData.id, initData.f2, initData.data);
|
||||
calcRotationAngle = CheckFormula(initData.id, initData.rotationAngle, initData.data);
|
||||
|
||||
const VPointF c = *data->GeometricObject<VPointF>(center);
|
||||
VEllipticalArc *elArc = new VEllipticalArc(c, calcRadius1, calcRadius2, radius1, radius2, calcF1, f1, calcF2, f2,
|
||||
calcRotationAngle, rotationAngle);
|
||||
elArc->SetColor(color);
|
||||
elArc->SetPenStyle(penStyle);
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
const VPointF c = *initData.data->GeometricObject<VPointF>(initData.center);
|
||||
VEllipticalArc *elArc = new VEllipticalArc(c, calcRadius1, calcRadius2, initData.radius1, initData.radius2, calcF1,
|
||||
initData.f1, calcF2, initData.f2, calcRotationAngle,
|
||||
initData.rotationAngle);
|
||||
elArc->SetColor(initData.color);
|
||||
elArc->SetPenStyle(initData.penStyle);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(elArc);
|
||||
data->AddArc(data->GeometricObject<VEllipticalArc>(id), id);
|
||||
initData.id = initData.data->AddGObject(elArc);
|
||||
initData.data->AddArc(initData.data->GeometricObject<VEllipticalArc>(initData.id), initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, elArc);
|
||||
data->AddArc(data->GeometricObject<VEllipticalArc>(id), id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, elArc);
|
||||
initData.data->AddArc(initData.data->GeometricObject<VEllipticalArc>(initData.id), initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::EllipticalArc, doc);
|
||||
VToolEllipticalArc *toolEllipticalArc = new VToolEllipticalArc(doc, data, id, typeCreation);
|
||||
scene->addItem(toolEllipticalArc);
|
||||
InitElArcToolConnections(scene, toolEllipticalArc);
|
||||
VAbstractPattern::AddTool(id, toolEllipticalArc);
|
||||
doc->IncrementReferens(c.getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::EllipticalArc, initData.doc);
|
||||
VToolEllipticalArc *toolEllipticalArc = new VToolEllipticalArc(initData);
|
||||
initData.scene->addItem(toolEllipticalArc);
|
||||
InitElArcToolConnections(initData.scene, toolEllipticalArc);
|
||||
VAbstractPattern::AddTool(initData.id, toolEllipticalArc);
|
||||
initData.doc->IncrementReferens(c.getIdTool());
|
||||
return toolEllipticalArc;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -211,7 +199,7 @@ QString VToolEllipticalArc::CenterPointName() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolEllipticalArc::getCenter() const
|
||||
{
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
|
||||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
return elArc->GetCenter().id();
|
||||
|
@ -222,7 +210,7 @@ void VToolEllipticalArc::setCenter(const quint32 &value)
|
|||
{
|
||||
if (value != NULL_ID)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
|
||||
|
||||
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(value);
|
||||
|
@ -234,12 +222,12 @@ void VToolEllipticalArc::setCenter(const quint32 &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolEllipticalArc::GetFormulaRadius1() const
|
||||
{
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
|
||||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
VFormula radius1(elArc->GetFormulaRadius1(), getData());
|
||||
radius1.setCheckZero(true);
|
||||
radius1.setToolId(id);
|
||||
radius1.setToolId(m_id);
|
||||
radius1.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
return radius1;
|
||||
}
|
||||
|
@ -251,7 +239,7 @@ void VToolEllipticalArc::SetFormulaRadius1(const VFormula &value)
|
|||
{
|
||||
if (value.getDoubleValue() > 0)// Formula don't check this, but radius1 can't be 0 or negative
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
|
||||
elArc->SetFormulaRadius1(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
|
@ -262,12 +250,12 @@ void VToolEllipticalArc::SetFormulaRadius1(const VFormula &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolEllipticalArc::GetFormulaRadius2() const
|
||||
{
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
|
||||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
VFormula radius2(elArc->GetFormulaRadius2(), getData());
|
||||
radius2.setCheckZero(true);
|
||||
radius2.setToolId(id);
|
||||
radius2.setToolId(m_id);
|
||||
radius2.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
return radius2;
|
||||
}
|
||||
|
@ -279,7 +267,7 @@ void VToolEllipticalArc::SetFormulaRadius2(const VFormula &value)
|
|||
{
|
||||
if (value.getDoubleValue() > 0)// Formula don't check this, but radius2 can't be 0 or negative
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
|
||||
elArc->SetFormulaRadius2(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
|
@ -290,12 +278,12 @@ void VToolEllipticalArc::SetFormulaRadius2(const VFormula &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolEllipticalArc::GetFormulaF1() const
|
||||
{
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
|
||||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
VFormula f1(elArc->GetFormulaF1(), getData());
|
||||
f1.setCheckZero(false);
|
||||
f1.setToolId(id);
|
||||
f1.setToolId(m_id);
|
||||
f1.setPostfix(degreeSymbol);
|
||||
return f1;
|
||||
}
|
||||
|
@ -305,7 +293,7 @@ void VToolEllipticalArc::SetFormulaF1(const VFormula &value)
|
|||
{
|
||||
if (value.error() == false)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
|
||||
|
||||
if (not VFuzzyComparePossibleNulls(value.getDoubleValue(), elArc->GetEndAngle()))// Angles can't be equal
|
||||
|
@ -319,12 +307,12 @@ void VToolEllipticalArc::SetFormulaF1(const VFormula &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolEllipticalArc::GetFormulaF2() const
|
||||
{
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
|
||||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
VFormula f2(elArc->GetFormulaF2(), getData());
|
||||
f2.setCheckZero(false);
|
||||
f2.setToolId(id);
|
||||
f2.setToolId(m_id);
|
||||
f2.setPostfix(degreeSymbol);
|
||||
return f2;
|
||||
}
|
||||
|
@ -334,7 +322,7 @@ void VToolEllipticalArc::SetFormulaF2(const VFormula &value)
|
|||
{
|
||||
if (value.error() == false)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
|
||||
if (not VFuzzyComparePossibleNulls(value.getDoubleValue(), elArc->GetStartAngle()))// Angles can't be equal
|
||||
{
|
||||
|
@ -347,12 +335,12 @@ void VToolEllipticalArc::SetFormulaF2(const VFormula &value)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolEllipticalArc::GetFormulaRotationAngle() const
|
||||
{
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
|
||||
QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
|
||||
SCASSERT(elArc.isNull() == false)
|
||||
|
||||
VFormula rotationAngle(elArc->GetFormulaRotationAngle(), getData());
|
||||
rotationAngle.setCheckZero(false);
|
||||
rotationAngle.setToolId(id);
|
||||
rotationAngle.setToolId(m_id);
|
||||
rotationAngle.setPostfix(degreeSymbol);
|
||||
return rotationAngle;
|
||||
}
|
||||
|
@ -362,7 +350,7 @@ void VToolEllipticalArc::SetFormulaRotationAngle(const VFormula &value)
|
|||
{
|
||||
if (value.error() == false)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VEllipticalArc> elArc = qSharedPointerDynamicCast<VEllipticalArc>(obj);
|
||||
elArc->SetFormulaRotationAngle(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
|
||||
SaveOption(obj);
|
||||
|
@ -376,15 +364,12 @@ void VToolEllipticalArc::ShowVisualization(bool show)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolEllipticalArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolEllipticalArc::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogEllipticalArc>(this, event);
|
||||
ContextMenu<DialogEllipticalArc>(event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
@ -399,7 +384,7 @@ void VToolEllipticalArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
*/
|
||||
void VToolEllipticalArc::RemoveReferens()
|
||||
{
|
||||
const auto elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
|
||||
const auto elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
|
||||
doc->DecrementReferens(elArc->GetCenter().getIdTool());
|
||||
}
|
||||
|
||||
|
@ -444,7 +429,7 @@ void VToolEllipticalArc::SetVisualization()
|
|||
{
|
||||
if (not vis.isNull())
|
||||
{
|
||||
const QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
|
||||
const QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
|
||||
VisToolEllipticalArc *visual = qobject_cast<VisToolEllipticalArc *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
|
@ -464,9 +449,10 @@ void VToolEllipticalArc::SetVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolEllipticalArc::MakeToolTip() const
|
||||
{
|
||||
const QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
|
||||
const QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%12:</b> %13</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
|
||||
|
@ -483,6 +469,8 @@ QString VToolEllipticalArc::MakeToolTip() const
|
|||
.arg(tr("Start angle"))
|
||||
.arg(elArc->GetStartAngle())
|
||||
.arg(tr("End angle"))
|
||||
.arg(elArc->GetEndAngle());
|
||||
.arg(elArc->GetEndAngle())
|
||||
.arg(tr("Label"))
|
||||
.arg(elArc->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,26 @@
|
|||
class VFormula;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolEllipticalArcInitData : public VAbstractSplineInitData
|
||||
{
|
||||
VToolEllipticalArcInitData()
|
||||
: VAbstractSplineInitData(),
|
||||
center(NULL_ID),
|
||||
radius1("0"),
|
||||
radius2("0"),
|
||||
f1("0"),
|
||||
f2("0"),
|
||||
rotationAngle("0")
|
||||
{}
|
||||
|
||||
quint32 center;
|
||||
QString radius1;
|
||||
QString radius2;
|
||||
QString f1;
|
||||
QString f2;
|
||||
QString rotationAngle;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolEllipticalArc class tool for creation elliptical arc.
|
||||
*/
|
||||
|
@ -53,11 +73,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolEllipticalArc* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolEllipticalArc* Create(const quint32 _id, const quint32 ¢er, QString &radius1, QString &radius2,
|
||||
QString &f1, QString &f2, QString &rotationAngle, const QString &color,
|
||||
const QString &penStyle, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolEllipticalArc* Create(VToolEllipticalArcInitData &initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::EllipticalArc)};
|
||||
|
@ -84,9 +100,9 @@ public:
|
|||
void SetFormulaRotationAngle(const VFormula &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -95,8 +111,7 @@ protected:
|
|||
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolEllipticalArc)
|
||||
VToolEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
VToolEllipticalArc(const VToolEllipticalArcInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLELLIPTICALARC_H
|
||||
|
|
|
@ -74,22 +74,19 @@ const QString VToolSpline::OldToolType = QStringLiteral("simple");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolSpline constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VAbstractSpline(doc, data, id, parent), oldPosition()
|
||||
VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
|
||||
: VAbstractSpline(initData.doc, initData.data, initData.id, parent),
|
||||
oldPosition()
|
||||
{
|
||||
sceneType = SceneObject::Spline;
|
||||
|
||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(initData.id);
|
||||
|
||||
const bool freeAngle1 = qmu::QmuTokenParser::IsSingle(spl->GetStartAngleFormula());
|
||||
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl->GetC1LengthFormula());
|
||||
|
@ -119,7 +116,7 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co
|
|||
|
||||
ShowHandles(false);
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -131,7 +128,7 @@ void VToolSpline::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogSpline> dialogTool = m_dialog.objectCast<DialogSpline>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
||||
dialogTool->SetSpline(*spl);
|
||||
dialogTool->SetColor(spl->GetColor());
|
||||
dialogTool->SetPenStyle(spl->GetPenStyle());
|
||||
|
@ -153,11 +150,18 @@ VToolSpline* VToolSpline::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
|||
QSharedPointer<DialogSpline> dialogTool = dialog.objectCast<DialogSpline>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
VToolSplineInitData initData;
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VSpline *spline = new VSpline(dialogTool->GetSpline());
|
||||
spline->SetColor(dialogTool->GetColor());
|
||||
spline->SetPenStyle(dialogTool->GetPenStyle());
|
||||
|
||||
auto spl = Create(0, spline, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
auto spl = Create(initData, spline);
|
||||
|
||||
if (spl != nullptr)
|
||||
{
|
||||
|
@ -169,87 +173,77 @@ VToolSpline* VToolSpline::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param initData init data.
|
||||
* @param spline spline.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @return the created tool
|
||||
*/
|
||||
VToolSpline* VToolSpline::Create(const quint32 _id, VSpline *spline, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
||||
VToolSpline* VToolSpline::Create(VToolSplineInitData &initData, VSpline *spline)
|
||||
{
|
||||
quint32 id = _id;
|
||||
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(spline);
|
||||
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
|
||||
initData.id = initData.data->AddGObject(spline);
|
||||
initData.data->AddSpline(initData.data->GeometricObject<VAbstractBezier>(initData.id), initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, spline);
|
||||
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, spline);
|
||||
initData.data->AddSpline(initData.data->GeometricObject<VAbstractBezier>(initData.id), initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::Spline, doc);
|
||||
auto _spl = new VToolSpline(doc, data, id, typeCreation);
|
||||
scene->addItem(_spl);
|
||||
InitSplineToolConnections(scene, _spl);
|
||||
VAbstractPattern::AddTool(id, _spl);
|
||||
doc->IncrementReferens(spline->GetP1().getIdTool());
|
||||
doc->IncrementReferens(spline->GetP4().getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::Spline, initData.doc);
|
||||
auto _spl = new VToolSpline(initData);
|
||||
initData.scene->addItem(_spl);
|
||||
InitSplineToolConnections(initData.scene, _spl);
|
||||
VAbstractPattern::AddTool(initData.id, _spl);
|
||||
initData.doc->IncrementReferens(spline->GetP1().getIdTool());
|
||||
initData.doc->IncrementReferens(spline->GetP4().getIdTool());
|
||||
return _spl;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolSpline *VToolSpline::Create(const quint32 _id, quint32 point1, quint32 point4, QString &a1, QString &a2,
|
||||
QString &l1, QString &l2, quint32 duplicate, const QString &color,
|
||||
const QString &penStyle, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
||||
VToolSpline *VToolSpline::Create(VToolSplineInitData &initData)
|
||||
{
|
||||
const qreal calcAngle1 = CheckFormula(_id, a1, data);
|
||||
const qreal calcAngle2 = CheckFormula(_id, a2, data);
|
||||
const qreal calcAngle1 = CheckFormula(initData.id, initData.a1, initData.data);
|
||||
const qreal calcAngle2 = CheckFormula(initData.id, initData.a2, initData.data);
|
||||
|
||||
const qreal calcLength1 = qApp->toPixel(CheckFormula(_id, l1, data));
|
||||
const qreal calcLength2 = qApp->toPixel(CheckFormula(_id, l2, data));
|
||||
const qreal calcLength1 = qApp->toPixel(CheckFormula(initData.id, initData.l1, initData.data));
|
||||
const qreal calcLength2 = qApp->toPixel(CheckFormula(initData.id, initData.l2, initData.data));
|
||||
|
||||
auto p1 = data->GeometricObject<VPointF>(point1);
|
||||
auto p4 = data->GeometricObject<VPointF>(point4);
|
||||
auto p1 = initData.data->GeometricObject<VPointF>(initData.point1);
|
||||
auto p4 = initData.data->GeometricObject<VPointF>(initData.point4);
|
||||
|
||||
auto spline = new VSpline(*p1, *p4, calcAngle1, a1, calcAngle2, a2, calcLength1, l1, calcLength2, l2);
|
||||
if (duplicate > 0)
|
||||
auto spline = new VSpline(*p1, *p4, calcAngle1, initData.a1, calcAngle2, initData.a2, calcLength1, initData.l1,
|
||||
calcLength2, initData.l2);
|
||||
if (initData.duplicate > 0)
|
||||
{
|
||||
spline->SetDuplicate(duplicate);
|
||||
spline->SetDuplicate(initData.duplicate);
|
||||
}
|
||||
|
||||
spline->SetColor(color);
|
||||
spline->SetPenStyle(penStyle);
|
||||
spline->SetColor(initData.color);
|
||||
spline->SetPenStyle(initData.penStyle);
|
||||
|
||||
return VToolSpline::Create(_id, spline, scene, doc, data, parse, typeCreation);
|
||||
return VToolSpline::Create(initData, spline);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSpline VToolSpline::getSpline() const
|
||||
{
|
||||
auto spline = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
auto spline = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
||||
return *spline.data();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSpline::setSpline(const VSpline &spl)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VSpline> spline = qSharedPointerDynamicCast<VSpline>(obj);
|
||||
*spline.data() = spl;
|
||||
SaveOption(obj);
|
||||
|
@ -272,10 +266,10 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
|
|||
const QPointF &pos)
|
||||
{
|
||||
Q_UNUSED(indexSpline)
|
||||
const QSharedPointer<VSpline> spline = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
const QSharedPointer<VSpline> spline = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
||||
const VSpline spl = CorrectedSpline(*spline, position, pos);
|
||||
|
||||
MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id);
|
||||
MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, m_id);
|
||||
connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveSpl);
|
||||
}
|
||||
|
@ -286,31 +280,13 @@ void VToolSpline::EnableToolMove(bool move)
|
|||
this->setFlag(QGraphicsItem::ItemIsMovable, move);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogSpline>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RemoveReferens decrement value of reference.
|
||||
*/
|
||||
void VToolSpline::RemoveReferens()
|
||||
{
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
||||
doc->DecrementReferens(spl->GetP1().getIdTool());
|
||||
doc->DecrementReferens(spl->GetP4().getIdTool());
|
||||
}
|
||||
|
@ -398,7 +374,7 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
// "weight" describes how the influence of the drag should be distributed
|
||||
// among the handles; 0 = front handle only, 1 = back handle only.
|
||||
|
||||
const auto spline = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
const auto spline = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
||||
const qreal t = spline->ParamT(oldPosition);
|
||||
|
||||
if (qFloor(t) == -1)
|
||||
|
@ -435,7 +411,7 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
VSpline spl = VSpline(spline->GetP1(), p2, p3, spline->GetP4());
|
||||
|
||||
MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id);
|
||||
MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, m_id);
|
||||
connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveSpl);
|
||||
|
||||
|
@ -498,7 +474,7 @@ void VToolSpline::SetVisualization()
|
|||
VisToolSpline *visual = qobject_cast<VisToolSpline *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
||||
visual->setObject1Id(spl->GetP1().id());
|
||||
visual->setObject4Id(spl->GetP4().id());
|
||||
visual->SetAngle1(spl->GetStartAngle());
|
||||
|
@ -515,7 +491,7 @@ void VToolSpline::SetVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VToolSpline::IsMovable() const
|
||||
{
|
||||
const auto spline = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
const auto spline = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
||||
|
||||
return qmu::QmuTokenParser::IsSingle(spline->GetStartAngleFormula()) &&
|
||||
qmu::QmuTokenParser::IsSingle(spline->GetEndAngleFormula()) &&
|
||||
|
@ -532,7 +508,7 @@ void VToolSpline::RefreshCtrlPoints()
|
|||
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||
}
|
||||
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(m_id);
|
||||
|
||||
controlPoints[0]->blockSignals(true);
|
||||
controlPoints[1]->blockSignals(true);
|
||||
|
@ -566,6 +542,21 @@ void VToolSpline::RefreshCtrlPoints()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSpline::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogSpline>(event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSpline::SetSplineAttributes(QDomElement &domElement, const VSpline &spl)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,28 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolSplineInitData : public VAbstractSplineInitData
|
||||
{
|
||||
VToolSplineInitData()
|
||||
: VAbstractSplineInitData(),
|
||||
point1(NULL_ID),
|
||||
point4(NULL_ID),
|
||||
a1(),
|
||||
a2(),
|
||||
l1(),
|
||||
l2(),
|
||||
duplicate(0)
|
||||
{}
|
||||
|
||||
quint32 point1;
|
||||
quint32 point4;
|
||||
QString a1;
|
||||
QString a2;
|
||||
QString l1;
|
||||
QString l2;
|
||||
quint32 duplicate;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolSpline class tool for creation spline. I mean bezier curve.
|
||||
*/
|
||||
|
@ -55,13 +77,8 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolSpline *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolSpline *Create(const quint32 _id, VSpline *spline,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolSpline *Create(const quint32 _id, quint32 point1, quint32 point4, QString &a1, QString &a2, QString &l1,
|
||||
QString &l2, quint32 duplicate, const QString &color, const QString &penStyle,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolSpline *Create(VToolSplineInitData &initData, VSpline *spline);
|
||||
static VToolSpline *Create(VToolSplineInitData &initData);
|
||||
static const QString ToolType;
|
||||
static const QString OldToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
@ -75,8 +92,9 @@ public slots:
|
|||
void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position,
|
||||
const QPointF &pos);
|
||||
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -91,8 +109,7 @@ private:
|
|||
Q_DISABLE_COPY(VToolSpline)
|
||||
QPointF oldPosition;
|
||||
|
||||
VToolSpline (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr );
|
||||
VToolSpline (VToolSplineInitData initData, QGraphicsItem *parent = nullptr );
|
||||
|
||||
bool IsMovable() const;
|
||||
void SetSplineAttributes(QDomElement &domElement, const VSpline &spl);
|
||||
|
|
|
@ -79,15 +79,11 @@ const QString VToolSplinePath::OldToolType = QStringLiteral("path");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolSplinePath constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
: VAbstractSpline(doc, data, id, parent),
|
||||
VToolSplinePath::VToolSplinePath(const VToolSplinePathInitData &initData, QGraphicsItem *parent)
|
||||
: VAbstractSpline(initData.doc, initData.data, initData.id, parent),
|
||||
oldPosition(),
|
||||
splIndex(-1)
|
||||
{
|
||||
|
@ -96,7 +92,7 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
|
|||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
|
||||
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(id);
|
||||
const QSharedPointer<VSplinePath> splPath = initData.data->GeometricObject<VSplinePath>(initData.id);
|
||||
for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i)
|
||||
{
|
||||
const VSpline spl = splPath->GetSpline(i);
|
||||
|
@ -128,7 +124,7 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
|
|||
|
||||
ShowHandles(false);
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -140,7 +136,7 @@ void VToolSplinePath::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogSplinePath> dialogTool = m_dialog.objectCast<DialogSplinePath>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
const QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
dialogTool->SetPath(*splPath);
|
||||
dialogTool->SetColor(splPath->GetColor());
|
||||
dialogTool->SetPenStyle(splPath->GetPenStyle());
|
||||
|
@ -160,6 +156,14 @@ VToolSplinePath* VToolSplinePath::Create(QSharedPointer<DialogTool> dialog, VMai
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogSplinePath> dialogTool = dialog.objectCast<DialogSplinePath>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
VToolSplinePathInitData initData;
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VSplinePath *path = new VSplinePath(dialogTool->GetPath());
|
||||
for (qint32 i = 0; i < path->CountPoints(); ++i)
|
||||
{
|
||||
|
@ -169,7 +173,7 @@ VToolSplinePath* VToolSplinePath::Create(QSharedPointer<DialogTool> dialog, VMai
|
|||
path->SetColor(dialogTool->GetColor());
|
||||
path->SetPenStyle(dialogTool->GetPenStyle());
|
||||
|
||||
VToolSplinePath* spl = Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
VToolSplinePath* spl = Create(initData, path);
|
||||
if (spl != nullptr)
|
||||
{
|
||||
spl->m_dialog = dialogTool;
|
||||
|
@ -180,79 +184,69 @@ VToolSplinePath* VToolSplinePath::Create(QSharedPointer<DialogTool> dialog, VMai
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param initData init data.
|
||||
* @param path spline path.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
*/
|
||||
VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolSplinePath* VToolSplinePath::Create(VToolSplinePathInitData &initData, VSplinePath *path)
|
||||
{
|
||||
quint32 id = _id;
|
||||
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(path);
|
||||
data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
|
||||
initData.id = initData.data->AddGObject(path);
|
||||
initData.data->AddCurveWithSegments(initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.id),
|
||||
initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, path);
|
||||
data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, path);
|
||||
initData.data->AddCurveWithSegments(initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.id),
|
||||
initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::SplinePath, doc);
|
||||
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation);
|
||||
scene->addItem(spl);
|
||||
InitSplinePathToolConnections(scene, spl);
|
||||
VAbstractPattern::AddTool(id, spl);
|
||||
VAbstractTool::AddRecord(initData.id, Tool::SplinePath, initData.doc);
|
||||
VToolSplinePath *spl = new VToolSplinePath(initData);
|
||||
initData.scene->addItem(spl);
|
||||
InitSplinePathToolConnections(initData.scene, spl);
|
||||
VAbstractPattern::AddTool(initData.id, spl);
|
||||
return spl;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolSplinePath *VToolSplinePath::Create(const quint32 _id, const QVector<quint32> &points, QVector<QString> &a1,
|
||||
QVector<QString> &a2, QVector<QString> &l1, QVector<QString> &l2,
|
||||
const QString &color, const QString &penStyle, quint32 duplicate,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolSplinePath *VToolSplinePath::Create(VToolSplinePathInitData &initData)
|
||||
{
|
||||
auto path = new VSplinePath();
|
||||
|
||||
if (duplicate > 0)
|
||||
if (initData.duplicate > 0)
|
||||
{
|
||||
path->SetDuplicate(duplicate);
|
||||
path->SetDuplicate(initData.duplicate);
|
||||
}
|
||||
|
||||
for (int i = 0; i < points.size(); ++i)
|
||||
for (int i = 0; i < initData.points.size(); ++i)
|
||||
{
|
||||
const qreal calcAngle1 = CheckFormula(_id, a1[i], data);
|
||||
const qreal calcAngle2 = CheckFormula(_id, a2[i], data);
|
||||
const qreal calcAngle1 = CheckFormula(initData.id, initData.a1[i], initData.data);
|
||||
const qreal calcAngle2 = CheckFormula(initData.id, initData.a2[i], initData.data);
|
||||
|
||||
const qreal calcLength1 = qApp->toPixel(CheckFormula(_id, l1[i], data));
|
||||
const qreal calcLength2 = qApp->toPixel(CheckFormula(_id, l2[i], data));
|
||||
const qreal calcLength1 = qApp->toPixel(CheckFormula(initData.id, initData.l1[i], initData.data));
|
||||
const qreal calcLength2 = qApp->toPixel(CheckFormula(initData.id, initData.l2[i], initData.data));
|
||||
|
||||
const auto p = *data->GeometricObject<VPointF>(points.at(i));
|
||||
const auto p = *initData.data->GeometricObject<VPointF>(initData.points.at(i));
|
||||
|
||||
path->append(VSplinePoint(p, calcAngle1, a1.at(i), calcAngle2, a2.at(i), calcLength1, l1.at(i), calcLength2,
|
||||
l2.at(i)));
|
||||
path->append(VSplinePoint(p, calcAngle1, initData.a1.at(i), calcAngle2, initData.a2.at(i), calcLength1,
|
||||
initData.l1.at(i), calcLength2, initData.l2.at(i)));
|
||||
}
|
||||
|
||||
path->SetColor(color);
|
||||
path->SetPenStyle(penStyle);
|
||||
path->SetColor(initData.color);
|
||||
path->SetPenStyle(initData.penStyle);
|
||||
|
||||
return VToolSplinePath::Create(_id, path, scene, doc, data, parse, typeCreation);
|
||||
return VToolSplinePath::Create(initData, path);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -265,12 +259,12 @@ VToolSplinePath *VToolSplinePath::Create(const quint32 _id, const QVector<quint3
|
|||
void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
|
||||
const QPointF &pos)
|
||||
{
|
||||
const VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
const VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
VSplinePath newSplPath = oldSplPath;
|
||||
const VSpline spl = CorrectedSpline(newSplPath.GetSpline(indexSpline), position, pos);
|
||||
UpdateControlPoints(spl, newSplPath, indexSpline);
|
||||
|
||||
MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, id);
|
||||
MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, m_id);
|
||||
connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveSplPath);
|
||||
}
|
||||
|
@ -281,6 +275,21 @@ void VToolSplinePath::EnableToolMove(bool move)
|
|||
this->setFlag(QGraphicsItem::ItemIsMovable, move);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSplinePath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogSplinePath>(event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief UpdateControlPoints update position points control points in file.
|
||||
|
@ -345,14 +354,14 @@ void VToolSplinePath::UpdatePathPoints(VAbstractPattern *doc, QDomElement &eleme
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSplinePath VToolSplinePath::getSplinePath() const
|
||||
{
|
||||
QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
return *splPath.data();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSplinePath::setSplinePath(const VSplinePath &splPath)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
QSharedPointer<VSplinePath> splinePath = qSharedPointerDynamicCast<VSplinePath>(obj);
|
||||
*splinePath.data() = splPath;
|
||||
SaveOption(obj);
|
||||
|
@ -364,24 +373,6 @@ void VToolSplinePath::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolSplinePath>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogSplinePath>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AddPathPoint write path point to pattern file.
|
||||
|
@ -423,7 +414,7 @@ void VToolSplinePath::AddPathPoint(VAbstractPattern *doc, QDomElement &domElemen
|
|||
*/
|
||||
void VToolSplinePath::RemoveReferens()
|
||||
{
|
||||
const QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
const QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
for (qint32 i = 0; i < splPath->CountSubSpl(); ++i)
|
||||
{
|
||||
doc->DecrementReferens(splPath->at(i).P().getIdTool());
|
||||
|
@ -480,7 +471,7 @@ void VToolSplinePath::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||
{
|
||||
oldPosition = event->scenePos();
|
||||
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
splIndex = splPath->Segment(oldPosition);
|
||||
if (IsMovable(splIndex))
|
||||
{
|
||||
|
@ -515,7 +506,7 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
if (IsMovable(splIndex))
|
||||
{
|
||||
VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
VSplinePath newSplPath = oldSplPath;
|
||||
|
||||
VSpline spline = newSplPath.GetSpline(splIndex);
|
||||
|
@ -561,7 +552,7 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
UpdateControlPoints(spl, newSplPath, splIndex);
|
||||
|
||||
MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, id);
|
||||
MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, m_id);
|
||||
connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveSplPath);
|
||||
|
||||
|
@ -594,7 +585,7 @@ void VToolSplinePath::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
oldPosition = event->scenePos();
|
||||
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
splIndex = splPath->Segment(oldPosition);
|
||||
if (IsMovable(splIndex))
|
||||
{
|
||||
|
@ -625,7 +616,7 @@ void VToolSplinePath::SetVisualization()
|
|||
VisToolSplinePath *visual = qobject_cast<VisToolSplinePath *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
visual->setPath(*splPath.data());
|
||||
visual->setLineStyle(LineStyleToPenStyle(splPath->GetPenStyle()));
|
||||
visual->SetMode(Mode::Show);
|
||||
|
@ -636,7 +627,7 @@ void VToolSplinePath::SetVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VToolSplinePath::IsMovable(int index) const
|
||||
{
|
||||
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
|
||||
//index == -1 - can delete, but decided to left
|
||||
if (index == -1 || index < 1 || index > splPath->CountSubSpl())
|
||||
|
@ -659,7 +650,7 @@ void VToolSplinePath::RefreshCtrlPoints()
|
|||
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||
}
|
||||
|
||||
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
|
||||
|
||||
for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,26 @@
|
|||
class VSplinePath;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolSplinePathInitData : public VAbstractSplineInitData
|
||||
{
|
||||
VToolSplinePathInitData()
|
||||
: VAbstractSplineInitData(),
|
||||
points(),
|
||||
a1(),
|
||||
a2(),
|
||||
l1(),
|
||||
l2(),
|
||||
duplicate(0)
|
||||
{}
|
||||
|
||||
QVector<quint32> points;
|
||||
QVector<QString> a1;
|
||||
QVector<QString> a2;
|
||||
QVector<QString> l1;
|
||||
QVector<QString> l2;
|
||||
quint32 duplicate;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolSplinePath class tool for creation spline path.
|
||||
*/
|
||||
|
@ -57,14 +77,8 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolSplinePath *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolSplinePath *Create(const quint32 _id, VSplinePath *path,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolSplinePath *Create(const quint32 _id, const QVector<quint32> &points, QVector<QString> &a1,
|
||||
QVector<QString> &a2, QVector<QString> &l1, QVector<QString> &l2,
|
||||
const QString &color, const QString &penStyle, quint32 duplicate,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolSplinePath *Create(VToolSplinePathInitData &initData, VSplinePath *path);
|
||||
static VToolSplinePath *Create(VToolSplinePathInitData &initData);
|
||||
static const QString ToolType;
|
||||
static const QString OldToolType;
|
||||
static void UpdatePathPoints(VAbstractPattern *doc, QDomElement &element, const VSplinePath &path);
|
||||
|
@ -90,8 +104,9 @@ public slots:
|
|||
void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
|
||||
const QPointF &pos);
|
||||
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -107,8 +122,7 @@ private:
|
|||
QPointF oldPosition;
|
||||
int splIndex;
|
||||
|
||||
VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
VToolSplinePath(const VToolSplinePathInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
|
||||
bool IsMovable(int index) const;
|
||||
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <new>
|
||||
|
||||
#include "../../../../undocommands/label/movedoublelabel.h"
|
||||
#include "../../../../undocommands/label/showdoublelabel.h"
|
||||
#include "../ifc/exception/vexception.h"
|
||||
#include "../ifc/exception/vexceptionbadid.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
|
@ -65,18 +66,20 @@ VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quin
|
|||
{
|
||||
firstPoint = new VSimplePoint(p1id, QColor(Qt::black));
|
||||
firstPoint->setParentItem(this);
|
||||
firstPoint->setToolTip(ComplexToolTip(p1id));
|
||||
connect(firstPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point1Choosed);
|
||||
connect(firstPoint, &VSimplePoint::Selected, this, &VToolDoublePoint::Point1Selected);
|
||||
connect(firstPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent);
|
||||
connect(firstPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::ShowContextMenu);
|
||||
connect(firstPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel);
|
||||
connect(firstPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label1ChangePosition);
|
||||
firstPoint->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
|
||||
|
||||
secondPoint = new VSimplePoint(p2id, QColor(Qt::black));
|
||||
secondPoint->setParentItem(this);
|
||||
secondPoint->setToolTip(ComplexToolTip(p2id));
|
||||
connect(secondPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point2Choosed);
|
||||
connect(secondPoint, &VSimplePoint::Selected, this, &VToolDoublePoint::Point2Selected);
|
||||
connect(secondPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent);
|
||||
connect(secondPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::ShowContextMenu);
|
||||
connect(secondPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel);
|
||||
connect(secondPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label2ChangePosition);
|
||||
secondPoint->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
|
||||
|
@ -119,6 +122,40 @@ void VToolDoublePoint::GroupVisibility(quint32 object, bool visible)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VToolDoublePoint::IsLabelVisible(quint32 id) const
|
||||
{
|
||||
if (p1id == id)
|
||||
{
|
||||
return VAbstractTool::data.GeometricObject<VPointF>(p1id)->IsShowLabel();
|
||||
}
|
||||
else if (p2id == id)
|
||||
{
|
||||
return VAbstractTool::data.GeometricObject<VPointF>(p2id)->IsShowLabel();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::SetLabelVisible(quint32 id, bool visible)
|
||||
{
|
||||
if (p1id == id)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(p1id);
|
||||
point->SetShowLabel(visible);
|
||||
firstPoint->RefreshPointGeometry(*point);
|
||||
}
|
||||
else if (p2id == id)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(p2id);
|
||||
point->SetShowLabel(visible);
|
||||
secondPoint->RefreshPointGeometry(*point);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
|
||||
{
|
||||
|
@ -162,20 +199,22 @@ void VToolDoublePoint::Point2Choosed()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::Point1Selected(bool selected)
|
||||
{
|
||||
emit ChangedToolSelection(selected, p1id, id);
|
||||
emit ChangedToolSelection(selected, p1id, m_id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::Point2Selected(bool selected)
|
||||
{
|
||||
emit ChangedToolSelection(selected, p2id, id);
|
||||
emit ChangedToolSelection(selected, p2id, m_id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::FullUpdateFromFile()
|
||||
{
|
||||
ReadAttributes();
|
||||
firstPoint->setToolTip(ComplexToolTip(p1id));
|
||||
firstPoint->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
|
||||
secondPoint->setToolTip(ComplexToolTip(p2id));
|
||||
secondPoint->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
|
||||
SetVisualization();
|
||||
}
|
||||
|
@ -244,7 +283,7 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id)
|
|||
{
|
||||
const VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
|
||||
|
||||
auto moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), DoublePoint::FirstPoint, this->id, p1id);
|
||||
auto moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), MoveDoublePoint::FirstPoint, m_id, p1id);
|
||||
connect(moveLabel, &MoveDoubleLabel::ChangePosition, this, &VToolDoublePoint::DoChangePosition);
|
||||
qApp->getUndoStack()->push(moveLabel);
|
||||
}
|
||||
|
@ -252,7 +291,7 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id)
|
|||
{
|
||||
const VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
|
||||
|
||||
auto moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), DoublePoint::SecondPoint, this->id, p2id);
|
||||
auto moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), MoveDoublePoint::SecondPoint, m_id, p2id);
|
||||
connect(moveLabel, &MoveDoubleLabel::ChangePosition, this, &VToolDoublePoint::DoChangePosition);
|
||||
qApp->getUndoStack()->push(moveLabel);
|
||||
}
|
||||
|
@ -312,7 +351,7 @@ void VToolDoublePoint::keyReleaseEvent(QKeyEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
ShowContextMenu(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -320,38 +359,43 @@ void VToolDoublePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &o
|
|||
{
|
||||
VDrawTool::SaveOptions(tag, obj);
|
||||
|
||||
auto SavePoint1 = [this](QDomElement &tag, const QSharedPointer<VPointF> &point)
|
||||
{
|
||||
doc->SetAttribute(tag, AttrName1, point->name());
|
||||
doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(point->mx()));
|
||||
doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(point->my()));
|
||||
doc->SetAttribute<bool>(tag, AttrShowLabel1, point->IsShowLabel());
|
||||
};
|
||||
|
||||
auto SavePoint2 = [this](QDomElement &tag, const QSharedPointer<VPointF> &point)
|
||||
{
|
||||
doc->SetAttribute(tag, AttrName2, point->name());
|
||||
doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(point->mx()));
|
||||
doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(point->my()));
|
||||
doc->SetAttribute<bool>(tag, AttrShowLabel2, point->IsShowLabel());
|
||||
};
|
||||
|
||||
if (obj->id() == p1id)
|
||||
{
|
||||
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
|
||||
SCASSERT(point.isNull() == false)
|
||||
|
||||
doc->SetAttribute(tag, AttrName1, point->name());
|
||||
doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(point->mx()));
|
||||
doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(point->my()));
|
||||
SavePoint1(tag, point);
|
||||
}
|
||||
else if (obj->id() == p2id)
|
||||
{
|
||||
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
|
||||
SCASSERT(point.isNull() == false)
|
||||
|
||||
doc->SetAttribute(tag, AttrName2, point->name());
|
||||
doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(point->mx()));
|
||||
doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(point->my()));
|
||||
SavePoint2(tag, point);
|
||||
}
|
||||
else
|
||||
{
|
||||
VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
|
||||
VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
|
||||
|
||||
doc->SetAttribute(tag, AttrPoint1, p1id);
|
||||
doc->SetAttribute(tag, AttrName1, p1->name());
|
||||
doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(p1->mx()));
|
||||
doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(p1->my()));
|
||||
SavePoint1(tag, VAbstractTool::data.GeometricObject<VPointF>(p1id));
|
||||
|
||||
doc->SetAttribute(tag, AttrPoint2, p2id);
|
||||
doc->SetAttribute(tag, AttrName2, p2->name());
|
||||
doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(p2->mx()));
|
||||
doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(p2->my()));
|
||||
SavePoint2(tag, VAbstractTool::data.GeometricObject<VPointF>(p2id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,7 +403,33 @@ void VToolDoublePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &o
|
|||
void VToolDoublePoint::AddToFile()
|
||||
{
|
||||
QDomElement domElement = doc->createElement(getTagName());
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOptions(domElement, obj);
|
||||
AddToCalculation(domElement);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::ChangeLabelVisibility(quint32 id, bool visible)
|
||||
{
|
||||
if (id == p1id)
|
||||
{
|
||||
qApp->getUndoStack()->push(new ShowDoubleLabel(doc, m_id, p1id, visible, ShowDoublePoint::FirstPoint));
|
||||
}
|
||||
else if (id == p2id)
|
||||
{
|
||||
qApp->getUndoStack()->push(new ShowDoubleLabel(doc, m_id, p2id, visible, ShowDoublePoint::SecondPoint));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolDoublePoint::ComplexToolTip(quint32 itemId) const
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(itemId);
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"%3"
|
||||
"</table>")
|
||||
.arg(tr("Label"), point->name(), MakeToolTip());
|
||||
return toolTip;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,9 @@ public:
|
|||
void setNameP2(const QString &name);
|
||||
|
||||
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE;
|
||||
virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||
public slots:
|
||||
void Label1ChangePosition(const QPointF &pos);
|
||||
void Label2ChangePosition(const QPointF &pos);
|
||||
|
@ -93,6 +96,9 @@ protected:
|
|||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void AddToFile() Q_DECL_OVERRIDE;
|
||||
virtual void ChangeLabelVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||
|
||||
QString ComplexToolTip(quint32 itemId) const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolDoublePoint)
|
||||
|
|
|
@ -55,26 +55,15 @@ template <class T> class QSharedPointer;
|
|||
const QString VToolTrueDarts::ToolType = QStringLiteral("trueDarts");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolTrueDarts::VToolTrueDarts(VAbstractPattern *doc,
|
||||
VContainer *data,
|
||||
const quint32 &id,
|
||||
const quint32 &p1id,
|
||||
const quint32 &p2id,
|
||||
const quint32 &baseLineP1Id,
|
||||
const quint32 &baseLineP2Id,
|
||||
const quint32 &dartP1Id,
|
||||
const quint32 &dartP2Id,
|
||||
const quint32 &dartP3Id,
|
||||
const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VToolDoublePoint(doc, data, id, p1id, p2id, parent),
|
||||
baseLineP1Id (baseLineP1Id),
|
||||
baseLineP2Id(baseLineP2Id),
|
||||
dartP1Id(dartP1Id),
|
||||
dartP2Id(dartP2Id),
|
||||
dartP3Id(dartP3Id)
|
||||
VToolTrueDarts::VToolTrueDarts(const VToolTrueDartsInitData &initData, QGraphicsItem *parent)
|
||||
:VToolDoublePoint(initData.doc, initData.data, initData.id, initData.p1id, initData.p2id, parent),
|
||||
baseLineP1Id (initData.baseLineP1Id),
|
||||
baseLineP2Id(initData.baseLineP2Id),
|
||||
dartP1Id(initData.dartP1Id),
|
||||
dartP2Id(initData.dartP2Id),
|
||||
dartP3Id(initData.dartP3Id)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -128,17 +117,21 @@ VToolTrueDarts *VToolTrueDarts::Create(QSharedPointer<DialogTool> dialog, VMainG
|
|||
QSharedPointer<DialogTrueDarts> dialogTool = dialog.objectCast<DialogTrueDarts>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
const QString point1Name = dialogTool->GetFirstNewDartPointName();
|
||||
const QString point2Name = dialogTool->GetSecondNewDartPointName();
|
||||
const quint32 baseLineP1Id = dialogTool->GetFirstBasePointId();
|
||||
const quint32 baseLineP2Id = dialogTool->GetSecondBasePointId();
|
||||
const quint32 dartP1Id = dialogTool->GetFirstDartPointId();
|
||||
const quint32 dartP2Id = dialogTool->GetSecondDartPointId();
|
||||
const quint32 dartP3Id = dialogTool->GetThirdDartPointId();
|
||||
VToolTrueDartsInitData initData;
|
||||
initData.name1 = dialogTool->GetFirstNewDartPointName();
|
||||
initData.name2 = dialogTool->GetSecondNewDartPointName();
|
||||
initData.baseLineP1Id = dialogTool->GetFirstBasePointId();
|
||||
initData.baseLineP2Id = dialogTool->GetSecondBasePointId();
|
||||
initData.dartP1Id = dialogTool->GetFirstDartPointId();
|
||||
initData.dartP2Id = dialogTool->GetSecondDartPointId();
|
||||
initData.dartP3Id = dialogTool->GetThirdDartPointId();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolTrueDarts *point = Create(0, 0, 0, baseLineP1Id, baseLineP2Id, dartP1Id, dartP2Id, dartP3Id,
|
||||
point1Name, 5, 10, point2Name, 5, 10, scene, doc, data, Document::FullParse,
|
||||
Source::FromGui);
|
||||
VToolTrueDarts *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -147,61 +140,54 @@ VToolTrueDarts *VToolTrueDarts::Create(QSharedPointer<DialogTool> dialog, VMainG
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolTrueDarts *VToolTrueDarts::Create(quint32 _id,
|
||||
const quint32 &_p1id, const quint32 &_p2id,
|
||||
const quint32 &baseLineP1Id,
|
||||
const quint32 &baseLineP2Id,
|
||||
const quint32 &dartP1Id,
|
||||
const quint32 &dartP2Id,
|
||||
const quint32 &dartP3Id,
|
||||
const QString &point1Name, const qreal &mx1, const qreal &my1,
|
||||
const QString &point2Name, const qreal &mx2, const qreal &my2,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolTrueDarts *VToolTrueDarts::Create(VToolTrueDartsInitData initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> baseLineP1 = data->GeometricObject<VPointF>(baseLineP1Id);
|
||||
const QSharedPointer<VPointF> baseLineP2 = data->GeometricObject<VPointF>(baseLineP2Id);
|
||||
const QSharedPointer<VPointF> dartP1 = data->GeometricObject<VPointF>(dartP1Id);
|
||||
const QSharedPointer<VPointF> dartP2 = data->GeometricObject<VPointF>(dartP2Id);
|
||||
const QSharedPointer<VPointF> dartP3 = data->GeometricObject<VPointF>(dartP3Id);
|
||||
const QSharedPointer<VPointF> baseLineP1 = initData.data->GeometricObject<VPointF>(initData.baseLineP1Id);
|
||||
const QSharedPointer<VPointF> baseLineP2 = initData.data->GeometricObject<VPointF>(initData.baseLineP2Id);
|
||||
const QSharedPointer<VPointF> dartP1 = initData.data->GeometricObject<VPointF>(initData.dartP1Id);
|
||||
const QSharedPointer<VPointF> dartP2 = initData.data->GeometricObject<VPointF>(initData.dartP2Id);
|
||||
const QSharedPointer<VPointF> dartP3 = initData.data->GeometricObject<VPointF>(initData.dartP3Id);
|
||||
|
||||
QPointF fPoint1;
|
||||
QPointF fPoint2;
|
||||
VToolTrueDarts::FindPoint(static_cast<QPointF>(*baseLineP1), static_cast<QPointF>(*baseLineP2),
|
||||
static_cast<QPointF>(*dartP1), static_cast<QPointF>(*dartP2),
|
||||
static_cast<QPointF>(*dartP3), fPoint1, fPoint2);
|
||||
quint32 id = _id;
|
||||
quint32 p1id = _p1id;
|
||||
quint32 p2id = _p2id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
|
||||
VPointF *p1 = new VPointF(fPoint1, initData.name1, initData.mx1, initData.my1, initData.id);
|
||||
p1->SetShowLabel(initData.showLabel1);
|
||||
|
||||
VPointF *p2 = new VPointF(fPoint2, initData.name2, initData.mx2, initData.my2, initData.id);
|
||||
p2->SetShowLabel(initData.showLabel2);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = VContainer::getNextId();//Just reserve id for tool
|
||||
p1id = data->AddGObject(new VPointF(fPoint1, point1Name, mx1, my1, id));
|
||||
p2id = data->AddGObject(new VPointF(fPoint2, point2Name, mx2, my2, id));
|
||||
initData.id = VContainer::getNextId();//Just reserve id for tool
|
||||
initData.p1id = initData.data->AddGObject(p1);
|
||||
initData.p2id = initData.data->AddGObject(p2);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(p1id, new VPointF(fPoint1, point1Name, mx1, my1, id));
|
||||
data->UpdateGObject(p2id, new VPointF(fPoint2, point2Name, mx2, my2, id));
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.p1id, p1);
|
||||
initData.data->UpdateGObject(initData.p2id, p2);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::TrueDarts, doc);
|
||||
VToolTrueDarts *points = new VToolTrueDarts(doc, data, id, p1id, p2id, baseLineP1Id, baseLineP2Id,
|
||||
dartP1Id, dartP2Id, dartP3Id, typeCreation);
|
||||
scene->addItem(points);
|
||||
InitToolConnections(scene, points);
|
||||
VAbstractPattern::AddTool(id, points);
|
||||
doc->IncrementReferens(baseLineP1->getIdTool());
|
||||
doc->IncrementReferens(baseLineP2->getIdTool());
|
||||
doc->IncrementReferens(dartP1->getIdTool());
|
||||
doc->IncrementReferens(dartP2->getIdTool());
|
||||
doc->IncrementReferens(dartP3->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::TrueDarts, initData.doc);
|
||||
VToolTrueDarts *points = new VToolTrueDarts(initData);
|
||||
initData.scene->addItem(points);
|
||||
InitToolConnections(initData.scene, points);
|
||||
VAbstractPattern::AddTool(initData.id, points);
|
||||
initData.doc->IncrementReferens(baseLineP1->getIdTool());
|
||||
initData.doc->IncrementReferens(baseLineP2->getIdTool());
|
||||
initData.doc->IncrementReferens(dartP1->getIdTool());
|
||||
initData.doc->IncrementReferens(dartP2->getIdTool());
|
||||
initData.doc->IncrementReferens(dartP3->getIdTool());
|
||||
return points;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -256,7 +242,7 @@ void VToolTrueDarts::SetBaseLineP1Id(const quint32 &value)
|
|||
{
|
||||
baseLineP1Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +260,7 @@ void VToolTrueDarts::SetBaseLineP2Id(const quint32 &value)
|
|||
{
|
||||
baseLineP2Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +278,7 @@ void VToolTrueDarts::SetDartP1Id(const quint32 &value)
|
|||
{
|
||||
dartP1Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +296,7 @@ void VToolTrueDarts::SetDartP2Id(const quint32 &value)
|
|||
{
|
||||
dartP2Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -328,17 +314,17 @@ void VToolTrueDarts::SetDartP3Id(const quint32 &value)
|
|||
{
|
||||
dartP3Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
|
||||
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolTrueDarts::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogTrueDarts>(this, event);
|
||||
ContextMenu<DialogTrueDarts>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,44 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolTrueDartsInitData : public VAbstractToolInitData
|
||||
{
|
||||
VToolTrueDartsInitData()
|
||||
: VAbstractToolInitData(),
|
||||
p1id(NULL_ID),
|
||||
p2id(NULL_ID),
|
||||
baseLineP1Id(NULL_ID),
|
||||
baseLineP2Id(NULL_ID),
|
||||
dartP1Id(NULL_ID),
|
||||
dartP2Id(NULL_ID),
|
||||
dartP3Id(NULL_ID),
|
||||
name1(),
|
||||
mx1(10),
|
||||
my1(15),
|
||||
showLabel1(true),
|
||||
name2(),
|
||||
mx2(10),
|
||||
my2(15),
|
||||
showLabel2(true)
|
||||
{}
|
||||
|
||||
quint32 p1id;
|
||||
quint32 p2id;
|
||||
quint32 baseLineP1Id;
|
||||
quint32 baseLineP2Id;
|
||||
quint32 dartP1Id;
|
||||
quint32 dartP2Id;
|
||||
quint32 dartP3Id;
|
||||
QString name1;
|
||||
qreal mx1;
|
||||
qreal my1;
|
||||
bool showLabel1;
|
||||
QString name2;
|
||||
qreal mx2;
|
||||
qreal my2;
|
||||
bool showLabel2;
|
||||
};
|
||||
|
||||
class VToolTrueDarts : public VToolDoublePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -53,17 +91,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolTrueDarts* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolTrueDarts* Create(quint32 _id,
|
||||
const quint32 &_p1id, const quint32 &_p2id,
|
||||
const quint32 &baseLineP1Id,
|
||||
const quint32 &baseLineP2Id,
|
||||
const quint32 &dartP1Id,
|
||||
const quint32 &dartP2Id,
|
||||
const quint32 &dartP3Id,
|
||||
const QString &point1Name, const qreal &mx1, const qreal &my1,
|
||||
const QString &point2Name, const qreal &mx2, const qreal &my2,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolTrueDarts* Create(VToolTrueDartsInitData initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::TrueDarts)};
|
||||
|
@ -91,8 +119,9 @@ public:
|
|||
quint32 GetDartP3Id() const;
|
||||
void SetDartP3Id(const quint32 &value);
|
||||
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -107,18 +136,7 @@ private:
|
|||
quint32 dartP2Id;
|
||||
quint32 dartP3Id;
|
||||
|
||||
VToolTrueDarts(VAbstractPattern *doc,
|
||||
VContainer *data,
|
||||
const quint32 &id,
|
||||
const quint32 &p1id,
|
||||
const quint32 &p2id,
|
||||
const quint32 &baseLineP1Id,
|
||||
const quint32 &baseLineP2Id,
|
||||
const quint32 &dartP1Id,
|
||||
const quint32 &dartP2Id,
|
||||
const quint32 &dartP3Id,
|
||||
const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
VToolTrueDarts(const VToolTrueDartsInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLTRUEDARTS_H
|
||||
|
|
|
@ -74,23 +74,6 @@ void VToolCut::FullUpdateFromFile()
|
|||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCut::MakeToolTip() const
|
||||
{
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(curveCutId);
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7°</td> </tr>"
|
||||
"<tr> <td><b>%8:</b> %9°</td> </tr>"
|
||||
"</table>")
|
||||
.arg(tr("Length"))
|
||||
.arg(qApp->fromPixel(curve->GetLength()))
|
||||
.arg(UnitsToStr(qApp->patternUnit(), true));
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
quint32 VToolCut::getCurveCutId() const
|
||||
|
@ -105,7 +88,7 @@ void VToolCut::setCurveCutId(const quint32 &value)
|
|||
if (value != NULL_ID)
|
||||
{
|
||||
curveCutId = value;
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +98,7 @@ VFormula VToolCut::GetFormula() const
|
|||
{
|
||||
VFormula val(formula, getData());
|
||||
val.setCheckZero(true);
|
||||
val.setToolId(id);
|
||||
val.setToolId(m_id);
|
||||
val.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
return val;
|
||||
}
|
||||
|
@ -127,7 +110,7 @@ void VToolCut::SetFormula(const VFormula &value)
|
|||
{
|
||||
formula = value.GetFormula(FormulaType::FromUser);
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +127,7 @@ QString VToolCut::CurveName() const
|
|||
*/
|
||||
void VToolCut::RefreshGeometry()
|
||||
{
|
||||
VToolSinglePoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
VToolSinglePoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(m_id));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -66,7 +66,6 @@ public slots:
|
|||
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
|
||||
virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE;
|
||||
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
||||
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
/** @brief formula keep formula of length */
|
||||
QString formula;
|
||||
|
|
|
@ -59,19 +59,13 @@ const QString VToolCutArc::ToolType = QStringLiteral("cutArc");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolCutArc constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param formula string with formula length first arc.
|
||||
* @param arcId id arc in data container.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolCutArc::VToolCutArc(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
||||
const quint32 &arcId, const Source &typeCreation, QGraphicsItem * parent)
|
||||
:VToolCut(doc, data, id, formula, arcId, parent)
|
||||
VToolCutArc::VToolCutArc(const VToolCutArcInitData &initData, QGraphicsItem * parent)
|
||||
:VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.arcId, parent)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -83,7 +77,7 @@ void VToolCutArc::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogCutArc> dialogTool = m_dialog.objectCast<DialogCutArc>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFormula(formula);
|
||||
dialogTool->setArcId(curveCutId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
|
@ -103,11 +97,18 @@ VToolCutArc* VToolCutArc::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogCutArc> dialogTool = dialog.objectCast<DialogCutArc>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
QString formula = dialogTool->GetFormula();
|
||||
const quint32 arcId = dialogTool->getArcId();
|
||||
VToolCutArc* point = Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse,
|
||||
Source::FromGui);
|
||||
|
||||
VToolCutArcInitData initData;
|
||||
initData.formula = dialogTool->GetFormula();
|
||||
initData.arcId = dialogTool->getArcId();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolCutArc* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -118,64 +119,54 @@ VToolCutArc* VToolCutArc::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param pointName point name.
|
||||
* @param formula string with formula length first arc.
|
||||
* @param arcId id arc in data container.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param initData init data.
|
||||
* @param typeCreation way we create this tool.
|
||||
*/
|
||||
VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
||||
VToolCutArc* VToolCutArc::Create(VToolCutArcInitData &initData)
|
||||
{
|
||||
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(arcId);
|
||||
const QSharedPointer<VArc> arc = initData.data->GeometricObject<VArc>(initData.arcId);
|
||||
|
||||
const qreal result = CheckFormula(_id, formula, data);
|
||||
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||
|
||||
VArc arc1;
|
||||
VArc arc2;
|
||||
QPointF point = arc->CutArc(qApp->toPixel(result), arc1, arc2);
|
||||
|
||||
quint32 id = _id;
|
||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
auto a1 = QSharedPointer<VArc>(new VArc(arc1));
|
||||
auto a2 = QSharedPointer<VArc>(new VArc(arc2));
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(p);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
a1->setId(VContainer::getNextId());
|
||||
a2->setId(VContainer::getNextId());
|
||||
data->AddArc(a1, a1->id(), id);
|
||||
data->AddArc(a2, a2->id(), id);
|
||||
initData.data->AddArc(a1, a1->id(), initData.id);
|
||||
initData.data->AddArc(a2, a2->id(), initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, p);
|
||||
a1->setId(id + 1);
|
||||
a2->setId(id + 2);
|
||||
data->AddArc(a1, a1->id(), id);
|
||||
data->AddArc(a2, a2->id(), id);
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
a1->setId(initData.id + 1);
|
||||
a2->setId(initData.id + 2);
|
||||
initData.data->AddArc(a1, a1->id(), initData.id);
|
||||
initData.data->AddArc(a2, a2->id(), initData.id);
|
||||
|
||||
if (parse != Document::FullParse)
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::CutArc, doc);
|
||||
VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(arc->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::CutArc, initData.doc);
|
||||
VToolCutArc *point = new VToolCutArc(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(arc->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -188,15 +179,11 @@ void VToolCutArc::ShowVisualization(bool show)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolCutArc::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogCutArc>(this, event);
|
||||
ContextMenu<DialogCutArc>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
@ -275,7 +262,8 @@ QString VToolCutArc::MakeToolTip() const
|
|||
auto ArcToolTip = [arcStr, lengthStr, startAngleStr, endAngleStr, radiusStr](QString toolTip, const VArc &arc,
|
||||
const QString &arcNumber)
|
||||
{
|
||||
toolTip += QString("<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
toolTip += QString("<tr> <td><b>%10:</b> %11</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7°</td> </tr>"
|
||||
"<tr> <td><b>%8:</b> %9°</td> </tr>")
|
||||
|
@ -287,7 +275,9 @@ QString VToolCutArc::MakeToolTip() const
|
|||
.arg(arcStr + arcNumber + QLatin1String(" ") + startAngleStr)
|
||||
.arg(qApp->fromPixel(arc.GetStartAngle()))
|
||||
.arg(arcStr + arcNumber + QLatin1String(" ") + endAngleStr)
|
||||
.arg(qApp->fromPixel(arc.GetEndAngle()));
|
||||
.arg(qApp->fromPixel(arc.GetEndAngle()))
|
||||
.arg(arcStr + arcNumber + QLatin1String(" ") + tr("label"))
|
||||
.arg(arc.name());
|
||||
return toolTip;
|
||||
};
|
||||
|
||||
|
|
|
@ -43,6 +43,18 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolCutArcInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolCutArcInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
formula(),
|
||||
arcId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formula;
|
||||
quint32 arcId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolCutArc class tool for cutting arc.
|
||||
*/
|
||||
|
@ -53,16 +65,14 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolCutArc* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolCutArc* Create(VToolCutArcInitData &initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::CutArc)};
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -71,8 +81,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolCutArc)
|
||||
|
||||
VToolCutArc(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
||||
const quint32 &arcId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolCutArc(const VToolCutArcInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLCUTARC_H
|
||||
|
|
|
@ -62,19 +62,13 @@ const QString VToolCutSpline::AttrSpline = QStringLiteral("spline");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolCutSpline constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param formula string with formula length first spline.
|
||||
* @param splineId id spline in data container.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolCutSpline::VToolCutSpline(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
||||
const quint32 &splineId, const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolCut(doc, data, id, formula, splineId, parent)
|
||||
VToolCutSpline::VToolCutSpline(const VToolCutSplineInitData &initData, QGraphicsItem *parent)
|
||||
:VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.splineId, parent)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -86,7 +80,7 @@ void VToolCutSpline::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogCutSpline> dialogTool = m_dialog.objectCast<DialogCutSpline>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFormula(formula);
|
||||
dialogTool->setSplineId(curveCutId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
|
@ -106,11 +100,18 @@ VToolCutSpline* VToolCutSpline::Create(QSharedPointer<DialogTool> dialog, VMainG
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogCutSpline> dialogTool = dialog.objectCast<DialogCutSpline>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
QString formula = dialogTool->GetFormula();
|
||||
const quint32 splineId = dialogTool->getSplineId();
|
||||
VToolCutSpline* point = Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse,
|
||||
Source::FromGui);
|
||||
|
||||
VToolCutSplineInitData initData;
|
||||
initData.formula = dialogTool->GetFormula();
|
||||
initData.splineId = dialogTool->getSplineId();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolCutSpline* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -121,61 +122,49 @@ VToolCutSpline* VToolCutSpline::Create(QSharedPointer<DialogTool> dialog, VMainG
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param pointName point name.
|
||||
* @param formula string with formula length first spline.
|
||||
* @param splineId id spline in data container.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula,
|
||||
const quint32 &splineId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolCutSpline* VToolCutSpline::Create(VToolCutSplineInitData &initData)
|
||||
{
|
||||
const auto spl = data->GeometricObject<VAbstractCubicBezier>(splineId);
|
||||
const auto spl = initData.data->GeometricObject<VAbstractCubicBezier>(initData.splineId);
|
||||
|
||||
const qreal result = CheckFormula(_id, formula, data);
|
||||
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||
|
||||
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
|
||||
QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
|
||||
|
||||
quint32 id = _id;
|
||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
auto spline1 = QSharedPointer<VAbstractBezier>(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p));
|
||||
auto spline2 = QSharedPointer<VAbstractBezier>(new VSpline(*p, spl2p2, spl2p3, spl->GetP4()));
|
||||
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(p);
|
||||
data->AddSpline(spline1, NULL_ID, id);
|
||||
data->AddSpline(spline2, NULL_ID, id);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddSpline(spline1, NULL_ID, initData.id);
|
||||
initData.data->AddSpline(spline2, NULL_ID, initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, p);
|
||||
data->AddSpline(spline1, NULL_ID, id);
|
||||
data->AddSpline(spline2, NULL_ID, id);
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddSpline(spline1, NULL_ID, initData.id);
|
||||
initData.data->AddSpline(spline2, NULL_ID, initData.id);
|
||||
|
||||
if (parse != Document::FullParse)
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::CutSpline, doc);
|
||||
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(spl->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::CutSpline, initData.doc);
|
||||
VToolCutSpline *point = new VToolCutSpline(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(spl->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -188,15 +177,11 @@ void VToolCutSpline::ShowVisualization(bool show)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolCutSpline::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogCutSpline>(this, event);
|
||||
ContextMenu<DialogCutSpline>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
@ -272,14 +257,20 @@ QString VToolCutSpline::MakeToolTip() const
|
|||
const QString lengthStr = tr("length");
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%6:</b> %7</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%8:</b> %9</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
|
||||
"</table>")
|
||||
.arg(curveStr + QLatin1String("1 ") + lengthStr)
|
||||
.arg(qApp->fromPixel(spline1.GetLength()))
|
||||
.arg(UnitsToStr(qApp->patternUnit(), true))
|
||||
.arg(curveStr + QLatin1String("2 ") + lengthStr)
|
||||
.arg(qApp->fromPixel(spline2.GetLength()));
|
||||
.arg(qApp->fromPixel(spline2.GetLength()))
|
||||
.arg(curveStr + QLatin1String(" 1") + tr("label"))
|
||||
.arg(spline1.name())
|
||||
.arg(curveStr + QLatin1String(" 2") + tr("label"))
|
||||
.arg(spline2.name());
|
||||
|
||||
return toolTip;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,18 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolCutSplineInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolCutSplineInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
formula(),
|
||||
splineId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formula;
|
||||
quint32 splineId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolCutSpline class for tool CutSpline. This tool find point on spline and cut spline on two.
|
||||
*/
|
||||
|
@ -53,18 +65,15 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolCutSpline *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula,
|
||||
const quint32 &splineId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolCutSpline *Create(VToolCutSplineInitData &initData);
|
||||
static const QString ToolType;
|
||||
static const QString AttrSpline;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::CutSpline)};
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -73,8 +82,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolCutSpline)
|
||||
|
||||
VToolCutSpline(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
||||
const quint32 &splineId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolCutSpline(const VToolCutSplineInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLCUTSPLINE_H
|
||||
|
|
|
@ -65,20 +65,13 @@ const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolCutSplinePath constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param formula string with formula length first splinePath.
|
||||
* @param splinePathId id splinePath (we cut this splinePath) in data container.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolCutSplinePath::VToolCutSplinePath(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
||||
const QString &formula, const quint32 &splinePathId,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolCut(doc, data, id, formula, splinePathId, parent)
|
||||
VToolCutSplinePath::VToolCutSplinePath(const VToolCutSplinePathInitData &initData, QGraphicsItem *parent)
|
||||
:VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.splinePathId, parent)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -90,7 +83,7 @@ void VToolCutSplinePath::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogCutSplinePath> dialogTool = m_dialog.objectCast<DialogCutSplinePath>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFormula(formula);
|
||||
dialogTool->setSplinePathId(curveCutId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
|
@ -110,11 +103,18 @@ VToolCutSplinePath* VToolCutSplinePath::Create(QSharedPointer<DialogTool> dialog
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogCutSplinePath> dialogTool = dialog.objectCast<DialogCutSplinePath>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
QString formula = dialogTool->GetFormula();
|
||||
const quint32 splinePathId = dialogTool->getSplinePathId();
|
||||
VToolCutSplinePath* point = Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data,
|
||||
Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolCutSplinePathInitData initData;
|
||||
initData.formula = dialogTool->GetFormula();
|
||||
initData.splinePathId = dialogTool->getSplinePathId();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolCutSplinePath* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -125,68 +125,55 @@ VToolCutSplinePath* VToolCutSplinePath::Create(QSharedPointer<DialogTool> dialog
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param pointName point name.
|
||||
* @param formula string with formula length first splinePath.
|
||||
* @param splinePathId id of splinePath in data container.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula,
|
||||
const quint32 &splinePathId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
||||
VToolCutSplinePath* VToolCutSplinePath::Create(VToolCutSplinePathInitData &initData)
|
||||
{
|
||||
const auto splPath = data->GeometricObject<VAbstractCubicBezierPath>(splinePathId);
|
||||
const auto splPath = initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.splinePathId);
|
||||
SCASSERT(splPath != nullptr)
|
||||
|
||||
const qreal result = CheckFormula(_id, formula, data);
|
||||
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||
|
||||
quint32 id = _id;
|
||||
VSplinePath *splPath1 = nullptr;
|
||||
VSplinePath *splPath2 = nullptr;
|
||||
VPointF *p = VToolCutSplinePath::CutSplinePath(qApp->toPixel(result), splPath, pointName, &splPath1, &splPath2);
|
||||
VPointF *p = VToolCutSplinePath::CutSplinePath(qApp->toPixel(result), splPath, initData.name, &splPath1, &splPath2);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
SCASSERT(splPath1 != nullptr)
|
||||
SCASSERT(splPath2 != nullptr)
|
||||
SCASSERT(p != nullptr)
|
||||
|
||||
p->setMx(mx);
|
||||
p->setMy(my);
|
||||
p->setMx(initData.mx);
|
||||
p->setMy(initData.my);
|
||||
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(p);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
|
||||
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, id);
|
||||
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, id);
|
||||
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, initData.id);
|
||||
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, p);
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
|
||||
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, id);
|
||||
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, id);
|
||||
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, initData.id);
|
||||
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, initData.id);
|
||||
|
||||
if (parse != Document::FullParse)
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::CutSplinePath, doc);
|
||||
VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(splPath->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::CutSplinePath, initData.doc);
|
||||
VToolCutSplinePath *point = new VToolCutSplinePath(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(splPath->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -275,15 +262,11 @@ VPointF *VToolCutSplinePath::CutSplinePath(qreal length, const QSharedPointer<VA
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolCutSplinePath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogCutSplinePath>(this, event);
|
||||
ContextMenu<DialogCutSplinePath>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
@ -358,14 +341,20 @@ QString VToolCutSplinePath::MakeToolTip() const
|
|||
const QString lengthStr = tr("length");
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%6:</b> %7</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%8:</b> %9</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
|
||||
"</table>")
|
||||
.arg(curveStr + QLatin1String("1 ") + lengthStr)
|
||||
.arg(qApp->fromPixel(splPath1->GetLength()))
|
||||
.arg(UnitsToStr(qApp->patternUnit(), true))
|
||||
.arg(curveStr + QLatin1String("2 ") + lengthStr)
|
||||
.arg(qApp->fromPixel(splPath2->GetLength()));
|
||||
.arg(qApp->fromPixel(splPath2->GetLength()))
|
||||
.arg(curveStr + QLatin1String(" 1") + tr("label"))
|
||||
.arg(splPath1->name())
|
||||
.arg(curveStr + QLatin1String(" 2") + tr("label"))
|
||||
.arg(splPath2->name());
|
||||
|
||||
delete splPath1;
|
||||
delete splPath2;
|
||||
|
|
|
@ -44,6 +44,18 @@
|
|||
class VSplinePath;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolCutSplinePathInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolCutSplinePathInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
formula(),
|
||||
splinePathId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formula;
|
||||
quint32 splinePathId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolCutSplinePath class for tool CutSplinePath. This tool find point on splinePath and cut splinePath on
|
||||
* two.
|
||||
|
@ -55,10 +67,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolCutSplinePath *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula,
|
||||
const quint32 &splinePathId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolCutSplinePath *Create(VToolCutSplinePathInitData &initData);
|
||||
static const QString ToolType;
|
||||
static const QString AttrSplinePath;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
@ -69,8 +78,9 @@ public:
|
|||
const QSharedPointer<VAbstractCubicBezierPath> &splPath,
|
||||
const QString &pName, VSplinePath **splPath1,
|
||||
VSplinePath **splPath2);
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -79,8 +89,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolCutSplinePath)
|
||||
|
||||
VToolCutSplinePath(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
||||
const quint32 &splinePathId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolCutSplinePath(const VToolCutSplinePathInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLCUTSPLINEPATH_H
|
||||
|
|
|
@ -71,32 +71,12 @@ const QString VToolAlongLine::ToolType = QStringLiteral("alongLine");
|
|||
* @param typeCreation way we create this tool.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolAlongLine::VToolAlongLine(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &formula,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const QString &typeLine, const QString &lineColor, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, 0, parent), secondPointId(secondPointId)
|
||||
VToolAlongLine::VToolAlongLine(const VToolAlongLineInitData &initData, QGraphicsItem *parent)
|
||||
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula,
|
||||
initData.firstPointId, 0, parent),
|
||||
secondPointId(initData.secondPointId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events. handle context menu event.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
//cppcheck-suppress unusedFunction
|
||||
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogAlongLine>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -168,12 +148,13 @@ QString VToolAlongLine::MakeToolTip() const
|
|||
{
|
||||
const QSharedPointer<VPointF> basePoint = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
|
||||
const QSharedPointer<VPointF> secondPoint = VAbstractTool::data.GeometricObject<VPointF>(secondPointId);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
|
||||
const QLineF curLine(static_cast<QPointF>(*basePoint), static_cast<QPointF>(*current));
|
||||
const QLineF curToSecond(static_cast<QPointF>(*current), static_cast<QPointF>(*secondPoint));
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%9:</b> %10</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5°</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %2 %3</td> </tr>"
|
||||
|
@ -186,7 +167,9 @@ QString VToolAlongLine::MakeToolTip() const
|
|||
.arg(curLine.angle())
|
||||
.arg(QString("%1->%2").arg(basePoint->name(), current->name()))
|
||||
.arg(QString("%1->%2").arg(current->name(), secondPoint->name()))
|
||||
.arg(qApp->fromPixel(curToSecond.length()));
|
||||
.arg(qApp->fromPixel(curToSecond.length()))
|
||||
.arg(tr("Label"))
|
||||
.arg(current->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
|
@ -203,7 +186,7 @@ void VToolAlongLine::SetSecondPointId(const quint32 &value)
|
|||
{
|
||||
secondPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -214,6 +197,20 @@ void VToolAlongLine::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolAlongLine>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolAlongLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogAlongLine>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setDialog set dialog when user want change tool option.
|
||||
|
@ -223,7 +220,7 @@ void VToolAlongLine::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogAlongLine> dialogTool = m_dialog.objectCast<DialogAlongLine>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetTypeLine(m_lineType);
|
||||
dialogTool->SetLineColor(lineColor);
|
||||
dialogTool->SetFormula(formulaLength);
|
||||
|
@ -246,14 +243,21 @@ VToolAlongLine* VToolAlongLine::Create(QSharedPointer<DialogTool> dialog, VMainG
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogAlongLine> dialogTool = dialog.objectCast<DialogAlongLine>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
QString formula = dialogTool->GetFormula();
|
||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
||||
const QString typeLine = dialogTool->GetTypeLine();
|
||||
const QString lineColor = dialogTool->GetLineColor();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolAlongLine *point = Create(0, pointName, typeLine, lineColor, formula, firstPointId, secondPointId,
|
||||
5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolAlongLineInitData initData;
|
||||
initData.formula = dialogTool->GetFormula();
|
||||
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||
initData.typeLine = dialogTool->GetTypeLine();
|
||||
initData.lineColor = dialogTool->GetLineColor();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolAlongLine *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -264,70 +268,55 @@ VToolAlongLine* VToolAlongLine::Create(QSharedPointer<DialogTool> dialog, VMainG
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param pointName point name. point name.
|
||||
* @param typeLine line type.
|
||||
* @param formula string with length formula.
|
||||
* @param firstPointId id first point of line.
|
||||
* @param secondPointId id second point of line.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &lineColor, QString &formula, const quint32 &firstPointId,
|
||||
const quint32 &secondPointId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolAlongLine* VToolAlongLine::Create(VToolAlongLineInitData &initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
||||
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||
QLineF line = QLineF(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
||||
|
||||
//Declare special variable "CurrentLength"
|
||||
VLengthLine *length = new VLengthLine(firstPoint.data(), firstPointId, secondPoint.data(),
|
||||
secondPointId, *data->GetPatternUnit());
|
||||
VLengthLine *length = new VLengthLine(firstPoint.data(), initData.firstPointId, secondPoint.data(),
|
||||
initData.secondPointId, *initData.data->GetPatternUnit());
|
||||
length->SetName(currentLength);
|
||||
data->AddVariable(currentLength, length);
|
||||
initData.data->AddVariable(currentLength, length);
|
||||
|
||||
line.setLength(qApp->toPixel(CheckFormula(_id, formula, data)));
|
||||
line.setLength(qApp->toPixel(CheckFormula(initData.id, initData.formula, initData.data)));
|
||||
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
VPointF *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject( new VPointF(line.p2(), pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(id, secondPointId);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||
initData.data->AddLine(initData.id, initData.secondPointId);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(line.p2(), pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(id, secondPointId);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||
initData.data->AddLine(initData.id, initData.secondPointId);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
VToolAlongLine *point = nullptr;
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::AlongLine, doc);
|
||||
point = new VToolAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine, lineColor,
|
||||
typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(firstPoint->getIdTool());
|
||||
doc->IncrementReferens(secondPoint->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::AlongLine, initData.doc);
|
||||
point = new VToolAlongLine(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||
}
|
||||
//Very important to delete it. Only this tool need this special variable.
|
||||
data->RemoveVariable(currentLength);
|
||||
initData.data->RemoveVariable(currentLength);
|
||||
return point;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,20 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolAlongLineInitData : public VToolLinePointInitData
|
||||
{
|
||||
VToolAlongLineInitData()
|
||||
: VToolLinePointInitData(),
|
||||
formula("100.0"),
|
||||
firstPointId(NULL_ID),
|
||||
secondPointId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formula;
|
||||
quint32 firstPointId;
|
||||
quint32 secondPointId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolAlongLine class tool for creation point along line.
|
||||
*/
|
||||
|
@ -53,12 +67,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolAlongLine* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &lineColor, QString &formula, const quint32 &firstPointId,
|
||||
const quint32 &secondPointId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolAlongLine* Create(VToolAlongLineInitData &initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::AlongLine)};
|
||||
|
@ -68,8 +77,9 @@ public:
|
|||
quint32 GetSecondPointId() const;
|
||||
void SetSecondPointId(const quint32 &value);
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -82,10 +92,7 @@ private:
|
|||
/** @brief secondPointId id second point of line. */
|
||||
quint32 secondPointId;
|
||||
|
||||
VToolAlongLine(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &formula,
|
||||
const quint32 &firstPointId,
|
||||
const quint32 &secondPointId, const QString &typeLine, const QString &lineColor,
|
||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolAlongLine(const VToolAlongLineInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLALONGLINE_H
|
||||
|
|
|
@ -59,25 +59,15 @@ const QString VToolBisector::ToolType = QStringLiteral("bisector");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolBisector constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param typeLine line type.
|
||||
* @param formula string with formula length of bisector.
|
||||
* @param firstPointId id first point of angle.
|
||||
* @param secondPointId id second point of angle.
|
||||
* @param thirdPointId id third point of angle.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param parent parent object.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolBisector::VToolBisector(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor, const QString &formula, const quint32 &firstPointId,
|
||||
const quint32 &secondPointId, const quint32 &thirdPointId, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, secondPointId, 0, parent), firstPointId(firstPointId),
|
||||
thirdPointId(thirdPointId)
|
||||
VToolBisector::VToolBisector(const VToolBisectorInitData &initData, QGraphicsItem *parent)
|
||||
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula,
|
||||
initData.secondPointId, 0, parent),
|
||||
firstPointId(initData.firstPointId),
|
||||
thirdPointId(initData.thirdPointId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -124,7 +114,7 @@ void VToolBisector::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogBisector> dialogTool = m_dialog.objectCast<DialogBisector>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetTypeLine(m_lineType);
|
||||
dialogTool->SetLineColor(lineColor);
|
||||
dialogTool->SetFormula(formulaLength);
|
||||
|
@ -148,15 +138,22 @@ VToolBisector* VToolBisector::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogBisector> dialogTool = dialog.objectCast<DialogBisector>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
QString formula = dialogTool->GetFormula();
|
||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
||||
const quint32 thirdPointId = dialogTool->GetThirdPointId();
|
||||
const QString typeLine = dialogTool->GetTypeLine();
|
||||
const QString lineColor = dialogTool->GetLineColor();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolBisector *point = Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, lineColor,
|
||||
pointName, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolBisectorInitData initData;
|
||||
initData.formula = dialogTool->GetFormula();
|
||||
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||
initData.thirdPointId = dialogTool->GetThirdPointId();
|
||||
initData.typeLine = dialogTool->GetTypeLine();
|
||||
initData.lineColor = dialogTool->GetLineColor();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolBisector *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -167,63 +164,47 @@ VToolBisector* VToolBisector::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param formula string with formula.
|
||||
* @param firstPointId id first point of angle.
|
||||
* @param secondPointId id second point of angle.
|
||||
* @param thirdPointId id third point of angle.
|
||||
* @param typeLine line type.
|
||||
* @param pointName point name.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
|
||||
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
|
||||
const QString &lineColor, const QString &pointName, const qreal &mx,
|
||||
const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolBisector* VToolBisector::Create(VToolBisectorInitData &initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
||||
const QSharedPointer<VPointF> thirdPoint = data->GeometricObject<VPointF>(thirdPointId);
|
||||
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||
const QSharedPointer<VPointF> thirdPoint = initData.data->GeometricObject<VPointF>(initData.thirdPointId);
|
||||
|
||||
const qreal result = CheckFormula(_id, formula, data);
|
||||
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||
|
||||
QPointF fPoint = VToolBisector::FindPoint(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint),
|
||||
static_cast<QPointF>(*thirdPoint), qApp->toPixel(result));
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
|
||||
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(secondPointId, id);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddLine(initData.secondPointId, initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(secondPointId, id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddLine(initData.secondPointId, initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::Bisector, doc);
|
||||
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, lineColor, formula, firstPointId,
|
||||
secondPointId, thirdPointId, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(firstPoint->getIdTool());
|
||||
doc->IncrementReferens(secondPoint->getIdTool());
|
||||
doc->IncrementReferens(thirdPoint->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::Bisector, initData.doc);
|
||||
VToolBisector *point = new VToolBisector(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||
initData.doc->IncrementReferens(thirdPoint->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -241,24 +222,6 @@ QString VToolBisector::ThirdPointName() const
|
|||
return VAbstractTool::data.GetGObject(thirdPointId)->name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogBisector>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RemoveReferens decrement value of reference.
|
||||
|
@ -344,7 +307,7 @@ void VToolBisector::SetThirdPointId(const quint32 &value)
|
|||
{
|
||||
thirdPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -355,6 +318,20 @@ void VToolBisector::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolBisector>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolBisector::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogBisector>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolBisector::GetFirstPointId() const
|
||||
{
|
||||
|
@ -368,7 +345,7 @@ void VToolBisector::SetFirstPointId(const quint32 &value)
|
|||
{
|
||||
firstPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,22 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolBisectorInitData : public VToolLinePointInitData
|
||||
{
|
||||
VToolBisectorInitData()
|
||||
: VToolLinePointInitData(),
|
||||
formula("100.0"),
|
||||
firstPointId(NULL_ID),
|
||||
secondPointId(NULL_ID),
|
||||
thirdPointId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formula;
|
||||
quint32 firstPointId;
|
||||
quint32 secondPointId;
|
||||
quint32 thirdPointId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolBisector class tool for creation bisector point.
|
||||
*/
|
||||
|
@ -57,12 +73,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolBisector* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolBisector* Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
|
||||
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
|
||||
const QString &lineColor, const QString &pointName, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolBisector* Create(VToolBisectorInitData &initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::Bisector)};
|
||||
|
@ -77,8 +88,9 @@ public:
|
|||
void SetThirdPointId(const quint32 &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -93,10 +105,7 @@ private:
|
|||
/** @brief thirdPointId id third point of angle. */
|
||||
quint32 thirdPointId;
|
||||
|
||||
VToolBisector(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor,
|
||||
const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const quint32 &thirdPointId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolBisector(const VToolBisectorInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLBISECTOR_H
|
||||
|
|
|
@ -70,15 +70,14 @@ template <class T> class QSharedPointer;
|
|||
const QString VToolCurveIntersectAxis::ToolType = QStringLiteral("curveIntersectAxis");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolCurveIntersectAxis::VToolCurveIntersectAxis(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
||||
const QString &typeLine, const QString &lineColor,
|
||||
const QString &formulaAngle, const quint32 &basePointId,
|
||||
const quint32 &curveId, const Source &typeCreation,
|
||||
VToolCurveIntersectAxis::VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData,
|
||||
QGraphicsItem *parent)
|
||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle),
|
||||
curveId(curveId)
|
||||
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(),
|
||||
initData.basePointId, 0, parent),
|
||||
formulaAngle(initData.formulaAngle),
|
||||
curveId(initData.curveId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -88,7 +87,7 @@ void VToolCurveIntersectAxis::setDialog()
|
|||
m_dialog->setModal(true);
|
||||
QSharedPointer<DialogCurveIntersectAxis> dialogTool = m_dialog.objectCast<DialogCurveIntersectAxis>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetTypeLine(m_lineType);
|
||||
dialogTool->SetLineColor(lineColor);
|
||||
dialogTool->SetAngle(formulaAngle);
|
||||
|
@ -105,15 +104,21 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(QSharedPointer<DialogTo
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogCurveIntersectAxis> dialogTool = dialog.objectCast<DialogCurveIntersectAxis>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
const QString typeLine = dialogTool->GetTypeLine();
|
||||
const QString lineColor = dialogTool->GetLineColor();
|
||||
QString formulaAngle = dialogTool->GetAngle();
|
||||
const quint32 basePointId = dialogTool->GetBasePointId();
|
||||
const quint32 curveId = dialogTool->getCurveId();
|
||||
|
||||
VToolCurveIntersectAxis *point = Create(0, pointName, typeLine, lineColor, formulaAngle, basePointId,
|
||||
curveId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
VToolCurveIntersectAxisInitData initData;
|
||||
initData.formulaAngle = dialogTool->GetAngle();
|
||||
initData.basePointId = dialogTool->GetBasePointId();
|
||||
initData.curveId = dialogTool->getCurveId();
|
||||
initData.typeLine = dialogTool->GetTypeLine();
|
||||
initData.lineColor = dialogTool->GetLineColor();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolCurveIntersectAxis *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -122,54 +127,49 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(QSharedPointer<DialogTo
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, const QString &pointName,
|
||||
const QString &typeLine, const QString &lineColor,
|
||||
QString &formulaAngle, const quint32 &basePointId,
|
||||
const quint32 &curveId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxisInitData &initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
|
||||
const qreal angle = CheckFormula(_id, formulaAngle, data);
|
||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(curveId);
|
||||
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
|
||||
const qreal angle = CheckFormula(initData.id, initData.formulaAngle, initData.data);
|
||||
const QSharedPointer<VAbstractCurve> curve = initData.data->GeometricObject<VAbstractCurve>(initData.curveId);
|
||||
|
||||
const QPointF fPoint = FindPoint(static_cast<QPointF>(*basePoint), angle, curve);
|
||||
const qreal segLength = curve->GetLengthByPoint(fPoint);
|
||||
quint32 id = _id;
|
||||
VPointF *p = new VPointF(fPoint, pointName, mx, my);
|
||||
if (typeCreation == Source::FromGui)
|
||||
|
||||
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(p);
|
||||
data->AddLine(basePointId, id);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddLine(initData.basePointId, initData.id);
|
||||
|
||||
VContainer::getNextId();
|
||||
VContainer::getNextId();
|
||||
InitSegments(curve->getType(), segLength, p, curveId, data);
|
||||
InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, p);
|
||||
data->AddLine(basePointId, id);
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddLine(initData.basePointId, initData.id);
|
||||
|
||||
InitSegments(curve->getType(), segLength, p, curveId, data);
|
||||
InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data);
|
||||
|
||||
if (parse != Document::FullParse)
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::CurveIntersectAxis, doc);
|
||||
VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle,
|
||||
basePointId, curveId, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(basePoint->getIdTool());
|
||||
doc->IncrementReferens(curve->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::CurveIntersectAxis, initData.doc);
|
||||
VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(basePoint->getIdTool());
|
||||
initData.doc->IncrementReferens(curve->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -214,7 +214,7 @@ VFormula VToolCurveIntersectAxis::GetFormulaAngle() const
|
|||
{
|
||||
VFormula fAngle(formulaAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(id);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
return fAngle;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ void VToolCurveIntersectAxis::SetFormulaAngle(const VFormula &value)
|
|||
{
|
||||
formulaAngle = value.GetFormula(FormulaType::FromUser);
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ void VToolCurveIntersectAxis::setCurveId(const quint32 &value)
|
|||
{
|
||||
curveId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -262,11 +262,11 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCurveIntersectAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolCurveIntersectAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogCurveIntersectAxis>(this, event);
|
||||
ContextMenu<DialogCurveIntersectAxis>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,20 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolCurveIntersectAxisInitData : public VToolLinePointInitData
|
||||
{
|
||||
VToolCurveIntersectAxisInitData()
|
||||
: VToolLinePointInitData(),
|
||||
formulaAngle("0"),
|
||||
basePointId(NULL_ID),
|
||||
curveId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formulaAngle;
|
||||
quint32 basePointId;
|
||||
quint32 curveId;
|
||||
};
|
||||
|
||||
class VToolCurveIntersectAxis : public VToolLinePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -55,11 +69,7 @@ public:
|
|||
|
||||
static VToolCurveIntersectAxis *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolCurveIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &lineColor, QString &formulaAngle, const quint32 &basePointId,
|
||||
const quint32 &curveId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolCurveIntersectAxis *Create(VToolCurveIntersectAxisInitData &initData);
|
||||
|
||||
static QPointF FindPoint(const QPointF &point, qreal angle, const QSharedPointer<VAbstractCurve> &curve);
|
||||
|
||||
|
@ -76,8 +86,9 @@ public:
|
|||
void setCurveId(const quint32 &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -87,9 +98,7 @@ private:
|
|||
QString formulaAngle;
|
||||
quint32 curveId;
|
||||
|
||||
VToolCurveIntersectAxis(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor, const QString &formulaAngle, const quint32 &basePointId,
|
||||
const quint32 &curveId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
|
||||
template <class Item>
|
||||
static void InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId);
|
||||
|
|
|
@ -59,23 +59,15 @@ const QString VToolEndLine::ToolType = QStringLiteral("endLine");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolEndLine constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param typeLine line type.
|
||||
* @param formulaLength string with formula length of line.
|
||||
* @param formulaAngle formula angle of line.
|
||||
* @param basePointId id first point of line.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolEndLine::VToolEndLine(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor, const QString &formulaLength, const QString &formulaAngle,
|
||||
const quint32 &basePointId, const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, formulaLength, basePointId, 0, parent),
|
||||
formulaAngle(formulaAngle)
|
||||
VToolEndLine::VToolEndLine(const VToolEndLineInitData &initData, QGraphicsItem *parent)
|
||||
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor,
|
||||
initData.formulaLength, initData.basePointId, 0, parent),
|
||||
formulaAngle(initData.formulaAngle)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -88,7 +80,7 @@ void VToolEndLine::setDialog()
|
|||
m_dialog->setModal(true);
|
||||
QSharedPointer<DialogEndLine> dialogTool = m_dialog.objectCast<DialogEndLine>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetTypeLine(m_lineType);
|
||||
dialogTool->SetLineColor(lineColor);
|
||||
dialogTool->SetFormula(formulaLength);
|
||||
|
@ -112,15 +104,21 @@ VToolEndLine* VToolEndLine::Create(QSharedPointer<DialogTool> dialog, VMainGraph
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogEndLine> dialogTool = dialog.objectCast<DialogEndLine>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
const QString typeLine = dialogTool->GetTypeLine();
|
||||
const QString lineColor = dialogTool->GetLineColor();
|
||||
QString formulaLength = dialogTool->GetFormula();
|
||||
QString formulaAngle = dialogTool->GetAngle();
|
||||
const quint32 basePointId = dialogTool->GetBasePointId();
|
||||
|
||||
VToolEndLine *point = Create(0, pointName, typeLine, lineColor, formulaLength, formulaAngle,
|
||||
basePointId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
VToolEndLineInitData initData;
|
||||
initData.formulaLength = dialogTool->GetFormula();
|
||||
initData.formulaAngle = dialogTool->GetAngle();
|
||||
initData.basePointId = dialogTool->GetBasePointId();
|
||||
initData.typeLine = dialogTool->GetTypeLine();
|
||||
initData.lineColor = dialogTool->GetLineColor();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolEndLine *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -131,82 +129,47 @@ VToolEndLine* VToolEndLine::Create(QSharedPointer<DialogTool> dialog, VMainGraph
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param pointName point name.
|
||||
* @param typeLine line type.
|
||||
* @param lineColor line color.
|
||||
* @param formulaLength string with formula length of line.
|
||||
* @param formulaAngle formula angle of line.
|
||||
* @param basePointId id first point of line.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @return the created tool
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &lineColor, QString &formulaLength, QString &formulaAngle,
|
||||
const quint32 &basePointId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolEndLine* VToolEndLine::Create(VToolEndLineInitData &initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
|
||||
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
|
||||
QLineF line = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x()+100, basePoint->y()));
|
||||
|
||||
line.setAngle(CheckFormula(_id, formulaAngle, data)); //First set angle.
|
||||
line.setLength(qApp->toPixel(CheckFormula(_id, formulaLength, data)));
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
line.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data)); //First set angle.
|
||||
line.setLength(qApp->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data)));
|
||||
|
||||
VPointF *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(line.p2(), pointName, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddLine(initData.basePointId, initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(line.p2(), pointName, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddLine(initData.basePointId, initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::EndLine, doc);
|
||||
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, lineColor, formulaLength, formulaAngle,
|
||||
basePointId, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(basePoint->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::EndLine, initData.doc);
|
||||
VToolEndLine *point = new VToolEndLine(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(basePoint->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogEndLine>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SaveDialog save options into file after change in dialog.
|
||||
|
@ -266,7 +229,7 @@ VFormula VToolEndLine::GetFormulaAngle() const
|
|||
{
|
||||
VFormula fAngle(formulaAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(id);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
return fAngle;
|
||||
}
|
||||
|
@ -278,7 +241,7 @@ void VToolEndLine::SetFormulaAngle(const VFormula &value)
|
|||
{
|
||||
formulaAngle = value.GetFormula(FormulaType::FromUser);
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -288,3 +251,17 @@ void VToolEndLine::ShowVisualization(bool show)
|
|||
{
|
||||
ShowToolVisualization<VisToolEndLine>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolEndLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogEndLine>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,20 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolEndLineInitData : public VToolLinePointInitData
|
||||
{
|
||||
VToolEndLineInitData()
|
||||
: VToolLinePointInitData(),
|
||||
formulaLength(),
|
||||
formulaAngle(),
|
||||
basePointId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formulaLength;
|
||||
QString formulaAngle;
|
||||
quint32 basePointId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolEndLine class tool for creation point on the line end.
|
||||
*/
|
||||
|
@ -55,12 +69,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolEndLine *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &lineColor, QString &formulaLength, QString &formulaAngle,
|
||||
const quint32 &basePointId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolEndLine *Create(VToolEndLineInitData &initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::EndLine)};
|
||||
|
@ -68,8 +77,9 @@ public:
|
|||
VFormula GetFormulaAngle() const;
|
||||
void SetFormulaAngle(const VFormula &value);
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -79,10 +89,7 @@ private:
|
|||
|
||||
QString formulaAngle;
|
||||
|
||||
VToolEndLine(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor,
|
||||
const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId,
|
||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolEndLine(const VToolEndLineInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLENDLINE_H
|
||||
|
|
|
@ -55,23 +55,16 @@ const QString VToolHeight::ToolType = QStringLiteral("height");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolHeight constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param typeLine line type.
|
||||
* @param basePointId id base point of projection.
|
||||
* @param p1LineId id first point of line.
|
||||
* @param p2LineId id second point of line.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolHeight::VToolHeight(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId,
|
||||
const quint32 &p2LineId, const Source &typeCreation, QGraphicsItem * parent)
|
||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), p1LineId(p1LineId),
|
||||
p2LineId(p2LineId)
|
||||
VToolHeight::VToolHeight(const VToolHeightInitData &initData, QGraphicsItem * parent)
|
||||
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(),
|
||||
initData.basePointId, 0, parent),
|
||||
p1LineId(initData.p1LineId),
|
||||
p2LineId(initData.p2LineId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -83,7 +76,7 @@ void VToolHeight::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogHeight> dialogTool = m_dialog.objectCast<DialogHeight>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetTypeLine(m_lineType);
|
||||
dialogTool->SetLineColor(lineColor);
|
||||
dialogTool->SetBasePointId(basePointId);
|
||||
|
@ -107,15 +100,21 @@ VToolHeight* VToolHeight::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogHeight> dialogTool = dialog.objectCast<DialogHeight>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
const QString typeLine = dialogTool->GetTypeLine();
|
||||
const QString lineColor = dialogTool->GetLineColor();
|
||||
const quint32 basePointId = dialogTool->GetBasePointId();
|
||||
const quint32 p1LineId = dialogTool->GetP1LineId();
|
||||
const quint32 p2LineId = dialogTool->GetP2LineId();
|
||||
|
||||
VToolHeight *point = Create(0, pointName, typeLine, lineColor, basePointId, p1LineId, p2LineId, 5, 10, scene, doc,
|
||||
data, Document::FullParse, Source::FromGui);
|
||||
VToolHeightInitData initData;
|
||||
initData.basePointId = dialogTool->GetBasePointId();
|
||||
initData.p1LineId = dialogTool->GetP1LineId();
|
||||
initData.p2LineId = dialogTool->GetP2LineId();
|
||||
initData.typeLine = dialogTool->GetTypeLine();
|
||||
initData.lineColor = dialogTool->GetLineColor();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolHeight *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -126,64 +125,49 @@ VToolHeight* VToolHeight::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param pointName point name.
|
||||
* @param typeLine line type.
|
||||
* @param basePointId id base point of projection.
|
||||
* @param p1LineId id first point of line.
|
||||
* @param p2LineId id second point of line.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @return the created tool
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId,
|
||||
const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolHeight* VToolHeight::Create(VToolHeightInitData initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
|
||||
const QSharedPointer<VPointF> p1Line = data->GeometricObject<VPointF>(p1LineId);
|
||||
const QSharedPointer<VPointF> p2Line = data->GeometricObject<VPointF>(p2LineId);
|
||||
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
|
||||
const QSharedPointer<VPointF> p1Line = initData.data->GeometricObject<VPointF>(initData.p1LineId);
|
||||
const QSharedPointer<VPointF> p2Line = initData.data->GeometricObject<VPointF>(initData.p2LineId);
|
||||
|
||||
QPointF pHeight = FindPoint(QLineF(static_cast<QPointF>(*p1Line), static_cast<QPointF>(*p2Line)),
|
||||
static_cast<QPointF>(*basePoint));
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
|
||||
VPointF *p = new VPointF(pHeight, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(pHeight, pointName, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
data->AddLine(p1LineId, id);
|
||||
data->AddLine(p2LineId, id);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddLine(initData.basePointId, initData.id);
|
||||
initData.data->AddLine(initData.p1LineId, initData.id);
|
||||
initData.data->AddLine(initData.p2LineId, initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(pHeight, pointName, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
data->AddLine(p1LineId, id);
|
||||
data->AddLine(p2LineId, id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddLine(initData.basePointId, initData.id);
|
||||
initData.data->AddLine(initData.p1LineId, initData.id);
|
||||
initData.data->AddLine(initData.p2LineId, initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::Height, doc);
|
||||
VToolHeight *point = new VToolHeight(doc, data, id, typeLine, lineColor, basePointId, p1LineId, p2LineId,
|
||||
typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(basePoint->getIdTool());
|
||||
doc->IncrementReferens(p1Line->getIdTool());
|
||||
doc->IncrementReferens(p2Line->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::Height, initData.doc);
|
||||
VToolHeight *point = new VToolHeight(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(basePoint->getIdTool());
|
||||
initData.doc->IncrementReferens(p1Line->getIdTool());
|
||||
initData.doc->IncrementReferens(p2Line->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -213,24 +197,6 @@ QString VToolHeight::SecondLinePointName() const
|
|||
return VAbstractTool::data.GetGObject(p2LineId)->name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogHeight>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SaveDialog save options into file after change in dialog.
|
||||
|
@ -291,13 +257,14 @@ QString VToolHeight::MakeToolTip() const
|
|||
const QSharedPointer<VPointF> basePoint = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
|
||||
const QSharedPointer<VPointF> p1Line = VAbstractTool::data.GeometricObject<VPointF>(p1LineId);
|
||||
const QSharedPointer<VPointF> p2Line = VAbstractTool::data.GeometricObject<VPointF>(p2LineId);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
|
||||
const QLineF curLine(static_cast<QPointF>(*basePoint), static_cast<QPointF>(*current));
|
||||
const QLineF p1ToCur(static_cast<QPointF>(*p1Line), static_cast<QPointF>(*current));
|
||||
const QLineF p2ToCur(static_cast<QPointF>(*p2Line), static_cast<QPointF>(*current));
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%10:</b> %11</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5°</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
|
||||
|
@ -311,7 +278,9 @@ QString VToolHeight::MakeToolTip() const
|
|||
.arg(QString("%1->%2").arg(p1Line->name(), current->name()))
|
||||
.arg(qApp->fromPixel(p1ToCur.length()))
|
||||
.arg(QString("%1->%2").arg(p2Line->name(), current->name()))
|
||||
.arg(qApp->fromPixel(p2ToCur.length()));
|
||||
.arg(qApp->fromPixel(p2ToCur.length()))
|
||||
.arg(tr("Label"))
|
||||
.arg(current->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
|
@ -328,7 +297,7 @@ void VToolHeight::SetP2LineId(const quint32 &value)
|
|||
{
|
||||
p2LineId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -339,6 +308,20 @@ void VToolHeight::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolHeight>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolHeight::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogHeight>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolHeight::GetP1LineId() const
|
||||
{
|
||||
|
@ -352,7 +335,7 @@ void VToolHeight::SetP1LineId(const quint32 &value)
|
|||
{
|
||||
p1LineId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,20 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolHeightInitData : public VToolLinePointInitData
|
||||
{
|
||||
VToolHeightInitData()
|
||||
: VToolLinePointInitData(),
|
||||
basePointId(NULL_ID),
|
||||
p1LineId(NULL_ID),
|
||||
p2LineId(NULL_ID)
|
||||
{}
|
||||
|
||||
quint32 basePointId;
|
||||
quint32 p1LineId;
|
||||
quint32 p2LineId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolHeight class tool for creation point of height. Help find point of projection onto line.
|
||||
*/
|
||||
|
@ -55,11 +69,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolHeight *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolHeight *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId,
|
||||
const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolHeight *Create(VToolHeightInitData initData);
|
||||
static QPointF FindPoint(const QLineF &line, const QPointF &point);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
@ -75,8 +85,9 @@ public:
|
|||
void SetP2LineId(const quint32 &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -91,10 +102,7 @@ private:
|
|||
/** @brief p2LineId id second point of line. */
|
||||
quint32 p2LineId;
|
||||
|
||||
VToolHeight(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor,
|
||||
const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId,
|
||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolHeight(const VToolHeightInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLHEIGHT_H
|
||||
|
|
|
@ -56,15 +56,14 @@ template <class T> class QSharedPointer;
|
|||
const QString VToolLineIntersectAxis::ToolType = QStringLiteral("lineIntersectAxis");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolLineIntersectAxis::VToolLineIntersectAxis(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
||||
const QString &typeLine, const QString &lineColor,
|
||||
const QString &formulaAngle, const quint32 &basePointId,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle),
|
||||
firstPointId(firstPointId), secondPointId(secondPointId)
|
||||
VToolLineIntersectAxis::VToolLineIntersectAxis(const VToolLineIntersectAxisInitData &initData, QGraphicsItem *parent)
|
||||
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(),
|
||||
initData.basePointId, 0, parent),
|
||||
formulaAngle(initData.formulaAngle),
|
||||
firstPointId(initData.firstPointId),
|
||||
secondPointId(initData.secondPointId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -74,7 +73,7 @@ void VToolLineIntersectAxis::setDialog()
|
|||
m_dialog->setModal(true);
|
||||
QSharedPointer<DialogLineIntersectAxis> dialogTool = m_dialog.objectCast<DialogLineIntersectAxis>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetTypeLine(m_lineType);
|
||||
dialogTool->SetLineColor(lineColor);
|
||||
dialogTool->SetAngle(formulaAngle);
|
||||
|
@ -91,17 +90,22 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(QSharedPointer<DialogTool
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogLineIntersectAxis> dialogTool = dialog.objectCast<DialogLineIntersectAxis>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
const QString typeLine = dialogTool->GetTypeLine();
|
||||
const QString lineColor = dialogTool->GetLineColor();
|
||||
QString formulaAngle = dialogTool->GetAngle();
|
||||
const quint32 basePointId = dialogTool->GetBasePointId();
|
||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
||||
|
||||
VToolLineIntersectAxis *point = Create(0, pointName, typeLine, lineColor, formulaAngle,
|
||||
basePointId, firstPointId, secondPointId, 5, 10,
|
||||
scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
VToolLineIntersectAxisInitData initData;
|
||||
initData.formulaAngle = dialogTool->GetAngle();
|
||||
initData.basePointId = dialogTool->GetBasePointId();
|
||||
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||
initData.typeLine = dialogTool->GetTypeLine();
|
||||
initData.lineColor = dialogTool->GetLineColor();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolLineIntersectAxis *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -110,55 +114,50 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(QSharedPointer<DialogTool
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const QString &pointName,
|
||||
const QString &typeLine, const QString &lineColor,
|
||||
QString &formulaAngle, const quint32 &basePointId,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolLineIntersectAxis *VToolLineIntersectAxis::Create(VToolLineIntersectAxisInitData &initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
|
||||
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
|
||||
QLineF axis = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x()+100, basePoint->y()));
|
||||
axis.setAngle(CheckFormula(_id, formulaAngle, data));
|
||||
axis.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data));
|
||||
|
||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
||||
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||
QLineF line(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
||||
|
||||
QPointF fPoint = FindPoint(axis, line);
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
|
||||
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(id, secondPointId);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddLine(initData.basePointId, initData.id);
|
||||
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||
initData.data->AddLine(initData.id, initData.secondPointId);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(id, secondPointId);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddLine(initData.basePointId, initData.id);
|
||||
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||
initData.data->AddLine(initData.id, initData.secondPointId);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::LineIntersectAxis, doc);
|
||||
VToolLineIntersectAxis *point = new VToolLineIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle,
|
||||
basePointId, firstPointId, secondPointId,
|
||||
typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(basePoint->getIdTool());
|
||||
doc->IncrementReferens(firstPoint->getIdTool());
|
||||
doc->IncrementReferens(secondPoint->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::LineIntersectAxis, initData.doc);
|
||||
VToolLineIntersectAxis *point = new VToolLineIntersectAxis(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(basePoint->getIdTool());
|
||||
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -204,7 +203,7 @@ VFormula VToolLineIntersectAxis::GetFormulaAngle() const
|
|||
{
|
||||
VFormula fAngle(formulaAngle, getData());
|
||||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(id);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
return fAngle;
|
||||
}
|
||||
|
@ -216,7 +215,7 @@ void VToolLineIntersectAxis::SetFormulaAngle(const VFormula &value)
|
|||
{
|
||||
formulaAngle = value.GetFormula(FormulaType::FromUser);
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +233,7 @@ void VToolLineIntersectAxis::SetFirstPointId(const quint32 &value)
|
|||
{
|
||||
firstPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +251,7 @@ void VToolLineIntersectAxis::SetSecondPointId(const quint32 &value)
|
|||
{
|
||||
secondPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -264,11 +263,11 @@ void VToolLineIntersectAxis::ShowVisualization(bool show)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLineIntersectAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolLineIntersectAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogLineIntersectAxis>(this, event);
|
||||
ContextMenu<DialogLineIntersectAxis>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
@ -338,13 +337,14 @@ QString VToolLineIntersectAxis::MakeToolTip() const
|
|||
const QSharedPointer<VPointF> basePoint = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
|
||||
const QSharedPointer<VPointF> firstPoint = VAbstractTool::data.GeometricObject<VPointF>(firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = VAbstractTool::data.GeometricObject<VPointF>(secondPointId);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
|
||||
const QLineF curLine(static_cast<QPointF>(*basePoint), static_cast<QPointF>(*current));
|
||||
const QLineF firstToCur(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*current));
|
||||
const QLineF curToSecond(static_cast<QPointF>(*current), static_cast<QPointF>(*secondPoint));
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%10:</b> %11</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5°</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
|
||||
|
@ -358,6 +358,8 @@ QString VToolLineIntersectAxis::MakeToolTip() const
|
|||
.arg(QString("%1->%2").arg(firstPoint->name(), current->name()))
|
||||
.arg(qApp->fromPixel(firstToCur.length()))
|
||||
.arg(QString("%1->%2").arg(current->name(), secondPoint->name()))
|
||||
.arg(qApp->fromPixel(curToSecond.length()));
|
||||
.arg(qApp->fromPixel(curToSecond.length()))
|
||||
.arg(tr("Label"))
|
||||
.arg(current->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,22 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolLineIntersectAxisInitData : public VToolLinePointInitData
|
||||
{
|
||||
VToolLineIntersectAxisInitData()
|
||||
: VToolLinePointInitData(),
|
||||
formulaAngle("0"),
|
||||
basePointId(NULL_ID),
|
||||
firstPointId(NULL_ID),
|
||||
secondPointId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formulaAngle;
|
||||
quint32 basePointId;
|
||||
quint32 firstPointId;
|
||||
quint32 secondPointId;
|
||||
};
|
||||
|
||||
class VToolLineIntersectAxis : public VToolLinePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -55,12 +71,7 @@ public:
|
|||
|
||||
static VToolLineIntersectAxis *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolLineIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &lineColor, QString &formulaAngle, const quint32 &basePointId,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation);
|
||||
static VToolLineIntersectAxis *Create(VToolLineIntersectAxisInitData &initData);
|
||||
|
||||
static QPointF FindPoint(const QLineF &axis, const QLineF &line);
|
||||
|
||||
|
@ -81,8 +92,9 @@ public:
|
|||
void SetSecondPointId(const quint32 &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -95,10 +107,7 @@ private:
|
|||
quint32 firstPointId;
|
||||
quint32 secondPointId;
|
||||
|
||||
VToolLineIntersectAxis(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor, const QString &formulaAngle, const quint32 &basePointId,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
VToolLineIntersectAxis(const VToolLineIntersectAxisInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLLINEINTERSECTAXIS_H
|
||||
|
|
|
@ -104,8 +104,8 @@ void VToolLinePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
|||
*/
|
||||
void VToolLinePoint::RefreshGeometry()
|
||||
{
|
||||
VToolSinglePoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
QPointF point = static_cast<QPointF>(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
VToolSinglePoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(m_id));
|
||||
QPointF point = static_cast<QPointF>(*VDrawTool::data.GeometricObject<VPointF>(m_id));
|
||||
QPointF basePoint = static_cast<QPointF>(*VDrawTool::data.GeometricObject<VPointF>(basePointId));
|
||||
mainLine->setLine(QLineF(basePoint - point, QPointF()));
|
||||
}
|
||||
|
@ -147,11 +147,12 @@ void VToolLinePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
QString VToolLinePoint::MakeToolTip() const
|
||||
{
|
||||
const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
|
||||
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
|
||||
const QLineF line(static_cast<QPointF>(*first), static_cast<QPointF>(*second));
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%6:</b> %7</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5°</td> </tr>"
|
||||
"</table>")
|
||||
|
@ -159,7 +160,9 @@ QString VToolLinePoint::MakeToolTip() const
|
|||
.arg(qApp->fromPixel(line.length()))
|
||||
.arg(UnitsToStr(qApp->patternUnit(), true))
|
||||
.arg(tr("Angle"))
|
||||
.arg(line.angle());
|
||||
.arg(line.angle())
|
||||
.arg(tr("Label"))
|
||||
.arg(second->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
|
@ -191,7 +194,7 @@ qreal VToolLinePoint::GetAngle() const
|
|||
void VToolLinePoint::SetAngle(const qreal &value)
|
||||
{
|
||||
angle = value;
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
|
@ -206,7 +209,7 @@ void VToolLinePoint::SetLineColor(const QString &value)
|
|||
{
|
||||
lineColor = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
|
@ -223,7 +226,7 @@ void VToolLinePoint::SetBasePointId(const quint32 &value)
|
|||
{
|
||||
basePointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +236,7 @@ VFormula VToolLinePoint::GetFormulaLength() const
|
|||
{
|
||||
VFormula fLength(formulaLength, this->getData());
|
||||
fLength.setCheckZero(true);
|
||||
fLength.setToolId(id);
|
||||
fLength.setToolId(m_id);
|
||||
fLength.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
|
||||
return fLength;
|
||||
|
@ -246,7 +249,7 @@ void VToolLinePoint::SetFormulaLength(const VFormula &value)
|
|||
{
|
||||
formulaLength = value.GetFormula(FormulaType::FromUser);
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,18 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolLinePointInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolLinePointInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
typeLine(TypeLineLine),
|
||||
lineColor(ColorBlack)
|
||||
{}
|
||||
|
||||
QString typeLine;
|
||||
QString lineColor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolLinePoint class parent for all tools what create point with line.
|
||||
*/
|
||||
|
|
|
@ -59,26 +59,16 @@ const QString VToolNormal::ToolType = QStringLiteral("normal");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolNormal constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param typeLine line type.
|
||||
* @param formula string with formula normal length.
|
||||
* @param angle additional angle.
|
||||
* @param firstPointId id first line point.
|
||||
* @param secondPointId id second line point.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolNormal::VToolNormal(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor, const QString &formula, const qreal &angle,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, angle, parent),
|
||||
secondPointId(secondPointId)
|
||||
VToolNormal::VToolNormal(const VToolNormalInitData &initData, QGraphicsItem *parent)
|
||||
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula,
|
||||
initData.firstPointId, initData.angle, parent),
|
||||
secondPointId(initData.secondPointId)
|
||||
{
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -90,7 +80,7 @@ void VToolNormal::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogNormal> dialogTool = m_dialog.objectCast<DialogNormal>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetTypeLine(m_lineType);
|
||||
dialogTool->SetFormula(formulaLength);
|
||||
dialogTool->SetAngle(angle);
|
||||
|
@ -113,15 +103,22 @@ VToolNormal* VToolNormal::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogNormal> dialogTool = dialog.objectCast<DialogNormal>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
QString formula = dialogTool->GetFormula();
|
||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
||||
const QString typeLine = dialogTool->GetTypeLine();
|
||||
const QString lineColor = dialogTool->GetLineColor();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
const qreal angle = dialogTool->GetAngle();
|
||||
VToolNormal *point = Create(0, formula, firstPointId, secondPointId, typeLine, lineColor, pointName, angle, 5, 10,
|
||||
scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolNormalInitData initData;
|
||||
initData.formula = dialogTool->GetFormula();
|
||||
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||
initData.angle = dialogTool->GetAngle();
|
||||
initData.typeLine = dialogTool->GetTypeLine();
|
||||
initData.lineColor = dialogTool->GetLineColor();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolNormal *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -132,61 +129,45 @@ VToolNormal* VToolNormal::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param formula string with formula normal length.
|
||||
* @param firstPointId id first line point.
|
||||
* @param secondPointId id second line point.
|
||||
* @param typeLine line type.
|
||||
* @param pointName point name.
|
||||
* @param angle additional angle.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
|
||||
const quint32 &secondPointId, const QString &typeLine, const QString &lineColor,
|
||||
const QString &pointName, const qreal angle, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolNormal* VToolNormal::Create(VToolNormalInitData initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
||||
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||
|
||||
const qreal result = CheckFormula(_id, formula, data);
|
||||
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||
|
||||
QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint),
|
||||
qApp->toPixel(result), angle);
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
qApp->toPixel(result), initData.angle);
|
||||
|
||||
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::Normal, doc);
|
||||
VToolNormal *point = new VToolNormal(doc, data, id, typeLine, lineColor, formula, angle, firstPointId,
|
||||
secondPointId, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(firstPoint->getIdTool());
|
||||
doc->IncrementReferens(secondPoint->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::Normal, initData.doc);
|
||||
VToolNormal *point = new VToolNormal(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -217,24 +198,6 @@ QString VToolNormal::SecondPointName() const
|
|||
return VAbstractTool::data.GetGObject(secondPointId)->name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogNormal>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RemoveReferens decrement value of reference.
|
||||
|
@ -317,7 +280,7 @@ void VToolNormal::SetSecondPointId(const quint32 &value)
|
|||
{
|
||||
secondPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -327,3 +290,17 @@ void VToolNormal::ShowVisualization(bool show)
|
|||
{
|
||||
ShowToolVisualization<VisToolNormal>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolNormal::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogNormal>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,22 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolNormalInitData : public VToolLinePointInitData
|
||||
{
|
||||
VToolNormalInitData()
|
||||
: VToolLinePointInitData(),
|
||||
formula(),
|
||||
firstPointId(NULL_ID),
|
||||
secondPointId(NULL_ID),
|
||||
angle(0)
|
||||
{}
|
||||
|
||||
QString formula;
|
||||
quint32 firstPointId;
|
||||
quint32 secondPointId;
|
||||
qreal angle;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolNormal class tool for creation point on normal. Normal begin from first point of line.
|
||||
*/
|
||||
|
@ -54,12 +70,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolNormal* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolNormal* Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
|
||||
const quint32 &secondPointId, const QString &typeLine, const QString &lineColor,
|
||||
const QString &pointName, const qreal angle, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolNormal* Create(VToolNormalInitData initData);
|
||||
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length,
|
||||
const qreal &angle = 0);
|
||||
static const QString ToolType;
|
||||
|
@ -72,8 +83,9 @@ public:
|
|||
void SetSecondPointId(const quint32 &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -85,10 +97,7 @@ private:
|
|||
/** @brief secondPointId id second line point. */
|
||||
quint32 secondPointId;
|
||||
|
||||
VToolNormal(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor,
|
||||
const QString &formula, const qreal &angle, const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolNormal(const VToolNormalInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLNORMAL_H
|
||||
|
|
|
@ -61,26 +61,16 @@ const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolShoulderPoint constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param typeLine line type.
|
||||
* @param formula string with formula length.
|
||||
* @param p1Line id first line point.
|
||||
* @param p2Line id second line point.
|
||||
* @param pShoulder id shoulder point.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolShoulderPoint::VToolShoulderPoint(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
||||
const QString &typeLine,
|
||||
const QString &lineColor, const QString &formula, const quint32 &p1Line,
|
||||
const quint32 &p2Line, const quint32 &pShoulder, const Source &typeCreation,
|
||||
QGraphicsItem * parent)
|
||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, p1Line, 0, parent), p2Line(p2Line),
|
||||
pShoulder(pShoulder)
|
||||
VToolShoulderPoint::VToolShoulderPoint(const VToolShoulderPointInitData &initData, QGraphicsItem * parent)
|
||||
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula,
|
||||
initData.p1Line, 0, parent),
|
||||
p2Line(initData.p2Line),
|
||||
pShoulder(initData.pShoulder)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -92,7 +82,7 @@ void VToolShoulderPoint::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogShoulderPoint> dialogTool = m_dialog.objectCast<DialogShoulderPoint>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetTypeLine(m_lineType);
|
||||
dialogTool->SetLineColor(lineColor);
|
||||
dialogTool->SetFormula(formulaLength);
|
||||
|
@ -162,15 +152,22 @@ VToolShoulderPoint* VToolShoulderPoint::Create(QSharedPointer<DialogTool> dialog
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogShoulderPoint> dialogTool = dialog.objectCast<DialogShoulderPoint>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
QString formula = dialogTool->GetFormula();
|
||||
const quint32 p1Line = dialogTool->GetP1Line();
|
||||
const quint32 p2Line = dialogTool->GetP2Line();
|
||||
const quint32 pShoulder = dialogTool->GetP3();
|
||||
const QString typeLine = dialogTool->GetTypeLine();
|
||||
const QString lineColor = dialogTool->GetLineColor();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolShoulderPoint * point = Create(0, formula, p1Line, p2Line, pShoulder, typeLine, lineColor, pointName, 5,
|
||||
10, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolShoulderPointInitData initData;
|
||||
initData.formula = dialogTool->GetFormula();
|
||||
initData.p1Line = dialogTool->GetP1Line();
|
||||
initData.p2Line = dialogTool->GetP2Line();
|
||||
initData.pShoulder = dialogTool->GetP3();
|
||||
initData.typeLine = dialogTool->GetTypeLine();
|
||||
initData.lineColor = dialogTool->GetLineColor();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolShoulderPoint * point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -181,67 +178,51 @@ VToolShoulderPoint* VToolShoulderPoint::Create(QSharedPointer<DialogTool> dialog
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param formula string with formula length.
|
||||
* @param p1Line id first line point.
|
||||
* @param p2Line id second line point.
|
||||
* @param pShoulder id shoulder point.
|
||||
* @param typeLine line type.
|
||||
* @param pointName point name.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @return the created tool
|
||||
*/
|
||||
VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line,
|
||||
const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine,
|
||||
const QString &lineColor, const QString &pointName, const qreal &mx,
|
||||
const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
||||
VToolShoulderPoint* VToolShoulderPoint::Create(VToolShoulderPointInitData &initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(p1Line);
|
||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(p2Line);
|
||||
const QSharedPointer<VPointF> shoulderPoint = data->GeometricObject<VPointF>(pShoulder);
|
||||
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.p1Line);
|
||||
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.p2Line);
|
||||
const QSharedPointer<VPointF> shoulderPoint = initData.data->GeometricObject<VPointF>(initData.pShoulder);
|
||||
|
||||
const qreal result = CheckFormula(_id, formula, data);
|
||||
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||
|
||||
QPointF fPoint = VToolShoulderPoint::FindPoint(static_cast<QPointF>(*firstPoint),
|
||||
static_cast<QPointF>(*secondPoint),
|
||||
static_cast<QPointF>(*shoulderPoint), qApp->toPixel(result));
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
|
||||
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(p1Line, id);
|
||||
data->AddLine(p2Line, id);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddLine(initData.p1Line, initData.id);
|
||||
initData.data->AddLine(initData.p2Line, initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(p1Line, id);
|
||||
data->AddLine(p2Line, id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddLine(initData.p1Line, initData.id);
|
||||
initData.data->AddLine(initData.p2Line, initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::ShoulderPoint, doc);
|
||||
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, lineColor, formula,
|
||||
p1Line, p2Line, pShoulder,
|
||||
typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(firstPoint->getIdTool());
|
||||
doc->IncrementReferens(secondPoint->getIdTool());
|
||||
doc->IncrementReferens(shoulderPoint->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::ShoulderPoint, initData.doc);
|
||||
VToolShoulderPoint *point = new VToolShoulderPoint(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||
initData.doc->IncrementReferens(shoulderPoint->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -259,24 +240,6 @@ QString VToolShoulderPoint::ShoulderPointName() const
|
|||
return VAbstractTool::data.GetGObject(pShoulder)->name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogShoulderPoint>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RemoveReferens decrement value of reference.
|
||||
|
@ -354,12 +317,13 @@ QString VToolShoulderPoint::MakeToolTip() const
|
|||
{
|
||||
const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
|
||||
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(p2Line);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
|
||||
const QLineF firstToCur(static_cast<QPointF>(*first), static_cast<QPointF>(*current));
|
||||
const QLineF secondToCur(static_cast<QPointF>(*second), static_cast<QPointF>(*current));
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%8:</b> %9</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5°</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
|
||||
|
@ -370,10 +334,26 @@ QString VToolShoulderPoint::MakeToolTip() const
|
|||
.arg(tr("Angle"))
|
||||
.arg(firstToCur.angle())
|
||||
.arg(QString("%1->%2").arg(second->name(), current->name()))
|
||||
.arg(qApp->fromPixel(secondToCur.length()));
|
||||
.arg(qApp->fromPixel(secondToCur.length()))
|
||||
.arg(tr("Label"))
|
||||
.arg(current->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolShoulderPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogShoulderPoint>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
quint32 VToolShoulderPoint::getPShoulder() const
|
||||
|
@ -389,7 +369,7 @@ void VToolShoulderPoint::setPShoulder(const quint32 &value)
|
|||
{
|
||||
pShoulder = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -413,7 +393,7 @@ void VToolShoulderPoint::SetP2Line(const quint32 &value)
|
|||
{
|
||||
p2Line = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,22 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolShoulderPointInitData : public VToolLinePointInitData
|
||||
{
|
||||
VToolShoulderPointInitData()
|
||||
: VToolLinePointInitData(),
|
||||
formula(),
|
||||
p1Line(NULL_ID),
|
||||
p2Line(NULL_ID),
|
||||
pShoulder(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formula;
|
||||
quint32 p1Line;
|
||||
quint32 p2Line;
|
||||
quint32 pShoulder;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolShoulderPoint class tool for creation point on shoulder. This tool for special situation, when you
|
||||
* want find point along line, but have only length from another point (shoulder).
|
||||
|
@ -57,12 +73,7 @@ public:
|
|||
const qreal &length);
|
||||
static VToolShoulderPoint* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolShoulderPoint* Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line,
|
||||
const quint32 &pShoulder, const QString &typeLine, const QString &lineColor,
|
||||
const QString &pointName, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolShoulderPoint* Create(VToolShoulderPointInitData &initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::ShoulderPoint) };
|
||||
|
@ -78,13 +89,14 @@ public:
|
|||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
|
||||
private slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolShoulderPoint)
|
||||
|
||||
|
@ -94,9 +106,7 @@ private:
|
|||
/** @brief pShoulder id shoulder line point. */
|
||||
quint32 pShoulder;
|
||||
|
||||
VToolShoulderPoint(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor, const QString &formula, const quint32 &p1Line, const quint32 &p2Line,
|
||||
const quint32 &pShoulder, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolShoulderPoint(const VToolShoulderPointInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLSHOULDERPOINT_H
|
||||
|
|
|
@ -73,21 +73,17 @@ const QString VToolBasePoint::ToolType = QStringLiteral("single");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolBasePoint constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolBasePoint::VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
const QString &namePP, QGraphicsItem * parent )
|
||||
:VToolSinglePoint(doc, data, id, parent), namePP(namePP)
|
||||
VToolBasePoint::VToolBasePoint (const VToolBasePointInitData &initData, QGraphicsItem * parent )
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent), namePP(initData.nameActivPP)
|
||||
{
|
||||
m_baseColor = Qt::red;
|
||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
m_namePoint->setBrush(Qt::black);
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -99,38 +95,36 @@ void VToolBasePoint::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogSinglePoint> dialogTool = m_dialog.objectCast<DialogSinglePoint>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetData(p->name(), static_cast<QPointF>(*p));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolBasePoint *VToolBasePoint::Create(quint32 _id, const QString &nameActivPP, VPointF *point,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolBasePoint *VToolBasePoint::Create(VToolBasePointInitData initData)
|
||||
{
|
||||
SCASSERT(point != nullptr)
|
||||
VPointF *point = new VPointF(initData.x, initData.y, initData.name, initData.mx, initData.my);
|
||||
point->SetShowLabel(initData.showLabel);
|
||||
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(point);
|
||||
initData.id = initData.data->AddGObject(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, point);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, point);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::BasePoint, doc);
|
||||
VToolBasePoint *spoint = new VToolBasePoint(doc, data, id, typeCreation, nameActivPP);
|
||||
scene->addItem(spoint);
|
||||
InitToolConnections(scene, spoint);
|
||||
VAbstractPattern::AddTool(id, spoint);
|
||||
VAbstractTool::AddRecord(initData.id, Tool::BasePoint, initData.doc);
|
||||
VToolBasePoint *spoint = new VToolBasePoint(initData);
|
||||
initData.scene->addItem(spoint);
|
||||
InitToolConnections(initData.scene, spoint);
|
||||
VAbstractPattern::AddTool(initData.id, spoint);
|
||||
return spoint;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -153,7 +147,7 @@ void VToolBasePoint::AddToFile()
|
|||
QDomElement sPoint = doc->createElement(getTagName());
|
||||
|
||||
// Create SPoint tag
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOptions(sPoint, obj);
|
||||
|
||||
//Create pattern piece structure
|
||||
|
@ -193,7 +187,7 @@ QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, co
|
|||
// value - this is new position.
|
||||
QPointF newPos = value.toPointF();
|
||||
|
||||
MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), id, this->scene());
|
||||
MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), m_id, this->scene());
|
||||
connect(moveSP, &MoveSPoint::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveSP);
|
||||
const QList<QGraphicsView *> viewList = scene()->views();
|
||||
|
@ -244,7 +238,7 @@ void VToolBasePoint::decrementReferens()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VToolBasePoint::GetBasePointPos() const
|
||||
{
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
QPointF pos(qApp->fromPixel(p->x()), qApp->fromPixel(p->y()));
|
||||
return pos;
|
||||
}
|
||||
|
@ -252,7 +246,7 @@ QPointF VToolBasePoint::GetBasePointPos() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolBasePoint::SetBasePointPos(const QPointF &pos)
|
||||
{
|
||||
QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
p->setX(qApp->toPixel(pos.x()));
|
||||
p->setY(qApp->toPixel(pos.y()));
|
||||
|
||||
|
@ -371,11 +365,20 @@ void VToolBasePoint::ReadToolAttributes(const QDomElement &domElement)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolBasePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event )
|
||||
QString VToolBasePoint::MakeToolTip() const
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"</table>")
|
||||
.arg(tr("Label"))
|
||||
.arg(point->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolBasePoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
qCDebug(vTool, "Context menu base point");
|
||||
#ifndef QT_NO_CURSOR
|
||||
|
@ -388,12 +391,12 @@ void VToolBasePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event )
|
|||
if (doc->CountPP() > 1)
|
||||
{
|
||||
qCDebug(vTool, "PP count > 1");
|
||||
ContextMenu<DialogSinglePoint>(this, event, RemoveOption::Enable, Referens::Ignore);
|
||||
ContextMenu<DialogSinglePoint>(event, id, RemoveOption::Enable, Referens::Ignore);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "PP count = 1");
|
||||
ContextMenu<DialogSinglePoint>(this, event, RemoveOption::Disable);
|
||||
ContextMenu<DialogSinglePoint>(event, id, RemoveOption::Disable);
|
||||
}
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
|
@ -411,7 +414,7 @@ void VToolBasePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event )
|
|||
*/
|
||||
void VToolBasePoint::FullUpdateFromFile()
|
||||
{
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(m_id));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -45,6 +45,20 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolBasePointInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolBasePointInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
nameActivPP(),
|
||||
x(10),
|
||||
y(10)
|
||||
{}
|
||||
|
||||
QString nameActivPP;
|
||||
qreal x;
|
||||
qreal y;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolBasePoint class tool for creation pattern base point. Only base point can move. All object
|
||||
* pattern peace depend on base point.
|
||||
|
@ -55,9 +69,7 @@ class VToolBasePoint : public VToolSinglePoint
|
|||
public:
|
||||
virtual ~VToolBasePoint() =default;
|
||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolBasePoint *Create(quint32 _id, const QString &nameActivPP, VPointF *point,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolBasePoint *Create(VToolBasePointInitData initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::BasePoint)};
|
||||
|
@ -75,7 +87,6 @@ signals:
|
|||
*/
|
||||
void LiteUpdateTree();
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void AddToFile() Q_DECL_OVERRIDE;
|
||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
|
||||
virtual void DeleteTool(bool ask = true) Q_DECL_OVERRIDE;
|
||||
|
@ -87,13 +98,15 @@ protected:
|
|||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE {}
|
||||
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
|
||||
private slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolBasePoint)
|
||||
|
||||
QString namePP;
|
||||
|
||||
VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
const QString &namePP, QGraphicsItem * parent = nullptr );
|
||||
VToolBasePoint (const VToolBasePointInitData &initData, QGraphicsItem * parent = nullptr );
|
||||
};
|
||||
|
||||
#endif // VTOOLBASEPOINT_H
|
||||
|
|
|
@ -58,24 +58,17 @@ const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolLineIntersect constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param p1Line1 id first point first line.
|
||||
* @param p2Line1 id second point first line.
|
||||
* @param p1Line2 id first point second line.
|
||||
* @param p2Line2 id second point second line.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolLineIntersect::VToolLineIntersect(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
||||
const quint32 &p1Line1, const quint32 &p2Line1, const quint32 &p1Line2,
|
||||
const quint32 &p2Line2, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VToolSinglePoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
|
||||
p2Line2(p2Line2)
|
||||
VToolLineIntersect::VToolLineIntersect(const VToolLineIntersectInitData &initData, QGraphicsItem *parent)
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||
p1Line1(initData.p1Line1Id),
|
||||
p2Line1(initData.p2Line1Id),
|
||||
p1Line2(initData.p1Line2Id),
|
||||
p2Line2(initData.p2Line2Id)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -86,8 +79,8 @@ void VToolLineIntersect::setDialog()
|
|||
{
|
||||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogLineIntersect> dialogTool = m_dialog.objectCast<DialogLineIntersect>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetP1Line1(p1Line1);
|
||||
dialogTool->SetP2Line1(p2Line1);
|
||||
dialogTool->SetP1Line2(p1Line2);
|
||||
|
@ -110,13 +103,20 @@ VToolLineIntersect* VToolLineIntersect::Create(QSharedPointer<DialogTool> dialog
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogLineIntersect> dialogTool = dialog.objectCast<DialogLineIntersect>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 p1Line1Id = dialogTool->GetP1Line1();
|
||||
const quint32 p2Line1Id = dialogTool->GetP2Line1();
|
||||
const quint32 p1Line2Id = dialogTool->GetP1Line2();
|
||||
const quint32 p2Line2Id = dialogTool->GetP2Line2();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolLineIntersect* point = Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc,
|
||||
data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolLineIntersectInitData initData;
|
||||
initData.p1Line1Id = dialogTool->GetP1Line1();
|
||||
initData.p2Line1Id = dialogTool->GetP2Line1();
|
||||
initData.p1Line2Id = dialogTool->GetP1Line2();
|
||||
initData.p2Line2Id = dialogTool->GetP2Line2();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolLineIntersect* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -127,31 +127,15 @@ VToolLineIntersect* VToolLineIntersect::Create(QSharedPointer<DialogTool> dialog
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param p1Line1Id id first point first line.
|
||||
* @param p2Line1Id id second point first line.
|
||||
* @param p1Line2Id id first point second line.
|
||||
* @param p2Line2Id id second point second line.
|
||||
* @param pointName point name.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @return the created tool
|
||||
*/
|
||||
VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id,
|
||||
const quint32 &p1Line2Id, const quint32 &p2Line2Id,
|
||||
const QString &pointName, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolLineIntersect* VToolLineIntersect::Create(VToolLineIntersectInitData initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> p1Line1 = data->GeometricObject<VPointF>(p1Line1Id);
|
||||
const QSharedPointer<VPointF> p2Line1 = data->GeometricObject<VPointF>(p2Line1Id);
|
||||
const QSharedPointer<VPointF> p1Line2 = data->GeometricObject<VPointF>(p1Line2Id);
|
||||
const QSharedPointer<VPointF> p2Line2 = data->GeometricObject<VPointF>(p2Line2Id);
|
||||
const QSharedPointer<VPointF> p1Line1 = initData.data->GeometricObject<VPointF>(initData.p1Line1Id);
|
||||
const QSharedPointer<VPointF> p2Line1 = initData.data->GeometricObject<VPointF>(initData.p2Line1Id);
|
||||
const QSharedPointer<VPointF> p1Line2 = initData.data->GeometricObject<VPointF>(initData.p1Line2Id);
|
||||
const QSharedPointer<VPointF> p2Line2 = initData.data->GeometricObject<VPointF>(initData.p2Line2Id);
|
||||
|
||||
QLineF line1(static_cast<QPointF>(*p1Line1), static_cast<QPointF>(*p2Line1));
|
||||
QLineF line2(static_cast<QPointF>(*p1Line2), static_cast<QPointF>(*p2Line2));
|
||||
|
@ -159,40 +143,41 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32
|
|||
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
|
||||
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
|
||||
{
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(p1Line1Id, id);
|
||||
data->AddLine(id, p2Line1Id);
|
||||
data->AddLine(p1Line2Id, id);
|
||||
data->AddLine(id, p2Line2Id);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddLine(initData.p1Line1Id, initData.id);
|
||||
initData.data->AddLine(initData.id, initData.p2Line1Id);
|
||||
initData.data->AddLine(initData.p1Line2Id, initData.id);
|
||||
initData.data->AddLine(initData.id, initData.p2Line2Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(p1Line1Id, id);
|
||||
data->AddLine(id, p2Line1Id);
|
||||
data->AddLine(p1Line2Id, id);
|
||||
data->AddLine(id, p2Line2Id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddLine(initData.p1Line1Id, initData.id);
|
||||
initData.data->AddLine(initData.id, initData.p2Line1Id);
|
||||
initData.data->AddLine(initData.p1Line2Id, initData.id);
|
||||
initData.data->AddLine(initData.id, initData.p2Line2Id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::LineIntersect, doc);
|
||||
VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id,
|
||||
p2Line2Id, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(p1Line1->getIdTool());
|
||||
doc->IncrementReferens(p2Line1->getIdTool());
|
||||
doc->IncrementReferens(p1Line2->getIdTool());
|
||||
doc->IncrementReferens(p2Line2->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::LineIntersect, initData.doc);
|
||||
VToolLineIntersect *point = new VToolLineIntersect(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(p1Line1->getIdTool());
|
||||
initData.doc->IncrementReferens(p2Line1->getIdTool());
|
||||
initData.doc->IncrementReferens(p1Line2->getIdTool());
|
||||
initData.doc->IncrementReferens(p2Line2->getIdTool());
|
||||
return point;
|
||||
}
|
||||
}
|
||||
|
@ -223,24 +208,6 @@ QString VToolLineIntersect::Line2P2Name() const
|
|||
return VAbstractTool::data.GetGObject(p2Line2)->name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogLineIntersect>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RemoveReferens decrement value of reference.
|
||||
|
@ -318,7 +285,7 @@ QString VToolLineIntersect::MakeToolTip() const
|
|||
const QSharedPointer<VPointF> p2L1 = VAbstractTool::data.GeometricObject<VPointF>(p2Line1);
|
||||
const QSharedPointer<VPointF> p1L2 = VAbstractTool::data.GeometricObject<VPointF>(p1Line2);
|
||||
const QSharedPointer<VPointF> p2L2 = VAbstractTool::data.GeometricObject<VPointF>(p2Line2);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
|
||||
const QLineF p1L1ToCur(static_cast<QPointF>(*p1L1), static_cast<QPointF>(*current));
|
||||
const QLineF curToP2L1(static_cast<QPointF>(*current), static_cast<QPointF>(*p2L1));
|
||||
|
@ -326,6 +293,7 @@ QString VToolLineIntersect::MakeToolTip() const
|
|||
const QLineF curToP2L2(static_cast<QPointF>(*current), static_cast<QPointF>(*p2L2));
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%10:</b> %11</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
|
||||
|
@ -339,7 +307,9 @@ QString VToolLineIntersect::MakeToolTip() const
|
|||
.arg(QString("%1->%2").arg(p1L2->name(), current->name()))
|
||||
.arg(qApp->fromPixel(p1L2ToCur.length()))
|
||||
.arg(QString("%1->%2").arg(current->name(), p2L2->name()))
|
||||
.arg(qApp->fromPixel(curToP2L2.length()));
|
||||
.arg(qApp->fromPixel(curToP2L2.length()))
|
||||
.arg(tr("Label"))
|
||||
.arg(current->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
|
@ -356,7 +326,7 @@ void VToolLineIntersect::SetP2Line2(const quint32 &value)
|
|||
{
|
||||
p2Line2 = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -367,6 +337,20 @@ void VToolLineIntersect::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolLineIntersect>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLineIntersect::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogLineIntersect>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolLineIntersect::GetP1Line2() const
|
||||
{
|
||||
|
@ -380,7 +364,7 @@ void VToolLineIntersect::SetP1Line2(const quint32 &value)
|
|||
{
|
||||
p1Line2 = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -398,7 +382,7 @@ void VToolLineIntersect::SetP2Line1(const quint32 &value)
|
|||
{
|
||||
p2Line1 = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -416,7 +400,7 @@ void VToolLineIntersect::SetP1Line1(const quint32 &value)
|
|||
{
|
||||
p1Line1 = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,22 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolLineIntersectInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolLineIntersectInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
p1Line1Id(NULL_ID),
|
||||
p2Line1Id(NULL_ID),
|
||||
p1Line2Id(NULL_ID),
|
||||
p2Line2Id(NULL_ID)
|
||||
{}
|
||||
|
||||
quint32 p1Line1Id;
|
||||
quint32 p2Line1Id;
|
||||
quint32 p1Line2Id;
|
||||
quint32 p2Line2Id;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolLineIntersect class help find point intersection lines.
|
||||
*/
|
||||
|
@ -53,11 +69,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolLineIntersect *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolLineIntersect *Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id,
|
||||
const quint32 &p1Line2Id, const quint32 &p2Line2Id, const QString &pointName,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation);
|
||||
static VToolLineIntersect *Create(VToolLineIntersectInitData initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::LineIntersect)};
|
||||
|
@ -80,8 +92,9 @@ public:
|
|||
void SetP2Line2(const quint32 &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -103,9 +116,7 @@ private:
|
|||
/** @brief p2Line2 id second point second line.*/
|
||||
quint32 p2Line2;
|
||||
|
||||
VToolLineIntersect(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &p1Line1,
|
||||
const quint32 &p2Line1, const quint32 &p1Line2, const quint32 &p2Line2,
|
||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolLineIntersect(const VToolLineIntersectInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLLINEINTERSECT_H
|
||||
|
|
|
@ -55,13 +55,14 @@ template <class T> class QSharedPointer;
|
|||
const QString VToolPointFromArcAndTangent::ToolType = QStringLiteral("pointFromArcAndTangent");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointFromArcAndTangent::VToolPointFromArcAndTangent(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
||||
quint32 arcId, quint32 tangentPointId,
|
||||
CrossCirclesPoint crossPoint, const Source &typeCreation,
|
||||
VToolPointFromArcAndTangent::VToolPointFromArcAndTangent(const VToolPointFromArcAndTangentInitData &initData,
|
||||
QGraphicsItem *parent)
|
||||
:VToolSinglePoint(doc, data, id, parent), arcId(arcId), tangentPointId(tangentPointId), crossPoint(crossPoint)
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||
arcId(initData.arcId),
|
||||
tangentPointId(initData.tangentPointId),
|
||||
crossPoint(initData.crossPoint)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -70,7 +71,7 @@ void VToolPointFromArcAndTangent::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogPointFromArcAndTangent> dialogTool = m_dialog.objectCast<DialogPointFromArcAndTangent>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetArcId(arcId);
|
||||
dialogTool->SetCrossCirclesPoint(crossPoint);
|
||||
dialogTool->SetTangentPointId(tangentPointId);
|
||||
|
@ -85,12 +86,19 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(QSharedPointer<
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogPointFromArcAndTangent> dialogTool = dialog.objectCast<DialogPointFromArcAndTangent>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 arcId = dialogTool->GetArcId();
|
||||
const quint32 tangentPointId = dialogTool->GetTangentPointId();
|
||||
const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolPointFromArcAndTangent *point = Create(0, pointName, arcId, tangentPointId, pType, 5, 10, scene, doc,
|
||||
data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolPointFromArcAndTangentInitData initData;
|
||||
initData.arcId = dialogTool->GetArcId();
|
||||
initData.tangentPointId = dialogTool->GetTangentPointId();
|
||||
initData.crossPoint = dialogTool->GetCrossCirclesPoint();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolPointFromArcAndTangent *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -99,41 +107,39 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(QSharedPointer<
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(const quint32 _id, const QString &pointName,
|
||||
quint32 arcId, quint32 tangentPointId,
|
||||
CrossCirclesPoint crossPoint, const qreal &mx,
|
||||
const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(VToolPointFromArcAndTangentInitData initData)
|
||||
{
|
||||
const VArc arc = *data->GeometricObject<VArc>(arcId);
|
||||
const VPointF tPoint = *data->GeometricObject<VPointF>(tangentPointId);
|
||||
const VArc arc = *initData.data->GeometricObject<VArc>(initData.arcId);
|
||||
const VPointF tPoint = *initData.data->GeometricObject<VPointF>(initData.tangentPointId);
|
||||
|
||||
const QPointF point = VToolPointFromArcAndTangent::FindPoint(static_cast<QPointF>(tPoint), &arc, crossPoint);
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
const QPointF point = VToolPointFromArcAndTangent::FindPoint(static_cast<QPointF>(tPoint), &arc,
|
||||
initData.crossPoint);
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(point, pointName, mx, my));
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(point, pointName, mx, my));
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::PointFromArcAndTangent, doc);
|
||||
VToolPointFromArcAndTangent *point = new VToolPointFromArcAndTangent(doc, data, id, arcId, tangentPointId,
|
||||
crossPoint, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(arc.getIdTool());
|
||||
doc->IncrementReferens(tPoint.getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::PointFromArcAndTangent, initData.doc);
|
||||
VToolPointFromArcAndTangent *point = new VToolPointFromArcAndTangent(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(arc.getIdTool());
|
||||
initData.doc->IncrementReferens(tPoint.getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -240,7 +246,7 @@ void VToolPointFromArcAndTangent::SetTangentPointId(const quint32 &value)
|
|||
{
|
||||
tangentPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +264,7 @@ void VToolPointFromArcAndTangent::SetArcId(const quint32 &value)
|
|||
{
|
||||
arcId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +280,7 @@ void VToolPointFromArcAndTangent::SetCrossCirclesPoint(const CrossCirclesPoint &
|
|||
{
|
||||
crossPoint = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
|
@ -284,6 +290,20 @@ void VToolPointFromArcAndTangent::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolPointFromArcAndTangent>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromArcAndTangent::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointFromArcAndTangent>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromArcAndTangent::RemoveReferens()
|
||||
{
|
||||
|
@ -294,20 +314,6 @@ void VToolPointFromArcAndTangent::RemoveReferens()
|
|||
doc->DecrementReferens(tP->getIdTool());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromArcAndTangent::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointFromArcAndTangent>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromArcAndTangent::SaveDialog(QDomElement &domElement)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,20 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolPointFromArcAndTangentInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolPointFromArcAndTangentInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
arcId(NULL_ID),
|
||||
tangentPointId(NULL_ID),
|
||||
crossPoint(CrossCirclesPoint::FirstPoint)
|
||||
{}
|
||||
|
||||
quint32 arcId;
|
||||
quint32 tangentPointId;
|
||||
CrossCirclesPoint crossPoint;
|
||||
};
|
||||
|
||||
class VToolPointFromArcAndTangent : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -51,10 +65,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolPointFromArcAndTangent *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolPointFromArcAndTangent *Create(const quint32 _id, const QString &pointName, quint32 arcId,
|
||||
quint32 tangentPointId, CrossCirclesPoint crossPoint, const qreal &mx,
|
||||
const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation);
|
||||
static VToolPointFromArcAndTangent *Create(VToolPointFromArcAndTangentInitData initData);
|
||||
static QPointF FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
@ -73,9 +84,10 @@ public:
|
|||
void SetCrossCirclesPoint(const CrossCirclesPoint &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -87,9 +99,7 @@ private:
|
|||
quint32 tangentPointId;
|
||||
CrossCirclesPoint crossPoint;
|
||||
|
||||
VToolPointFromArcAndTangent(VAbstractPattern *doc, VContainer *data, const quint32 &id, quint32 arcId,
|
||||
quint32 tangentPointId, CrossCirclesPoint crossPoint, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
VToolPointFromArcAndTangent(const VToolPointFromArcAndTangentInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLPOINTFROMARCANDTANGENT_H
|
||||
|
|
|
@ -56,15 +56,15 @@ template <class T> class QSharedPointer;
|
|||
const QString VToolPointFromCircleAndTangent::ToolType = QStringLiteral("pointFromCircleAndTangent");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointFromCircleAndTangent::VToolPointFromCircleAndTangent(VAbstractPattern *doc, VContainer *data,
|
||||
const quint32 &id,
|
||||
quint32 circleCenterId, const QString &circleRadius,
|
||||
quint32 tangentPointId, CrossCirclesPoint crossPoint,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolSinglePoint(doc, data, id, parent), circleCenterId(circleCenterId), tangentPointId(tangentPointId),
|
||||
circleRadius(circleRadius), crossPoint(crossPoint)
|
||||
VToolPointFromCircleAndTangent::VToolPointFromCircleAndTangent(const VToolPointFromCircleAndTangentInitData &initData,
|
||||
QGraphicsItem *parent)
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||
circleCenterId(initData.circleCenterId),
|
||||
tangentPointId(initData.tangentPointId),
|
||||
circleRadius(initData.circleRadius),
|
||||
crossPoint(initData.crossPoint)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -73,7 +73,7 @@ void VToolPointFromCircleAndTangent::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogPointFromCircleAndTangent> dialogTool = m_dialog.objectCast<DialogPointFromCircleAndTangent>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetCircleCenterId(circleCenterId);
|
||||
dialogTool->SetCircleRadius(circleRadius);
|
||||
dialogTool->SetCrossCirclesPoint(crossPoint);
|
||||
|
@ -89,13 +89,20 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(QSharedPo
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogPointFromCircleAndTangent> dialogTool = dialog.objectCast<DialogPointFromCircleAndTangent>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 circleCenterId = dialogTool->GetCircleCenterId();
|
||||
QString circleRadius = dialogTool->GetCircleRadius();
|
||||
const quint32 tangentPointId = dialogTool->GetTangentPointId();
|
||||
const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolPointFromCircleAndTangent *point = Create(0, pointName, circleCenterId, circleRadius, tangentPointId, pType,
|
||||
5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolPointFromCircleAndTangentInitData initData;
|
||||
initData.circleCenterId = dialogTool->GetCircleCenterId();
|
||||
initData.circleRadius = dialogTool->GetCircleRadius();
|
||||
initData.tangentPointId = dialogTool->GetTangentPointId();
|
||||
initData.crossPoint = dialogTool->GetCrossCirclesPoint();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolPointFromCircleAndTangent *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -104,46 +111,41 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(QSharedPo
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const quint32 _id, const QString &pointName,
|
||||
quint32 circleCenterId, QString &circleRadius,
|
||||
quint32 tangentPointId,
|
||||
CrossCirclesPoint crossPoint, const qreal &mx,
|
||||
const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(VToolPointFromCircleAndTangentInitData &initData)
|
||||
{
|
||||
const qreal radius = qApp->toPixel(CheckFormula(_id, circleRadius, data));
|
||||
const VPointF cPoint = *data->GeometricObject<VPointF>(circleCenterId);
|
||||
const VPointF tPoint = *data->GeometricObject<VPointF>(tangentPointId);
|
||||
const qreal radius = qApp->toPixel(CheckFormula(initData.id, initData.circleRadius, initData.data));
|
||||
const VPointF cPoint = *initData.data->GeometricObject<VPointF>(initData.circleCenterId);
|
||||
const VPointF tPoint = *initData.data->GeometricObject<VPointF>(initData.tangentPointId);
|
||||
|
||||
const QPointF point = VToolPointFromCircleAndTangent::FindPoint(static_cast<QPointF>(tPoint),
|
||||
static_cast<QPointF>(cPoint), radius, crossPoint);
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
static_cast<QPointF>(cPoint), radius,
|
||||
initData.crossPoint);
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(point, pointName, mx, my));
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(point, pointName, mx, my));
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::PointFromCircleAndTangent, doc);
|
||||
VToolPointFromCircleAndTangent *point = new VToolPointFromCircleAndTangent(doc, data, id, circleCenterId,
|
||||
circleRadius, tangentPointId,
|
||||
crossPoint, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(cPoint.getIdTool());
|
||||
doc->IncrementReferens(tPoint.getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::PointFromCircleAndTangent, initData.doc);
|
||||
VToolPointFromCircleAndTangent *point = new VToolPointFromCircleAndTangent(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(cPoint.getIdTool());
|
||||
initData.doc->IncrementReferens(tPoint.getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -201,7 +203,7 @@ void VToolPointFromCircleAndTangent::SetTangentPointId(const quint32 &value)
|
|||
{
|
||||
tangentPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +221,7 @@ void VToolPointFromCircleAndTangent::SetCircleCenterId(const quint32 &value)
|
|||
{
|
||||
circleCenterId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +231,7 @@ VFormula VToolPointFromCircleAndTangent::GetCircleRadius() const
|
|||
{
|
||||
VFormula radius(circleRadius, getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(id);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
return radius;
|
||||
}
|
||||
|
@ -242,7 +244,7 @@ void VToolPointFromCircleAndTangent::SetCircleRadius(const VFormula &value)
|
|||
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
|
||||
{
|
||||
circleRadius = value.GetFormula(FormulaType::FromUser);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +261,7 @@ void VToolPointFromCircleAndTangent::SetCrossCirclesPoint(const CrossCirclesPoin
|
|||
{
|
||||
crossPoint = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
|
@ -269,6 +271,20 @@ void VToolPointFromCircleAndTangent::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolPointFromCircleAndTangent>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromCircleAndTangent::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointFromCircleAndTangent>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromCircleAndTangent::RemoveReferens()
|
||||
{
|
||||
|
@ -279,20 +295,6 @@ void VToolPointFromCircleAndTangent::RemoveReferens()
|
|||
doc->DecrementReferens(tangentPoint->getIdTool());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromCircleAndTangent::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointFromCircleAndTangent>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromCircleAndTangent::SaveDialog(QDomElement &domElement)
|
||||
{
|
||||
|
|
|
@ -45,6 +45,22 @@
|
|||
class VFormula;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolPointFromCircleAndTangentInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolPointFromCircleAndTangentInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
circleCenterId(NULL_ID),
|
||||
circleRadius("0"),
|
||||
tangentPointId(NULL_ID),
|
||||
crossPoint(CrossCirclesPoint::FirstPoint)
|
||||
{}
|
||||
|
||||
quint32 circleCenterId;
|
||||
QString circleRadius;
|
||||
quint32 tangentPointId;
|
||||
CrossCirclesPoint crossPoint;
|
||||
};
|
||||
|
||||
class VToolPointFromCircleAndTangent : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -52,11 +68,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolPointFromCircleAndTangent *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolPointFromCircleAndTangent *Create(const quint32 _id, const QString &pointName,
|
||||
quint32 circleCenterId, QString &circleRadius, quint32 tangentPointId,
|
||||
CrossCirclesPoint crossPoint, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolPointFromCircleAndTangent *Create(VToolPointFromCircleAndTangentInitData &initData);
|
||||
static QPointF FindPoint(const QPointF &p, const QPointF ¢er, qreal radius, const CrossCirclesPoint crossPoint);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
@ -78,9 +90,10 @@ public:
|
|||
void SetCrossCirclesPoint(const CrossCirclesPoint &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -93,9 +106,8 @@ private:
|
|||
QString circleRadius;
|
||||
CrossCirclesPoint crossPoint;
|
||||
|
||||
VToolPointFromCircleAndTangent(VAbstractPattern *doc, VContainer *data, const quint32 &id, quint32 circleCenterId,
|
||||
const QString &circleRadius, quint32 tangentPointId, CrossCirclesPoint crossPoint,
|
||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolPointFromCircleAndTangent(const VToolPointFromCircleAndTangentInitData &initData,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLPOINTFROMCIRCLEANDTANGENT_H
|
||||
|
|
|
@ -63,24 +63,17 @@ const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolPointOfContact constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param radius string with formula radius arc.
|
||||
* @param center id center arc point.
|
||||
* @param firstPointId id first line point.
|
||||
* @param secondPointId id second line point.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolPointOfContact::VToolPointOfContact(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
||||
const QString &radius, const quint32 ¢er,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
: VToolSinglePoint(doc, data, id, parent), arcRadius(radius), center(center), firstPointId(firstPointId),
|
||||
secondPointId(secondPointId)
|
||||
VToolPointOfContact::VToolPointOfContact(const VToolPointOfContactInitData &initData, QGraphicsItem *parent)
|
||||
: VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||
arcRadius(initData.radius),
|
||||
center(initData.center),
|
||||
firstPointId(initData.firstPointId),
|
||||
secondPointId(initData.secondPointId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -92,7 +85,7 @@ void VToolPointOfContact::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogPointOfContact> dialogTool = m_dialog.objectCast<DialogPointOfContact>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->setRadius(arcRadius);
|
||||
dialogTool->setCenter(center);
|
||||
dialogTool->SetFirstPoint(firstPointId);
|
||||
|
@ -170,13 +163,20 @@ VToolPointOfContact* VToolPointOfContact::Create(QSharedPointer<DialogTool> dial
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogPointOfContact> dialogTool = dialog.objectCast<DialogPointOfContact>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
QString radius = dialogTool->getRadius();
|
||||
const quint32 center = dialogTool->getCenter();
|
||||
const quint32 firstPointId = dialogTool->GetFirstPoint();
|
||||
const quint32 secondPointId = dialogTool->GetSecondPoint();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolPointOfContact *point = Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc,
|
||||
data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolPointOfContactInitData initData;
|
||||
initData.radius = dialogTool->getRadius();
|
||||
initData.center = dialogTool->getCenter();
|
||||
initData.firstPointId = dialogTool->GetFirstPoint();
|
||||
initData.secondPointId = dialogTool->GetSecondPoint();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolPointOfContact *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -187,65 +187,51 @@ VToolPointOfContact* VToolPointOfContact::Create(QSharedPointer<DialogTool> dial
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param radius string with formula radius arc.
|
||||
* @param center id center arc point.
|
||||
* @param firstPointId id first line point.
|
||||
* @param secondPointId id second line point.
|
||||
* @param pointName point name.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 ¢er,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const QString &pointName, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
VToolPointOfContact* VToolPointOfContact::Create(VToolPointOfContactInitData &initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> centerP = data->GeometricObject<VPointF>(center);
|
||||
const QSharedPointer<VPointF> firstP = data->GeometricObject<VPointF>(firstPointId);
|
||||
const QSharedPointer<VPointF> secondP = data->GeometricObject<VPointF>(secondPointId);
|
||||
const QSharedPointer<VPointF> centerP = initData.data->GeometricObject<VPointF>(initData.center);
|
||||
const QSharedPointer<VPointF> firstP = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||
const QSharedPointer<VPointF> secondP = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||
|
||||
const qreal result = CheckFormula(_id, radius, data);
|
||||
const qreal result = CheckFormula(initData.id, initData.radius, initData.data);
|
||||
|
||||
QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), static_cast<QPointF>(*centerP),
|
||||
static_cast<QPointF>(*firstP), static_cast<QPointF>(*secondP));
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
|
||||
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(secondPointId, id);
|
||||
data->AddLine(center, id);
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||
initData.data->AddLine(initData.secondPointId, initData.id);
|
||||
initData.data->AddLine(initData.center, initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(secondPointId, id);
|
||||
data->AddLine(center, id);
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||
initData.data->AddLine(initData.secondPointId, initData.id);
|
||||
initData.data->AddLine(initData.center, initData.id);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::PointOfContact, doc);
|
||||
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center,
|
||||
firstPointId, secondPointId, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(centerP->getIdTool());
|
||||
doc->IncrementReferens(firstP->getIdTool());
|
||||
doc->IncrementReferens(secondP->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::PointOfContact, initData.doc);
|
||||
VToolPointOfContact *point = new VToolPointOfContact(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(centerP->getIdTool());
|
||||
initData.doc->IncrementReferens(firstP->getIdTool());
|
||||
initData.doc->IncrementReferens(secondP->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -269,24 +255,6 @@ QString VToolPointOfContact::SecondPointName() const
|
|||
return VAbstractTool::data.GetGObject(secondPointId)->name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfContact>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RemoveReferens decrement value of reference.
|
||||
|
@ -361,13 +329,14 @@ QString VToolPointOfContact::MakeToolTip() const
|
|||
const QSharedPointer<VPointF> p1 = VAbstractTool::data.GeometricObject<VPointF>(firstPointId);
|
||||
const QSharedPointer<VPointF> p2 = VAbstractTool::data.GeometricObject<VPointF>(secondPointId);
|
||||
const QSharedPointer<VPointF> centerP = VAbstractTool::data.GeometricObject<VPointF>(center);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
|
||||
const QLineF p1ToCur(static_cast<QPointF>(*p1), static_cast<QPointF>(*current));
|
||||
const QLineF p2ToCur(static_cast<QPointF>(*p2), static_cast<QPointF>(*current));
|
||||
const QLineF centerToCur(static_cast<QPointF>(*centerP), static_cast<QPointF>(*current));
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%10:</b> %11</td> </tr>"
|
||||
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
||||
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
|
||||
|
@ -381,7 +350,9 @@ QString VToolPointOfContact::MakeToolTip() const
|
|||
.arg(QString("%1 %2->%3").arg(tr("Length"), centerP->name(), current->name()))
|
||||
.arg(qApp->fromPixel(centerToCur.length()))
|
||||
.arg(QString("%1 %2->%3").arg(tr("Angle"), centerP->name(), current->name()))
|
||||
.arg(centerToCur.angle());
|
||||
.arg(centerToCur.angle())
|
||||
.arg(tr("Label"))
|
||||
.arg(current->name());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
|
@ -403,6 +374,20 @@ void VToolPointOfContact::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolPointOfContact>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfContact::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfContact>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolPointOfContact::GetFirstPointId() const
|
||||
{
|
||||
|
@ -428,7 +413,7 @@ void VToolPointOfContact::setCenter(const quint32 &value)
|
|||
{
|
||||
center = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +423,7 @@ VFormula VToolPointOfContact::getArcRadius() const
|
|||
{
|
||||
VFormula radius(arcRadius, this->getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(id);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
|
||||
return radius;
|
||||
|
@ -451,7 +436,7 @@ void VToolPointOfContact::setArcRadius(const VFormula &value)
|
|||
{
|
||||
arcRadius = value.GetFormula(FormulaType::FromUser);
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,22 @@
|
|||
class VFormula;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolPointOfContactInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolPointOfContactInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
radius("0"),
|
||||
center(NULL_ID),
|
||||
firstPointId(NULL_ID),
|
||||
secondPointId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString radius;
|
||||
quint32 center;
|
||||
quint32 firstPointId;
|
||||
quint32 secondPointId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolPointOfContact class tool for creation point intersection line and arc.
|
||||
*/
|
||||
|
@ -57,12 +73,7 @@ public:
|
|||
const QPointF &secondPoint);
|
||||
static VToolPointOfContact* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolPointOfContact* Create(const quint32 _id, QString &radius, const quint32 ¢er,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const QString &pointName,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation);
|
||||
static VToolPointOfContact* Create(VToolPointOfContactInitData &initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::PointOfContact) };
|
||||
|
@ -84,8 +95,9 @@ public:
|
|||
void SetSecondPointId(const quint32 &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
|
@ -107,9 +119,7 @@ private:
|
|||
/** @brief secondPointId id second line point. */
|
||||
quint32 secondPointId;
|
||||
|
||||
VToolPointOfContact(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &radius,
|
||||
const quint32 ¢er, const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
VToolPointOfContact(const VToolPointOfContactInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLPOINTOFCONTACT_H
|
||||
|
|
|
@ -56,20 +56,16 @@ const QString VToolPointOfIntersection::ToolType = QStringLiteral("pointOfInters
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolPointOfIntersection constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param firstPointId id first line point.
|
||||
* @param secondPointId id second line point.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolPointOfIntersection::VToolPointOfIntersection(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolSinglePoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId)
|
||||
VToolPointOfIntersection::VToolPointOfIntersection(const VToolPointOfIntersectionInitData &initData,
|
||||
QGraphicsItem *parent)
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||
firstPointId(initData.firstPointId),
|
||||
secondPointId(initData.secondPointId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -81,7 +77,7 @@ void VToolPointOfIntersection::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogPointOfIntersection> dialogTool = m_dialog.objectCast<DialogPointOfIntersection>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFirstPointId(firstPointId);
|
||||
dialogTool->SetSecondPointId(secondPointId);
|
||||
dialogTool->SetPointName(p->name());
|
||||
|
@ -102,11 +98,18 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(QSharedPointer<Dialog
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogPointOfIntersection> dialogTool = dialog.objectCast<DialogPointOfIntersection>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolPointOfIntersection *point = Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc,
|
||||
data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolPointOfIntersectionInitData initData;
|
||||
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolPointOfIntersection *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -117,54 +120,41 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(QSharedPointer<Dialog
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param pointName point name.
|
||||
* @param firstPointId id first line point.
|
||||
* @param secondPointId id second line point.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @return the created tool
|
||||
*/
|
||||
VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, const QString &pointName,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolPointOfIntersection *VToolPointOfIntersection::Create(VToolPointOfIntersectionInitData initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
||||
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||
|
||||
QPointF point(firstPoint->x(), secondPoint->y());
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(point, pointName, mx, my));
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(point, pointName, mx, my));
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::PointOfIntersection, doc);
|
||||
VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId,
|
||||
secondPointId, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(firstPoint->getIdTool());
|
||||
doc->IncrementReferens(secondPoint->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::PointOfIntersection, initData.doc);
|
||||
VToolPointOfIntersection *point = new VToolPointOfIntersection(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -195,24 +185,6 @@ void VToolPointOfIntersection::RemoveReferens()
|
|||
doc->DecrementReferens(secondPoint->getIdTool());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersection>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SaveDialog save options into file after change in dialog.
|
||||
|
@ -258,6 +230,20 @@ void VToolPointOfIntersection::SetVisualization()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersection::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersection>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolPointOfIntersection::GetSecondPointId() const
|
||||
{
|
||||
|
@ -271,7 +257,7 @@ void VToolPointOfIntersection::SetSecondPointId(const quint32 &value)
|
|||
{
|
||||
secondPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +281,7 @@ void VToolPointOfIntersection::SetFirstPointId(const quint32 &value)
|
|||
{
|
||||
firstPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,18 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolPointOfIntersectionInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolPointOfIntersectionInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
firstPointId(NULL_ID),
|
||||
secondPointId(NULL_ID)
|
||||
{}
|
||||
|
||||
quint32 firstPointId;
|
||||
quint32 secondPointId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolPointOfIntersection class tool for creation point intersection two lines.
|
||||
*/
|
||||
|
@ -53,10 +65,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolPointOfIntersection *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolPointOfIntersection *Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId,
|
||||
const quint32 &secondPointId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static VToolPointOfIntersection *Create(VToolPointOfIntersectionInitData initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::PointOfIntersection) };
|
||||
|
@ -73,11 +82,12 @@ public:
|
|||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
private slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolPointOfIntersection)
|
||||
|
||||
|
@ -87,9 +97,7 @@ private:
|
|||
/** @brief secondPointId id second line point. */
|
||||
quint32 secondPointId;
|
||||
|
||||
VToolPointOfIntersection(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstPointId,
|
||||
const quint32 &secondPointId, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
VToolPointOfIntersection(const VToolPointOfIntersectionInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLPOINTOFINTERSECTION_H
|
||||
|
|
|
@ -55,13 +55,14 @@ template <class T> class QSharedPointer;
|
|||
const QString VToolPointOfIntersectionArcs::ToolType = QStringLiteral("pointOfIntersectionArcs");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
||||
const quint32 &firstArcId, const quint32 &secondArcId,
|
||||
CrossCirclesPoint pType, const Source &typeCreation,
|
||||
VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(const VToolPointOfIntersectionArcsInitData &initData,
|
||||
QGraphicsItem *parent)
|
||||
:VToolSinglePoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType)
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||
firstArcId(initData.firstArcId),
|
||||
secondArcId(initData.secondArcId),
|
||||
crossPoint(initData.pType)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -70,7 +71,7 @@ void VToolPointOfIntersectionArcs::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogPointOfIntersectionArcs> dialogTool = m_dialog.objectCast<DialogPointOfIntersectionArcs>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFirstArcId(firstArcId);
|
||||
dialogTool->SetSecondArcId(secondArcId);
|
||||
dialogTool->SetCrossArcPoint(crossPoint);
|
||||
|
@ -85,12 +86,19 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(QSharedPointe
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogPointOfIntersectionArcs> dialogTool = dialog.objectCast<DialogPointOfIntersectionArcs>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 firstArcId = dialogTool->GetFirstArcId();
|
||||
const quint32 secondArcId = dialogTool->GetSecondArcId();
|
||||
const CrossCirclesPoint pType = dialogTool->GetCrossArcPoint();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolPointOfIntersectionArcs *point = Create(0, pointName, firstArcId, secondArcId, pType, 5, 10, scene, doc,
|
||||
data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolPointOfIntersectionArcsInitData initData;
|
||||
initData.firstArcId = dialogTool->GetFirstArcId();
|
||||
initData.secondArcId = dialogTool->GetSecondArcId();
|
||||
initData.pType = dialogTool->GetCrossArcPoint();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolPointOfIntersectionArcs *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -99,42 +107,38 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(QSharedPointe
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 _id, const QString &pointName,
|
||||
const quint32 &firstArcId,
|
||||
const quint32 &secondArcId, CrossCirclesPoint pType,
|
||||
const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(VToolPointOfIntersectionArcsInitData initData)
|
||||
{
|
||||
const QSharedPointer<VArc> firstArc = data->GeometricObject<VArc>(firstArcId);
|
||||
const QSharedPointer<VArc> secondArc = data->GeometricObject<VArc>(secondArcId);
|
||||
const QSharedPointer<VArc> firstArc = initData.data->GeometricObject<VArc>(initData.firstArcId);
|
||||
const QSharedPointer<VArc> secondArc = initData.data->GeometricObject<VArc>(initData.secondArcId);
|
||||
|
||||
const QPointF point = FindPoint(firstArc.data(), secondArc.data(), pType);
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
const QPointF point = FindPoint(firstArc.data(), secondArc.data(), initData.pType);
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(point, pointName, mx, my));
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(point, pointName, mx, my));
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::PointOfIntersectionArcs, doc);
|
||||
VToolPointOfIntersectionArcs *point = new VToolPointOfIntersectionArcs(doc, data, id, firstArcId,
|
||||
secondArcId, pType, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(firstArc->getIdTool());
|
||||
doc->IncrementReferens(secondArc->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::PointOfIntersectionArcs, initData.doc);
|
||||
VToolPointOfIntersectionArcs *point = new VToolPointOfIntersectionArcs(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(firstArc->getIdTool());
|
||||
initData.doc->IncrementReferens(secondArc->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -247,7 +251,7 @@ void VToolPointOfIntersectionArcs::SetFirstArcId(const quint32 &value)
|
|||
{
|
||||
firstArcId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +269,7 @@ void VToolPointOfIntersectionArcs::SetSecondArcId(const quint32 &value)
|
|||
{
|
||||
secondArcId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +285,7 @@ void VToolPointOfIntersectionArcs::SetCrossCirclesPoint(const CrossCirclesPoint
|
|||
{
|
||||
crossPoint = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
|
@ -291,6 +295,20 @@ void VToolPointOfIntersectionArcs::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolPointOfIntersectionArcs>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionArcs::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersectionArcs>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionArcs::RemoveReferens()
|
||||
{
|
||||
|
@ -301,20 +319,6 @@ void VToolPointOfIntersectionArcs::RemoveReferens()
|
|||
doc->DecrementReferens(secondArc->getIdTool());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionArcs::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersectionArcs>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionArcs::SaveDialog(QDomElement &domElement)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,20 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolPointOfIntersectionArcsInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolPointOfIntersectionArcsInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
firstArcId(NULL_ID),
|
||||
secondArcId(NULL_ID),
|
||||
pType(CrossCirclesPoint::FirstPoint)
|
||||
{}
|
||||
|
||||
quint32 firstArcId;
|
||||
quint32 secondArcId;
|
||||
CrossCirclesPoint pType;
|
||||
};
|
||||
|
||||
class VToolPointOfIntersectionArcs : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -52,11 +66,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolPointOfIntersectionArcs *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, const quint32 &firstArcId,
|
||||
const quint32 &secondArcId, CrossCirclesPoint pType,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolPointOfIntersectionArcs *Create(VToolPointOfIntersectionArcsInitData initData);
|
||||
static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossCirclesPoint pType);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
@ -75,9 +85,10 @@ public:
|
|||
void SetCrossCirclesPoint(const CrossCirclesPoint &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -93,8 +104,7 @@ private:
|
|||
|
||||
CrossCirclesPoint crossPoint;
|
||||
|
||||
VToolPointOfIntersectionArcs(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstArcId,
|
||||
const quint32 &secondArcId, CrossCirclesPoint pType, const Source &typeCreation,
|
||||
VToolPointOfIntersectionArcs(const VToolPointOfIntersectionArcsInitData &initData,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
};
|
||||
|
||||
|
|
|
@ -56,19 +56,16 @@ template <class T> class QSharedPointer;
|
|||
const QString VToolPointOfIntersectionCircles::ToolType = QStringLiteral("pointOfIntersectionCircles");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionCircles::VToolPointOfIntersectionCircles(VAbstractPattern *doc, VContainer *data,
|
||||
const quint32 &id,
|
||||
quint32 firstCircleCenterId,
|
||||
quint32 secondCircleCenterId,
|
||||
const QString &firstCircleRadius,
|
||||
const QString &secondCircleRadius,
|
||||
CrossCirclesPoint crossPoint,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolSinglePoint(doc, data, id, parent), firstCircleCenterId(firstCircleCenterId),
|
||||
secondCircleCenterId(secondCircleCenterId), firstCircleRadius(firstCircleRadius),
|
||||
secondCircleRadius(secondCircleRadius), crossPoint(crossPoint)
|
||||
VToolPointOfIntersectionCircles::VToolPointOfIntersectionCircles(
|
||||
const VToolPointOfIntersectionCirclesInitData &initData, QGraphicsItem *parent)
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||
firstCircleCenterId(initData.firstCircleCenterId),
|
||||
secondCircleCenterId(initData.secondCircleCenterId),
|
||||
firstCircleRadius(initData.firstCircleRadius),
|
||||
secondCircleRadius(initData.secondCircleRadius),
|
||||
crossPoint(initData.crossPoint)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -78,7 +75,7 @@ void VToolPointOfIntersectionCircles::setDialog()
|
|||
QSharedPointer<DialogPointOfIntersectionCircles> dialogTool =
|
||||
m_dialog.objectCast<DialogPointOfIntersectionCircles>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFirstCircleCenterId(firstCircleCenterId);
|
||||
dialogTool->SetSecondCircleCenterId(secondCircleCenterId);
|
||||
dialogTool->SetFirstCircleRadius(firstCircleRadius);
|
||||
|
@ -93,18 +90,23 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(QShared
|
|||
VAbstractPattern *doc, VContainer *data)
|
||||
{
|
||||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogPointOfIntersectionCircles> dialogTool =
|
||||
dialog.objectCast<DialogPointOfIntersectionCircles>();
|
||||
QSharedPointer<DialogPointOfIntersectionCircles> dialogTool = dialog.objectCast<DialogPointOfIntersectionCircles>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 firstCircleCenterId = dialogTool->GetFirstCircleCenterId();
|
||||
const quint32 secondCircleCenterId = dialogTool->GetSecondCircleCenterId();
|
||||
QString firstCircleRadius = dialogTool->GetFirstCircleRadius();
|
||||
QString secondCircleRadius = dialogTool->GetSecondCircleRadius();
|
||||
const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolPointOfIntersectionCircles *point = Create(0, pointName, firstCircleCenterId, secondCircleCenterId,
|
||||
firstCircleRadius, secondCircleRadius, pType, 5, 10, scene, doc,
|
||||
data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolPointOfIntersectionCirclesInitData initData;
|
||||
initData.firstCircleCenterId = dialogTool->GetFirstCircleCenterId();
|
||||
initData.secondCircleCenterId = dialogTool->GetSecondCircleCenterId();
|
||||
initData.firstCircleRadius = dialogTool->GetFirstCircleRadius();
|
||||
initData.secondCircleRadius = dialogTool->GetSecondCircleRadius();
|
||||
initData.crossPoint = dialogTool->GetCrossCirclesPoint();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolPointOfIntersectionCircles *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -113,52 +115,43 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(QShared
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(const quint32 _id, const QString &pointName,
|
||||
quint32 firstCircleCenterId,
|
||||
quint32 secondCircleCenterId,
|
||||
QString &firstCircleRadius,
|
||||
QString &secondCircleRadius,
|
||||
CrossCirclesPoint crossPoint, const qreal &mx,
|
||||
const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolPointOfIntersectionCircles *
|
||||
VToolPointOfIntersectionCircles::Create(VToolPointOfIntersectionCirclesInitData &initData)
|
||||
{
|
||||
const qreal calcC1Radius = qApp->toPixel(CheckFormula(_id, firstCircleRadius, data));
|
||||
const qreal calcC2Radius = qApp->toPixel(CheckFormula(_id, secondCircleRadius, data));
|
||||
const qreal calcC1Radius = qApp->toPixel(CheckFormula(initData.id, initData.firstCircleRadius, initData.data));
|
||||
const qreal calcC2Radius = qApp->toPixel(CheckFormula(initData.id, initData.secondCircleRadius, initData.data));
|
||||
|
||||
const VPointF c1Point = *data->GeometricObject<VPointF>(firstCircleCenterId);
|
||||
const VPointF c2Point = *data->GeometricObject<VPointF>(secondCircleCenterId);
|
||||
const VPointF c1Point = *initData.data->GeometricObject<VPointF>(initData.firstCircleCenterId);
|
||||
const VPointF c2Point = *initData.data->GeometricObject<VPointF>(initData.secondCircleCenterId);
|
||||
|
||||
const QPointF point = FindPoint(static_cast<QPointF>(c1Point), static_cast<QPointF>(c2Point), calcC1Radius,
|
||||
calcC2Radius, crossPoint);
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
calcC2Radius, initData.crossPoint);
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(point, pointName, mx, my));
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(point, pointName, mx, my));
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::PointOfIntersectionCircles, doc);
|
||||
VToolPointOfIntersectionCircles *point = new VToolPointOfIntersectionCircles(doc, data, id, firstCircleCenterId,
|
||||
secondCircleCenterId,
|
||||
firstCircleRadius,
|
||||
secondCircleRadius, crossPoint,
|
||||
typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(c1Point.getIdTool());
|
||||
doc->IncrementReferens(c2Point.getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::PointOfIntersectionCircles, initData.doc);
|
||||
VToolPointOfIntersectionCircles *point = new VToolPointOfIntersectionCircles(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(c1Point.getIdTool());
|
||||
initData.doc->IncrementReferens(c2Point.getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -216,7 +209,7 @@ void VToolPointOfIntersectionCircles::SetFirstCircleCenterId(const quint32 &valu
|
|||
{
|
||||
firstCircleCenterId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +227,7 @@ void VToolPointOfIntersectionCircles::SetSecondCircleCenterId(const quint32 &val
|
|||
{
|
||||
secondCircleCenterId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -244,7 +237,7 @@ VFormula VToolPointOfIntersectionCircles::GetFirstCircleRadius() const
|
|||
{
|
||||
VFormula radius(firstCircleRadius, getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(id);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
return radius;
|
||||
}
|
||||
|
@ -257,7 +250,7 @@ void VToolPointOfIntersectionCircles::SetFirstCircleRadius(const VFormula &value
|
|||
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
|
||||
{
|
||||
firstCircleRadius = value.GetFormula(FormulaType::FromUser);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +261,7 @@ VFormula VToolPointOfIntersectionCircles::GetSecondCircleRadius() const
|
|||
{
|
||||
VFormula radius(secondCircleRadius, getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(id);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
return radius;
|
||||
}
|
||||
|
@ -281,7 +274,7 @@ void VToolPointOfIntersectionCircles::SetSecondCircleRadius(const VFormula &valu
|
|||
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
|
||||
{
|
||||
secondCircleRadius = value.GetFormula(FormulaType::FromUser);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +291,7 @@ void VToolPointOfIntersectionCircles::SetCrossCirclesPoint(const CrossCirclesPoi
|
|||
{
|
||||
crossPoint = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
|
@ -308,6 +301,20 @@ void VToolPointOfIntersectionCircles::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolPointOfIntersectionCircles>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersectionCircles>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::RemoveReferens()
|
||||
{
|
||||
|
@ -318,20 +325,6 @@ void VToolPointOfIntersectionCircles::RemoveReferens()
|
|||
doc->DecrementReferens(secondCircleCenter->getIdTool());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersectionCircles>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement)
|
||||
{
|
||||
|
|
|
@ -45,6 +45,24 @@
|
|||
class VFormula;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolPointOfIntersectionCirclesInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolPointOfIntersectionCirclesInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
firstCircleCenterId(NULL_ID),
|
||||
secondCircleCenterId(NULL_ID),
|
||||
firstCircleRadius("0"),
|
||||
secondCircleRadius("0"),
|
||||
crossPoint(CrossCirclesPoint::FirstPoint)
|
||||
{}
|
||||
|
||||
quint32 firstCircleCenterId;
|
||||
quint32 secondCircleCenterId;
|
||||
QString firstCircleRadius;
|
||||
QString secondCircleRadius;
|
||||
CrossCirclesPoint crossPoint;
|
||||
};
|
||||
|
||||
class VToolPointOfIntersectionCircles : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -52,13 +70,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolPointOfIntersectionCircles *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolPointOfIntersectionCircles *Create(const quint32 _id, const QString &pointName,
|
||||
quint32 firstCircleCenterId, quint32 secondCircleCenterId,
|
||||
QString &firstCircleRadius, QString &secondCircleRadius,
|
||||
CrossCirclesPoint crossPoint,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolPointOfIntersectionCircles *Create(VToolPointOfIntersectionCirclesInitData &initData);
|
||||
static QPointF FindPoint(const QPointF &c1Point, const QPointF &c2Point, qreal c1Radius, qreal c2Radius,
|
||||
const CrossCirclesPoint crossPoint);
|
||||
static const QString ToolType;
|
||||
|
@ -84,9 +96,10 @@ public:
|
|||
void SetCrossCirclesPoint(const CrossCirclesPoint &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -102,10 +115,7 @@ private:
|
|||
|
||||
CrossCirclesPoint crossPoint;
|
||||
|
||||
VToolPointOfIntersectionCircles(VAbstractPattern *doc, VContainer *data, const quint32 &id, const
|
||||
quint32 firstCircleCenterId, quint32 secondCircleCenterId,
|
||||
const QString &firstCircleRadius, const QString &secondCircleRadius,
|
||||
CrossCirclesPoint crossPoint, const Source &typeCreation,
|
||||
VToolPointOfIntersectionCircles(const VToolPointOfIntersectionCirclesInitData &initData,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
};
|
||||
|
||||
|
|
|
@ -55,18 +55,15 @@ template <class T> class QSharedPointer;
|
|||
const QString VToolPointOfIntersectionCurves::ToolType = QStringLiteral("pointOfIntersectionCurves");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionCurves::VToolPointOfIntersectionCurves(VAbstractPattern *doc, VContainer *data,
|
||||
const quint32 &id, const quint32 firstCurveId,
|
||||
quint32 secondCurveId, VCrossCurvesPoint vCrossPoint,
|
||||
HCrossCurvesPoint hCrossPoint, const Source &typeCreation,
|
||||
VToolPointOfIntersectionCurves::VToolPointOfIntersectionCurves(const VToolPointOfIntersectionCurvesInitData &initData,
|
||||
QGraphicsItem *parent)
|
||||
:VToolSinglePoint(doc, data, id, parent),
|
||||
firstCurveId(firstCurveId),
|
||||
secondCurveId(secondCurveId),
|
||||
vCrossPoint(vCrossPoint),
|
||||
hCrossPoint(hCrossPoint)
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||
firstCurveId(initData.firstCurveId),
|
||||
secondCurveId(initData.secondCurveId),
|
||||
vCrossPoint(initData.vCrossPoint),
|
||||
hCrossPoint(initData.hCrossPoint)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -75,7 +72,7 @@ void VToolPointOfIntersectionCurves::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
auto dialogTool = qobject_cast<DialogPointOfIntersectionCurves*>(m_dialog);
|
||||
SCASSERT(dialogTool != nullptr)
|
||||
auto p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
auto p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFirstCurveId(firstCurveId);
|
||||
dialogTool->SetSecondCurveId(secondCurveId);
|
||||
dialogTool->SetVCrossPoint(vCrossPoint);
|
||||
|
@ -91,13 +88,20 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(QSharedPo
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogPointOfIntersectionCurves> dialogTool = dialog.objectCast<DialogPointOfIntersectionCurves>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 firstCurveId = dialogTool->GetFirstCurveId();
|
||||
const quint32 secondCurveId = dialogTool->GetSecondCurveId();
|
||||
const VCrossCurvesPoint vCrossPoint = dialogTool->GetVCrossPoint();
|
||||
const HCrossCurvesPoint hCrossPoint = dialogTool->GetHCrossPoint();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolPointOfIntersectionCurves *point = Create(0, pointName, firstCurveId, secondCurveId, vCrossPoint, hCrossPoint,
|
||||
5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolPointOfIntersectionCurvesInitData initData;
|
||||
initData.firstCurveId = dialogTool->GetFirstCurveId();
|
||||
initData.secondCurveId = dialogTool->GetSecondCurveId();
|
||||
initData.vCrossPoint = dialogTool->GetVCrossPoint();
|
||||
initData.hCrossPoint = dialogTool->GetHCrossPoint();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolPointOfIntersectionCurves *point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -106,44 +110,39 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(QSharedPo
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(const quint32 _id, const QString &pointName,
|
||||
quint32 firstCurveId, quint32 secondCurveId,
|
||||
VCrossCurvesPoint vCrossPoint,
|
||||
HCrossCurvesPoint hCrossPoint, const qreal &mx,
|
||||
const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(VToolPointOfIntersectionCurvesInitData initData)
|
||||
{
|
||||
auto curve1 = data->GeometricObject<VAbstractCurve>(firstCurveId);
|
||||
auto curve2 = data->GeometricObject<VAbstractCurve>(secondCurveId);
|
||||
auto curve1 = initData.data->GeometricObject<VAbstractCurve>(initData.firstCurveId);
|
||||
auto curve2 = initData.data->GeometricObject<VAbstractCurve>(initData.secondCurveId);
|
||||
|
||||
const QPointF point = VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(),
|
||||
vCrossPoint, hCrossPoint);
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
initData.vCrossPoint, initData.hCrossPoint);
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(point, pointName, mx, my));
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(point, pointName, mx, my));
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::PointOfIntersectionCurves, doc);
|
||||
auto point = new VToolPointOfIntersectionCurves(doc, data, id, firstCurveId, secondCurveId, vCrossPoint,
|
||||
hCrossPoint, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(curve1->getIdTool());
|
||||
doc->IncrementReferens(curve2->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::PointOfIntersectionCurves, initData.doc);
|
||||
auto point = new VToolPointOfIntersectionCurves(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(curve1->getIdTool());
|
||||
initData.doc->IncrementReferens(curve2->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -287,7 +286,7 @@ void VToolPointOfIntersectionCurves::SetFirstCurveId(const quint32 &value)
|
|||
{
|
||||
firstCurveId = value;
|
||||
|
||||
auto obj = VAbstractTool::data.GetGObject(id);
|
||||
auto obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -305,7 +304,7 @@ void VToolPointOfIntersectionCurves::SetSecondCurveId(const quint32 &value)
|
|||
{
|
||||
secondCurveId = value;
|
||||
|
||||
auto obj = VAbstractTool::data.GetGObject(id);
|
||||
auto obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -321,7 +320,7 @@ void VToolPointOfIntersectionCurves::SetVCrossPoint(const VCrossCurvesPoint &val
|
|||
{
|
||||
vCrossPoint = value;
|
||||
|
||||
auto obj = VAbstractTool::data.GetGObject(id);
|
||||
auto obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
|
@ -336,7 +335,7 @@ void VToolPointOfIntersectionCurves::SetHCrossPoint(const HCrossCurvesPoint &val
|
|||
{
|
||||
hCrossPoint = value;
|
||||
|
||||
auto obj = VAbstractTool::data.GetGObject(id);
|
||||
auto obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
|
@ -346,6 +345,20 @@ void VToolPointOfIntersectionCurves::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolPointOfIntersectionCurves>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCurves::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersectionCurves>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCurves::RemoveReferens()
|
||||
{
|
||||
|
@ -356,20 +369,6 @@ void VToolPointOfIntersectionCurves::RemoveReferens()
|
|||
doc->DecrementReferens(curve2->getIdTool());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCurves::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersectionCurves>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement)
|
||||
{
|
||||
|
|
|
@ -45,6 +45,22 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolPointOfIntersectionCurvesInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolPointOfIntersectionCurvesInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
firstCurveId(NULL_ID),
|
||||
secondCurveId(NULL_ID),
|
||||
vCrossPoint(VCrossCurvesPoint::HighestPoint),
|
||||
hCrossPoint(HCrossCurvesPoint::LeftmostPoint)
|
||||
{}
|
||||
|
||||
quint32 firstCurveId;
|
||||
quint32 secondCurveId;
|
||||
VCrossCurvesPoint vCrossPoint;
|
||||
HCrossCurvesPoint hCrossPoint;
|
||||
};
|
||||
|
||||
class VToolPointOfIntersectionCurves : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -52,12 +68,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolPointOfIntersectionCurves *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolPointOfIntersectionCurves *Create(const quint32 _id, const QString &pointName,
|
||||
quint32 firstCurveId, quint32 secondCurveId,
|
||||
VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolPointOfIntersectionCurves *Create(VToolPointOfIntersectionCurvesInitData initData);
|
||||
static QPointF FindPoint(const QVector<QPointF> &curve1Points, const QVector<QPointF> &curve2Points,
|
||||
VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint);
|
||||
static const QString ToolType;
|
||||
|
@ -80,9 +91,10 @@ public:
|
|||
void SetHCrossPoint(const HCrossCurvesPoint &value);
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
|
@ -96,10 +108,8 @@ private:
|
|||
VCrossCurvesPoint vCrossPoint;
|
||||
HCrossCurvesPoint hCrossPoint;
|
||||
|
||||
explicit VToolPointOfIntersectionCurves(VAbstractPattern *doc, VContainer *data, const quint32 &id, const
|
||||
quint32 firstCurveId, quint32 secondCurveId,
|
||||
VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint,
|
||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||
explicit VToolPointOfIntersectionCurves(const VToolPointOfIntersectionCurvesInitData &initData,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLPOINTOFINTERSECTIONCURVES_H
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <new>
|
||||
|
||||
#include "../../../../undocommands/label/movelabel.h"
|
||||
#include "../../../../undocommands/label/showlabel.h"
|
||||
#include "../ifc/exception/vexception.h"
|
||||
#include "../ifc/exception/vexceptionbadid.h"
|
||||
#include "../ifc/ifcdef.h"
|
||||
|
@ -91,13 +92,13 @@ VToolSinglePoint::VToolSinglePoint(VAbstractPattern *doc, VContainer *data, quin
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolSinglePoint::name() const
|
||||
{
|
||||
return ObjectName<VPointF>(id);
|
||||
return ObjectName<VPointF>(m_id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSinglePoint::setName(const QString &name)
|
||||
{
|
||||
SetPointName(id, name);
|
||||
SetPointName(m_id, name);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -114,6 +115,31 @@ void VToolSinglePoint::GroupVisibility(quint32 object, bool visible)
|
|||
setVisible(visible);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VToolSinglePoint::IsLabelVisible(quint32 id) const
|
||||
{
|
||||
if (m_id == id)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
return point->IsShowLabel();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSinglePoint::SetLabelVisible(quint32 id, bool visible)
|
||||
{
|
||||
if (m_id == id)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
point->SetShowLabel(visible);
|
||||
RefreshPointGeometry(*point);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief NameChangePosition handle change posion point label.
|
||||
|
@ -121,7 +147,7 @@ void VToolSinglePoint::GroupVisibility(quint32 object, bool visible)
|
|||
*/
|
||||
void VToolSinglePoint::NameChangePosition(const QPointF &pos)
|
||||
{
|
||||
ChangePosition(this, id, pos);
|
||||
ChangePosition(this, m_id, pos);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -178,7 +204,7 @@ void VToolSinglePoint::EnableToolMove(bool move)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSinglePoint::PointChoosed()
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Point);
|
||||
emit ChoosedTool(m_id, SceneObject::Point);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -194,7 +220,7 @@ void VToolSinglePoint::PointSelected(bool selected)
|
|||
void VToolSinglePoint::FullUpdateFromFile()
|
||||
{
|
||||
ReadAttributes();
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(m_id));
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
|
@ -236,7 +262,7 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change,
|
|||
m_namePoint->blockSignals(true);
|
||||
m_namePoint->setSelected(value.toBool());
|
||||
m_namePoint->blockSignals(false);
|
||||
emit ChangedToolSelection(value.toBool(), id, id);
|
||||
emit ChangedToolSelection(value.toBool(), m_id, m_id);
|
||||
}
|
||||
|
||||
return VScenePoint::itemChange(change, value);
|
||||
|
@ -271,7 +297,7 @@ void VToolSinglePoint::keyReleaseEvent(QKeyEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSinglePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
ShowContextMenu(event, m_id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -285,6 +311,16 @@ void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &o
|
|||
doc->SetAttribute(tag, AttrName, point->name());
|
||||
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
|
||||
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
|
||||
doc->SetAttribute<bool>(tag, AttrShowLabel, point->IsShowLabel());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSinglePoint::ChangeLabelVisibility(quint32 id, bool visible)
|
||||
{
|
||||
if (id == m_id)
|
||||
{
|
||||
qApp->getUndoStack()->push(new ShowLabel(doc, id, visible));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -44,6 +44,22 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolSinglePointInitData : public VAbstractToolInitData
|
||||
{
|
||||
VToolSinglePointInitData()
|
||||
: VAbstractToolInitData(),
|
||||
name(),
|
||||
mx(5),
|
||||
my(10),
|
||||
showLabel(true)
|
||||
{}
|
||||
|
||||
QString name;
|
||||
qreal mx;
|
||||
qreal my;
|
||||
bool showLabel;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolSinglePoint class parent for all tools what create points.
|
||||
*/
|
||||
|
@ -63,6 +79,9 @@ public:
|
|||
void SetEnabled(bool enabled);
|
||||
|
||||
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual bool IsLabelVisible(quint32 id) const Q_DECL_OVERRIDE;
|
||||
virtual void SetLabelVisible(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||
public slots:
|
||||
void NameChangePosition(const QPointF &pos);
|
||||
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
|
||||
|
@ -85,6 +104,7 @@ protected:
|
|||
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ChangeLabelVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolSinglePoint)
|
||||
};
|
||||
|
|
|
@ -58,23 +58,17 @@ const QString VToolTriangle::ToolType = QStringLiteral("triangle");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolTriangle constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param axisP1Id id first axis point.
|
||||
* @param axisP2Id id second axis point.
|
||||
* @param firstPointId id first triangle point, what lies on the hypotenuse.
|
||||
* @param secondPointId id second triangle point, what lies on the hypotenuse.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolTriangle::VToolTriangle(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id,
|
||||
const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolSinglePoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId),
|
||||
secondPointId(secondPointId)
|
||||
VToolTriangle::VToolTriangle(const VToolTriangleInitData &initData, QGraphicsItem *parent)
|
||||
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||
axisP1Id(initData.axisP1Id),
|
||||
axisP2Id(initData.axisP2Id),
|
||||
firstPointId(initData.firstPointId),
|
||||
secondPointId(initData.secondPointId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -86,7 +80,7 @@ void VToolTriangle::setDialog()
|
|||
SCASSERT(not m_dialog.isNull())
|
||||
QSharedPointer<DialogTriangle> dialogTool = m_dialog.objectCast<DialogTriangle>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetAxisP1Id(axisP1Id);
|
||||
dialogTool->SetAxisP2Id(axisP2Id);
|
||||
dialogTool->SetFirstPointId(firstPointId);
|
||||
|
@ -109,13 +103,20 @@ VToolTriangle* VToolTriangle::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogTriangle> dialogTool = dialog.objectCast<DialogTriangle>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 axisP1Id = dialogTool->GetAxisP1Id();
|
||||
const quint32 axisP2Id = dialogTool->GetAxisP2Id();
|
||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolTriangle* point = Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10,
|
||||
scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
|
||||
VToolTriangleInitData initData;
|
||||
initData.axisP1Id = dialogTool->GetAxisP1Id();
|
||||
initData.axisP2Id = dialogTool->GetAxisP2Id();
|
||||
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||
initData.name = dialogTool->getPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolTriangle* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->m_dialog = dialogTool;
|
||||
|
@ -126,59 +127,46 @@ VToolTriangle* VToolTriangle::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||
* @param pointName point name.
|
||||
* @param axisP1Id id first axis point.
|
||||
* @param axisP2Id id second axis point.
|
||||
* @param firstPointId id first triangle point, what lies on the hypotenuse.
|
||||
* @param secondPointId id second triangle point, what lies on the hypotenuse.
|
||||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
* @param scene pointer to scene.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @return the created tool
|
||||
*/
|
||||
VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id,
|
||||
const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
||||
VToolTriangle* VToolTriangle::Create(VToolTriangleInitData initData)
|
||||
{
|
||||
const QSharedPointer<VPointF> axisP1 = data->GeometricObject<VPointF>(axisP1Id);
|
||||
const QSharedPointer<VPointF> axisP2 = data->GeometricObject<VPointF>(axisP2Id);
|
||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
||||
const QSharedPointer<VPointF> axisP1 = initData.data->GeometricObject<VPointF>(initData.axisP1Id);
|
||||
const QSharedPointer<VPointF> axisP2 = initData.data->GeometricObject<VPointF>(initData.axisP2Id);
|
||||
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||
|
||||
QPointF point = FindPoint(static_cast<QPointF>(*axisP1), static_cast<QPointF>(*axisP2),
|
||||
static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->AddGObject(new VPointF(point, pointName, mx, my));
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(id, new VPointF(point, pointName, mx, my));
|
||||
if (parse != Document::FullParse)
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::Triangle, doc);
|
||||
VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId,
|
||||
secondPointId, typeCreation);
|
||||
scene->addItem(point);
|
||||
InitToolConnections(scene, point);
|
||||
VAbstractPattern::AddTool(id, point);
|
||||
doc->IncrementReferens(axisP1->getIdTool());
|
||||
doc->IncrementReferens(axisP2->getIdTool());
|
||||
doc->IncrementReferens(firstPoint->getIdTool());
|
||||
doc->IncrementReferens(secondPoint->getIdTool());
|
||||
VAbstractTool::AddRecord(initData.id, Tool::Triangle, initData.doc);
|
||||
VToolTriangle *point = new VToolTriangle(initData);
|
||||
initData.scene->addItem(point);
|
||||
InitToolConnections(initData.scene, point);
|
||||
VAbstractPattern::AddTool(initData.id, point);
|
||||
initData.doc->IncrementReferens(axisP1->getIdTool());
|
||||
initData.doc->IncrementReferens(axisP2->getIdTool());
|
||||
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -273,24 +261,6 @@ void VToolTriangle::RemoveReferens()
|
|||
doc->DecrementReferens(secondPoint->getIdTool());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogTriangle>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SaveDialog save options into file after change in dialog.
|
||||
|
@ -344,6 +314,20 @@ void VToolTriangle::SetVisualization()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTriangle::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogTriangle>(event, id);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolTriangle::GetSecondPointId() const
|
||||
{
|
||||
|
@ -357,7 +341,7 @@ void VToolTriangle::SetSecondPointId(const quint32 &value)
|
|||
{
|
||||
secondPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +365,7 @@ void VToolTriangle::SetFirstPointId(const quint32 &value)
|
|||
{
|
||||
firstPointId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +383,7 @@ void VToolTriangle::SetAxisP2Id(const quint32 &value)
|
|||
{
|
||||
axisP2Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
@ -417,7 +401,7 @@ void VToolTriangle::SetAxisP1Id(const quint32 &value)
|
|||
{
|
||||
axisP1Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,22 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolTriangleInitData : public VToolSinglePointInitData
|
||||
{
|
||||
VToolTriangleInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
axisP1Id(NULL_ID),
|
||||
axisP2Id(NULL_ID),
|
||||
firstPointId(NULL_ID),
|
||||
secondPointId(NULL_ID)
|
||||
{}
|
||||
|
||||
quint32 axisP1Id;
|
||||
quint32 axisP2Id;
|
||||
quint32 firstPointId;
|
||||
quint32 secondPointId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolTriangle class for tool that find point intersection two foots right triangle
|
||||
* (triangle with 90 degree).
|
||||
|
@ -55,10 +71,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolTriangle *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolTriangle *Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id,
|
||||
const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data, const Document &parse, const Source &typeCreation);
|
||||
static VToolTriangle *Create(VToolTriangleInitData initData);
|
||||
static QPointF FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint);
|
||||
static const QString ToolType;
|
||||
|
@ -85,11 +98,12 @@ public:
|
|||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
private slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolTriangle)
|
||||
/** @brief axisP1Id id first axis point. */
|
||||
|
@ -104,10 +118,7 @@ private:
|
|||
/** @brief secondPointId id second triangle point, what lies on the hypotenuse. */
|
||||
quint32 secondPointId;
|
||||
|
||||
VToolTriangle(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id,
|
||||
const quint32 &axisP2Id,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
VToolTriangle(const VToolTriangleInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLTRIANGLE_H
|
||||
|
|
|
@ -106,19 +106,19 @@ void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName)
|
|||
void VDrawTool::SaveDialogChange()
|
||||
{
|
||||
qCDebug(vTool, "Saving tool options after using dialog");
|
||||
QDomElement oldDomElement = doc->elementById(id, getTagName());
|
||||
QDomElement oldDomElement = doc->elementById(m_id, getTagName());
|
||||
if (oldDomElement.isElement())
|
||||
{
|
||||
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
|
||||
SaveDialog(newDomElement);
|
||||
|
||||
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id);
|
||||
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, m_id);
|
||||
connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(saveOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "Can't find tool with id = %u", id);
|
||||
qCDebug(vTool, "Can't find tool with id = %u", m_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ void VDrawTool::SaveDialogChange()
|
|||
void VDrawTool::AddToFile()
|
||||
{
|
||||
QDomElement domElement = doc->createElement(getTagName());
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOptions(domElement, obj);
|
||||
AddToCalculation(domElement);
|
||||
}
|
||||
|
@ -138,20 +138,20 @@ void VDrawTool::AddToFile()
|
|||
void VDrawTool::SaveOption(QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
qCDebug(vTool, "Saving tool options");
|
||||
QDomElement oldDomElement = doc->elementById(id, getTagName());
|
||||
QDomElement oldDomElement = doc->elementById(m_id, getTagName());
|
||||
if (oldDomElement.isElement())
|
||||
{
|
||||
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
|
||||
|
||||
SaveOptions(newDomElement, obj);
|
||||
|
||||
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id);
|
||||
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, m_id);
|
||||
connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(saveOptions);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "Can't find tool with id = %u", id);
|
||||
qCDebug(vTool, "Can't find tool with id = %u", m_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ void VDrawTool::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
{
|
||||
Q_UNUSED(obj)
|
||||
|
||||
doc->SetAttribute(tag, VDomDocument::AttrId, id);
|
||||
doc->SetAttribute(tag, VDomDocument::AttrId, m_id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -185,14 +185,14 @@ bool VDrawTool::CorrectDisable(bool disable, const QString &namePP) const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VDrawTool::ReadAttributes()
|
||||
{
|
||||
const QDomElement domElement = doc->elementById(id, getTagName());
|
||||
const QDomElement domElement = doc->elementById(m_id, getTagName());
|
||||
if (domElement.isElement())
|
||||
{
|
||||
ReadToolAttributes(domElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "Can't find tool with id = %u", id);
|
||||
qCDebug(vTool, "Can't find tool with id = %u", m_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,6 +210,13 @@ void VDrawTool::DetailsMode(bool mode)
|
|||
// Do nothing.
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VDrawTool::ChangeLabelVisibility(quint32 id, bool visible)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
Q_UNUSED(visible)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AddToCalculation add tool to calculation tag in pattern file.
|
||||
|
@ -233,6 +240,20 @@ void VDrawTool::SetTypeLine(const QString &value)
|
|||
{
|
||||
m_lineType = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VDrawTool::IsLabelVisible(quint32 id) const
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VDrawTool::SetLabelVisible(quint32 id, bool visible)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
Q_UNUSED(visible)
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../vwidgets/vmaingraphicsview.h"
|
||||
#include "../vdatatool.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
|
@ -66,6 +67,9 @@ public:
|
|||
QString getLineType() const;
|
||||
virtual void SetTypeLine(const QString &value);
|
||||
|
||||
virtual bool IsLabelVisible(quint32 id) const;
|
||||
virtual void SetLabelVisible(quint32 id, bool visible);
|
||||
|
||||
signals:
|
||||
void ChangedToolSelection(bool selected, quint32 object, quint32 tool);
|
||||
|
||||
|
@ -76,6 +80,8 @@ public slots:
|
|||
virtual void EnableToolMove(bool move);
|
||||
virtual void Disable(bool disable, const QString &namePP)=0;
|
||||
virtual void DetailsMode(bool mode);
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID)=0;
|
||||
protected:
|
||||
|
||||
enum class RemoveOption : bool {Disable = false, Enable = true};
|
||||
|
@ -101,9 +107,10 @@ protected:
|
|||
|
||||
void ReadAttributes();
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement)=0;
|
||||
virtual void ChangeLabelVisibility(quint32 id, bool visible);
|
||||
|
||||
template <typename Dialog, typename Tool>
|
||||
void ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event,
|
||||
template <typename Dialog>
|
||||
void ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemId = NULL_ID,
|
||||
const RemoveOption &showRemove = RemoveOption::Enable,
|
||||
const Referens &ref = Referens::Follow);
|
||||
|
||||
|
@ -120,18 +127,17 @@ private:
|
|||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename Dialog, typename Tool>
|
||||
template <typename Dialog>
|
||||
/**
|
||||
* @brief ContextMenu show context menu for tool.
|
||||
* @param tool tool.
|
||||
* @param event context menu event.
|
||||
* @param itemId id of point. 0 if not a point
|
||||
* @param showRemove true - tool enable option delete.
|
||||
* @param ref true - do not ignore referens value.
|
||||
*/
|
||||
void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, const RemoveOption &showRemove,
|
||||
void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemId, const RemoveOption &showRemove,
|
||||
const Referens &ref)
|
||||
{
|
||||
SCASSERT(tool != nullptr)
|
||||
SCASSERT(event != nullptr)
|
||||
|
||||
if (m_suppressContextMenu)
|
||||
|
@ -142,6 +148,18 @@ void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, c
|
|||
qCDebug(vTool, "Creating tool context menu.");
|
||||
QMenu menu;
|
||||
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
||||
|
||||
QAction *actionShowLabel = menu.addAction(tr("Show label"));
|
||||
actionShowLabel->setCheckable(true);
|
||||
if (itemId != NULL_ID)
|
||||
{
|
||||
actionShowLabel->setChecked(IsLabelVisible(itemId));
|
||||
}
|
||||
else
|
||||
{
|
||||
actionShowLabel->setVisible(false);
|
||||
}
|
||||
|
||||
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
||||
if (showRemove == RemoveOption::Enable)
|
||||
{
|
||||
|
@ -175,22 +193,26 @@ void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, c
|
|||
{
|
||||
qCDebug(vTool, "Show options.");
|
||||
qApp->getSceneView()->itemClicked(nullptr);
|
||||
m_dialog = QSharedPointer<Dialog>(new Dialog(getData(), id, qApp->getMainWindow()));
|
||||
m_dialog = QSharedPointer<Dialog>(new Dialog(getData(), m_id, qApp->getMainWindow()));
|
||||
m_dialog->setModal(true);
|
||||
|
||||
connect(m_dialog.data(), &DialogTool::DialogClosed, tool, &Tool::FullUpdateFromGuiOk);
|
||||
connect(m_dialog.data(), &DialogTool::DialogApplied, tool, &Tool::FullUpdateFromGuiApply);
|
||||
connect(m_dialog.data(), &DialogTool::DialogClosed, this, &VDrawTool::FullUpdateFromGuiOk);
|
||||
connect(m_dialog.data(), &DialogTool::DialogApplied, this, &VDrawTool::FullUpdateFromGuiApply);
|
||||
|
||||
tool->setDialog();
|
||||
this->setDialog();
|
||||
|
||||
m_dialog->show();
|
||||
}
|
||||
if (selectedAction == actionRemove)
|
||||
else if (selectedAction == actionRemove)
|
||||
{
|
||||
qCDebug(vTool, "Deleting tool.");
|
||||
DeleteTool(); // do not catch exception here
|
||||
return; //Leave this method immediately after call!!!
|
||||
}
|
||||
else if (selectedAction == actionShowLabel)
|
||||
{
|
||||
ChangeLabelVisibility(itemId, selectedAction->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -204,7 +226,7 @@ template <typename Item>
|
|||
void VDrawTool::ShowItem(Item *item, quint32 id, bool enable)
|
||||
{
|
||||
SCASSERT(item != nullptr)
|
||||
if (id == item->id)
|
||||
if (id == item->m_id)
|
||||
{
|
||||
ShowVisualization(enable);
|
||||
}
|
||||
|
|
|
@ -57,33 +57,25 @@ template <class T> class QSharedPointer;
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolLine constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param firstPoint id first line point.
|
||||
* @param secondPoint id second line point.
|
||||
* @param typeLine line type.
|
||||
* @param typeCreation way we create this tool.
|
||||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint,
|
||||
const QString &typeLine, const QString &lineColor, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VDrawTool(doc, data, id),
|
||||
VToolLine::VToolLine(const VToolLineInitData &initData, QGraphicsItem *parent)
|
||||
:VDrawTool(initData.doc, initData.data, initData.id),
|
||||
QGraphicsLineItem(parent),
|
||||
firstPoint(firstPoint),
|
||||
secondPoint(secondPoint),
|
||||
lineColor(lineColor),
|
||||
firstPoint(initData.firstPoint),
|
||||
secondPoint(initData.secondPoint),
|
||||
lineColor(initData.lineColor),
|
||||
m_isHovered(false)
|
||||
{
|
||||
this->m_lineType = typeLine;
|
||||
this->m_lineType = initData.typeLine;
|
||||
//Line
|
||||
RefreshGeometry();
|
||||
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -115,13 +107,19 @@ VToolLine *VToolLine::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsSce
|
|||
SCASSERT(not dialog.isNull())
|
||||
QSharedPointer<DialogLine> dialogTool = dialog.objectCast<DialogLine>();
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
const quint32 firstPoint = dialogTool->GetFirstPoint();
|
||||
const quint32 secondPoint = dialogTool->GetSecondPoint();
|
||||
const QString typeLine = dialogTool->GetTypeLine();
|
||||
const QString lineColor = dialogTool->GetLineColor();
|
||||
|
||||
VToolLine *line = Create(0, firstPoint, secondPoint, typeLine, lineColor, scene, doc, data, Document::FullParse,
|
||||
Source::FromGui);
|
||||
VToolLineInitData initData;
|
||||
initData.firstPoint = dialogTool->GetFirstPoint();
|
||||
initData.secondPoint = dialogTool->GetSecondPoint();
|
||||
initData.typeLine = dialogTool->GetTypeLine();
|
||||
initData.lineColor = dialogTool->GetLineColor();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
initData.data = data;
|
||||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
|
||||
VToolLine *line = Create(initData);
|
||||
if (line != nullptr)
|
||||
{
|
||||
line->m_dialog = dialogTool;
|
||||
|
@ -142,45 +140,41 @@ VToolLine *VToolLine::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsSce
|
|||
* @param parse parser file mode.
|
||||
* @param typeCreation way we create this tool.
|
||||
*/
|
||||
VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
|
||||
const QString &typeLine, const QString &lineColor, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
VToolLine * VToolLine::Create(VToolLineInitData initData)
|
||||
{
|
||||
SCASSERT(scene != nullptr)
|
||||
SCASSERT(doc != nullptr)
|
||||
SCASSERT(data != nullptr)
|
||||
quint32 id = _id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
SCASSERT(initData.scene != nullptr)
|
||||
SCASSERT(initData.doc != nullptr)
|
||||
SCASSERT(initData.data != nullptr)
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
id = VContainer::getNextId();
|
||||
data->AddLine(firstPoint, secondPoint);
|
||||
initData.id = VContainer::getNextId();
|
||||
initData.data->AddLine(initData.firstPoint, initData.secondPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
VContainer::UpdateId(id);
|
||||
data->AddLine(firstPoint, secondPoint);
|
||||
if (parse != Document::FullParse)
|
||||
VContainer::UpdateId(initData.id);
|
||||
initData.data->AddLine(initData.firstPoint, initData.secondPoint);
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
}
|
||||
}
|
||||
|
||||
if (parse == Document::FullParse)
|
||||
if (initData.parse == Document::FullParse)
|
||||
{
|
||||
VAbstractTool::AddRecord(id, Tool::Line, doc);
|
||||
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, lineColor, typeCreation);
|
||||
scene->addItem(line);
|
||||
InitDrawToolConnections(scene, line);
|
||||
connect(scene, &VMainGraphicsScene::EnableLineItemSelection, line, &VToolLine::AllowSelecting);
|
||||
connect(scene, &VMainGraphicsScene::EnableLineItemHover, line, &VToolLine::AllowHover);
|
||||
VAbstractPattern::AddTool(id, line);
|
||||
VAbstractTool::AddRecord(initData.id, Tool::Line, initData.doc);
|
||||
VToolLine *line = new VToolLine(initData);
|
||||
initData.scene->addItem(line);
|
||||
InitDrawToolConnections(initData.scene, line);
|
||||
connect(initData.scene, &VMainGraphicsScene::EnableLineItemSelection, line, &VToolLine::AllowSelecting);
|
||||
connect(initData.scene, &VMainGraphicsScene::EnableLineItemHover, line, &VToolLine::AllowHover);
|
||||
VAbstractPattern::AddTool(initData.id, line);
|
||||
|
||||
const QSharedPointer<VPointF> first = data->GeometricObject<VPointF>(firstPoint);
|
||||
const QSharedPointer<VPointF> second = data->GeometricObject<VPointF>(secondPoint);
|
||||
const QSharedPointer<VPointF> first = initData.data->GeometricObject<VPointF>(initData.firstPoint);
|
||||
const QSharedPointer<VPointF> second = initData.data->GeometricObject<VPointF>(initData.secondPoint);
|
||||
|
||||
doc->IncrementReferens(first->getIdTool());
|
||||
doc->IncrementReferens(second->getIdTool());
|
||||
initData.doc->IncrementReferens(first->getIdTool());
|
||||
initData.doc->IncrementReferens(second->getIdTool());
|
||||
return line;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -256,15 +250,12 @@ void VToolLine::AllowSelecting(bool enabled)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogLine>(this, event);
|
||||
ContextMenu<DialogLine>(event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
|
@ -273,6 +264,16 @@ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
* @param event context menu event.
|
||||
*/
|
||||
void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
ShowContextMenu(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AddToFile add tag with informations about tool into file.
|
||||
|
@ -335,7 +336,7 @@ QVariant VToolLine::itemChange(QGraphicsItem::GraphicsItemChange change, const Q
|
|||
{
|
||||
if (change == QGraphicsItem::ItemSelectedChange)
|
||||
{
|
||||
emit ChangedToolSelection(value.toBool(), id, id);
|
||||
emit ChangedToolSelection(value.toBool(), m_id, m_id);
|
||||
}
|
||||
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
|
|
|
@ -45,6 +45,22 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolLineInitData : public VAbstractToolInitData
|
||||
{
|
||||
VToolLineInitData()
|
||||
: VAbstractToolInitData(),
|
||||
firstPoint(NULL_ID),
|
||||
secondPoint(NULL_ID),
|
||||
typeLine(TypeLineLine),
|
||||
lineColor(ColorBlack)
|
||||
{}
|
||||
|
||||
quint32 firstPoint;
|
||||
quint32 secondPoint;
|
||||
QString typeLine;
|
||||
QString lineColor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolLine class tool for creation line.
|
||||
*/
|
||||
|
@ -55,10 +71,7 @@ public:
|
|||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolLine *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolLine *Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
|
||||
const QString &typeLine, const QString &lineColor, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static VToolLine *Create(VToolLineInitData initData);
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::Line)};
|
||||
|
@ -89,6 +102,8 @@ public slots:
|
|||
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
|
||||
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
||||
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
||||
protected slots:
|
||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void AddToFile() Q_DECL_OVERRIDE;
|
||||
|
@ -116,9 +131,7 @@ private:
|
|||
|
||||
bool m_isHovered;
|
||||
|
||||
VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint,
|
||||
const QString &typeLine, const QString &lineColor, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
VToolLine(const VToolLineInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
|
||||
void RefreshGeometry();
|
||||
};
|
||||
|
|
|
@ -90,7 +90,7 @@ void VAbstractNode::incrementReferens()
|
|||
doc->IncrementReferens(node->getIdTool());
|
||||
}
|
||||
ShowNode();
|
||||
QDomElement domElement = doc->elementById(id, getTagName());
|
||||
QDomElement domElement = doc->elementById(m_id, getTagName());
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
|
||||
|
@ -117,7 +117,7 @@ void VAbstractNode::decrementReferens()
|
|||
doc->DecrementReferens(node->getIdTool());
|
||||
}
|
||||
HideNode();
|
||||
QDomElement domElement = doc->elementById(id, getTagName());
|
||||
QDomElement domElement = doc->elementById(m_id, getTagName());
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
|
||||
|
|
|
@ -41,6 +41,20 @@
|
|||
|
||||
enum class ParentType : bool {Scene, Item};
|
||||
|
||||
struct VAbstractNodeInitData : public VAbstractToolInitData
|
||||
{
|
||||
VAbstractNodeInitData()
|
||||
: VAbstractToolInitData(),
|
||||
idObject(NULL_ID),
|
||||
drawName(),
|
||||
idTool(NULL_ID)
|
||||
{}
|
||||
|
||||
quint32 idObject;
|
||||
QString drawName;
|
||||
quint32 idTool;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VAbstractNode class parent class for all detail node.
|
||||
*/
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user