Fixed wrong handling with true darts points inside tool detail.
(grafted from c84b1a66716faa7e171e5acb2824a7fb5702dd27) --HG-- branch : develop
This commit is contained in:
parent
f69186b7b3
commit
d72ea565cb
|
@ -11,6 +11,9 @@
|
||||||
- [#325] Check pattern for inverse compatibility.
|
- [#325] Check pattern for inverse compatibility.
|
||||||
- [#385] Add 'Open Recent' option in Tape.exe, 'File' dropdown menu.
|
- [#385] Add 'Open Recent' option in Tape.exe, 'File' dropdown menu.
|
||||||
|
|
||||||
|
# Version 0.4.4
|
||||||
|
- Fixed wrong handling with true darts points inside tool detail.
|
||||||
|
|
||||||
# Version 0.4.3 March 6, 2016
|
# Version 0.4.3 March 6, 2016
|
||||||
- [#456] Crash: broken formula + clicking on the f(x) symbol.
|
- [#456] Crash: broken formula + clicking on the f(x) symbol.
|
||||||
- [#454] Crash: using CRTL+Z while using line tool
|
- [#454] Crash: using CRTL+Z while using line tool
|
||||||
|
|
|
@ -322,16 +322,16 @@ VDetail VDetail::RemoveEdge(const quint32 &index) const
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Missing find missing ids in detail. When we deleted object in detail and return this detail need
|
* @brief Missing find missing nodes in detail. When we deleted object in detail and return this detail need
|
||||||
* understand, what nodes need make invisible.
|
* understand, what nodes need make invisible.
|
||||||
* @param det changed detail.
|
* @param det changed detail.
|
||||||
* @return list with missing detail.
|
* @return list with missing nodes.
|
||||||
*/
|
*/
|
||||||
QList<quint32> VDetail::Missing(const VDetail &det) const
|
QVector<VNodeDetail> VDetail::Missing(const VDetail &det) const
|
||||||
{
|
{
|
||||||
if (d->nodes.size() == det.CountNode()) //-V807
|
if (d->nodes.size() == det.CountNode()) //-V807
|
||||||
{
|
{
|
||||||
return QList<quint32>();
|
return QVector<VNodeDetail>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<quint32> set1;
|
QSet<quint32> set1;
|
||||||
|
@ -346,9 +346,18 @@ QList<quint32> VDetail::Missing(const VDetail &det) const
|
||||||
set2.insert(det.at(j).getId());
|
set2.insert(det.at(j).getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<quint32> set3 = set1.subtract(set2);
|
const QList<quint32> set3 = set1.subtract(set2).toList();
|
||||||
|
QVector<VNodeDetail> nodes;
|
||||||
|
for (qint32 i = 0; i < set3.size(); ++i)
|
||||||
|
{
|
||||||
|
const int index = indexOfNode(d->nodes, set3.at(i));
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
nodes.append(d->nodes.at(index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return set3.toList();
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
void NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2)const;
|
void NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2)const;
|
||||||
VDetail RemoveEdge(const quint32 &index) const;
|
VDetail RemoveEdge(const quint32 &index) const;
|
||||||
|
|
||||||
QList<quint32> Missing(const VDetail &det) const;
|
QVector<VNodeDetail> Missing(const VDetail &det) const;
|
||||||
|
|
||||||
QVector<QPointF> ContourPoints(const VContainer *data) const;
|
QVector<QPointF> ContourPoints(const VContainer *data) const;
|
||||||
QVector<QPointF> SeamAllowancePoints(const VContainer *data) const;
|
QVector<QPointF> SeamAllowancePoints(const VContainer *data) const;
|
||||||
|
|
|
@ -119,6 +119,57 @@ QString VNodePoint::getTagName() const
|
||||||
return VNodePoint::TagName;
|
return VNodePoint::TagName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VNodePoint::incrementReferens()
|
||||||
|
{
|
||||||
|
++_referens;
|
||||||
|
if (_referens == 1)
|
||||||
|
{
|
||||||
|
if (idTool != NULL_ID)
|
||||||
|
{
|
||||||
|
doc->IncrementReferens(idTool);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(idNode);
|
||||||
|
doc->IncrementReferens(point->getIdTool());
|
||||||
|
}
|
||||||
|
ShowNode();
|
||||||
|
QDomElement domElement = doc->elementById(id);
|
||||||
|
if (domElement.isElement())
|
||||||
|
{
|
||||||
|
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VNodePoint::decrementReferens()
|
||||||
|
{
|
||||||
|
if (_referens > 0)
|
||||||
|
{
|
||||||
|
--_referens;
|
||||||
|
}
|
||||||
|
if (_referens == 0)
|
||||||
|
{
|
||||||
|
if (idTool != NULL_ID)
|
||||||
|
{
|
||||||
|
doc->DecrementReferens(idTool);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(idNode);
|
||||||
|
doc->DecrementReferens(point->getIdTool());
|
||||||
|
}
|
||||||
|
HideNode();
|
||||||
|
QDomElement domElement = doc->elementById(id);
|
||||||
|
if (domElement.isElement())
|
||||||
|
{
|
||||||
|
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VNodePoint::PointChoosed()
|
void VNodePoint::PointChoosed()
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,9 @@ public:
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Tool::NodePoint)};
|
enum { Type = UserType + static_cast<int>(Tool::NodePoint)};
|
||||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
virtual void incrementReferens() Q_DECL_OVERRIDE;
|
||||||
|
virtual void decrementReferens() Q_DECL_OVERRIDE;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
||||||
void NameChangePosition(const QPointF &pos);
|
void NameChangePosition(const QPointF &pos);
|
||||||
|
|
|
@ -457,15 +457,8 @@ void VToolUnionDetails::incrementReferens()
|
||||||
++_referens;
|
++_referens;
|
||||||
if (_referens == 1)
|
if (_referens == 1)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d1.CountNode(); ++i)
|
IncrementReferences(d1);
|
||||||
{
|
IncrementReferences(d2);
|
||||||
doc->IncrementReferens(d1.at(i).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < d2.CountNode(); ++i)
|
|
||||||
{
|
|
||||||
doc->IncrementReferens(d2.at(i).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
|
@ -484,15 +477,8 @@ void VToolUnionDetails::decrementReferens()
|
||||||
}
|
}
|
||||||
if (_referens == 0)
|
if (_referens == 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d1.CountNode(); ++i)
|
DecrementReferences(d1);
|
||||||
{
|
DecrementReferences(d2);
|
||||||
doc->DecrementReferens(d1.at(i).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < d2.CountNode(); ++i)
|
|
||||||
{
|
|
||||||
doc->DecrementReferens(d2.at(i).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
|
@ -900,6 +886,56 @@ void VToolUnionDetails::AddToModeling(const QDomElement &domElement)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolUnionDetails::IncrementReferences(const VDetail &d) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < d.CountNode(); ++i)
|
||||||
|
{
|
||||||
|
switch (d.at(i).getTypeTool())
|
||||||
|
{
|
||||||
|
case (Tool::NodePoint):
|
||||||
|
{
|
||||||
|
const auto point = VAbstractTool::data.GeometricObject<VPointF>(d.at(i).getId());
|
||||||
|
doc->IncrementReferens(point->getIdTool());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (Tool::NodeArc):
|
||||||
|
case (Tool::NodeSpline):
|
||||||
|
case (Tool::NodeSplinePath):
|
||||||
|
doc->IncrementReferens(d.at(i).getId());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qDebug()<<"Get wrong tool type. Ignore.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolUnionDetails::DecrementReferences(const VDetail &d) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < d.CountNode(); ++i)
|
||||||
|
{
|
||||||
|
switch (d.at(i).getTypeTool())
|
||||||
|
{
|
||||||
|
case (Tool::NodePoint):
|
||||||
|
{
|
||||||
|
const auto point = VAbstractTool::data.GeometricObject<VPointF>(d.at(i).getId());
|
||||||
|
doc->DecrementReferens(point->getIdTool());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (Tool::NodeArc):
|
||||||
|
case (Tool::NodeSpline):
|
||||||
|
case (Tool::NodeSplinePath):
|
||||||
|
doc->DecrementReferens(d.at(i).getId());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qDebug()<<"Get wrong tool type. Ignore.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolUnionDetails::SaveChildren(VAbstractPattern *doc, quint32 id, const QVector<quint32> &children)
|
void VToolUnionDetails::SaveChildren(VAbstractPattern *doc, quint32 id, const QVector<quint32> &children)
|
||||||
{
|
{
|
||||||
|
|
|
@ -113,6 +113,8 @@ private:
|
||||||
void AddNode(QDomElement &domElement, const VNodeDetail &node);
|
void AddNode(QDomElement &domElement, const VNodeDetail &node);
|
||||||
QDomNode UpdateDetail(const QDomNode &domNode, const VDetail &d);
|
QDomNode UpdateDetail(const QDomNode &domNode, const VDetail &d);
|
||||||
void AddToModeling(const QDomElement &domElement);
|
void AddToModeling(const QDomElement &domElement);
|
||||||
|
void IncrementReferences(const VDetail &d) const;
|
||||||
|
void DecrementReferences(const VDetail &d) const;
|
||||||
|
|
||||||
static void SaveChildren(VAbstractPattern *doc, quint32 id, const QVector<quint32> &children);
|
static void SaveChildren(VAbstractPattern *doc, quint32 id, const QVector<quint32> &children);
|
||||||
static QVector<quint32> AllChildren(VAbstractPattern *doc, quint32 id);
|
static QVector<quint32> AllChildren(VAbstractPattern *doc, quint32 id);
|
||||||
|
|
|
@ -59,14 +59,7 @@ void AddDet::undo()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<VNodeDetail> nodes = detail.getNodes();
|
DecrementReferences(detail.getNodes());
|
||||||
if (nodes.size()>0)
|
|
||||||
{
|
|
||||||
for (qint32 i = 0; i < nodes.size(); ++i)
|
|
||||||
{
|
|
||||||
doc->DecrementReferens(nodes.at(i).getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,15 +89,7 @@ void DeleteDetail::redo()
|
||||||
SCASSERT(toolDet != nullptr);
|
SCASSERT(toolDet != nullptr);
|
||||||
toolDet->hide();
|
toolDet->hide();
|
||||||
|
|
||||||
QVector<VNodeDetail> nodes = detail.getNodes();
|
DecrementReferences(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.
|
emit NeedFullParsing(); // Doesn't work when UnionDetail delete detail.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -59,14 +59,7 @@ void SaveDetailOptions::undo()
|
||||||
{
|
{
|
||||||
VToolDetail::AddNode(doc, domElement, oldDet.at(i));
|
VToolDetail::AddNode(doc, domElement, oldDet.at(i));
|
||||||
}
|
}
|
||||||
QVector<VNodeDetail> nodes = oldDet.getNodes();
|
IncrementReferences(oldDet.getNodes());
|
||||||
if (nodes.size()>0)
|
|
||||||
{
|
|
||||||
for (qint32 i = 0; i < nodes.size(); ++i)
|
|
||||||
{
|
|
||||||
doc->IncrementReferens(nodes.at(i).getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit NeedLiteParsing(Document::LiteParse);
|
emit NeedLiteParsing(Document::LiteParse);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -90,14 +83,8 @@ void SaveDetailOptions::redo()
|
||||||
{
|
{
|
||||||
VToolDetail::AddNode(doc, domElement, newDet.at(i));
|
VToolDetail::AddNode(doc, domElement, newDet.at(i));
|
||||||
}
|
}
|
||||||
QList<quint32> list = oldDet.Missing(newDet);
|
|
||||||
if (list.size()>0)
|
DecrementReferences(oldDet.Missing(newDet));
|
||||||
{
|
|
||||||
for (qint32 i = 0; i < list.size(); ++i)
|
|
||||||
{
|
|
||||||
doc->DecrementReferens(list.at(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit NeedLiteParsing(Document::LiteParse);
|
emit NeedLiteParsing(Document::LiteParse);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "vundocommand.h"
|
#include "vundocommand.h"
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
#include "../vgeometry/vpointf.h"
|
||||||
|
#include "../vtools/tools/vabstracttool.h"
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(vUndo, "v.undo")
|
Q_LOGGING_CATEGORY(vUndo, "v.undo")
|
||||||
|
|
||||||
|
@ -65,3 +67,57 @@ void VUndoCommand::UndoDeleteAfterSibling(QDomNode &parentNode, const quint32 &s
|
||||||
parentNode.insertAfter(xml, refElement);
|
parentNode.insertAfter(xml, refElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VUndoCommand::IncrementReferences(const QVector<VNodeDetail> &nodes) const
|
||||||
|
{
|
||||||
|
for (qint32 i = 0; i < nodes.size(); ++i)
|
||||||
|
{
|
||||||
|
switch (nodes.at(i).getTypeTool())
|
||||||
|
{
|
||||||
|
case (Tool::NodePoint):
|
||||||
|
{
|
||||||
|
auto tool = qobject_cast<VAbstractTool *>(doc->getTool(nodeId));
|
||||||
|
SCASSERT(tool != nullptr);
|
||||||
|
const auto point = tool->getData()->GeometricObject<VPointF>(nodes.at(i).getId());
|
||||||
|
doc->IncrementReferens(point->getIdTool());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (Tool::NodeArc):
|
||||||
|
case (Tool::NodeSpline):
|
||||||
|
case (Tool::NodeSplinePath):
|
||||||
|
doc->IncrementReferens(nodes.at(i).getId());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qDebug()<<"Get wrong tool type. Ignore.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VUndoCommand::DecrementReferences(const QVector<VNodeDetail> &nodes) const
|
||||||
|
{
|
||||||
|
for (qint32 i = 0; i < nodes.size(); ++i)
|
||||||
|
{
|
||||||
|
switch (nodes.at(i).getTypeTool())
|
||||||
|
{
|
||||||
|
case (Tool::NodePoint):
|
||||||
|
{
|
||||||
|
auto tool = qobject_cast<VAbstractTool *>(doc->getTool(nodeId));
|
||||||
|
SCASSERT(tool != nullptr);
|
||||||
|
const auto point = tool->getData()->GeometricObject<VPointF>(nodes.at(i).getId());
|
||||||
|
doc->DecrementReferens(point->getIdTool());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (Tool::NodeArc):
|
||||||
|
case (Tool::NodeSpline):
|
||||||
|
case (Tool::NodeSplinePath):
|
||||||
|
doc->DecrementReferens(nodes.at(i).getId());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qDebug()<<"Get wrong tool type. Ignore.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ enum class UndoCommand: char { AddPatternPiece,
|
||||||
};
|
};
|
||||||
|
|
||||||
class VPattern;
|
class VPattern;
|
||||||
|
class VNodeDetail;
|
||||||
|
|
||||||
class VUndoCommand : public QObject, public QUndoCommand
|
class VUndoCommand : public QObject, public QUndoCommand
|
||||||
{
|
{
|
||||||
|
@ -71,6 +72,9 @@ protected:
|
||||||
bool redoFlag;
|
bool redoFlag;
|
||||||
virtual void RedoFullParsing();
|
virtual void RedoFullParsing();
|
||||||
void UndoDeleteAfterSibling(QDomNode &parentNode, const quint32 &siblingId) const;
|
void UndoDeleteAfterSibling(QDomNode &parentNode, const quint32 &siblingId) const;
|
||||||
|
|
||||||
|
void IncrementReferences(const QVector<VNodeDetail> &nodes) const;
|
||||||
|
void DecrementReferences(const QVector<VNodeDetail> &nodes) const;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VUndoCommand)
|
Q_DISABLE_COPY(VUndoCommand)
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user