Fixed issue with deleting detail and blocked objects. Part about tool union

still is not fixed.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-12-26 15:08:41 +02:00
parent 4d3aeaca08
commit 00b8aae5a7
29 changed files with 764 additions and 239 deletions

View File

@ -1790,6 +1790,7 @@ void MainWindow::ActionDraw(bool checked)
leftGoToStage->setPixmap(QPixmap("://icon/24x24/fast_forward_left_to_right_arrow.png"));
rightGoToStage->setPixmap(QPixmap("://icon/24x24/left_to_right_arrow.png"));
ui->actionDraw->setChecked(true);
ui->actionDetails->setChecked(false);
ui->actionLayout->setChecked(false);
SaveCurrentScene();
@ -1868,6 +1869,7 @@ void MainWindow::ActionDetails(bool checked)
rightGoToStage->setPixmap(QPixmap("://icon/24x24/left_to_right_arrow.png"));
ui->actionDraw->setChecked(false);
ui->actionDetails->setChecked(true);
ui->actionLayout->setChecked(false);
SaveCurrentScene();
@ -1955,6 +1957,7 @@ void MainWindow::ActionLayout(bool checked)
ui->actionDraw->setChecked(false);
ui->actionDetails->setChecked(false);
ui->actionLayout->setChecked(true);
SaveCurrentScene();
PrepareDetailsForLayout(details);
@ -2192,7 +2195,7 @@ void MainWindow::Clear()
qCDebug(vMainWindow, "Reseting main window.");
lock.reset();
qCDebug(vMainWindow, "Unlocked pattern file.");
ui->actionDraw->setChecked(true);
ActionDraw(true);
qCDebug(vMainWindow, "Returned to Draw mode.");
pattern->Clear();
qCDebug(vMainWindow, "Clearing pattern.");
@ -2489,9 +2492,7 @@ void MainWindow::Layout()
else
{
listDetails.clear();
ui->actionDetails->setChecked(false);
ui->actionLayout->setChecked(false);
ui->actionDraw->setChecked(true);
ActionDraw(true);
SetLayoutModeActions(false);
}
}
@ -3543,7 +3544,7 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
//Fit scene size to best size for first show
ZoomFirstShow();
ui->actionDraw->setChecked(true);
ActionDraw(true);
}
qApp->setOpeningPattern();// End opening file
return true;

View File

