Removing objects before each FullParse. NodeArc, NodeSpline, NodeSplinePath are

not part of a scene anymore.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-02-10 18:45:49 +02:00
parent 9eac04654c
commit 85f5df4b21
16 changed files with 91 additions and 324 deletions

View File

@ -1940,7 +1940,7 @@ void VPattern::ParseNodeSpline(const QDomElement &domElement, const Document &pa
spl->setIdObject(idObject);
spl->setMode(Draw::Modeling);
data->UpdateGObject(id, spl);
VNodeSpline::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
VNodeSpline::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
}
catch (const VExceptionBadId &e)
{
@ -1966,7 +1966,7 @@ void VPattern::ParseNodeSplinePath(const QDomElement &domElement, const Document
path->setIdObject(idObject);
path->setMode(Draw::Modeling);
data->UpdateGObject(id, path);
VNodeSplinePath::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
VNodeSplinePath::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
}
catch (const VExceptionBadId &e)
{
@ -2037,7 +2037,7 @@ void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse
arc->setIdObject(idObject);
arc->setMode(Draw::Modeling);
data->UpdateGObject(id, arc);
VNodeArc::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
VNodeArc::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
}
catch (const VExceptionBadId &e)
{
@ -2767,6 +2767,7 @@ void VPattern::PrepareForParse(const Document &parse)
data->ClearForFullParse();
nameActivPP.clear();
patternPieces.clear();
qDeleteAll(toolsOnRemove);//Remove all invisible on a scene objects.
tools.clear();
cursor = 0;
history.clear();

View File

@ -107,7 +107,8 @@ const QString VAbstractPattern::IncrementDescription = QStringLiteral("descripti
//---------------------------------------------------------------------------------------------------------------------
VAbstractPattern::VAbstractPattern(QObject *parent)
: QObject(parent), VDomDocument(), nameActivPP(QString()), cursor(0), tools(QHash<quint32, VDataTool*>()),
history(QVector<VToolRecord>()), patternPieces(QStringList()), modified(false)
toolsOnRemove(QVector<VDataTool*>()), history(QVector<VToolRecord>()), patternPieces(QStringList()),
modified(false)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -431,6 +432,13 @@ void VAbstractPattern::AddTool(const quint32 &id, VDataTool *tool)
tools.insert(id, tool);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::AddToolOnRemove(VDataTool *tool)
{
SCASSERT(tool != nullptr);
toolsOnRemove.append(tool);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getHistory return list with list of history records.

View File

@ -81,6 +81,8 @@ public:
VDataTool *getTool(const quint32 &id);
void AddTool(const quint32 &id, VDataTool *tool);
void AddToolOnRemove(VDataTool *tool);
QVector<VToolRecord> *getHistory();
QVector<VToolRecord> getLocalHistory() const;
@ -240,6 +242,8 @@ protected:
/** @brief tools list with pointer on tools. */
QHash<quint32, VDataTool*> tools;
QVector<VDataTool*> toolsOnRemove;
/** @brief history history records. */
QVector<VToolRecord> history;

View File

@ -289,7 +289,7 @@ void VContainer::AddVariable(const QString& name, T *var)
throw VExceptionBadId(tr("Can't find object. Type mismatch."), name);
}
}
d->variables[name] = QSharedPointer<T>(var);
d->variables.insert(name, QSharedPointer<T>(var));
uniqueNames.insert(name);
}

View File

@ -47,12 +47,9 @@ const QString VNodeArc::ToolType = QStringLiteral("modeling");
* @param parent parent object.
*/
VNodeArc::VNodeArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation,
const quint32 &idTool, QObject *qoParent, QGraphicsItem *parent)
:VAbstractNode(doc, data, id, idArc, idTool, qoParent), QGraphicsPathItem(parent)
const quint32 &idTool, QObject *qoParent)
:VAbstractNode(doc, data, id, idArc, idTool, qoParent)
{
RefreshGeometry();
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
ToolCreation(typeCreation);
}
@ -68,13 +65,13 @@ VNodeArc::VNodeArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32
* @param idTool tool id.
* @param parent QObject parent
*/
void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id, quint32 idArc,
const Document &parse, const Source &typeCreation, const quint32 &idTool, QObject *parent)
void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc,
const Document &parse, const Source &typeCreation, const quint32 &idTool)
{
VAbstractTool::AddRecord(id, Tool::NodeArc, doc);
if (parse == Document::FullParse)
{
VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeCreation, idTool, parent);
VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeCreation, idTool, doc);
doc->AddTool(id, arc);
if (idTool != NULL_ID)
@ -86,10 +83,8 @@ void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScen
}
else
{
// Try to prevent memory leak
scene->addItem(arc);// First adopted by scene
arc->hide();// If no one will use node, it will stay hidden
arc->SetParentType(ParentType::Scene);
// Help to delete the node before each FullParse
doc->AddToolOnRemove(arc);
}
}
else
@ -104,15 +99,6 @@ QString VNodeArc::getTagName() const
return VNodeArc::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VNodeArc::FullUpdateFromFile()
{
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
@ -148,68 +134,3 @@ void VNodeArc::RefreshDataInFile()
}
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
emit ChoosedTool(id, SceneObject::Arc);
}
QGraphicsItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
// cppcheck-suppress unusedFunction
void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeArc::ShowNode()
{
if (parentType != ParentType::Scene)
{
show();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeArc::HideNode()
{
hide();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VNodeArc::RefreshGeometry()
{
// const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
// QPainterPath path;
// path.addPath(arc->GetPath());
// path.setFillRule( Qt::WindingFill );
// this->setPath(path);
}

View File

@ -35,33 +35,27 @@
/**
* @brief The VNodeArc class arc detail node.
*/
class VNodeArc :public VAbstractNode, public QGraphicsPathItem
class VNodeArc :public VAbstractNode
{
Q_OBJECT
public:
VNodeArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
const quint32 &idTool = 0, QObject *qoParent = nullptr);
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idArc, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0);
static const QString TagName;
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::NodeArc)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE {}
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
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;
virtual void ShowNode() Q_DECL_OVERRIDE {}
virtual void HideNode() Q_DECL_OVERRIDE {}
private:
void RefreshGeometry();
Q_DISABLE_COPY(VNodeArc)
};
#endif // VNODEARC_H4

