Added VNodeEllipticalArc.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-12-20 16:51:58 +02:00
parent f0b35ddc11
commit 1fb0ab4d75
18 changed files with 491 additions and 146 deletions

View File

@ -77,7 +77,7 @@ void VToolOptionsPropertyBrowser::ClearPropertyBrowser()
void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
{
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50, "Not all tools were used in switch.");
switch (item->type())
{
@ -213,7 +213,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
}
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50, "Not all tools were used in switch.");
switch (currentItem->type())
{
@ -360,7 +360,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
}
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50, "Not all tools were used in switch.");
switch (currentItem->type())
{

View File

@ -209,7 +209,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
QString DialogHistory::Record(const VToolRecord &tool)
{
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used in history.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50, "Not all tools were used in history.");
const QDomElement domElem = doc->elementById(tool.getId());
if (domElem.isElement() == false)
@ -392,6 +392,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Tool::Detail:
case Tool::UnionDetails:
case Tool::NodeArc:
case Tool::NodeElArc:
case Tool::NodePoint:
case Tool::NodeSpline:
case Tool::NodeSplinePath:

View File

@ -1791,7 +1791,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
void MainWindow::CancelTool()
{
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50, "Not all tools were handled.");
qCDebug(vMainWindow, "Canceling tool.");
delete dialogTool;
@ -1824,6 +1824,7 @@ void MainWindow::CancelTool()
case Tool::LAST_ONE_DO_NOT_USE:
case Tool::NodePoint:
case Tool::NodeArc:
case Tool::NodeElArc:
case Tool::NodeSpline:
case Tool::NodeSplinePath:
Q_UNREACHABLE(); //-V501
@ -2995,7 +2996,7 @@ void MainWindow::SetEnableTool(bool enable)
}
// This check helps to find missed tools
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50, "Not all tools were handled.");
//Drawing Tools
ui->toolButtonEndLine->setEnabled(drawTools);
@ -3316,7 +3317,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
void MainWindow::LastUsedTool()
{
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50, "Not all tools were handled.");
if (currentTool == lastUsedTool)
{
@ -3341,6 +3342,7 @@ void MainWindow::LastUsedTool()
case Tool::LAST_ONE_DO_NOT_USE:
case Tool::NodePoint:
case Tool::NodeArc:
case Tool::NodeElArc:
case Tool::NodeSpline:
case Tool::NodeSplinePath:
Q_UNREACHABLE(); //-V501

View File

@ -44,6 +44,7 @@
#include "../vmisc/vmath.h"
#include "../qmuparser/qmuparsererror.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vsplinepath.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
@ -628,8 +629,11 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping())));
detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr));
QStringList types = QStringList() << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline
<< VToolDetail::NodeSplinePath;
QStringList types = QStringList() << VToolDetail::NodePoint
<< VToolDetail::NodeArc
<< VToolDetail::NodeSpline
<< VToolDetail::NodeSplinePath
<< VToolDetail::NodeElArc;
const QDomNodeList nodeList = domElement.childNodes();
const qint32 num = nodeList.size();
for (qint32 i = 0; i < num; ++i)
@ -662,6 +666,9 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
case 3: // VToolDetail::NodeSplinePath
tool = Tool::NodeSplinePath;
break;
case 4: // VToolDetail::NodeElArc
tool = Tool::NodeElArc;
break;
default:
VException e(tr("Wrong tag name '%1'.").arg(t));
throw e;
@ -2495,6 +2502,41 @@ void VPattern::ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &do
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseNodeEllipticalArc(const QDomElement &domElement, const Document &parse)
{
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
try
{
quint32 id = 0;
ToolsCommonAttributes(domElement, id);
const quint32 idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
VEllipticalArc *arc = nullptr;
try
{
arc = new VEllipticalArc(*data->GeometricObject<VEllipticalArc>(idObject));
}
catch (const VExceptionBadId &e)
{ // Possible case. Parent was deleted, but the node object is still here.
Q_UNUSED(e);
return;// Just ignore
}
arc->setIdObject(idObject);
arc->setMode(Draw::Modeling);
data->UpdateGObject(id, arc);
VNodeEllipticalArc::Create(this, data, id, idObject, parse, Source::FromFile, "", idTool);
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating modeling elliptical arc"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse)
{
@ -2937,13 +2979,17 @@ void VPattern::ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of elliptical arc is empty");
QStringList arcs = QStringList() << VToolEllipticalArc::ToolType; /*0*/
const QStringList arcs = QStringList() << VToolEllipticalArc::ToolType /*0*/
<< VNodeEllipticalArc::ToolType; /*1*/
switch (arcs.indexOf(type))
{
case 0: //VToolArc::ToolType
ParseToolEllipticalArc(scene, domElement, parse);
break;
case 1: //VNodeEllipticalArc::ToolType
ParseNodeEllipticalArc(domElement, parse);
break;
default:
VException e(tr("Unknown elliptical arc type '%1'.").arg(type));
throw e;
@ -3527,7 +3573,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
QRectF VPattern::ActiveDrawBoundingRect() const
{
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50, "Not all tools were used.");
QRectF rec;
@ -3655,6 +3701,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const
case Tool::Detail:
case Tool::UnionDetails:
case Tool::NodeArc:
case Tool::NodeElArc:
case Tool::NodePoint:
case Tool::NodeSpline:
case Tool::NodeSplinePath:

View File

@ -196,6 +196,7 @@ private:
void ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
void ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
void ParseNodeEllipticalArc(const QDomElement &domElement, const Document &parse);
void ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
void ParseToolFlippingByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);

View File

@ -638,6 +638,7 @@ quint32 VAbstractPattern::SiblingNodeId(const quint32 &nodeId) const
case Tool::Detail:
case Tool::UnionDetails:
case Tool::NodeArc:
case Tool::NodeElArc:
case Tool::NodePoint:
case Tool::NodeSpline:
case Tool::NodeSplinePath:
@ -1426,7 +1427,7 @@ QStringList VAbstractPattern::ListPointExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment a number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagPoint);
@ -1498,7 +1499,7 @@ QStringList VAbstractPattern::ListArcExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagArc);
@ -1552,7 +1553,7 @@ QStringList VAbstractPattern::ListElArcExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagElArc);
@ -1623,7 +1624,7 @@ QStringList VAbstractPattern::ListPathPointExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50);
QStringList expressions;
const QDomNodeList list = elementsByTagName(AttrPathPoint);
@ -1690,7 +1691,7 @@ QStringList VAbstractPattern::ListOperationExpressions() const
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 50);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagOperation);