@ -91,6 +91,13 @@ void VPattern::CreateEmptyFile()
insertBefore(createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), this->firstChild());
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::setXMLContent(const QString &fileName)
{
VDomDocument::setXMLContent(fileName);
GarbageCollector();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Parse parse file.
@ -1272,10 +1279,11 @@ void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &par
PointsCommonAttributes(domElement, id, mx, my);
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
const NodeUsage inUse = GetParametrUsage(domElement, VAbstractNode::AttrInUse);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idObject );
data->UpdateGObject(id, new VPointF(point->toQPointF(), point->name(), mx, my, idObject,
Draw::Modeling));
VNodePoint::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
VNodePoint::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, inUse, idTool);
}
catch (const VExceptionBadId &e)
{
@ -1892,11 +1900,12 @@ void VPattern::ParseNodeSpline(const QDomElement &domElement, const Document &pa
quint32 idTool = 0;
SplinesCommonAttributes(domElement, id, idObject, idTool);
const NodeUsage inUse = GetParametrUsage(domElement, VAbstractNode::AttrInUse);
VSpline *spl = new VSpline(*data->GeometricObject<VSpline>(idObject));
spl->setIdObject(idObject);
spl->setMode(Draw::Modeling);
data->UpdateGObject(id, spl);
VNodeSpline::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
VNodeSpline::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, inUse, idTool);
}
catch (const VExceptionBadId &e)
{
@ -1918,11 +1927,12 @@ void VPattern::ParseNodeSplinePath(const QDomElement &domElement, const Document
quint32 idTool = 0;
SplinesCommonAttributes(domElement, id, idObject, idTool);
const NodeUsage inUse = GetParametrUsage(domElement, VAbstractNode::AttrInUse);
VSplinePath *path = new VSplinePath(*data->GeometricObject<VSplinePath>(idObject));
path->setIdObject(idObject);
path->setMode(Draw::Modeling);
data->UpdateGObject(id, path);
VNodeSplinePath::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
VNodeSplinePath::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, inUse, idTool);
}
catch (const VExceptionBadId &e)
{
@ -1989,11 +1999,12 @@ void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse
ToolsCommonAttributes(domElement, id);
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
const NodeUsage inUse = GetParametrUsage(domElement, VAbstractNode::AttrInUse);
VArc *arc = new VArc(*data->GeometricObject<VArc>(idObject));
arc->setIdObject(idObject);
arc->setMode(Draw::Modeling);
data->UpdateGObject(id, arc);
VNodeArc::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
VNodeArc::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, inUse, idTool);
}
catch (const VExceptionBadId &e)
{
@ -2111,6 +2122,44 @@ QDomElement VPattern::FindIncrement(const QString &name) const
return QDomElement();
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::GarbageCollector()
{
QDomNodeList modelingList = elementsByTagName(TagModeling);
for (int i=0; i < modelingList.size(); ++i)
{
QDomElement modElement = modelingList.at(i).toElement();
if (not modElement.isNull())
{
QDomElement modNode = modElement.firstChild().toElement();
while (not modNode.isNull())
{
// First get next sibling because later will not have chance to get it
QDomElement nextSibling = modNode.nextSibling().toElement();
if (modNode.hasAttribute(VAbstractNode::AttrInUse))
{
const NodeUsage inUse = GetParametrUsage(modNode, VAbstractNode::AttrInUse);
if (inUse == NodeUsage::InUse)
{ // It is dangerous to leave object with attribute 'inUse'
// Each parse should confirm this status.
modNode.removeAttribute(VAbstractNode::AttrInUse);
}
else
{ // Parent was deleted. We do not need this object anymore
modElement.removeChild(modNode);
}
}
else
{ // Last parse did not confirm use of an object
modElement.removeChild(modNode); // was not used
}
modNode = nextSibling;
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ParseSplineElement parse spline tag.

View File

@ -58,6 +58,7 @@ public:
quint32 SPointActiveDraw();
virtual void setXMLContent(const QString &fileName) Q_DECL_OVERRIDE;
virtual bool SaveDocument(const QString &fileName, QString &error) const Q_DECL_OVERRIDE;
QRectF ActiveDrawBoundingRect() const;
@ -174,6 +175,8 @@ private:
QDomElement MakeEmptyIncrement(const QString &name);
QDomElement FindIncrement(const QString &name) const;
void GarbageCollector();
};
#endif // VPATTERN_H

View File

@ -8,6 +8,7 @@
<file>schema/pattern/v0.2.0.xsd</file>
<file>schema/pattern/v0.2.1.xsd</file>
<file>schema/pattern/v0.2.2.xsd</file>
<file>schema/pattern/v0.2.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>

View File

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

View File

@ -274,6 +274,33 @@ bool VDomDocument::GetParametrBool(const QDomElement &domElement, const QString
return val;
}
//---------------------------------------------------------------------------------------------------------------------
NodeUsage VDomDocument::GetParametrUsage(const QDomElement &domElement, const QString &name) const
{
const bool value = GetParametrBool(domElement, name, QStringLiteral("true"));
if (value)
{
return NodeUsage::InUse;
}
else
{
return NodeUsage::NotInUse;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VDomDocument::SetParametrUsage(QDomElement &domElement, const QString &name, const NodeUsage &value)
{
if (value == NodeUsage::InUse)
{
domElement.setAttribute(name, QStringLiteral("true"));
}
else
{
domElement.setAttribute(name, QStringLiteral("false"));
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the string value of the given attribute. RENAME: see above
@ -794,6 +821,7 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q
if (result)
{
QFile::remove(destination);
if (not destFile.rename(destination))
{
error = destFile.errorString();

View File

@ -87,13 +87,17 @@ public:
quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, const QString &defValue) const;
bool GetParametrBool(const QDomElement& domElement, const QString &name, const QString &defValue) const;
NodeUsage GetParametrUsage(const QDomElement& domElement, const QString &name) const;
void SetParametrUsage(QDomElement& domElement, const QString &name, const NodeUsage &value);
QString GetParametrString(const QDomElement& domElement, const QString &name,
const QString &defValue = QString()) const;
qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const;
quint32 GetParametrId(const QDomElement& domElement) const;
static void ValidateXML(const QString &schema, const QString &fileName);
void setXMLContent(const QString &fileName);
virtual void setXMLContent(const QString &fileName);
static Unit StrToUnits(const QString &unit);
static QString UnitsToStr(const Unit &unit, const bool translate = false);
static QString UnitsHelpString();

View File

@ -43,8 +43,8 @@
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.2");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.2.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.3");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.3.xsd");
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName)
@ -104,6 +104,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000201):
return QStringLiteral("://schema/pattern/v0.2.1.xsd");
case (0x000202):
return QStringLiteral("://schema/pattern/v0.2.2.xsd");
case (0x000203):
return CurrentSchema;
default:
{
@ -170,6 +172,13 @@ void VPatternConverter::ApplyPatches()
V_FALLTHROUGH
}
case (0x000202):
{
ToV0_2_3();
const QString schema = XSDSchema(0x000203);
ValidateXML(schema, fileName);
V_FALLTHROUGH
}
case (0x000203):
break;
default:
break;
@ -248,6 +257,13 @@ void VPatternConverter::ToV0_2_2()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_2_3()
{
SetVersion(QStringLiteral("0.2.3"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -62,6 +62,7 @@ private:
void ToV0_2_0();
void ToV0_2_1();
void ToV0_2_2();
void ToV0_2_3();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -54,6 +54,7 @@ enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Un
enum class MeasurementsType : char { Standard, Individual , Unknown};
enum class Unit : char { Mm = 0, Cm, Inch, Px, LAST_UNIT_DO_NOT_USE};
enum class Source : char { FromGui, FromFile, FromTool };
enum class NodeUsage : bool {NotInUse = false, InUse = true};
typedef unsigned char ToolVisHolderType;
enum class Tool : ToolVisHolderType

View File

@ -47,6 +47,7 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::BasePoint)};
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
virtual void decrementReferens() Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
@ -60,7 +61,6 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void AddToFile() Q_DECL_OVERRIDE;
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void decrementReferens() Q_DECL_OVERRIDE;
virtual void DeleteTool(bool ask = true) Q_DECL_OVERRIDE;
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;

View File

@ -33,6 +33,7 @@
const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject");
const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool");
const QString VAbstractNode::AttrInUse = QStringLiteral("inUse");
//---------------------------------------------------------------------------------------------------------------------
/**
@ -51,23 +52,6 @@ VAbstractNode::VAbstractNode(VAbstractPattern *doc, VContainer *data, const quin
_referens = 0;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractNode::DeleteNode()
{
if (_referens <= 1)
{
RemoveReferens();//deincrement referens
}
}
void VAbstractNode::RestoreNode()
{
if (_referens <= 1)
{
RestoreReferens();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractNode::ShowVisualization(bool show)
{
@ -75,14 +59,22 @@ void VAbstractNode::ShowVisualization(bool show)
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToModeling add tag to modeling tag current pattern peace.
* @param domElement tag.
*/
void VAbstractNode::AddToModeling(const QDomElement &domElement)
void VAbstractNode::incrementReferens()
{
AddDetNode *addNode = new AddDetNode(domElement, doc);
qApp->getUndoStack()->push(addNode);
if (_referens <= 0)
{
++_referens;
}
if (_referens > 0)
{
idTool != NULL_ID ? doc->IncrementReferens(idTool) : doc->IncrementReferens(idNode);
ShowNode();
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -97,41 +89,23 @@ void VAbstractNode::decrementReferens()
}
if (_referens <= 0)
{
doc->DecrementReferens(idNode);
idTool != NULL_ID ? doc->DecrementReferens(idTool) : doc->DecrementReferens(idNode);
HideNode();
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
QDomNode element = domElement.parentNode();
if (element.isNull() == false)
{
element.removeChild(domElement);
}
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractNode::RemoveReferens()
/**
* @brief AddToModeling add tag to modeling tag current pattern peace.
* @param domElement tag.
*/
void VAbstractNode::AddToModeling(const QDomElement &domElement)
{
if (idTool != 0)
{
doc->DecrementReferens(idTool);
}
else
{
doc->DecrementReferens(idNode);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractNode::RestoreReferens()
{
if (idTool != 0)
{
doc->IncrementReferens(idTool);
}
else
{
doc->IncrementReferens(idNode);
}
AddDetNode *addNode = new AddDetNode(domElement, doc);
qApp->getUndoStack()->push(addNode);
}

View File

@ -45,9 +45,10 @@ public:
virtual ~VAbstractNode() Q_DECL_OVERRIDE {}
static const QString AttrIdObject;
static const QString AttrIdTool;
virtual void DeleteNode();
virtual void RestoreNode();
static const QString AttrInUse;
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
virtual void incrementReferens() Q_DECL_OVERRIDE;
virtual void decrementReferens() Q_DECL_OVERRIDE;
protected:
/** @brief idNodenode id. */
quint32 idNode;
@ -59,10 +60,10 @@ protected:
QColor currentColor;
void AddToModeling(const QDomElement &domElement);
virtual void decrementReferens() Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;
virtual void RestoreReferens();
virtual void SetVisualization() {}
virtual void ShowNode()=0;
virtual void HideNode()=0;
};
#endif // VABSTRACTNODE_H

View File

@ -68,25 +68,37 @@ VNodeArc::VNodeArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32
* @param idTool tool id.
* @param parent QObject parent
*/
void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, quint32 idArc,
const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool, QObject *parent)
{
VAbstractTool::AddRecord(id, Tool::NodeArc, doc);
if (parse == Document::FullParse)
{
VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeCreation, idTool, parent);
// Try to prevent memory leak
arc->hide();// If no one will use node, it will stay hidden
scene->addItem(arc);// First adopted by scene
doc->AddTool(id, arc);
if (idTool != 0)
if (idTool != NULL_ID)
{
doc->IncrementReferens(idTool);
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idTool);
}
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
VDataTool *tool = doc->getTool(idTool);
SCASSERT(tool != nullptr);
arc->setParent(tool);
arc->setParent(tool);// Adopted by a tool
}
else
{
doc->IncrementReferens(idArc);
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idArc);
}
}
}
else
@ -95,26 +107,6 @@ void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DeleteNode delete node from detail.
*/
void VNodeArc::DeleteNode()
{
VAbstractNode::DeleteNode();
this->setVisible(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeArc::RestoreNode()
{
if (this->isVisible() == false)
{
VAbstractNode::RestoreNode();
this->setVisible(true);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VNodeArc::getTagName() const
{
@ -203,6 +195,18 @@ void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeArc::ShowNode()
{
show();
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeArc::HideNode()
{
hide();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -42,12 +42,12 @@ public:
VNodeArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idArc, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool = 0,
QObject *parent = nullptr);
static const QString TagName;
static const QString ToolType;
virtual void DeleteNode() Q_DECL_OVERRIDE;
virtual void RestoreNode() Q_DECL_OVERRIDE;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::NodeArc)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
@ -59,6 +59,8 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void ShowNode() Q_DECL_OVERRIDE;
virtual void HideNode() Q_DECL_OVERRIDE;
private:
void RefreshGeometry();
};

View File

@ -81,7 +81,7 @@ VNodePoint::VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quin
*/
void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene,
quint32 id, quint32 idPoint, const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool, QObject *parent)
{
VAbstractTool::AddRecord(id, Tool::NodePoint, doc);
if (parse == Document::FullParse)
@ -89,19 +89,30 @@ void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsSc
//TODO Need create garbage collector and remove all nodes, what we don't use.
//Better check garbage before each saving file. Check only modeling tags.
VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, idTool, parent);
// Try to prevent memory leak
point->hide();// If no one will use node, it will stay hidden
scene->addItem(point);// First adopted by scene
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VNodePoint::EnableToolMove);
doc->AddTool(id, point);
if (idTool != 0)
if (idTool != NULL_ID)
{
doc->IncrementReferens(idTool);
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idTool);
}
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
VDataTool *tool = doc->getTool(idTool);
SCASSERT(tool != nullptr);
point->setParent(tool);
point->setParent(tool);// Adopted by a tool
}
else
{
doc->IncrementReferens(idPoint);
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idPoint);
}
}
}
else
@ -110,26 +121,6 @@ void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsSc
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DeleteNode delete node from detail.
*/
void VNodePoint::DeleteNode()
{
VAbstractNode::DeleteNode();
this->setVisible(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::RestoreNode()
{
if (this->isVisible() == false)
{
VAbstractNode::RestoreNode();
this->setVisible(true);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VNodePoint::getTagName() const
{
@ -291,6 +282,18 @@ void VNodePoint::RefreshLine()
VAbstractTool::RefreshLine(this, namePoint, lineName, radius);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::ShowNode()
{
show();
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::HideNode()
{
hide();
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::EnableToolMove(bool move)
{

View File

@ -50,11 +50,10 @@ public:
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene,
quint32 id, quint32 idPoint, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool = 0,
QObject *parent = nullptr);
static const QString TagName;
static const QString ToolType;
virtual void DeleteNode() Q_DECL_OVERRIDE;
virtual void RestoreNode() Q_DECL_OVERRIDE;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::NodePoint)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
@ -81,6 +80,8 @@ protected:
virtual void UpdateNamePosition(qreal mx, qreal my);
virtual void RefreshPointGeometry(const VPointF &point);
void RefreshLine();
virtual void ShowNode() Q_DECL_OVERRIDE;
virtual void HideNode() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VNodePoint)
};

View File

@ -69,27 +69,39 @@ VNodeSpline::VNodeSpline(VAbstractPattern *doc, VContainer *data, quint32 id, qu
* @param idTool id node.
* @return pointer to node.
*/
VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idSpline, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool,
QObject *parent)
{
VAbstractTool::AddRecord(id, Tool::NodeSpline, doc);
VNodeSpline *spl = nullptr;
if (parse == Document::FullParse)
{
spl = new VNodeSpline(doc, data, id, idSpline, typeCreation, idTool, parent);
// Try to prevent memory leak
spl->hide();// If no one will use node, it will stay hidden
scene->addItem(spl);// First adopted by scene
doc->AddTool(id, spl);
if (idTool != 0)
if (idTool != NULL_ID)
{
doc->IncrementReferens(idTool);
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idTool);
}
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
VDataTool *tool = doc->getTool(idTool);
SCASSERT(tool != nullptr);
spl->setParent(tool);
spl->setParent(tool);// Adopted by a tool
}
else
{
doc->IncrementReferens(idSpline);
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idSpline);
}
}
}
else
@ -99,26 +111,6 @@ VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, quint3
return spl;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DeleteNode delete node from detail.
*/
void VNodeSpline::DeleteNode()
{
VAbstractNode::DeleteNode();
this->setVisible(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSpline::RestoreNode()
{
if (this->isVisible() == false)
{
VAbstractNode::RestoreNode();
this->setVisible(true);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VNodeSpline::getTagName() const
{
@ -206,6 +198,18 @@ void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSpline::ShowNode()
{
show();
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSpline::HideNode()
{
hide();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -42,13 +42,12 @@ public:
VNodeSpline(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
static VNodeSpline *Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
static VNodeSpline *Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idSpline, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool = 0,
QObject *parent = nullptr);
static const QString TagName;
static const QString ToolType;
virtual void DeleteNode() Q_DECL_OVERRIDE;
virtual void RestoreNode() Q_DECL_OVERRIDE;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::NodeSpline)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
@ -60,6 +59,8 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void ShowNode() Q_DECL_OVERRIDE;
virtual void HideNode() Q_DECL_OVERRIDE;
private:
void RefreshGeometry ();
};

View File

@ -70,30 +70,41 @@ VNodeSplinePath::VNodeSplinePath(VAbstractPattern *doc, VContainer *data, quint3
* @param idTool tool id.
* @param parent QObject parent.
*/
void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idSpline, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool, QObject *parent)
{
VAbstractTool::AddRecord(id, Tool::NodeSplinePath, doc);
if (parse == Document::FullParse)
{
VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeCreation, idTool, parent);
// Try to prevent memory leak
splPath->hide();// If no one will use node, it will stay hidden
scene->addItem(splPath);// First adopted by scene
doc->AddTool(id, splPath);
const QSharedPointer<VSplinePath> path = data->GeometricObject<VSplinePath>(id);
const QVector<VSplinePoint> *points = path->GetPoint();
for (qint32 i = 0; i<points->size(); ++i)
{
if (idTool != 0)
if (idTool != NULL_ID)
{
doc->IncrementReferens(idTool);
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(idTool);
}
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
VDataTool *tool = doc->getTool(idTool);
SCASSERT(tool != nullptr);
splPath->setParent(tool);
splPath->setParent(tool);// Adopted by a tool
}
else
{
doc->IncrementReferens(points->at(i).P().id());
if (inUse == NodeUsage::InUse)
{
doc->IncrementReferens(points->at(i).P().id());
}
}
}
}
@ -103,26 +114,6 @@ void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, quint32 id
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DeleteNode delete node from detail.
*/
void VNodeSplinePath::DeleteNode()
{
VAbstractNode::DeleteNode();
this->setVisible(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSplinePath::RestoreNode()
{
if (this->isVisible() == false)
{
VAbstractNode::RestoreNode();
this->setVisible(true);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VNodeSplinePath::getTagName() const
{
@ -210,6 +201,18 @@ void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSplinePath::ShowNode()
{
show();
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSplinePath::HideNode()
{
hide();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -41,12 +41,12 @@ class VNodeSplinePath : public VAbstractNode, public QGraphicsPathItem
public:
VNodeSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = 0);
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idSpline, const Document &parse,
const Source &typeCreation, const NodeUsage &inUse, const quint32 &idTool = 0,
QObject *parent = 0);
static const QString TagName;
static const QString ToolType;
virtual void DeleteNode() Q_DECL_OVERRIDE;
virtual void RestoreNode() Q_DECL_OVERRIDE;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::SplinePath)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
@ -58,6 +58,8 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void ShowNode() Q_DECL_OVERRIDE;
virtual void HideNode() Q_DECL_OVERRIDE;
private:
void RefreshGeometry();
};

View File

@ -162,25 +162,29 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstrac
case (Tool::NodePoint):
{
id = CreateNode<VPointF>(data, nodeD.getId());
VNodePoint::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui);
VNodePoint::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui,
NodeUsage::InUse);
}
break;
case (Tool::NodeArc):
{
id = CreateNode<VArc>(data, nodeD.getId());
VNodeArc::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui);
VNodeArc::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui,
NodeUsage::InUse);
}
break;
case (Tool::NodeSpline):
{
id = CreateNode<VSpline>(data, nodeD.getId());
VNodeSpline::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui);
VNodeSpline::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui,
NodeUsage::InUse);
}
break;
case (Tool::NodeSplinePath):
{
id = CreateNode<VSplinePath>(data, nodeD.getId());
VNodeSplinePath::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui);
VNodeSplinePath::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui,
NodeUsage::InUse);
}
break;
default:
@ -306,7 +310,7 @@ void VToolDetail::AddToFile()
AddNode(doc, domElement, detail.at(i));
}
AddDet *addDet = new AddDet(domElement, doc);
AddDet *addDet = new AddDet(domElement, doc, detail);
connect(addDet, &AddDet::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
qApp->getUndoStack()->push(addDet);
}
@ -499,19 +503,6 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
*/
void VToolDetail::RemoveReferens()
{
VDetail detail = VAbstractTool::data.GetDetail(id);
for (int i = 0; i< detail.CountNode(); ++i)
{
doc->DecrementReferens(detail.at(i).getId());
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddNode add node to the file.
@ -588,7 +579,7 @@ void VToolDetail::RefreshGeometry()
//---------------------------------------------------------------------------------------------------------------------
void VToolDetail::DeleteTool(bool ask)
{
DeleteDetail *delDet = new DeleteDetail(doc, id);
DeleteDetail *delDet = new DeleteDetail(doc, id, VAbstractTool::data.GetDetail(id));
if (ask)
{
if (ConfirmDeletion() == QMessageBox::No)

View File

@ -100,7 +100,6 @@ protected:
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE {}
private:

View File

@ -105,7 +105,8 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
VPointF *point1 = new VPointF(*point);
point1->setMode(Draw::Modeling);
id = data->AddGObject(point1);
VNodePoint::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
VNodePoint::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui,
NodeUsage::InUse, idTool, tool);
}
}
break;
@ -117,7 +118,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
}
else
{
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(det.at(i).getId());
VPointF p1 = VPointF(arc->GetP1(), "A", 0, 0);
BiasRotatePoint(&p1, dx, dy, p, angle);
@ -141,7 +142,8 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
arc2->setMode(Draw::Modeling);
id = data->AddGObject(arc2);
VNodeArc::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
VNodeArc::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, NodeUsage::InUse,
idTool, tool);
}
}
break;
@ -155,7 +157,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
{
const QSharedPointer<VSpline> spline = data->GeometricObject<VSpline>(det.at(i).getId());
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
VPointF *p1 = new VPointF(spline->GetP1());
BiasRotatePoint(p1, dx, dy, p, angle);
@ -175,7 +177,8 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
VSpline *spl1 = new VSpline(*spl);
spl1->setMode(Draw::Modeling);
id = data->AddGObject(spl1);
VNodeSpline::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
VNodeSpline::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui,
NodeUsage::InUse, idTool, tool);
delete p4;
delete p1;
@ -195,13 +198,13 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
const QSharedPointer<VSplinePath> splinePath = data->GeometricObject<VSplinePath>(det.at(i).getId());
for (qint32 i = 1; i <= splinePath->Count(); ++i)
{
const VSplinePoint &point1 = splinePath->at(i-1);
const VSplinePoint &point2 = splinePath->at(i);
const VSplinePoint &point1 = splinePath->at(i-1);
const VSplinePoint &point2 = splinePath->at(i);
VSpline spline(point1.P(), point2.P(),
point1.Angle2(), point2.Angle1(), point1.KAsm2(),
point2.KAsm1(), splinePath->GetKCurve());
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
VPointF *p1 = new VPointF(spline.GetP1());
BiasRotatePoint(p1, dx, dy, p, angle);
@ -230,7 +233,8 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
VSplinePath *path1 = new VSplinePath(*path);
path1->setMode(Draw::Modeling);
id = data->AddGObject(path1);
VNodeSplinePath::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
VNodeSplinePath::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui,
NodeUsage::InUse, idTool, tool);
}
}
break;
@ -278,7 +282,7 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data,
{
if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0)
{
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(det.at(i).getId());
VPointF p1 = VPointF(arc->GetP1());
BiasRotatePoint(&p1, dx, dy, p, angle);
@ -309,7 +313,7 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data,
{
const QSharedPointer<VSpline> spline = data->GeometricObject<VSpline>(det.at(i).getId());
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
VPointF *p1 = new VPointF(spline->GetP1());
BiasRotatePoint(p1, dx, dy, p, angle);
@ -344,13 +348,13 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data,
SCASSERT(splinePath != nullptr);
for (qint32 i = 1; i <= splinePath->Count(); ++i)
{
const VSplinePoint &point1 = splinePath->at(i-1);
const VSplinePoint &point2 = splinePath->at(i);
const VSplinePoint &point1 = splinePath->at(i-1);
const VSplinePoint &point2 = splinePath->at(i);
VSpline spline(point1.P(), point2.P(),
point1.Angle2(), point2.Angle1(), point1.KAsm2(),
point2.KAsm1(), splinePath->GetKCurve());
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
VPointF *p1 = new VPointF(spline.GetP1());
BiasRotatePoint(p1, dx, dy, p, angle);
@ -438,8 +442,8 @@ VToolUnionDetails* VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsSc
quint32 indexD1 = static_cast<quint32>(dialogTool->getIndexD1());
quint32 indexD2 = static_cast<quint32>(dialogTool->getIndexD2());
qApp->getUndoStack()->beginMacro("union details");
VToolUnionDetails* tool = Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene,
doc, data, Document::FullParse, Source::FromGui);
VToolUnionDetails* tool = Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene,
doc, data, Document::FullParse, Source::FromGui);
qApp->getUndoStack()->endMacro();
return tool;
}