View File

@ -81,14 +81,14 @@ 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 quint32 &idTool)
{
VAbstractTool::AddRecord(id, Tool::NodePoint, doc);
if (parse == Document::FullParse)
{
//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);
VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, idTool, doc);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VNodePoint::EnableToolMove);
doc->AddTool(id, point);

View File

@ -50,7 +50,7 @@ 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 quint32 &idTool = 0);
static const QString TagName;
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}

View File

@ -47,13 +47,9 @@ const QString VNodeSpline::ToolType = QStringLiteral("modelingSpline");
* @param parent QGraphicsItem parent.
*/
VNodeSpline::VNodeSpline(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Source &typeCreation, const quint32 &idTool, QObject *qoParent,
QGraphicsItem * parent)
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent)
const Source &typeCreation, const quint32 &idTool, QObject *qoParent)
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent)
{
RefreshGeometry();
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
ToolCreation(typeCreation);
}
@ -69,15 +65,15 @@ VNodeSpline::VNodeSpline(VAbstractPattern *doc, VContainer *data, quint32 id, qu
* @param idTool id node.
* @return pointer to node.
*/
VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, quint32 id,
quint32 idSpline, const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
const Source &typeCreation, const quint32 &idTool)
{
VAbstractTool::AddRecord(id, Tool::NodeSpline, doc);
VNodeSpline *spl = nullptr;
if (parse == Document::FullParse)
{
spl = new VNodeSpline(doc, data, id, idSpline, typeCreation, idTool, parent);
spl = new VNodeSpline(doc, data, id, idSpline, typeCreation, idTool, doc);
doc->AddTool(id, spl);
if (idTool != NULL_ID)
@ -89,10 +85,8 @@ VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, VMainG
}
else
{
// Try to prevent memory leak
scene->addItem(spl);// First adopted by scene
spl->hide();// If no one will use node, it will stay hidden
spl->SetParentType(ParentType::Scene);
// Help to delete the node before each FullParse
doc->AddToolOnRemove(spl);
}
}
else
@ -108,15 +102,6 @@ QString VNodeSpline::getTagName() const
return VNodeSpline::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VNodeSpline::FullUpdateFromFile()
{
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
@ -152,67 +137,3 @@ void VNodeSpline::RefreshDataInFile()
}
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
emit ChoosedTool(id, SceneObject::Spline);
}
QGraphicsItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSpline::ShowNode()
{
if (parentType != ParentType::Scene)
{
show();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSpline::HideNode()
{
hide();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VNodeSpline::RefreshGeometry()
{
// const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
// QPainterPath path;
// path.addPath(spl->GetPath());
// path.setFillRule( Qt::WindingFill );
// this->setPath(path);
}

View File

@ -35,33 +35,28 @@
/**
* @brief The VNodeSpline class spline detail node.
*/
class VNodeSpline:public VAbstractNode, public QGraphicsPathItem
class VNodeSpline:public VAbstractNode
{
Q_OBJECT
public:
VNodeSpline(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
const quint32 &idTool = 0, QObject *qoParent = nullptr);
static VNodeSpline *Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
static VNodeSpline *Create(VAbstractPattern *doc, VContainer *data, quint32 id,
quint32 idSpline, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
const Source &typeCreation, const quint32 &idTool = 0);
static const QString TagName;
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::NodeSpline)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE {}
protected:
virtual void AddToFile () Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
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;
virtual void ShowNode() Q_DECL_OVERRIDE {}
virtual void HideNode() Q_DECL_OVERRIDE {}
private:
void RefreshGeometry ();
Q_DISABLE_COPY(VNodeSpline)
};
#endif // VNODESPLINE_H

View File

@ -48,13 +48,9 @@ const QString VNodeSplinePath::ToolType = QStringLiteral("modelingPath");
* @param parent parent object.
*/
VNodeSplinePath::VNodeSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Source &typeCreation, const quint32 &idTool, QObject *qoParent,
QGraphicsItem * parent)
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent)
const Source &typeCreation, const quint32 &idTool, QObject *qoParent)
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent)
{
RefreshGeometry();
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
ToolCreation(typeCreation);
}
@ -70,14 +66,13 @@ VNodeSplinePath::VNodeSplinePath(VAbstractPattern *doc, VContainer *data, quint3
* @param idTool tool id.
* @param parent QObject parent.
*/
void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene, quint32 id,
quint32 idSpline, const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, quint32 id,
quint32 idSpline, const Document &parse, const Source &typeCreation, const quint32 &idTool)
{
VAbstractTool::AddRecord(id, Tool::NodeSplinePath, doc);
if (parse == Document::FullParse)
{
VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeCreation, idTool, parent);
VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeCreation, idTool, doc);
doc->AddTool(id, splPath);
if (idTool != NULL_ID)
@ -89,10 +84,8 @@ void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, VMainGraph
}
else
{
// Try to prevent memory leak
scene->addItem(splPath);// First adopted by scene
splPath->hide();// If no one will use node, it will stay hidden
splPath->SetParentType(ParentType::Scene);
// Help to delete the node before each FullParse
doc->AddToolOnRemove(splPath);
}
}
else
@ -107,15 +100,6 @@ QString VNodeSplinePath::getTagName() const
return VNodeSplinePath::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VNodeSplinePath::FullUpdateFromFile()
{
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
@ -151,67 +135,3 @@ void VNodeSplinePath::RefreshDataInFile()
}
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event.
*/
void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
emit ChoosedTool(id, SceneObject::SplinePath);
}
QGraphicsItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSplinePath::ShowNode()
{
if (parentType != ParentType::Scene)
{
show();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSplinePath::HideNode()
{
hide();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VNodeSplinePath::RefreshGeometry()
{
// const QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
// QPainterPath path;
// path.addPath(splPath->GetPath());
// path.setFillRule( Qt::WindingFill );
// this->setPath(path);
}

View File

@ -35,32 +35,27 @@
/**
* @brief The VNodeSplinePath class spline path detail node.
*/
class VNodeSplinePath : public VAbstractNode, public QGraphicsPathItem
class VNodeSplinePath : public VAbstractNode
{
Q_OBJECT
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, VMainGraphicsScene *scene, quint32 id,
const quint32 &idTool = 0, QObject *qoParent = 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);
const Source &typeCreation, const quint32 &idTool = 0);
static const QString TagName;
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::SplinePath)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE {}
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
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;
virtual void ShowNode() Q_DECL_OVERRIDE {}
virtual void HideNode() Q_DECL_OVERRIDE {}
private:
void RefreshGeometry();
Q_DISABLE_COPY(VNodeSplinePath)
};
#endif // VNODESPLINEPATH_H

