2016-12-20 15:51:58 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 20 12, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2016 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vnodeellipticalarc.h"
|
|
|
|
|
|
|
|
#include <QDomElement>
|
|
|
|
#include <QStaticStringData>
|
|
|
|
#include <QStringData>
|
|
|
|
#include <QStringDataPtr>
|
|
|
|
|
|
|
|
#include "../ifc/xml/vdomdocument.h"
|
|
|
|
#include "../ifc/ifcdef.h"
|
|
|
|
#include "../vabstracttool.h"
|
|
|
|
#include "../vdatatool.h"
|
|
|
|
#include "vabstractnode.h"
|
|
|
|
|
|
|
|
const QString VNodeEllipticalArc::ToolType = QStringLiteral("modeling");
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-09-18 10:37:23 +02:00
|
|
|
void VNodeEllipticalArc::Create(VAbstractNodeInitData initData)
|
2016-12-20 15:51:58 +01:00
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
if (initData.parse == Document::FullParse)
|
2016-12-20 15:51:58 +01:00
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
VAbstractTool::AddRecord(initData.id, Tool::NodeElArc, initData.doc);
|
|
|
|
VNodeEllipticalArc *arc = new VNodeEllipticalArc(initData);
|
2016-12-20 15:51:58 +01:00
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
VAbstractPattern::AddTool(initData.id, arc);
|
|
|
|
if (initData.idTool != NULL_ID)
|
2016-12-20 15:51:58 +01:00
|
|
|
{
|
|
|
|
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
2017-09-18 10:37:23 +02:00
|
|
|
VDataTool *tool = VAbstractPattern::getTool(initData.idTool);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(tool != nullptr)
|
2016-12-20 15:51:58 +01:00
|
|
|
arc->setParent(tool);// Adopted by a tool
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Help to delete the node before each FullParse
|
2017-09-18 10:37:23 +02:00
|
|
|
initData.doc->AddToolOnRemove(arc);
|
2016-12-20 15:51:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
2016-12-20 15:51:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VNodeEllipticalArc::getTagName() const
|
|
|
|
{
|
|
|
|
return VAbstractPattern::TagElArc;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VNodeEllipticalArc::AllowHover(bool enabled)
|
|
|
|
{
|
|
|
|
Q_UNUSED(enabled)
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VNodeEllipticalArc::AllowSelecting(bool enabled)
|
|
|
|
{
|
|
|
|
Q_UNUSED(enabled)
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VNodeEllipticalArc::AddToFile()
|
|
|
|
{
|
|
|
|
QDomElement domElement = doc->createElement(getTagName());
|
|
|
|
|
2017-09-17 08:45:18 +02:00
|
|
|
doc->SetAttribute(domElement, VDomDocument::AttrId, m_id);
|
2016-12-20 15:51:58 +01:00
|
|
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
|
|
|
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
|
|
|
if (idTool != NULL_ID)
|
|
|
|
{
|
|
|
|
doc->SetAttribute(domElement, AttrIdTool, idTool);
|
|
|
|
}
|
|
|
|
|
|
|
|
AddToModeling(domElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-09-18 10:37:23 +02:00
|
|
|
VNodeEllipticalArc::VNodeEllipticalArc(const VAbstractNodeInitData &initData, QObject *qoParent)
|
|
|
|
:VAbstractNode(initData.doc, initData.data, initData.id, initData.idObject, initData.drawName, initData.idTool,
|
|
|
|
qoParent)
|
2016-12-20 15:51:58 +01:00
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
ToolCreation(initData.typeCreation);
|
2016-12-20 15:51:58 +01:00
|
|
|
}
|