Fixed issue #230. Program hangs when I try to open saved file.
--HG-- branch : develop
This commit is contained in:
parent
665d276e96
commit
2a27ebfe1f
|
@ -103,6 +103,11 @@ void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
{
|
{
|
||||||
if (type == SceneObject::Point)
|
if (type == SceneObject::Point)
|
||||||
{
|
{
|
||||||
|
if (path.CountPoint() >= 2 && path.at(path.CountPoint()-1).P().id() == id)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
NewItem(id, 1, 0, 1, 180);
|
NewItem(id, 1, 0, 1, 180);
|
||||||
emit ToolTip(tr("Select point of curve path"));
|
emit ToolTip(tr("Select point of curve path"));
|
||||||
|
|
||||||
|
|
|
@ -294,6 +294,17 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
|
||||||
qreal x3, qreal y3, qreal x4, qreal y4,
|
qreal x3, qreal y3, qreal x4, qreal y4,
|
||||||
qint16 level, QVector<qreal> &px, QVector<qreal> &py)
|
qint16 level, QVector<qreal> &px, QVector<qreal> &py)
|
||||||
{
|
{
|
||||||
|
if (px.size() >= 2)
|
||||||
|
{
|
||||||
|
for (int i=1; i < px.size(); ++i)
|
||||||
|
{
|
||||||
|
if (QPointF(px.at(i-1), py.at(i-1)) == QPointF(px.at(i), py.at(i)))
|
||||||
|
{
|
||||||
|
qCritical("All neighbors points in path must be unique.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const double curve_collinearity_epsilon = 1e-30;
|
const double curve_collinearity_epsilon = 1e-30;
|
||||||
const double curve_angle_tolerance_epsilon = 0.01;
|
const double curve_angle_tolerance_epsilon = 0.01;
|
||||||
const double m_angle_tolerance = 0.0;
|
const double m_angle_tolerance = 0.0;
|
||||||
|
|
|
@ -47,6 +47,11 @@ VSplinePath::~VSplinePath()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSplinePath::append(const VSplinePoint &point)
|
void VSplinePath::append(const VSplinePoint &point)
|
||||||
{
|
{
|
||||||
|
if (d->path.size() > 0 && d->path.last().P().toQPointF() == point.P().toQPointF())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
d->path.append(point);
|
d->path.append(point);
|
||||||
QString name = splPath;
|
QString name = splPath;
|
||||||
name.append(QString("_%1").arg(d->path.first().P().name()));
|
name.append(QString("_%1").arg(d->path.first().P().name()));
|
||||||
|
|
|
@ -251,20 +251,18 @@ void VToolSplinePath::RefreshSplinePath(VSplinePath &splPath)
|
||||||
*/
|
*/
|
||||||
void VToolSplinePath::UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path)
|
void VToolSplinePath::UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path)
|
||||||
{
|
{
|
||||||
SCASSERT(doc != nullptr)
|
SCASSERT(doc != nullptr);
|
||||||
QDomNodeList nodeList = node.childNodes();
|
QDomElement element = node.toElement();
|
||||||
qint32 num = nodeList.size();
|
if (element.isElement() == false)
|
||||||
for (qint32 i = 0; i < num; ++i)
|
|
||||||
{
|
{
|
||||||
QDomElement domElement = nodeList.at(i).toElement();
|
qDebug()<<"Couldn't convert parent to element.";
|
||||||
if (domElement.isNull() == false)
|
return;
|
||||||
{
|
}
|
||||||
VSplinePoint p = path.at(i);
|
|
||||||
doc->SetAttribute(domElement, AttrPSpline, p.P().id());
|
doc->removeAllChilds(element);
|
||||||
doc->SetAttribute(domElement, AttrKAsm1, p.KAsm1());
|
for (qint32 i = 0; i < path.CountPoint(); ++i)
|
||||||
doc->SetAttribute(domElement, AttrKAsm2, p.KAsm2());
|
{
|
||||||
doc->SetAttribute(domElement, AttrAngle, p.Angle2());
|
AddPathPoint(doc, element, path.at(i));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,8 +350,9 @@ void VToolSplinePath::RefreshDataInFile()
|
||||||
* @param domElement dom element.
|
* @param domElement dom element.
|
||||||
* @param splPoint spline path point.
|
* @param splPoint spline path point.
|
||||||
*/
|
*/
|
||||||
void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint)
|
void VToolSplinePath::AddPathPoint(VPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint)
|
||||||
{
|
{
|
||||||
|
SCASSERT(doc != nullptr);
|
||||||
QDomElement pathPoint = doc->createElement(AttrPathPoint);
|
QDomElement pathPoint = doc->createElement(AttrPathPoint);
|
||||||
|
|
||||||
doc->SetAttribute(pathPoint, AttrPSpline, splPoint.P().id());
|
doc->SetAttribute(pathPoint, AttrPSpline, splPoint.P().id());
|
||||||
|
@ -406,7 +405,7 @@ void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &ob
|
||||||
doc->RemoveAllChild(tag);
|
doc->RemoveAllChild(tag);
|
||||||
for (qint32 i = 0; i < splPath->CountPoint(); ++i)
|
for (qint32 i = 0; i < splPath->CountPoint(); ++i)
|
||||||
{
|
{
|
||||||
AddPathPoint(tag, splPath->at(i));
|
AddPathPoint(doc, tag, splPath->at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ protected:
|
||||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||||
private:
|
private:
|
||||||
void RefreshGeometry();
|
void RefreshGeometry();
|
||||||
void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint);
|
static void AddPathPoint(VPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);
|
||||||
void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const;
|
void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const;
|
||||||
void RefreshSplinePath(VSplinePath &splPath);
|
void RefreshSplinePath(VSplinePath &splPath);
|
||||||
};
|
};
|
||||||
|
|
|
@ -301,6 +301,21 @@ bool VPattern::ChangeNamePP(const QString& oldName, const QString &newName)
|
||||||
void VPattern::Parse(const Document &parse)
|
void VPattern::Parse(const Document &parse)
|
||||||
{
|
{
|
||||||
qCDebug(vXML)<<"Parsing pattern.";
|
qCDebug(vXML)<<"Parsing pattern.";
|
||||||
|
switch (parse)
|
||||||
|
{
|
||||||
|
case Document::FullParse:
|
||||||
|
qCDebug(vXML)<<"Full parse.";
|
||||||
|
break;
|
||||||
|
case Document::LiteParse:
|
||||||
|
qCDebug(vXML)<<"Lite parse.";
|
||||||
|
break;
|
||||||
|
case Document::LitePPParse:
|
||||||
|
qCDebug(vXML)<<"Lite pattern piece parse.";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
SCASSERT(sceneDraw != nullptr);
|
SCASSERT(sceneDraw != nullptr);
|
||||||
SCASSERT(sceneDetail != nullptr);
|
SCASSERT(sceneDetail != nullptr);
|
||||||
QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes
|
QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes
|
||||||
|
@ -317,6 +332,7 @@ void VPattern::Parse(const Document &parse)
|
||||||
switch (tags.indexOf(domElement.tagName()))
|
switch (tags.indexOf(domElement.tagName()))
|
||||||
{
|
{
|
||||||
case 0: // TagDraw
|
case 0: // TagDraw
|
||||||
|
qCDebug(vXML)<<"Tag draw.";
|
||||||
if (parse == Document::FullParse)
|
if (parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
if (nameActivPP.isEmpty())
|
if (nameActivPP.isEmpty())
|
||||||
|
@ -336,22 +352,29 @@ void VPattern::Parse(const Document &parse)
|
||||||
ParseDrawElement(domElement, parse);
|
ParseDrawElement(domElement, parse);
|
||||||
break;
|
break;
|
||||||
case 1: // TagIncrements
|
case 1: // TagIncrements
|
||||||
|
qCDebug(vXML)<<"Tag increments.";
|
||||||
ParseIncrementsElement(domElement);
|
ParseIncrementsElement(domElement);
|
||||||
break;
|
break;
|
||||||
case 2: // TagAuthor
|
case 2: // TagAuthor
|
||||||
|
qCDebug(vXML)<<"Tag author.";
|
||||||
break;
|
break;
|
||||||
case 3: // TagDescription
|
case 3: // TagDescription
|
||||||
|
qCDebug(vXML)<<"Tag description.";
|
||||||
break;
|
break;
|
||||||
case 4: // TagNotes
|
case 4: // TagNotes
|
||||||
|
qCDebug(vXML)<<"Tag notes.";
|
||||||
break;
|
break;
|
||||||
case 5: // TagMeasurements
|
case 5: // TagMeasurements
|
||||||
|
qCDebug(vXML)<<"Tag measurements.";
|
||||||
break;
|
break;
|
||||||
case 6: // TagVersion
|
case 6: // TagVersion
|
||||||
|
qCDebug(vXML)<<"Tag version.";
|
||||||
break;
|
break;
|
||||||
case 7: // TagGradation
|
case 7: // TagGradation
|
||||||
|
qCDebug(vXML)<<"Tag gradation.";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug()<<"Wrong tag name"<<domElement.tagName()<<Q_FUNC_INFO;
|
qCDebug(vXML)<<"Wrong tag name"<<domElement.tagName();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -883,17 +906,20 @@ void VPattern::ParseDrawElement(const QDomNode &node, const Document &parse)
|
||||||
switch (tags.indexOf(domElement.tagName()))
|
switch (tags.indexOf(domElement.tagName()))
|
||||||
{
|
{
|
||||||
case 0: // TagCalculation
|
case 0: // TagCalculation
|
||||||
|
qCDebug(vXML)<<"Tag calculation.";
|
||||||
data->ClearCalculationGObjects();
|
data->ClearCalculationGObjects();
|
||||||
ParseDrawMode(domElement, parse, Draw::Calculation);
|
ParseDrawMode(domElement, parse, Draw::Calculation);
|
||||||
break;
|
break;
|
||||||
case 1: // TagModeling
|
case 1: // TagModeling
|
||||||
|
qCDebug(vXML)<<"Tag modeling.";
|
||||||
ParseDrawMode(domElement, parse, Draw::Modeling);
|
ParseDrawMode(domElement, parse, Draw::Modeling);
|
||||||
break;
|
break;
|
||||||
case 2: // TagDetails
|
case 2: // TagDetails
|
||||||
|
qCDebug(vXML)<<"Tag details.";
|
||||||
ParseDetails(domElement, parse);
|
ParseDetails(domElement, parse);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug()<<"Wrong tag name"<<Q_FUNC_INFO;
|
qCDebug(vXML)<<"Wrong tag name";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -933,22 +959,27 @@ void VPattern::ParseDrawMode(const QDomNode &node, const Document &parse, const
|
||||||
switch (tags.indexOf(domElement.tagName()))
|
switch (tags.indexOf(domElement.tagName()))
|
||||||
{
|
{
|
||||||
case 0: // TagPoint
|
case 0: // TagPoint
|
||||||
|
qCDebug(vXML)<<"Tag point.";
|
||||||
ParsePointElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
ParsePointElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
||||||
break;
|
break;
|
||||||
case 1: // TagLine
|
case 1: // TagLine
|
||||||
|
qCDebug(vXML)<<"Tag line.";
|
||||||
ParseLineElement(scene, domElement, parse);
|
ParseLineElement(scene, domElement, parse);
|
||||||
break;
|
break;
|
||||||
case 2: // TagSpline
|
case 2: // TagSpline
|
||||||
|
qCDebug(vXML)<<"Tag spline.";
|
||||||
ParseSplineElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
ParseSplineElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
||||||
break;
|
break;
|
||||||
case 3: // TagArc
|
case 3: // TagArc
|
||||||
|
qCDebug(vXML)<<"Tag arc.";
|
||||||
ParseArcElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
ParseArcElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
||||||
break;
|
break;
|
||||||
case 4: // TagTools
|
case 4: // TagTools
|
||||||
|
qCDebug(vXML)<<"Tag tools.";
|
||||||
ParseToolsElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
ParseToolsElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug()<<"Wrong tag name"<<Q_FUNC_INFO;
|
qCDebug(vXML)<<"Wrong tag name";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1813,6 +1844,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
|
||||||
switch (splines.indexOf(type))
|
switch (splines.indexOf(type))
|
||||||
{
|
{
|
||||||
case 0: //VToolSpline::ToolType
|
case 0: //VToolSpline::ToolType
|
||||||
|
qCDebug(vXML)<<"VToolSpline.";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ToolsCommonAttributes(domElement, id);
|
ToolsCommonAttributes(domElement, id);
|
||||||
|
@ -1835,6 +1867,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1: //VToolSplinePath::ToolType
|
case 1: //VToolSplinePath::ToolType
|
||||||
|
qCDebug(vXML)<<"VToolSplinePath.";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ToolsCommonAttributes(domElement, id);
|
ToolsCommonAttributes(domElement, id);
|
||||||
|
@ -1879,6 +1912,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: //VNodeSpline::ToolType
|
case 2: //VNodeSpline::ToolType
|
||||||
|
qCDebug(vXML)<<"VNodeSpline.";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SplinesCommonAttributes(domElement, id, idObject, idTool);
|
SplinesCommonAttributes(domElement, id, idObject, idTool);
|
||||||
|
@ -1896,6 +1930,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: //VNodeSplinePath::ToolType
|
case 3: //VNodeSplinePath::ToolType
|
||||||
|
qCDebug(vXML)<<"VNodeSplinePath.";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SplinesCommonAttributes(domElement, id, idObject, idTool);
|
SplinesCommonAttributes(domElement, id, idObject, idTool);
|
||||||
|
@ -1913,7 +1948,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug() << "Illegal spline type in VDomDocument::ParseSplineElement().";
|
qCDebug(vXML) << "Illegal spline type in VDomDocument::ParseSplineElement().";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user