View File

@ -88,13 +88,13 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
InitTool<VNodePoint>(scene, detail.at(i));
break;
case (Tool::NodeArc):
InitTool<VNodeArc>(scene, detail.at(i));
doc->IncrementReferens(detail.at(i).getId());
break;
case (Tool::NodeSpline):
InitTool<VNodeSpline>(scene, detail.at(i));
doc->IncrementReferens(detail.at(i).getId());
break;
case (Tool::NodeSplinePath):
InitTool<VNodeSplinePath>(scene, detail.at(i));
doc->IncrementReferens(detail.at(i).getId());
break;
default:
qDebug()<<"Get wrong tool type. Ignore.";
@ -173,26 +173,27 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstrac
case (Tool::NodeArc):
{
id = CreateNode<VArc>(data, nodeD.getId());
VNodeArc::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui);
VNodeArc::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui);
}
break;
case (Tool::NodeSpline):
{
id = CreateNode<VSpline>(data, nodeD.getId());
VNodeSpline::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui);
VNodeSpline::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui);
}
break;
case (Tool::NodeSplinePath):
{
id = CreateNode<VSplinePath>(data, nodeD.getId());
VNodeSplinePath::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui);
VNodeSplinePath::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui);
}
break;
default:
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
break;
}
VNodeDetail node(id, nodeD.getTypeTool(), NodeDetail::Contour, nodeD.getMx(), nodeD.getMy(), nodeD.getReverse());
VNodeDetail node(id, nodeD.getTypeTool(), NodeDetail::Contour, nodeD.getMx(), nodeD.getMy(),
nodeD.getReverse());
det.append(node);
}
det.setName(detail.getName());