View File

@ -57,7 +57,8 @@ public:
VEllipticalArc (const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
VEllipticalArc (qreal length, const QString &formulaLength, const VPointF &center, qreal radius1, qreal radius2,
const QString &formulaRadius1, const QString &formulaRadius2, qreal f1, const QString &formulaF1,
qreal rotationAngle, const QString &formulaRotationAngle, quint32 idObject = 0, Draw mode = Draw::Calculation);
qreal rotationAngle, const QString &formulaRotationAngle, quint32 idObject = 0,
Draw mode = Draw::Calculation);
VEllipticalArc (qreal length, const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle);
VEllipticalArc(const VEllipticalArc &arc);

View File

@ -57,7 +57,7 @@ class VTranslateMeasurements;
#define DefPointRadius 1.5//mm
enum class NodeDetail : char { Contour, Modeling };
enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown };
enum class SceneObject : char { Point, Line, Spline, Arc, ElArc, SplinePath, Detail, Unknown };
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 };
@ -94,6 +94,7 @@ enum class Tool : ToolVisHolderType
Detail,
NodePoint,
NodeArc,
NodeElArc,
NodeSpline,
NodeSplinePath,
Height,

View File

@ -404,6 +404,7 @@ QVector<QPointF> VDetail::ContourPoints(const VContainer *data) const
}
break;
case (Tool::NodeArc):
case (Tool::NodeElArc):
case (Tool::NodeSpline):
case (Tool::NodeSplinePath):
{
@ -448,6 +449,7 @@ QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
}
break;
case (Tool::NodeArc):
case (Tool::NodeElArc):
case (Tool::NodeSpline):
case (Tool::NodeSplinePath):
{

View File

@ -193,6 +193,9 @@ void DialogDetail::ChosenObject(quint32 id, const SceneObject &type)
case (SceneObject::Arc):
NewItem(id, Tool::NodeArc, NodeDetail::Contour);
break;
case (SceneObject::ElArc):
NewItem(id, Tool::NodeElArc, NodeDetail::Contour);
break;
case (SceneObject::Point):
NewItem(id, Tool::NodePoint, NodeDetail::Contour);
break;
@ -394,6 +397,7 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t
{
case (Tool::NodePoint):
case (Tool::NodeArc):
case (Tool::NodeElArc):
case (Tool::NodeSpline):
case (Tool::NodeSplinePath):
{

View File

@ -30,6 +30,7 @@
#define NODEDETAILS_H
#include "vnodearc.h"
#include "vnodeellipticalarc.h"
#include "vnodepoint.h"
#include "vnodespline.h"
#include "vnodesplinepath.h"

View File

@ -39,8 +39,6 @@
#include "../vdatatool.h"
#include "vabstractnode.h"
class VContainer;
const QString VNodeArc::ToolType = QStringLiteral("modeling");
//---------------------------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,131 @@
/************************************************************************
**
** @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");
//---------------------------------------------------------------------------------------------------------------------
void VNodeEllipticalArc::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc,
const Document &parse, const Source &typeCreation, const QString &drawName,
const quint32 &idTool)
{
VAbstractTool::AddRecord(id, Tool::NodeElArc, doc);
if (parse == Document::FullParse)
{
VNodeEllipticalArc *arc = new VNodeEllipticalArc(doc, data, id, idArc, typeCreation, drawName, idTool, doc);
doc->AddTool(id, arc);
if (idTool != NULL_ID)
{
//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);// Adopted by a tool
}
else
{
// Help to delete the node before each FullParse
doc->AddToolOnRemove(arc);
}
}
else
{
doc->UpdateToolData(id, data);
}
}
//---------------------------------------------------------------------------------------------------------------------
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());
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrIdObject, idNode);
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
AddToModeling(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeEllipticalArc::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrIdObject, idNode);
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
VNodeEllipticalArc::VNodeEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc,
const Source &typeCreation, const QString &drawName, const quint32 &idTool,
QObject *qoParent)
:VAbstractNode(doc, data, id, idArc, drawName, idTool, qoParent)
{
ToolCreation(typeCreation);
}

View File

@ -0,0 +1,71 @@
/************************************************************************
**
** @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/>.
**
*************************************************************************/
#ifndef VNODEELLIPTICALARC_H
#define VNODEELLIPTICALARC_H
#include <qcompilerdetection.h>
#include <QGraphicsPathItem>
#include <QMetaObject>
#include <QObject>
#include <QString>
#include <QtGlobal>
#include "../ifc/xml/vabstractpattern.h"
#include "../vmisc/def.h"
#include "vabstractnode.h"
class VContainer;
class VNodeEllipticalArc :public VAbstractNode
{
Q_OBJECT
public:
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse,
const Source &typeCreation, const QString &drawName = QString(),
const quint32 &idTool = NULL_ID);
static const QString ToolType;
virtual QString getTagName() const Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE {}
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void ShowNode() Q_DECL_OVERRIDE {}
virtual void HideNode() Q_DECL_OVERRIDE {}
private:
Q_DISABLE_COPY(VNodeEllipticalArc)
VNodeEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation,
const QString &drawName = QString(), const quint32 &idTool = 0, QObject *qoParent = nullptr);
};
#endif // VNODEELLIPTICALARC_H

View File

@ -58,7 +58,8 @@ HEADERS += \
$$PWD/drawTools/operation/flipping/vtoolflippingbyaxis.h \
$$PWD/drawTools/operation/flipping/vabstractflipping.h \
$$PWD/drawTools/operation/vtoolmove.h \
$$PWD/drawTools/toolcurve/vtoolellipticalarc.h
$$PWD/drawTools/toolcurve/vtoolellipticalarc.h \
$$PWD/nodeDetails/vnodeellipticalarc.h
SOURCES += \
$$PWD/vtooldetail.cpp \
@ -114,4 +115,5 @@ SOURCES += \
$$PWD/drawTools/operation/flipping/vtoolflippingbyaxis.cpp \
$$PWD/drawTools/operation/flipping/vabstractflipping.cpp \
$$PWD/drawTools/operation/vtoolmove.cpp \
$$PWD/drawTools/toolcurve/vtoolellipticalarc.cpp
$$PWD/drawTools/toolcurve/vtoolellipticalarc.cpp \
$$PWD/nodeDetails/vnodeellipticalarc.cpp

View File

@ -78,6 +78,7 @@
#include "../undocommands/savedetailoptions.h"
#include "../undocommands/toggledetailinlayout.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vgeometry/vgeometrydef.h"
@ -99,6 +100,7 @@
#include "vabstracttool.h"
#include "nodeDetails/vabstractnode.h"
#include "nodeDetails/vnodearc.h"
#include "nodeDetails/vnodeellipticalarc.h"
#include "nodeDetails/vnodepoint.h"
#include "nodeDetails/vnodespline.h"
#include "nodeDetails/vnodesplinepath.h"
@ -130,6 +132,7 @@ const QString VToolDetail::NodeTypeContour = QStringLiteral("Contour");
const QString VToolDetail::NodeTypeModeling = QStringLiteral("Modeling");
const QString VToolDetail::NodeArc = QStringLiteral("NodeArc");
const QString VToolDetail::NodeElArc = QStringLiteral("NodeElArc");
const QString VToolDetail::NodePoint = QStringLiteral("NodePoint");
const QString VToolDetail::NodeSpline = QStringLiteral("NodeSpline");
const QString VToolDetail::NodeSplinePath = QStringLiteral("NodeSplinePath");
@ -162,11 +165,8 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
break;
}
case (Tool::NodeArc):
doc->IncrementReferens(detail.at(i).getId());
break;
case (Tool::NodeElArc):
case (Tool::NodeSpline):
doc->IncrementReferens(detail.at(i).getId());
break;
case (Tool::NodeSplinePath):
doc->IncrementReferens(detail.at(i).getId());
break;
@ -275,6 +275,12 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstrac
VNodeArc::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui);
}
break;
case (Tool::NodeElArc):
{
id = CreateNode<VEllipticalArc>(data, nodeD.getId());
VNodeEllipticalArc::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui);
}
break;
case (Tool::NodeSpline):
{
const auto obj = data->GetGObject(nodeD.getId());
@ -1155,6 +1161,9 @@ void VToolDetail::AddNode(VAbstractPattern *doc, QDomElement &domElement, const
case (Tool::NodeArc):
doc->SetAttribute(nod, AttrType, NodeArc);
break;
case (Tool::NodeElArc):
doc->SetAttribute(nod, AttrType, NodeElArc);
break;
case (Tool::NodePoint):
doc->SetAttribute(nod, AttrType, NodePoint);
break;

View File

@ -83,6 +83,7 @@ public:
static const QString NodeTypeContour;
static const QString NodeTypeModeling;
static const QString NodeArc;
static const QString NodeElArc;
static const QString NodePoint;
static const QString NodeSpline;
static const QString NodeSplinePath;

View File

@ -46,6 +46,7 @@
#include "../ifc/xml/vdomdocument.h"
#include "../ifc/xml/vpatternconverter.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vsplinepath.h"
#include "../vgeometry/vabstractcubicbezier.h"
#include "../vgeometry/vabstractcubicbezierpath.h"
@ -59,6 +60,7 @@
#include "../vpatterndb/vcontainer.h"
#include "../dialogs/tools/dialogtool.h"
#include "nodeDetails/vnodearc.h"
#include "nodeDetails/vnodeellipticalarc.h"
#include "nodeDetails/vnodepoint.h"
#include "nodeDetails/vnodespline.h"
#include "nodeDetails/vnodesplinepath.h"
@ -188,6 +190,42 @@ void VToolUnionDetails::AddToNewDetail(VMainGraphicsScene *scene, VAbstractPatte
VNodeArc::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, drawName, idTool);
}
break;
case (Tool::NodeElArc):
{
const QSharedPointer<VEllipticalArc> arc = data->GeometricObject<VEllipticalArc>(det.at(i).getId());
VPointF p1 = VPointF(arc->GetP1(), "A", 0, 0);
VPointF p2 = VPointF(arc->GetP2(), "A", 0, 0);
VPointF *center = new VPointF(arc->GetCenter());
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{
const QPointF p = *data->GeometricObject<VPointF>(pRotate);
BiasRotatePoint(&p1, dx, dy, p, angle);
BiasRotatePoint(&p2, dx, dy, p, angle);
BiasRotatePoint(center, dx, dy, p, angle);
}
QLineF l1(*center, p1);
QLineF l2(*center, p2);
center->setMode(Draw::Modeling);
quint32 idCenter = data->AddGObject(center);
Q_UNUSED(idCenter);
VEllipticalArc *arc1 = new VEllipticalArc (*center, arc->GetRadius1(), arc->GetRadius2(),
arc->GetFormulaRadius1(), arc->GetFormulaRadius2(),
l1.angle(), QString().setNum(l1.angle()), l2.angle(),
QString().setNum(l2.angle()), 0, "0");
arc1->setMode(Draw::Modeling);
idObject = data->AddGObject(arc1);
children.append(idObject);
VEllipticalArc *arc2 = new VEllipticalArc(*arc1);
arc2->setMode(Draw::Modeling);
id = data->AddGObject(arc2);
VNodeEllipticalArc::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, drawName, idTool);
}
break;
case (Tool::NodeSpline):
{
const QSharedPointer<VAbstractCubicBezier> spline =
@ -344,6 +382,34 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const
delete center;
}
break;
case (Tool::NodeElArc):
{
const QSharedPointer<VEllipticalArc> arc = data->GeometricObject<VEllipticalArc>(det.at(i).getId());
VPointF p1 = VPointF(arc->GetP1());
VPointF p2 = VPointF(arc->GetP2());
VPointF *center = new VPointF(arc->GetCenter());
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{
const QPointF p = *data->GeometricObject<VPointF>(pRotate);
BiasRotatePoint(&p1, dx, dy, p, angle);
BiasRotatePoint(&p2, dx, dy, p, angle);
BiasRotatePoint(center, dx, dy, p, angle);
}
QLineF l1(*center, p1);
QLineF l2(*center, p2);
VEllipticalArc *arc1 = new VEllipticalArc (*center, arc->GetRadius1(), arc->GetRadius2(),
arc->GetFormulaRadius1(), arc->GetFormulaRadius2(),
l1.angle(), QString().setNum(l1.angle()), l2.angle(),
QString().setNum(l2.angle()), 0, "0");
arc1->setMode(Draw::Modeling);
data->UpdateGObject(TakeNextId(children), arc1);
delete center;
}
break;
case (Tool::NodeSpline):
{
const QSharedPointer<VAbstractCubicBezier> spline =
@ -803,19 +869,23 @@ QVector<VDetail> VToolUnionDetails::GetDetailFromFile(VAbstractPattern *doc, con
Tool tool = Tool::NodePoint;
NodeDetail nodeType = NodeDetail::Contour;
QString t = doc->GetParametrString(element, "type", "NodePoint");
if (t == "NodePoint")
if (t == QLatin1String("NodePoint"))
{
tool = Tool::NodePoint;
}
else if (t == "NodeArc")
else if (t == QLatin1String("NodeArc"))
{
tool = Tool::NodeArc;
}
else if (t == "NodeSpline")
else if (t == QLatin1String("NodeElArc"))
{
tool = Tool::NodeElArc;
}
else if (t == QLatin1String("NodeSpline"))
{
tool = Tool::NodeSpline;
}
else if (t == "NodeSplinePath")
else if (t == QLatin1String("NodeSplinePath"))
{
tool = Tool::NodeSplinePath;
}
@ -962,6 +1032,7 @@ void VToolUnionDetails::IncrementReferences(const VDetail &d) const
break;
}
case (Tool::NodeArc):
case (Tool::NodeElArc):
case (Tool::NodeSpline):
case (Tool::NodeSplinePath):
doc->IncrementReferens(d.at(i).getId());
@ -987,6 +1058,7 @@ void VToolUnionDetails::DecrementReferences(const VDetail &d) const
break;
}
case (Tool::NodeArc):
case (Tool::NodeElArc):
case (Tool::NodeSpline):
case (Tool::NodeSplinePath):
doc->DecrementReferens(d.at(i).getId());