Refactor tool clases to pass data in structure.
--HG-- branch : feature
This commit is contained in:
parent
783f2f1296
commit
e7db934fb5
|
@ -263,9 +263,19 @@ void MainWindow::AddPP(const QString &PPName)
|
||||||
ui->view->itemClicked(nullptr);//hide options previous tool
|
ui->view->itemClicked(nullptr);//hide options previous tool
|
||||||
const QString label = doc->GenerateLabel(LabelType::NewPatternPiece);
|
const QString label = doc->GenerateLabel(LabelType::NewPatternPiece);
|
||||||
const QPointF startPosition = StartPositionNewPP();
|
const QPointF startPosition = StartPositionNewPP();
|
||||||
VPointF *point = new VPointF(startPosition.x(), startPosition.y(), label, 5, 10);
|
|
||||||
auto spoint = VToolBasePoint::Create(0, PPName, point, sceneDraw, doc, pattern, Document::FullParse,
|
VToolBasePointInitData initData;
|
||||||
Source::FromGui);
|
initData.scene = sceneDraw;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = pattern;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
initData.x = startPosition.x();
|
||||||
|
initData.y = startPosition.y();
|
||||||
|
initData.name = label;
|
||||||
|
initData.nameActivPP = PPName;
|
||||||
|
|
||||||
|
auto spoint = VToolBasePoint::Create(initData);
|
||||||
ui->view->itemClicked(spoint);
|
ui->view->itemClicked(spoint);
|
||||||
|
|
||||||
SetEnableTool(true);
|
SetEnableTool(true);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
class VMainGraphicsScene;
|
class VMainGraphicsScene;
|
||||||
class VNodeDetail;
|
class VNodeDetail;
|
||||||
|
class VToolSinglePointInitData;
|
||||||
|
class VToolLinePointInitData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VPattern class working with pattern file.
|
* @brief The VPattern class working with pattern file.
|
||||||
|
@ -155,10 +157,8 @@ private:
|
||||||
void ParseIncrementsElement(const QDomNode& node);
|
void ParseIncrementsElement(const QDomNode& node);
|
||||||
void PrepareForParse(const Document &parse);
|
void PrepareForParse(const Document &parse);
|
||||||
void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id);
|
void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id);
|
||||||
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx,
|
void PointsWithLineCommonAttributes(const QDomElement &domElement, VToolLinePointInitData &initData);
|
||||||
qreal &my, bool &labelVisible, QString &typeLine, QString &lineColor);
|
void PointsCommonAttributes(const QDomElement &domElement, VToolSinglePointInitData &initData);
|
||||||
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx,
|
|
||||||
qreal &my, bool &labelVisible);
|
|
||||||
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my);
|
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my);
|
||||||
void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject,
|
void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject,
|
||||||
quint32 &idTool);
|
quint32 &idTool);
|
||||||
|
|
|
@ -46,21 +46,19 @@ VAbstractFlipping::VAbstractFlipping(VAbstractPattern *doc, VContainer *data, qu
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractFlipping::CreateDestination(Source typeCreation, quint32 &id, QVector<DestinationItem> &dest,
|
void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint,
|
||||||
const QVector<quint32> &source, const QPointF &fPoint, const QPointF &sPoint,
|
const QPointF &sPoint)
|
||||||
const QString &suffix, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse)
|
|
||||||
{
|
{
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
dest.clear();// Try to avoid mistake, value must be empty
|
initData.destination.clear();// Try to avoid mistake, value must be empty
|
||||||
|
|
||||||
id = VContainer::getNextId();//Just reserve id for tool
|
initData.id = VContainer::getNextId();//Just reserve id for tool
|
||||||
|
|
||||||
for (int i = 0; i < source.size(); ++i)
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
{
|
{
|
||||||
const quint32 idObject = source.at(i);
|
const quint32 idObject = initData.source.at(i);
|
||||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||||
|
@ -70,25 +68,34 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
dest.append(CreatePoint(id, idObject, fPoint, sPoint, suffix, data));
|
initData.destination.append(CreatePoint(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
||||||
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
dest.append(CreateArc<VArc>(id, idObject, fPoint, sPoint, suffix, data));
|
initData.destination.append(CreateArc<VArc>(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
||||||
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
dest.append(CreateArc<VEllipticalArc>(id, idObject, fPoint, sPoint, suffix, data));
|
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, idObject, fPoint, sPoint,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
dest.append(CreateCurve<VSpline>(id, idObject, fPoint, sPoint, suffix, data));
|
initData.destination.append(CreateCurve<VSpline>(initData.id, idObject, fPoint, sPoint,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
dest.append(CreateCurveWithSegments<VSplinePath>(id, idObject, fPoint, sPoint, suffix, data));
|
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, fPoint,
|
||||||
|
sPoint, initData.suffix,
|
||||||
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
dest.append(CreateCurve<VCubicBezier>(id, idObject, fPoint, sPoint, suffix, data));
|
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, idObject, fPoint, sPoint,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
dest.append(CreateCurveWithSegments<VCubicBezierPath>(id, idObject, fPoint, sPoint, suffix, data));
|
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, fPoint,
|
||||||
|
sPoint, initData.suffix,
|
||||||
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
break;
|
break;
|
||||||
|
@ -98,10 +105,10 @@ QT_WARNING_POP
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < source.size(); ++i)
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
{
|
{
|
||||||
const quint32 idObject = source.at(i);
|
const quint32 idObject = initData.source.at(i);
|
||||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||||
|
@ -111,36 +118,44 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
UpdatePoint(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id, dest.at(i).mx,
|
{
|
||||||
dest.at(i).my);
|
const DestinationItem &item = initData.destination.at(i);
|
||||||
|
UpdatePoint(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data, item.id, item.mx,
|
||||||
|
item.my);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
UpdateArc<VArc>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
|
UpdateArc<VArc>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
UpdateArc<VEllipticalArc>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
|
UpdateArc<VEllipticalArc>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
UpdateCurve<VSpline>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
|
UpdateCurve<VSpline>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
UpdateCurveWithSegments<VSplinePath>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
|
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
||||||
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
UpdateCurve<VCubicBezier>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
|
UpdateCurve<VCubicBezier>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
UpdateCurveWithSegments<VCubicBezierPath>(id, idObject, fPoint, sPoint, suffix, data,
|
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, fPoint, sPoint, initData.suffix,
|
||||||
dest.at(i).id);
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
}
|
}
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,7 @@ protected:
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||||
QGraphicsItem *parent = nullptr);
|
QGraphicsItem *parent = nullptr);
|
||||||
|
|
||||||
static void CreateDestination(Source typeCreation, quint32 &id, QVector<DestinationItem> &dest,
|
static void CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint, const QPointF &sPoint);
|
||||||
const QVector<quint32> &source, const QPointF &fPoint, const QPointF &sPoint,
|
|
||||||
const QString &suffix, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse);
|
|
||||||
|
|
||||||
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
const QPointF &secondPoint, const QString &suffix, VContainer *data);
|
||||||
|
|
|
@ -84,12 +84,19 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(QSharedPointer<DialogTool> dial
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogFlippingByAxis> dialogTool = dialog.objectCast<DialogFlippingByAxis>();
|
QSharedPointer<DialogFlippingByAxis> dialogTool = dialog.objectCast<DialogFlippingByAxis>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 originPointId = dialogTool->GetOriginPointId();
|
|
||||||
const AxisType axisType = dialogTool->GetAxisType();
|
VToolFlippingByAxisInitData initData;
|
||||||
const QString suffix = dialogTool->GetSuffix();
|
initData.originPointId = dialogTool->GetOriginPointId();
|
||||||
const QVector<quint32> source = dialogTool->GetObjects();
|
initData.axisType = dialogTool->GetAxisType();
|
||||||
VToolFlippingByAxis* operation = Create(0, originPointId, axisType, suffix, source, QVector<DestinationItem>(),
|
initData.suffix = dialogTool->GetSuffix();
|
||||||
scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.source = dialogTool->GetObjects();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolFlippingByAxis* operation = Create(initData);
|
||||||
if (operation != nullptr)
|
if (operation != nullptr)
|
||||||
{
|
{
|
||||||
operation->m_dialog = dialogTool;
|
operation->m_dialog = dialogTool;
|
||||||
|
@ -98,17 +105,13 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(QSharedPointer<DialogTool> dial
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolFlippingByAxis *VToolFlippingByAxis::Create(const quint32 _id, quint32 originPointId, AxisType axisType,
|
VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData initData)
|
||||||
const QString &suffix, const QVector<quint32> &source,
|
|
||||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const auto originPoint = *data->GeometricObject<VPointF>(originPointId);
|
const auto originPoint = *initData.data->GeometricObject<VPointF>(initData.originPointId);
|
||||||
const QPointF fPoint = static_cast<QPointF>(originPoint);
|
const QPointF fPoint = static_cast<QPointF>(originPoint);
|
||||||
|
|
||||||
QPointF sPoint;
|
QPointF sPoint;
|
||||||
if (axisType == AxisType::VerticalAxis)
|
if (initData.axisType == AxisType::VerticalAxis)
|
||||||
{
|
{
|
||||||
sPoint = QPointF(fPoint.x(), fPoint.y() + 100);
|
sPoint = QPointF(fPoint.x(), fPoint.y() + 100);
|
||||||
}
|
}
|
||||||
|
@ -117,23 +120,19 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(const quint32 _id, quint32 orig
|
||||||
sPoint = QPointF(fPoint.x() + 100, fPoint.y());
|
sPoint = QPointF(fPoint.x() + 100, fPoint.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<DestinationItem> dest = destination;
|
CreateDestination(initData, fPoint, sPoint);
|
||||||
|
|
||||||
quint32 id = _id;
|
if (initData.parse == Document::FullParse)
|
||||||
CreateDestination(typeCreation, id, dest, source, fPoint, sPoint, suffix, doc, data, parse);
|
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::FlippingByAxis, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::FlippingByAxis, initData.doc);
|
||||||
VToolFlippingByAxis *tool = new VToolFlippingByAxis(doc, data, id, originPointId, axisType, suffix, source,
|
VToolFlippingByAxis *tool = new VToolFlippingByAxis(initData);
|
||||||
dest, typeCreation);
|
initData.scene->addItem(tool);
|
||||||
scene->addItem(tool);
|
InitOperationToolConnections(initData.scene, tool);
|
||||||
InitOperationToolConnections(scene, tool);
|
VAbstractPattern::AddTool(initData.id, tool);
|
||||||
VAbstractPattern::AddTool(id, tool);
|
initData.doc->IncrementReferens(originPoint.getIdTool());
|
||||||
doc->IncrementReferens(originPoint.getIdTool());
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
for (int i = 0; i < source.size(); ++i)
|
|
||||||
{
|
{
|
||||||
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
|
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool());
|
||||||
}
|
}
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
@ -239,15 +238,13 @@ QString VToolFlippingByAxis::MakeToolTip() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolFlippingByAxis::VToolFlippingByAxis(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 originPointId,
|
VToolFlippingByAxis::VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent)
|
||||||
AxisType axisType, const QString &suffix,
|
: VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
initData.destination, parent),
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
m_originPointId(initData.originPointId),
|
||||||
: VAbstractFlipping(doc, data, id, suffix, source, destination, parent),
|
m_axisType(initData.axisType)
|
||||||
m_originPointId(originPointId),
|
|
||||||
m_axisType(axisType)
|
|
||||||
{
|
{
|
||||||
InitOperatedObjects();
|
InitOperatedObjects();
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,18 @@
|
||||||
|
|
||||||
#include "vabstractflipping.h"
|
#include "vabstractflipping.h"
|
||||||
|
|
||||||
|
struct VToolFlippingByAxisInitData : public VAbstractOperationInitData
|
||||||
|
{
|
||||||
|
VToolFlippingByAxisInitData()
|
||||||
|
: VAbstractOperationInitData(),
|
||||||
|
originPointId(NULL_ID),
|
||||||
|
axisType(AxisType::VerticalAxis)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 originPointId;
|
||||||
|
AxisType axisType;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolFlippingByAxis : public VAbstractFlipping
|
class VToolFlippingByAxis : public VAbstractFlipping
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -41,11 +53,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolFlippingByAxis* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolFlippingByAxis* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolFlippingByAxis* Create(const quint32 _id, quint32 originPointId, AxisType axisType,
|
static VToolFlippingByAxis* Create(VToolFlippingByAxisInitData initData);
|
||||||
const QString &suffix, const QVector<quint32> &source,
|
|
||||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
|
|
||||||
|
@ -72,10 +80,7 @@ private:
|
||||||
quint32 m_originPointId;
|
quint32 m_originPointId;
|
||||||
AxisType m_axisType;
|
AxisType m_axisType;
|
||||||
|
|
||||||
VToolFlippingByAxis(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 originPointId,
|
VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
AxisType axisType, const QString &suffix, const QVector<quint32> &source,
|
|
||||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
|
||||||
QGraphicsItem *parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLFLIPPINGBYAXIS_H
|
#endif // VTOOLFLIPPINGBYAXIS_H
|
||||||
|
|
|
@ -84,13 +84,19 @@ VToolFlippingByLine *VToolFlippingByLine::Create(QSharedPointer<DialogTool> dial
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogFlippingByLine> dialogTool = dialog.objectCast<DialogFlippingByLine>();
|
QSharedPointer<DialogFlippingByLine> dialogTool = dialog.objectCast<DialogFlippingByLine>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 firstLinePointId = dialogTool->GetFirstLinePointId();
|
|
||||||
const quint32 secondLinePointId = dialogTool->GetSecondLinePointId();
|
VToolFlippingByLineInitData initData;
|
||||||
const QString suffix = dialogTool->GetSuffix();
|
initData.firstLinePointId = dialogTool->GetFirstLinePointId();
|
||||||
const QVector<quint32> source = dialogTool->GetObjects();
|
initData.secondLinePointId = dialogTool->GetSecondLinePointId();
|
||||||
VToolFlippingByLine* operation = Create(0, firstLinePointId, secondLinePointId, suffix, source,
|
initData.suffix = dialogTool->GetSuffix();
|
||||||
QVector<DestinationItem>(), scene, doc, data, Document::FullParse,
|
initData.source = dialogTool->GetObjects();
|
||||||
Source::FromGui);
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolFlippingByLine* operation = Create(initData);
|
||||||
if (operation != nullptr)
|
if (operation != nullptr)
|
||||||
{
|
{
|
||||||
operation->m_dialog = dialogTool;
|
operation->m_dialog = dialogTool;
|
||||||
|
@ -99,36 +105,28 @@ VToolFlippingByLine *VToolFlippingByLine::Create(QSharedPointer<DialogTool> dial
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolFlippingByLine *VToolFlippingByLine::Create(const quint32 _id, quint32 firstLinePointId, quint32 secondLinePointId,
|
VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData initData)
|
||||||
const QString &suffix, const QVector<quint32> &source,
|
|
||||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const auto firstPoint = *data->GeometricObject<VPointF>(firstLinePointId);
|
const auto firstPoint = *initData.data->GeometricObject<VPointF>(initData.firstLinePointId);
|
||||||
const QPointF fPoint = static_cast<QPointF>(firstPoint);
|
const QPointF fPoint = static_cast<QPointF>(firstPoint);
|
||||||
|
|
||||||
const auto secondPoint = *data->GeometricObject<VPointF>(secondLinePointId);
|
const auto secondPoint = *initData.data->GeometricObject<VPointF>(initData.secondLinePointId);
|
||||||
const QPointF sPoint = static_cast<QPointF>(secondPoint);
|
const QPointF sPoint = static_cast<QPointF>(secondPoint);
|
||||||
|
|
||||||
QVector<DestinationItem> dest = destination;
|
CreateDestination(initData, fPoint, sPoint);
|
||||||
|
|
||||||
quint32 id = _id;
|
if (initData.parse == Document::FullParse)
|
||||||
CreateDestination(typeCreation, id, dest, source, fPoint, sPoint, suffix, doc, data, parse);
|
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::FlippingByLine, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::FlippingByLine, initData.doc);
|
||||||
VToolFlippingByLine *tool = new VToolFlippingByLine(doc, data, id, firstLinePointId, secondLinePointId, suffix,
|
VToolFlippingByLine *tool = new VToolFlippingByLine(initData);
|
||||||
source, dest, typeCreation);
|
initData.scene->addItem(tool);
|
||||||
scene->addItem(tool);
|
InitOperationToolConnections(initData.scene, tool);
|
||||||
InitOperationToolConnections(scene, tool);
|
VAbstractPattern::AddTool(initData.id, tool);
|
||||||
VAbstractPattern::AddTool(id, tool);
|
initData.doc->IncrementReferens(firstPoint.getIdTool());
|
||||||
doc->IncrementReferens(firstPoint.getIdTool());
|
initData.doc->IncrementReferens(secondPoint.getIdTool());
|
||||||
doc->IncrementReferens(secondPoint.getIdTool());
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
for (int i = 0; i < source.size(); ++i)
|
|
||||||
{
|
{
|
||||||
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
|
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool());
|
||||||
}
|
}
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
@ -228,14 +226,12 @@ QString VToolFlippingByLine::MakeToolTip() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolFlippingByLine::VToolFlippingByLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstLinePointId,
|
VToolFlippingByLine::VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent)
|
||||||
quint32 secondLinePointId, const QString &suffix,
|
: VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
initData.destination, parent),
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
m_firstLinePointId(initData.firstLinePointId),
|
||||||
: VAbstractFlipping(doc, data, id, suffix, source, destination, parent),
|
m_secondLinePointId(initData.secondLinePointId)
|
||||||
m_firstLinePointId(firstLinePointId),
|
|
||||||
m_secondLinePointId(secondLinePointId)
|
|
||||||
{
|
{
|
||||||
InitOperatedObjects();
|
InitOperatedObjects();
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,19 @@
|
||||||
|
|
||||||
#include "vabstractflipping.h"
|
#include "vabstractflipping.h"
|
||||||
|
|
||||||
|
struct VToolFlippingByLineInitData : public VAbstractOperationInitData
|
||||||
|
{
|
||||||
|
VToolFlippingByLineInitData()
|
||||||
|
: VAbstractOperationInitData(),
|
||||||
|
firstLinePointId(NULL_ID),
|
||||||
|
secondLinePointId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 firstLinePointId;
|
||||||
|
quint32 secondLinePointId;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class VToolFlippingByLine : public VAbstractFlipping
|
class VToolFlippingByLine : public VAbstractFlipping
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -41,11 +54,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolFlippingByLine* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolFlippingByLine* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolFlippingByLine* Create(const quint32 _id, quint32 firstLinePointId, quint32 secondLinePointId,
|
static VToolFlippingByLine* Create(VToolFlippingByLineInitData initData);
|
||||||
const QString &suffix, const QVector<quint32> &source,
|
|
||||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
|
|
||||||
|
@ -70,10 +79,7 @@ private:
|
||||||
quint32 m_firstLinePointId;
|
quint32 m_firstLinePointId;
|
||||||
quint32 m_secondLinePointId;
|
quint32 m_secondLinePointId;
|
||||||
|
|
||||||
VToolFlippingByLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstLinePointId,
|
VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
quint32 secondLinePointId, const QString &suffix, const QVector<quint32> &source,
|
|
||||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
|
||||||
QGraphicsItem *parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLFLIPPINGBYLINE_H
|
#endif // VTOOLFLIPPINGBYLINE_H
|
||||||
|
|
|
@ -85,8 +85,7 @@ void VAbstractOperation::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractOperation::ExtractData(const QDomElement &domElement, QVector<quint32> &source,
|
void VAbstractOperation::ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData)
|
||||||
QVector<DestinationItem> &destination)
|
|
||||||
{
|
{
|
||||||
const QDomNodeList nodeList = domElement.childNodes();
|
const QDomNodeList nodeList = domElement.childNodes();
|
||||||
for (qint32 i = 0; i < nodeList.size(); ++i)
|
for (qint32 i = 0; i < nodeList.size(); ++i)
|
||||||
|
@ -94,21 +93,21 @@ void VAbstractOperation::ExtractData(const QDomElement &domElement, QVector<quin
|
||||||
const QDomElement dataElement = nodeList.at(i).toElement();
|
const QDomElement dataElement = nodeList.at(i).toElement();
|
||||||
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
|
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
|
||||||
{
|
{
|
||||||
source.clear();
|
initData.source.clear();
|
||||||
const QDomNodeList srcList = dataElement.childNodes();
|
const QDomNodeList srcList = dataElement.childNodes();
|
||||||
for (qint32 j = 0; j < srcList.size(); ++j)
|
for (qint32 j = 0; j < srcList.size(); ++j)
|
||||||
{
|
{
|
||||||
const QDomElement element = srcList.at(j).toElement();
|
const QDomElement element = srcList.at(j).toElement();
|
||||||
if (not element.isNull())
|
if (not element.isNull())
|
||||||
{
|
{
|
||||||
source.append(VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR));
|
initData.source.append(VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
|
if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
|
||||||
{
|
{
|
||||||
destination.clear();
|
initData.destination.clear();
|
||||||
const QDomNodeList srcList = dataElement.childNodes();
|
const QDomNodeList srcList = dataElement.childNodes();
|
||||||
for (qint32 j = 0; j < srcList.size(); ++j)
|
for (qint32 j = 0; j < srcList.size(); ++j)
|
||||||
{
|
{
|
||||||
|
@ -119,7 +118,7 @@ void VAbstractOperation::ExtractData(const QDomElement &domElement, QVector<quin
|
||||||
d.id = VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
|
d.id = VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
|
||||||
d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
|
d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
|
||||||
d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
|
d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
|
||||||
destination.append(d);
|
initData.destination.append(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,20 @@ struct DestinationItem
|
||||||
qreal my;
|
qreal my;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct VAbstractOperationInitData : public VAbstractToolInitData
|
||||||
|
{
|
||||||
|
VAbstractOperationInitData()
|
||||||
|
: VAbstractToolInitData(),
|
||||||
|
suffix(),
|
||||||
|
source(),
|
||||||
|
destination()
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString suffix;
|
||||||
|
QVector<quint32> source;
|
||||||
|
QVector<DestinationItem> destination;
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME. I don't know how to use QGraphicsItem properly, so just took first available finished class.
|
// FIXME. I don't know how to use QGraphicsItem properly, so just took first available finished class.
|
||||||
// QGraphicsItem itself produce case where clicking on empty space produce call to QGraphicsItem.
|
// QGraphicsItem itself produce case where clicking on empty space produce call to QGraphicsItem.
|
||||||
// And i don't know how to fix it.
|
// And i don't know how to fix it.
|
||||||
|
@ -73,8 +87,7 @@ public:
|
||||||
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
static void ExtractData(const QDomElement &domElement, QVector<quint32> &source,
|
static void ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData);
|
||||||
QVector<DestinationItem> &destination);
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
|
|
@ -92,12 +92,19 @@ VToolMove *VToolMove::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsSce
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogMove> dialogTool = dialog.objectCast<DialogMove>();
|
QSharedPointer<DialogMove> dialogTool = dialog.objectCast<DialogMove>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
QString angle = dialogTool->GetAngle();
|
|
||||||
QString length = dialogTool->GetLength();
|
VToolMoveInitData initData;
|
||||||
const QString suffix = dialogTool->GetSuffix();
|
initData.formulaAngle = dialogTool->GetAngle();
|
||||||
const QVector<quint32> source = dialogTool->GetObjects();
|
initData.formulaLength = dialogTool->GetLength();
|
||||||
VToolMove* operation = Create(0, angle, length, suffix, source, QVector<DestinationItem>(), scene, doc, data,
|
initData.suffix = dialogTool->GetSuffix();
|
||||||
Document::FullParse, Source::FromGui);
|
initData.source = dialogTool->GetObjects();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolMove* operation = Create(initData);
|
||||||
if (operation != nullptr)
|
if (operation != nullptr)
|
||||||
{
|
{
|
||||||
operation->m_dialog = dialogTool;
|
operation->m_dialog = dialogTool;
|
||||||
|
@ -106,31 +113,24 @@ VToolMove *VToolMove::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsSce
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolMove *VToolMove::Create(quint32 _id, QString &formulaAngle, QString &formulaLength,
|
VToolMove *VToolMove::Create(VToolMoveInitData &initData)
|
||||||
const QString &suffix, const QVector<quint32> &source,
|
|
||||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
qreal calcAngle = 0;
|
qreal calcAngle = 0;
|
||||||
qreal calcLength = 0;
|
qreal calcLength = 0;
|
||||||
|
|
||||||
calcAngle = CheckFormula(_id, formulaAngle, data);
|
calcAngle = CheckFormula(initData.id, initData.formulaAngle, initData.data);
|
||||||
calcLength = qApp->toPixel(CheckFormula(_id, formulaLength, data));
|
calcLength = qApp->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data));
|
||||||
|
|
||||||
QVector<DestinationItem> dest = destination;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
|
|
||||||
quint32 id = _id;
|
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
dest.clear();// Try to avoid mistake, value must be empty
|
initData.destination.clear();// Try to avoid mistake, value must be empty
|
||||||
|
|
||||||
id = VContainer::getNextId();//Just reserve id for tool
|
initData.id = VContainer::getNextId();//Just reserve id for tool
|
||||||
|
|
||||||
for (int i = 0; i < source.size(); ++i)
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
{
|
{
|
||||||
const quint32 idObject = source.at(i);
|
const quint32 idObject = initData.source.at(i);
|
||||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||||
|
@ -140,27 +140,35 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
dest.append(CreatePoint(id, idObject, calcAngle, calcLength, suffix, data));
|
initData.destination.append(CreatePoint(initData.id, idObject, calcAngle, calcLength,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
dest.append(CreateArc<VArc>(id, idObject, calcAngle, calcLength, suffix, data));
|
initData.destination.append(CreateArc<VArc>(initData.id, idObject, calcAngle, calcLength,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
dest.append(CreateArc<VEllipticalArc>(id, idObject, calcAngle, calcLength, suffix, data));
|
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, idObject, calcAngle, calcLength,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
dest.append(CreateCurve<VSpline>(id, idObject, calcAngle, calcLength, suffix, data));
|
initData.destination.append(CreateCurve<VSpline>(initData.id, idObject, calcAngle, calcLength,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
dest.append(CreateCurveWithSegments<VSplinePath>(id, idObject, calcAngle, calcLength, suffix,
|
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, calcAngle,
|
||||||
data));
|
calcLength, initData.suffix,
|
||||||
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
dest.append(CreateCurve<VCubicBezier>(id, idObject, calcAngle, calcLength, suffix, data));
|
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, idObject, calcAngle, calcLength,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
dest.append(CreateCurveWithSegments<VCubicBezierPath>(id, idObject, calcAngle, calcLength, suffix,
|
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject,
|
||||||
data));
|
calcAngle, calcLength,
|
||||||
|
initData.suffix,
|
||||||
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
break;
|
break;
|
||||||
|
@ -170,10 +178,10 @@ QT_WARNING_POP
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < source.size(); ++i)
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
{
|
{
|
||||||
const quint32 idObject = source.at(i);
|
const quint32 idObject = initData.source.at(i);
|
||||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||||
|
@ -183,51 +191,58 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
UpdatePoint(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id, dest.at(i).mx,
|
{
|
||||||
dest.at(i).my);
|
const DestinationItem &item = initData.destination.at(i);
|
||||||
|
UpdatePoint(initData.id, idObject, calcAngle, calcLength, initData.suffix, initData.data, item.id,
|
||||||
|
item.mx, item.my);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
UpdateArc<VArc>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
|
UpdateArc<VArc>(initData.id, idObject, calcAngle, calcLength, initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
UpdateArc<VEllipticalArc>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
|
UpdateArc<VEllipticalArc>(initData.id, idObject, calcAngle, calcLength, initData.suffix,
|
||||||
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
UpdateCurve<VSpline>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
|
UpdateCurve<VSpline>(initData.id, idObject, calcAngle, calcLength, initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
UpdateCurveWithSegments<VSplinePath>(id, idObject, calcAngle, calcLength, suffix, data,
|
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, calcAngle, calcLength, initData.suffix,
|
||||||
dest.at(i).id);
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
UpdateCurve<VCubicBezier>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
|
UpdateCurve<VCubicBezier>(initData.id, idObject, calcAngle, calcLength, initData.suffix,
|
||||||
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
UpdateCurveWithSegments<VCubicBezierPath>(id, idObject, calcAngle, calcLength, suffix, data,
|
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, calcAngle, calcLength,
|
||||||
dest.at(i).id);
|
initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
}
|
}
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::Move, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Move, initData.doc);
|
||||||
VToolMove *tool = new VToolMove(doc, data, id, formulaAngle, formulaLength, suffix, source, dest,
|
VToolMove *tool = new VToolMove(initData);
|
||||||
typeCreation);
|
initData.scene->addItem(tool);
|
||||||
scene->addItem(tool);
|
InitOperationToolConnections(initData.scene, tool);
|
||||||
InitOperationToolConnections(scene, tool);
|
VAbstractPattern::AddTool(initData.id, tool);
|
||||||
VAbstractPattern::AddTool(id, tool);
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
for (int i = 0; i < source.size(); ++i)
|
|
||||||
{
|
{
|
||||||
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
|
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool());
|
||||||
}
|
}
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
@ -361,16 +376,14 @@ QString VToolMove::MakeToolTip() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolMove::VToolMove(VAbstractPattern *doc, VContainer *data, quint32 id,
|
VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent)
|
||||||
const QString &formulaAngle, const QString &formulaLength, const QString &suffix,
|
: VAbstractOperation(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
initData.destination, parent),
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
formulaAngle(initData.formulaAngle),
|
||||||
: VAbstractOperation(doc, data, id, suffix, source, destination, parent),
|
formulaLength(initData.formulaLength)
|
||||||
formulaAngle(formulaAngle),
|
|
||||||
formulaLength(formulaLength)
|
|
||||||
{
|
{
|
||||||
InitOperatedObjects();
|
InitOperatedObjects();
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -45,6 +45,18 @@
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
class VFormula;
|
class VFormula;
|
||||||
|
|
||||||
|
struct VToolMoveInitData : public VAbstractOperationInitData
|
||||||
|
{
|
||||||
|
VToolMoveInitData()
|
||||||
|
: VAbstractOperationInitData(),
|
||||||
|
formulaAngle(),
|
||||||
|
formulaLength()
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formulaAngle;
|
||||||
|
QString formulaLength;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolMove : public VAbstractOperation
|
class VToolMove : public VAbstractOperation
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -53,10 +65,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolMove* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolMove* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolMove* Create(quint32 _id, QString &formulaAngle, QString &formulaLength, const QString &suffix,
|
static VToolMove* Create(VToolMoveInitData &initData);
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
|
|
||||||
|
@ -83,10 +92,7 @@ private:
|
||||||
QString formulaAngle;
|
QString formulaAngle;
|
||||||
QString formulaLength;
|
QString formulaLength;
|
||||||
|
|
||||||
VToolMove(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &formulaAngle,
|
VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QString &formulaLength, const QString &suffix, const QVector<quint32> &source,
|
|
||||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
|
||||||
QGraphicsItem *parent = nullptr);
|
|
||||||
|
|
||||||
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
|
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
|
|
|
@ -80,16 +80,14 @@ template <class T> class QSharedPointer;
|
||||||
const QString VToolRotation::ToolType = QStringLiteral("rotation");
|
const QString VToolRotation::ToolType = QStringLiteral("rotation");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolRotation::VToolRotation(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 origPointId,
|
VToolRotation::VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent)
|
||||||
const QString &angle, const QString &suffix, const QVector<quint32> &source,
|
: VAbstractOperation(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
|
||||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
initData.destination, parent),
|
||||||
QGraphicsItem *parent)
|
origPointId(initData.origin),
|
||||||
: VAbstractOperation(doc, data, id, suffix, source, destination, parent),
|
formulaAngle(initData.angle)
|
||||||
origPointId(origPointId),
|
|
||||||
formulaAngle(angle)
|
|
||||||
{
|
{
|
||||||
InitOperatedObjects();
|
InitOperatedObjects();
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -110,12 +108,19 @@ VToolRotation *VToolRotation::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogRotation> dialogTool = dialog.objectCast<DialogRotation>();
|
QSharedPointer<DialogRotation> dialogTool = dialog.objectCast<DialogRotation>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 originPointId = dialogTool->GetOrigPointId();
|
|
||||||
QString angle = dialogTool->GetAngle();
|
VToolRotationInitData initData;
|
||||||
const QString suffix = dialogTool->GetSuffix();
|
initData.origin = dialogTool->GetOrigPointId();
|
||||||
const QVector<quint32> source = dialogTool->GetObjects();
|
initData.angle = dialogTool->GetAngle();
|
||||||
VToolRotation* operation = Create(0, originPointId, angle, suffix, source, QVector<DestinationItem>(),
|
initData.suffix = dialogTool->GetSuffix();
|
||||||
scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.source = dialogTool->GetObjects();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolRotation* operation = Create(initData);
|
||||||
if (operation != nullptr)
|
if (operation != nullptr)
|
||||||
{
|
{
|
||||||
operation->m_dialog = dialogTool;
|
operation->m_dialog = dialogTool;
|
||||||
|
@ -124,32 +129,25 @@ VToolRotation *VToolRotation::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolRotation *VToolRotation::Create(const quint32 _id, const quint32 &origin, QString &angle, const QString &suffix,
|
VToolRotation *VToolRotation::Create(VToolRotationInitData &initData)
|
||||||
const QVector<quint32> &source,
|
|
||||||
const QVector<DestinationItem> &destination,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
qreal calcAngle = 0;
|
qreal calcAngle = 0;
|
||||||
|
|
||||||
calcAngle = CheckFormula(_id, angle, data);
|
calcAngle = CheckFormula(initData.id, initData.angle, initData.data);
|
||||||
|
|
||||||
const auto originPoint = *data->GeometricObject<VPointF>(origin);
|
const auto originPoint = *initData.data->GeometricObject<VPointF>(initData.origin);
|
||||||
const QPointF oPoint = static_cast<QPointF>(originPoint);
|
const QPointF oPoint = static_cast<QPointF>(originPoint);
|
||||||
|
|
||||||
QVector<DestinationItem> dest = destination;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
|
|
||||||
quint32 id = _id;
|
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
dest.clear();// Try to avoid mistake, value must be empty
|
initData.destination.clear();// Try to avoid mistake, value must be empty
|
||||||
|
|
||||||
id = VContainer::getNextId();//Just reserve id for tool
|
initData.id = VContainer::getNextId();//Just reserve id for tool
|
||||||
|
|
||||||
for (int i = 0; i < source.size(); ++i)
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
{
|
{
|
||||||
const quint32 idObject = source.at(i);
|
const quint32 idObject = initData.source.at(i);
|
||||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||||
|
@ -159,26 +157,34 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
dest.append(CreatePoint(id, idObject, oPoint, calcAngle, suffix, data));
|
initData.destination.append(CreatePoint(initData.id, idObject, oPoint, calcAngle, initData.suffix,
|
||||||
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
dest.append(CreateArc<VArc>(id, idObject, oPoint, calcAngle, suffix, data));
|
initData.destination.append(CreateArc<VArc>(initData.id, idObject, oPoint, calcAngle,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
dest.append(CreateArc<VEllipticalArc>(id, idObject, oPoint, calcAngle, suffix, data));
|
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, idObject, oPoint, calcAngle,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
dest.append(CreateCurve<VSpline>(id, idObject, oPoint, calcAngle, suffix, data));
|
initData.destination.append(CreateCurve<VSpline>(initData.id, idObject, oPoint, calcAngle,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
dest.append(CreateCurveWithSegments<VSplinePath>(id, idObject, oPoint, calcAngle, suffix, data));
|
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, oPoint,
|
||||||
|
calcAngle, initData.suffix,
|
||||||
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
dest.append(CreateCurve<VCubicBezier>(id, idObject, oPoint, calcAngle, suffix, data));
|
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, idObject, oPoint, calcAngle,
|
||||||
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
dest.append(CreateCurveWithSegments<VCubicBezierPath>(id, idObject, oPoint, calcAngle, suffix,
|
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, oPoint,
|
||||||
data));
|
calcAngle, initData.suffix,
|
||||||
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
break;
|
break;
|
||||||
|
@ -188,10 +194,10 @@ QT_WARNING_POP
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < source.size(); ++i)
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
{
|
{
|
||||||
const quint32 idObject = source.at(i);
|
const quint32 idObject = initData.source.at(i);
|
||||||
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
|
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
|
||||||
|
|
||||||
// This check helps to find missed objects in the switch
|
// This check helps to find missed objects in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||||
|
@ -201,50 +207,58 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
UpdatePoint(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id, dest.at(i).mx,
|
{
|
||||||
dest.at(i).my);
|
const DestinationItem &item = initData.destination.at(i);
|
||||||
|
UpdatePoint(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
||||||
|
item.id, item.mx, item.my);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case GOType::Arc:
|
case GOType::Arc:
|
||||||
UpdateArc<VArc>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
UpdateArc<VArc>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::EllipticalArc:
|
case GOType::EllipticalArc:
|
||||||
UpdateArc<VEllipticalArc>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
UpdateArc<VEllipticalArc>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
UpdateCurve<VSpline>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
UpdateCurve<VSpline>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
UpdateCurveWithSegments<VSplinePath>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, oPoint, calcAngle, initData.suffix,
|
||||||
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
UpdateCurve<VCubicBezier>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
UpdateCurve<VCubicBezier>(initData.id, idObject, oPoint, calcAngle, initData.suffix, initData.data,
|
||||||
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
UpdateCurveWithSegments<VCubicBezierPath>(id, idObject, oPoint, calcAngle, suffix, data,
|
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, oPoint, calcAngle, initData.suffix,
|
||||||
dest.at(i).id);
|
initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
}
|
}
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::Rotation, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Rotation, initData.doc);
|
||||||
VToolRotation *tool = new VToolRotation(doc, data, id, origin, angle, suffix, source, dest, typeCreation);
|
VToolRotation *tool = new VToolRotation(initData);
|
||||||
scene->addItem(tool);
|
initData.scene->addItem(tool);
|
||||||
InitOperationToolConnections(scene, tool);
|
InitOperationToolConnections(initData.scene, tool);
|
||||||
VAbstractPattern::AddTool(id, tool);
|
VAbstractPattern::AddTool(initData.id, tool);
|
||||||
doc->IncrementReferens(originPoint.getIdTool());
|
initData.doc->IncrementReferens(originPoint.getIdTool());
|
||||||
for (int i = 0; i < source.size(); ++i)
|
for (int i = 0; i < initData.source.size(); ++i)
|
||||||
{
|
{
|
||||||
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
|
initData.doc->IncrementReferens(initData.data->GetGObject(initData.source.at(i))->getIdTool());
|
||||||
}
|
}
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,18 @@
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
class VFormula;
|
class VFormula;
|
||||||
|
|
||||||
|
struct VToolRotationInitData : public VAbstractOperationInitData
|
||||||
|
{
|
||||||
|
VToolRotationInitData()
|
||||||
|
: VAbstractOperationInitData(),
|
||||||
|
origin(NULL_ID),
|
||||||
|
angle()
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 origin;
|
||||||
|
QString angle;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolRotation : public VAbstractOperation
|
class VToolRotation : public VAbstractOperation
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -53,10 +65,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolRotation* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolRotation* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolRotation* Create(const quint32 _id, const quint32 &origin, QString &angle, const QString &suffix,
|
static VToolRotation* Create(VToolRotationInitData &initData);
|
||||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
|
|
||||||
|
@ -83,10 +92,7 @@ private:
|
||||||
quint32 origPointId;
|
quint32 origPointId;
|
||||||
QString formulaAngle;
|
QString formulaAngle;
|
||||||
|
|
||||||
VToolRotation(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 origPointId,
|
VToolRotation(const VToolRotationInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QString &angle, const QString &suffix, const QVector<quint32> &source,
|
|
||||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
|
||||||
QGraphicsItem *parent = nullptr);
|
|
||||||
|
|
||||||
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
const QString &suffix, VContainer *data);
|
const QString &suffix, VContainer *data);
|
||||||
|
|
|
@ -54,6 +54,18 @@
|
||||||
class VControlPointSpline;
|
class VControlPointSpline;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VAbstractSplineInitData : public VAbstractToolInitData
|
||||||
|
{
|
||||||
|
VAbstractSplineInitData()
|
||||||
|
: VAbstractToolInitData(),
|
||||||
|
color(ColorBlack),
|
||||||
|
penStyle(TypeLineLine)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString color;
|
||||||
|
QString penStyle;
|
||||||
|
};
|
||||||
|
|
||||||
class VAbstractSpline:public VDrawTool, public QGraphicsPathItem
|
class VAbstractSpline:public VDrawTool, public QGraphicsPathItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -61,21 +61,16 @@ const QString VToolArc::ToolType = QStringLiteral("simple");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolArc constuctor.
|
* @brief VToolArc constuctor.
|
||||||
* @param doc dom document container
|
* @param initData init data
|
||||||
* @param data container with variables
|
|
||||||
* @param id object id in container
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object
|
|
||||||
*/
|
*/
|
||||||
VToolArc::VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolArc::VToolArc(const VToolArcInitData &initData, QGraphicsItem *parent)
|
||||||
QGraphicsItem *parent)
|
: VAbstractSpline(initData.doc, initData.data, initData.id, parent)
|
||||||
: VAbstractSpline(doc, data, id, parent)
|
|
||||||
{
|
{
|
||||||
sceneType = SceneObject::Arc;
|
sceneType = SceneObject::Arc;
|
||||||
|
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -110,14 +105,21 @@ VToolArc* VToolArc::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogArc> dialogTool = dialog.objectCast<DialogArc>();
|
QSharedPointer<DialogArc> dialogTool = dialog.objectCast<DialogArc>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 center = dialogTool->GetCenter();
|
|
||||||
QString radius = dialogTool->GetRadius();
|
VToolArcInitData initData;
|
||||||
QString f1 = dialogTool->GetF1();
|
initData.center = dialogTool->GetCenter();
|
||||||
QString f2 = dialogTool->GetF2();
|
initData.radius = dialogTool->GetRadius();
|
||||||
const QString color = dialogTool->GetColor();
|
initData.f1 = dialogTool->GetF1();
|
||||||
const QString penStyle = dialogTool->GetPenStyle();
|
initData.f2 = dialogTool->GetF2();
|
||||||
VToolArc* point = Create(0, center, radius, f1, f2, color, penStyle, scene, doc, data, Document::FullParse,
|
initData.color = dialogTool->GetColor();
|
||||||
Source::FromGui);
|
initData.penStyle = dialogTool->GetPenStyle();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolArc* point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -128,56 +130,45 @@ VToolArc* VToolArc::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool form GUI.
|
* @brief Create help create tool form GUI.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param center id arc center point.
|
|
||||||
* @param radius arc radius.
|
|
||||||
* @param f1 start angle of arc.
|
|
||||||
* @param f2 end angle of arc.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
*/
|
*/
|
||||||
VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2,
|
VToolArc* VToolArc::Create(VToolArcInitData &initData)
|
||||||
const QString &color, const QString &penStyle, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
|
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
|
||||||
|
|
||||||
calcRadius = qApp->toPixel(CheckFormula(_id, radius, data));
|
calcRadius = qApp->toPixel(CheckFormula(initData.id, initData.radius, initData.data));
|
||||||
|
|
||||||
calcF1 = CheckFormula(_id, f1, data);
|
calcF1 = CheckFormula(initData.id, initData.f1, initData.data);
|
||||||
calcF2 = CheckFormula(_id, f2, data);
|
calcF2 = CheckFormula(initData.id, initData.f2, initData.data);
|
||||||
|
|
||||||
const VPointF c = *data->GeometricObject<VPointF>(center);
|
const VPointF c = *initData.data->GeometricObject<VPointF>(initData.center);
|
||||||
VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 );
|
VArc *arc = new VArc(c, calcRadius, initData.radius, calcF1, initData.f1, calcF2, initData.f2 );
|
||||||
arc->SetColor(color);
|
arc->SetColor(initData.color);
|
||||||
arc->SetPenStyle(penStyle);
|
arc->SetPenStyle(initData.penStyle);
|
||||||
quint32 id = _id;
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(arc);
|
initData.id = initData.data->AddGObject(arc);
|
||||||
data->AddArc(data->GeometricObject<VArc>(id), id);
|
initData.data->AddArc(initData.data->GeometricObject<VArc>(initData.id), initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, arc);
|
initData.data->UpdateGObject(initData.id, arc);
|
||||||
data->AddArc(data->GeometricObject<VArc>(id), id);
|
initData.data->AddArc(initData.data->GeometricObject<VArc>(initData.id), initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::Arc, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Arc, initData.doc);
|
||||||
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
|
VToolArc *toolArc = new VToolArc(initData);
|
||||||
scene->addItem(toolArc);
|
initData.scene->addItem(toolArc);
|
||||||
InitArcToolConnections(scene, toolArc);
|
InitArcToolConnections(initData.scene, toolArc);
|
||||||
VAbstractPattern::AddTool(id, toolArc);
|
VAbstractPattern::AddTool(initData.id, toolArc);
|
||||||
doc->IncrementReferens(c.getIdTool());
|
initData.doc->IncrementReferens(c.getIdTool());
|
||||||
return toolArc;
|
return toolArc;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -43,6 +43,22 @@
|
||||||
class VFormula;
|
class VFormula;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolArcInitData : public VAbstractSplineInitData
|
||||||
|
{
|
||||||
|
VToolArcInitData()
|
||||||
|
: VAbstractSplineInitData(),
|
||||||
|
center(NULL_ID),
|
||||||
|
radius("0"),
|
||||||
|
f1("0"),
|
||||||
|
f2("0")
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 center;
|
||||||
|
QString radius;
|
||||||
|
QString f1;
|
||||||
|
QString f2;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolArc class tool for creation arc.
|
* @brief The VToolArc class tool for creation arc.
|
||||||
*/
|
*/
|
||||||
|
@ -53,9 +69,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolArc* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolArc* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolArc* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2,
|
static VToolArc* Create(VToolArcInitData &initData);
|
||||||
const QString &color, const QString &penStyle, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
@ -88,8 +102,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolArc)
|
Q_DISABLE_COPY(VToolArc)
|
||||||
|
|
||||||
VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolArc(const VToolArcInitData &initData, QGraphicsItem * parent = nullptr);
|
||||||
QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLARC_H
|
#endif // VTOOLARC_H
|
||||||
|
|
|
@ -59,15 +59,14 @@
|
||||||
const QString VToolArcWithLength::ToolType = QStringLiteral("arcWithLength");
|
const QString VToolArcWithLength::ToolType = QStringLiteral("arcWithLength");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolArcWithLength::VToolArcWithLength(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolArcWithLength::VToolArcWithLength(const VToolArcWithLengthInitData &initData, QGraphicsItem *parent)
|
||||||
QGraphicsItem *parent)
|
:VAbstractSpline(initData.doc, initData.data, initData.id, parent)
|
||||||
:VAbstractSpline(doc, data, id, parent)
|
|
||||||
{
|
{
|
||||||
sceneType = SceneObject::Arc;
|
sceneType = SceneObject::Arc;
|
||||||
|
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -92,14 +91,21 @@ VToolArcWithLength *VToolArcWithLength::Create(QSharedPointer<DialogTool> dialog
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogArcWithLength> dialogTool = dialog.objectCast<DialogArcWithLength>();
|
QSharedPointer<DialogArcWithLength> dialogTool = dialog.objectCast<DialogArcWithLength>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 center = dialogTool->GetCenter();
|
|
||||||
QString radius = dialogTool->GetRadius();
|
VToolArcWithLengthInitData initData;
|
||||||
QString f1 = dialogTool->GetF1();
|
initData.center = dialogTool->GetCenter();
|
||||||
QString length = dialogTool->GetLength();
|
initData.radius = dialogTool->GetRadius();
|
||||||
const QString color = dialogTool->GetColor();
|
initData.f1 = dialogTool->GetF1();
|
||||||
const QString penStyle = dialogTool->GetPenStyle();
|
initData.length = dialogTool->GetLength();
|
||||||
VToolArcWithLength* point = Create(0, center, radius, f1, length, color, penStyle, scene, doc, data,
|
initData.color = dialogTool->GetColor();
|
||||||
Document::FullParse, Source::FromGui);
|
initData.penStyle = dialogTool->GetPenStyle();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolArcWithLength* point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -108,45 +114,42 @@ VToolArcWithLength *VToolArcWithLength::Create(QSharedPointer<DialogTool> dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1,
|
VToolArcWithLength *VToolArcWithLength::Create(VToolArcWithLengthInitData &initData)
|
||||||
QString &length, const QString &color, const QString &penStyle,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
qreal calcRadius = 0, calcF1 = 0, calcLength = 0;
|
qreal calcRadius = 0, calcF1 = 0, calcLength = 0;
|
||||||
|
|
||||||
calcRadius = qApp->toPixel(CheckFormula(_id, radius, data));
|
calcRadius = qApp->toPixel(CheckFormula(initData.id, initData.radius, initData.data));
|
||||||
calcLength = qApp->toPixel(CheckFormula(_id, length, data));
|
calcLength = qApp->toPixel(CheckFormula(initData.id, initData.length, initData.data));
|
||||||
calcF1 = CheckFormula(_id, f1, data);
|
calcF1 = CheckFormula(initData.id, initData.f1, initData.data);
|
||||||
|
|
||||||
const VPointF c = *data->GeometricObject<VPointF>(center);
|
const VPointF c = *initData.data->GeometricObject<VPointF>(initData.center);
|
||||||
VArc *arc = new VArc(calcLength, length, c, calcRadius, radius, calcF1, f1);
|
VArc *arc = new VArc(calcLength, initData.length, c, calcRadius, initData.radius, calcF1, initData.f1);
|
||||||
arc->SetColor(color);
|
arc->SetColor(initData.color);
|
||||||
arc->SetPenStyle(penStyle);
|
arc->SetPenStyle(initData.penStyle);
|
||||||
quint32 id = _id;
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(arc);
|
initData.id = initData.data->AddGObject(arc);
|
||||||
data->AddArc(data->GeometricObject<VArc>(id), id);
|
initData.data->AddArc(initData.data->GeometricObject<VArc>(initData.id), initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, arc);
|
initData.data->UpdateGObject(initData.id, arc);
|
||||||
data->AddArc(data->GeometricObject<VArc>(id), id);
|
initData.data->AddArc(initData.data->GeometricObject<VArc>(initData.id), initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::ArcWithLength, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::ArcWithLength, initData.doc);
|
||||||
VToolArcWithLength *toolArc = new VToolArcWithLength(doc, data, id, typeCreation);
|
VToolArcWithLength *toolArc = new VToolArcWithLength(initData);
|
||||||
scene->addItem(toolArc);
|
initData.scene->addItem(toolArc);
|
||||||
InitArcToolConnections(scene, toolArc);
|
InitArcToolConnections(initData.scene, toolArc);
|
||||||
VAbstractPattern::AddTool(id, toolArc);
|
VAbstractPattern::AddTool(initData.id, toolArc);
|
||||||
doc->IncrementReferens(c.getIdTool());
|
initData.doc->IncrementReferens(c.getIdTool());
|
||||||
return toolArc;
|
return toolArc;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -43,6 +43,22 @@
|
||||||
class VFormula;
|
class VFormula;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolArcWithLengthInitData : public VAbstractSplineInitData
|
||||||
|
{
|
||||||
|
VToolArcWithLengthInitData()
|
||||||
|
: VAbstractSplineInitData(),
|
||||||
|
center(NULL_ID),
|
||||||
|
radius("0"),
|
||||||
|
f1("0"),
|
||||||
|
length("0")
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 center;
|
||||||
|
QString radius;
|
||||||
|
QString f1;
|
||||||
|
QString length;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolArcWithLength : public VAbstractSpline
|
class VToolArcWithLength : public VAbstractSpline
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -50,10 +66,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolArcWithLength* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolArcWithLength* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolArcWithLength* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1,
|
static VToolArcWithLength* Create(VToolArcWithLengthInitData &initData);
|
||||||
QString &length, const QString &color, const QString &penStyle,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
@ -86,8 +99,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolArcWithLength)
|
Q_DISABLE_COPY(VToolArcWithLength)
|
||||||
|
|
||||||
VToolArcWithLength(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolArcWithLength(const VToolArcWithLengthInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLARCWITHLENGTH_H
|
#endif // VTOOLARCWITHLENGTH_H
|
||||||
|
|
|
@ -57,15 +57,14 @@
|
||||||
const QString VToolCubicBezier::ToolType = QStringLiteral("cubicBezier");
|
const QString VToolCubicBezier::ToolType = QStringLiteral("cubicBezier");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolCubicBezier::VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quint32 id,
|
VToolCubicBezier::VToolCubicBezier(const VToolCubicBezierInitData &initData, QGraphicsItem *parent)
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
:VAbstractSpline(initData.doc, initData.data, initData.id, parent)
|
||||||
:VAbstractSpline(doc, data, id, parent)
|
|
||||||
{
|
{
|
||||||
sceneType = SceneObject::Spline;
|
sceneType = SceneObject::Spline;
|
||||||
|
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -88,11 +87,17 @@ VToolCubicBezier *VToolCubicBezier::Create(QSharedPointer<DialogTool> dialog, VM
|
||||||
QSharedPointer<DialogCubicBezier> dialogTool = dialog.objectCast<DialogCubicBezier>();
|
QSharedPointer<DialogCubicBezier> dialogTool = dialog.objectCast<DialogCubicBezier>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
|
|
||||||
VCubicBezier *spline = new VCubicBezier(dialogTool->GetSpline());
|
VToolCubicBezierInitData initData;
|
||||||
spline->SetColor(dialogTool->GetColor());
|
initData.scene = scene;
|
||||||
spline->SetPenStyle(dialogTool->GetPenStyle());
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
initData.spline = new VCubicBezier(dialogTool->GetSpline());
|
||||||
|
initData.spline->SetColor(dialogTool->GetColor());
|
||||||
|
initData.spline->SetPenStyle(dialogTool->GetPenStyle());
|
||||||
|
|
||||||
auto spl = Create(0, spline, scene, doc, data, Document::FullParse, Source::FromGui);
|
auto spl = Create(initData);
|
||||||
|
|
||||||
if (spl != nullptr)
|
if (spl != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -102,37 +107,34 @@ VToolCubicBezier *VToolCubicBezier::Create(QSharedPointer<DialogTool> dialog, VM
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolCubicBezier *VToolCubicBezier::Create(const quint32 _id, VCubicBezier *spline, VMainGraphicsScene *scene,
|
VToolCubicBezier *VToolCubicBezier::Create(VToolCubicBezierInitData initData)
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
quint32 id = _id;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = data->AddGObject(spline);
|
initData.id = initData.data->AddGObject(initData.spline);
|
||||||
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
|
initData.data->AddSpline(initData.data->GeometricObject<VAbstractBezier>(initData.id), initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, spline);
|
initData.data->UpdateGObject(initData.id, initData.spline);
|
||||||
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
|
initData.data->AddSpline(initData.data->GeometricObject<VAbstractBezier>(initData.id), initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::CubicBezier, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::CubicBezier, initData.doc);
|
||||||
auto _spl = new VToolCubicBezier(doc, data, id, typeCreation);
|
auto _spl = new VToolCubicBezier(initData);
|
||||||
scene->addItem(_spl);
|
initData.scene->addItem(_spl);
|
||||||
InitSplineToolConnections(scene, _spl);
|
InitSplineToolConnections(initData.scene, _spl);
|
||||||
VAbstractPattern::AddTool(id, _spl);
|
VAbstractPattern::AddTool(initData.id, _spl);
|
||||||
doc->IncrementReferens(spline->GetP1().getIdTool());
|
initData.doc->IncrementReferens(initData.spline->GetP1().getIdTool());
|
||||||
doc->IncrementReferens(spline->GetP1().getIdTool());
|
initData.doc->IncrementReferens(initData.spline->GetP1().getIdTool());
|
||||||
doc->IncrementReferens(spline->GetP1().getIdTool());
|
initData.doc->IncrementReferens(initData.spline->GetP1().getIdTool());
|
||||||
doc->IncrementReferens(spline->GetP4().getIdTool());
|
initData.doc->IncrementReferens(initData.spline->GetP4().getIdTool());
|
||||||
return _spl;
|
return _spl;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -43,6 +43,16 @@
|
||||||
class VCubicBezier;
|
class VCubicBezier;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolCubicBezierInitData : public VAbstractToolInitData
|
||||||
|
{
|
||||||
|
VToolCubicBezierInitData()
|
||||||
|
: VAbstractToolInitData(),
|
||||||
|
spline(nullptr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
VCubicBezier *spline;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolCubicBezier : public VAbstractSpline
|
class VToolCubicBezier : public VAbstractSpline
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -51,9 +61,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolCubicBezier *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolCubicBezier *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolCubicBezier *Create(const quint32 _id, VCubicBezier *spline, VMainGraphicsScene *scene,
|
static VToolCubicBezier *Create(VToolCubicBezierInitData initData);
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::CubicBezier)};
|
enum { Type = UserType + static_cast<int>(Tool::CubicBezier)};
|
||||||
|
@ -78,8 +86,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolCubicBezier)
|
Q_DISABLE_COPY(VToolCubicBezier)
|
||||||
|
|
||||||
VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolCubicBezier(const VToolCubicBezierInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
QGraphicsItem * parent = nullptr);
|
|
||||||
|
|
||||||
void SetSplineAttributes(QDomElement &domElement, const VCubicBezier &spl);
|
void SetSplineAttributes(QDomElement &domElement, const VCubicBezier &spl);
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,15 +59,14 @@
|
||||||
const QString VToolCubicBezierPath::ToolType = QStringLiteral("cubicBezierPath");
|
const QString VToolCubicBezierPath::ToolType = QStringLiteral("cubicBezierPath");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolCubicBezierPath::VToolCubicBezierPath(VAbstractPattern *doc, VContainer *data, quint32 id,
|
VToolCubicBezierPath::VToolCubicBezierPath(const VToolCubicBezierPathInitData &initData, QGraphicsItem *parent)
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
: VAbstractSpline(initData.doc, initData.data, initData.id, parent)
|
||||||
: VAbstractSpline(doc, data, id, parent)
|
|
||||||
{
|
{
|
||||||
sceneType = SceneObject::SplinePath;
|
sceneType = SceneObject::SplinePath;
|
||||||
|
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -89,17 +88,25 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(QSharedPointer<DialogTool> di
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogCubicBezierPath> dialogTool = dialog.objectCast<DialogCubicBezierPath>();
|
QSharedPointer<DialogCubicBezierPath> dialogTool = dialog.objectCast<DialogCubicBezierPath>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
auto path = new VCubicBezierPath(dialogTool->GetPath());
|
|
||||||
|
VToolCubicBezierPathInitData initData;
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
initData.path = new VCubicBezierPath(dialogTool->GetPath());
|
||||||
const QString color = dialogTool->GetColor();
|
const QString color = dialogTool->GetColor();
|
||||||
const QString penStyle = dialogTool->GetPenStyle();
|
const QString penStyle = dialogTool->GetPenStyle();
|
||||||
for (qint32 i = 0; i < path->CountPoints(); ++i)
|
for (qint32 i = 0; i < initData.path->CountPoints(); ++i)
|
||||||
{
|
{
|
||||||
doc->IncrementReferens((*path)[i].getIdTool());
|
doc->IncrementReferens((*initData.path)[i].getIdTool());
|
||||||
}
|
}
|
||||||
path->SetColor(color);
|
initData.path->SetColor(color);
|
||||||
path->SetPenStyle(penStyle);
|
initData.path->SetPenStyle(penStyle);
|
||||||
|
|
||||||
VToolCubicBezierPath* spl = Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui);
|
VToolCubicBezierPath* spl = Create(initData);
|
||||||
if (spl != nullptr)
|
if (spl != nullptr)
|
||||||
{
|
{
|
||||||
spl->m_dialog = dialogTool;
|
spl->m_dialog = dialogTool;
|
||||||
|
@ -108,33 +115,32 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(QSharedPointer<DialogTool> di
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolCubicBezierPath *VToolCubicBezierPath::Create(const quint32 _id, VCubicBezierPath *path, VMainGraphicsScene *scene,
|
VToolCubicBezierPath *VToolCubicBezierPath::Create(VToolCubicBezierPathInitData initData)
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
quint32 id = _id;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = data->AddGObject(path);
|
initData.id = initData.data->AddGObject(initData.path);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
|
initData.data->AddCurveWithSegments(initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.id),
|
||||||
|
initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, path);
|
initData.data->UpdateGObject(initData.id, initData.path);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
|
initData.data->AddCurveWithSegments(initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.id),
|
||||||
if (parse != Document::FullParse)
|
initData.id);
|
||||||
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::CubicBezierPath, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::CubicBezierPath, initData.doc);
|
||||||
VToolCubicBezierPath *spl = new VToolCubicBezierPath(doc, data, id, typeCreation);
|
VToolCubicBezierPath *spl = new VToolCubicBezierPath(initData);
|
||||||
scene->addItem(spl);
|
initData.scene->addItem(spl);
|
||||||
InitSplinePathToolConnections(scene, spl);
|
InitSplinePathToolConnections(initData.scene, spl);
|
||||||
VAbstractPattern::AddTool(id, spl);
|
VAbstractPattern::AddTool(initData.id, spl);
|
||||||
return spl;
|
return spl;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -43,6 +43,16 @@
|
||||||
class VCubicBezierPath;
|
class VCubicBezierPath;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolCubicBezierPathInitData : public VAbstractToolInitData
|
||||||
|
{
|
||||||
|
VToolCubicBezierPathInitData()
|
||||||
|
: VAbstractToolInitData(),
|
||||||
|
path(nullptr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
VCubicBezierPath *path;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolCubicBezierPath:public VAbstractSpline
|
class VToolCubicBezierPath:public VAbstractSpline
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -51,9 +61,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolCubicBezierPath *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolCubicBezierPath *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolCubicBezierPath *Create(const quint32 _id, VCubicBezierPath *path, VMainGraphicsScene *scene,
|
static VToolCubicBezierPath *Create(VToolCubicBezierPathInitData initData);
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
static void UpdatePathPoints(VAbstractPattern *doc, QDomElement &element, const VCubicBezierPath &path);
|
static void UpdatePathPoints(VAbstractPattern *doc, QDomElement &element, const VCubicBezierPath &path);
|
||||||
|
@ -75,8 +83,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolCubicBezierPath)
|
Q_DISABLE_COPY(VToolCubicBezierPath)
|
||||||
|
|
||||||
VToolCubicBezierPath(VAbstractPattern *doc, VContainer *data, quint32 id,
|
VToolCubicBezierPath(const VToolCubicBezierPathInitData &initData, QGraphicsItem * parent = nullptr);
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
|
|
||||||
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VPointF &splPoint);
|
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VPointF &splPoint);
|
||||||
void SetSplinePathAttributes(QDomElement &domElement, const VCubicBezierPath &path);
|
void SetSplinePathAttributes(QDomElement &domElement, const VCubicBezierPath &path);
|
||||||
|
|
|
@ -61,21 +61,17 @@ const QString VToolEllipticalArc::ToolType = QStringLiteral("simple");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolEllipticalArc constuctor.
|
* @brief VToolEllipticalArc constuctor.
|
||||||
* @param doc dom document container
|
* @param initData init data
|
||||||
* @param data container with variables
|
|
||||||
* @param id object id in container
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object
|
* @param parent parent object
|
||||||
*/
|
*/
|
||||||
VToolEllipticalArc::VToolEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolEllipticalArc::VToolEllipticalArc(const VToolEllipticalArcInitData &initData, QGraphicsItem *parent)
|
||||||
QGraphicsItem *parent)
|
:VAbstractSpline(initData.doc, initData.data, initData.id, parent)
|
||||||
:VAbstractSpline(doc, data, id, parent)
|
|
||||||
{
|
{
|
||||||
sceneType = SceneObject::ElArc;
|
sceneType = SceneObject::ElArc;
|
||||||
|
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -113,16 +109,22 @@ VToolEllipticalArc* VToolEllipticalArc::Create(QSharedPointer<DialogTool> dialog
|
||||||
QSharedPointer<DialogEllipticalArc> dialogTool = dialog.objectCast<DialogEllipticalArc>();
|
QSharedPointer<DialogEllipticalArc> dialogTool = dialog.objectCast<DialogEllipticalArc>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
|
|
||||||
const quint32 center = dialogTool->GetCenter();
|
VToolEllipticalArcInitData initData;
|
||||||
QString radius1 = dialogTool->GetRadius1();
|
initData.center = dialogTool->GetCenter();
|
||||||
QString radius2 = dialogTool->GetRadius2();
|
initData.radius1 = dialogTool->GetRadius1();
|
||||||
QString f1 = dialogTool->GetF1();
|
initData.radius2 = dialogTool->GetRadius2();
|
||||||
QString f2 = dialogTool->GetF2();
|
initData.f1 = dialogTool->GetF1();
|
||||||
QString rotationAngle = dialogTool->GetRotationAngle();
|
initData.f2 = dialogTool->GetF2();
|
||||||
const QString color = dialogTool->GetColor();
|
initData.rotationAngle = dialogTool->GetRotationAngle();
|
||||||
const QString penStyle = dialogTool->GetPenStyle();
|
initData.color = dialogTool->GetColor();
|
||||||
VToolEllipticalArc* point = Create(0, center, radius1, radius2, f1, f2, rotationAngle, color, penStyle, scene, doc,
|
initData.penStyle = dialogTool->GetPenStyle();
|
||||||
data, Document::FullParse, Source::FromGui);
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolEllipticalArc* point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -134,63 +136,49 @@ VToolEllipticalArc* VToolEllipticalArc::Create(QSharedPointer<DialogTool> dialog
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool form GUI.
|
* @brief Create help create tool form GUI.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param center id elliptical arc center point.
|
|
||||||
* @param radius1 elliptical arc radius1.
|
|
||||||
* @param radius2 elliptical arc radius2.
|
|
||||||
* @param f1 start angle of elliptical arc.
|
|
||||||
* @param f2 end angle of elliptical arc.
|
|
||||||
* @param rotationAngle rotation angle of elliptical arc.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
*/
|
*/
|
||||||
VToolEllipticalArc* VToolEllipticalArc::Create(const quint32 _id, const quint32 ¢er, QString &radius1,
|
VToolEllipticalArc* VToolEllipticalArc::Create(VToolEllipticalArcInitData &initData)
|
||||||
QString &radius2, QString &f1, QString &f2, QString &rotationAngle,
|
|
||||||
const QString &color, const QString &penStyle, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
qreal calcRadius1 = 0, calcRadius2 = 0, calcF1 = 0, calcF2 = 0, calcRotationAngle = 0;
|
qreal calcRadius1 = 0, calcRadius2 = 0, calcF1 = 0, calcF2 = 0, calcRotationAngle = 0;
|
||||||
|
|
||||||
calcRadius1 = qApp->toPixel(CheckFormula(_id, radius1, data));
|
calcRadius1 = qApp->toPixel(CheckFormula(initData.id, initData.radius1, initData.data));
|
||||||
calcRadius2 = qApp->toPixel(CheckFormula(_id, radius2, data));
|
calcRadius2 = qApp->toPixel(CheckFormula(initData.id, initData.radius2, initData.data));
|
||||||
|
|
||||||
calcF1 = CheckFormula(_id, f1, data);
|
calcF1 = CheckFormula(initData.id, initData.f1, initData.data);
|
||||||
calcF2 = CheckFormula(_id, f2, data);
|
calcF2 = CheckFormula(initData.id, initData.f2, initData.data);
|
||||||
calcRotationAngle = CheckFormula(_id, rotationAngle, data);
|
calcRotationAngle = CheckFormula(initData.id, initData.rotationAngle, initData.data);
|
||||||
|
|
||||||
const VPointF c = *data->GeometricObject<VPointF>(center);
|
const VPointF c = *initData.data->GeometricObject<VPointF>(initData.center);
|
||||||
VEllipticalArc *elArc = new VEllipticalArc(c, calcRadius1, calcRadius2, radius1, radius2, calcF1, f1, calcF2, f2,
|
VEllipticalArc *elArc = new VEllipticalArc(c, calcRadius1, calcRadius2, initData.radius1, initData.radius2, calcF1,
|
||||||
calcRotationAngle, rotationAngle);
|
initData.f1, calcF2, initData.f2, calcRotationAngle,
|
||||||
elArc->SetColor(color);
|
initData.rotationAngle);
|
||||||
elArc->SetPenStyle(penStyle);
|
elArc->SetColor(initData.color);
|
||||||
quint32 id = _id;
|
elArc->SetPenStyle(initData.penStyle);
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(elArc);
|
initData.id = initData.data->AddGObject(elArc);
|
||||||
data->AddArc(data->GeometricObject<VEllipticalArc>(id), id);
|
initData.data->AddArc(initData.data->GeometricObject<VEllipticalArc>(initData.id), initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, elArc);
|
initData.data->UpdateGObject(initData.id, elArc);
|
||||||
data->AddArc(data->GeometricObject<VEllipticalArc>(id), id);
|
initData.data->AddArc(initData.data->GeometricObject<VEllipticalArc>(initData.id), initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::EllipticalArc, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::EllipticalArc, initData.doc);
|
||||||
VToolEllipticalArc *toolEllipticalArc = new VToolEllipticalArc(doc, data, id, typeCreation);
|
VToolEllipticalArc *toolEllipticalArc = new VToolEllipticalArc(initData);
|
||||||
scene->addItem(toolEllipticalArc);
|
initData.scene->addItem(toolEllipticalArc);
|
||||||
InitElArcToolConnections(scene, toolEllipticalArc);
|
InitElArcToolConnections(initData.scene, toolEllipticalArc);
|
||||||
VAbstractPattern::AddTool(id, toolEllipticalArc);
|
VAbstractPattern::AddTool(initData.id, toolEllipticalArc);
|
||||||
doc->IncrementReferens(c.getIdTool());
|
initData.doc->IncrementReferens(c.getIdTool());
|
||||||
return toolEllipticalArc;
|
return toolEllipticalArc;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -43,6 +43,26 @@
|
||||||
class VFormula;
|
class VFormula;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolEllipticalArcInitData : public VAbstractSplineInitData
|
||||||
|
{
|
||||||
|
VToolEllipticalArcInitData()
|
||||||
|
: VAbstractSplineInitData(),
|
||||||
|
center(NULL_ID),
|
||||||
|
radius1("0"),
|
||||||
|
radius2("0"),
|
||||||
|
f1("0"),
|
||||||
|
f2("0"),
|
||||||
|
rotationAngle("0")
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 center;
|
||||||
|
QString radius1;
|
||||||
|
QString radius2;
|
||||||
|
QString f1;
|
||||||
|
QString f2;
|
||||||
|
QString rotationAngle;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolEllipticalArc class tool for creation elliptical arc.
|
* @brief The VToolEllipticalArc class tool for creation elliptical arc.
|
||||||
*/
|
*/
|
||||||
|
@ -53,11 +73,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolEllipticalArc* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolEllipticalArc* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolEllipticalArc* Create(const quint32 _id, const quint32 ¢er, QString &radius1, QString &radius2,
|
static VToolEllipticalArc* Create(VToolEllipticalArcInitData &initData);
|
||||||
QString &f1, QString &f2, QString &rotationAngle, const QString &color,
|
|
||||||
const QString &penStyle, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
|
||||||
VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::EllipticalArc)};
|
enum { Type = UserType + static_cast<int>(Tool::EllipticalArc)};
|
||||||
|
@ -95,8 +111,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolEllipticalArc)
|
Q_DISABLE_COPY(VToolEllipticalArc)
|
||||||
VToolEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolEllipticalArc(const VToolEllipticalArcInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLELLIPTICALARC_H
|
#endif // VTOOLELLIPTICALARC_H
|
||||||
|
|
|
@ -74,22 +74,19 @@ const QString VToolSpline::OldToolType = QStringLiteral("simple");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolSpline constructor.
|
* @brief VToolSpline constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolSpline::VToolSpline(VToolSplineInitData initData, QGraphicsItem *parent)
|
||||||
QGraphicsItem *parent)
|
: VAbstractSpline(initData.doc, initData.data, initData.id, parent),
|
||||||
:VAbstractSpline(doc, data, id, parent), oldPosition()
|
oldPosition()
|
||||||
{
|
{
|
||||||
sceneType = SceneObject::Spline;
|
sceneType = SceneObject::Spline;
|
||||||
|
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
|
||||||
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(initData.id);
|
||||||
|
|
||||||
const bool freeAngle1 = qmu::QmuTokenParser::IsSingle(spl->GetStartAngleFormula());
|
const bool freeAngle1 = qmu::QmuTokenParser::IsSingle(spl->GetStartAngleFormula());
|
||||||
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl->GetC1LengthFormula());
|
const bool freeLength1 = qmu::QmuTokenParser::IsSingle(spl->GetC1LengthFormula());
|
||||||
|
@ -119,7 +116,7 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co
|
||||||
|
|
||||||
ShowHandles(false);
|
ShowHandles(false);
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -153,11 +150,18 @@ VToolSpline* VToolSpline::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
||||||
QSharedPointer<DialogSpline> dialogTool = dialog.objectCast<DialogSpline>();
|
QSharedPointer<DialogSpline> dialogTool = dialog.objectCast<DialogSpline>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
|
|
||||||
|
VToolSplineInitData initData;
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
VSpline *spline = new VSpline(dialogTool->GetSpline());
|
VSpline *spline = new VSpline(dialogTool->GetSpline());
|
||||||
spline->SetColor(dialogTool->GetColor());
|
spline->SetColor(dialogTool->GetColor());
|
||||||
spline->SetPenStyle(dialogTool->GetPenStyle());
|
spline->SetPenStyle(dialogTool->GetPenStyle());
|
||||||
|
|
||||||
auto spl = Create(0, spline, scene, doc, data, Document::FullParse, Source::FromGui);
|
auto spl = Create(initData, spline);
|
||||||
|
|
||||||
if (spl != nullptr)
|
if (spl != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -169,74 +173,64 @@ VToolSpline* VToolSpline::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param spline spline.
|
* @param spline spline.
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @return the created tool
|
* @return the created tool
|
||||||
*/
|
*/
|
||||||
VToolSpline* VToolSpline::Create(const quint32 _id, VSpline *spline, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
VToolSpline* VToolSpline::Create(VToolSplineInitData &initData, VSpline *spline)
|
||||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
quint32 id = _id;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = data->AddGObject(spline);
|
initData.id = initData.data->AddGObject(spline);
|
||||||
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
|
initData.data->AddSpline(initData.data->GeometricObject<VAbstractBezier>(initData.id), initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, spline);
|
initData.data->UpdateGObject(initData.id, spline);
|
||||||
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
|
initData.data->AddSpline(initData.data->GeometricObject<VAbstractBezier>(initData.id), initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::Spline, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Spline, initData.doc);
|
||||||
auto _spl = new VToolSpline(doc, data, id, typeCreation);
|
auto _spl = new VToolSpline(initData);
|
||||||
scene->addItem(_spl);
|
initData.scene->addItem(_spl);
|
||||||
InitSplineToolConnections(scene, _spl);
|
InitSplineToolConnections(initData.scene, _spl);
|
||||||
VAbstractPattern::AddTool(id, _spl);
|
VAbstractPattern::AddTool(initData.id, _spl);
|
||||||
doc->IncrementReferens(spline->GetP1().getIdTool());
|
initData.doc->IncrementReferens(spline->GetP1().getIdTool());
|
||||||
doc->IncrementReferens(spline->GetP4().getIdTool());
|
initData.doc->IncrementReferens(spline->GetP4().getIdTool());
|
||||||
return _spl;
|
return _spl;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolSpline *VToolSpline::Create(const quint32 _id, quint32 point1, quint32 point4, QString &a1, QString &a2,
|
VToolSpline *VToolSpline::Create(VToolSplineInitData &initData)
|
||||||
QString &l1, QString &l2, quint32 duplicate, const QString &color,
|
|
||||||
const QString &penStyle, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
|
||||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const qreal calcAngle1 = CheckFormula(_id, a1, data);
|
const qreal calcAngle1 = CheckFormula(initData.id, initData.a1, initData.data);
|
||||||
const qreal calcAngle2 = CheckFormula(_id, a2, data);
|
const qreal calcAngle2 = CheckFormula(initData.id, initData.a2, initData.data);
|
||||||
|
|
||||||
const qreal calcLength1 = qApp->toPixel(CheckFormula(_id, l1, data));
|
const qreal calcLength1 = qApp->toPixel(CheckFormula(initData.id, initData.l1, initData.data));
|
||||||
const qreal calcLength2 = qApp->toPixel(CheckFormula(_id, l2, data));
|
const qreal calcLength2 = qApp->toPixel(CheckFormula(initData.id, initData.l2, initData.data));
|
||||||
|
|
||||||
auto p1 = data->GeometricObject<VPointF>(point1);
|
auto p1 = initData.data->GeometricObject<VPointF>(initData.point1);
|
||||||
auto p4 = data->GeometricObject<VPointF>(point4);
|
auto p4 = initData.data->GeometricObject<VPointF>(initData.point4);
|
||||||
|
|
||||||
auto spline = new VSpline(*p1, *p4, calcAngle1, a1, calcAngle2, a2, calcLength1, l1, calcLength2, l2);
|
auto spline = new VSpline(*p1, *p4, calcAngle1, initData.a1, calcAngle2, initData.a2, calcLength1, initData.l1,
|
||||||
if (duplicate > 0)
|
calcLength2, initData.l2);
|
||||||
|
if (initData.duplicate > 0)
|
||||||
{
|
{
|
||||||
spline->SetDuplicate(duplicate);
|
spline->SetDuplicate(initData.duplicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
spline->SetColor(color);
|
spline->SetColor(initData.color);
|
||||||
spline->SetPenStyle(penStyle);
|
spline->SetPenStyle(initData.penStyle);
|
||||||
|
|
||||||
return VToolSpline::Create(_id, spline, scene, doc, data, parse, typeCreation);
|
return VToolSpline::Create(initData, spline);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -44,6 +44,28 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolSplineInitData : public VAbstractSplineInitData
|
||||||
|
{
|
||||||
|
VToolSplineInitData()
|
||||||
|
: VAbstractSplineInitData(),
|
||||||
|
point1(NULL_ID),
|
||||||
|
point4(NULL_ID),
|
||||||
|
a1(),
|
||||||
|
a2(),
|
||||||
|
l1(),
|
||||||
|
l2(),
|
||||||
|
duplicate(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 point1;
|
||||||
|
quint32 point4;
|
||||||
|
QString a1;
|
||||||
|
QString a2;
|
||||||
|
QString l1;
|
||||||
|
QString l2;
|
||||||
|
quint32 duplicate;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolSpline class tool for creation spline. I mean bezier curve.
|
* @brief The VToolSpline class tool for creation spline. I mean bezier curve.
|
||||||
*/
|
*/
|
||||||
|
@ -55,13 +77,8 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolSpline *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolSpline *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolSpline *Create(const quint32 _id, VSpline *spline,
|
static VToolSpline *Create(VToolSplineInitData &initData, VSpline *spline);
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
static VToolSpline *Create(VToolSplineInitData &initData);
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static VToolSpline *Create(const quint32 _id, quint32 point1, quint32 point4, QString &a1, QString &a2, QString &l1,
|
|
||||||
QString &l2, quint32 duplicate, const QString &color, const QString &penStyle,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
static const QString OldToolType;
|
static const QString OldToolType;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
@ -92,8 +109,7 @@ private:
|
||||||
Q_DISABLE_COPY(VToolSpline)
|
Q_DISABLE_COPY(VToolSpline)
|
||||||
QPointF oldPosition;
|
QPointF oldPosition;
|
||||||
|
|
||||||
VToolSpline (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolSpline (VToolSplineInitData initData, QGraphicsItem *parent = nullptr );
|
||||||
QGraphicsItem * parent = nullptr );
|
|
||||||
|
|
||||||
bool IsMovable() const;
|
bool IsMovable() const;
|
||||||
void SetSplineAttributes(QDomElement &domElement, const VSpline &spl);
|
void SetSplineAttributes(QDomElement &domElement, const VSpline &spl);
|
||||||
|
|
|
@ -79,15 +79,11 @@ const QString VToolSplinePath::OldToolType = QStringLiteral("path");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolSplinePath constructor.
|
* @brief VToolSplinePath constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolSplinePath::VToolSplinePath(const VToolSplinePathInitData &initData, QGraphicsItem *parent)
|
||||||
QGraphicsItem *parent)
|
: VAbstractSpline(initData.doc, initData.data, initData.id, parent),
|
||||||
: VAbstractSpline(doc, data, id, parent),
|
|
||||||
oldPosition(),
|
oldPosition(),
|
||||||
splIndex(-1)
|
splIndex(-1)
|
||||||
{
|
{
|
||||||
|
@ -96,7 +92,7 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
|
||||||
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(id);
|
const QSharedPointer<VSplinePath> splPath = initData.data->GeometricObject<VSplinePath>(initData.id);
|
||||||
for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i)
|
for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i)
|
||||||
{
|
{
|
||||||
const VSpline spl = splPath->GetSpline(i);
|
const VSpline spl = splPath->GetSpline(i);
|
||||||
|
@ -128,7 +124,7 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
|
||||||
|
|
||||||
ShowHandles(false);
|
ShowHandles(false);
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -160,6 +156,14 @@ VToolSplinePath* VToolSplinePath::Create(QSharedPointer<DialogTool> dialog, VMai
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogSplinePath> dialogTool = dialog.objectCast<DialogSplinePath>();
|
QSharedPointer<DialogSplinePath> dialogTool = dialog.objectCast<DialogSplinePath>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
|
|
||||||
|
VToolSplinePathInitData initData;
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
VSplinePath *path = new VSplinePath(dialogTool->GetPath());
|
VSplinePath *path = new VSplinePath(dialogTool->GetPath());
|
||||||
for (qint32 i = 0; i < path->CountPoints(); ++i)
|
for (qint32 i = 0; i < path->CountPoints(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -169,7 +173,7 @@ VToolSplinePath* VToolSplinePath::Create(QSharedPointer<DialogTool> dialog, VMai
|
||||||
path->SetColor(dialogTool->GetColor());
|
path->SetColor(dialogTool->GetColor());
|
||||||
path->SetPenStyle(dialogTool->GetPenStyle());
|
path->SetPenStyle(dialogTool->GetPenStyle());
|
||||||
|
|
||||||
VToolSplinePath* spl = Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui);
|
VToolSplinePath* spl = Create(initData, path);
|
||||||
if (spl != nullptr)
|
if (spl != nullptr)
|
||||||
{
|
{
|
||||||
spl->m_dialog = dialogTool;
|
spl->m_dialog = dialogTool;
|
||||||
|
@ -180,79 +184,69 @@ VToolSplinePath* VToolSplinePath::Create(QSharedPointer<DialogTool> dialog, VMai
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param path spline path.
|
* @param path spline path.
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
* @param typeCreation way we create this tool.
|
||||||
*/
|
*/
|
||||||
VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene,
|
VToolSplinePath* VToolSplinePath::Create(VToolSplinePathInitData &initData, VSplinePath *path)
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
quint32 id = _id;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = data->AddGObject(path);
|
initData.id = initData.data->AddGObject(path);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
|
initData.data->AddCurveWithSegments(initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.id),
|
||||||
|
initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, path);
|
initData.data->UpdateGObject(initData.id, path);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
|
initData.data->AddCurveWithSegments(initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.id),
|
||||||
if (parse != Document::FullParse)
|
initData.id);
|
||||||
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::SplinePath, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::SplinePath, initData.doc);
|
||||||
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation);
|
VToolSplinePath *spl = new VToolSplinePath(initData);
|
||||||
scene->addItem(spl);
|
initData.scene->addItem(spl);
|
||||||
InitSplinePathToolConnections(scene, spl);
|
InitSplinePathToolConnections(initData.scene, spl);
|
||||||
VAbstractPattern::AddTool(id, spl);
|
VAbstractPattern::AddTool(initData.id, spl);
|
||||||
return spl;
|
return spl;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolSplinePath *VToolSplinePath::Create(const quint32 _id, const QVector<quint32> &points, QVector<QString> &a1,
|
VToolSplinePath *VToolSplinePath::Create(VToolSplinePathInitData &initData)
|
||||||
QVector<QString> &a2, QVector<QString> &l1, QVector<QString> &l2,
|
|
||||||
const QString &color, const QString &penStyle, quint32 duplicate,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
auto path = new VSplinePath();
|
auto path = new VSplinePath();
|
||||||
|
|
||||||
if (duplicate > 0)
|
if (initData.duplicate > 0)
|
||||||
{
|
{
|
||||||
path->SetDuplicate(duplicate);
|
path->SetDuplicate(initData.duplicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < points.size(); ++i)
|
for (int i = 0; i < initData.points.size(); ++i)
|
||||||
{
|
{
|
||||||
const qreal calcAngle1 = CheckFormula(_id, a1[i], data);
|
const qreal calcAngle1 = CheckFormula(initData.id, initData.a1[i], initData.data);
|
||||||
const qreal calcAngle2 = CheckFormula(_id, a2[i], data);
|
const qreal calcAngle2 = CheckFormula(initData.id, initData.a2[i], initData.data);
|
||||||
|
|
||||||
const qreal calcLength1 = qApp->toPixel(CheckFormula(_id, l1[i], data));
|
const qreal calcLength1 = qApp->toPixel(CheckFormula(initData.id, initData.l1[i], initData.data));
|
||||||
const qreal calcLength2 = qApp->toPixel(CheckFormula(_id, l2[i], data));
|
const qreal calcLength2 = qApp->toPixel(CheckFormula(initData.id, initData.l2[i], initData.data));
|
||||||
|
|
||||||
const auto p = *data->GeometricObject<VPointF>(points.at(i));
|
const auto p = *initData.data->GeometricObject<VPointF>(initData.points.at(i));
|
||||||
|
|
||||||
path->append(VSplinePoint(p, calcAngle1, a1.at(i), calcAngle2, a2.at(i), calcLength1, l1.at(i), calcLength2,
|
path->append(VSplinePoint(p, calcAngle1, initData.a1.at(i), calcAngle2, initData.a2.at(i), calcLength1,
|
||||||
l2.at(i)));
|
initData.l1.at(i), calcLength2, initData.l2.at(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
path->SetColor(color);
|
path->SetColor(initData.color);
|
||||||
path->SetPenStyle(penStyle);
|
path->SetPenStyle(initData.penStyle);
|
||||||
|
|
||||||
return VToolSplinePath::Create(_id, path, scene, doc, data, parse, typeCreation);
|
return VToolSplinePath::Create(initData, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -46,6 +46,26 @@
|
||||||
class VSplinePath;
|
class VSplinePath;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolSplinePathInitData : public VAbstractSplineInitData
|
||||||
|
{
|
||||||
|
VToolSplinePathInitData()
|
||||||
|
: VAbstractSplineInitData(),
|
||||||
|
points(),
|
||||||
|
a1(),
|
||||||
|
a2(),
|
||||||
|
l1(),
|
||||||
|
l2(),
|
||||||
|
duplicate(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QVector<quint32> points;
|
||||||
|
QVector<QString> a1;
|
||||||
|
QVector<QString> a2;
|
||||||
|
QVector<QString> l1;
|
||||||
|
QVector<QString> l2;
|
||||||
|
quint32 duplicate;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolSplinePath class tool for creation spline path.
|
* @brief The VToolSplinePath class tool for creation spline path.
|
||||||
*/
|
*/
|
||||||
|
@ -57,14 +77,8 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolSplinePath *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolSplinePath *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolSplinePath *Create(const quint32 _id, VSplinePath *path,
|
static VToolSplinePath *Create(VToolSplinePathInitData &initData, VSplinePath *path);
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
static VToolSplinePath *Create(VToolSplinePathInitData &initData);
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static VToolSplinePath *Create(const quint32 _id, const QVector<quint32> &points, QVector<QString> &a1,
|
|
||||||
QVector<QString> &a2, QVector<QString> &l1, QVector<QString> &l2,
|
|
||||||
const QString &color, const QString &penStyle, quint32 duplicate,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
static const QString OldToolType;
|
static const QString OldToolType;
|
||||||
static void UpdatePathPoints(VAbstractPattern *doc, QDomElement &element, const VSplinePath &path);
|
static void UpdatePathPoints(VAbstractPattern *doc, QDomElement &element, const VSplinePath &path);
|
||||||
|
@ -108,8 +122,7 @@ private:
|
||||||
QPointF oldPosition;
|
QPointF oldPosition;
|
||||||
int splIndex;
|
int splIndex;
|
||||||
|
|
||||||
VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolSplinePath(const VToolSplinePathInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
QGraphicsItem *parent = nullptr);
|
|
||||||
|
|
||||||
bool IsMovable(int index) const;
|
bool IsMovable(int index) const;
|
||||||
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);
|
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);
|
||||||
|
|
|
@ -55,26 +55,15 @@ template <class T> class QSharedPointer;
|
||||||
const QString VToolTrueDarts::ToolType = QStringLiteral("trueDarts");
|
const QString VToolTrueDarts::ToolType = QStringLiteral("trueDarts");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolTrueDarts::VToolTrueDarts(VAbstractPattern *doc,
|
VToolTrueDarts::VToolTrueDarts(const VToolTrueDartsInitData &initData, QGraphicsItem *parent)
|
||||||
VContainer *data,
|
:VToolDoublePoint(initData.doc, initData.data, initData.id, initData.p1id, initData.p2id, parent),
|
||||||
const quint32 &id,
|
baseLineP1Id (initData.baseLineP1Id),
|
||||||
const quint32 &p1id,
|
baseLineP2Id(initData.baseLineP2Id),
|
||||||
const quint32 &p2id,
|
dartP1Id(initData.dartP1Id),
|
||||||
const quint32 &baseLineP1Id,
|
dartP2Id(initData.dartP2Id),
|
||||||
const quint32 &baseLineP2Id,
|
dartP3Id(initData.dartP3Id)
|
||||||
const quint32 &dartP1Id,
|
|
||||||
const quint32 &dartP2Id,
|
|
||||||
const quint32 &dartP3Id,
|
|
||||||
const Source &typeCreation,
|
|
||||||
QGraphicsItem *parent)
|
|
||||||
:VToolDoublePoint(doc, data, id, p1id, p2id, parent),
|
|
||||||
baseLineP1Id (baseLineP1Id),
|
|
||||||
baseLineP2Id(baseLineP2Id),
|
|
||||||
dartP1Id(dartP1Id),
|
|
||||||
dartP2Id(dartP2Id),
|
|
||||||
dartP3Id(dartP3Id)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -128,17 +117,21 @@ VToolTrueDarts *VToolTrueDarts::Create(QSharedPointer<DialogTool> dialog, VMainG
|
||||||
QSharedPointer<DialogTrueDarts> dialogTool = dialog.objectCast<DialogTrueDarts>();
|
QSharedPointer<DialogTrueDarts> dialogTool = dialog.objectCast<DialogTrueDarts>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
|
|
||||||
const QString point1Name = dialogTool->GetFirstNewDartPointName();
|
VToolTrueDartsInitData initData;
|
||||||
const QString point2Name = dialogTool->GetSecondNewDartPointName();
|
initData.name1 = dialogTool->GetFirstNewDartPointName();
|
||||||
const quint32 baseLineP1Id = dialogTool->GetFirstBasePointId();
|
initData.name2 = dialogTool->GetSecondNewDartPointName();
|
||||||
const quint32 baseLineP2Id = dialogTool->GetSecondBasePointId();
|
initData.baseLineP1Id = dialogTool->GetFirstBasePointId();
|
||||||
const quint32 dartP1Id = dialogTool->GetFirstDartPointId();
|
initData.baseLineP2Id = dialogTool->GetSecondBasePointId();
|
||||||
const quint32 dartP2Id = dialogTool->GetSecondDartPointId();
|
initData.dartP1Id = dialogTool->GetFirstDartPointId();
|
||||||
const quint32 dartP3Id = dialogTool->GetThirdDartPointId();
|
initData.dartP2Id = dialogTool->GetSecondDartPointId();
|
||||||
|
initData.dartP3Id = dialogTool->GetThirdDartPointId();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
VToolTrueDarts *point = Create(0, 0, 0, baseLineP1Id, baseLineP2Id, dartP1Id, dartP2Id, dartP3Id,
|
VToolTrueDarts *point = Create(initData);
|
||||||
point1Name, 5, 10, point2Name, 5, 10, scene, doc, data, Document::FullParse,
|
|
||||||
Source::FromGui);
|
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -147,61 +140,52 @@ VToolTrueDarts *VToolTrueDarts::Create(QSharedPointer<DialogTool> dialog, VMainG
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolTrueDarts *VToolTrueDarts::Create(quint32 _id,
|
VToolTrueDarts *VToolTrueDarts::Create(VToolTrueDartsInitData initData)
|
||||||
const quint32 &_p1id, const quint32 &_p2id,
|
|
||||||
const quint32 &baseLineP1Id,
|
|
||||||
const quint32 &baseLineP2Id,
|
|
||||||
const quint32 &dartP1Id,
|
|
||||||
const quint32 &dartP2Id,
|
|
||||||
const quint32 &dartP3Id,
|
|
||||||
const QString &point1Name, const qreal &mx1, const qreal &my1,
|
|
||||||
const QString &point2Name, const qreal &mx2, const qreal &my2,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> baseLineP1 = data->GeometricObject<VPointF>(baseLineP1Id);
|
const QSharedPointer<VPointF> baseLineP1 = initData.data->GeometricObject<VPointF>(initData.baseLineP1Id);
|
||||||
const QSharedPointer<VPointF> baseLineP2 = data->GeometricObject<VPointF>(baseLineP2Id);
|
const QSharedPointer<VPointF> baseLineP2 = initData.data->GeometricObject<VPointF>(initData.baseLineP2Id);
|
||||||
const QSharedPointer<VPointF> dartP1 = data->GeometricObject<VPointF>(dartP1Id);
|
const QSharedPointer<VPointF> dartP1 = initData.data->GeometricObject<VPointF>(initData.dartP1Id);
|
||||||
const QSharedPointer<VPointF> dartP2 = data->GeometricObject<VPointF>(dartP2Id);
|
const QSharedPointer<VPointF> dartP2 = initData.data->GeometricObject<VPointF>(initData.dartP2Id);
|
||||||
const QSharedPointer<VPointF> dartP3 = data->GeometricObject<VPointF>(dartP3Id);
|
const QSharedPointer<VPointF> dartP3 = initData.data->GeometricObject<VPointF>(initData.dartP3Id);
|
||||||
|
|
||||||
QPointF fPoint1;
|
QPointF fPoint1;
|
||||||
QPointF fPoint2;
|
QPointF fPoint2;
|
||||||
VToolTrueDarts::FindPoint(static_cast<QPointF>(*baseLineP1), static_cast<QPointF>(*baseLineP2),
|
VToolTrueDarts::FindPoint(static_cast<QPointF>(*baseLineP1), static_cast<QPointF>(*baseLineP2),
|
||||||
static_cast<QPointF>(*dartP1), static_cast<QPointF>(*dartP2),
|
static_cast<QPointF>(*dartP1), static_cast<QPointF>(*dartP2),
|
||||||
static_cast<QPointF>(*dartP3), fPoint1, fPoint2);
|
static_cast<QPointF>(*dartP3), fPoint1, fPoint2);
|
||||||
quint32 id = _id;
|
|
||||||
quint32 p1id = _p1id;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
quint32 p2id = _p2id;
|
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = VContainer::getNextId();//Just reserve id for tool
|
initData.id = VContainer::getNextId();//Just reserve id for tool
|
||||||
p1id = data->AddGObject(new VPointF(fPoint1, point1Name, mx1, my1, id));
|
initData.p1id = initData.data->AddGObject(new VPointF(fPoint1, initData.name1, initData.mx1, initData.my1,
|
||||||
p2id = data->AddGObject(new VPointF(fPoint2, point2Name, mx2, my2, id));
|
initData.id));
|
||||||
|
initData.p2id = initData.data->AddGObject(new VPointF(fPoint2, initData.name2, initData.mx2, initData.my2,
|
||||||
|
initData.id));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(p1id, new VPointF(fPoint1, point1Name, mx1, my1, id));
|
initData.data->UpdateGObject(initData.p1id, new VPointF(fPoint1, initData.name1, initData.mx1, initData.my1,
|
||||||
data->UpdateGObject(p2id, new VPointF(fPoint2, point2Name, mx2, my2, id));
|
initData.id));
|
||||||
if (parse != Document::FullParse)
|
initData.data->UpdateGObject(initData.p2id, new VPointF(fPoint2, initData.name2, initData.mx2, initData.my2,
|
||||||
|
initData.id));
|
||||||
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::TrueDarts, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::TrueDarts, initData.doc);
|
||||||
VToolTrueDarts *points = new VToolTrueDarts(doc, data, id, p1id, p2id, baseLineP1Id, baseLineP2Id,
|
VToolTrueDarts *points = new VToolTrueDarts(initData);
|
||||||
dartP1Id, dartP2Id, dartP3Id, typeCreation);
|
initData.scene->addItem(points);
|
||||||
scene->addItem(points);
|
InitToolConnections(initData.scene, points);
|
||||||
InitToolConnections(scene, points);
|
VAbstractPattern::AddTool(initData.id, points);
|
||||||
VAbstractPattern::AddTool(id, points);
|
initData.doc->IncrementReferens(baseLineP1->getIdTool());
|
||||||
doc->IncrementReferens(baseLineP1->getIdTool());
|
initData.doc->IncrementReferens(baseLineP2->getIdTool());
|
||||||
doc->IncrementReferens(baseLineP2->getIdTool());
|
initData.doc->IncrementReferens(dartP1->getIdTool());
|
||||||
doc->IncrementReferens(dartP1->getIdTool());
|
initData.doc->IncrementReferens(dartP2->getIdTool());
|
||||||
doc->IncrementReferens(dartP2->getIdTool());
|
initData.doc->IncrementReferens(dartP3->getIdTool());
|
||||||
doc->IncrementReferens(dartP3->getIdTool());
|
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -44,6 +44,40 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolTrueDartsInitData : public VAbstractToolInitData
|
||||||
|
{
|
||||||
|
VToolTrueDartsInitData()
|
||||||
|
: VAbstractToolInitData(),
|
||||||
|
p1id(NULL_ID),
|
||||||
|
p2id(NULL_ID),
|
||||||
|
baseLineP1Id(NULL_ID),
|
||||||
|
baseLineP2Id(NULL_ID),
|
||||||
|
dartP1Id(NULL_ID),
|
||||||
|
dartP2Id(NULL_ID),
|
||||||
|
dartP3Id(NULL_ID),
|
||||||
|
name1(),
|
||||||
|
mx1(10),
|
||||||
|
my1(15),
|
||||||
|
name2(),
|
||||||
|
mx2(10),
|
||||||
|
my2(15)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 p1id;
|
||||||
|
quint32 p2id;
|
||||||
|
quint32 baseLineP1Id;
|
||||||
|
quint32 baseLineP2Id;
|
||||||
|
quint32 dartP1Id;
|
||||||
|
quint32 dartP2Id;
|
||||||
|
quint32 dartP3Id;
|
||||||
|
QString name1;
|
||||||
|
qreal mx1;
|
||||||
|
qreal my1;
|
||||||
|
QString name2;
|
||||||
|
qreal mx2;
|
||||||
|
qreal my2;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolTrueDarts : public VToolDoublePoint
|
class VToolTrueDarts : public VToolDoublePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -53,17 +87,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolTrueDarts* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolTrueDarts* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolTrueDarts* Create(quint32 _id,
|
static VToolTrueDarts* Create(VToolTrueDartsInitData initData);
|
||||||
const quint32 &_p1id, const quint32 &_p2id,
|
|
||||||
const quint32 &baseLineP1Id,
|
|
||||||
const quint32 &baseLineP2Id,
|
|
||||||
const quint32 &dartP1Id,
|
|
||||||
const quint32 &dartP2Id,
|
|
||||||
const quint32 &dartP3Id,
|
|
||||||
const QString &point1Name, const qreal &mx1, const qreal &my1,
|
|
||||||
const QString &point2Name, const qreal &mx2, const qreal &my2,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::TrueDarts)};
|
enum { Type = UserType + static_cast<int>(Tool::TrueDarts)};
|
||||||
|
@ -108,18 +132,7 @@ private:
|
||||||
quint32 dartP2Id;
|
quint32 dartP2Id;
|
||||||
quint32 dartP3Id;
|
quint32 dartP3Id;
|
||||||
|
|
||||||
VToolTrueDarts(VAbstractPattern *doc,
|
VToolTrueDarts(const VToolTrueDartsInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
VContainer *data,
|
|
||||||
const quint32 &id,
|
|
||||||
const quint32 &p1id,
|
|
||||||
const quint32 &p2id,
|
|
||||||
const quint32 &baseLineP1Id,
|
|
||||||
const quint32 &baseLineP2Id,
|
|
||||||
const quint32 &dartP1Id,
|
|
||||||
const quint32 &dartP2Id,
|
|
||||||
const quint32 &dartP3Id,
|
|
||||||
const Source &typeCreation,
|
|
||||||
QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLTRUEDARTS_H
|
#endif // VTOOLTRUEDARTS_H
|
||||||
|
|
|
@ -59,19 +59,13 @@ const QString VToolCutArc::ToolType = QStringLiteral("cutArc");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolCutArc constructor.
|
* @brief VToolCutArc constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param formula string with formula length first arc.
|
|
||||||
* @param arcId id arc in data container.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolCutArc::VToolCutArc(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
VToolCutArc::VToolCutArc(const VToolCutArcInitData &initData, QGraphicsItem * parent)
|
||||||
const quint32 &arcId, const Source &typeCreation, QGraphicsItem * parent)
|
:VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.arcId, parent)
|
||||||
:VToolCut(doc, data, id, formula, arcId, parent)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -103,11 +97,18 @@ VToolCutArc* VToolCutArc::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogCutArc> dialogTool = dialog.objectCast<DialogCutArc>();
|
QSharedPointer<DialogCutArc> dialogTool = dialog.objectCast<DialogCutArc>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const QString pointName = dialogTool->getPointName();
|
|
||||||
QString formula = dialogTool->GetFormula();
|
VToolCutArcInitData initData;
|
||||||
const quint32 arcId = dialogTool->getArcId();
|
initData.formula = dialogTool->GetFormula();
|
||||||
VToolCutArc* point = Create(0, pointName, formula, arcId, 5, 10, true, scene, doc, data, Document::FullParse,
|
initData.arcId = dialogTool->getArcId();
|
||||||
Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolCutArc* point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -118,67 +119,54 @@ VToolCutArc* VToolCutArc::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param pointName point name.
|
|
||||||
* @param formula string with formula length first arc.
|
|
||||||
* @param arcId id arc in data container.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
* @param typeCreation way we create this tool.
|
||||||
*/
|
*/
|
||||||
VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, quint32 arcId,
|
VToolCutArc* VToolCutArc::Create(VToolCutArcInitData &initData)
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
|
||||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(arcId);
|
const QSharedPointer<VArc> arc = initData.data->GeometricObject<VArc>(initData.arcId);
|
||||||
|
|
||||||
const qreal result = CheckFormula(_id, formula, data);
|
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||||
|
|
||||||
VArc arc1;
|
VArc arc1;
|
||||||
VArc arc2;
|
VArc arc2;
|
||||||
QPointF point = arc->CutArc(qApp->toPixel(result), arc1, arc2);
|
QPointF point = arc->CutArc(qApp->toPixel(result), arc1, arc2);
|
||||||
|
|
||||||
quint32 id = _id;
|
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||||
|
p->SetShowLabel(initData.showLabel);
|
||||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
|
||||||
p->SetShowLabel(showLabel);
|
|
||||||
|
|
||||||
auto a1 = QSharedPointer<VArc>(new VArc(arc1));
|
auto a1 = QSharedPointer<VArc>(new VArc(arc1));
|
||||||
auto a2 = QSharedPointer<VArc>(new VArc(arc2));
|
auto a2 = QSharedPointer<VArc>(new VArc(arc2));
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
a1->setId(VContainer::getNextId());
|
a1->setId(VContainer::getNextId());
|
||||||
a2->setId(VContainer::getNextId());
|
a2->setId(VContainer::getNextId());
|
||||||
data->AddArc(a1, a1->id(), id);
|
initData.data->AddArc(a1, a1->id(), initData.id);
|
||||||
data->AddArc(a2, a2->id(), id);
|
initData.data->AddArc(a2, a2->id(), initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
a1->setId(id + 1);
|
a1->setId(initData.id + 1);
|
||||||
a2->setId(id + 2);
|
a2->setId(initData.id + 2);
|
||||||
data->AddArc(a1, a1->id(), id);
|
initData.data->AddArc(a1, a1->id(), initData.id);
|
||||||
data->AddArc(a2, a2->id(), id);
|
initData.data->AddArc(a2, a2->id(), initData.id);
|
||||||
|
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::CutArc, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::CutArc, initData.doc);
|
||||||
VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, typeCreation);
|
VToolCutArc *point = new VToolCutArc(initData);
|
||||||
scene->addItem(point);
|
initData.scene->addItem(point);
|
||||||
InitToolConnections(scene, point);
|
InitToolConnections(initData.scene, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
doc->IncrementReferens(arc->getIdTool());
|
initData.doc->IncrementReferens(arc->getIdTool());
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -43,6 +43,18 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolCutArcInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolCutArcInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
formula(),
|
||||||
|
arcId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formula;
|
||||||
|
quint32 arcId;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolCutArc class tool for cutting arc.
|
* @brief The VToolCutArc class tool for cutting arc.
|
||||||
*/
|
*/
|
||||||
|
@ -53,10 +65,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolCutArc* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolCutArc* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, quint32 arcId,
|
static VToolCutArc* Create(VToolCutArcInitData &initData);
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::CutArc)};
|
enum { Type = UserType + static_cast<int>(Tool::CutArc)};
|
||||||
|
@ -72,8 +81,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolCutArc)
|
Q_DISABLE_COPY(VToolCutArc)
|
||||||
|
|
||||||
VToolCutArc(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
VToolCutArc(const VToolCutArcInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const quint32 &arcId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLCUTARC_H
|
#endif // VTOOLCUTARC_H
|
||||||
|
|
|
@ -62,19 +62,13 @@ const QString VToolCutSpline::AttrSpline = QStringLiteral("spline");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolCutSpline constructor.
|
* @brief VToolCutSpline constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param formula string with formula length first spline.
|
|
||||||
* @param splineId id spline in data container.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolCutSpline::VToolCutSpline(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
VToolCutSpline::VToolCutSpline(const VToolCutSplineInitData &initData, QGraphicsItem *parent)
|
||||||
const quint32 &splineId, const Source &typeCreation, QGraphicsItem *parent)
|
:VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.splineId, parent)
|
||||||
:VToolCut(doc, data, id, formula, splineId, parent)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -106,11 +100,18 @@ VToolCutSpline* VToolCutSpline::Create(QSharedPointer<DialogTool> dialog, VMainG
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogCutSpline> dialogTool = dialog.objectCast<DialogCutSpline>();
|
QSharedPointer<DialogCutSpline> dialogTool = dialog.objectCast<DialogCutSpline>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const QString pointName = dialogTool->getPointName();
|
|
||||||
QString formula = dialogTool->GetFormula();
|
VToolCutSplineInitData initData;
|
||||||
const quint32 splineId = dialogTool->getSplineId();
|
initData.formula = dialogTool->GetFormula();
|
||||||
VToolCutSpline* point = Create(0, pointName, formula, splineId, 5, 10, true, scene, doc, data, Document::FullParse,
|
initData.splineId = dialogTool->getSplineId();
|
||||||
Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolCutSpline* point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -121,64 +122,49 @@ VToolCutSpline* VToolCutSpline::Create(QSharedPointer<DialogTool> dialog, VMainG
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param pointName point name.
|
|
||||||
* @param formula string with formula length first spline.
|
|
||||||
* @param splineId id spline in data container.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
*/
|
*/
|
||||||
VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula,
|
VToolCutSpline* VToolCutSpline::Create(VToolCutSplineInitData &initData)
|
||||||
quint32 splineId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const auto spl = data->GeometricObject<VAbstractCubicBezier>(splineId);
|
const auto spl = initData.data->GeometricObject<VAbstractCubicBezier>(initData.splineId);
|
||||||
|
|
||||||
const qreal result = CheckFormula(_id, formula, data);
|
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||||
|
|
||||||
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
|
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
|
||||||
QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
|
QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
|
||||||
|
|
||||||
quint32 id = _id;
|
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||||
|
p->SetShowLabel(initData.showLabel);
|
||||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
|
||||||
p->SetShowLabel(showLabel);
|
|
||||||
|
|
||||||
auto spline1 = QSharedPointer<VAbstractBezier>(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p));
|
auto spline1 = QSharedPointer<VAbstractBezier>(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p));
|
||||||
auto spline2 = QSharedPointer<VAbstractBezier>(new VSpline(*p, spl2p2, spl2p3, spl->GetP4()));
|
auto spline2 = QSharedPointer<VAbstractBezier>(new VSpline(*p, spl2p2, spl2p3, spl->GetP4()));
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddSpline(spline1, NULL_ID, id);
|
initData.data->AddSpline(spline1, NULL_ID, initData.id);
|
||||||
data->AddSpline(spline2, NULL_ID, id);
|
initData.data->AddSpline(spline2, NULL_ID, initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddSpline(spline1, NULL_ID, id);
|
initData.data->AddSpline(spline1, NULL_ID, initData.id);
|
||||||
data->AddSpline(spline2, NULL_ID, id);
|
initData.data->AddSpline(spline2, NULL_ID, initData.id);
|
||||||
|
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::CutSpline, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::CutSpline, initData.doc);
|
||||||
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, typeCreation);
|
VToolCutSpline *point = new VToolCutSpline(initData);
|
||||||
scene->addItem(point);
|
initData.scene->addItem(point);
|
||||||
InitToolConnections(scene, point);
|
InitToolConnections(initData.scene, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
doc->IncrementReferens(spl->getIdTool());
|
initData.doc->IncrementReferens(spl->getIdTool());
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -43,6 +43,18 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolCutSplineInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolCutSplineInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
formula(),
|
||||||
|
splineId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formula;
|
||||||
|
quint32 splineId;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolCutSpline class for tool CutSpline. This tool find point on spline and cut spline on two.
|
* @brief The VToolCutSpline class for tool CutSpline. This tool find point on spline and cut spline on two.
|
||||||
*/
|
*/
|
||||||
|
@ -53,11 +65,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolCutSpline *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolCutSpline *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula,
|
static VToolCutSpline *Create(VToolCutSplineInitData &initData);
|
||||||
quint32 splineId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
static const QString AttrSpline;
|
static const QString AttrSpline;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
@ -74,8 +82,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolCutSpline)
|
Q_DISABLE_COPY(VToolCutSpline)
|
||||||
|
|
||||||
VToolCutSpline(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
VToolCutSpline(const VToolCutSplineInitData &initData, QGraphicsItem * parent = nullptr);
|
||||||
const quint32 &splineId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLCUTSPLINE_H
|
#endif // VTOOLCUTSPLINE_H
|
||||||
|
|
|
@ -65,20 +65,13 @@ const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolCutSplinePath constructor.
|
* @brief VToolCutSplinePath constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param formula string with formula length first splinePath.
|
|
||||||
* @param splinePathId id splinePath (we cut this splinePath) in data container.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolCutSplinePath::VToolCutSplinePath(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
VToolCutSplinePath::VToolCutSplinePath(const VToolCutSplinePathInitData &initData, QGraphicsItem *parent)
|
||||||
const QString &formula, const quint32 &splinePathId,
|
:VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.splinePathId, parent)
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
|
||||||
:VToolCut(doc, data, id, formula, splinePathId, parent)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -110,11 +103,18 @@ VToolCutSplinePath* VToolCutSplinePath::Create(QSharedPointer<DialogTool> dialog
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogCutSplinePath> dialogTool = dialog.objectCast<DialogCutSplinePath>();
|
QSharedPointer<DialogCutSplinePath> dialogTool = dialog.objectCast<DialogCutSplinePath>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const QString pointName = dialogTool->getPointName();
|
|
||||||
QString formula = dialogTool->GetFormula();
|
VToolCutSplinePathInitData initData;
|
||||||
const quint32 splinePathId = dialogTool->getSplinePathId();
|
initData.formula = dialogTool->GetFormula();
|
||||||
VToolCutSplinePath* point = Create(0, pointName, formula, splinePathId, 5, 10, true, scene, doc, data,
|
initData.splinePathId = dialogTool->getSplinePathId();
|
||||||
Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolCutSplinePath* point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -125,69 +125,55 @@ VToolCutSplinePath* VToolCutSplinePath::Create(QSharedPointer<DialogTool> dialog
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param pointName point name.
|
|
||||||
* @param formula string with formula length first splinePath.
|
|
||||||
* @param splinePathId id of splinePath in data container.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
*/
|
*/
|
||||||
VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula,
|
VToolCutSplinePath* VToolCutSplinePath::Create(VToolCutSplinePathInitData &initData)
|
||||||
quint32 splinePathId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc,
|
|
||||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const auto splPath = data->GeometricObject<VAbstractCubicBezierPath>(splinePathId);
|
const auto splPath = initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.splinePathId);
|
||||||
SCASSERT(splPath != nullptr)
|
SCASSERT(splPath != nullptr)
|
||||||
|
|
||||||
const qreal result = CheckFormula(_id, formula, data);
|
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||||
|
|
||||||
quint32 id = _id;
|
|
||||||
VSplinePath *splPath1 = nullptr;
|
VSplinePath *splPath1 = nullptr;
|
||||||
VSplinePath *splPath2 = nullptr;
|
VSplinePath *splPath2 = nullptr;
|
||||||
VPointF *p = VToolCutSplinePath::CutSplinePath(qApp->toPixel(result), splPath, pointName, &splPath1, &splPath2);
|
VPointF *p = VToolCutSplinePath::CutSplinePath(qApp->toPixel(result), splPath, initData.name, &splPath1, &splPath2);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
SCASSERT(splPath1 != nullptr)
|
SCASSERT(splPath1 != nullptr)
|
||||||
SCASSERT(splPath2 != nullptr)
|
SCASSERT(splPath2 != nullptr)
|
||||||
SCASSERT(p != nullptr)
|
SCASSERT(p != nullptr)
|
||||||
|
|
||||||
p->setMx(mx);
|
p->setMx(initData.mx);
|
||||||
p->setMy(my);
|
p->setMy(initData.my);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
|
|
||||||
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, id);
|
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, initData.id);
|
||||||
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, id);
|
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
|
|
||||||
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, id);
|
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, initData.id);
|
||||||
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, id);
|
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, initData.id);
|
||||||
|
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::CutSplinePath, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::CutSplinePath, initData.doc);
|
||||||
VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, typeCreation);
|
VToolCutSplinePath *point = new VToolCutSplinePath(initData);
|
||||||
scene->addItem(point);
|
initData.scene->addItem(point);
|
||||||
InitToolConnections(scene, point);
|
InitToolConnections(initData.scene, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
doc->IncrementReferens(splPath->getIdTool());
|
initData.doc->IncrementReferens(splPath->getIdTool());
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -44,6 +44,18 @@
|
||||||
class VSplinePath;
|
class VSplinePath;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolCutSplinePathInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolCutSplinePathInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
formula(),
|
||||||
|
splinePathId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formula;
|
||||||
|
quint32 splinePathId;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolCutSplinePath class for tool CutSplinePath. This tool find point on splinePath and cut splinePath on
|
* @brief The VToolCutSplinePath class for tool CutSplinePath. This tool find point on splinePath and cut splinePath on
|
||||||
* two.
|
* two.
|
||||||
|
@ -55,10 +67,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolCutSplinePath *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolCutSplinePath *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula,
|
static VToolCutSplinePath *Create(VToolCutSplinePathInitData &initData);
|
||||||
quint32 splinePathId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
static const QString AttrSplinePath;
|
static const QString AttrSplinePath;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
@ -80,8 +89,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VToolCutSplinePath)
|
Q_DISABLE_COPY(VToolCutSplinePath)
|
||||||
|
|
||||||
VToolCutSplinePath(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
VToolCutSplinePath(const VToolCutSplinePathInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const quint32 &splinePathId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLCUTSPLINEPATH_H
|
#endif // VTOOLCUTSPLINEPATH_H
|
||||||
|
|
|
@ -71,13 +71,12 @@ const QString VToolAlongLine::ToolType = QStringLiteral("alongLine");
|
||||||
* @param typeCreation way we create this tool.
|
* @param typeCreation way we create this tool.
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolAlongLine::VToolAlongLine(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &formula,
|
VToolAlongLine::VToolAlongLine(const VToolAlongLineInitData &initData, QGraphicsItem *parent)
|
||||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula,
|
||||||
const QString &typeLine, const QString &lineColor, const Source &typeCreation,
|
initData.firstPointId, 0, parent),
|
||||||
QGraphicsItem *parent)
|
secondPointId(initData.secondPointId)
|
||||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, 0, parent), secondPointId(secondPointId)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -244,14 +243,21 @@ VToolAlongLine* VToolAlongLine::Create(QSharedPointer<DialogTool> dialog, VMainG
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogAlongLine> dialogTool = dialog.objectCast<DialogAlongLine>();
|
QSharedPointer<DialogAlongLine> dialogTool = dialog.objectCast<DialogAlongLine>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
QString formula = dialogTool->GetFormula();
|
|
||||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
VToolAlongLineInitData initData;
|
||||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
initData.formula = dialogTool->GetFormula();
|
||||||
const QString typeLine = dialogTool->GetTypeLine();
|
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||||
const QString lineColor = dialogTool->GetLineColor();
|
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
VToolAlongLine *point = Create(0, pointName, typeLine, lineColor, formula, firstPointId, secondPointId,
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolAlongLine *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -262,75 +268,55 @@ VToolAlongLine* VToolAlongLine::Create(QSharedPointer<DialogTool> dialog, VMainG
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param pointName point name. point name.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param formula string with length formula.
|
|
||||||
* @param firstPointId id first point of line.
|
|
||||||
* @param secondPointId id second point of line.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param showLabel show/hide label.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
*/
|
*/
|
||||||
VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
VToolAlongLine* VToolAlongLine::Create(VToolAlongLineInitData &initData)
|
||||||
const QString &lineColor, QString &formula, const quint32 &firstPointId,
|
|
||||||
quint32 secondPointId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||||
QLineF line = QLineF(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
QLineF line = QLineF(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
||||||
|
|
||||||
//Declare special variable "CurrentLength"
|
//Declare special variable "CurrentLength"
|
||||||
VLengthLine *length = new VLengthLine(firstPoint.data(), firstPointId, secondPoint.data(),
|
VLengthLine *length = new VLengthLine(firstPoint.data(), initData.firstPointId, secondPoint.data(),
|
||||||
secondPointId, *data->GetPatternUnit());
|
initData.secondPointId, *initData.data->GetPatternUnit());
|
||||||
length->SetName(currentLength);
|
length->SetName(currentLength);
|
||||||
data->AddVariable(currentLength, length);
|
initData.data->AddVariable(currentLength, length);
|
||||||
|
|
||||||
line.setLength(qApp->toPixel(CheckFormula(_id, formula, data)));
|
line.setLength(qApp->toPixel(CheckFormula(initData.id, initData.formula, initData.data)));
|
||||||
|
|
||||||
quint32 id = _id;
|
VPointF *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my);
|
||||||
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
VPointF *p = new VPointF(line.p2(), pointName, mx, my);
|
if (initData.typeCreation == Source::FromGui)
|
||||||
p->SetShowLabel(showLabel);
|
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddLine(firstPointId, id);
|
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||||
data->AddLine(id, secondPointId);
|
initData.data->AddLine(initData.id, initData.secondPointId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddLine(firstPointId, id);
|
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||||
data->AddLine(id, secondPointId);
|
initData.data->AddLine(initData.id, initData.secondPointId);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VToolAlongLine *point = nullptr;
|
VToolAlongLine *point = nullptr;
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::AlongLine, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::AlongLine, initData.doc);
|
||||||
point = new VToolAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine, lineColor,
|
point = new VToolAlongLine(initData);
|
||||||
typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||||
doc->IncrementReferens(firstPoint->getIdTool());
|
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||||
doc->IncrementReferens(secondPoint->getIdTool());
|
|
||||||
}
|
}
|
||||||
//Very important to delete it. Only this tool need this special variable.
|
//Very important to delete it. Only this tool need this special variable.
|
||||||
data->RemoveVariable(currentLength);
|
initData.data->RemoveVariable(currentLength);
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,20 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolAlongLineInitData : public VToolLinePointInitData
|
||||||
|
{
|
||||||
|
VToolAlongLineInitData()
|
||||||
|
: VToolLinePointInitData(),
|
||||||
|
formula("100.0"),
|
||||||
|
firstPointId(NULL_ID),
|
||||||
|
secondPointId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formula;
|
||||||
|
quint32 firstPointId;
|
||||||
|
quint32 secondPointId;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolAlongLine class tool for creation point along line.
|
* @brief The VToolAlongLine class tool for creation point along line.
|
||||||
*/
|
*/
|
||||||
|
@ -53,12 +67,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolAlongLine* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolAlongLine* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
static VToolAlongLine* Create(VToolAlongLineInitData &initData);
|
||||||
const QString &lineColor, QString &formula, const quint32 &firstPointId,
|
|
||||||
quint32 secondPointId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::AlongLine)};
|
enum { Type = UserType + static_cast<int>(Tool::AlongLine)};
|
||||||
|
@ -83,10 +92,7 @@ private:
|
||||||
/** @brief secondPointId id second point of line. */
|
/** @brief secondPointId id second point of line. */
|
||||||
quint32 secondPointId;
|
quint32 secondPointId;
|
||||||
|
|
||||||
VToolAlongLine(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &formula,
|
VToolAlongLine(const VToolAlongLineInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const quint32 &firstPointId,
|
|
||||||
const quint32 &secondPointId, const QString &typeLine, const QString &lineColor,
|
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLALONGLINE_H
|
#endif // VTOOLALONGLINE_H
|
||||||
|
|
|
@ -59,25 +59,15 @@ const QString VToolBisector::ToolType = QStringLiteral("bisector");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolBisector constructor.
|
* @brief VToolBisector constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param formula string with formula length of bisector.
|
|
||||||
* @param firstPointId id first point of angle.
|
|
||||||
* @param secondPointId id second point of angle.
|
|
||||||
* @param thirdPointId id third point of angle.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
|
||||||
*/
|
*/
|
||||||
VToolBisector::VToolBisector(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolBisector::VToolBisector(const VToolBisectorInitData &initData, QGraphicsItem *parent)
|
||||||
const QString &lineColor, const QString &formula, const quint32 &firstPointId,
|
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula,
|
||||||
const quint32 &secondPointId, const quint32 &thirdPointId, const Source &typeCreation,
|
initData.secondPointId, 0, parent),
|
||||||
QGraphicsItem *parent)
|
firstPointId(initData.firstPointId),
|
||||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, secondPointId, 0, parent), firstPointId(firstPointId),
|
thirdPointId(initData.thirdPointId)
|
||||||
thirdPointId(thirdPointId)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -148,15 +138,22 @@ VToolBisector* VToolBisector::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogBisector> dialogTool = dialog.objectCast<DialogBisector>();
|
QSharedPointer<DialogBisector> dialogTool = dialog.objectCast<DialogBisector>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
QString formula = dialogTool->GetFormula();
|
|
||||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
VToolBisectorInitData initData;
|
||||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
initData.formula = dialogTool->GetFormula();
|
||||||
const quint32 thirdPointId = dialogTool->GetThirdPointId();
|
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||||
const QString typeLine = dialogTool->GetTypeLine();
|
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||||
const QString lineColor = dialogTool->GetLineColor();
|
initData.thirdPointId = dialogTool->GetThirdPointId();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
VToolBisector *point = Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, lineColor,
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
pointName, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolBisector *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -167,67 +164,47 @@ VToolBisector* VToolBisector::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param formula string with formula.
|
|
||||||
* @param firstPointId id first point of angle.
|
|
||||||
* @param secondPointId id second point of angle.
|
|
||||||
* @param thirdPointId id third point of angle.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param pointName point name.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param showLabel show/hide label.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
*/
|
*/
|
||||||
VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, quint32 firstPointId, quint32 secondPointId,
|
VToolBisector* VToolBisector::Create(VToolBisectorInitData &initData)
|
||||||
quint32 thirdPointId, const QString &typeLine, const QString &lineColor,
|
|
||||||
const QString &pointName, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||||
const QSharedPointer<VPointF> thirdPoint = data->GeometricObject<VPointF>(thirdPointId);
|
const QSharedPointer<VPointF> thirdPoint = initData.data->GeometricObject<VPointF>(initData.thirdPointId);
|
||||||
|
|
||||||
const qreal result = CheckFormula(_id, formula, data);
|
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||||
|
|
||||||
QPointF fPoint = VToolBisector::FindPoint(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint),
|
QPointF fPoint = VToolBisector::FindPoint(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint),
|
||||||
static_cast<QPointF>(*thirdPoint), qApp->toPixel(result));
|
static_cast<QPointF>(*thirdPoint), qApp->toPixel(result));
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(fPoint, pointName, mx, my);
|
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddLine(secondPointId, id);
|
initData.data->AddLine(initData.secondPointId, initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddLine(secondPointId, id);
|
initData.data->AddLine(initData.secondPointId, initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::Bisector, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Bisector, initData.doc);
|
||||||
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, lineColor, formula, firstPointId,
|
VToolBisector *point = new VToolBisector(initData);
|
||||||
secondPointId, thirdPointId, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||||
doc->IncrementReferens(firstPoint->getIdTool());
|
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||||
doc->IncrementReferens(secondPoint->getIdTool());
|
initData.doc->IncrementReferens(thirdPoint->getIdTool());
|
||||||
doc->IncrementReferens(thirdPoint->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -44,6 +44,22 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolBisectorInitData : public VToolLinePointInitData
|
||||||
|
{
|
||||||
|
VToolBisectorInitData()
|
||||||
|
: VToolLinePointInitData(),
|
||||||
|
formula("100.0"),
|
||||||
|
firstPointId(NULL_ID),
|
||||||
|
secondPointId(NULL_ID),
|
||||||
|
thirdPointId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formula;
|
||||||
|
quint32 firstPointId;
|
||||||
|
quint32 secondPointId;
|
||||||
|
quint32 thirdPointId;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolBisector class tool for creation bisector point.
|
* @brief The VToolBisector class tool for creation bisector point.
|
||||||
*/
|
*/
|
||||||
|
@ -57,11 +73,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolBisector* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolBisector* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolBisector* Create(const quint32 _id, QString &formula, quint32 firstPointId, quint32 secondPointId,
|
static VToolBisector* Create(VToolBisectorInitData &initData);
|
||||||
quint32 thirdPointId, const QString &typeLine, const QString &lineColor,
|
|
||||||
const QString &pointName, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::Bisector)};
|
enum { Type = UserType + static_cast<int>(Tool::Bisector)};
|
||||||
|
@ -93,10 +105,7 @@ private:
|
||||||
/** @brief thirdPointId id third point of angle. */
|
/** @brief thirdPointId id third point of angle. */
|
||||||
quint32 thirdPointId;
|
quint32 thirdPointId;
|
||||||
|
|
||||||
VToolBisector(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolBisector(const VToolBisectorInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QString &lineColor,
|
|
||||||
const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId,
|
|
||||||
const quint32 &thirdPointId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLBISECTOR_H
|
#endif // VTOOLBISECTOR_H
|
||||||
|
|
|
@ -70,15 +70,14 @@ template <class T> class QSharedPointer;
|
||||||
const QString VToolCurveIntersectAxis::ToolType = QStringLiteral("curveIntersectAxis");
|
const QString VToolCurveIntersectAxis::ToolType = QStringLiteral("curveIntersectAxis");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolCurveIntersectAxis::VToolCurveIntersectAxis(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
VToolCurveIntersectAxis::VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData,
|
||||||
const QString &typeLine, const QString &lineColor,
|
|
||||||
const QString &formulaAngle, const quint32 &basePointId,
|
|
||||||
const quint32 &curveId, const Source &typeCreation,
|
|
||||||
QGraphicsItem *parent)
|
QGraphicsItem *parent)
|
||||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle),
|
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(),
|
||||||
curveId(curveId)
|
initData.basePointId, 0, parent),
|
||||||
|
formulaAngle(initData.formulaAngle),
|
||||||
|
curveId(initData.curveId)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -105,16 +104,21 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(QSharedPointer<DialogTo
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogCurveIntersectAxis> dialogTool = dialog.objectCast<DialogCurveIntersectAxis>();
|
QSharedPointer<DialogCurveIntersectAxis> dialogTool = dialog.objectCast<DialogCurveIntersectAxis>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const QString pointName = dialogTool->getPointName();
|
|
||||||
const QString typeLine = dialogTool->GetTypeLine();
|
|
||||||
const QString lineColor = dialogTool->GetLineColor();
|
|
||||||
QString formulaAngle = dialogTool->GetAngle();
|
|
||||||
const quint32 basePointId = dialogTool->GetBasePointId();
|
|
||||||
const quint32 curveId = dialogTool->getCurveId();
|
|
||||||
|
|
||||||
VToolCurveIntersectAxis *point = Create(0, pointName, typeLine, lineColor, formulaAngle, basePointId,
|
VToolCurveIntersectAxisInitData initData;
|
||||||
curveId, 5, 10, true, scene, doc, data, Document::FullParse,
|
initData.formulaAngle = dialogTool->GetAngle();
|
||||||
Source::FromGui);
|
initData.basePointId = dialogTool->GetBasePointId();
|
||||||
|
initData.curveId = dialogTool->getCurveId();
|
||||||
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolCurveIntersectAxis *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -123,57 +127,49 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(QSharedPointer<DialogTo
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, const QString &pointName,
|
VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxisInitData &initData)
|
||||||
const QString &typeLine, const QString &lineColor,
|
|
||||||
QString &formulaAngle, quint32 basePointId,
|
|
||||||
quint32 curveId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc,
|
|
||||||
VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
|
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
|
||||||
const qreal angle = CheckFormula(_id, formulaAngle, data);
|
const qreal angle = CheckFormula(initData.id, initData.formulaAngle, initData.data);
|
||||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(curveId);
|
const QSharedPointer<VAbstractCurve> curve = initData.data->GeometricObject<VAbstractCurve>(initData.curveId);
|
||||||
|
|
||||||
const QPointF fPoint = FindPoint(static_cast<QPointF>(*basePoint), angle, curve);
|
const QPointF fPoint = FindPoint(static_cast<QPointF>(*basePoint), angle, curve);
|
||||||
const qreal segLength = curve->GetLengthByPoint(fPoint);
|
const qreal segLength = curve->GetLengthByPoint(fPoint);
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(fPoint, pointName, mx, my);
|
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddLine(basePointId, id);
|
initData.data->AddLine(initData.basePointId, initData.id);
|
||||||
|
|
||||||
VContainer::getNextId();
|
VContainer::getNextId();
|
||||||
VContainer::getNextId();
|
VContainer::getNextId();
|
||||||
InitSegments(curve->getType(), segLength, p, curveId, data);
|
InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddLine(basePointId, id);
|
initData.data->AddLine(initData.basePointId, initData.id);
|
||||||
|
|
||||||
InitSegments(curve->getType(), segLength, p, curveId, data);
|
InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data);
|
||||||
|
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::CurveIntersectAxis, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::CurveIntersectAxis, initData.doc);
|
||||||
VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle,
|
VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(initData);
|
||||||
basePointId, curveId, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(basePoint->getIdTool());
|
||||||
doc->IncrementReferens(basePoint->getIdTool());
|
initData.doc->IncrementReferens(curve->getIdTool());
|
||||||
doc->IncrementReferens(curve->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -46,6 +46,20 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolCurveIntersectAxisInitData : public VToolLinePointInitData
|
||||||
|
{
|
||||||
|
VToolCurveIntersectAxisInitData()
|
||||||
|
: VToolLinePointInitData(),
|
||||||
|
formulaAngle("0"),
|
||||||
|
basePointId(NULL_ID),
|
||||||
|
curveId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formulaAngle;
|
||||||
|
quint32 basePointId;
|
||||||
|
quint32 curveId;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolCurveIntersectAxis : public VToolLinePoint
|
class VToolCurveIntersectAxis : public VToolLinePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -55,11 +69,7 @@ public:
|
||||||
|
|
||||||
static VToolCurveIntersectAxis *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolCurveIntersectAxis *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolCurveIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
static VToolCurveIntersectAxis *Create(VToolCurveIntersectAxisInitData &initData);
|
||||||
const QString &lineColor, QString &formulaAngle, quint32 basePointId,
|
|
||||||
quint32 curveId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
|
|
||||||
static QPointF FindPoint(const QPointF &point, qreal angle, const QSharedPointer<VAbstractCurve> &curve);
|
static QPointF FindPoint(const QPointF &point, qreal angle, const QSharedPointer<VAbstractCurve> &curve);
|
||||||
|
|
||||||
|
@ -88,9 +98,7 @@ private:
|
||||||
QString formulaAngle;
|
QString formulaAngle;
|
||||||
quint32 curveId;
|
quint32 curveId;
|
||||||
|
|
||||||
VToolCurveIntersectAxis(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QString &lineColor, const QString &formulaAngle, const quint32 &basePointId,
|
|
||||||
const quint32 &curveId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
|
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId);
|
static void InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId);
|
||||||
|
|
|
@ -59,23 +59,15 @@ const QString VToolEndLine::ToolType = QStringLiteral("endLine");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolEndLine constructor.
|
* @brief VToolEndLine constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param formulaLength string with formula length of line.
|
|
||||||
* @param formulaAngle formula angle of line.
|
|
||||||
* @param basePointId id first point of line.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolEndLine::VToolEndLine(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolEndLine::VToolEndLine(const VToolEndLineInitData &initData, QGraphicsItem *parent)
|
||||||
const QString &lineColor, const QString &formulaLength, const QString &formulaAngle,
|
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor,
|
||||||
const quint32 &basePointId, const Source &typeCreation, QGraphicsItem *parent)
|
initData.formulaLength, initData.basePointId, 0, parent),
|
||||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, formulaLength, basePointId, 0, parent),
|
formulaAngle(initData.formulaAngle)
|
||||||
formulaAngle(formulaAngle)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -112,15 +104,21 @@ VToolEndLine* VToolEndLine::Create(QSharedPointer<DialogTool> dialog, VMainGraph
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogEndLine> dialogTool = dialog.objectCast<DialogEndLine>();
|
QSharedPointer<DialogEndLine> dialogTool = dialog.objectCast<DialogEndLine>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const QString pointName = dialogTool->getPointName();
|
|
||||||
const QString typeLine = dialogTool->GetTypeLine();
|
|
||||||
const QString lineColor = dialogTool->GetLineColor();
|
|
||||||
QString formulaLength = dialogTool->GetFormula();
|
|
||||||
QString formulaAngle = dialogTool->GetAngle();
|
|
||||||
const quint32 basePointId = dialogTool->GetBasePointId();
|
|
||||||
|
|
||||||
VToolEndLine *point = Create(0, pointName, typeLine, lineColor, formulaLength, formulaAngle,
|
VToolEndLineInitData initData;
|
||||||
basePointId, 5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.formulaLength = dialogTool->GetFormula();
|
||||||
|
initData.formulaAngle = dialogTool->GetAngle();
|
||||||
|
initData.basePointId = dialogTool->GetBasePointId();
|
||||||
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolEndLine *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -131,63 +129,42 @@ VToolEndLine* VToolEndLine::Create(QSharedPointer<DialogTool> dialog, VMainGraph
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param pointName point name.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param lineColor line color.
|
|
||||||
* @param formulaLength string with formula length of line.
|
|
||||||
* @param formulaAngle formula angle of line.
|
|
||||||
* @param basePointId id first point of line.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param showLabel show/hide label
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @return the created tool
|
|
||||||
*/
|
*/
|
||||||
VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
VToolEndLine* VToolEndLine::Create(VToolEndLineInitData &initData)
|
||||||
const QString &lineColor, QString &formulaLength, QString &formulaAngle,
|
|
||||||
quint32 basePointId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
|
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
|
||||||
QLineF line = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x()+100, basePoint->y()));
|
QLineF line = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x()+100, basePoint->y()));
|
||||||
|
|
||||||
line.setAngle(CheckFormula(_id, formulaAngle, data)); //First set angle.
|
line.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data)); //First set angle.
|
||||||
line.setLength(qApp->toPixel(CheckFormula(_id, formulaLength, data)));
|
line.setLength(qApp->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data)));
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(line.p2(), pointName, mx, my);
|
VPointF *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddLine(basePointId, id);
|
initData.data->AddLine(initData.basePointId, initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddLine(basePointId, id);
|
initData.data->AddLine(initData.basePointId, initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::EndLine, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::EndLine, initData.doc);
|
||||||
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, lineColor, formulaLength, formulaAngle,
|
VToolEndLine *point = new VToolEndLine(initData);
|
||||||
basePointId, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(basePoint->getIdTool());
|
||||||
doc->IncrementReferens(basePoint->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -44,6 +44,20 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolEndLineInitData : public VToolLinePointInitData
|
||||||
|
{
|
||||||
|
VToolEndLineInitData()
|
||||||
|
: VToolLinePointInitData(),
|
||||||
|
formulaLength(),
|
||||||
|
formulaAngle(),
|
||||||
|
basePointId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formulaLength;
|
||||||
|
QString formulaAngle;
|
||||||
|
quint32 basePointId;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolEndLine class tool for creation point on the line end.
|
* @brief The VToolEndLine class tool for creation point on the line end.
|
||||||
*/
|
*/
|
||||||
|
@ -55,12 +69,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolEndLine *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolEndLine *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
static VToolEndLine *Create(VToolEndLineInitData &initData);
|
||||||
const QString &lineColor, QString &formulaLength, QString &formulaAngle,
|
|
||||||
quint32 basePointId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::EndLine)};
|
enum { Type = UserType + static_cast<int>(Tool::EndLine)};
|
||||||
|
@ -80,10 +89,7 @@ private:
|
||||||
|
|
||||||
QString formulaAngle;
|
QString formulaAngle;
|
||||||
|
|
||||||
VToolEndLine(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolEndLine(const VToolEndLineInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QString &lineColor,
|
|
||||||
const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId,
|
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLENDLINE_H
|
#endif // VTOOLENDLINE_H
|
||||||
|
|
|
@ -55,23 +55,16 @@ const QString VToolHeight::ToolType = QStringLiteral("height");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolHeight constructor.
|
* @brief VToolHeight constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param basePointId id base point of projection.
|
|
||||||
* @param p1LineId id first point of line.
|
|
||||||
* @param p2LineId id second point of line.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolHeight::VToolHeight(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolHeight::VToolHeight(const VToolHeightInitData &initData, QGraphicsItem * parent)
|
||||||
const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId,
|
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(),
|
||||||
const quint32 &p2LineId, const Source &typeCreation, QGraphicsItem * parent)
|
initData.basePointId, 0, parent),
|
||||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), p1LineId(p1LineId),
|
p1LineId(initData.p1LineId),
|
||||||
p2LineId(p2LineId)
|
p2LineId(initData.p2LineId)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -107,15 +100,21 @@ VToolHeight* VToolHeight::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogHeight> dialogTool = dialog.objectCast<DialogHeight>();
|
QSharedPointer<DialogHeight> dialogTool = dialog.objectCast<DialogHeight>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const QString pointName = dialogTool->getPointName();
|
|
||||||
const QString typeLine = dialogTool->GetTypeLine();
|
|
||||||
const QString lineColor = dialogTool->GetLineColor();
|
|
||||||
const quint32 basePointId = dialogTool->GetBasePointId();
|
|
||||||
const quint32 p1LineId = dialogTool->GetP1LineId();
|
|
||||||
const quint32 p2LineId = dialogTool->GetP2LineId();
|
|
||||||
|
|
||||||
VToolHeight *point = Create(0, pointName, typeLine, lineColor, basePointId, p1LineId, p2LineId, 5, 10, true, scene,
|
VToolHeightInitData initData;
|
||||||
doc, data, Document::FullParse, Source::FromGui);
|
initData.basePointId = dialogTool->GetBasePointId();
|
||||||
|
initData.p1LineId = dialogTool->GetP1LineId();
|
||||||
|
initData.p2LineId = dialogTool->GetP2LineId();
|
||||||
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolHeight *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -126,68 +125,49 @@ VToolHeight* VToolHeight::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool
|
* @brief Create help create tool
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param pointName point name.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param basePointId id base point of projection.
|
|
||||||
* @param p1LineId id first point of line.
|
|
||||||
* @param p2LineId id second point of line.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @return the created tool
|
|
||||||
*/
|
*/
|
||||||
VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
VToolHeight* VToolHeight::Create(VToolHeightInitData initData)
|
||||||
const QString &lineColor, quint32 basePointId, quint32 p1LineId,
|
|
||||||
quint32 p2LineId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
|
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
|
||||||
const QSharedPointer<VPointF> p1Line = data->GeometricObject<VPointF>(p1LineId);
|
const QSharedPointer<VPointF> p1Line = initData.data->GeometricObject<VPointF>(initData.p1LineId);
|
||||||
const QSharedPointer<VPointF> p2Line = data->GeometricObject<VPointF>(p2LineId);
|
const QSharedPointer<VPointF> p2Line = initData.data->GeometricObject<VPointF>(initData.p2LineId);
|
||||||
|
|
||||||
QPointF pHeight = FindPoint(QLineF(static_cast<QPointF>(*p1Line), static_cast<QPointF>(*p2Line)),
|
QPointF pHeight = FindPoint(QLineF(static_cast<QPointF>(*p1Line), static_cast<QPointF>(*p2Line)),
|
||||||
static_cast<QPointF>(*basePoint));
|
static_cast<QPointF>(*basePoint));
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(pHeight, pointName, mx, my);
|
VPointF *p = new VPointF(pHeight, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddLine(basePointId, id);
|
initData.data->AddLine(initData.basePointId, initData.id);
|
||||||
data->AddLine(p1LineId, id);
|
initData.data->AddLine(initData.p1LineId, initData.id);
|
||||||
data->AddLine(p2LineId, id);
|
initData.data->AddLine(initData.p2LineId, initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddLine(basePointId, id);
|
initData.data->AddLine(initData.basePointId, initData.id);
|
||||||
data->AddLine(p1LineId, id);
|
initData.data->AddLine(initData.p1LineId, initData.id);
|
||||||
data->AddLine(p2LineId, id);
|
initData.data->AddLine(initData.p2LineId, initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::Height, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Height, initData.doc);
|
||||||
VToolHeight *point = new VToolHeight(doc, data, id, typeLine, lineColor, basePointId, p1LineId, p2LineId,
|
VToolHeight *point = new VToolHeight(initData);
|
||||||
typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(basePoint->getIdTool());
|
||||||
doc->IncrementReferens(basePoint->getIdTool());
|
initData.doc->IncrementReferens(p1Line->getIdTool());
|
||||||
doc->IncrementReferens(p1Line->getIdTool());
|
initData.doc->IncrementReferens(p2Line->getIdTool());
|
||||||
doc->IncrementReferens(p2Line->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -45,6 +45,20 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolHeightInitData : public VToolLinePointInitData
|
||||||
|
{
|
||||||
|
VToolHeightInitData()
|
||||||
|
: VToolLinePointInitData(),
|
||||||
|
basePointId(NULL_ID),
|
||||||
|
p1LineId(NULL_ID),
|
||||||
|
p2LineId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 basePointId;
|
||||||
|
quint32 p1LineId;
|
||||||
|
quint32 p2LineId;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolHeight class tool for creation point of height. Help find point of projection onto line.
|
* @brief The VToolHeight class tool for creation point of height. Help find point of projection onto line.
|
||||||
*/
|
*/
|
||||||
|
@ -55,11 +69,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolHeight *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolHeight *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolHeight *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
static VToolHeight *Create(VToolHeightInitData initData);
|
||||||
const QString &lineColor, quint32 basePointId, quint32 p1LineId,
|
|
||||||
quint32 p2LineId, qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static QPointF FindPoint(const QLineF &line, const QPointF &point);
|
static QPointF FindPoint(const QLineF &line, const QPointF &point);
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
@ -92,10 +102,7 @@ private:
|
||||||
/** @brief p2LineId id second point of line. */
|
/** @brief p2LineId id second point of line. */
|
||||||
quint32 p2LineId;
|
quint32 p2LineId;
|
||||||
|
|
||||||
VToolHeight(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolHeight(const VToolHeightInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QString &lineColor,
|
|
||||||
const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId,
|
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLHEIGHT_H
|
#endif // VTOOLHEIGHT_H
|
||||||
|
|
|
@ -56,15 +56,14 @@ template <class T> class QSharedPointer;
|
||||||
const QString VToolLineIntersectAxis::ToolType = QStringLiteral("lineIntersectAxis");
|
const QString VToolLineIntersectAxis::ToolType = QStringLiteral("lineIntersectAxis");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolLineIntersectAxis::VToolLineIntersectAxis(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
VToolLineIntersectAxis::VToolLineIntersectAxis(const VToolLineIntersectAxisInitData &initData, QGraphicsItem *parent)
|
||||||
const QString &typeLine, const QString &lineColor,
|
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(),
|
||||||
const QString &formulaAngle, const quint32 &basePointId,
|
initData.basePointId, 0, parent),
|
||||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
formulaAngle(initData.formulaAngle),
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
firstPointId(initData.firstPointId),
|
||||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle),
|
secondPointId(initData.secondPointId)
|
||||||
firstPointId(firstPointId), secondPointId(secondPointId)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -91,17 +90,22 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(QSharedPointer<DialogTool
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogLineIntersectAxis> dialogTool = dialog.objectCast<DialogLineIntersectAxis>();
|
QSharedPointer<DialogLineIntersectAxis> dialogTool = dialog.objectCast<DialogLineIntersectAxis>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const QString pointName = dialogTool->getPointName();
|
|
||||||
const QString typeLine = dialogTool->GetTypeLine();
|
|
||||||
const QString lineColor = dialogTool->GetLineColor();
|
|
||||||
QString formulaAngle = dialogTool->GetAngle();
|
|
||||||
const quint32 basePointId = dialogTool->GetBasePointId();
|
|
||||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
|
||||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
|
||||||
|
|
||||||
VToolLineIntersectAxis *point = Create(0, pointName, typeLine, lineColor, formulaAngle,
|
VToolLineIntersectAxisInitData initData;
|
||||||
basePointId, firstPointId, secondPointId, 5, 10, true,
|
initData.formulaAngle = dialogTool->GetAngle();
|
||||||
scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.basePointId = dialogTool->GetBasePointId();
|
||||||
|
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||||
|
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||||
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolLineIntersectAxis *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -110,59 +114,50 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(QSharedPointer<DialogTool
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const QString &pointName,
|
VToolLineIntersectAxis *VToolLineIntersectAxis::Create(VToolLineIntersectAxisInitData &initData)
|
||||||
const QString &typeLine, const QString &lineColor,
|
|
||||||
QString &formulaAngle, quint32 basePointId,
|
|
||||||
quint32 firstPointId, quint32 secondPointId,
|
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
|
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
|
||||||
QLineF axis = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x()+100, basePoint->y()));
|
QLineF axis = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x()+100, basePoint->y()));
|
||||||
axis.setAngle(CheckFormula(_id, formulaAngle, data));
|
axis.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data));
|
||||||
|
|
||||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||||
QLineF line(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
QLineF line(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
||||||
|
|
||||||
QPointF fPoint = FindPoint(axis, line);
|
QPointF fPoint = FindPoint(axis, line);
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(fPoint, pointName, mx, my);
|
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddLine(basePointId, id);
|
initData.data->AddLine(initData.basePointId, initData.id);
|
||||||
data->AddLine(firstPointId, id);
|
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||||
data->AddLine(id, secondPointId);
|
initData.data->AddLine(initData.id, initData.secondPointId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddLine(basePointId, id);
|
initData.data->AddLine(initData.basePointId, initData.id);
|
||||||
data->AddLine(firstPointId, id);
|
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||||
data->AddLine(id, secondPointId);
|
initData.data->AddLine(initData.id, initData.secondPointId);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::LineIntersectAxis, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::LineIntersectAxis, initData.doc);
|
||||||
VToolLineIntersectAxis *point = new VToolLineIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle,
|
VToolLineIntersectAxis *point = new VToolLineIntersectAxis(initData);
|
||||||
basePointId, firstPointId, secondPointId,
|
initData.scene->addItem(point);
|
||||||
typeCreation);
|
InitToolConnections(initData.scene, point);
|
||||||
scene->addItem(point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
InitToolConnections(scene, point);
|
initData.doc->IncrementReferens(basePoint->getIdTool());
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||||
doc->IncrementReferens(basePoint->getIdTool());
|
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||||
doc->IncrementReferens(firstPoint->getIdTool());
|
|
||||||
doc->IncrementReferens(secondPoint->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -46,6 +46,22 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolLineIntersectAxisInitData : public VToolLinePointInitData
|
||||||
|
{
|
||||||
|
VToolLineIntersectAxisInitData()
|
||||||
|
: VToolLinePointInitData(),
|
||||||
|
formulaAngle("0"),
|
||||||
|
basePointId(NULL_ID),
|
||||||
|
firstPointId(NULL_ID),
|
||||||
|
secondPointId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formulaAngle;
|
||||||
|
quint32 basePointId;
|
||||||
|
quint32 firstPointId;
|
||||||
|
quint32 secondPointId;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolLineIntersectAxis : public VToolLinePoint
|
class VToolLineIntersectAxis : public VToolLinePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -55,12 +71,7 @@ public:
|
||||||
|
|
||||||
static VToolLineIntersectAxis *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolLineIntersectAxis *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolLineIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
static VToolLineIntersectAxis *Create(VToolLineIntersectAxisInitData &initData);
|
||||||
const QString &lineColor, QString &formulaAngle, quint32 basePointId,
|
|
||||||
quint32 firstPointId, quint32 secondPointId,
|
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc,
|
|
||||||
VContainer *data, const Document &parse, const Source &typeCreation);
|
|
||||||
|
|
||||||
static QPointF FindPoint(const QLineF &axis, const QLineF &line);
|
static QPointF FindPoint(const QLineF &axis, const QLineF &line);
|
||||||
|
|
||||||
|
@ -96,10 +107,7 @@ private:
|
||||||
quint32 firstPointId;
|
quint32 firstPointId;
|
||||||
quint32 secondPointId;
|
quint32 secondPointId;
|
||||||
|
|
||||||
VToolLineIntersectAxis(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolLineIntersectAxis(const VToolLineIntersectAxisInitData &initData, QGraphicsItem * parent = nullptr);
|
||||||
const QString &lineColor, const QString &formulaAngle, const quint32 &basePointId,
|
|
||||||
const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation,
|
|
||||||
QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLLINEINTERSECTAXIS_H
|
#endif // VTOOLLINEINTERSECTAXIS_H
|
||||||
|
|
|
@ -42,6 +42,18 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolLinePointInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolLinePointInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
typeLine(TypeLineLine),
|
||||||
|
lineColor(ColorBlack)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString typeLine;
|
||||||
|
QString lineColor;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolLinePoint class parent for all tools what create point with line.
|
* @brief The VToolLinePoint class parent for all tools what create point with line.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -59,26 +59,16 @@ const QString VToolNormal::ToolType = QStringLiteral("normal");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolNormal constructor.
|
* @brief VToolNormal constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param formula string with formula normal length.
|
|
||||||
* @param angle additional angle.
|
|
||||||
* @param firstPointId id first line point.
|
|
||||||
* @param secondPointId id second line point.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolNormal::VToolNormal(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolNormal::VToolNormal(const VToolNormalInitData &initData, QGraphicsItem *parent)
|
||||||
const QString &lineColor, const QString &formula, const qreal &angle,
|
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula,
|
||||||
const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation,
|
initData.firstPointId, initData.angle, parent),
|
||||||
QGraphicsItem *parent)
|
secondPointId(initData.secondPointId)
|
||||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, angle, parent),
|
|
||||||
secondPointId(secondPointId)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -113,15 +103,22 @@ VToolNormal* VToolNormal::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogNormal> dialogTool = dialog.objectCast<DialogNormal>();
|
QSharedPointer<DialogNormal> dialogTool = dialog.objectCast<DialogNormal>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
QString formula = dialogTool->GetFormula();
|
|
||||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
VToolNormalInitData initData;
|
||||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
initData.formula = dialogTool->GetFormula();
|
||||||
const QString typeLine = dialogTool->GetTypeLine();
|
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||||
const QString lineColor = dialogTool->GetLineColor();
|
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.angle = dialogTool->GetAngle();
|
||||||
const qreal angle = dialogTool->GetAngle();
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
VToolNormal *point = Create(0, formula, firstPointId, secondPointId, typeLine, lineColor, pointName, angle, 5, 10,
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
true, scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolNormal *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -132,65 +129,45 @@ VToolNormal* VToolNormal::Create(QSharedPointer<DialogTool> dialog, VMainGraphic
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param formula string with formula normal length.
|
|
||||||
* @param firstPointId id first line point.
|
|
||||||
* @param secondPointId id second line point.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param pointName point name.
|
|
||||||
* @param angle additional angle.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param showLabel show/hide label.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
*/
|
*/
|
||||||
VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, quint32 firstPointId, quint32 secondPointId,
|
VToolNormal* VToolNormal::Create(VToolNormalInitData initData)
|
||||||
const QString &typeLine, const QString &lineColor,
|
|
||||||
const QString &pointName, qreal angle, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||||
|
|
||||||
const qreal result = CheckFormula(_id, formula, data);
|
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||||
|
|
||||||
QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint),
|
QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint),
|
||||||
qApp->toPixel(result), angle);
|
qApp->toPixel(result), initData.angle);
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(fPoint, pointName, mx, my);
|
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddLine(firstPointId, id);
|
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddLine(firstPointId, id);
|
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::Normal, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Normal, initData.doc);
|
||||||
VToolNormal *point = new VToolNormal(doc, data, id, typeLine, lineColor, formula, angle, firstPointId,
|
VToolNormal *point = new VToolNormal(initData);
|
||||||
secondPointId, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||||
doc->IncrementReferens(firstPoint->getIdTool());
|
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||||
doc->IncrementReferens(secondPoint->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -44,6 +44,22 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolNormalInitData : public VToolLinePointInitData
|
||||||
|
{
|
||||||
|
VToolNormalInitData()
|
||||||
|
: VToolLinePointInitData(),
|
||||||
|
formula(),
|
||||||
|
firstPointId(NULL_ID),
|
||||||
|
secondPointId(NULL_ID),
|
||||||
|
angle(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formula;
|
||||||
|
quint32 firstPointId;
|
||||||
|
quint32 secondPointId;
|
||||||
|
qreal angle;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolNormal class tool for creation point on normal. Normal begin from first point of line.
|
* @brief The VToolNormal class tool for creation point on normal. Normal begin from first point of line.
|
||||||
*/
|
*/
|
||||||
|
@ -54,11 +70,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolNormal* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolNormal* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolNormal* Create(const quint32 _id, QString &formula, quint32 firstPointId,
|
static VToolNormal* Create(VToolNormalInitData initData);
|
||||||
quint32 secondPointId, const QString &typeLine, const QString &lineColor,
|
|
||||||
const QString &pointName, const qreal angle, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length,
|
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length,
|
||||||
const qreal &angle = 0);
|
const qreal &angle = 0);
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
|
@ -85,10 +97,7 @@ private:
|
||||||
/** @brief secondPointId id second line point. */
|
/** @brief secondPointId id second line point. */
|
||||||
quint32 secondPointId;
|
quint32 secondPointId;
|
||||||
|
|
||||||
VToolNormal(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolNormal(const VToolNormalInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QString &lineColor,
|
|
||||||
const QString &formula, const qreal &angle, const quint32 &firstPointId, const quint32 &secondPointId,
|
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLNORMAL_H
|
#endif // VTOOLNORMAL_H
|
||||||
|
|
|
@ -61,26 +61,16 @@ const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolShoulderPoint constructor.
|
* @brief VToolShoulderPoint constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param formula string with formula length.
|
|
||||||
* @param p1Line id first line point.
|
|
||||||
* @param p2Line id second line point.
|
|
||||||
* @param pShoulder id shoulder point.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolShoulderPoint::VToolShoulderPoint(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
VToolShoulderPoint::VToolShoulderPoint(const VToolShoulderPointInitData &initData, QGraphicsItem * parent)
|
||||||
const QString &typeLine,
|
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula,
|
||||||
const QString &lineColor, const QString &formula, const quint32 &p1Line,
|
initData.p1Line, 0, parent),
|
||||||
const quint32 &p2Line, const quint32 &pShoulder, const Source &typeCreation,
|
p2Line(initData.p2Line),
|
||||||
QGraphicsItem * parent)
|
pShoulder(initData.pShoulder)
|
||||||
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, p1Line, 0, parent), p2Line(p2Line),
|
|
||||||
pShoulder(pShoulder)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -162,15 +152,22 @@ VToolShoulderPoint* VToolShoulderPoint::Create(QSharedPointer<DialogTool> dialog
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogShoulderPoint> dialogTool = dialog.objectCast<DialogShoulderPoint>();
|
QSharedPointer<DialogShoulderPoint> dialogTool = dialog.objectCast<DialogShoulderPoint>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
QString formula = dialogTool->GetFormula();
|
|
||||||
const quint32 p1Line = dialogTool->GetP1Line();
|
VToolShoulderPointInitData initData;
|
||||||
const quint32 p2Line = dialogTool->GetP2Line();
|
initData.formula = dialogTool->GetFormula();
|
||||||
const quint32 pShoulder = dialogTool->GetP3();
|
initData.p1Line = dialogTool->GetP1Line();
|
||||||
const QString typeLine = dialogTool->GetTypeLine();
|
initData.p2Line = dialogTool->GetP2Line();
|
||||||
const QString lineColor = dialogTool->GetLineColor();
|
initData.pShoulder = dialogTool->GetP3();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
VToolShoulderPoint * point = Create(0, formula, p1Line, p2Line, pShoulder, typeLine, lineColor, pointName, 5,
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
10, true, scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolShoulderPoint * point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -181,72 +178,51 @@ VToolShoulderPoint* VToolShoulderPoint::Create(QSharedPointer<DialogTool> dialog
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param formula string with formula length.
|
|
||||||
* @param p1Line id first line point.
|
|
||||||
* @param p2Line id second line point.
|
|
||||||
* @param pShoulder id shoulder point.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param pointName point name.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param showLabel show/hide label.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @return the created tool
|
* @return the created tool
|
||||||
*/
|
*/
|
||||||
VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formula, quint32 p1Line, quint32 p2Line,
|
VToolShoulderPoint* VToolShoulderPoint::Create(VToolShoulderPointInitData &initData)
|
||||||
quint32 pShoulder, const QString &typeLine, const QString &lineColor,
|
|
||||||
const QString &pointName, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(p1Line);
|
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.p1Line);
|
||||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(p2Line);
|
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.p2Line);
|
||||||
const QSharedPointer<VPointF> shoulderPoint = data->GeometricObject<VPointF>(pShoulder);
|
const QSharedPointer<VPointF> shoulderPoint = initData.data->GeometricObject<VPointF>(initData.pShoulder);
|
||||||
|
|
||||||
const qreal result = CheckFormula(_id, formula, data);
|
const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
|
||||||
|
|
||||||
QPointF fPoint = VToolShoulderPoint::FindPoint(static_cast<QPointF>(*firstPoint),
|
QPointF fPoint = VToolShoulderPoint::FindPoint(static_cast<QPointF>(*firstPoint),
|
||||||
static_cast<QPointF>(*secondPoint),
|
static_cast<QPointF>(*secondPoint),
|
||||||
static_cast<QPointF>(*shoulderPoint), qApp->toPixel(result));
|
static_cast<QPointF>(*shoulderPoint), qApp->toPixel(result));
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(fPoint, pointName, mx, my);
|
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddLine(p1Line, id);
|
initData.data->AddLine(initData.p1Line, initData.id);
|
||||||
data->AddLine(p2Line, id);
|
initData.data->AddLine(initData.p2Line, initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddLine(p1Line, id);
|
initData.data->AddLine(initData.p1Line, initData.id);
|
||||||
data->AddLine(p2Line, id);
|
initData.data->AddLine(initData.p2Line, initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::ShoulderPoint, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::ShoulderPoint, initData.doc);
|
||||||
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, lineColor, formula,
|
VToolShoulderPoint *point = new VToolShoulderPoint(initData);
|
||||||
p1Line, p2Line, pShoulder,
|
initData.scene->addItem(point);
|
||||||
typeCreation);
|
InitToolConnections(initData.scene, point);
|
||||||
scene->addItem(point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
InitToolConnections(scene, point);
|
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||||
doc->IncrementReferens(firstPoint->getIdTool());
|
initData.doc->IncrementReferens(shoulderPoint->getIdTool());
|
||||||
doc->IncrementReferens(secondPoint->getIdTool());
|
|
||||||
doc->IncrementReferens(shoulderPoint->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -44,6 +44,22 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolShoulderPointInitData : public VToolLinePointInitData
|
||||||
|
{
|
||||||
|
VToolShoulderPointInitData()
|
||||||
|
: VToolLinePointInitData(),
|
||||||
|
formula(),
|
||||||
|
p1Line(NULL_ID),
|
||||||
|
p2Line(NULL_ID),
|
||||||
|
pShoulder(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString formula;
|
||||||
|
quint32 p1Line;
|
||||||
|
quint32 p2Line;
|
||||||
|
quint32 pShoulder;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolShoulderPoint class tool for creation point on shoulder. This tool for special situation, when you
|
* @brief The VToolShoulderPoint class tool for creation point on shoulder. This tool for special situation, when you
|
||||||
* want find point along line, but have only length from another point (shoulder).
|
* want find point along line, but have only length from another point (shoulder).
|
||||||
|
@ -57,12 +73,7 @@ public:
|
||||||
const qreal &length);
|
const qreal &length);
|
||||||
static VToolShoulderPoint* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolShoulderPoint* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolShoulderPoint* Create(const quint32 _id, QString &formula, quint32 p1Line, quint32 p2Line,
|
static VToolShoulderPoint* Create(VToolShoulderPointInitData &initData);
|
||||||
quint32 pShoulder, const QString &typeLine, const QString &lineColor,
|
|
||||||
const QString &pointName, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::ShoulderPoint) };
|
enum { Type = UserType + static_cast<int>(Tool::ShoulderPoint) };
|
||||||
|
@ -95,9 +106,7 @@ private:
|
||||||
/** @brief pShoulder id shoulder line point. */
|
/** @brief pShoulder id shoulder line point. */
|
||||||
quint32 pShoulder;
|
quint32 pShoulder;
|
||||||
|
|
||||||
VToolShoulderPoint(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolShoulderPoint(const VToolShoulderPointInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QString &lineColor, const QString &formula, const quint32 &p1Line, const quint32 &p2Line,
|
|
||||||
const quint32 &pShoulder, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLSHOULDERPOINT_H
|
#endif // VTOOLSHOULDERPOINT_H
|
||||||
|
|
|
@ -73,21 +73,17 @@ const QString VToolBasePoint::ToolType = QStringLiteral("single");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolBasePoint constructor.
|
* @brief VToolBasePoint constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolBasePoint::VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolBasePoint::VToolBasePoint (const VToolBasePointInitData &initData, QGraphicsItem * parent )
|
||||||
const QString &namePP, QGraphicsItem * parent )
|
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent), namePP(initData.nameActivPP)
|
||||||
:VToolSinglePoint(doc, data, id, parent), namePP(namePP)
|
|
||||||
{
|
{
|
||||||
m_baseColor = Qt::red;
|
m_baseColor = Qt::red;
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
m_namePoint->setBrush(Qt::black);
|
m_namePoint->setBrush(Qt::black);
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -104,33 +100,31 @@ void VToolBasePoint::setDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolBasePoint *VToolBasePoint::Create(quint32 _id, const QString &nameActivPP, VPointF *point,
|
VToolBasePoint *VToolBasePoint::Create(VToolBasePointInitData initData)
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
SCASSERT(point != nullptr)
|
VPointF *point = new VPointF(initData.x, initData.y, initData.name, initData.mx, initData.my);
|
||||||
|
point->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
quint32 id = _id;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = data->AddGObject(point);
|
initData.id = initData.data->AddGObject(point);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, point);
|
initData.data->UpdateGObject(initData.id, point);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::BasePoint, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::BasePoint, initData.doc);
|
||||||
VToolBasePoint *spoint = new VToolBasePoint(doc, data, id, typeCreation, nameActivPP);
|
VToolBasePoint *spoint = new VToolBasePoint(initData);
|
||||||
scene->addItem(spoint);
|
initData.scene->addItem(spoint);
|
||||||
InitToolConnections(scene, spoint);
|
InitToolConnections(initData.scene, spoint);
|
||||||
VAbstractPattern::AddTool(id, spoint);
|
VAbstractPattern::AddTool(initData.id, spoint);
|
||||||
return spoint;
|
return spoint;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -45,6 +45,20 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolBasePointInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolBasePointInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
nameActivPP(),
|
||||||
|
x(10),
|
||||||
|
y(10)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString nameActivPP;
|
||||||
|
qreal x;
|
||||||
|
qreal y;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolBasePoint class tool for creation pattern base point. Only base point can move. All object
|
* @brief The VToolBasePoint class tool for creation pattern base point. Only base point can move. All object
|
||||||
* pattern peace depend on base point.
|
* pattern peace depend on base point.
|
||||||
|
@ -55,9 +69,7 @@ class VToolBasePoint : public VToolSinglePoint
|
||||||
public:
|
public:
|
||||||
virtual ~VToolBasePoint() =default;
|
virtual ~VToolBasePoint() =default;
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolBasePoint *Create(quint32 _id, const QString &nameActivPP, VPointF *point,
|
static VToolBasePoint *Create(VToolBasePointInitData initData);
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::BasePoint)};
|
enum { Type = UserType + static_cast<int>(Tool::BasePoint)};
|
||||||
|
@ -94,8 +106,7 @@ private:
|
||||||
|
|
||||||
QString namePP;
|
QString namePP;
|
||||||
|
|
||||||
VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolBasePoint (const VToolBasePointInitData &initData, QGraphicsItem * parent = nullptr );
|
||||||
const QString &namePP, QGraphicsItem * parent = nullptr );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLBASEPOINT_H
|
#endif // VTOOLBASEPOINT_H
|
||||||
|
|
|
@ -58,24 +58,17 @@ const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolLineIntersect constructor.
|
* @brief VToolLineIntersect constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param p1Line1 id first point first line.
|
|
||||||
* @param p2Line1 id second point first line.
|
|
||||||
* @param p1Line2 id first point second line.
|
|
||||||
* @param p2Line2 id second point second line.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolLineIntersect::VToolLineIntersect(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
VToolLineIntersect::VToolLineIntersect(const VToolLineIntersectInitData &initData, QGraphicsItem *parent)
|
||||||
const quint32 &p1Line1, const quint32 &p2Line1, const quint32 &p1Line2,
|
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||||
const quint32 &p2Line2, const Source &typeCreation,
|
p1Line1(initData.p1Line1Id),
|
||||||
QGraphicsItem *parent)
|
p2Line1(initData.p2Line1Id),
|
||||||
:VToolSinglePoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
|
p1Line2(initData.p1Line2Id),
|
||||||
p2Line2(p2Line2)
|
p2Line2(initData.p2Line2Id)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -86,7 +79,7 @@ void VToolLineIntersect::setDialog()
|
||||||
{
|
{
|
||||||
SCASSERT(not m_dialog.isNull())
|
SCASSERT(not m_dialog.isNull())
|
||||||
QSharedPointer<DialogLineIntersect> dialogTool = m_dialog.objectCast<DialogLineIntersect>();
|
QSharedPointer<DialogLineIntersect> dialogTool = m_dialog.objectCast<DialogLineIntersect>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||||
dialogTool->SetP1Line1(p1Line1);
|
dialogTool->SetP1Line1(p1Line1);
|
||||||
dialogTool->SetP2Line1(p2Line1);
|
dialogTool->SetP2Line1(p2Line1);
|
||||||
|
@ -110,13 +103,20 @@ VToolLineIntersect* VToolLineIntersect::Create(QSharedPointer<DialogTool> dialog
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogLineIntersect> dialogTool = dialog.objectCast<DialogLineIntersect>();
|
QSharedPointer<DialogLineIntersect> dialogTool = dialog.objectCast<DialogLineIntersect>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 p1Line1Id = dialogTool->GetP1Line1();
|
|
||||||
const quint32 p2Line1Id = dialogTool->GetP2Line1();
|
VToolLineIntersectInitData initData;
|
||||||
const quint32 p1Line2Id = dialogTool->GetP1Line2();
|
initData.p1Line1Id = dialogTool->GetP1Line1();
|
||||||
const quint32 p2Line2Id = dialogTool->GetP2Line2();
|
initData.p2Line1Id = dialogTool->GetP2Line1();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.p1Line2Id = dialogTool->GetP1Line2();
|
||||||
VToolLineIntersect* point = Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, true, scene,
|
initData.p2Line2Id = dialogTool->GetP2Line2();
|
||||||
doc, data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolLineIntersect* point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -127,31 +127,15 @@ VToolLineIntersect* VToolLineIntersect::Create(QSharedPointer<DialogTool> dialog
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param p1Line1Id id first point first line.
|
|
||||||
* @param p2Line1Id id second point first line.
|
|
||||||
* @param p1Line2Id id first point second line.
|
|
||||||
* @param p2Line2Id id second point second line.
|
|
||||||
* @param pointName point name.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @return the created tool
|
* @return the created tool
|
||||||
*/
|
*/
|
||||||
VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, quint32 p1Line1Id, quint32 p2Line1Id,
|
VToolLineIntersect* VToolLineIntersect::Create(VToolLineIntersectInitData initData)
|
||||||
quint32 p1Line2Id, quint32 p2Line2Id, const QString &pointName,
|
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> p1Line1 = data->GeometricObject<VPointF>(p1Line1Id);
|
const QSharedPointer<VPointF> p1Line1 = initData.data->GeometricObject<VPointF>(initData.p1Line1Id);
|
||||||
const QSharedPointer<VPointF> p2Line1 = data->GeometricObject<VPointF>(p2Line1Id);
|
const QSharedPointer<VPointF> p2Line1 = initData.data->GeometricObject<VPointF>(initData.p2Line1Id);
|
||||||
const QSharedPointer<VPointF> p1Line2 = data->GeometricObject<VPointF>(p1Line2Id);
|
const QSharedPointer<VPointF> p1Line2 = initData.data->GeometricObject<VPointF>(initData.p1Line2Id);
|
||||||
const QSharedPointer<VPointF> p2Line2 = data->GeometricObject<VPointF>(p2Line2Id);
|
const QSharedPointer<VPointF> p2Line2 = initData.data->GeometricObject<VPointF>(initData.p2Line2Id);
|
||||||
|
|
||||||
QLineF line1(static_cast<QPointF>(*p1Line1), static_cast<QPointF>(*p2Line1));
|
QLineF line1(static_cast<QPointF>(*p1Line1), static_cast<QPointF>(*p2Line1));
|
||||||
QLineF line2(static_cast<QPointF>(*p1Line2), static_cast<QPointF>(*p2Line2));
|
QLineF line2(static_cast<QPointF>(*p1Line2), static_cast<QPointF>(*p2Line2));
|
||||||
|
@ -159,44 +143,41 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, quint32 p1Line
|
||||||
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
|
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
|
||||||
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
|
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
|
||||||
{
|
{
|
||||||
quint32 id = _id;
|
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||||
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
VPointF *p = new VPointF(fPoint, pointName, mx, my);
|
if (initData.typeCreation == Source::FromGui)
|
||||||
p->SetShowLabel(showLabel);
|
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddLine(p1Line1Id, id);
|
initData.data->AddLine(initData.p1Line1Id, initData.id);
|
||||||
data->AddLine(id, p2Line1Id);
|
initData.data->AddLine(initData.id, initData.p2Line1Id);
|
||||||
data->AddLine(p1Line2Id, id);
|
initData.data->AddLine(initData.p1Line2Id, initData.id);
|
||||||
data->AddLine(id, p2Line2Id);
|
initData.data->AddLine(initData.id, initData.p2Line2Id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddLine(p1Line1Id, id);
|
initData.data->AddLine(initData.p1Line1Id, initData.id);
|
||||||
data->AddLine(id, p2Line1Id);
|
initData.data->AddLine(initData.id, initData.p2Line1Id);
|
||||||
data->AddLine(p1Line2Id, id);
|
initData.data->AddLine(initData.p1Line2Id, initData.id);
|
||||||
data->AddLine(id, p2Line2Id);
|
initData.data->AddLine(initData.id, initData.p2Line2Id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::LineIntersect, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::LineIntersect, initData.doc);
|
||||||
VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id,
|
VToolLineIntersect *point = new VToolLineIntersect(initData);
|
||||||
p2Line2Id, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(p1Line1->getIdTool());
|
||||||
doc->IncrementReferens(p1Line1->getIdTool());
|
initData.doc->IncrementReferens(p2Line1->getIdTool());
|
||||||
doc->IncrementReferens(p2Line1->getIdTool());
|
initData.doc->IncrementReferens(p1Line2->getIdTool());
|
||||||
doc->IncrementReferens(p1Line2->getIdTool());
|
initData.doc->IncrementReferens(p2Line2->getIdTool());
|
||||||
doc->IncrementReferens(p2Line2->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,22 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolLineIntersectInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolLineIntersectInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
p1Line1Id(NULL_ID),
|
||||||
|
p2Line1Id(NULL_ID),
|
||||||
|
p1Line2Id(NULL_ID),
|
||||||
|
p2Line2Id(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 p1Line1Id;
|
||||||
|
quint32 p2Line1Id;
|
||||||
|
quint32 p1Line2Id;
|
||||||
|
quint32 p2Line2Id;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolLineIntersect class help find point intersection lines.
|
* @brief The VToolLineIntersect class help find point intersection lines.
|
||||||
*/
|
*/
|
||||||
|
@ -53,11 +69,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolLineIntersect *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolLineIntersect *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolLineIntersect *Create(const quint32 _id, quint32 p1Line1Id, quint32 p2Line1Id,
|
static VToolLineIntersect *Create(VToolLineIntersectInitData initData);
|
||||||
quint32 p1Line2Id, quint32 p2Line2Id, const QString &pointName,
|
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc,
|
|
||||||
VContainer *data, const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::LineIntersect)};
|
enum { Type = UserType + static_cast<int>(Tool::LineIntersect)};
|
||||||
|
@ -104,9 +116,7 @@ private:
|
||||||
/** @brief p2Line2 id second point second line.*/
|
/** @brief p2Line2 id second point second line.*/
|
||||||
quint32 p2Line2;
|
quint32 p2Line2;
|
||||||
|
|
||||||
VToolLineIntersect(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &p1Line1,
|
VToolLineIntersect(const VToolLineIntersectInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const quint32 &p2Line1, const quint32 &p1Line2, const quint32 &p2Line2,
|
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLLINEINTERSECT_H
|
#endif // VTOOLLINEINTERSECT_H
|
||||||
|
|
|
@ -55,13 +55,14 @@ template <class T> class QSharedPointer;
|
||||||
const QString VToolPointFromArcAndTangent::ToolType = QStringLiteral("pointFromArcAndTangent");
|
const QString VToolPointFromArcAndTangent::ToolType = QStringLiteral("pointFromArcAndTangent");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPointFromArcAndTangent::VToolPointFromArcAndTangent(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
VToolPointFromArcAndTangent::VToolPointFromArcAndTangent(const VToolPointFromArcAndTangentInitData &initData,
|
||||||
quint32 arcId, quint32 tangentPointId,
|
|
||||||
CrossCirclesPoint crossPoint, const Source &typeCreation,
|
|
||||||
QGraphicsItem *parent)
|
QGraphicsItem *parent)
|
||||||
:VToolSinglePoint(doc, data, id, parent), arcId(arcId), tangentPointId(tangentPointId), crossPoint(crossPoint)
|
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||||
|
arcId(initData.arcId),
|
||||||
|
tangentPointId(initData.tangentPointId),
|
||||||
|
crossPoint(initData.crossPoint)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -85,12 +86,19 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(QSharedPointer<
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogPointFromArcAndTangent> dialogTool = dialog.objectCast<DialogPointFromArcAndTangent>();
|
QSharedPointer<DialogPointFromArcAndTangent> dialogTool = dialog.objectCast<DialogPointFromArcAndTangent>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 arcId = dialogTool->GetArcId();
|
|
||||||
const quint32 tangentPointId = dialogTool->GetTangentPointId();
|
VToolPointFromArcAndTangentInitData initData;
|
||||||
const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint();
|
initData.arcId = dialogTool->GetArcId();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.tangentPointId = dialogTool->GetTangentPointId();
|
||||||
VToolPointFromArcAndTangent *point = Create(0, pointName, arcId, tangentPointId, pType, 5, 10, true, scene, doc,
|
initData.crossPoint = dialogTool->GetCrossCirclesPoint();
|
||||||
data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolPointFromArcAndTangent *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -99,45 +107,39 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(QSharedPointer<
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(const quint32 _id, const QString &pointName,
|
VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(VToolPointFromArcAndTangentInitData initData)
|
||||||
quint32 arcId, quint32 tangentPointId,
|
|
||||||
CrossCirclesPoint crossPoint, qreal mx,
|
|
||||||
qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const VArc arc = *data->GeometricObject<VArc>(arcId);
|
const VArc arc = *initData.data->GeometricObject<VArc>(initData.arcId);
|
||||||
const VPointF tPoint = *data->GeometricObject<VPointF>(tangentPointId);
|
const VPointF tPoint = *initData.data->GeometricObject<VPointF>(initData.tangentPointId);
|
||||||
|
|
||||||
const QPointF point = VToolPointFromArcAndTangent::FindPoint(static_cast<QPointF>(tPoint), &arc, crossPoint);
|
const QPointF point = VToolPointFromArcAndTangent::FindPoint(static_cast<QPointF>(tPoint), &arc,
|
||||||
quint32 id = _id;
|
initData.crossPoint);
|
||||||
|
|
||||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::PointFromArcAndTangent, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::PointFromArcAndTangent, initData.doc);
|
||||||
VToolPointFromArcAndTangent *point = new VToolPointFromArcAndTangent(doc, data, id, arcId, tangentPointId,
|
VToolPointFromArcAndTangent *point = new VToolPointFromArcAndTangent(initData);
|
||||||
crossPoint, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(arc.getIdTool());
|
||||||
doc->IncrementReferens(arc.getIdTool());
|
initData.doc->IncrementReferens(tPoint.getIdTool());
|
||||||
doc->IncrementReferens(tPoint.getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -44,6 +44,20 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolPointFromArcAndTangentInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolPointFromArcAndTangentInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
arcId(NULL_ID),
|
||||||
|
tangentPointId(NULL_ID),
|
||||||
|
crossPoint(CrossCirclesPoint::FirstPoint)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 arcId;
|
||||||
|
quint32 tangentPointId;
|
||||||
|
CrossCirclesPoint crossPoint;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolPointFromArcAndTangent : public VToolSinglePoint
|
class VToolPointFromArcAndTangent : public VToolSinglePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -51,11 +65,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolPointFromArcAndTangent *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolPointFromArcAndTangent *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolPointFromArcAndTangent *Create(const quint32 _id, const QString &pointName, quint32 arcId,
|
static VToolPointFromArcAndTangent *Create(VToolPointFromArcAndTangentInitData initData);
|
||||||
quint32 tangentPointId, CrossCirclesPoint crossPoint, qreal mx,
|
|
||||||
qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static QPointF FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType);
|
static QPointF FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType);
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
@ -89,9 +99,7 @@ private:
|
||||||
quint32 tangentPointId;
|
quint32 tangentPointId;
|
||||||
CrossCirclesPoint crossPoint;
|
CrossCirclesPoint crossPoint;
|
||||||
|
|
||||||
VToolPointFromArcAndTangent(VAbstractPattern *doc, VContainer *data, const quint32 &id, quint32 arcId,
|
VToolPointFromArcAndTangent(const VToolPointFromArcAndTangentInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
quint32 tangentPointId, CrossCirclesPoint crossPoint, const Source &typeCreation,
|
|
||||||
QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLPOINTFROMARCANDTANGENT_H
|
#endif // VTOOLPOINTFROMARCANDTANGENT_H
|
||||||
|
|
|
@ -56,15 +56,15 @@ template <class T> class QSharedPointer;
|
||||||
const QString VToolPointFromCircleAndTangent::ToolType = QStringLiteral("pointFromCircleAndTangent");
|
const QString VToolPointFromCircleAndTangent::ToolType = QStringLiteral("pointFromCircleAndTangent");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPointFromCircleAndTangent::VToolPointFromCircleAndTangent(VAbstractPattern *doc, VContainer *data,
|
VToolPointFromCircleAndTangent::VToolPointFromCircleAndTangent(const VToolPointFromCircleAndTangentInitData &initData,
|
||||||
const quint32 &id,
|
QGraphicsItem *parent)
|
||||||
quint32 circleCenterId, const QString &circleRadius,
|
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||||
quint32 tangentPointId, CrossCirclesPoint crossPoint,
|
circleCenterId(initData.circleCenterId),
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
tangentPointId(initData.tangentPointId),
|
||||||
:VToolSinglePoint(doc, data, id, parent), circleCenterId(circleCenterId), tangentPointId(tangentPointId),
|
circleRadius(initData.circleRadius),
|
||||||
circleRadius(circleRadius), crossPoint(crossPoint)
|
crossPoint(initData.crossPoint)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -89,13 +89,20 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(QSharedPo
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogPointFromCircleAndTangent> dialogTool = dialog.objectCast<DialogPointFromCircleAndTangent>();
|
QSharedPointer<DialogPointFromCircleAndTangent> dialogTool = dialog.objectCast<DialogPointFromCircleAndTangent>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 circleCenterId = dialogTool->GetCircleCenterId();
|
|
||||||
QString circleRadius = dialogTool->GetCircleRadius();
|
VToolPointFromCircleAndTangentInitData initData;
|
||||||
const quint32 tangentPointId = dialogTool->GetTangentPointId();
|
initData.circleCenterId = dialogTool->GetCircleCenterId();
|
||||||
const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint();
|
initData.circleRadius = dialogTool->GetCircleRadius();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.tangentPointId = dialogTool->GetTangentPointId();
|
||||||
VToolPointFromCircleAndTangent *point = Create(0, pointName, circleCenterId, circleRadius, tangentPointId, pType,
|
initData.crossPoint = dialogTool->GetCrossCirclesPoint();
|
||||||
5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolPointFromCircleAndTangent *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -104,51 +111,41 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(QSharedPo
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const quint32 _id, const QString &pointName,
|
VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(VToolPointFromCircleAndTangentInitData &initData)
|
||||||
quint32 circleCenterId, QString &circleRadius,
|
|
||||||
quint32 tangentPointId,
|
|
||||||
CrossCirclesPoint crossPoint, qreal mx,
|
|
||||||
qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const qreal radius = qApp->toPixel(CheckFormula(_id, circleRadius, data));
|
const qreal radius = qApp->toPixel(CheckFormula(initData.id, initData.circleRadius, initData.data));
|
||||||
const VPointF cPoint = *data->GeometricObject<VPointF>(circleCenterId);
|
const VPointF cPoint = *initData.data->GeometricObject<VPointF>(initData.circleCenterId);
|
||||||
const VPointF tPoint = *data->GeometricObject<VPointF>(tangentPointId);
|
const VPointF tPoint = *initData.data->GeometricObject<VPointF>(initData.tangentPointId);
|
||||||
|
|
||||||
const QPointF point = VToolPointFromCircleAndTangent::FindPoint(static_cast<QPointF>(tPoint),
|
const QPointF point = VToolPointFromCircleAndTangent::FindPoint(static_cast<QPointF>(tPoint),
|
||||||
static_cast<QPointF>(cPoint), radius, crossPoint);
|
static_cast<QPointF>(cPoint), radius,
|
||||||
quint32 id = _id;
|
initData.crossPoint);
|
||||||
|
|
||||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::PointFromCircleAndTangent, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::PointFromCircleAndTangent, initData.doc);
|
||||||
VToolPointFromCircleAndTangent *point = new VToolPointFromCircleAndTangent(doc, data, id, circleCenterId,
|
VToolPointFromCircleAndTangent *point = new VToolPointFromCircleAndTangent(initData);
|
||||||
circleRadius, tangentPointId,
|
initData.scene->addItem(point);
|
||||||
crossPoint, typeCreation);
|
InitToolConnections(initData.scene, point);
|
||||||
scene->addItem(point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
InitToolConnections(scene, point);
|
initData.doc->IncrementReferens(cPoint.getIdTool());
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(tPoint.getIdTool());
|
||||||
doc->IncrementReferens(cPoint.getIdTool());
|
|
||||||
doc->IncrementReferens(tPoint.getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -45,6 +45,22 @@
|
||||||
class VFormula;
|
class VFormula;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolPointFromCircleAndTangentInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolPointFromCircleAndTangentInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
circleCenterId(NULL_ID),
|
||||||
|
circleRadius("0"),
|
||||||
|
tangentPointId(NULL_ID),
|
||||||
|
crossPoint(CrossCirclesPoint::FirstPoint)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 circleCenterId;
|
||||||
|
QString circleRadius;
|
||||||
|
quint32 tangentPointId;
|
||||||
|
CrossCirclesPoint crossPoint;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolPointFromCircleAndTangent : public VToolSinglePoint
|
class VToolPointFromCircleAndTangent : public VToolSinglePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -52,11 +68,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolPointFromCircleAndTangent *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolPointFromCircleAndTangent *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolPointFromCircleAndTangent *Create(const quint32 _id, const QString &pointName,
|
static VToolPointFromCircleAndTangent *Create(VToolPointFromCircleAndTangentInitData &initData);
|
||||||
quint32 circleCenterId, QString &circleRadius, quint32 tangentPointId,
|
|
||||||
CrossCirclesPoint crossPoint, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static QPointF FindPoint(const QPointF &p, const QPointF ¢er, qreal radius, const CrossCirclesPoint crossPoint);
|
static QPointF FindPoint(const QPointF &p, const QPointF ¢er, qreal radius, const CrossCirclesPoint crossPoint);
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
@ -94,9 +106,8 @@ private:
|
||||||
QString circleRadius;
|
QString circleRadius;
|
||||||
CrossCirclesPoint crossPoint;
|
CrossCirclesPoint crossPoint;
|
||||||
|
|
||||||
VToolPointFromCircleAndTangent(VAbstractPattern *doc, VContainer *data, const quint32 &id, quint32 circleCenterId,
|
VToolPointFromCircleAndTangent(const VToolPointFromCircleAndTangentInitData &initData,
|
||||||
const QString &circleRadius, quint32 tangentPointId, CrossCirclesPoint crossPoint,
|
QGraphicsItem *parent = nullptr);
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLPOINTFROMCIRCLEANDTANGENT_H
|
#endif // VTOOLPOINTFROMCIRCLEANDTANGENT_H
|
||||||
|
|
|
@ -63,24 +63,17 @@ const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolPointOfContact constructor.
|
* @brief VToolPointOfContact constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param radius string with formula radius arc.
|
|
||||||
* @param center id center arc point.
|
|
||||||
* @param firstPointId id first line point.
|
|
||||||
* @param secondPointId id second line point.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolPointOfContact::VToolPointOfContact(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
VToolPointOfContact::VToolPointOfContact(const VToolPointOfContactInitData &initData, QGraphicsItem *parent)
|
||||||
const QString &radius, const quint32 ¢er,
|
: VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
arcRadius(initData.radius),
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
center(initData.center),
|
||||||
: VToolSinglePoint(doc, data, id, parent), arcRadius(radius), center(center), firstPointId(firstPointId),
|
firstPointId(initData.firstPointId),
|
||||||
secondPointId(secondPointId)
|
secondPointId(initData.secondPointId)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -170,13 +163,20 @@ VToolPointOfContact* VToolPointOfContact::Create(QSharedPointer<DialogTool> dial
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogPointOfContact> dialogTool = dialog.objectCast<DialogPointOfContact>();
|
QSharedPointer<DialogPointOfContact> dialogTool = dialog.objectCast<DialogPointOfContact>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
QString radius = dialogTool->getRadius();
|
|
||||||
const quint32 center = dialogTool->getCenter();
|
VToolPointOfContactInitData initData;
|
||||||
const quint32 firstPointId = dialogTool->GetFirstPoint();
|
initData.radius = dialogTool->getRadius();
|
||||||
const quint32 secondPointId = dialogTool->GetSecondPoint();
|
initData.center = dialogTool->getCenter();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.firstPointId = dialogTool->GetFirstPoint();
|
||||||
VToolPointOfContact *point = Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, true, scene,
|
initData.secondPointId = dialogTool->GetSecondPoint();
|
||||||
doc, data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolPointOfContact *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -187,69 +187,51 @@ VToolPointOfContact* VToolPointOfContact::Create(QSharedPointer<DialogTool> dial
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param radius string with formula radius arc.
|
|
||||||
* @param center id center arc point.
|
|
||||||
* @param firstPointId id first line point.
|
|
||||||
* @param secondPointId id second line point.
|
|
||||||
* @param pointName point name.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
*/
|
*/
|
||||||
VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &radius, quint32 center,
|
VToolPointOfContact* VToolPointOfContact::Create(VToolPointOfContactInitData &initData)
|
||||||
quint32 firstPointId, quint32 secondPointId,
|
|
||||||
const QString &pointName, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> centerP = data->GeometricObject<VPointF>(center);
|
const QSharedPointer<VPointF> centerP = initData.data->GeometricObject<VPointF>(initData.center);
|
||||||
const QSharedPointer<VPointF> firstP = data->GeometricObject<VPointF>(firstPointId);
|
const QSharedPointer<VPointF> firstP = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||||
const QSharedPointer<VPointF> secondP = data->GeometricObject<VPointF>(secondPointId);
|
const QSharedPointer<VPointF> secondP = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||||
|
|
||||||
const qreal result = CheckFormula(_id, radius, data);
|
const qreal result = CheckFormula(initData.id, initData.radius, initData.data);
|
||||||
|
|
||||||
QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), static_cast<QPointF>(*centerP),
|
QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), static_cast<QPointF>(*centerP),
|
||||||
static_cast<QPointF>(*firstP), static_cast<QPointF>(*secondP));
|
static_cast<QPointF>(*firstP), static_cast<QPointF>(*secondP));
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(fPoint, pointName, mx, my);
|
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
data->AddLine(firstPointId, id);
|
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||||
data->AddLine(secondPointId, id);
|
initData.data->AddLine(initData.secondPointId, initData.id);
|
||||||
data->AddLine(center, id);
|
initData.data->AddLine(initData.center, initData.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
data->AddLine(firstPointId, id);
|
initData.data->AddLine(initData.firstPointId, initData.id);
|
||||||
data->AddLine(secondPointId, id);
|
initData.data->AddLine(initData.secondPointId, initData.id);
|
||||||
data->AddLine(center, id);
|
initData.data->AddLine(initData.center, initData.id);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::PointOfContact, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::PointOfContact, initData.doc);
|
||||||
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center,
|
VToolPointOfContact *point = new VToolPointOfContact(initData);
|
||||||
firstPointId, secondPointId, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(centerP->getIdTool());
|
||||||
doc->IncrementReferens(centerP->getIdTool());
|
initData.doc->IncrementReferens(firstP->getIdTool());
|
||||||
doc->IncrementReferens(firstP->getIdTool());
|
initData.doc->IncrementReferens(secondP->getIdTool());
|
||||||
doc->IncrementReferens(secondP->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -45,6 +45,22 @@
|
||||||
class VFormula;
|
class VFormula;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolPointOfContactInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolPointOfContactInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
radius("0"),
|
||||||
|
center(NULL_ID),
|
||||||
|
firstPointId(NULL_ID),
|
||||||
|
secondPointId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString radius;
|
||||||
|
quint32 center;
|
||||||
|
quint32 firstPointId;
|
||||||
|
quint32 secondPointId;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolPointOfContact class tool for creation point intersection line and arc.
|
* @brief The VToolPointOfContact class tool for creation point intersection line and arc.
|
||||||
*/
|
*/
|
||||||
|
@ -57,12 +73,7 @@ public:
|
||||||
const QPointF &secondPoint);
|
const QPointF &secondPoint);
|
||||||
static VToolPointOfContact* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolPointOfContact* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolPointOfContact* Create(const quint32 _id, QString &radius, quint32 center,
|
static VToolPointOfContact* Create(VToolPointOfContactInitData &initData);
|
||||||
quint32 firstPointId, quint32 secondPointId,
|
|
||||||
const QString &pointName,
|
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc,
|
|
||||||
VContainer *data, const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::PointOfContact) };
|
enum { Type = UserType + static_cast<int>(Tool::PointOfContact) };
|
||||||
|
@ -108,9 +119,7 @@ private:
|
||||||
/** @brief secondPointId id second line point. */
|
/** @brief secondPointId id second line point. */
|
||||||
quint32 secondPointId;
|
quint32 secondPointId;
|
||||||
|
|
||||||
VToolPointOfContact(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &radius,
|
VToolPointOfContact(const VToolPointOfContactInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const quint32 ¢er, const quint32 &firstPointId, const quint32 &secondPointId,
|
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLPOINTOFCONTACT_H
|
#endif // VTOOLPOINTOFCONTACT_H
|
||||||
|
|
|
@ -56,20 +56,16 @@ const QString VToolPointOfIntersection::ToolType = QStringLiteral("pointOfInters
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolPointOfIntersection constructor.
|
* @brief VToolPointOfIntersection constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param firstPointId id first line point.
|
|
||||||
* @param secondPointId id second line point.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolPointOfIntersection::VToolPointOfIntersection(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
VToolPointOfIntersection::VToolPointOfIntersection(const VToolPointOfIntersectionInitData &initData,
|
||||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
QGraphicsItem *parent)
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||||
:VToolSinglePoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId)
|
firstPointId(initData.firstPointId),
|
||||||
|
secondPointId(initData.secondPointId)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -102,11 +98,18 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(QSharedPointer<Dialog
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogPointOfIntersection> dialogTool = dialog.objectCast<DialogPointOfIntersection>();
|
QSharedPointer<DialogPointOfIntersection> dialogTool = dialog.objectCast<DialogPointOfIntersection>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
|
||||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
VToolPointOfIntersectionInitData initData;
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||||
VToolPointOfIntersection *point = Create(0, pointName, firstPointId, secondPointId, 5, 10, true, scene, doc,
|
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||||
data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolPointOfIntersection *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -117,57 +120,41 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(QSharedPointer<Dialog
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param pointName point name.
|
|
||||||
* @param firstPointId id first line point.
|
|
||||||
* @param secondPointId id second line point.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @return the created tool
|
* @return the created tool
|
||||||
*/
|
*/
|
||||||
VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, const QString &pointName,
|
VToolPointOfIntersection *VToolPointOfIntersection::Create(VToolPointOfIntersectionInitData initData)
|
||||||
quint32 firstPointId, quint32 secondPointId, qreal mx,
|
|
||||||
qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||||
|
|
||||||
QPointF point(firstPoint->x(), secondPoint->y());
|
QPointF point(firstPoint->x(), secondPoint->y());
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::PointOfIntersection, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::PointOfIntersection, initData.doc);
|
||||||
VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId,
|
VToolPointOfIntersection *point = new VToolPointOfIntersection(initData);
|
||||||
secondPointId, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||||
doc->IncrementReferens(firstPoint->getIdTool());
|
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||||
doc->IncrementReferens(secondPoint->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -43,6 +43,18 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolPointOfIntersectionInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolPointOfIntersectionInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
firstPointId(NULL_ID),
|
||||||
|
secondPointId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 firstPointId;
|
||||||
|
quint32 secondPointId;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolPointOfIntersection class tool for creation point intersection two lines.
|
* @brief The VToolPointOfIntersection class tool for creation point intersection two lines.
|
||||||
*/
|
*/
|
||||||
|
@ -53,10 +65,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolPointOfIntersection *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolPointOfIntersection *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolPointOfIntersection *Create(const quint32 _id, const QString &pointName, quint32 firstPointId,
|
static VToolPointOfIntersection *Create(VToolPointOfIntersectionInitData initData);
|
||||||
quint32 secondPointId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
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::PointOfIntersection) };
|
enum { Type = UserType + static_cast<int>(Tool::PointOfIntersection) };
|
||||||
|
@ -88,9 +97,7 @@ private:
|
||||||
/** @brief secondPointId id second line point. */
|
/** @brief secondPointId id second line point. */
|
||||||
quint32 secondPointId;
|
quint32 secondPointId;
|
||||||
|
|
||||||
VToolPointOfIntersection(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstPointId,
|
VToolPointOfIntersection(const VToolPointOfIntersectionInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const quint32 &secondPointId, const Source &typeCreation,
|
|
||||||
QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLPOINTOFINTERSECTION_H
|
#endif // VTOOLPOINTOFINTERSECTION_H
|
||||||
|
|
|
@ -55,13 +55,14 @@ template <class T> class QSharedPointer;
|
||||||
const QString VToolPointOfIntersectionArcs::ToolType = QStringLiteral("pointOfIntersectionArcs");
|
const QString VToolPointOfIntersectionArcs::ToolType = QStringLiteral("pointOfIntersectionArcs");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(const VToolPointOfIntersectionArcsInitData &initData,
|
||||||
const quint32 &firstArcId, const quint32 &secondArcId,
|
|
||||||
CrossCirclesPoint pType, const Source &typeCreation,
|
|
||||||
QGraphicsItem *parent)
|
QGraphicsItem *parent)
|
||||||
:VToolSinglePoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType)
|
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||||
|
firstArcId(initData.firstArcId),
|
||||||
|
secondArcId(initData.secondArcId),
|
||||||
|
crossPoint(initData.pType)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -85,12 +86,19 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(QSharedPointe
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogPointOfIntersectionArcs> dialogTool = dialog.objectCast<DialogPointOfIntersectionArcs>();
|
QSharedPointer<DialogPointOfIntersectionArcs> dialogTool = dialog.objectCast<DialogPointOfIntersectionArcs>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 firstArcId = dialogTool->GetFirstArcId();
|
|
||||||
const quint32 secondArcId = dialogTool->GetSecondArcId();
|
VToolPointOfIntersectionArcsInitData initData;
|
||||||
const CrossCirclesPoint pType = dialogTool->GetCrossArcPoint();
|
initData.firstArcId = dialogTool->GetFirstArcId();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.secondArcId = dialogTool->GetSecondArcId();
|
||||||
VToolPointOfIntersectionArcs *point = Create(0, pointName, firstArcId, secondArcId, pType, 5, 10, true, scene, doc,
|
initData.pType = dialogTool->GetCrossArcPoint();
|
||||||
data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolPointOfIntersectionArcs *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -99,45 +107,38 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(QSharedPointe
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 _id, const QString &pointName,
|
VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(VToolPointOfIntersectionArcsInitData initData)
|
||||||
quint32 firstArcId, quint32 secondArcId,
|
|
||||||
CrossCirclesPoint pType, qreal mx, qreal my,
|
|
||||||
bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VArc> firstArc = data->GeometricObject<VArc>(firstArcId);
|
const QSharedPointer<VArc> firstArc = initData.data->GeometricObject<VArc>(initData.firstArcId);
|
||||||
const QSharedPointer<VArc> secondArc = data->GeometricObject<VArc>(secondArcId);
|
const QSharedPointer<VArc> secondArc = initData.data->GeometricObject<VArc>(initData.secondArcId);
|
||||||
|
|
||||||
const QPointF point = FindPoint(firstArc.data(), secondArc.data(), pType);
|
const QPointF point = FindPoint(firstArc.data(), secondArc.data(), initData.pType);
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::PointOfIntersectionArcs, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::PointOfIntersectionArcs, initData.doc);
|
||||||
VToolPointOfIntersectionArcs *point = new VToolPointOfIntersectionArcs(doc, data, id, firstArcId,
|
VToolPointOfIntersectionArcs *point = new VToolPointOfIntersectionArcs(initData);
|
||||||
secondArcId, pType, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(firstArc->getIdTool());
|
||||||
doc->IncrementReferens(firstArc->getIdTool());
|
initData.doc->IncrementReferens(secondArc->getIdTool());
|
||||||
doc->IncrementReferens(secondArc->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -44,6 +44,20 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolPointOfIntersectionArcsInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolPointOfIntersectionArcsInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
firstArcId(NULL_ID),
|
||||||
|
secondArcId(NULL_ID),
|
||||||
|
pType(CrossCirclesPoint::FirstPoint)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 firstArcId;
|
||||||
|
quint32 secondArcId;
|
||||||
|
CrossCirclesPoint pType;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolPointOfIntersectionArcs : public VToolSinglePoint
|
class VToolPointOfIntersectionArcs : public VToolSinglePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -52,11 +66,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolPointOfIntersectionArcs *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolPointOfIntersectionArcs *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, quint32 firstArcId,
|
static VToolPointOfIntersectionArcs *Create(VToolPointOfIntersectionArcsInitData initData);
|
||||||
quint32 secondArcId, CrossCirclesPoint pType,
|
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossCirclesPoint pType);
|
static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossCirclesPoint pType);
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
@ -94,8 +104,7 @@ private:
|
||||||
|
|
||||||
CrossCirclesPoint crossPoint;
|
CrossCirclesPoint crossPoint;
|
||||||
|
|
||||||
VToolPointOfIntersectionArcs(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstArcId,
|
VToolPointOfIntersectionArcs(const VToolPointOfIntersectionArcsInitData &initData,
|
||||||
const quint32 &secondArcId, CrossCirclesPoint pType, const Source &typeCreation,
|
|
||||||
QGraphicsItem * parent = nullptr);
|
QGraphicsItem * parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,19 +56,16 @@ template <class T> class QSharedPointer;
|
||||||
const QString VToolPointOfIntersectionCircles::ToolType = QStringLiteral("pointOfIntersectionCircles");
|
const QString VToolPointOfIntersectionCircles::ToolType = QStringLiteral("pointOfIntersectionCircles");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPointOfIntersectionCircles::VToolPointOfIntersectionCircles(VAbstractPattern *doc, VContainer *data,
|
VToolPointOfIntersectionCircles::VToolPointOfIntersectionCircles(
|
||||||
const quint32 &id,
|
const VToolPointOfIntersectionCirclesInitData &initData, QGraphicsItem *parent)
|
||||||
quint32 firstCircleCenterId,
|
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||||
quint32 secondCircleCenterId,
|
firstCircleCenterId(initData.firstCircleCenterId),
|
||||||
const QString &firstCircleRadius,
|
secondCircleCenterId(initData.secondCircleCenterId),
|
||||||
const QString &secondCircleRadius,
|
firstCircleRadius(initData.firstCircleRadius),
|
||||||
CrossCirclesPoint crossPoint,
|
secondCircleRadius(initData.secondCircleRadius),
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
crossPoint(initData.crossPoint)
|
||||||
:VToolSinglePoint(doc, data, id, parent), firstCircleCenterId(firstCircleCenterId),
|
|
||||||
secondCircleCenterId(secondCircleCenterId), firstCircleRadius(firstCircleRadius),
|
|
||||||
secondCircleRadius(secondCircleRadius), crossPoint(crossPoint)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -93,18 +90,23 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(QShared
|
||||||
VAbstractPattern *doc, VContainer *data)
|
VAbstractPattern *doc, VContainer *data)
|
||||||
{
|
{
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogPointOfIntersectionCircles> dialogTool =
|
QSharedPointer<DialogPointOfIntersectionCircles> dialogTool = dialog.objectCast<DialogPointOfIntersectionCircles>();
|
||||||
dialog.objectCast<DialogPointOfIntersectionCircles>();
|
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 firstCircleCenterId = dialogTool->GetFirstCircleCenterId();
|
|
||||||
const quint32 secondCircleCenterId = dialogTool->GetSecondCircleCenterId();
|
VToolPointOfIntersectionCirclesInitData initData;
|
||||||
QString firstCircleRadius = dialogTool->GetFirstCircleRadius();
|
initData.firstCircleCenterId = dialogTool->GetFirstCircleCenterId();
|
||||||
QString secondCircleRadius = dialogTool->GetSecondCircleRadius();
|
initData.secondCircleCenterId = dialogTool->GetSecondCircleCenterId();
|
||||||
const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint();
|
initData.firstCircleRadius = dialogTool->GetFirstCircleRadius();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.secondCircleRadius = dialogTool->GetSecondCircleRadius();
|
||||||
VToolPointOfIntersectionCircles *point = Create(0, pointName, firstCircleCenterId, secondCircleCenterId,
|
initData.crossPoint = dialogTool->GetCrossCirclesPoint();
|
||||||
firstCircleRadius, secondCircleRadius, pType, 5, 10, true, scene,
|
initData.name = dialogTool->getPointName();
|
||||||
doc, data, Document::FullParse, Source::FromGui);
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolPointOfIntersectionCircles *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -113,57 +115,43 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(QShared
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(const quint32 _id, const QString &pointName,
|
VToolPointOfIntersectionCircles *
|
||||||
quint32 firstCircleCenterId,
|
VToolPointOfIntersectionCircles::Create(VToolPointOfIntersectionCirclesInitData &initData)
|
||||||
quint32 secondCircleCenterId,
|
|
||||||
QString &firstCircleRadius,
|
|
||||||
QString &secondCircleRadius,
|
|
||||||
CrossCirclesPoint crossPoint, qreal mx,
|
|
||||||
qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const qreal calcC1Radius = qApp->toPixel(CheckFormula(_id, firstCircleRadius, data));
|
const qreal calcC1Radius = qApp->toPixel(CheckFormula(initData.id, initData.firstCircleRadius, initData.data));
|
||||||
const qreal calcC2Radius = qApp->toPixel(CheckFormula(_id, secondCircleRadius, data));
|
const qreal calcC2Radius = qApp->toPixel(CheckFormula(initData.id, initData.secondCircleRadius, initData.data));
|
||||||
|
|
||||||
const VPointF c1Point = *data->GeometricObject<VPointF>(firstCircleCenterId);
|
const VPointF c1Point = *initData.data->GeometricObject<VPointF>(initData.firstCircleCenterId);
|
||||||
const VPointF c2Point = *data->GeometricObject<VPointF>(secondCircleCenterId);
|
const VPointF c2Point = *initData.data->GeometricObject<VPointF>(initData.secondCircleCenterId);
|
||||||
|
|
||||||
const QPointF point = FindPoint(static_cast<QPointF>(c1Point), static_cast<QPointF>(c2Point), calcC1Radius,
|
const QPointF point = FindPoint(static_cast<QPointF>(c1Point), static_cast<QPointF>(c2Point), calcC1Radius,
|
||||||
calcC2Radius, crossPoint);
|
calcC2Radius, initData.crossPoint);
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::PointOfIntersectionCircles, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::PointOfIntersectionCircles, initData.doc);
|
||||||
VToolPointOfIntersectionCircles *point = new VToolPointOfIntersectionCircles(doc, data, id, firstCircleCenterId,
|
VToolPointOfIntersectionCircles *point = new VToolPointOfIntersectionCircles(initData);
|
||||||
secondCircleCenterId,
|
initData.scene->addItem(point);
|
||||||
firstCircleRadius,
|
InitToolConnections(initData.scene, point);
|
||||||
secondCircleRadius, crossPoint,
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
typeCreation);
|
initData.doc->IncrementReferens(c1Point.getIdTool());
|
||||||
scene->addItem(point);
|
initData.doc->IncrementReferens(c2Point.getIdTool());
|
||||||
InitToolConnections(scene, point);
|
|
||||||
VAbstractPattern::AddTool(id, point);
|
|
||||||
doc->IncrementReferens(c1Point.getIdTool());
|
|
||||||
doc->IncrementReferens(c2Point.getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -45,6 +45,24 @@
|
||||||
class VFormula;
|
class VFormula;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolPointOfIntersectionCirclesInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolPointOfIntersectionCirclesInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
firstCircleCenterId(NULL_ID),
|
||||||
|
secondCircleCenterId(NULL_ID),
|
||||||
|
firstCircleRadius("0"),
|
||||||
|
secondCircleRadius("0"),
|
||||||
|
crossPoint(CrossCirclesPoint::FirstPoint)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 firstCircleCenterId;
|
||||||
|
quint32 secondCircleCenterId;
|
||||||
|
QString firstCircleRadius;
|
||||||
|
QString secondCircleRadius;
|
||||||
|
CrossCirclesPoint crossPoint;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolPointOfIntersectionCircles : public VToolSinglePoint
|
class VToolPointOfIntersectionCircles : public VToolSinglePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -52,13 +70,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolPointOfIntersectionCircles *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolPointOfIntersectionCircles *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolPointOfIntersectionCircles *Create(const quint32 _id, const QString &pointName,
|
static VToolPointOfIntersectionCircles *Create(VToolPointOfIntersectionCirclesInitData &initData);
|
||||||
quint32 firstCircleCenterId, quint32 secondCircleCenterId,
|
|
||||||
QString &firstCircleRadius, QString &secondCircleRadius,
|
|
||||||
CrossCirclesPoint crossPoint,
|
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static QPointF FindPoint(const QPointF &c1Point, const QPointF &c2Point, qreal c1Radius, qreal c2Radius,
|
static QPointF FindPoint(const QPointF &c1Point, const QPointF &c2Point, qreal c1Radius, qreal c2Radius,
|
||||||
const CrossCirclesPoint crossPoint);
|
const CrossCirclesPoint crossPoint);
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
|
@ -103,10 +115,7 @@ private:
|
||||||
|
|
||||||
CrossCirclesPoint crossPoint;
|
CrossCirclesPoint crossPoint;
|
||||||
|
|
||||||
VToolPointOfIntersectionCircles(VAbstractPattern *doc, VContainer *data, const quint32 &id, const
|
VToolPointOfIntersectionCircles(const VToolPointOfIntersectionCirclesInitData &initData,
|
||||||
quint32 firstCircleCenterId, quint32 secondCircleCenterId,
|
|
||||||
const QString &firstCircleRadius, const QString &secondCircleRadius,
|
|
||||||
CrossCirclesPoint crossPoint, const Source &typeCreation,
|
|
||||||
QGraphicsItem * parent = nullptr);
|
QGraphicsItem * parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -55,18 +55,15 @@ template <class T> class QSharedPointer;
|
||||||
const QString VToolPointOfIntersectionCurves::ToolType = QStringLiteral("pointOfIntersectionCurves");
|
const QString VToolPointOfIntersectionCurves::ToolType = QStringLiteral("pointOfIntersectionCurves");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPointOfIntersectionCurves::VToolPointOfIntersectionCurves(VAbstractPattern *doc, VContainer *data,
|
VToolPointOfIntersectionCurves::VToolPointOfIntersectionCurves(const VToolPointOfIntersectionCurvesInitData &initData,
|
||||||
const quint32 &id, const quint32 firstCurveId,
|
|
||||||
quint32 secondCurveId, VCrossCurvesPoint vCrossPoint,
|
|
||||||
HCrossCurvesPoint hCrossPoint, const Source &typeCreation,
|
|
||||||
QGraphicsItem *parent)
|
QGraphicsItem *parent)
|
||||||
:VToolSinglePoint(doc, data, id, parent),
|
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||||
firstCurveId(firstCurveId),
|
firstCurveId(initData.firstCurveId),
|
||||||
secondCurveId(secondCurveId),
|
secondCurveId(initData.secondCurveId),
|
||||||
vCrossPoint(vCrossPoint),
|
vCrossPoint(initData.vCrossPoint),
|
||||||
hCrossPoint(hCrossPoint)
|
hCrossPoint(initData.hCrossPoint)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -91,13 +88,20 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(QSharedPo
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogPointOfIntersectionCurves> dialogTool = dialog.objectCast<DialogPointOfIntersectionCurves>();
|
QSharedPointer<DialogPointOfIntersectionCurves> dialogTool = dialog.objectCast<DialogPointOfIntersectionCurves>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 firstCurveId = dialogTool->GetFirstCurveId();
|
|
||||||
const quint32 secondCurveId = dialogTool->GetSecondCurveId();
|
VToolPointOfIntersectionCurvesInitData initData;
|
||||||
const VCrossCurvesPoint vCrossPoint = dialogTool->GetVCrossPoint();
|
initData.firstCurveId = dialogTool->GetFirstCurveId();
|
||||||
const HCrossCurvesPoint hCrossPoint = dialogTool->GetHCrossPoint();
|
initData.secondCurveId = dialogTool->GetSecondCurveId();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.vCrossPoint = dialogTool->GetVCrossPoint();
|
||||||
VToolPointOfIntersectionCurves *point = Create(0, pointName, firstCurveId, secondCurveId, vCrossPoint, hCrossPoint,
|
initData.hCrossPoint = dialogTool->GetHCrossPoint();
|
||||||
5, 10, true, scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolPointOfIntersectionCurves *point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -106,49 +110,39 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(QSharedPo
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(const quint32 _id, const QString &pointName,
|
VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(VToolPointOfIntersectionCurvesInitData initData)
|
||||||
quint32 firstCurveId, quint32 secondCurveId,
|
|
||||||
VCrossCurvesPoint vCrossPoint,
|
|
||||||
HCrossCurvesPoint hCrossPoint,qreal mx,
|
|
||||||
qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data,
|
|
||||||
const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
auto curve1 = data->GeometricObject<VAbstractCurve>(firstCurveId);
|
auto curve1 = initData.data->GeometricObject<VAbstractCurve>(initData.firstCurveId);
|
||||||
auto curve2 = data->GeometricObject<VAbstractCurve>(secondCurveId);
|
auto curve2 = initData.data->GeometricObject<VAbstractCurve>(initData.secondCurveId);
|
||||||
|
|
||||||
const QPointF point = VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(),
|
const QPointF point = VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(),
|
||||||
vCrossPoint, hCrossPoint);
|
initData.vCrossPoint, initData.hCrossPoint);
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::PointOfIntersectionCurves, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::PointOfIntersectionCurves, initData.doc);
|
||||||
auto point = new VToolPointOfIntersectionCurves(doc, data, id, firstCurveId, secondCurveId, vCrossPoint,
|
auto point = new VToolPointOfIntersectionCurves(initData);
|
||||||
hCrossPoint, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(curve1->getIdTool());
|
||||||
doc->IncrementReferens(curve1->getIdTool());
|
initData.doc->IncrementReferens(curve2->getIdTool());
|
||||||
doc->IncrementReferens(curve2->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -45,6 +45,22 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolPointOfIntersectionCurvesInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolPointOfIntersectionCurvesInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
firstCurveId(NULL_ID),
|
||||||
|
secondCurveId(NULL_ID),
|
||||||
|
vCrossPoint(VCrossCurvesPoint::HighestPoint),
|
||||||
|
hCrossPoint(HCrossCurvesPoint::LeftmostPoint)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 firstCurveId;
|
||||||
|
quint32 secondCurveId;
|
||||||
|
VCrossCurvesPoint vCrossPoint;
|
||||||
|
HCrossCurvesPoint hCrossPoint;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolPointOfIntersectionCurves : public VToolSinglePoint
|
class VToolPointOfIntersectionCurves : public VToolSinglePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -52,12 +68,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolPointOfIntersectionCurves *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolPointOfIntersectionCurves *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolPointOfIntersectionCurves *Create(const quint32 _id, const QString &pointName,
|
static VToolPointOfIntersectionCurves *Create(VToolPointOfIntersectionCurvesInitData initData);
|
||||||
quint32 firstCurveId, quint32 secondCurveId,
|
|
||||||
VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint,
|
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
static QPointF FindPoint(const QVector<QPointF> &curve1Points, const QVector<QPointF> &curve2Points,
|
static QPointF FindPoint(const QVector<QPointF> &curve1Points, const QVector<QPointF> &curve2Points,
|
||||||
VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint);
|
VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint);
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
|
@ -97,10 +108,8 @@ private:
|
||||||
VCrossCurvesPoint vCrossPoint;
|
VCrossCurvesPoint vCrossPoint;
|
||||||
HCrossCurvesPoint hCrossPoint;
|
HCrossCurvesPoint hCrossPoint;
|
||||||
|
|
||||||
explicit VToolPointOfIntersectionCurves(VAbstractPattern *doc, VContainer *data, const quint32 &id, const
|
explicit VToolPointOfIntersectionCurves(const VToolPointOfIntersectionCurvesInitData &initData,
|
||||||
quint32 firstCurveId, quint32 secondCurveId,
|
QGraphicsItem *parent = nullptr);
|
||||||
VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint,
|
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLPOINTOFINTERSECTIONCURVES_H
|
#endif // VTOOLPOINTOFINTERSECTIONCURVES_H
|
||||||
|
|
|
@ -44,6 +44,22 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolSinglePointInitData : public VAbstractToolInitData
|
||||||
|
{
|
||||||
|
VToolSinglePointInitData()
|
||||||
|
: VAbstractToolInitData(),
|
||||||
|
name(),
|
||||||
|
mx(5),
|
||||||
|
my(10),
|
||||||
|
showLabel(true)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
qreal mx;
|
||||||
|
qreal my;
|
||||||
|
bool showLabel;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolSinglePoint class parent for all tools what create points.
|
* @brief The VToolSinglePoint class parent for all tools what create points.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -58,23 +58,17 @@ const QString VToolTriangle::ToolType = QStringLiteral("triangle");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolTriangle constructor.
|
* @brief VToolTriangle constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param axisP1Id id first axis point.
|
|
||||||
* @param axisP2Id id second axis point.
|
|
||||||
* @param firstPointId id first triangle point, what lies on the hypotenuse.
|
|
||||||
* @param secondPointId id second triangle point, what lies on the hypotenuse.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolTriangle::VToolTriangle(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id,
|
VToolTriangle::VToolTriangle(const VToolTriangleInitData &initData, QGraphicsItem *parent)
|
||||||
const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId,
|
:VToolSinglePoint(initData.doc, initData.data, initData.id, parent),
|
||||||
const Source &typeCreation, QGraphicsItem *parent)
|
axisP1Id(initData.axisP1Id),
|
||||||
:VToolSinglePoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId),
|
axisP2Id(initData.axisP2Id),
|
||||||
secondPointId(secondPointId)
|
firstPointId(initData.firstPointId),
|
||||||
|
secondPointId(initData.secondPointId)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -109,13 +103,20 @@ VToolTriangle* VToolTriangle::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogTriangle> dialogTool = dialog.objectCast<DialogTriangle>();
|
QSharedPointer<DialogTriangle> dialogTool = dialog.objectCast<DialogTriangle>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 axisP1Id = dialogTool->GetAxisP1Id();
|
|
||||||
const quint32 axisP2Id = dialogTool->GetAxisP2Id();
|
VToolTriangleInitData initData;
|
||||||
const quint32 firstPointId = dialogTool->GetFirstPointId();
|
initData.axisP1Id = dialogTool->GetAxisP1Id();
|
||||||
const quint32 secondPointId = dialogTool->GetSecondPointId();
|
initData.axisP2Id = dialogTool->GetAxisP2Id();
|
||||||
const QString pointName = dialogTool->getPointName();
|
initData.firstPointId = dialogTool->GetFirstPointId();
|
||||||
VToolTriangle* point = Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, true,
|
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||||
scene, doc, data, Document::FullParse, Source::FromGui);
|
initData.name = dialogTool->getPointName();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolTriangle* point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
{
|
{
|
||||||
point->m_dialog = dialogTool;
|
point->m_dialog = dialogTool;
|
||||||
|
@ -126,63 +127,46 @@ VToolTriangle* VToolTriangle::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param initData init data.
|
||||||
* @param pointName point name.
|
|
||||||
* @param axisP1Id id first axis point.
|
|
||||||
* @param axisP2Id id second axis point.
|
|
||||||
* @param firstPointId id first triangle point, what lies on the hypotenuse.
|
|
||||||
* @param secondPointId id second triangle point, what lies on the hypotenuse.
|
|
||||||
* @param mx label bias x axis.
|
|
||||||
* @param my label bias y axis.
|
|
||||||
* @param scene pointer to scene.
|
|
||||||
* @param doc dom document container.
|
|
||||||
* @param data container with variables.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @return the created tool
|
* @return the created tool
|
||||||
*/
|
*/
|
||||||
VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName, quint32 axisP1Id, quint32 axisP2Id,
|
VToolTriangle* VToolTriangle::Create(VToolTriangleInitData initData)
|
||||||
quint32 firstPointId, quint32 secondPointId, qreal mx, qreal my, bool showLabel,
|
|
||||||
VMainGraphicsScene *scene, VAbstractPattern *doc,
|
|
||||||
VContainer *data, const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> axisP1 = data->GeometricObject<VPointF>(axisP1Id);
|
const QSharedPointer<VPointF> axisP1 = initData.data->GeometricObject<VPointF>(initData.axisP1Id);
|
||||||
const QSharedPointer<VPointF> axisP2 = data->GeometricObject<VPointF>(axisP2Id);
|
const QSharedPointer<VPointF> axisP2 = initData.data->GeometricObject<VPointF>(initData.axisP2Id);
|
||||||
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
|
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||||
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
|
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||||
|
|
||||||
QPointF point = FindPoint(static_cast<QPointF>(*axisP1), static_cast<QPointF>(*axisP2),
|
QPointF point = FindPoint(static_cast<QPointF>(*axisP1), static_cast<QPointF>(*axisP2),
|
||||||
static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
||||||
quint32 id = _id;
|
|
||||||
|
|
||||||
VPointF *p = new VPointF(point, pointName, mx, my);
|
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = data->AddGObject(p);
|
initData.id = initData.data->AddGObject(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdateGObject(id, p);
|
initData.data->UpdateGObject(initData.id, p);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::Triangle, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Triangle, initData.doc);
|
||||||
VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId,
|
VToolTriangle *point = new VToolTriangle(initData);
|
||||||
secondPointId, typeCreation);
|
initData.scene->addItem(point);
|
||||||
scene->addItem(point);
|
InitToolConnections(initData.scene, point);
|
||||||
InitToolConnections(scene, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
VAbstractPattern::AddTool(id, point);
|
initData.doc->IncrementReferens(axisP1->getIdTool());
|
||||||
doc->IncrementReferens(axisP1->getIdTool());
|
initData.doc->IncrementReferens(axisP2->getIdTool());
|
||||||
doc->IncrementReferens(axisP2->getIdTool());
|
initData.doc->IncrementReferens(firstPoint->getIdTool());
|
||||||
doc->IncrementReferens(firstPoint->getIdTool());
|
initData.doc->IncrementReferens(secondPoint->getIdTool());
|
||||||
doc->IncrementReferens(secondPoint->getIdTool());
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -44,6 +44,22 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolTriangleInitData : public VToolSinglePointInitData
|
||||||
|
{
|
||||||
|
VToolTriangleInitData()
|
||||||
|
: VToolSinglePointInitData(),
|
||||||
|
axisP1Id(NULL_ID),
|
||||||
|
axisP2Id(NULL_ID),
|
||||||
|
firstPointId(NULL_ID),
|
||||||
|
secondPointId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 axisP1Id;
|
||||||
|
quint32 axisP2Id;
|
||||||
|
quint32 firstPointId;
|
||||||
|
quint32 secondPointId;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolTriangle class for tool that find point intersection two foots right triangle
|
* @brief The VToolTriangle class for tool that find point intersection two foots right triangle
|
||||||
* (triangle with 90 degree).
|
* (triangle with 90 degree).
|
||||||
|
@ -55,10 +71,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolTriangle *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolTriangle *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolTriangle *Create(const quint32 _id, const QString &pointName, quint32 axisP1Id,
|
static VToolTriangle *Create(VToolTriangleInitData initData);
|
||||||
quint32 axisP2Id, quint32 firstPointId, quint32 secondPointId,
|
|
||||||
qreal mx, qreal my, bool showLabel, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
|
||||||
VContainer *data, const Document &parse, const Source &typeCreation);
|
|
||||||
static QPointF FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint,
|
static QPointF FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint);
|
const QPointF &secondPoint);
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
|
@ -105,10 +118,7 @@ private:
|
||||||
/** @brief secondPointId id second triangle point, what lies on the hypotenuse. */
|
/** @brief secondPointId id second triangle point, what lies on the hypotenuse. */
|
||||||
quint32 secondPointId;
|
quint32 secondPointId;
|
||||||
|
|
||||||
VToolTriangle(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id,
|
VToolTriangle(const VToolTriangleInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const quint32 &axisP2Id,
|
|
||||||
const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation,
|
|
||||||
QGraphicsItem * parent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLTRIANGLE_H
|
#endif // VTOOLTRIANGLE_H
|
||||||
|
|
|
@ -57,33 +57,25 @@ template <class T> class QSharedPointer;
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolLine constructor.
|
* @brief VToolLine constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param firstPoint id first line point.
|
|
||||||
* @param secondPoint id second line point.
|
|
||||||
* @param typeLine line type.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint,
|
VToolLine::VToolLine(const VToolLineInitData &initData, QGraphicsItem *parent)
|
||||||
const QString &typeLine, const QString &lineColor, const Source &typeCreation,
|
:VDrawTool(initData.doc, initData.data, initData.id),
|
||||||
QGraphicsItem *parent)
|
|
||||||
:VDrawTool(doc, data, id),
|
|
||||||
QGraphicsLineItem(parent),
|
QGraphicsLineItem(parent),
|
||||||
firstPoint(firstPoint),
|
firstPoint(initData.firstPoint),
|
||||||
secondPoint(secondPoint),
|
secondPoint(initData.secondPoint),
|
||||||
lineColor(lineColor),
|
lineColor(initData.lineColor),
|
||||||
m_isHovered(false)
|
m_isHovered(false)
|
||||||
{
|
{
|
||||||
this->m_lineType = typeLine;
|
this->m_lineType = initData.typeLine;
|
||||||
//Line
|
//Line
|
||||||
RefreshGeometry();
|
RefreshGeometry();
|
||||||
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -115,13 +107,19 @@ VToolLine *VToolLine::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsSce
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
QSharedPointer<DialogLine> dialogTool = dialog.objectCast<DialogLine>();
|
QSharedPointer<DialogLine> dialogTool = dialog.objectCast<DialogLine>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 firstPoint = dialogTool->GetFirstPoint();
|
|
||||||
const quint32 secondPoint = dialogTool->GetSecondPoint();
|
|
||||||
const QString typeLine = dialogTool->GetTypeLine();
|
|
||||||
const QString lineColor = dialogTool->GetLineColor();
|
|
||||||
|
|
||||||
VToolLine *line = Create(0, firstPoint, secondPoint, typeLine, lineColor, scene, doc, data, Document::FullParse,
|
VToolLineInitData initData;
|
||||||
Source::FromGui);
|
initData.firstPoint = dialogTool->GetFirstPoint();
|
||||||
|
initData.secondPoint = dialogTool->GetSecondPoint();
|
||||||
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
VToolLine *line = Create(initData);
|
||||||
if (line != nullptr)
|
if (line != nullptr)
|
||||||
{
|
{
|
||||||
line->m_dialog = dialogTool;
|
line->m_dialog = dialogTool;
|
||||||
|
@ -142,45 +140,41 @@ VToolLine *VToolLine::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsSce
|
||||||
* @param parse parser file mode.
|
* @param parse parser file mode.
|
||||||
* @param typeCreation way we create this tool.
|
* @param typeCreation way we create this tool.
|
||||||
*/
|
*/
|
||||||
VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
|
VToolLine * VToolLine::Create(VToolLineInitData initData)
|
||||||
const QString &typeLine, const QString &lineColor, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
SCASSERT(scene != nullptr)
|
SCASSERT(initData.scene != nullptr)
|
||||||
SCASSERT(doc != nullptr)
|
SCASSERT(initData.doc != nullptr)
|
||||||
SCASSERT(data != nullptr)
|
SCASSERT(initData.data != nullptr)
|
||||||
quint32 id = _id;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = VContainer::getNextId();
|
initData.id = VContainer::getNextId();
|
||||||
data->AddLine(firstPoint, secondPoint);
|
initData.data->AddLine(initData.firstPoint, initData.secondPoint);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VContainer::UpdateId(id);
|
VContainer::UpdateId(initData.id);
|
||||||
data->AddLine(firstPoint, secondPoint);
|
initData.data->AddLine(initData.firstPoint, initData.secondPoint);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::Line, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Line, initData.doc);
|
||||||
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, lineColor, typeCreation);
|
VToolLine *line = new VToolLine(initData);
|
||||||
scene->addItem(line);
|
initData.scene->addItem(line);
|
||||||
InitDrawToolConnections(scene, line);
|
InitDrawToolConnections(initData.scene, line);
|
||||||
connect(scene, &VMainGraphicsScene::EnableLineItemSelection, line, &VToolLine::AllowSelecting);
|
connect(initData.scene, &VMainGraphicsScene::EnableLineItemSelection, line, &VToolLine::AllowSelecting);
|
||||||
connect(scene, &VMainGraphicsScene::EnableLineItemHover, line, &VToolLine::AllowHover);
|
connect(initData.scene, &VMainGraphicsScene::EnableLineItemHover, line, &VToolLine::AllowHover);
|
||||||
VAbstractPattern::AddTool(id, line);
|
VAbstractPattern::AddTool(initData.id, line);
|
||||||
|
|
||||||
const QSharedPointer<VPointF> first = data->GeometricObject<VPointF>(firstPoint);
|
const QSharedPointer<VPointF> first = initData.data->GeometricObject<VPointF>(initData.firstPoint);
|
||||||
const QSharedPointer<VPointF> second = data->GeometricObject<VPointF>(secondPoint);
|
const QSharedPointer<VPointF> second = initData.data->GeometricObject<VPointF>(initData.secondPoint);
|
||||||
|
|
||||||
doc->IncrementReferens(first->getIdTool());
|
initData.doc->IncrementReferens(first->getIdTool());
|
||||||
doc->IncrementReferens(second->getIdTool());
|
initData.doc->IncrementReferens(second->getIdTool());
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -45,6 +45,22 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
struct VToolLineInitData : public VAbstractToolInitData
|
||||||
|
{
|
||||||
|
VToolLineInitData()
|
||||||
|
: VAbstractToolInitData(),
|
||||||
|
firstPoint(NULL_ID),
|
||||||
|
secondPoint(NULL_ID),
|
||||||
|
typeLine(TypeLineLine),
|
||||||
|
lineColor(ColorBlack)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 firstPoint;
|
||||||
|
quint32 secondPoint;
|
||||||
|
QString typeLine;
|
||||||
|
QString lineColor;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolLine class tool for creation line.
|
* @brief The VToolLine class tool for creation line.
|
||||||
*/
|
*/
|
||||||
|
@ -55,10 +71,7 @@ public:
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolLine *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolLine *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolLine *Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
|
static VToolLine *Create(VToolLineInitData initData);
|
||||||
const QString &typeLine, const QString &lineColor, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation);
|
|
||||||
|
|
||||||
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::Line)};
|
enum { Type = UserType + static_cast<int>(Tool::Line)};
|
||||||
|
@ -118,9 +131,7 @@ private:
|
||||||
|
|
||||||
bool m_isHovered;
|
bool m_isHovered;
|
||||||
|
|
||||||
VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint,
|
VToolLine(const VToolLineInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
const QString &typeLine, const QString &lineColor, const Source &typeCreation,
|
|
||||||
QGraphicsItem * parent = nullptr);
|
|
||||||
|
|
||||||
void RefreshGeometry();
|
void RefreshGeometry();
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,6 +41,20 @@
|
||||||
|
|
||||||
enum class ParentType : bool {Scene, Item};
|
enum class ParentType : bool {Scene, Item};
|
||||||
|
|
||||||
|
struct VAbstractNodeInitData : public VAbstractToolInitData
|
||||||
|
{
|
||||||
|
VAbstractNodeInitData()
|
||||||
|
: VAbstractToolInitData(),
|
||||||
|
idObject(NULL_ID),
|
||||||
|
drawName(),
|
||||||
|
idTool(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 idObject;
|
||||||
|
QString drawName;
|
||||||
|
quint32 idTool;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VAbstractNode class parent class for all detail node.
|
* @brief The VAbstractNode class parent class for all detail node.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -44,57 +44,45 @@ const QString VNodeArc::ToolType = QStringLiteral("modeling");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VNodeArc constructor.
|
* @brief VNodeArc constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param idArc object id in containerArc.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param idTool tool id.
|
|
||||||
* @param qoParent QObject parent
|
* @param qoParent QObject parent
|
||||||
*/
|
*/
|
||||||
VNodeArc::VNodeArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation,
|
VNodeArc::VNodeArc(const VAbstractNodeInitData &initData, QObject *qoParent)
|
||||||
const QString &drawName, const quint32 &idTool, QObject *qoParent)
|
:VAbstractNode(initData.doc, initData.data, initData.id, initData.idObject, initData.drawName, initData.idTool,
|
||||||
:VAbstractNode(doc, data, id, idArc, drawName, idTool, qoParent)
|
qoParent)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param idArc object id in containerArc.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param idTool tool id.
|
|
||||||
*/
|
*/
|
||||||
void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc,
|
void VNodeArc::Create(VAbstractNodeInitData initData)
|
||||||
const Document &parse, const Source &typeCreation, const QString &drawName, const quint32 &idTool)
|
|
||||||
{
|
{
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::NodeArc, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::NodeArc, initData.doc);
|
||||||
VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeCreation, drawName, idTool, doc);
|
VNodeArc *arc = new VNodeArc(initData);
|
||||||
|
|
||||||
VAbstractPattern::AddTool(id, arc);
|
VAbstractPattern::AddTool(initData.id, arc);
|
||||||
if (idTool != NULL_ID)
|
if (initData.idTool != NULL_ID)
|
||||||
{
|
{
|
||||||
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
||||||
VDataTool *tool = VAbstractPattern::getTool(idTool);
|
VDataTool *tool = VAbstractPattern::getTool(initData.idTool);
|
||||||
SCASSERT(tool != nullptr)
|
SCASSERT(tool != nullptr)
|
||||||
arc->setParent(tool);// Adopted by a tool
|
arc->setParent(tool);// Adopted by a tool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Help to delete the node before each FullParse
|
// Help to delete the node before each FullParse
|
||||||
doc->AddToolOnRemove(arc);
|
initData.doc->AddToolOnRemove(arc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,7 @@ class VNodeArc :public VAbstractNode
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse,
|
static void Create(VAbstractNodeInitData initData);
|
||||||
const Source &typeCreation, const QString &drawName = QString(), const quint32 &idTool = 0);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||||
|
@ -63,8 +62,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VNodeArc)
|
Q_DISABLE_COPY(VNodeArc)
|
||||||
|
|
||||||
VNodeArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation,
|
VNodeArc(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr);
|
||||||
const QString &drawName = QString(), const quint32 &idTool = 0, QObject *qoParent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VNODEARC_H4
|
#endif // VNODEARC_H4
|
||||||
|
|
|
@ -42,32 +42,30 @@
|
||||||
const QString VNodeEllipticalArc::ToolType = QStringLiteral("modeling");
|
const QString VNodeEllipticalArc::ToolType = QStringLiteral("modeling");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VNodeEllipticalArc::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc,
|
void VNodeEllipticalArc::Create(VAbstractNodeInitData initData)
|
||||||
const Document &parse, const Source &typeCreation, const QString &drawName,
|
|
||||||
const quint32 &idTool)
|
|
||||||
{
|
{
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::NodeElArc, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::NodeElArc, initData.doc);
|
||||||
VNodeEllipticalArc *arc = new VNodeEllipticalArc(doc, data, id, idArc, typeCreation, drawName, idTool, doc);
|
VNodeEllipticalArc *arc = new VNodeEllipticalArc(initData);
|
||||||
|
|
||||||
VAbstractPattern::AddTool(id, arc);
|
VAbstractPattern::AddTool(initData.id, arc);
|
||||||
if (idTool != NULL_ID)
|
if (initData.idTool != NULL_ID)
|
||||||
{
|
{
|
||||||
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
||||||
VDataTool *tool = VAbstractPattern::getTool(idTool);
|
VDataTool *tool = VAbstractPattern::getTool(initData.idTool);
|
||||||
SCASSERT(tool != nullptr)
|
SCASSERT(tool != nullptr)
|
||||||
arc->setParent(tool);// Adopted by a tool
|
arc->setParent(tool);// Adopted by a tool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Help to delete the node before each FullParse
|
// Help to delete the node before each FullParse
|
||||||
doc->AddToolOnRemove(arc);
|
initData.doc->AddToolOnRemove(arc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,10 +106,9 @@ void VNodeEllipticalArc::AddToFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VNodeEllipticalArc::VNodeEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc,
|
VNodeEllipticalArc::VNodeEllipticalArc(const VAbstractNodeInitData &initData, QObject *qoParent)
|
||||||
const Source &typeCreation, const QString &drawName, const quint32 &idTool,
|
:VAbstractNode(initData.doc, initData.data, initData.id, initData.idObject, initData.drawName, initData.idTool,
|
||||||
QObject *qoParent)
|
qoParent)
|
||||||
:VAbstractNode(doc, data, id, idArc, drawName, idTool, qoParent)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,7 @@ class VNodeEllipticalArc :public VAbstractNode
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse,
|
static void Create(VAbstractNodeInitData initData);
|
||||||
const Source &typeCreation, const QString &drawName = QString(),
|
|
||||||
const quint32 &idTool = NULL_ID);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||||
|
@ -61,8 +59,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VNodeEllipticalArc)
|
Q_DISABLE_COPY(VNodeEllipticalArc)
|
||||||
|
|
||||||
VNodeEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation,
|
VNodeEllipticalArc(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr);
|
||||||
const QString &drawName = QString(), const quint32 &idTool = 0, QObject *qoParent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VNODEELLIPTICALARC_H
|
#endif // VNODEELLIPTICALARC_H
|
||||||
|
|
|
@ -60,18 +60,12 @@ const QString VNodePoint::ToolType = QStringLiteral("modeling");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VNodePoint constructor.
|
* @brief VNodePoint constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param idPoint object id in containerPoint.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param idTool tool id.
|
|
||||||
* @param qoParent QObject parent
|
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VNodePoint::VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation,
|
VNodePoint::VNodePoint(const VAbstractNodeInitData &initData, QObject *qoParent, QGraphicsItem *parent)
|
||||||
const QString &drawName, const quint32 &idTool, QObject *qoParent, QGraphicsItem *parent)
|
: VAbstractNode(initData.doc, initData.data, initData.id, initData.idObject, initData.drawName, initData.idTool,
|
||||||
: VAbstractNode(doc, data, id, idPoint, drawName, idTool, qoParent),
|
qoParent),
|
||||||
VScenePoint(parent)
|
VScenePoint(parent)
|
||||||
{
|
{
|
||||||
connect(m_namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VNodePoint::PointChoosed);
|
connect(m_namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VNodePoint::PointChoosed);
|
||||||
|
@ -81,56 +75,48 @@ VNodePoint::VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quin
|
||||||
{
|
{
|
||||||
emit ShowContextMenu(event);
|
emit ShowContextMenu(event);
|
||||||
});
|
});
|
||||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(initData.id));
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param idPoint object id in containerPoint.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param idTool tool id.
|
|
||||||
*/
|
*/
|
||||||
void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene,
|
void VNodePoint::Create(VAbstractNodeInitData initData)
|
||||||
quint32 id, quint32 idPoint, const Document &parse,
|
|
||||||
const Source &typeCreation, const QString &drawName, const quint32 &idTool)
|
|
||||||
{
|
{
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::NodePoint, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::NodePoint, initData.doc);
|
||||||
//TODO Need create garbage collector and remove all nodes, what we don't use.
|
//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.
|
//Better check garbage before each saving file. Check only modeling tags.
|
||||||
VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, drawName, idTool, doc);
|
VNodePoint *point = new VNodePoint(initData);
|
||||||
|
|
||||||
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VNodePoint::EnableToolMove);
|
connect(initData.scene, &VMainGraphicsScene::EnableToolMove, point, &VNodePoint::EnableToolMove);
|
||||||
connect(scene, &VMainGraphicsScene::EnablePointItemHover, point, &VNodePoint::AllowHover);
|
connect(initData.scene, &VMainGraphicsScene::EnablePointItemHover, point, &VNodePoint::AllowHover);
|
||||||
connect(scene, &VMainGraphicsScene::EnablePointItemSelection, point, &VNodePoint::AllowSelecting);
|
connect(initData.scene, &VMainGraphicsScene::EnablePointItemSelection, point, &VNodePoint::AllowSelecting);
|
||||||
connect(scene, &VMainGraphicsScene::EnableLabelItemHover, point, &VNodePoint::AllowLabelHover);
|
connect(initData.scene, &VMainGraphicsScene::EnableLabelItemHover, point, &VNodePoint::AllowLabelHover);
|
||||||
connect(scene, &VMainGraphicsScene::EnableLabelItemSelection, point, &VNodePoint::AllowLabelSelecting);
|
connect(initData.scene, &VMainGraphicsScene::EnableLabelItemSelection, point, &VNodePoint::AllowLabelSelecting);
|
||||||
VAbstractPattern::AddTool(id, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
if (idTool != NULL_ID)
|
if (initData.idTool != NULL_ID)
|
||||||
{
|
{
|
||||||
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
||||||
VDataTool *tool = VAbstractPattern::getTool(idTool);
|
VDataTool *tool = VAbstractPattern::getTool(initData.idTool);
|
||||||
SCASSERT(tool != nullptr)
|
SCASSERT(tool != nullptr)
|
||||||
point->setParent(tool);// Adopted by a tool
|
point->setParent(tool);// Adopted by a tool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Try to prevent memory leak
|
// Try to prevent memory leak
|
||||||
scene->addItem(point);// First adopted by scene
|
initData.scene->addItem(point);// First adopted by scene
|
||||||
point->hide();// If no one will use node, it will stay hidden
|
point->hide();// If no one will use node, it will stay hidden
|
||||||
point->SetParentType(ParentType::Scene);
|
point->SetParentType(ParentType::Scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,9 +50,7 @@ class VNodePoint: public VAbstractNode, public VScenePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene,
|
static void Create(VAbstractNodeInitData initData);
|
||||||
quint32 id, quint32 idPoint, const Document &parse,
|
|
||||||
const Source &typeCreation, const QString &drawName = QString(), const quint32 &idTool = 0);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
@ -86,9 +84,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VNodePoint)
|
Q_DISABLE_COPY(VNodePoint)
|
||||||
|
|
||||||
VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation,
|
VNodePoint(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr, QGraphicsItem *parent = nullptr);
|
||||||
const QString &drawName = QString(), const quint32 &idTool = 0, QObject *qoParent = nullptr,
|
|
||||||
QGraphicsItem * parent = nullptr );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VNODEPOINT_H
|
#endif // VNODEPOINT_H
|
||||||
|
|
|
@ -44,60 +44,47 @@ const QString VNodeSpline::ToolType = QStringLiteral("modelingSpline");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VNodeSpline constructor.
|
* @brief VNodeSpline constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param idSpline object id in containerSpline.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param idTool id node.
|
|
||||||
* @param qoParent QObject parent.
|
* @param qoParent QObject parent.
|
||||||
*/
|
*/
|
||||||
VNodeSpline::VNodeSpline(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
|
VNodeSpline::VNodeSpline(const VAbstractNodeInitData &initData, QObject *qoParent)
|
||||||
const Source &typeCreation, const QString &drawName, const quint32 &idTool, QObject *qoParent)
|
:VAbstractNode(initData.doc, initData.data, initData.id, initData.idObject, initData.drawName, initData.idTool,
|
||||||
:VAbstractNode(doc, data, id, idSpline, drawName, idTool, qoParent)
|
qoParent)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param idSpline object id in containerSpline.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param idTool id node.
|
|
||||||
* @return pointer to node.
|
* @return pointer to node.
|
||||||
*/
|
*/
|
||||||
VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, quint32 id,
|
VNodeSpline *VNodeSpline::Create(VAbstractNodeInitData initData)
|
||||||
quint32 idSpline, const Document &parse,
|
|
||||||
const Source &typeCreation, const QString &drawName, const quint32 &idTool)
|
|
||||||
{
|
{
|
||||||
VNodeSpline *spl = nullptr;
|
VNodeSpline *spl = nullptr;
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::NodeSpline, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::NodeSpline, initData.doc);
|
||||||
spl = new VNodeSpline(doc, data, id, idSpline, typeCreation, drawName, idTool, doc);
|
spl = new VNodeSpline(initData);
|
||||||
|
|
||||||
VAbstractPattern::AddTool(id, spl);
|
VAbstractPattern::AddTool(initData.id, spl);
|
||||||
if (idTool != NULL_ID)
|
if (initData.idTool != NULL_ID)
|
||||||
{
|
{
|
||||||
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
||||||
VDataTool *tool = VAbstractPattern::getTool(idTool);
|
VDataTool *tool = VAbstractPattern::getTool(initData.idTool);
|
||||||
SCASSERT(tool != nullptr)
|
SCASSERT(tool != nullptr)
|
||||||
spl->setParent(tool);// Adopted by a tool
|
spl->setParent(tool);// Adopted by a tool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Help to delete the node before each FullParse
|
// Help to delete the node before each FullParse
|
||||||
doc->AddToolOnRemove(spl);
|
initData.doc->AddToolOnRemove(spl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
return spl;
|
return spl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,7 @@ class VNodeSpline:public VAbstractNode
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static VNodeSpline *Create(VAbstractPattern *doc, VContainer *data, quint32 id,
|
static VNodeSpline *Create(VAbstractNodeInitData initData);
|
||||||
quint32 idSpline, const Document &parse,
|
|
||||||
const Source &typeCreation, const QString &drawName = QString(),
|
|
||||||
const quint32 &idTool = 0);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||||
|
@ -65,8 +62,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VNodeSpline)
|
Q_DISABLE_COPY(VNodeSpline)
|
||||||
|
|
||||||
VNodeSpline(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation,
|
VNodeSpline(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr);
|
||||||
const QString &drawName = QString(), const quint32 &idTool = 0, QObject *qoParent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VNODESPLINE_H
|
#endif // VNODESPLINE_H
|
||||||
|
|
|
@ -44,59 +44,45 @@ const QString VNodeSplinePath::ToolType = QStringLiteral("modelingPath");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VNodeSplinePath constructor.
|
* @brief VNodeSplinePath constructor.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param idSpline object id in containerSpline.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param idTool tool id.
|
|
||||||
* @param qoParent QObject parent.
|
* @param qoParent QObject parent.
|
||||||
*/
|
*/
|
||||||
VNodeSplinePath::VNodeSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
|
VNodeSplinePath::VNodeSplinePath(const VAbstractNodeInitData &initData, QObject *qoParent)
|
||||||
const Source &typeCreation, const QString &drawName, const quint32 &idTool,
|
:VAbstractNode(initData.doc, initData.data, initData.id, initData.idObject, initData.drawName, initData.idTool,
|
||||||
QObject *qoParent)
|
qoParent)
|
||||||
:VAbstractNode(doc, data, id, idSpline, drawName, idTool, qoParent)
|
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param doc dom document container.
|
* @param initData init data.
|
||||||
* @param data container with variables.
|
|
||||||
* @param id object id in container.
|
|
||||||
* @param idSpline object id in containerSpline.
|
|
||||||
* @param parse parser file mode.
|
|
||||||
* @param typeCreation way we create this tool.
|
|
||||||
* @param idTool tool id.
|
|
||||||
*/
|
*/
|
||||||
void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, quint32 id,
|
void VNodeSplinePath::Create(VAbstractNodeInitData initData)
|
||||||
quint32 idSpline, const Document &parse, const Source &typeCreation,
|
|
||||||
const QString &drawName, const quint32 &idTool)
|
|
||||||
{
|
{
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::NodeSplinePath, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::NodeSplinePath, initData.doc);
|
||||||
VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeCreation, drawName, idTool, doc);
|
VNodeSplinePath *splPath = new VNodeSplinePath(initData);
|
||||||
|
|
||||||
VAbstractPattern::AddTool(id, splPath);
|
VAbstractPattern::AddTool(initData.id, splPath);
|
||||||
if (idTool != NULL_ID)
|
if (initData.idTool != NULL_ID)
|
||||||
{
|
{
|
||||||
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
||||||
VDataTool *tool = VAbstractPattern::getTool(idTool);
|
VDataTool *tool = VAbstractPattern::getTool(initData.idTool);
|
||||||
SCASSERT(tool != nullptr)
|
SCASSERT(tool != nullptr)
|
||||||
splPath->setParent(tool);// Adopted by a tool
|
splPath->setParent(tool);// Adopted by a tool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Help to delete the node before each FullParse
|
// Help to delete the node before each FullParse
|
||||||
doc->AddToolOnRemove(splPath);
|
initData.doc->AddToolOnRemove(splPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,7 @@ class VNodeSplinePath : public VAbstractNode
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id,
|
static void Create(VAbstractNodeInitData initData);
|
||||||
quint32 idSpline, const Document &parse,
|
|
||||||
const Source &typeCreation, const QString &drawName = QString(), const quint32 &idTool = 0);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||||
|
@ -64,8 +62,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VNodeSplinePath)
|
Q_DISABLE_COPY(VNodeSplinePath)
|
||||||
|
|
||||||
VNodeSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation,
|
VNodeSplinePath(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr);
|
||||||
const QString &drawName = QString(), const quint32 &idTool = 0, QObject *qoParent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VNODESPLINEPATH_H
|
#endif // VNODESPLINEPATH_H
|
||||||
|
|
|
@ -40,55 +40,61 @@ VToolPiecePath *VToolPiecePath::Create(QSharedPointer<DialogTool> dialog, VMainG
|
||||||
SCASSERT(not dialog.isNull());
|
SCASSERT(not dialog.isNull());
|
||||||
QSharedPointer<DialogPiecePath> dialogTool = dialog.objectCast<DialogPiecePath>();
|
QSharedPointer<DialogPiecePath> dialogTool = dialog.objectCast<DialogPiecePath>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
VPiecePath path = dialogTool->GetPiecePath();
|
|
||||||
const quint32 pieceId = dialogTool->GetPieceId();
|
|
||||||
qApp->getUndoStack()->beginMacro("add path");
|
|
||||||
path.SetNodes(PrepareNodes(path, scene, doc, data));
|
|
||||||
|
|
||||||
VToolPiecePath *pathTool = Create(0, path, pieceId, scene, doc, data, Document::FullParse, Source::FromGui);
|
VToolPiecePathInitData initData;
|
||||||
|
initData.path = dialogTool->GetPiecePath();
|
||||||
|
initData.idObject = dialogTool->GetPieceId();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
qApp->getUndoStack()->beginMacro("add path");
|
||||||
|
initData.path.SetNodes(PrepareNodes(initData.path, scene, doc, data));
|
||||||
|
|
||||||
|
VToolPiecePath *pathTool = Create(initData);
|
||||||
return pathTool;
|
return pathTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPiecePath *VToolPiecePath::Create(quint32 _id, const VPiecePath &path, quint32 pieceId, VMainGraphicsScene *scene,
|
VToolPiecePath *VToolPiecePath::Create(VToolPiecePathInitData initData)
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation, const QString &drawName, const quint32 &idTool)
|
|
||||||
{
|
{
|
||||||
quint32 id = _id;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = data->AddPiecePath(path);
|
initData.id = initData.data->AddPiecePath(initData.path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->UpdatePiecePath(id, path);
|
initData.data->UpdatePiecePath(initData.id, initData.path);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::PiecePath, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::PiecePath, initData.doc);
|
||||||
//TODO Need create garbage collector and remove all nodes, that we don't use.
|
//TODO Need create garbage collector and remove all nodes, that we don't use.
|
||||||
//Better check garbage before each saving file. Check only modeling tags.
|
//Better check garbage before each saving file. Check only modeling tags.
|
||||||
VToolPiecePath *pathTool = new VToolPiecePath(doc, data, id, pieceId, typeCreation, drawName, idTool, doc);
|
VToolPiecePath *pathTool = new VToolPiecePath(initData);
|
||||||
|
|
||||||
VAbstractPattern::AddTool(id, pathTool);
|
VAbstractPattern::AddTool(initData.id, pathTool);
|
||||||
if (idTool != NULL_ID)
|
if (initData.idTool != NULL_ID)
|
||||||
{
|
{
|
||||||
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
||||||
VDataTool *tool = VAbstractPattern::getTool(idTool);
|
VDataTool *tool = VAbstractPattern::getTool(initData.idTool);
|
||||||
SCASSERT(tool != nullptr);
|
SCASSERT(tool != nullptr);
|
||||||
pathTool->setParent(tool);// Adopted by a tool
|
pathTool->setParent(tool);// Adopted by a tool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (typeCreation == Source::FromGui && path.GetType() == PiecePathType::InternalPath)
|
if (initData.typeCreation == Source::FromGui && initData.path.GetType() == PiecePathType::InternalPath)
|
||||||
{ // Seam allowance tool already initializated and can't init the path
|
{ // Seam allowance tool already initializated and can't init the path
|
||||||
SCASSERT(pieceId > NULL_ID);
|
SCASSERT(initData.idObject > NULL_ID);
|
||||||
VToolSeamAllowance *saTool = qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(pieceId));
|
VToolSeamAllowance *saTool =
|
||||||
|
qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(initData.idObject));
|
||||||
SCASSERT(saTool != nullptr);
|
SCASSERT(saTool != nullptr);
|
||||||
pathTool->setParentItem(saTool);
|
pathTool->setParentItem(saTool);
|
||||||
pathTool->SetParentType(ParentType::Item);
|
pathTool->SetParentType(ParentType::Item);
|
||||||
|
@ -96,7 +102,7 @@ VToolPiecePath *VToolPiecePath::Create(quint32 _id, const VPiecePath &path, quin
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Try to prevent memory leak
|
// Try to prevent memory leak
|
||||||
scene->addItem(pathTool);// First adopted by scene
|
initData.scene->addItem(pathTool);// First adopted by scene
|
||||||
pathTool->hide();// If no one will use node, it will stay hidden
|
pathTool->hide();// If no one will use node, it will stay hidden
|
||||||
pathTool->SetParentType(ParentType::Scene);
|
pathTool->SetParentType(ParentType::Scene);
|
||||||
}
|
}
|
||||||
|
@ -285,16 +291,14 @@ void VToolPiecePath::ToolCreation(const Source &typeCreation)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPiecePath::VToolPiecePath(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 pieceId,
|
VToolPiecePath::VToolPiecePath(const VToolPiecePathInitData &initData, QObject *qoParent, QGraphicsItem *parent)
|
||||||
const Source &typeCreation, const QString &drawName, const quint32 &idTool,
|
:VAbstractNode(initData.doc, initData.data, initData.id, NULL_ID, initData.drawName, initData.idTool, qoParent),
|
||||||
QObject *qoParent, QGraphicsItem *parent)
|
|
||||||
:VAbstractNode(doc, data, id, 0, drawName, idTool, qoParent),
|
|
||||||
QGraphicsPathItem(parent),
|
QGraphicsPathItem(parent),
|
||||||
m_pieceId(pieceId)
|
m_pieceId(initData.idObject)
|
||||||
{
|
{
|
||||||
IncrementNodes(VAbstractTool::data.GetPiecePath(id));
|
IncrementNodes(VAbstractTool::data.GetPiecePath(initData.id));
|
||||||
RefreshGeometry();
|
RefreshGeometry();
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -35,16 +35,23 @@
|
||||||
|
|
||||||
class DialogTool;
|
class DialogTool;
|
||||||
|
|
||||||
|
struct VToolPiecePathInitData : public VAbstractNodeInitData
|
||||||
|
{
|
||||||
|
VToolPiecePathInitData()
|
||||||
|
: VAbstractNodeInitData(),
|
||||||
|
path()
|
||||||
|
{}
|
||||||
|
|
||||||
|
VPiecePath path;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolPiecePath : public VAbstractNode, public QGraphicsPathItem
|
class VToolPiecePath : public VAbstractNode, public QGraphicsPathItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static VToolPiecePath* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
static VToolPiecePath* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VContainer *data);
|
VContainer *data);
|
||||||
static VToolPiecePath *Create(quint32 _id, const VPiecePath &path, quint32 pieceId, VMainGraphicsScene *scene,
|
static VToolPiecePath *Create(VToolPiecePathInitData initData);
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation, const QString &drawName = QString(),
|
|
||||||
const quint32 &idTool = 0);
|
|
||||||
|
|
||||||
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::PiecePath)};
|
enum { Type = UserType + static_cast<int>(Tool::PiecePath)};
|
||||||
|
@ -71,9 +78,8 @@ private:
|
||||||
|
|
||||||
quint32 m_pieceId;
|
quint32 m_pieceId;
|
||||||
|
|
||||||
VToolPiecePath(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 pieceId, const Source &typeCreation,
|
VToolPiecePath(const VToolPiecePathInitData &initData, QObject *qoParent = nullptr,
|
||||||
const QString &drawName = QString(), const quint32 &idTool = 0, QObject *qoParent = nullptr,
|
QGraphicsItem *parent = nullptr);
|
||||||
QGraphicsItem * parent = nullptr );
|
|
||||||
|
|
||||||
void RefreshGeometry();
|
void RefreshGeometry();
|
||||||
|
|
||||||
|
|
|
@ -40,28 +40,31 @@ VToolPin *VToolPin::Create(QSharedPointer<DialogTool> dialog, VAbstractPattern *
|
||||||
SCASSERT(not dialog.isNull());
|
SCASSERT(not dialog.isNull());
|
||||||
QSharedPointer<DialogPin> dialogTool = dialog.objectCast<DialogPin>();
|
QSharedPointer<DialogPin> dialogTool = dialog.objectCast<DialogPin>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
const quint32 pointId = dialogTool->GetPointId();
|
|
||||||
const quint32 pieceId = dialogTool->GetPieceId();
|
|
||||||
|
|
||||||
return Create(0, pointId, pieceId, doc, data, Document::FullParse, Source::FromGui);
|
VToolPinInitData initData;
|
||||||
|
initData.pointId = dialogTool->GetPointId();
|
||||||
|
initData.idObject = dialogTool->GetPieceId();
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
return Create(initData);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPin *VToolPin::Create(quint32 _id, quint32 pointId, quint32 pieceId, VAbstractPattern *doc, VContainer *data,
|
VToolPin *VToolPin::Create(VToolPinInitData initData)
|
||||||
const Document &parse, const Source &typeCreation, const QString &drawName,
|
|
||||||
const quint32 &idTool)
|
|
||||||
{
|
{
|
||||||
quint32 id = _id;
|
if (initData.typeCreation == Source::FromGui)
|
||||||
if (typeCreation == Source::FromGui)
|
|
||||||
{
|
{
|
||||||
id = CreateNode<VPointF>(data, pointId);
|
initData.id = CreateNode<VPointF>(initData.data, initData.pointId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QSharedPointer<VPointF> point;
|
QSharedPointer<VPointF> point;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
point = data->GeometricObject<VPointF>(pointId);
|
point = initData.data->GeometricObject<VPointF>(initData.pointId);
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &e)
|
catch (const VExceptionBadId &e)
|
||||||
{ // Possible case. Parent was deleted, but the node object is still here.
|
{ // Possible case. Parent was deleted, but the node object is still here.
|
||||||
|
@ -70,35 +73,35 @@ VToolPin *VToolPin::Create(quint32 _id, quint32 pointId, quint32 pieceId, VAbstr
|
||||||
}
|
}
|
||||||
VPointF *pinPoint = new VPointF(*point);
|
VPointF *pinPoint = new VPointF(*point);
|
||||||
pinPoint->setMode(Draw::Modeling);
|
pinPoint->setMode(Draw::Modeling);
|
||||||
data->UpdateGObject(id, pinPoint);
|
initData.data->UpdateGObject(initData.id, pinPoint);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VAbstractTool::AddRecord(id, Tool::Pin, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Pin, initData.doc);
|
||||||
VToolPin *point = nullptr;
|
VToolPin *point = nullptr;
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
point = new VToolPin(doc, data, id, pointId, pieceId, typeCreation, drawName, idTool, doc);
|
point = new VToolPin(initData);
|
||||||
|
|
||||||
VAbstractPattern::AddTool(id, point);
|
VAbstractPattern::AddTool(initData.id, point);
|
||||||
if (idTool != NULL_ID)
|
if (initData.idTool != NULL_ID)
|
||||||
{
|
{
|
||||||
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
//Some nodes we don't show on scene. Tool that create this nodes must free memory.
|
||||||
VDataTool *tool = VAbstractPattern::getTool(idTool);
|
VDataTool *tool = VAbstractPattern::getTool(initData.idTool);
|
||||||
SCASSERT(tool != nullptr)
|
SCASSERT(tool != nullptr)
|
||||||
point->setParent(tool);// Adopted by a tool
|
point->setParent(tool);// Adopted by a tool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Help to delete the node before each FullParse
|
// Help to delete the node before each FullParse
|
||||||
doc->AddToolOnRemove(point);
|
initData.doc->AddToolOnRemove(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
@ -153,10 +156,10 @@ void VToolPin::AddToFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolPin::VToolPin(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 pointId, quint32 pieceId,
|
VToolPin::VToolPin(const VToolPinInitData &initData, QObject *qoParent)
|
||||||
const Source &typeCreation, const QString &drawName, const quint32 &idTool, QObject *qoParent)
|
: VAbstractNode(initData.doc, initData.data, initData.id, initData.pointId, initData.drawName, initData.idTool,
|
||||||
: VAbstractNode(doc, data, id, pointId, drawName, idTool, qoParent),
|
qoParent),
|
||||||
m_pieceId(pieceId)
|
m_pieceId(initData.idObject)
|
||||||
{
|
{
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,22 @@
|
||||||
|
|
||||||
class DialogTool;
|
class DialogTool;
|
||||||
|
|
||||||
|
struct VToolPinInitData : public VAbstractNodeInitData
|
||||||
|
{
|
||||||
|
VToolPinInitData()
|
||||||
|
: VAbstractNodeInitData(),
|
||||||
|
pointId(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
quint32 pointId;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolPin : public VAbstractNode
|
class VToolPin : public VAbstractNode
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static VToolPin* Create(QSharedPointer<DialogTool> dialog, VAbstractPattern *doc, VContainer *data);
|
static VToolPin* Create(QSharedPointer<DialogTool> dialog, VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolPin *Create(quint32 _id, quint32 pointId, quint32 pieceId, VAbstractPattern *doc, VContainer *data,
|
static VToolPin *Create(VToolPinInitData initData);
|
||||||
const Document &parse, const Source &typeCreation, const QString &drawName = QString(),
|
|
||||||
const quint32 &idTool = 0);
|
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||||
|
@ -59,9 +67,7 @@ private:
|
||||||
|
|
||||||
quint32 m_pieceId;
|
quint32 m_pieceId;
|
||||||
|
|
||||||
VToolPin(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 pointId, quint32 pieceId,
|
VToolPin(const VToolPinInitData &initData, QObject *qoParent = nullptr);
|
||||||
const Source &typeCreation, const QString &drawName = QString(), const quint32 &idTool = 0,
|
|
||||||
QObject *qoParent = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLPIN_H
|
#endif // VTOOLPIN_H
|
||||||
|
|
|
@ -618,32 +618,38 @@ quint32 VAbstractTool::PrepareNode(const VPieceNode &node, VMainGraphicsScene *s
|
||||||
SCASSERT(doc != nullptr)
|
SCASSERT(doc != nullptr)
|
||||||
SCASSERT(data != nullptr)
|
SCASSERT(data != nullptr)
|
||||||
|
|
||||||
quint32 id = NULL_ID;
|
VAbstractNodeInitData initData;
|
||||||
|
initData.idObject = node.GetId();
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
switch (node.GetTypeTool())
|
switch (node.GetTypeTool())
|
||||||
{
|
{
|
||||||
case (Tool::NodePoint):
|
case (Tool::NodePoint):
|
||||||
id = CreateNode<VPointF>(data, node.GetId());
|
initData.id = CreateNode<VPointF>(data, node.GetId());
|
||||||
VNodePoint::Create(doc, data, scene, id, node.GetId(), Document::FullParse, Source::FromGui);
|
VNodePoint::Create(initData);
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeArc):
|
case (Tool::NodeArc):
|
||||||
id = CreateNode<VArc>(data, node.GetId());
|
initData.id = CreateNode<VArc>(data, node.GetId());
|
||||||
VNodeArc::Create(doc, data, id, node.GetId(), Document::FullParse, Source::FromGui);
|
VNodeArc::Create(initData);
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeElArc):
|
case (Tool::NodeElArc):
|
||||||
id = CreateNode<VEllipticalArc>(data, node.GetId());
|
initData.id = CreateNode<VEllipticalArc>(data, node.GetId());
|
||||||
VNodeEllipticalArc::Create(doc, data, id, node.GetId(), Document::FullParse, Source::FromGui);
|
VNodeEllipticalArc::Create(initData);
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeSpline):
|
case (Tool::NodeSpline):
|
||||||
id = CreateNodeSpline(data, node.GetId());
|
initData.id = CreateNodeSpline(data, node.GetId());
|
||||||
VNodeSpline::Create(doc, data, id, node.GetId(), Document::FullParse, Source::FromGui);
|
VNodeSpline::Create(initData);
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeSplinePath):
|
case (Tool::NodeSplinePath):
|
||||||
id = CreateNodeSplinePath(data, node.GetId());
|
initData.id = CreateNodeSplinePath(data, node.GetId());
|
||||||
VNodeSplinePath::Create(doc, data, id, node.GetId(), Document::FullParse, Source::FromGui);
|
VNodeSplinePath::Create(initData);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
|
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return id;
|
return initData.id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,26 @@
|
||||||
class VGraphicsSimpleTextItem;
|
class VGraphicsSimpleTextItem;
|
||||||
class VAbstractNode;
|
class VAbstractNode;
|
||||||
|
|
||||||
|
struct VAbstractToolInitData
|
||||||
|
{
|
||||||
|
VAbstractToolInitData()
|
||||||
|
: id(NULL_ID),
|
||||||
|
scene(nullptr),
|
||||||
|
doc(nullptr),
|
||||||
|
data(nullptr),
|
||||||
|
parse(Document::FullParse),
|
||||||
|
typeCreation(Source::FromFile)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/** @brief id tool id, 0 if tool doesn't exist yet.*/
|
||||||
|
quint32 id;
|
||||||
|
VMainGraphicsScene *scene;
|
||||||
|
VAbstractPattern *doc;
|
||||||
|
VContainer *data;
|
||||||
|
Document parse;
|
||||||
|
Source typeCreation;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VAbstractTool abstract class for all tools.
|
* @brief The VAbstractTool abstract class for all tools.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -91,12 +91,20 @@ VToolSeamAllowance *VToolSeamAllowance::Create(QSharedPointer<DialogTool> dialog
|
||||||
SCASSERT(not dialog.isNull());
|
SCASSERT(not dialog.isNull());
|
||||||
QSharedPointer<DialogSeamAllowance> dialogTool = dialog.objectCast<DialogSeamAllowance>();
|
QSharedPointer<DialogSeamAllowance> dialogTool = dialog.objectCast<DialogSeamAllowance>();
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
VPiece detail = dialogTool->GetPiece();
|
|
||||||
QString width = detail.GetFormulaSAWidth();
|
|
||||||
qApp->getUndoStack()->beginMacro("add detail");
|
|
||||||
detail.GetPath().SetNodes(PrepareNodes(detail.GetPath(), scene, doc, data));
|
|
||||||
|
|
||||||
VToolSeamAllowance *piece = Create(0, detail, width, scene, doc, data, Document::FullParse, Source::FromGui);
|
VToolSeamAllowanceInitData initData;
|
||||||
|
initData.detail = dialogTool->GetPiece();
|
||||||
|
initData.width = initData.detail.GetFormulaSAWidth();
|
||||||
|
initData.scene = scene;
|
||||||
|
initData.doc = doc;
|
||||||
|
initData.data = data;
|
||||||
|
initData.parse = Document::FullParse;
|
||||||
|
initData.typeCreation = Source::FromGui;
|
||||||
|
|
||||||
|
qApp->getUndoStack()->beginMacro("add detail");
|
||||||
|
initData.detail.GetPath().SetNodes(PrepareNodes(initData.detail.GetPath(), scene, doc, data));
|
||||||
|
|
||||||
|
VToolSeamAllowance *piece = Create(initData);
|
||||||
|
|
||||||
if (piece != nullptr)
|
if (piece != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -106,45 +114,47 @@ VToolSeamAllowance *VToolSeamAllowance::Create(QSharedPointer<DialogTool> dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolSeamAllowance *VToolSeamAllowance::Create(quint32 id, VPiece newPiece, QString &width, VMainGraphicsScene *scene,
|
VToolSeamAllowance *VToolSeamAllowance::Create(VToolSeamAllowanceInitData &initData)
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation, const QString &drawName)
|
|
||||||
{
|
{
|
||||||
if (typeCreation == Source::FromGui || typeCreation == Source::FromTool)
|
if (initData.typeCreation == Source::FromGui || initData.typeCreation == Source::FromTool)
|
||||||
{
|
{
|
||||||
data->AddVariable(currentSeamAllowance, new VIncrement(data, currentSeamAllowance, 0, newPiece.GetSAWidth(),
|
initData.data->AddVariable(currentSeamAllowance, new VIncrement(initData.data, currentSeamAllowance, 0,
|
||||||
width, true, tr("Current seam allowance")));
|
initData.detail.GetSAWidth(),
|
||||||
id = data->AddPiece(newPiece);
|
initData.width, true,
|
||||||
|
tr("Current seam allowance")));
|
||||||
|
initData.id = initData.data->AddPiece(initData.detail);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const qreal calcWidth = CheckFormula(id, width, data);
|
const qreal calcWidth = CheckFormula(initData.id, initData.width, initData.data);
|
||||||
newPiece.SetFormulaSAWidth(width, calcWidth);
|
initData.detail.SetFormulaSAWidth(initData.width, calcWidth);
|
||||||
|
|
||||||
data->AddVariable(currentSeamAllowance, new VIncrement(data, currentSeamAllowance, 0, calcWidth,
|
initData.data->AddVariable(currentSeamAllowance, new VIncrement(initData.data, currentSeamAllowance, 0,
|
||||||
width, true, tr("Current seam allowance")));
|
calcWidth, initData.width, true,
|
||||||
|
tr("Current seam allowance")));
|
||||||
|
|
||||||
data->UpdatePiece(id, newPiece);
|
initData.data->UpdatePiece(initData.id, initData.detail);
|
||||||
if (parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
doc->UpdateToolData(id, data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VToolSeamAllowance *piece = nullptr;
|
VToolSeamAllowance *piece = nullptr;
|
||||||
if (parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::Piece, doc);
|
VAbstractTool::AddRecord(initData.id, Tool::Piece, initData.doc);
|
||||||
piece = new VToolSeamAllowance(doc, data, id, typeCreation, scene, drawName);
|
piece = new VToolSeamAllowance(initData);
|
||||||
scene->addItem(piece);
|
initData.scene->addItem(piece);
|
||||||
connect(piece, &VToolSeamAllowance::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(piece, &VToolSeamAllowance::ChoosedTool, initData.scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(scene, &VMainGraphicsScene::EnableDetailItemHover, piece, &VToolSeamAllowance::AllowHover);
|
connect(initData.scene, &VMainGraphicsScene::EnableDetailItemHover, piece, &VToolSeamAllowance::AllowHover);
|
||||||
connect(scene, &VMainGraphicsScene::EnableDetailItemSelection, piece, &VToolSeamAllowance::AllowSelecting);
|
connect(initData.scene, &VMainGraphicsScene::EnableDetailItemSelection, piece,
|
||||||
connect(scene, &VMainGraphicsScene::HighlightDetail, piece, &VToolSeamAllowance::Highlight);
|
&VToolSeamAllowance::AllowSelecting);
|
||||||
VAbstractPattern::AddTool(id, piece);
|
connect(initData.scene, &VMainGraphicsScene::HighlightDetail, piece, &VToolSeamAllowance::Highlight);
|
||||||
|
VAbstractPattern::AddTool(initData.id, piece);
|
||||||
}
|
}
|
||||||
//Very important to delete it. Only this tool need this special variable.
|
//Very important to delete it. Only this tool need this special variable.
|
||||||
data->RemoveVariable(currentSeamAllowance);
|
initData.data->RemoveVariable(currentSeamAllowance);
|
||||||
return piece;
|
return piece;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,23 +1113,21 @@ void VToolSeamAllowance::SetDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
VToolSeamAllowance::VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem *parent)
|
||||||
const Source &typeCreation, VMainGraphicsScene *scene,
|
: VInteractiveTool(initData.doc, initData.data, initData.id),
|
||||||
const QString &drawName, QGraphicsItem *parent)
|
|
||||||
: VInteractiveTool(doc, data, id),
|
|
||||||
QGraphicsPathItem(parent),
|
QGraphicsPathItem(parent),
|
||||||
m_mainPath(),
|
m_mainPath(),
|
||||||
m_mainPathRect(),
|
m_mainPathRect(),
|
||||||
m_sceneDetails(scene),
|
m_sceneDetails(initData.scene),
|
||||||
m_drawName(drawName),
|
m_drawName(initData.drawName),
|
||||||
m_seamAllowance(new VNoBrushScalePathItem(this)),
|
m_seamAllowance(new VNoBrushScalePathItem(this)),
|
||||||
m_dataLabel(new VTextGraphicsItem(this)),
|
m_dataLabel(new VTextGraphicsItem(this)),
|
||||||
m_patternInfo(new VTextGraphicsItem(this)),
|
m_patternInfo(new VTextGraphicsItem(this)),
|
||||||
m_grainLine(new VGrainlineItem(this)),
|
m_grainLine(new VGrainlineItem(this)),
|
||||||
m_passmarks(new QGraphicsPathItem(this))
|
m_passmarks(new QGraphicsPathItem(this))
|
||||||
{
|
{
|
||||||
VPiece detail = data->GetPiece(id);
|
VPiece detail = initData.data->GetPiece(initData.id);
|
||||||
InitNodes(detail, scene);
|
InitNodes(detail, initData.scene);
|
||||||
InitCSAPaths(detail);
|
InitCSAPaths(detail);
|
||||||
InitInternalPaths(detail);
|
InitInternalPaths(detail);
|
||||||
InitPins(detail);
|
InitPins(detail);
|
||||||
|
@ -1130,9 +1138,9 @@ VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data,
|
||||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||||
|
|
||||||
connect(scene, &VMainGraphicsScene::EnableToolMove, this, &VToolSeamAllowance::EnableToolMove);
|
connect(initData.scene, &VMainGraphicsScene::EnableToolMove, this, &VToolSeamAllowance::EnableToolMove);
|
||||||
connect(scene, &VMainGraphicsScene::ItemClicked, this, &VToolSeamAllowance::ResetChildren);
|
connect(initData.scene, &VMainGraphicsScene::ItemClicked, this, &VToolSeamAllowance::ResetChildren);
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
|
|
||||||
connect(m_dataLabel, &VTextGraphicsItem::SignalMoved, this, &VToolSeamAllowance::SaveMoveDetail);
|
connect(m_dataLabel, &VTextGraphicsItem::SignalMoved, this, &VToolSeamAllowance::SaveMoveDetail);
|
||||||
|
|
|
@ -41,6 +41,20 @@
|
||||||
class DialogTool;
|
class DialogTool;
|
||||||
class VNoBrushScalePathItem;
|
class VNoBrushScalePathItem;
|
||||||
|
|
||||||
|
struct VToolSeamAllowanceInitData : public VAbstractToolInitData
|
||||||
|
{
|
||||||
|
VToolSeamAllowanceInitData()
|
||||||
|
: VAbstractToolInitData(),
|
||||||
|
detail(),
|
||||||
|
width("0"),
|
||||||
|
drawName()
|
||||||
|
{}
|
||||||
|
|
||||||
|
VPiece detail;
|
||||||
|
QString width;
|
||||||
|
QString drawName;
|
||||||
|
};
|
||||||
|
|
||||||
class VToolSeamAllowance : public VInteractiveTool, public QGraphicsPathItem
|
class VToolSeamAllowance : public VInteractiveTool, public QGraphicsPathItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -49,9 +63,7 @@ public:
|
||||||
|
|
||||||
static VToolSeamAllowance* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolSeamAllowance* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolSeamAllowance* Create(quint32 id, VPiece newPiece, QString &width, VMainGraphicsScene *scene,
|
static VToolSeamAllowance* Create(VToolSeamAllowanceInitData &initData);
|
||||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
|
||||||
const Source &typeCreation, const QString &drawName = QString());
|
|
||||||
|
|
||||||
static const quint8 pieceVersion;
|
static const quint8 pieceVersion;
|
||||||
|
|
||||||
|
@ -152,8 +164,7 @@ private:
|
||||||
VGrainlineItem *m_grainLine;
|
VGrainlineItem *m_grainLine;
|
||||||
QGraphicsPathItem *m_passmarks;
|
QGraphicsPathItem *m_passmarks;
|
||||||
|
|
||||||
VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation,
|
VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr);
|
||||||
VMainGraphicsScene *scene, const QString &drawName, QGraphicsItem * parent = nullptr);
|
|
||||||
|
|
||||||
void UpdateExcludeState();
|
void UpdateExcludeState();
|
||||||
void RefreshGeometry();
|
void RefreshGeometry();
|
||||||
|
|
|
@ -359,7 +359,7 @@ void UnionInitParameters(const VToolUnionDetailsInitData &initData, const VPiece
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint32 AddNodePoint(const VPieceNode &node, const VToolUnionDetailsInitData &initData, quint32 idTool,
|
quint32 AddNodePoint(const VPieceNode &node, const VToolUnionDetailsInitData &initData,
|
||||||
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
||||||
quint32 pRotate, qreal angle)
|
quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
|
@ -378,13 +378,23 @@ quint32 AddNodePoint(const VPieceNode &node, const VToolUnionDetailsInitData &in
|
||||||
children.append(idObject);
|
children.append(idObject);
|
||||||
point1->setMode(Draw::Modeling);
|
point1->setMode(Draw::Modeling);
|
||||||
const quint32 id = initData.data->AddGObject(point1.take());
|
const quint32 id = initData.data->AddGObject(point1.take());
|
||||||
VNodePoint::Create(initData.doc, initData.data, initData.scene, id, idObject, Document::FullParse, Source::FromTool,
|
|
||||||
drawName, idTool);
|
VAbstractNodeInitData initNodeData;
|
||||||
|
initNodeData.id = id;
|
||||||
|
initNodeData.idObject = idObject;
|
||||||
|
initNodeData.doc = initData.doc;
|
||||||
|
initNodeData.data = initData.data;
|
||||||
|
initNodeData.parse = Document::FullParse;
|
||||||
|
initNodeData.typeCreation = Source::FromTool;
|
||||||
|
initNodeData.idTool = initData.id;
|
||||||
|
initNodeData.drawName = drawName;
|
||||||
|
|
||||||
|
VNodePoint::Create(initNodeData);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint32 AddPin(quint32 id, const VToolUnionDetailsInitData &initData, quint32 idTool, QVector<quint32> &children,
|
quint32 AddPin(quint32 id, const VToolUnionDetailsInitData &initData, QVector<quint32> &children,
|
||||||
const QString &drawName, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
const QString &drawName, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
QScopedPointer<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(id)));
|
QScopedPointer<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(id)));
|
||||||
|
@ -402,13 +412,24 @@ quint32 AddPin(quint32 id, const VToolUnionDetailsInitData &initData, quint32 id
|
||||||
children.append(idObject);
|
children.append(idObject);
|
||||||
point1->setMode(Draw::Modeling);
|
point1->setMode(Draw::Modeling);
|
||||||
const quint32 idPin = initData.data->AddGObject(point1.take());
|
const quint32 idPin = initData.data->AddGObject(point1.take());
|
||||||
VToolPin::Create(idPin, idObject, 0, initData.doc, initData.data, Document::FullParse, Source::FromTool, drawName,
|
|
||||||
idTool);
|
VToolPinInitData initNodeData;
|
||||||
|
initNodeData.id = idPin;
|
||||||
|
initNodeData.pointId = idObject;
|
||||||
|
initNodeData.idObject = NULL_ID;
|
||||||
|
initNodeData.doc = initData.doc;
|
||||||
|
initNodeData.data = initData.data;
|
||||||
|
initNodeData.parse = Document::FullParse;
|
||||||
|
initNodeData.typeCreation = Source::FromTool;
|
||||||
|
initNodeData.idTool = initData.id;
|
||||||
|
initNodeData.drawName = drawName;
|
||||||
|
|
||||||
|
VToolPin::Create(initNodeData);
|
||||||
return idPin;
|
return idPin;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint32 AddNodeArc(const VPieceNode &node, const VToolUnionDetailsInitData &initData, quint32 idTool,
|
quint32 AddNodeArc(const VPieceNode &node, const VToolUnionDetailsInitData &initData,
|
||||||
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
||||||
quint32 pRotate, qreal angle)
|
quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
|
@ -444,13 +465,22 @@ quint32 AddNodeArc(const VPieceNode &node, const VToolUnionDetailsInitData &init
|
||||||
arc2->setMode(Draw::Modeling);
|
arc2->setMode(Draw::Modeling);
|
||||||
const quint32 id = initData.data->AddGObject(arc2.take());
|
const quint32 id = initData.data->AddGObject(arc2.take());
|
||||||
|
|
||||||
VNodeArc::Create(initData.doc, initData.data, id, idObject, Document::FullParse, Source::FromTool, drawName,
|
VAbstractNodeInitData initNodeData;
|
||||||
idTool);
|
initNodeData.id = id;
|
||||||
|
initNodeData.idObject = idObject;
|
||||||
|
initNodeData.doc = initData.doc;
|
||||||
|
initNodeData.data = initData.data;
|
||||||
|
initNodeData.parse = Document::FullParse;
|
||||||
|
initNodeData.typeCreation = Source::FromTool;
|
||||||
|
initNodeData.idTool = initData.id;
|
||||||
|
initNodeData.drawName = drawName;
|
||||||
|
|
||||||
|
VNodeArc::Create(initNodeData);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint32 AddNodeElArc(const VPieceNode &node, const VToolUnionDetailsInitData &initData, quint32 idTool,
|
quint32 AddNodeElArc(const VPieceNode &node, const VToolUnionDetailsInitData &initData,
|
||||||
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
||||||
quint32 pRotate, qreal angle)
|
quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
|
@ -488,13 +518,22 @@ quint32 AddNodeElArc(const VPieceNode &node, const VToolUnionDetailsInitData &in
|
||||||
arc2->setMode(Draw::Modeling);
|
arc2->setMode(Draw::Modeling);
|
||||||
const quint32 id = initData.data->AddGObject(arc2.take());
|
const quint32 id = initData.data->AddGObject(arc2.take());
|
||||||
|
|
||||||
VNodeEllipticalArc::Create(initData.doc, initData.data, id, idObject, Document::FullParse, Source::FromTool,
|
VAbstractNodeInitData initNodeData;
|
||||||
drawName, idTool);
|
initNodeData.id = id;
|
||||||
|
initNodeData.idObject = idObject;
|
||||||
|
initNodeData.doc = initData.doc;
|
||||||
|
initNodeData.data = initData.data;
|
||||||
|
initNodeData.parse = Document::FullParse;
|
||||||
|
initNodeData.typeCreation = Source::FromTool;
|
||||||
|
initNodeData.idTool = initData.id;
|
||||||
|
initNodeData.drawName = drawName;
|
||||||
|
|
||||||
|
VNodeEllipticalArc::Create(initNodeData);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint32 AddNodeSpline(const VPieceNode &node, const VToolUnionDetailsInitData &initData, quint32 idTool,
|
quint32 AddNodeSpline(const VPieceNode &node, const VToolUnionDetailsInitData &initData,
|
||||||
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
||||||
quint32 pRotate, qreal angle)
|
quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
|
@ -523,13 +562,23 @@ quint32 AddNodeSpline(const VPieceNode &node, const VToolUnionDetailsInitData &i
|
||||||
VSpline *spl1 = new VSpline(*spl);
|
VSpline *spl1 = new VSpline(*spl);
|
||||||
spl1->setMode(Draw::Modeling);
|
spl1->setMode(Draw::Modeling);
|
||||||
const quint32 id = initData.data->AddGObject(spl1);
|
const quint32 id = initData.data->AddGObject(spl1);
|
||||||
VNodeSpline::Create(initData.doc, initData.data, id, idObject, Document::FullParse, Source::FromTool, drawName,
|
|
||||||
idTool);
|
VAbstractNodeInitData initNodeData;
|
||||||
|
initNodeData.id = id;
|
||||||
|
initNodeData.idObject = idObject;
|
||||||
|
initNodeData.doc = initData.doc;
|
||||||
|
initNodeData.data = initData.data;
|
||||||
|
initNodeData.parse = Document::FullParse;
|
||||||
|
initNodeData.typeCreation = Source::FromTool;
|
||||||
|
initNodeData.idTool = initData.id;
|
||||||
|
initNodeData.drawName = drawName;
|
||||||
|
|
||||||
|
VNodeSpline::Create(initNodeData);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint32 AddNodeSplinePath(const VPieceNode &node, const VToolUnionDetailsInitData &initData, quint32 idTool,
|
quint32 AddNodeSplinePath(const VPieceNode &node, const VToolUnionDetailsInitData &initData,
|
||||||
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
||||||
quint32 pRotate, qreal angle)
|
quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
|
@ -587,8 +636,17 @@ quint32 AddNodeSplinePath(const VPieceNode &node, const VToolUnionDetailsInitDat
|
||||||
path1->setMode(Draw::Modeling);
|
path1->setMode(Draw::Modeling);
|
||||||
const quint32 id = initData.data->AddGObject(path1.take());
|
const quint32 id = initData.data->AddGObject(path1.take());
|
||||||
|
|
||||||
VNodeSplinePath::Create(initData.doc, initData.data, id, idObject, Document::FullParse, Source::FromTool, drawName,
|
VAbstractNodeInitData initNodeData;
|
||||||
idTool);
|
initNodeData.id = id;
|
||||||
|
initNodeData.idObject = idObject;
|
||||||
|
initNodeData.doc = initData.doc;
|
||||||
|
initNodeData.data = initData.data;
|
||||||
|
initNodeData.parse = Document::FullParse;
|
||||||
|
initNodeData.typeCreation = Source::FromTool;
|
||||||
|
initNodeData.idTool = initData.id;
|
||||||
|
initNodeData.drawName = drawName;
|
||||||
|
|
||||||
|
VNodeSplinePath::Create(initNodeData);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,30 +655,30 @@ quint32 AddNodeSplinePath(const VPieceNode &node, const VToolUnionDetailsInitDat
|
||||||
* @brief AddToNewDetail create united detail adding one node per time.
|
* @brief AddToNewDetail create united detail adding one node per time.
|
||||||
*/
|
*/
|
||||||
void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &newPath, VPieceNode node,
|
void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &newPath, VPieceNode node,
|
||||||
quint32 idTool, QVector<quint32> &children, const QString &drawName, qreal dx = 0, qreal dy = 0,
|
QVector<quint32> &children, const QString &drawName, qreal dx = 0, qreal dy = 0,
|
||||||
quint32 pRotate = NULL_ID, qreal angle = 0);
|
quint32 pRotate = NULL_ID, qreal angle = 0);
|
||||||
|
|
||||||
void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &newPath, VPieceNode node,
|
void AddNodeToNewPath(const VToolUnionDetailsInitData &initData, VPiecePath &newPath, VPieceNode node,
|
||||||
quint32 idTool, QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
|
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy, quint32 pRotate,
|
||||||
quint32 pRotate, qreal angle)
|
qreal angle)
|
||||||
{
|
{
|
||||||
quint32 id = 0;
|
quint32 id = 0;
|
||||||
switch (node.GetTypeTool())
|
switch (node.GetTypeTool())
|
||||||
{
|
{
|
||||||
case (Tool::NodePoint):
|
case (Tool::NodePoint):
|
||||||
id = AddNodePoint(node, initData, idTool, children, drawName, dx, dy, pRotate, angle);
|
id = AddNodePoint(node, initData, children, drawName, dx, dy, pRotate, angle);
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeArc):
|
case (Tool::NodeArc):
|
||||||
id = AddNodeArc(node, initData, idTool, children, drawName, dx, dy, pRotate, angle);
|
id = AddNodeArc(node, initData, children, drawName, dx, dy, pRotate, angle);
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeElArc):
|
case (Tool::NodeElArc):
|
||||||
id = AddNodeElArc(node, initData, idTool, children, drawName, dx, dy, pRotate, angle);
|
id = AddNodeElArc(node, initData, children, drawName, dx, dy, pRotate, angle);
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeSpline):
|
case (Tool::NodeSpline):
|
||||||
id = AddNodeSpline(node, initData, idTool, children, drawName, dx, dy, pRotate, angle);
|
id = AddNodeSpline(node, initData, children, drawName, dx, dy, pRotate, angle);
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeSplinePath):
|
case (Tool::NodeSplinePath):
|
||||||
id = AddNodeSplinePath(node, initData, idTool, children, drawName, dx, dy, pRotate, angle);
|
id = AddNodeSplinePath(node, initData, children, drawName, dx, dy, pRotate, angle);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
|
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
|
||||||
|
@ -979,7 +1037,7 @@ void UpdatePathNode(VContainer *data, const VPieceNode &node, QVector<quint32> &
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void CreateUnitedNodes(VPiece &newDetail, const VPiece &d1, const VPiece &d2, quint32 id, const QString &drawName,
|
void CreateUnitedNodes(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName,
|
||||||
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
const VPiecePath d1Path = d1.GetPath().RemoveEdge(initData.indexD1);
|
const VPiecePath d1Path = d1.GetPath().RemoveEdge(initData.indexD1);
|
||||||
|
@ -995,23 +1053,22 @@ void CreateUnitedNodes(VPiece &newDetail, const VPiece &d1, const VPiece &d2, qu
|
||||||
{
|
{
|
||||||
if (unitedPath.at(i).first)
|
if (unitedPath.at(i).first)
|
||||||
{// first piece
|
{// first piece
|
||||||
AddNodeToNewPath(initData, newPath, unitedPath.at(i).second, id, children, drawName);
|
AddNodeToNewPath(initData, newPath, unitedPath.at(i).second, children, drawName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{// second piece
|
{// second piece
|
||||||
AddNodeToNewPath(initData, newPath, unitedPath.at(i).second, id, children, drawName, dx, dy, pRotate,
|
AddNodeToNewPath(initData, newPath, unitedPath.at(i).second, children, drawName, dx, dy, pRotate, angle);
|
||||||
angle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newDetail.SetPath(newPath);
|
newDetail.SetPath(newPath);
|
||||||
|
|
||||||
SCASSERT(not children.isEmpty())
|
SCASSERT(not children.isEmpty())
|
||||||
SaveNodesChildren(initData.doc, id, children);
|
SaveNodesChildren(initData.doc, initData.id, children);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector<quint32> &children, quint32 id,
|
void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector<quint32> &children,
|
||||||
const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy,
|
const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy,
|
||||||
quint32 pRotate, qreal angle)
|
quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
|
@ -1024,11 +1081,23 @@ void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector<quint32>
|
||||||
newPath.Clear();//Clear nodes
|
newPath.Clear();//Clear nodes
|
||||||
for (int i=0; i < path.CountNodes(); ++i)
|
for (int i=0; i < path.CountNodes(); ++i)
|
||||||
{
|
{
|
||||||
AddNodeToNewPath(initData, newPath, path.at(i), id, nodeChildren, drawName, dx, dy, pRotate, angle);
|
AddNodeToNewPath(initData, newPath, path.at(i), nodeChildren, drawName, dx, dy, pRotate, angle);
|
||||||
}
|
}
|
||||||
const quint32 idPath = initData.data->AddPiecePath(newPath);
|
const quint32 idPath = initData.data->AddPiecePath(newPath);
|
||||||
VToolPiecePath::Create(idPath, newPath, NULL_ID, initData.scene, initData.doc, initData.data, initData.parse,
|
|
||||||
Source::FromTool, drawName, id);
|
VToolPiecePathInitData initNodeData;
|
||||||
|
initNodeData.id = idPath;
|
||||||
|
initNodeData.idObject = NULL_ID;
|
||||||
|
initNodeData.scene = initData.scene;
|
||||||
|
initNodeData.doc = initData.doc;
|
||||||
|
initNodeData.data = initData.data;
|
||||||
|
initNodeData.parse = Document::FullParse;
|
||||||
|
initNodeData.typeCreation = Source::FromTool;
|
||||||
|
initNodeData.idTool = initData.id;
|
||||||
|
initNodeData.drawName = drawName;
|
||||||
|
initNodeData.path = newPath;
|
||||||
|
|
||||||
|
VToolPiecePath::Create(initNodeData);
|
||||||
record.path = idPath;
|
record.path = idPath;
|
||||||
newDetail.GetCustomSARecords().append(record);
|
newDetail.GetCustomSARecords().append(record);
|
||||||
nodeChildren.prepend(idPath);
|
nodeChildren.prepend(idPath);
|
||||||
|
@ -1037,7 +1106,7 @@ void CreateUnitedDetailCSA(VPiece &newDetail, const VPiece &d, QVector<quint32>
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void CreateUnitedCSA(VPiece &newDetail, const VPiece &d1, const VPiece &d2, quint32 id, const QString &drawName,
|
void CreateUnitedCSA(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName,
|
||||||
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d1.GetCustomSARecords().size(); ++i)
|
for (int i = 0; i < d1.GetCustomSARecords().size(); ++i)
|
||||||
|
@ -1046,12 +1115,12 @@ void CreateUnitedCSA(VPiece &newDetail, const VPiece &d1, const VPiece &d2, quin
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<quint32> children;
|
QVector<quint32> children;
|
||||||
CreateUnitedDetailCSA(newDetail, d2, children, id, drawName, initData, dx, dy, pRotate, angle);
|
CreateUnitedDetailCSA(newDetail, d2, children, drawName, initData, dx, dy, pRotate, angle);
|
||||||
SaveCSAChildren(initData.doc, id, children);
|
SaveCSAChildren(initData.doc, initData.id, children);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void CreateUnitedDetailInternalPaths(VPiece &newDetail, const VPiece &d, QVector<quint32> &children, quint32 id,
|
void CreateUnitedDetailInternalPaths(VPiece &newDetail, const VPiece &d, QVector<quint32> &children,
|
||||||
const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx,
|
const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx,
|
||||||
qreal dy, quint32 pRotate, qreal angle)
|
qreal dy, quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
|
@ -1064,11 +1133,23 @@ void CreateUnitedDetailInternalPaths(VPiece &newDetail, const VPiece &d, QVector
|
||||||
|
|
||||||
for (int i=0; i < path.CountNodes(); ++i)
|
for (int i=0; i < path.CountNodes(); ++i)
|
||||||
{
|
{
|
||||||
AddNodeToNewPath(initData, newPath, path.at(i), id, nodeChildren, drawName, dx, dy, pRotate, angle);
|
AddNodeToNewPath(initData, newPath, path.at(i), nodeChildren, drawName, dx, dy, pRotate, angle);
|
||||||
}
|
}
|
||||||
const quint32 idPath = initData.data->AddPiecePath(newPath);
|
const quint32 idPath = initData.data->AddPiecePath(newPath);
|
||||||
VToolPiecePath::Create(idPath, newPath, NULL_ID, initData.scene, initData.doc, initData.data, initData.parse,
|
|
||||||
Source::FromTool, drawName, id);
|
VToolPiecePathInitData initNodeData;
|
||||||
|
initNodeData.id = idPath;
|
||||||
|
initNodeData.idObject = NULL_ID;
|
||||||
|
initNodeData.scene = initData.scene;
|
||||||
|
initNodeData.doc = initData.doc;
|
||||||
|
initNodeData.data = initData.data;
|
||||||
|
initNodeData.parse = Document::FullParse;
|
||||||
|
initNodeData.typeCreation = Source::FromTool;
|
||||||
|
initNodeData.idTool = initData.id;
|
||||||
|
initNodeData.drawName = drawName;
|
||||||
|
initNodeData.path = newPath;
|
||||||
|
|
||||||
|
VToolPiecePath::Create(initNodeData);
|
||||||
newDetail.GetInternalPaths().append(idPath);
|
newDetail.GetInternalPaths().append(idPath);
|
||||||
nodeChildren.prepend(idPath);
|
nodeChildren.prepend(idPath);
|
||||||
}
|
}
|
||||||
|
@ -1076,9 +1157,9 @@ void CreateUnitedDetailInternalPaths(VPiece &newDetail, const VPiece &d, QVector
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void CreateUnitedInternalPaths(VPiece &newDetail, const VPiece &d1, const VPiece &d2, quint32 id,
|
void CreateUnitedInternalPaths(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName,
|
||||||
const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy,
|
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
|
||||||
quint32 pRotate, qreal angle)
|
qreal angle)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d1.GetInternalPaths().size(); ++i)
|
for (int i = 0; i < d1.GetInternalPaths().size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -1086,20 +1167,20 @@ void CreateUnitedInternalPaths(VPiece &newDetail, const VPiece &d1, const VPiece
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<quint32> children;
|
QVector<quint32> children;
|
||||||
CreateUnitedDetailInternalPaths(newDetail, d2, children, id, drawName, initData, dx, dy, pRotate, angle);
|
CreateUnitedDetailInternalPaths(newDetail, d2, children, drawName, initData, dx, dy, pRotate, angle);
|
||||||
|
|
||||||
SaveInternalPathsChildren(initData.doc, id, children);
|
SaveInternalPathsChildren(initData.doc, initData.id, children);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector<quint32> &children, quint32 idTool,
|
void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector<quint32> &children,
|
||||||
const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy,
|
const QString &drawName, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy,
|
||||||
quint32 pRotate, qreal angle)
|
quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
QVector<quint32> nodeChildren;
|
QVector<quint32> nodeChildren;
|
||||||
for(int i=0; i < d.GetPins().size(); ++i)
|
for(int i=0; i < d.GetPins().size(); ++i)
|
||||||
{
|
{
|
||||||
const quint32 id = AddPin(d.GetPins().at(i), initData, idTool, children, drawName, dx, dy, pRotate, angle);
|
const quint32 id = AddPin(d.GetPins().at(i), initData, children, drawName, dx, dy, pRotate, angle);
|
||||||
newDetail.GetPins().append(id);
|
newDetail.GetPins().append(id);
|
||||||
nodeChildren.prepend(id);
|
nodeChildren.prepend(id);
|
||||||
}
|
}
|
||||||
|
@ -1107,7 +1188,7 @@ void CreateUnitedDetailPins(VPiece &newDetail, const VPiece &d, QVector<quint32>
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void CreateUnitedPins(VPiece &newDetail, const VPiece &d1, const VPiece &d2, quint32 id, const QString &drawName,
|
void CreateUnitedPins(VPiece &newDetail, const VPiece &d1, const VPiece &d2, const QString &drawName,
|
||||||
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d1.GetPins().size(); ++i)
|
for (int i = 0; i < d1.GetPins().size(); ++i)
|
||||||
|
@ -1116,21 +1197,20 @@ void CreateUnitedPins(VPiece &newDetail, const VPiece &d1, const VPiece &d2, qui
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<quint32> children;
|
QVector<quint32> children;
|
||||||
CreateUnitedDetailPins(newDetail, d2, children, id, drawName, initData, dx, dy, pRotate, angle);
|
CreateUnitedDetailPins(newDetail, d2, children, drawName, initData, dx, dy, pRotate, angle);
|
||||||
SavePinsChildren(initData.doc, id, children);
|
SavePinsChildren(initData.doc, initData.id, children);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void UpdateUnitedNodes(quint32 id, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
|
void UpdateUnitedNodes(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
||||||
qreal angle)
|
|
||||||
{
|
{
|
||||||
const VPiecePath d1REPath = GetPiece1MainPath(initData.doc, id).RemoveEdge(initData.indexD1);
|
const VPiecePath d1REPath = GetPiece1MainPath(initData.doc, initData.id).RemoveEdge(initData.indexD1);
|
||||||
const VPiecePath d2REPath = GetPiece2MainPath(initData.doc, id).RemoveEdge(initData.indexD2);
|
const VPiecePath d2REPath = GetPiece2MainPath(initData.doc, initData.id).RemoveEdge(initData.indexD2);
|
||||||
|
|
||||||
const qint32 countNodeD1 = d1REPath.CountNodes();
|
const qint32 countNodeD1 = d1REPath.CountNodes();
|
||||||
const qint32 countNodeD2 = d2REPath.CountNodes();
|
const qint32 countNodeD2 = d2REPath.CountNodes();
|
||||||
|
|
||||||
QVector<quint32> children = GetNodesChildren(initData.doc, id);
|
QVector<quint32> children = GetNodesChildren(initData.doc, initData.id);
|
||||||
if (not children.isEmpty())
|
if (not children.isEmpty())
|
||||||
{
|
{
|
||||||
// This check need for backward compatibility
|
// This check need for backward compatibility
|
||||||
|
@ -1210,7 +1290,7 @@ void UpdateUnitedDetailPaths(const VToolUnionDetailsInitData &initData, qreal dx
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void UpdateUnitedDetailCSA(quint32 id, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
|
void UpdateUnitedDetailCSA(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
|
||||||
qreal angle, const QVector<CustomSARecord> &records)
|
qreal angle, const QVector<CustomSARecord> &records)
|
||||||
{
|
{
|
||||||
QVector<quint32> idRecords;
|
QVector<quint32> idRecords;
|
||||||
|
@ -1218,21 +1298,22 @@ void UpdateUnitedDetailCSA(quint32 id, const VToolUnionDetailsInitData &initData
|
||||||
{
|
{
|
||||||
idRecords.append(records.at(i).path);
|
idRecords.append(records.at(i).path);
|
||||||
}
|
}
|
||||||
UpdateUnitedDetailPaths(initData, dx, dy, pRotate, angle, idRecords, GetCSAChildren(initData.doc, id));
|
UpdateUnitedDetailPaths(initData, dx, dy, pRotate, angle, idRecords, GetCSAChildren(initData.doc, initData.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void UpdateUnitedDetailInternalPaths(quint32 id, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy,
|
void UpdateUnitedDetailInternalPaths(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy,
|
||||||
quint32 pRotate, qreal angle, const QVector<quint32> &records)
|
quint32 pRotate, qreal angle, const QVector<quint32> &records)
|
||||||
{
|
{
|
||||||
UpdateUnitedDetailPaths(initData, dx, dy, pRotate, angle, records, GetInternalPathsChildren(initData.doc, id));
|
UpdateUnitedDetailPaths(initData, dx, dy, pRotate, angle, records,
|
||||||
|
GetInternalPathsChildren(initData.doc, initData.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void UpdateUnitedDetailPins(quint32 id, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy,
|
void UpdateUnitedDetailPins(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle,
|
||||||
quint32 pRotate, qreal angle, const QVector<quint32> &records)
|
const QVector<quint32> &records)
|
||||||
{
|
{
|
||||||
QVector<quint32> children = GetPinChildren(initData.doc, id);
|
QVector<quint32> children = GetPinChildren(initData.doc, initData.id);
|
||||||
|
|
||||||
for (int i = 0; i < records.size(); ++i)
|
for (int i = 0; i < records.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -1248,8 +1329,7 @@ void UpdateUnitedDetailPins(quint32 id, const VToolUnionDetailsInitData &initDat
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void CreateUnitedDetail(quint32 id, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
|
void CreateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
||||||
qreal angle)
|
|
||||||
{
|
{
|
||||||
const QString drawName = DrawName(initData.doc, initData.d1id, initData.d2id);
|
const QString drawName = DrawName(initData.doc, initData.d1id, initData.d2id);
|
||||||
SCASSERT(not drawName.isEmpty())
|
SCASSERT(not drawName.isEmpty())
|
||||||
|
@ -1259,10 +1339,10 @@ void CreateUnitedDetail(quint32 id, const VToolUnionDetailsInitData &initData, q
|
||||||
|
|
||||||
VPiece newDetail;
|
VPiece newDetail;
|
||||||
|
|
||||||
CreateUnitedNodes(newDetail, d1, d2, id, drawName, initData, dx, dy, pRotate, angle);
|
CreateUnitedNodes(newDetail, d1, d2, drawName, initData, dx, dy, pRotate, angle);
|
||||||
CreateUnitedCSA(newDetail, d1, d2, id, drawName, initData, dx, dy, pRotate, angle);
|
CreateUnitedCSA(newDetail, d1, d2, drawName, initData, dx, dy, pRotate, angle);
|
||||||
CreateUnitedInternalPaths(newDetail, d1, d2, id, drawName, initData, dx, dy, pRotate, angle);
|
CreateUnitedInternalPaths(newDetail, d1, d2, drawName, initData, dx, dy, pRotate, angle);
|
||||||
CreateUnitedPins(newDetail, d1, d2, id, drawName, initData, dx, dy, pRotate, angle);
|
CreateUnitedPins(newDetail, d1, d2, drawName, initData, dx, dy, pRotate, angle);
|
||||||
|
|
||||||
newDetail.SetName(QObject::tr("United detail"));
|
newDetail.SetName(QObject::tr("United detail"));
|
||||||
QString formulaSAWidth = d1.GetFormulaSAWidth();
|
QString formulaSAWidth = d1.GetFormulaSAWidth();
|
||||||
|
@ -1270,8 +1350,18 @@ void CreateUnitedDetail(quint32 id, const VToolUnionDetailsInitData &initData, q
|
||||||
newDetail.SetMx(d1.GetMx());
|
newDetail.SetMx(d1.GetMx());
|
||||||
newDetail.SetMy(d1.GetMy());
|
newDetail.SetMy(d1.GetMy());
|
||||||
newDetail.SetUnited(true);
|
newDetail.SetUnited(true);
|
||||||
VToolSeamAllowance::Create(0, newDetail, formulaSAWidth, initData.scene, initData.doc, initData.data,
|
|
||||||
initData.parse, Source::FromTool, drawName);
|
VToolSeamAllowanceInitData pieceInitData;
|
||||||
|
pieceInitData.detail = newDetail;
|
||||||
|
pieceInitData.width = formulaSAWidth;
|
||||||
|
pieceInitData.scene = initData.scene;
|
||||||
|
pieceInitData.doc = initData.doc;
|
||||||
|
pieceInitData.data = initData.data;
|
||||||
|
pieceInitData.parse = initData.parse;
|
||||||
|
pieceInitData.typeCreation = Source::FromTool;
|
||||||
|
pieceInitData.drawName = drawName;
|
||||||
|
|
||||||
|
VToolSeamAllowance::Create(pieceInitData);
|
||||||
|
|
||||||
auto RemoveDetail = [initData](quint32 id)
|
auto RemoveDetail = [initData](quint32 id)
|
||||||
{
|
{
|
||||||
|
@ -1292,17 +1382,17 @@ void CreateUnitedDetail(quint32 id, const VToolUnionDetailsInitData &initData, q
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void UpdateUnitedDetail(quint32 id, const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate,
|
void UpdateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qreal dy, quint32 pRotate, qreal angle)
|
||||||
qreal angle)
|
|
||||||
{
|
{
|
||||||
UpdateUnitedNodes(id, initData, dx, dy, pRotate, angle);
|
UpdateUnitedNodes(initData, dx, dy, pRotate, angle);
|
||||||
UpdateUnitedDetailCSA(id, initData, dx, dy, pRotate, angle, GetPiece2CSAPaths(initData.doc, id));
|
UpdateUnitedDetailCSA(initData, dx, dy, pRotate, angle, GetPiece2CSAPaths(initData.doc, initData.id));
|
||||||
UpdateUnitedDetailInternalPaths(id, initData, dx, dy, pRotate, angle, GetPiece2InternalPaths(initData.doc, id));
|
UpdateUnitedDetailInternalPaths(initData, dx, dy, pRotate, angle,
|
||||||
UpdateUnitedDetailPins(id, initData, dx, dy, pRotate, angle, GetPiece2Pins(initData.doc, id));
|
GetPiece2InternalPaths(initData.doc, initData.id));
|
||||||
|
UpdateUnitedDetailPins(initData, dx, dy, pRotate, angle, GetPiece2Pins(initData.doc, initData.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void UniteDetails(quint32 id, const VToolUnionDetailsInitData &initData)
|
void UniteDetails(const VToolUnionDetailsInitData &initData)
|
||||||
{
|
{
|
||||||
VPieceNode det1p1;
|
VPieceNode det1p1;
|
||||||
qreal dx = 0;
|
qreal dx = 0;
|
||||||
|
@ -1314,14 +1404,14 @@ void UniteDetails(quint32 id, const VToolUnionDetailsInitData &initData)
|
||||||
const VPiece d1 = initData.data->GetPiece(initData.d1id);
|
const VPiece d1 = initData.data->GetPiece(initData.d1id);
|
||||||
const VPiece d2 = initData.data->GetPiece(initData.d2id);
|
const VPiece d2 = initData.data->GetPiece(initData.d2id);
|
||||||
UnionInitParameters(initData, d1.GetPath(), d2.GetPath(), det1p1, dx, dy, angle);
|
UnionInitParameters(initData, d1.GetPath(), d2.GetPath(), det1p1, dx, dy, angle);
|
||||||
CreateUnitedDetail(id, initData, dx, dy, det1p1.GetId(), angle);
|
CreateUnitedDetail(initData, dx, dy, det1p1.GetId(), angle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const VPiecePath d1Path = GetPiece1MainPath(initData.doc, id);
|
const VPiecePath d1Path = GetPiece1MainPath(initData.doc, initData.id);
|
||||||
const VPiecePath d2Path = GetPiece2MainPath(initData.doc, id);
|
const VPiecePath d2Path = GetPiece2MainPath(initData.doc, initData.id);
|
||||||
UnionInitParameters(initData, d1Path, d2Path, det1p1, dx, dy, angle);
|
UnionInitParameters(initData, d1Path, d2Path, det1p1, dx, dy, angle);
|
||||||
UpdateUnitedDetail(id, initData, dx, dy, det1p1.GetId(), angle);
|
UpdateUnitedDetail(initData, dx, dy, det1p1.GetId(), angle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // static functions
|
} // static functions
|
||||||
|
@ -1329,13 +1419,11 @@ void UniteDetails(quint32 id, const VToolUnionDetailsInitData &initData)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VToolUnionDetails costructor.
|
* @brief VToolUnionDetails costructor.
|
||||||
* @param id object id in container.
|
|
||||||
* @param initData global init data.
|
* @param initData global init data.
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VToolUnionDetails::VToolUnionDetails(quint32 id, const VToolUnionDetailsInitData &initData,
|
VToolUnionDetails::VToolUnionDetails(const VToolUnionDetailsInitData &initData, QObject *parent)
|
||||||
QObject *parent)
|
: VAbstractTool(initData.doc, initData.data, initData.id, parent),
|
||||||
: VAbstractTool(initData.doc, initData.data, id, parent),
|
|
||||||
d1id(initData.d1id),
|
d1id(initData.d1id),
|
||||||
d2id(initData.d2id),
|
d2id(initData.d2id),
|
||||||
indexD1(initData.indexD1),
|
indexD1(initData.indexD1),
|
||||||
|
@ -1431,7 +1519,7 @@ VToolUnionDetails* VToolUnionDetails::Create(QSharedPointer<DialogTool> dialog,
|
||||||
initData.retainPieces = dialogTool->RetainPieces();
|
initData.retainPieces = dialogTool->RetainPieces();
|
||||||
|
|
||||||
qApp->getUndoStack()->beginMacro(tr("union details"));
|
qApp->getUndoStack()->beginMacro(tr("union details"));
|
||||||
VToolUnionDetails* tool = Create(0, initData);
|
VToolUnionDetails* tool = Create(initData);
|
||||||
qApp->getUndoStack()->endMacro();
|
qApp->getUndoStack()->endMacro();
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
@ -1439,36 +1527,34 @@ VToolUnionDetails* VToolUnionDetails::Create(QSharedPointer<DialogTool> dialog,
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
|
||||||
* @param initData contains all init data.
|
* @param initData contains all init data.
|
||||||
*/
|
*/
|
||||||
VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VToolUnionDetailsInitData &initData)
|
VToolUnionDetails* VToolUnionDetails::Create(VToolUnionDetailsInitData initData)
|
||||||
{
|
{
|
||||||
VToolUnionDetails *unionDetails = nullptr;
|
VToolUnionDetails *unionDetails = nullptr;
|
||||||
quint32 id = _id;
|
|
||||||
if (initData.typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
id = VContainer::getNextId();
|
initData.id = VContainer::getNextId();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (initData.parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
initData.doc->UpdateToolData(id, initData.data);
|
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//First add tool to file
|
//First add tool to file
|
||||||
if (initData.parse == Document::FullParse)
|
if (initData.parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VAbstractTool::AddRecord(id, Tool::UnionDetails, initData.doc);
|
VAbstractTool::AddRecord(initData.id, Tool::UnionDetails, initData.doc);
|
||||||
//Scene doesn't show this tool, so doc will destroy this object.
|
//Scene doesn't show this tool, so doc will destroy this object.
|
||||||
unionDetails = new VToolUnionDetails(id, initData);
|
unionDetails = new VToolUnionDetails(initData);
|
||||||
VAbstractPattern::AddTool(id, unionDetails);
|
VAbstractPattern::AddTool(initData.id, unionDetails);
|
||||||
// Unfortunatelly doc will destroy all objects only in the end, but we should delete them before each FullParse
|
// Unfortunatelly doc will destroy all objects only in the end, but we should delete them before each FullParse
|
||||||
initData.doc->AddToolOnRemove(unionDetails);
|
initData.doc->AddToolOnRemove(unionDetails);
|
||||||
}
|
}
|
||||||
UniteDetails(id, initData);
|
UniteDetails(initData);
|
||||||
return unionDetails;
|
return unionDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,18 +47,14 @@
|
||||||
|
|
||||||
class DialogTool;
|
class DialogTool;
|
||||||
|
|
||||||
struct VToolUnionDetailsInitData
|
struct VToolUnionDetailsInitData : public VAbstractToolInitData
|
||||||
{
|
{
|
||||||
VToolUnionDetailsInitData()
|
VToolUnionDetailsInitData()
|
||||||
: d1id(NULL_ID),
|
: VAbstractToolInitData(),
|
||||||
|
d1id(NULL_ID),
|
||||||
d2id(NULL_ID),
|
d2id(NULL_ID),
|
||||||
indexD1(NULL_ID),
|
indexD1(NULL_ID),
|
||||||
indexD2(NULL_ID),
|
indexD2(NULL_ID),
|
||||||
scene(nullptr),
|
|
||||||
doc(nullptr),
|
|
||||||
data(nullptr),
|
|
||||||
parse(Document::FullParse),
|
|
||||||
typeCreation(Source::FromFile),
|
|
||||||
retainPieces(false)
|
retainPieces(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -66,11 +62,6 @@ struct VToolUnionDetailsInitData
|
||||||
quint32 d2id;
|
quint32 d2id;
|
||||||
quint32 indexD1;
|
quint32 indexD1;
|
||||||
quint32 indexD2;
|
quint32 indexD2;
|
||||||
VMainGraphicsScene *scene;
|
|
||||||
VAbstractPattern *doc;
|
|
||||||
VContainer *data;
|
|
||||||
Document parse;
|
|
||||||
Source typeCreation;
|
|
||||||
bool retainPieces;
|
bool retainPieces;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +74,7 @@ class VToolUnionDetails : public VAbstractTool
|
||||||
public:
|
public:
|
||||||
static VToolUnionDetails *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
static VToolUnionDetails *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||||
VAbstractPattern *doc, VContainer *data);
|
VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolUnionDetails *Create(const quint32 _id, const VToolUnionDetailsInitData &initData);
|
static VToolUnionDetails *Create(VToolUnionDetailsInitData initData);
|
||||||
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
static const QString TagDetail;
|
static const QString TagDetail;
|
||||||
|
@ -129,7 +120,7 @@ private:
|
||||||
/** @brief indexD2 index edge in second detail. */
|
/** @brief indexD2 index edge in second detail. */
|
||||||
quint32 indexD2;
|
quint32 indexD2;
|
||||||
|
|
||||||
VToolUnionDetails(quint32 id, const VToolUnionDetailsInitData &initData, QObject *parent = nullptr);
|
VToolUnionDetails(const VToolUnionDetailsInitData &initData, QObject *parent = nullptr);
|
||||||
|
|
||||||
void AddDetail(QDomElement &domElement, const VPiece &d) const;
|
void AddDetail(QDomElement &domElement, const VPiece &d) const;
|
||||||
void AddToModeling(const QDomElement &domElement);
|
void AddToModeling(const QDomElement &domElement);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user