View File

@ -102,7 +102,7 @@ VToolUnionDetails::VToolUnionDetails(VAbstractPattern *doc, VContainer *data, co
* @param pRotate point rotation.
* @param angle angle rotation.
*/
void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene, VAbstractPattern *doc,
void VToolUnionDetails::AddToNewDetail(VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data, VDetail &newDetail, const VDetail &det, const int &i,
const quint32 &idTool, QVector<quint32> &children, const qreal &dx,
const qreal &dy, const quint32 &pRotate, const qreal &angle)
@ -127,7 +127,7 @@ 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, idTool);
}
}
break;
@ -164,7 +164,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
arc2->setMode(Draw::Modeling);
id = data->AddGObject(arc2);
VNodeArc::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
VNodeArc::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool);
}
}
break;
@ -199,7 +199,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
VSpline *spl1 = new VSpline(*spl);
spl1->setMode(Draw::Modeling);
id = data->AddGObject(spl1);
VNodeSpline::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
VNodeSpline::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool);
delete p4;
delete p1;
@ -255,8 +255,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene,
VSplinePath *path1 = new VSplinePath(*path);
path1->setMode(Draw::Modeling);
id = data->AddGObject(path1);
VNodeSplinePath::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, idTool,
tool);
VNodeSplinePath::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool);
}
}
break;
@ -552,6 +551,8 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
//Scene doesn't show this tool, so doc will destroy this object.
unionDetails = new VToolUnionDetails(doc, data, id, d1, d2, indexD1, indexD2, typeCreation, drawName, doc);
doc->AddTool(id, unionDetails);
// Unfortunatelly doc will destroy all objects only in the end, but we should delete them before each FullParse
doc->AddToolOnRemove(unionDetails);
}
//Then create new details
VNodeDetail det1p1;
@ -592,7 +593,7 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
QVector<quint32> children;
do
{
AddToNewDetail(unionDetails, scene, doc, data, newDetail, d1.RemoveEdge(indexD1), i, id, children);
AddToNewDetail(scene, doc, data, newDetail, d1.RemoveEdge(indexD1), i, id, children);
++i;
if (i > d1.indexOfNode(det1p1.getId()) && pointsD2 < countNodeD2-1)
{
@ -604,7 +605,7 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
{
j=0;
}
AddToNewDetail(unionDetails, scene, doc, data, newDetail, d2.RemoveEdge(indexD2), j, id, children,
AddToNewDetail(scene, doc, data, newDetail, d2.RemoveEdge(indexD2), j, id, children,
dx, dy, det1p1.getId(), angle);
++pointsD2;
++j;

View File

@ -71,7 +71,7 @@ public:
static const QString AttrNodeType;
static const QString NodeTypeContour;
static const QString NodeTypeModeling;
static void AddToNewDetail(QObject *tool, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
static void AddToNewDetail(VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
VDetail &newDetail, const VDetail &det, const int &i, const quint32 &idTool,
QVector<quint32> &children, const qreal &dx = 0,
const qreal &dy = 0, const quint32 &pRotate = 0, const qreal &angle = 0);

View File

@ -89,7 +89,13 @@ void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::InitOrigins()
{
qDeleteAll(origins);
foreach (QGraphicsItem *item, origins)
{
if (this->items().contains(item))
{
delete item;
}
}
QPen originsPen(Qt::green, ToPixel(WidthHairLine(Unit::Mm), Unit::Mm), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
QBrush axisTextBrush(Qt::green);