View File

@ -29,8 +29,8 @@
#include "adddet.h"
//---------------------------------------------------------------------------------------------------------------------
AddDet::AddDet(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent)
: VUndoCommand(xml, doc, parent)
AddDet::AddDet(const QDomElement &xml, VAbstractPattern *doc, const VDetail &detail, QUndoCommand *parent)
: VUndoCommand(xml, doc, parent), detail(detail)
{
setText(tr("add detail"));
nodeId = doc->GetParametrId(xml);
@ -57,6 +57,15 @@ void AddDet::undo()
qCDebug(vUndo, "Can't delete node");
return;
}
QVector<VNodeDetail> nodes = detail.getNodes();
if (nodes.size()>0)
{
for (qint32 i = 0; i < nodes.size(); ++i)
{
doc->DecrementReferens(nodes.at(i).getId());
}
}
}
else
{

View File

@ -30,12 +30,13 @@
#define ADDDET_H
#include "vundocommand.h"
#include "../tools/vtooldetail.h"
class AddDet : public VUndoCommand
{
Q_OBJECT
public:
AddDet(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = 0);
AddDet(const QDomElement &xml, VAbstractPattern *doc, const VDetail &detail, QUndoCommand *parent = 0);
virtual ~AddDet() Q_DECL_OVERRIDE;
// cppcheck-suppress unusedFunction
virtual void undo() Q_DECL_OVERRIDE;
@ -43,6 +44,7 @@ public:
virtual void redo() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(AddDet)
VDetail detail;
};
#endif // ADDDET_H

View File

@ -30,8 +30,8 @@
#include "../tools/vtooldetail.h"
//---------------------------------------------------------------------------------------------------------------------
DeleteDetail::DeleteDetail(VAbstractPattern *doc, quint32 id, QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), siblingId(NULL_ID)
DeleteDetail::DeleteDetail(VAbstractPattern *doc, quint32 id, const VDetail &detail, QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), siblingId(NULL_ID), detail(detail)
{
setText(tr("delete tool"));
nodeId = id;
@ -89,6 +89,15 @@ void DeleteDetail::redo()
SCASSERT(toolDet != nullptr);
toolDet->hide();
QVector<VNodeDetail> nodes = detail.getNodes();
if (nodes.size()>0)
{
for (qint32 i = 0; i < nodes.size(); ++i)
{
doc->DecrementReferens(nodes.at(i).getId());
}
}
emit NeedFullParsing(); // Doesn't work when UnionDetail delete detail.
}
else

View File

@ -30,13 +30,15 @@
#define DELETEDETAIL_H
#include "vundocommand.h"
#include "../tools/vtooldetail.h"
class QGraphicsItem;
class DeleteDetail : public VUndoCommand
{
Q_OBJECT
public:
DeleteDetail(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = 0);
DeleteDetail(VAbstractPattern *doc, quint32 id, const VDetail &detail, QUndoCommand *parent = 0);
virtual ~DeleteDetail() Q_DECL_OVERRIDE;
virtual void undo() Q_DECL_OVERRIDE;
virtual void redo() Q_DECL_OVERRIDE;
@ -44,6 +46,7 @@ private:
Q_DISABLE_COPY(DeleteDetail)
QDomNode parentNode;
quint32 siblingId;
VDetail detail;
};
#endif // DELETEDETAIL_H

View File

@ -60,13 +60,10 @@ void SaveDetailOptions::undo()
VToolDetail::AddNode(doc, domElement, oldDet.at(i));
}
QVector<VNodeDetail> nodes = oldDet.getNodes();
QHash<quint32, VDataTool*>* tools = doc->getTools();
if (nodes.size()>0)
{
for (qint32 i = 0; i < nodes.size(); ++i)
{
VAbstractNode *node = qobject_cast<VAbstractNode *>(tools->value(nodes.at(i).getId()));
node->RestoreNode();
doc->IncrementReferens(nodes.at(i).getId());
}
}
@ -94,13 +91,10 @@ void SaveDetailOptions::redo()
VToolDetail::AddNode(doc, domElement, newDet.at(i));
}
QList<quint32> list = oldDet.Missing(newDet);
QHash<quint32, VDataTool*>* tools = doc->getTools();
if (list.size()>0)
{
for (qint32 i = 0; i < list.size(); ++i)
{
VAbstractNode *node = qobject_cast<VAbstractNode *>(tools->value(list.at(i)));
node->DeleteNode();
doc->DecrementReferens(list.at(i));
}
}