Commit after success build. Still not stable.
--HG-- branch : feature
This commit is contained in:
parent
5e94742b06
commit
41f5f207d8
|
@ -133,4 +133,4 @@ INSTALLS += target \
|
|||
desktop \
|
||||
pixmaps \
|
||||
translations
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
SOURCES += \
|
||||
src/container/vpointf.cpp \
|
||||
src/container/vincrementtablerow.cpp \
|
||||
src/container/vcontainer.cpp \
|
||||
src/container/calculator.cpp \
|
||||
src/container/vstandarttablerow.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/container/vpointf.h \
|
||||
src/container/vincrementtablerow.h \
|
||||
src/container/vcontainer.h \
|
||||
src/container/calculator.h \
|
||||
|
|
|
@ -30,15 +30,15 @@
|
|||
#include "../exception/vexceptionbadid.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtAlgorithms>
|
||||
|
||||
qint64 VContainer::_id = 0;
|
||||
|
||||
VContainer::VContainer()
|
||||
:base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()),
|
||||
standartTable(QHash<QString, VStandartTableRow>()), incrementTable(QHash<QString, VIncrementTableRow>()),
|
||||
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()),
|
||||
lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), lengthArcs(QHash<QString, qreal>()),
|
||||
splinePaths(QHash<qint64, VSplinePath>()), details(QHash<qint64, VDetail>())
|
||||
:base(QHash<QString, qint32>()), gObjects(QHash<qint64, VGObject *>()),
|
||||
standartTable(QHash<QString, VStandartTableRow *>()), incrementTable(QHash<QString, VIncrementTableRow *>()),
|
||||
lengthLines(QHash<QString, qreal>()),lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
|
||||
lengthArcs(QHash<QString, qreal>()), details(QHash<qint64, VDetail *>())
|
||||
{
|
||||
SetSize(500);
|
||||
SetGrowth(1760);
|
||||
|
@ -52,11 +52,10 @@ VContainer &VContainer::operator =(const VContainer &data)
|
|||
}
|
||||
|
||||
VContainer::VContainer(const VContainer &data)
|
||||
:base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()),
|
||||
standartTable(QHash<QString, VStandartTableRow>()), incrementTable(QHash<QString, VIncrementTableRow>()),
|
||||
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()),
|
||||
lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), lengthArcs(QHash<QString, qreal>()),
|
||||
splinePaths(QHash<qint64, VSplinePath>()), details(QHash<qint64, VDetail>())
|
||||
:base(QHash<QString, qint32>()), gObjects(QHash<qint64, VGObject *>()),
|
||||
standartTable(QHash<QString, VStandartTableRow *>()), incrementTable(QHash<QString, VIncrementTableRow *>()),
|
||||
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
|
||||
lengthArcs(QHash<QString, qreal>()), details(QHash<qint64, VDetail *>())
|
||||
{
|
||||
setData(data);
|
||||
}
|
||||
|
@ -64,26 +63,23 @@ VContainer::VContainer(const VContainer &data)
|
|||
void VContainer::setData(const VContainer &data)
|
||||
{
|
||||
base = *data.DataBase();
|
||||
points = *data.DataPoints();
|
||||
gObjects = *data.DataGObjects();
|
||||
standartTable = *data.DataStandartTable();
|
||||
incrementTable = *data.DataIncrementTable();
|
||||
lengthLines = *data.DataLengthLines();
|
||||
lineAngles = *data.DataLineAngles();
|
||||
splines = *data.DataSplines();
|
||||
lengthSplines = *data.DataLengthSplines();
|
||||
arcs = *data.DataArcs();
|
||||
lengthArcs = *data.DataLengthArcs();
|
||||
splinePaths = *data.DataSplinePaths();
|
||||
details = *data.DataDetails();
|
||||
}
|
||||
|
||||
VPointF VContainer::GetPoint(qint64 id) const
|
||||
const VGObject *VContainer::GetGObject(qint64 id)const
|
||||
{
|
||||
return GetObject(points, id);
|
||||
return GetObject(gObjects, id);
|
||||
}
|
||||
|
||||
template <typename key, typename val>
|
||||
val VContainer::GetObject(const QHash<key, val> &obj, key id)
|
||||
const val *VContainer::GetObject(const QHash<key, val*> &obj, key id) const
|
||||
{
|
||||
if (obj.contains(id))
|
||||
{
|
||||
|
@ -95,13 +91,26 @@ val VContainer::GetObject(const QHash<key, val> &obj, key id)
|
|||
}
|
||||
}
|
||||
|
||||
VStandartTableRow VContainer::GetStandartTableCell(const QString &name) const
|
||||
template <typename key, typename val>
|
||||
val VContainer::GetVariable(const QHash<key, val> &obj, key id) const
|
||||
{
|
||||
if (obj.contains(id))
|
||||
{
|
||||
return obj.value(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw VExceptionBadId(tr("Can't find object"), id);
|
||||
}
|
||||
}
|
||||
|
||||
const VStandartTableRow *VContainer::GetStandartTableCell(const QString &name) const
|
||||
{
|
||||
Q_ASSERT(name.isEmpty()==false);
|
||||
return GetObject(standartTable, name);
|
||||
}
|
||||
|
||||
VIncrementTableRow VContainer::GetIncrementTableRow(const QString& name) const
|
||||
const VIncrementTableRow *VContainer::GetIncrementTableRow(const QString& name) const
|
||||
{
|
||||
Q_ASSERT(name.isEmpty()==false);
|
||||
return GetObject(incrementTable, name);
|
||||
|
@ -110,53 +119,38 @@ VIncrementTableRow VContainer::GetIncrementTableRow(const QString& name) const
|
|||
qreal VContainer::GetLine(const QString &name) const
|
||||
{
|
||||
Q_ASSERT(name.isEmpty()==false);
|
||||
return GetObject(lengthLines, name);
|
||||
return GetVariable(lengthLines, name);
|
||||
}
|
||||
|
||||
qreal VContainer::GetLengthArc(const QString &name) const
|
||||
{
|
||||
Q_ASSERT(name.isEmpty()==false);
|
||||
return GetObject(lengthArcs, name);
|
||||
return GetVariable(lengthArcs, name);
|
||||
}
|
||||
|
||||
qreal VContainer::GetLengthSpline(const QString &name) const
|
||||
{
|
||||
Q_ASSERT(name.isEmpty()==false);
|
||||
return GetObject(lengthSplines, name);
|
||||
return GetVariable(lengthSplines, name);
|
||||
}
|
||||
|
||||
qreal VContainer::GetLineAngle(const QString &name) const
|
||||
{
|
||||
Q_ASSERT(name.isEmpty()==false);
|
||||
return GetObject(lineAngles, name);
|
||||
return GetVariable(lineAngles, name);
|
||||
}
|
||||
|
||||
VSpline VContainer::GetSpline(qint64 id) const
|
||||
{
|
||||
return GetObject(splines, id);
|
||||
}
|
||||
|
||||
VArc VContainer::GetArc(qint64 id) const
|
||||
{
|
||||
return GetObject(arcs, id);
|
||||
}
|
||||
|
||||
VSplinePath VContainer::GetSplinePath(qint64 id) const
|
||||
{
|
||||
return GetObject(splinePaths, id);
|
||||
}
|
||||
|
||||
VDetail VContainer::GetDetail(qint64 id) const
|
||||
const VDetail *VContainer::GetDetail(qint64 id) const
|
||||
{
|
||||
return GetObject(details, id);
|
||||
}
|
||||
|
||||
qint64 VContainer::AddPoint(const VPointF &point)
|
||||
qint64 VContainer::AddGObject(VGObject *obj)
|
||||
{
|
||||
return AddObject(points, point);
|
||||
return AddObject(gObjects, obj);
|
||||
}
|
||||
|
||||
qint64 VContainer::AddDetail(const VDetail &detail)
|
||||
qint64 VContainer::AddDetail(VDetail *detail)
|
||||
{
|
||||
return AddObject(details, detail);
|
||||
}
|
||||
|
@ -177,101 +171,100 @@ void VContainer::UpdateId(qint64 newId)
|
|||
|
||||
QPainterPath VContainer::ContourPath(qint64 idDetail) const
|
||||
{
|
||||
VDetail detail = GetDetail(idDetail);
|
||||
const VDetail *detail = GetDetail(idDetail);
|
||||
QVector<QPointF> points;
|
||||
QVector<QPointF> pointsEkv;
|
||||
for (ptrdiff_t i = 0; i< detail.CountNode(); ++i)
|
||||
for (ptrdiff_t i = 0; i< detail->CountNode(); ++i)
|
||||
{
|
||||
switch (detail[i].getTypeTool())
|
||||
switch (detail->at(i).getTypeTool())
|
||||
{
|
||||
case (Tool::NodePoint):
|
||||
{
|
||||
VPointF point = GetPoint(detail[i].getId());
|
||||
points.append(point.toQPointF());
|
||||
if (detail.getSupplement() == true)
|
||||
const VPointF *point = GeometricObject<const VPointF*>(detail->at(i).getId());
|
||||
points.append(point->toQPointF());
|
||||
if (detail->getSupplement() == true)
|
||||
{
|
||||
QPointF pEkv = point.toQPointF();
|
||||
pEkv.setX(pEkv.x()+detail[i].getMx());
|
||||
pEkv.setY(pEkv.y()+detail[i].getMy());
|
||||
QPointF pEkv = point->toQPointF();
|
||||
pEkv.setX(pEkv.x()+detail->at(i).getMx());
|
||||
pEkv.setY(pEkv.y()+detail->at(i).getMy());
|
||||
pointsEkv.append(pEkv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeArc):
|
||||
{
|
||||
VArc arc = GetArc(detail[i].getId());
|
||||
qreal len1 = GetLengthContour(points, arc.GetPoints());
|
||||
qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints()));
|
||||
const VArc *arc = GeometricObject<const VArc *>(detail->at(i).getId());
|
||||
qreal len1 = GetLengthContour(points, arc->GetPoints());
|
||||
qreal lenReverse = GetLengthContour(points, GetReversePoint(arc->GetPoints()));
|
||||
if (len1 <= lenReverse)
|
||||
{
|
||||
points << arc.GetPoints();
|
||||
if (detail.getSupplement() == true)
|
||||
points << arc->GetPoints();
|
||||
if (detail->getSupplement() == true)
|
||||
{
|
||||
pointsEkv << biasPoints(arc.GetPoints(), detail[i].getMx(), detail[i].getMy());
|
||||
pointsEkv << biasPoints(arc->GetPoints(), detail->at(i).getMx(), detail->at(i).getMy());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points << GetReversePoint(arc.GetPoints());
|
||||
if (detail.getSupplement() == true)
|
||||
points << GetReversePoint(arc->GetPoints());
|
||||
if (detail->getSupplement() == true)
|
||||
{
|
||||
pointsEkv << biasPoints(GetReversePoint(arc.GetPoints()), detail[i].getMx(), detail[i].getMy());
|
||||
pointsEkv << biasPoints(GetReversePoint(arc->GetPoints()), detail->at(i).getMx(),
|
||||
detail->at(i).getMy());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeSpline):
|
||||
{
|
||||
VSpline spline = GetSpline(detail[i].getId());
|
||||
qreal len1 = GetLengthContour(points, spline.GetPoints());
|
||||
qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints()));
|
||||
const VSpline *spline = GeometricObject<const VSpline *>(detail->at(i).getId());
|
||||
qreal len1 = GetLengthContour(points, spline->GetPoints());
|
||||
qreal lenReverse = GetLengthContour(points, GetReversePoint(spline->GetPoints()));
|
||||
if (len1 <= lenReverse)
|
||||
{
|
||||
points << spline.GetPoints();
|
||||
if (detail.getSupplement() == true)
|
||||
points << spline->GetPoints();
|
||||
if (detail->getSupplement() == true)
|
||||
{
|
||||
pointsEkv << biasPoints(spline.GetPoints(), detail[i].getMx(), detail[i].getMy());
|
||||
pointsEkv << biasPoints(spline->GetPoints(), detail->at(i).getMx(), detail->at(i).getMy());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points << GetReversePoint(spline.GetPoints());
|
||||
if (detail.getSupplement() == true)
|
||||
points << GetReversePoint(spline->GetPoints());
|
||||
if (detail->getSupplement() == true)
|
||||
{
|
||||
pointsEkv << biasPoints(GetReversePoint(spline.GetPoints()), detail[i].getMx(),
|
||||
detail[i].getMy());
|
||||
pointsEkv << biasPoints(GetReversePoint(spline->GetPoints()), detail->at(i).getMx(),
|
||||
detail->at(i).getMy());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeSplinePath):
|
||||
{
|
||||
VSplinePath splinePath = GetSplinePath(detail[i].getId());
|
||||
qreal len1 = GetLengthContour(points, splinePath.GetPathPoints());
|
||||
qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints()));
|
||||
const VSplinePath *splinePath = GeometricObject<const VSplinePath *>(detail->at(i).getId());
|
||||
qreal len1 = GetLengthContour(points, splinePath->GetPathPoints());
|
||||
qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath->GetPathPoints()));
|
||||
if (len1 <= lenReverse)
|
||||
{
|
||||
points << splinePath.GetPathPoints();
|
||||
if (detail.getSupplement() == true)
|
||||
points << splinePath->GetPathPoints();
|
||||
if (detail->getSupplement() == true)
|
||||
{
|
||||
pointsEkv << biasPoints(splinePath.GetPathPoints(), detail[i].getMx(), detail[i].getMy());
|
||||
pointsEkv << biasPoints(splinePath->GetPathPoints(), detail->at(i).getMx(), detail->at(i).getMy());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
points << GetReversePoint(splinePath.GetPathPoints());
|
||||
if (detail.getSupplement() == true)
|
||||
points << GetReversePoint(splinePath->GetPathPoints());
|
||||
if (detail->getSupplement() == true)
|
||||
{
|
||||
pointsEkv << biasPoints(GetReversePoint(splinePath.GetPathPoints()), detail[i].getMx(),
|
||||
detail[i].getMy());
|
||||
pointsEkv << biasPoints(GetReversePoint(splinePath->GetPathPoints()), detail->at(i).getMx(),
|
||||
detail->at(i).getMy());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (Tool::SplineTool):
|
||||
break;//Nothing to do, just ignore.
|
||||
default:
|
||||
qWarning()<<"Get wrong tool type. Ignore."<<detail[i].getTypeTool();
|
||||
qWarning()<<"Get wrong tool type. Ignore."<<detail->at(i).getTypeTool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -284,16 +277,16 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
|
|||
}
|
||||
path.lineTo(points[0]);
|
||||
|
||||
if (detail.getSupplement() == true)
|
||||
if (detail->getSupplement() == true)
|
||||
{
|
||||
QPainterPath ekv;
|
||||
if (detail.getClosed() == true)
|
||||
if (detail->getClosed() == true)
|
||||
{
|
||||
ekv = Equidistant(pointsEkv, Detail::CloseEquidistant, toPixel(detail.getWidth()));
|
||||
ekv = Equidistant(pointsEkv, Detail::CloseEquidistant, toPixel(detail->getWidth()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ekv = Equidistant(pointsEkv, Detail::OpenEquidistant, toPixel(detail.getWidth()));
|
||||
ekv = Equidistant(pointsEkv, Detail::OpenEquidistant, toPixel(detail->getWidth()));
|
||||
}
|
||||
path.addPath(ekv);
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
|
@ -363,7 +356,7 @@ QPainterPath VContainer::Equidistant(QVector<QPointF> points, const Detail::Equi
|
|||
continue;
|
||||
}
|
||||
else if (i == points.size()-1 && eqv == Detail::OpenEquidistant)
|
||||
{//остання точка, polyline doesn't closed
|
||||
{//last point, polyline doesn't closed
|
||||
ekvPoints.append(SingleParallelPoint(QLineF(points[points.size()-1], points[points.size()-2]), -90,
|
||||
width));
|
||||
continue;
|
||||
|
@ -508,18 +501,21 @@ QVector<QPointF> VContainer::CheckLoops(const QVector<QPointF> &points) const
|
|||
|
||||
void VContainer::PrepareDetails(QVector<VItem *> &list) const
|
||||
{
|
||||
QHashIterator<qint64, VDetail> iDetail(details);
|
||||
while (iDetail.hasNext())
|
||||
QHashIterator<qint64, VDetail *> idetail(details);
|
||||
while (idetail.hasNext())
|
||||
{
|
||||
iDetail.next();
|
||||
list.append(new VItem(ContourPath(iDetail.key()), list.size()));
|
||||
idetail.next();
|
||||
list.append(new VItem(ContourPath(idetail.key()), list.size()));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename val>
|
||||
void VContainer::UpdateObject(QHash<qint64, val> &obj, const qint64 &id, const val& point)
|
||||
void VContainer::UpdateObject(QHash<qint64, val *> &obj, const qint64 &id, val *point)
|
||||
{
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
Q_ASSERT(point != 0);
|
||||
point->setId(id);
|
||||
delete GetObject(gObjects, id);
|
||||
obj[id] = point;
|
||||
UpdateId(id);
|
||||
}
|
||||
|
@ -532,7 +528,8 @@ void VContainer::AddLengthSpline(const QString &name, const qreal &value)
|
|||
|
||||
void VContainer::AddLengthArc(const qint64 &id)
|
||||
{
|
||||
AddLengthArc(GetArc(id).name(), toMM(GetArc(id).GetLength()));
|
||||
const VArc * arc = GeometricObject<const VArc *>(id);
|
||||
AddLengthArc(arc->name(), toMM(arc->GetLength()));
|
||||
}
|
||||
|
||||
void VContainer::AddLengthArc(const QString &name, const qreal &value)
|
||||
|
@ -549,19 +546,19 @@ void VContainer::AddLineAngle(const QString &name, const qreal &value)
|
|||
|
||||
qreal VContainer::GetValueStandartTableCell(const QString& name) const
|
||||
{
|
||||
VStandartTableRow cell = GetStandartTableCell(name);
|
||||
const VStandartTableRow *cell = GetStandartTableCell(name);
|
||||
qreal k_size = ( static_cast<qreal> (size()/10.0) - 50.0 ) / 2.0;
|
||||
qreal k_growth = ( static_cast<qreal> (growth()/10.0) - 176.0 ) / 6.0;
|
||||
qreal value = cell.GetBase() + k_size*cell.GetKsize() + k_growth*cell.GetKgrowth();
|
||||
qreal value = cell->GetBase() + k_size*cell->GetKsize() + k_growth*cell->GetKgrowth();
|
||||
return value;
|
||||
}
|
||||
|
||||
qreal VContainer::GetValueIncrementTableRow(const QString& name) const
|
||||
{
|
||||
VIncrementTableRow cell = GetIncrementTableRow(name);
|
||||
const VIncrementTableRow *cell = GetIncrementTableRow(name);
|
||||
qreal k_size = ( static_cast<qreal> (size()/10.0) - 50.0 ) / 2.0;
|
||||
qreal k_growth = ( static_cast<qreal> (growth()/10.0) - 176.0 ) / 6.0;
|
||||
qreal value = cell.getBase() + k_size*cell.getKsize() + k_growth*cell.getKgrowth();
|
||||
qreal value = cell->getBase() + k_size*cell->getKsize() + k_growth*cell->getKgrowth();
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -580,10 +577,8 @@ void VContainer::Clear()
|
|||
|
||||
void VContainer::ClearObject()
|
||||
{
|
||||
points.clear();
|
||||
splines.clear();
|
||||
arcs.clear();
|
||||
splinePaths.clear();
|
||||
qDeleteAll(gObjects);
|
||||
gObjects.clear();
|
||||
}
|
||||
|
||||
qreal VContainer::FindVar(const QString &name, bool *ok)const
|
||||
|
@ -631,77 +626,49 @@ qreal VContainer::FindVar(const QString &name, bool *ok)const
|
|||
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId)
|
||||
{
|
||||
QString nameLine = GetNameLine(firstPointId, secondPointId);
|
||||
VPointF first = GetPoint(firstPointId);
|
||||
VPointF second = GetPoint(secondPointId);
|
||||
AddLengthLine(nameLine, toMM(QLineF(first.toQPointF(), second.toQPointF()).length()));
|
||||
const VPointF *first = GeometricObject<const VPointF *>(firstPointId);
|
||||
const VPointF *second = GeometricObject<const VPointF *>(secondPointId);
|
||||
AddLengthLine(nameLine, toMM(QLineF(first->toQPointF(), second->toQPointF()).length()));
|
||||
nameLine = GetNameLineAngle(firstPointId, secondPointId);
|
||||
AddLineAngle(nameLine, QLineF(first.toQPointF(), second.toQPointF()).angle());
|
||||
}
|
||||
|
||||
qint64 VContainer::AddSpline(const VSpline &spl)
|
||||
{
|
||||
return AddObject(splines, spl);
|
||||
}
|
||||
|
||||
qint64 VContainer::AddSplinePath(const VSplinePath &splPath)
|
||||
{
|
||||
return AddObject(splinePaths, splPath);
|
||||
}
|
||||
|
||||
qint64 VContainer::AddArc(const VArc &arc)
|
||||
{
|
||||
return AddObject(arcs, arc);
|
||||
AddLineAngle(nameLine, QLineF(first->toQPointF(), second->toQPointF()).angle());
|
||||
}
|
||||
|
||||
template <typename key, typename val>
|
||||
qint64 VContainer::AddObject(QHash<key, val> &obj, const val& value)
|
||||
qint64 VContainer::AddObject(QHash<key, val*> &obj, val *value)
|
||||
{
|
||||
Q_ASSERT(value != 0);
|
||||
qint64 id = getNextId();
|
||||
value->setId(id);
|
||||
obj[id] = value;
|
||||
return id;
|
||||
}
|
||||
|
||||
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const
|
||||
{
|
||||
VPointF first = GetPoint(firstPoint);
|
||||
VPointF second = GetPoint(secondPoint);
|
||||
const VPointF *first = GeometricObject<const VPointF *>(firstPoint);
|
||||
const VPointF *second = GeometricObject<const VPointF *>(secondPoint);
|
||||
|
||||
return QString("Line_%1_%2").arg(first.name(), second.name());
|
||||
return QString("Line_%1_%2").arg(first->name(), second->name());
|
||||
}
|
||||
|
||||
QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const
|
||||
{
|
||||
VPointF first = GetPoint(firstPoint);
|
||||
VPointF second = GetPoint(secondPoint);
|
||||
const VPointF *first = GeometricObject<const VPointF *>(firstPoint);
|
||||
const VPointF *second = GeometricObject<const VPointF *>(secondPoint);
|
||||
|
||||
return QString("AngleLine_%1_%2").arg(first.name(), second.name());
|
||||
return QString("AngleLine_%1_%2").arg(first->name(), second->name());
|
||||
}
|
||||
|
||||
void VContainer::UpdatePoint(qint64 id, const VPointF &point)
|
||||
void VContainer::UpdateGObject(qint64 id, VGObject* obj)
|
||||
{
|
||||
UpdateObject(points, id, point);
|
||||
UpdateObject(gObjects, id, obj);
|
||||
}
|
||||
|
||||
void VContainer::UpdateDetail(qint64 id, const VDetail &detail)
|
||||
void VContainer::UpdateDetail(qint64 id,VDetail *detail)
|
||||
{
|
||||
UpdateObject(details, id, detail);
|
||||
}
|
||||
|
||||
void VContainer::UpdateSpline(qint64 id, const VSpline &spl)
|
||||
{
|
||||
UpdateObject(splines, id, spl);
|
||||
}
|
||||
|
||||
void VContainer::UpdateSplinePath(qint64 id, const VSplinePath &splPath)
|
||||
{
|
||||
UpdateObject(splinePaths, id, splPath);
|
||||
}
|
||||
|
||||
void VContainer::UpdateArc(qint64 id, const VArc &arc)
|
||||
{
|
||||
UpdateObject(arcs, id, arc);
|
||||
}
|
||||
|
||||
void VContainer::AddLengthLine(const QString &name, const qreal &value)
|
||||
{
|
||||
Q_ASSERT(name.isEmpty() == false);
|
||||
|
@ -710,60 +677,60 @@ void VContainer::AddLengthLine(const QString &name, const qreal &value)
|
|||
|
||||
void VContainer::CreateManTableIGroup ()
|
||||
{
|
||||
AddStandartTableCell("Pkor", VStandartTableRow(84, 0, 3));
|
||||
AddStandartTableCell("Pkor", VStandartTableRow(84, 0, 3));
|
||||
AddStandartTableCell("Vtos", VStandartTableRow(1450, 2, 51));
|
||||
AddStandartTableCell("Vtosh", VStandartTableRow(1506, 2, 54));
|
||||
AddStandartTableCell("Vpt", VStandartTableRow(1438, 3, 52));
|
||||
AddStandartTableCell("Vst", VStandartTableRow(1257, -1, 49));
|
||||
AddStandartTableCell("Vlt", VStandartTableRow(1102, 0, 43));
|
||||
AddStandartTableCell("Vk", VStandartTableRow(503, 0, 22));
|
||||
AddStandartTableCell("Vsht", VStandartTableRow(1522, 2, 54));
|
||||
AddStandartTableCell("Vzy", VStandartTableRow(1328, 0, 49));
|
||||
AddStandartTableCell("Vlop", VStandartTableRow(1320, 0, 49));
|
||||
AddStandartTableCell("Vps", VStandartTableRow(811, -1, 36));
|
||||
AddStandartTableCell("Ssh", VStandartTableRow(202, 4, 1));
|
||||
AddStandartTableCell("SgI", VStandartTableRow(517, 18, 2));
|
||||
AddStandartTableCell("SgII", VStandartTableRow(522, 19, 1));
|
||||
AddStandartTableCell("SgIII", VStandartTableRow(500, 20, 0));
|
||||
AddStandartTableCell("St", VStandartTableRow(390, 20, 0));
|
||||
AddStandartTableCell("Sb", VStandartTableRow(492, 15, 5));
|
||||
AddStandartTableCell("SbI", VStandartTableRow(482, 12, 6));
|
||||
AddStandartTableCell("Obed", VStandartTableRow(566, 18, 6));
|
||||
AddStandartTableCell("Ok", VStandartTableRow(386, 8, 8));
|
||||
AddStandartTableCell("Oi", VStandartTableRow(380, 8, 6));
|
||||
AddStandartTableCell("Osch", VStandartTableRow(234, 4, 4));
|
||||
AddStandartTableCell("Dsb", VStandartTableRow(1120, 0, 44));
|
||||
AddStandartTableCell("Dsp", VStandartTableRow(1110, 0, 43));
|
||||
AddStandartTableCell("Dn", VStandartTableRow(826, -3, 37));
|
||||
AddStandartTableCell("Dps", VStandartTableRow(316, 4, 7));
|
||||
AddStandartTableCell("Dpob", VStandartTableRow(783, 14, 15));
|
||||
AddStandartTableCell("Ds", VStandartTableRow(260, 1, 6));
|
||||
AddStandartTableCell("Op", VStandartTableRow(316, 12, 0));
|
||||
AddStandartTableCell("Ozap", VStandartTableRow(180, 4, 0));
|
||||
AddStandartTableCell("Pkis", VStandartTableRow(250, 4, 0));
|
||||
AddStandartTableCell("SHp", VStandartTableRow(160, 1, 4));
|
||||
AddStandartTableCell("Dlych", VStandartTableRow(500, 2, 15));
|
||||
AddStandartTableCell("Dzap", VStandartTableRow(768, 2, 24));
|
||||
AddStandartTableCell("DIIIp", VStandartTableRow(970, 2, 29));
|
||||
AddStandartTableCell("Vprp", VStandartTableRow(214, 3, 3));
|
||||
AddStandartTableCell("Vg", VStandartTableRow(262, 8, 3));
|
||||
AddStandartTableCell("Dtp", VStandartTableRow(460, 7, 9));
|
||||
AddStandartTableCell("Dp", VStandartTableRow(355, 5, 5));
|
||||
AddStandartTableCell("Vprz", VStandartTableRow(208, 3, 5));
|
||||
AddStandartTableCell("Dts", VStandartTableRow(438, 2, 10));
|
||||
AddStandartTableCell("DtsI", VStandartTableRow(469, 2, 10));
|
||||
AddStandartTableCell("Dvcht", VStandartTableRow(929, 9, 19));
|
||||
AddStandartTableCell("SHg", VStandartTableRow(370, 14, 4));
|
||||
AddStandartTableCell("Cg", VStandartTableRow(224, 6, 0));
|
||||
AddStandartTableCell("SHs", VStandartTableRow(416, 10, 2));
|
||||
AddStandartTableCell("dpzr", VStandartTableRow(121, 6, 0));
|
||||
AddStandartTableCell("Ogol", VStandartTableRow(576, 4, 4));
|
||||
AddStandartTableCell("Ssh1", VStandartTableRow(205, 5, 0));
|
||||
AddStandartTableCell("St", VStandartTableRow(410, 20, 0));
|
||||
AddStandartTableCell("Drzap", VStandartTableRow(594, 3, 19));
|
||||
AddStandartTableCell("DbII", VStandartTableRow(1020, 0, 44));
|
||||
AddStandartTableCell("Sb", VStandartTableRow(504, 15, 4));
|
||||
AddStandartTableCell("Pkor", new VStandartTableRow(84, 0, 3));
|
||||
AddStandartTableCell("Pkor", new VStandartTableRow(84, 0, 3));
|
||||
AddStandartTableCell("Vtos", new VStandartTableRow(1450, 2, 51));
|
||||
AddStandartTableCell("Vtosh", new VStandartTableRow(1506, 2, 54));
|
||||
AddStandartTableCell("Vpt", new VStandartTableRow(1438, 3, 52));
|
||||
AddStandartTableCell("Vst", new VStandartTableRow(1257, -1, 49));
|
||||
AddStandartTableCell("Vlt", new VStandartTableRow(1102, 0, 43));
|
||||
AddStandartTableCell("Vk", new VStandartTableRow(503, 0, 22));
|
||||
AddStandartTableCell("Vsht", new VStandartTableRow(1522, 2, 54));
|
||||
AddStandartTableCell("Vzy", new VStandartTableRow(1328, 0, 49));
|
||||
AddStandartTableCell("Vlop", new VStandartTableRow(1320, 0, 49));
|
||||
AddStandartTableCell("Vps", new VStandartTableRow(811, -1, 36));
|
||||
AddStandartTableCell("Ssh", new VStandartTableRow(202, 4, 1));
|
||||
AddStandartTableCell("SgI", new VStandartTableRow(517, 18, 2));
|
||||
AddStandartTableCell("SgII", new VStandartTableRow(522, 19, 1));
|
||||
AddStandartTableCell("SgIII", new VStandartTableRow(500, 20, 0));
|
||||
AddStandartTableCell("St", new VStandartTableRow(390, 20, 0));
|
||||
AddStandartTableCell("Sb", new VStandartTableRow(492, 15, 5));
|
||||
AddStandartTableCell("SbI", new VStandartTableRow(482, 12, 6));
|
||||
AddStandartTableCell("Obed", new VStandartTableRow(566, 18, 6));
|
||||
AddStandartTableCell("Ok", new VStandartTableRow(386, 8, 8));
|
||||
AddStandartTableCell("Oi", new VStandartTableRow(380, 8, 6));
|
||||
AddStandartTableCell("Osch", new VStandartTableRow(234, 4, 4));
|
||||
AddStandartTableCell("Dsb", new VStandartTableRow(1120, 0, 44));
|
||||
AddStandartTableCell("Dsp", new VStandartTableRow(1110, 0, 43));
|
||||
AddStandartTableCell("Dn", new VStandartTableRow(826, -3, 37));
|
||||
AddStandartTableCell("Dps", new VStandartTableRow(316, 4, 7));
|
||||
AddStandartTableCell("Dpob", new VStandartTableRow(783, 14, 15));
|
||||
AddStandartTableCell("Ds", new VStandartTableRow(260, 1, 6));
|
||||
AddStandartTableCell("Op", new VStandartTableRow(316, 12, 0));
|
||||
AddStandartTableCell("Ozap", new VStandartTableRow(180, 4, 0));
|
||||
AddStandartTableCell("Pkis", new VStandartTableRow(250, 4, 0));
|
||||
AddStandartTableCell("SHp", new VStandartTableRow(160, 1, 4));
|
||||
AddStandartTableCell("Dlych", new VStandartTableRow(500, 2, 15));
|
||||
AddStandartTableCell("Dzap", new VStandartTableRow(768, 2, 24));
|
||||
AddStandartTableCell("DIIIp", new VStandartTableRow(970, 2, 29));
|
||||
AddStandartTableCell("Vprp", new VStandartTableRow(214, 3, 3));
|
||||
AddStandartTableCell("Vg", new VStandartTableRow(262, 8, 3));
|
||||
AddStandartTableCell("Dtp", new VStandartTableRow(460, 7, 9));
|
||||
AddStandartTableCell("Dp", new VStandartTableRow(355, 5, 5));
|
||||
AddStandartTableCell("Vprz", new VStandartTableRow(208, 3, 5));
|
||||
AddStandartTableCell("Dts", new VStandartTableRow(438, 2, 10));
|
||||
AddStandartTableCell("DtsI", new VStandartTableRow(469, 2, 10));
|
||||
AddStandartTableCell("Dvcht", new VStandartTableRow(929, 9, 19));
|
||||
AddStandartTableCell("SHg", new VStandartTableRow(370, 14, 4));
|
||||
AddStandartTableCell("Cg", new VStandartTableRow(224, 6, 0));
|
||||
AddStandartTableCell("SHs", new VStandartTableRow(416, 10, 2));
|
||||
AddStandartTableCell("dpzr", new VStandartTableRow(121, 6, 0));
|
||||
AddStandartTableCell("Ogol", new VStandartTableRow(576, 4, 4));
|
||||
AddStandartTableCell("Ssh1", new VStandartTableRow(205, 5, 0));
|
||||
AddStandartTableCell("St", new VStandartTableRow(410, 20, 0));
|
||||
AddStandartTableCell("Drzap", new VStandartTableRow(594, 3, 19));
|
||||
AddStandartTableCell("DbII", new VStandartTableRow(1020, 0, 44));
|
||||
AddStandartTableCell("Sb", new VStandartTableRow(504, 15, 4));
|
||||
}
|
||||
|
||||
QVector<QPointF> VContainer::GetReversePoint(const QVector<QPointF> &points) const
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "../geometry/vsplinepath.h"
|
||||
#include "../geometry/vdetail.h"
|
||||
#include "../widgets/vitem.h"
|
||||
#include "../geometry/vgobject.h"
|
||||
|
||||
/**
|
||||
* @brief The VContainer class container of all variables.
|
||||
|
@ -63,24 +64,32 @@ public:
|
|||
* @param data container
|
||||
*/
|
||||
void setData(const VContainer &data);
|
||||
template <typename T>
|
||||
const T GeometricObject(qint64 id) const
|
||||
{
|
||||
const T obj = dynamic_cast<T>(GetObject(gObjects, id));
|
||||
Q_ASSERT(obj != 0);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GetPoint returns a point by id
|
||||
* @brief GetGObject returns a point by id
|
||||
* @param id id of point
|
||||
* @return point
|
||||
*/
|
||||
VPointF GetPoint(qint64 id) const;
|
||||
const VGObject *GetGObject(qint64 id) const;
|
||||
/**
|
||||
* @brief GetStandartTableCell return standart table row by name
|
||||
* @param name name of standart table row
|
||||
* @return row of standart table
|
||||
*/
|
||||
VStandartTableRow GetStandartTableCell(const QString& name) const;
|
||||
const VStandartTableRow *GetStandartTableCell(const QString& name) const;
|
||||
/**
|
||||
* @brief GetIncrementTableRow return increment table row by name
|
||||
* @param name name of increment table row
|
||||
* @return row of increment table
|
||||
*/
|
||||
VIncrementTableRow GetIncrementTableRow(const QString& name) const;
|
||||
const VIncrementTableRow *GetIncrementTableRow(const QString& name) const;
|
||||
/**
|
||||
* @brief GetLine return length of line by name
|
||||
* @param name name of line
|
||||
|
@ -105,30 +114,12 @@ public:
|
|||
* @return angle in degree
|
||||
*/
|
||||
qreal GetLineAngle(const QString &name) const;
|
||||
/**
|
||||
* @brief GetSpline return spline by id
|
||||
* @param id id of spline
|
||||
* @return spline
|
||||
*/
|
||||
VSpline GetSpline(qint64 id) const;
|
||||
/**
|
||||
* @brief GetArc return arc by id
|
||||
* @param id id of arc
|
||||
* @return arc
|
||||
*/
|
||||
VArc GetArc(qint64 id) const;
|
||||
/**
|
||||
* @brief GetSplinePath return spline path by id
|
||||
* @param id id of spline path
|
||||
* @return spline path
|
||||
*/
|
||||
VSplinePath GetSplinePath(qint64 id) const;
|
||||
/**
|
||||
* @brief GetDetail return detail by id
|
||||
* @param id id of detail
|
||||
* @return detail
|
||||
*/
|
||||
VDetail GetDetail(qint64 id) const;
|
||||
const VDetail *GetDetail(qint64 id) const;
|
||||
/**
|
||||
* @brief getId return current id
|
||||
* @return current id
|
||||
|
@ -139,26 +130,26 @@ public:
|
|||
* @param point new point
|
||||
* @return return id of new point in container
|
||||
*/
|
||||
qint64 AddPoint(const VPointF& point);
|
||||
qint64 AddGObject(VGObject *obj);
|
||||
/**
|
||||
* @brief AddDetail add new detail to container
|
||||
* @param detail new detail
|
||||
* @return return id of new detail in container
|
||||
*/
|
||||
qint64 AddDetail(const VDetail& detail);
|
||||
qint64 AddDetail(VDetail *detail);
|
||||
/**
|
||||
* @brief AddStandartTableCell add new row of standart table
|
||||
* @param name name of row of standart table
|
||||
* @param cell row of standart table
|
||||
*/
|
||||
inline void AddStandartTableCell(const QString& name, const VStandartTableRow& cell)
|
||||
inline void AddStandartTableCell(const QString& name, VStandartTableRow *cell)
|
||||
{standartTable[name] = cell;}
|
||||
/**
|
||||
* @brief AddIncrementTableRow add new row of increment table
|
||||
* @param name name of new row of increment table
|
||||
* @param row new row of increment table
|
||||
*/
|
||||
inline void AddIncrementTableRow(const QString& name, const VIncrementTableRow &row)
|
||||
inline void AddIncrementTableRow(const QString& name, VIncrementTableRow *row)
|
||||
{incrementTable[name] = row;}
|
||||
/**
|
||||
* @brief AddLengthLine add length of line to container
|
||||
|
@ -196,30 +187,6 @@ public:
|
|||
* @param mode mode of line
|
||||
*/
|
||||
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId);
|
||||
/**
|
||||
* @brief AddSpline add spline to container
|
||||
* @param spl new spline
|
||||
* @return id of spline in container
|
||||
*/
|
||||
qint64 AddSpline(const VSpline& spl);
|
||||
/**
|
||||
* @brief AddSplinePath add spline path to container
|
||||
* @param splPath new spline path
|
||||
* @return id of spline path in container
|
||||
*/
|
||||
qint64 AddSplinePath(const VSplinePath& splPath);
|
||||
/**
|
||||
* @brief AddArc add arc to container
|
||||
* @param arc new arc
|
||||
* @return id of arc in container in container
|
||||
*/
|
||||
qint64 AddArc(const VArc& arc);
|
||||
/**
|
||||
* @brief AddArcModeling add arc modeling to container
|
||||
* @param arc new arc modeling
|
||||
* @return id of new arc modeling in container
|
||||
*/
|
||||
qint64 AddArcModeling(const VArc& arc);
|
||||
/**
|
||||
* @brief GetNameLine return name of line
|
||||
* @param firstPoint id of first point of line
|
||||
|
@ -239,50 +206,26 @@ public:
|
|||
* @param id id of existing point
|
||||
* @param point point
|
||||
*/
|
||||
void UpdatePoint(qint64 id, const VPointF& point);
|
||||
void UpdateGObject(qint64 id, VGObject* obj);
|
||||
/**
|
||||
* @brief UpdateDetail update detail by id
|
||||
* @param id id of existing detail
|
||||
* @param detail detail
|
||||
*/
|
||||
void UpdateDetail(qint64 id, const VDetail& detail);
|
||||
/**
|
||||
* @brief UpdateSpline update spline by id
|
||||
* @param id if of existing spline
|
||||
* @param spl spline
|
||||
*/
|
||||
void UpdateSpline(qint64 id, const VSpline& spl);
|
||||
/**
|
||||
* @brief UpdateSplinePath update spline path by id
|
||||
* @param id id of existing spline path
|
||||
* @param splPath spline path
|
||||
*/
|
||||
void UpdateSplinePath(qint64 id, const VSplinePath& splPath);
|
||||
/**
|
||||
* @brief UpdateArc update arc by id
|
||||
* @param id id of existing arc
|
||||
* @param arc arc
|
||||
*/
|
||||
void UpdateArc(qint64 id, const VArc& arc);
|
||||
/**
|
||||
* @brief UpdateArcModeling update arc modeling by id
|
||||
* @param id id of existing arc modeling
|
||||
* @param arc arc modeling
|
||||
*/
|
||||
void UpdateArcModeling(qint64 id, const VArc& arc);
|
||||
void UpdateDetail(qint64 id, VDetail *detail);
|
||||
/**
|
||||
* @brief UpdateStandartTableCell update standart table row by name
|
||||
* @param name name of row
|
||||
* @param cell row of standart table
|
||||
*/
|
||||
inline void UpdateStandartTableCell(const QString& name, const VStandartTableRow& cell)
|
||||
inline void UpdateStandartTableCell(const QString& name, VStandartTableRow *cell)
|
||||
{standartTable[name] = cell;}
|
||||
/**
|
||||
* @brief UpdateIncrementTableRow update increment table row by name
|
||||
* @param name name of row
|
||||
* @param row row
|
||||
*/
|
||||
inline void UpdateIncrementTableRow(const QString& name, const VIncrementTableRow& row)
|
||||
inline void UpdateIncrementTableRow(const QString& name, VIncrementTableRow *row)
|
||||
{incrementTable[name] = row;}
|
||||
/**
|
||||
* @brief GetValueStandartTableCell return value of standart table row by name
|
||||
|
@ -368,20 +311,10 @@ public:
|
|||
*/
|
||||
inline void RemoveIncrementTableRow(const QString& name) {incrementTable.remove(name);}
|
||||
/**
|
||||
* @brief data container with dataPoints return container of points
|
||||
* @return pointer on container of points
|
||||
* @brief data container with datagObjects return container of gObjects
|
||||
* @return pointer on container of gObjects
|
||||
*/
|
||||
inline const QHash<qint64, VPointF> *DataPoints() const {return &points;}
|
||||
/**
|
||||
* @brief data container with dataSplines return container of splines
|
||||
* @return pointer on container of splines
|
||||
*/
|
||||
inline const QHash<qint64, VSpline> *DataSplines() const {return &splines;}
|
||||
/**
|
||||
* @brief data container with dataArcs return container of arcs
|
||||
* @return pointer on container of arcs
|
||||
*/
|
||||
inline const QHash<qint64, VArc> *DataArcs() const {return &arcs;}
|
||||
inline const QHash<qint64, VGObject*> *DataGObjects() const {return &gObjects;}
|
||||
/**
|
||||
* @brief data container with dataBase return container of data
|
||||
* @return pointer on container of base data
|
||||
|
@ -391,12 +324,12 @@ public:
|
|||
* @brief data container with dataStandartTable return container of standart table
|
||||
* @return pointer on container of standart table
|
||||
*/
|
||||
inline const QHash<QString, VStandartTableRow> *DataStandartTable() const {return &standartTable;}
|
||||
inline const QHash<QString, VStandartTableRow *> *DataStandartTable() const {return &standartTable;}
|
||||
/**
|
||||
* @brief data container with dataIncrementTable return container of increment table
|
||||
* @return pointer on container of increment table
|
||||
*/
|
||||
inline const QHash<QString, VIncrementTableRow> *DataIncrementTable() const {return &incrementTable;}
|
||||
inline const QHash<QString, VIncrementTableRow *> *DataIncrementTable() const {return &incrementTable;}
|
||||
/**
|
||||
* @brief data container with dataLengthLines return container of lines lengths
|
||||
* @return pointer on container of lines lengths
|
||||
|
@ -417,16 +350,11 @@ public:
|
|||
* @return pointer on container of angles of line
|
||||
*/
|
||||
inline const QHash<QString, qreal> *DataLineAngles() const {return &lineAngles;}
|
||||
/**
|
||||
* @brief data container with dataSplinePaths return container of spline paths
|
||||
* @return pointer on container of spline paths
|
||||
*/
|
||||
inline const QHash<qint64, VSplinePath> *DataSplinePaths() const {return &splinePaths;}
|
||||
/**
|
||||
* @brief data container with dataDetails return container of details
|
||||
* @return pointer on container of details
|
||||
*/
|
||||
inline const QHash<qint64, VDetail> *DataDetails() const {return &details;}
|
||||
inline const QHash<qint64, VDetail *> *DataDetails() const {return &details;}
|
||||
/**
|
||||
* @brief UpdateId update id. If new id bigger when current save new like current.
|
||||
* @param newId id
|
||||
|
@ -498,17 +426,17 @@ private:
|
|||
*/
|
||||
QHash<QString, qint32> base;
|
||||
/**
|
||||
* @brief points container of points
|
||||
* @brief gObjects graphicals objects of pattern.
|
||||
*/
|
||||
QHash<qint64, VPointF> points;
|
||||
QHash<qint64, VGObject*> gObjects;
|
||||
/**
|
||||
* @brief standartTable container of standart table rows
|
||||
*/
|
||||
QHash<QString, VStandartTableRow> standartTable;
|
||||
QHash<QString, VStandartTableRow*> standartTable;
|
||||
/**
|
||||
* @brief incrementTable
|
||||
*/
|
||||
QHash<QString, VIncrementTableRow> incrementTable;
|
||||
QHash<QString, VIncrementTableRow*> incrementTable;
|
||||
/**
|
||||
* @brief lengthLines container of lines lengths
|
||||
*/
|
||||
|
@ -517,30 +445,18 @@ private:
|
|||
* @brief lineAngles container of angles of lines
|
||||
*/
|
||||
QHash<QString, qreal> lineAngles;
|
||||
/**
|
||||
* @brief splines container of splines
|
||||
*/
|
||||
QHash<qint64, VSpline> splines;
|
||||
/**
|
||||
* @brief lengthSplines container of splines length
|
||||
*/
|
||||
QHash<QString, qreal> lengthSplines;
|
||||
/**
|
||||
* @brief arcs container of arcs
|
||||
*/
|
||||
QHash<qint64, VArc> arcs;
|
||||
/**
|
||||
* @brief lengthArcs container of arcs length
|
||||
*/
|
||||
QHash<QString, qreal> lengthArcs;
|
||||
/**
|
||||
* @brief splinePaths container of spline paths
|
||||
*/
|
||||
QHash<qint64, VSplinePath> splinePaths;
|
||||
/**
|
||||
* @brief details container of details
|
||||
*/
|
||||
QHash<qint64, VDetail> details;
|
||||
QHash<qint64, VDetail*> details;
|
||||
/**
|
||||
* @brief CreateManTableIGroup generate man standart table of measurements
|
||||
*/
|
||||
|
@ -565,7 +481,15 @@ private:
|
|||
* @param id id of object
|
||||
* @return Object
|
||||
*/
|
||||
static val GetObject(const QHash<key, val> &obj, key id);
|
||||
const val *GetObject(const QHash<key, val*> &obj, key id) const;
|
||||
template <typename key, typename val>
|
||||
/**
|
||||
* @brief GetObject return object from container
|
||||
* @param obj container
|
||||
* @param id id of object
|
||||
* @return Object
|
||||
*/
|
||||
val GetVariable(const QHash<key, val> &obj, key id) const;
|
||||
template <typename val>
|
||||
/**
|
||||
* @brief UpdateObject update object in container
|
||||
|
@ -573,7 +497,7 @@ private:
|
|||
* @param id id of existing object
|
||||
* @param point object
|
||||
*/
|
||||
static void UpdateObject(QHash<qint64, val> &obj, const qint64 &id, const val& point);
|
||||
void UpdateObject(QHash<qint64, val *> &obj, const qint64 &id, val* point);
|
||||
template <typename key, typename val>
|
||||
/**
|
||||
* @brief AddObject add object to container
|
||||
|
@ -581,7 +505,7 @@ private:
|
|||
* @param value object
|
||||
* @return id of object in container
|
||||
*/
|
||||
static qint64 AddObject(QHash<key, val> &obj, const val& value);
|
||||
static qint64 AddObject(QHash<key, val*> &obj, val *value);
|
||||
};
|
||||
|
||||
#endif // VCONTAINER_H
|
||||
|
|
|
@ -85,10 +85,10 @@ void DialogAlongLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
if (number == 0)
|
||||
{
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
||||
|
@ -99,7 +99,7 @@ void DialogAlongLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 1)
|
||||
{
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
||||
|
|
|
@ -122,9 +122,9 @@ void DialogArc::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
|
||||
ChangeCurrentText(ui->comboBoxBasePoint, point.name());
|
||||
ChangeCurrentText(ui->comboBoxBasePoint, point->name());
|
||||
emit ToolTip("");
|
||||
this->show();
|
||||
}
|
||||
|
|
|
@ -86,10 +86,10 @@ void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
if (number == 0)
|
||||
{
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
||||
|
@ -100,7 +100,7 @@ void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 1)
|
||||
{
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
||||
|
@ -111,7 +111,7 @@ void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 2)
|
||||
{
|
||||
qint32 index = ui->comboBoxThirdPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxThirdPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxThirdPoint->setCurrentIndex(index);
|
||||
|
|
|
@ -97,8 +97,8 @@ void DialogCutSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Spline)
|
||||
{
|
||||
VSpline spl = data->GetSpline(id);
|
||||
ChangeCurrentText(ui->comboBoxSpline, spl.name());
|
||||
const VSpline *spl = data->GeometricObject<const VSpline *>(id);
|
||||
ChangeCurrentText(ui->comboBoxSpline, spl->name());
|
||||
emit ToolTip("");
|
||||
this->show();
|
||||
}
|
||||
|
|
|
@ -98,8 +98,8 @@ void DialogCutSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::SplinePath)
|
||||
{
|
||||
VSplinePath splPath = data->GetSplinePath(id);
|
||||
ChangeCurrentText(ui->comboBoxSplinePath, splPath.name());
|
||||
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(id);
|
||||
ChangeCurrentText(ui->comboBoxSplinePath, splPath->name());
|
||||
emit ToolTip("");
|
||||
this->show();
|
||||
}
|
||||
|
|
|
@ -103,26 +103,26 @@ void DialogDetail::NewItem(qint64 id, const Tool::Tools &typeTool, const NodeDet
|
|||
{
|
||||
case (Tool::NodePoint):
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
name = point.name();
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
name = point->name();
|
||||
break;
|
||||
}
|
||||
case (Tool::NodeArc):
|
||||
{
|
||||
VArc arc = data->GetArc(id);
|
||||
name = arc.name();
|
||||
const VArc *arc = data->GeometricObject<const VArc *>(id);
|
||||
name = arc->name();
|
||||
break;
|
||||
}
|
||||
case (Tool::NodeSpline):
|
||||
{
|
||||
VSpline spl = data->GetSpline(id);
|
||||
name = spl.GetName();
|
||||
const VSpline *spl = data->GeometricObject<const VSpline *>(id);
|
||||
name = spl->name();
|
||||
break;
|
||||
}
|
||||
case (Tool::NodeSplinePath):
|
||||
{
|
||||
VSplinePath splPath = data->GetSplinePath(id);
|
||||
name = splPath.name();
|
||||
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(id);
|
||||
name = splPath->name();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -97,8 +97,8 @@ void DialogEndLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
ChangeCurrentText(ui->comboBoxBasePoint, point.name());
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
ChangeCurrentText(ui->comboBoxBasePoint, point->name());
|
||||
emit ToolTip("");
|
||||
this->show();
|
||||
}
|
||||
|
|
|
@ -90,21 +90,21 @@ void DialogHeight::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
switch (number)
|
||||
{
|
||||
case (0):
|
||||
ChangeCurrentText(ui->comboBoxBasePoint, point.name());
|
||||
ChangeCurrentText(ui->comboBoxBasePoint, point->name());
|
||||
number++;
|
||||
emit ToolTip(tr("Select first point of line"));
|
||||
break;
|
||||
case (1):
|
||||
ChangeCurrentText(ui->comboBoxP1Line, point.name());
|
||||
ChangeCurrentText(ui->comboBoxP1Line, point->name());
|
||||
number++;
|
||||
emit ToolTip(tr("Select second point of line"));
|
||||
break;
|
||||
case (2):
|
||||
ChangeCurrentText(ui->comboBoxP2Line, point.name());
|
||||
ChangeCurrentText(ui->comboBoxP2Line, point->name());
|
||||
number = 0;
|
||||
emit ToolTip(tr(""));
|
||||
if (isInitialized == false)
|
||||
|
|
|
@ -175,53 +175,72 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
case Tool::ArrowTool:
|
||||
break;
|
||||
case Tool::SinglePointTool:
|
||||
record = QString(tr("%1 - Base point")).arg(data->GetPoint(tool.getId()).name());
|
||||
{
|
||||
QString name = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
||||
record = QString(tr("%1 - Base point")).arg(name);
|
||||
break;
|
||||
}
|
||||
case Tool::EndLineTool:
|
||||
{
|
||||
domElement = doc->elementById(QString().setNum(tool.getId()));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0");
|
||||
}
|
||||
record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(basePointId).name(),
|
||||
data->GetPoint(tool.getId()).name());
|
||||
QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
|
||||
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
||||
record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(basePointIdName, toolIdName);
|
||||
break;
|
||||
}
|
||||
case Tool::LineTool:
|
||||
{
|
||||
domElement = doc->elementById(QString().setNum(tool.getId()));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||
secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
||||
}
|
||||
record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(data->GetPoint(firstPointId).name(),
|
||||
data->GetPoint(secondPointId).name());
|
||||
QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
|
||||
QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
||||
record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(firstPointIdName, secondPointIdName);
|
||||
break;
|
||||
}
|
||||
case Tool::AlongLineTool:
|
||||
{
|
||||
domElement = doc->elementById(QString().setNum(tool.getId()));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||
secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
||||
}
|
||||
record = QString(tr("%3 - Point along line %1_%2")).arg(data->GetPoint(basePointId).name(),
|
||||
data->GetPoint(secondPointId).name(),
|
||||
data->GetPoint(tool.getId()).name());
|
||||
QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
|
||||
QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
||||
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
||||
record = QString(tr("%3 - Point along line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName);
|
||||
break;
|
||||
}
|
||||
case Tool::ShoulderPointTool:
|
||||
record = QString(tr("%1 - Point of shoulder")).arg(data->GetPoint(tool.getId()).name());
|
||||
{
|
||||
QString name = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
||||
record = QString(tr("%1 - Point of shoulder")).arg(name);
|
||||
break;
|
||||
}
|
||||
case Tool::NormalTool:
|
||||
{
|
||||
domElement = doc->elementById(QString().setNum(tool.getId()));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
basePointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||
secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
||||
}
|
||||
record = QString(tr("%3 - normal to line %1_%2")).arg(data->GetPoint(basePointId).name(),
|
||||
data->GetPoint(secondPointId).name(),
|
||||
data->GetPoint(tool.getId()).name());
|
||||
QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
|
||||
QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
||||
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
||||
record = QString(tr("%3 - normal to line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName);
|
||||
break;
|
||||
}
|
||||
case Tool::BisectorTool:
|
||||
{
|
||||
domElement = doc->elementById(QString().setNum(tool.getId()));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
|
@ -229,12 +248,16 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
||||
thirdPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrThirdPoint, "0");
|
||||
}
|
||||
record = QString(tr("%4 - bisector of angle %1_%2_%3")).arg(data->GetPoint(firstPointId).name(),
|
||||
data->GetPoint(basePointId).name(),
|
||||
data->GetPoint(thirdPointId).name(),
|
||||
data->GetPoint(tool.getId()).name());
|
||||
QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
|
||||
QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
|
||||
QString thirdPointIdName = data->GeometricObject<const VPointF *>(thirdPointId)->name();
|
||||
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
||||
record = QString(tr("%4 - bisector of angle %1_%2_%3")).arg(firstPointIdName, basePointIdName,
|
||||
thirdPointIdName, toolIdName);
|
||||
break;
|
||||
}
|
||||
case Tool::LineIntersectTool:
|
||||
{
|
||||
domElement = doc->elementById(QString().setNum(tool.getId()));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
|
@ -243,41 +266,50 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
p1Line2 = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP1Line2, "0");
|
||||
p2Line2 = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP2Line2, "0");
|
||||
}
|
||||
record = QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(data->GetPoint(p1Line1).name(),
|
||||
data->GetPoint(p2Line1).name(),
|
||||
data->GetPoint(p1Line2).name(),
|
||||
data->GetPoint(p2Line2).name(),
|
||||
data->GetPoint(tool.getId()).name());
|
||||
QString p1Line1Name = data->GeometricObject<const VPointF *>(p1Line1)->name();
|
||||
QString p2Line1Name = data->GeometricObject<const VPointF *>(p2Line1)->name();
|
||||
QString p1Line2Name = data->GeometricObject<const VPointF *>(p1Line2)->name();
|
||||
QString p2Line2Name = data->GeometricObject<const VPointF *>(p2Line2)->name();
|
||||
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
||||
record = QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(p1Line1Name, p2Line1Name,
|
||||
p1Line2Name, p2Line2Name,
|
||||
toolIdName);
|
||||
break;
|
||||
}
|
||||
case Tool::SplineTool:
|
||||
{
|
||||
VSpline spl = data->GetSpline(tool.getId());
|
||||
record = QString(tr("Curve %1_%2")).arg(data->GetPoint(spl.GetP1()).name(),
|
||||
data->GetPoint(spl.GetP4()).name());
|
||||
const VSpline *spl = data->GeometricObject<const VSpline *>(tool.getId());
|
||||
QString splP1Name = data->GeometricObject<const VSpline *>(spl->GetP1().id())->name();
|
||||
QString splP4Name = data->GeometricObject<const VSpline *>(spl->GetP4().id())->name();
|
||||
record = QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name);
|
||||
}
|
||||
break;
|
||||
case Tool::ArcTool:
|
||||
{
|
||||
VArc arc = data->GetArc(tool.getId());
|
||||
record = QString(tr("Arc with center in point %1")).arg(data->GetPoint(arc.GetCenter()).name());
|
||||
const VArc *arc = data->GeometricObject<const VArc *>(tool.getId());
|
||||
QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name();
|
||||
record = QString(tr("Arc with center in point %1")).arg(arcCenterName);
|
||||
}
|
||||
break;
|
||||
case Tool::SplinePathTool:
|
||||
{
|
||||
VSplinePath splPath = data->GetSplinePath(tool.getId());
|
||||
QVector<VSplinePoint> points = splPath.GetSplinePath();
|
||||
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(tool.getId());
|
||||
QVector<VSplinePoint> points = splPath->GetSplinePath();
|
||||
if (points.size() != 0 )
|
||||
{
|
||||
record = QString(tr("Curve point %1")).arg(data->GetPoint(points[0].P()).name());
|
||||
QString pName = data->GeometricObject<const VPointF *>(points[0].P().id())->name();
|
||||
record = QString(tr("Curve point %1")).arg(pName);
|
||||
for (qint32 i = 1; i< points.size(); ++i)
|
||||
{
|
||||
QString name = QString("_%1").arg(data->GetPoint(points[i].P()).name());
|
||||
pName = data->GeometricObject<const VPointF *>(points[i].P().id())->name();
|
||||
QString name = QString("_%1").arg(pName);
|
||||
record.append(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Tool::PointOfContact:
|
||||
{
|
||||
domElement = doc->elementById(QString().setNum(tool.getId()));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
|
@ -285,10 +317,14 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||
secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
||||
}
|
||||
QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
|
||||
QString centerName = data->GeometricObject<const VPointF *>(center)->name();
|
||||
QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
||||
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
||||
record = QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3")).arg(
|
||||
data->GetPoint(center).name(), data->GetPoint(firstPointId).name(),
|
||||
data->GetPoint(secondPointId).name(), data->GetPoint(tool.getId()).name());
|
||||
centerName, firstPointIdName, secondPointIdName, toolIdName);
|
||||
break;
|
||||
}
|
||||
case Tool::Height:
|
||||
{
|
||||
qint64 p1LineId = 0;
|
||||
|
@ -300,9 +336,11 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
p1LineId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP1Line, "0");
|
||||
p2LineId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrP2Line, "0");
|
||||
}
|
||||
record = QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg(
|
||||
data->GetPoint(basePointId).name(), data->GetPoint(p1LineId).name(),
|
||||
data->GetPoint(p2LineId).name());
|
||||
QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
|
||||
QString p1LineIdName = data->GeometricObject<const VPointF *>(p1LineId)->name();
|
||||
QString p2LineIdName = data->GeometricObject<const VPointF *>(p2LineId)->name();
|
||||
record = QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg( basePointIdName,
|
||||
p1LineIdName, p2LineIdName);
|
||||
break;
|
||||
}
|
||||
case Tool::Triangle:
|
||||
|
@ -317,9 +355,12 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
firstPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
||||
secondPointId = doc->GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
||||
}
|
||||
record = QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg(
|
||||
data->GetPoint(axisP1Id).name(), data->GetPoint(axisP2Id).name(),
|
||||
data->GetPoint(firstPointId).name(), data->GetPoint(secondPointId).name());
|
||||
QString axisP1IdName = data->GeometricObject<const VPointF *>(axisP1Id)->name();
|
||||
QString axisP2IdName = data->GeometricObject<const VPointF *>(axisP2Id)->name();
|
||||
QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
|
||||
QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
||||
record = QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg( axisP1IdName, axisP2IdName,
|
||||
firstPointIdName, secondPointIdName);
|
||||
break;
|
||||
}
|
||||
case Tool::CutSplineTool:
|
||||
|
@ -330,10 +371,11 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
{
|
||||
splineId = doc->GetParametrLongLong(domElement, VToolCutSpline::AttrSpline, "0");
|
||||
}
|
||||
VSpline spl = data->GetSpline(splineId);
|
||||
record = QString(tr("%1 - cut curve %2_%3")).arg(data->GetPoint(tool.getId()).name(),
|
||||
data->GetPoint(spl.GetP1()).name(),
|
||||
data->GetPoint(spl.GetP4()).name());
|
||||
const VSpline *spl = data->GeometricObject<const VSpline *>(splineId);
|
||||
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
||||
QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name();
|
||||
QString splP4Name = data->GeometricObject<const VPointF *>(spl->GetP4().id())->name();
|
||||
record = QString(tr("%1 - cut curve %2_%3")).arg(toolIdName, splP1Name, splP4Name);
|
||||
}
|
||||
break;
|
||||
case Tool::CutSplinePathTool:
|
||||
|
@ -344,15 +386,17 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
{
|
||||
splinePathId = doc->GetParametrLongLong(domElement, VToolCutSplinePath::AttrSplinePath, "0");
|
||||
}
|
||||
VSplinePath splPath = data->GetSplinePath(splinePathId);
|
||||
QVector<VSplinePoint> points = splPath.GetSplinePath();
|
||||
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(splinePathId);
|
||||
QVector<VSplinePoint> points = splPath->GetSplinePath();
|
||||
if (points.size() != 0 )
|
||||
{
|
||||
record = QString(tr("%1 - cut curve point %2")).arg(data->GetPoint(tool.getId()).name(),
|
||||
data->GetPoint(points[0].P()).name());
|
||||
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
||||
QString pName = data->GeometricObject<const VPointF *>(points[0].P().id())->name();
|
||||
record = QString(tr("%1 - cut curve point %2")).arg(toolIdName, pName);
|
||||
for (qint32 i = 1; i< points.size(); ++i)
|
||||
{
|
||||
QString name = QString("_%1").arg(data->GetPoint(points[i].P()).name());
|
||||
pName = data->GeometricObject<const VPointF *>(points[i].P().id())->name();
|
||||
QString name = QString("_%1").arg(pName);
|
||||
record.append(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,14 +69,14 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget
|
|||
|
||||
void DialogIncrements::FillStandartTable()
|
||||
{
|
||||
const QHash<QString, VStandartTableRow> *standartTable = data->DataStandartTable();
|
||||
const QHash<QString, VStandartTableRow *> *standartTable = data->DataStandartTable();
|
||||
qint32 currentRow = -1;
|
||||
QHashIterator<QString, VStandartTableRow> i(*standartTable);
|
||||
QHashIterator<QString, VStandartTableRow *> i(*standartTable);
|
||||
ui->tableWidgetStandart->setRowCount ( standartTable->size() );
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
VStandartTableRow cell = i.value();
|
||||
VStandartTableRow *cell = i.value();
|
||||
currentRow++;
|
||||
|
||||
QTableWidgetItem *item = new QTableWidgetItem(QString(i.key()));
|
||||
|
@ -88,19 +88,19 @@ void DialogIncrements::FillStandartTable()
|
|||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
ui->tableWidgetStandart->setItem(currentRow, 1, item);
|
||||
|
||||
item = new QTableWidgetItem(QString().setNum(cell.GetBase()));
|
||||
item = new QTableWidgetItem(QString().setNum(cell->GetBase()));
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
ui->tableWidgetStandart->setItem(currentRow, 2, item);
|
||||
|
||||
item = new QTableWidgetItem(QString().setNum(cell.GetKsize()));
|
||||
item = new QTableWidgetItem(QString().setNum(cell->GetKsize()));
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
ui->tableWidgetStandart->setItem(currentRow, 3, item);
|
||||
|
||||
item = new QTableWidgetItem(QString().setNum(cell.GetKgrowth()));
|
||||
item = new QTableWidgetItem(QString().setNum(cell->GetKgrowth()));
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
ui->tableWidgetStandart->setItem(currentRow, 4, item);
|
||||
|
||||
item = new QTableWidgetItem(cell.GetDescription());
|
||||
item = new QTableWidgetItem(cell->GetDescription());
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
ui->tableWidgetStandart->setItem(currentRow, 5, item);
|
||||
}
|
||||
|
@ -111,15 +111,15 @@ void DialogIncrements::FillStandartTable()
|
|||
|
||||
void DialogIncrements::FillIncrementTable()
|
||||
{
|
||||
const QHash<QString, VIncrementTableRow> *incrementTable = data->DataIncrementTable();
|
||||
QHashIterator<QString, VIncrementTableRow> i(*incrementTable);
|
||||
const QHash<QString, VIncrementTableRow *> *incrementTable = data->DataIncrementTable();
|
||||
QHashIterator<QString, VIncrementTableRow *> i(*incrementTable);
|
||||
QMap<qint64, QString> map;
|
||||
//Sorting QHash by id
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
VIncrementTableRow cell = i.value();
|
||||
map.insert(cell.getId(), i.key());
|
||||
VIncrementTableRow *cell = i.value();
|
||||
map.insert(cell->getId(), i.key());
|
||||
}
|
||||
|
||||
qint32 currentRow = -1;
|
||||
|
@ -127,14 +127,14 @@ void DialogIncrements::FillIncrementTable()
|
|||
while (iMap.hasNext())
|
||||
{
|
||||
iMap.next();
|
||||
VIncrementTableRow cell = incrementTable->value(iMap.value());
|
||||
VIncrementTableRow *cell = incrementTable->value(iMap.value());
|
||||
currentRow++;
|
||||
ui->tableWidgetIncrement->setRowCount ( incrementTable->size() );
|
||||
|
||||
QTableWidgetItem *item = new QTableWidgetItem(iMap.value());
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
item->setFont(QFont("Times", 12, QFont::Bold));
|
||||
item->setData(Qt::UserRole, cell.getId());
|
||||
item->setData(Qt::UserRole, cell->getId());
|
||||
ui->tableWidgetIncrement->setItem(currentRow, 0, item);
|
||||
|
||||
item = new QTableWidgetItem(QString().setNum(data->GetValueIncrementTableRow(iMap.value())));
|
||||
|
@ -145,19 +145,19 @@ void DialogIncrements::FillIncrementTable()
|
|||
item->setFlags(flags);
|
||||
ui->tableWidgetIncrement->setItem(currentRow, 1, item);
|
||||
|
||||
item = new QTableWidgetItem(QString().setNum(cell.getBase()));
|
||||
item = new QTableWidgetItem(QString().setNum(cell->getBase()));
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
ui->tableWidgetIncrement->setItem(currentRow, 2, item);
|
||||
|
||||
item = new QTableWidgetItem(QString().setNum(cell.getKsize()));
|
||||
item = new QTableWidgetItem(QString().setNum(cell->getKsize()));
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
ui->tableWidgetIncrement->setItem(currentRow, 3, item);
|
||||
|
||||
item = new QTableWidgetItem(QString().setNum(cell.getKgrowth()));
|
||||
item = new QTableWidgetItem(QString().setNum(cell->getKgrowth()));
|
||||
item->setTextAlignment(Qt::AlignHCenter);
|
||||
ui->tableWidgetIncrement->setItem(currentRow, 4, item);
|
||||
|
||||
item = new QTableWidgetItem(cell.getDescription());
|
||||
item = new QTableWidgetItem(cell->getDescription());
|
||||
item->setTextAlignment(Qt::AlignLeft);
|
||||
ui->tableWidgetIncrement->setItem(currentRow, 5, item);
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ void DialogIncrements::clickedToolButtonAdd()
|
|||
qreal ksize = 0;
|
||||
qreal kgrowth = 0;
|
||||
QString description = QString(tr("Description"));
|
||||
VIncrementTableRow incrementRow = VIncrementTableRow(id, base, ksize, kgrowth, description);
|
||||
VIncrementTableRow *incrementRow = new VIncrementTableRow(id, base, ksize, kgrowth, description);
|
||||
data->AddIncrementTableRow(name, incrementRow);
|
||||
|
||||
AddIncrementToFile(id, name, base, ksize, kgrowth, description);
|
||||
|
@ -499,8 +499,9 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column )
|
|||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute("description", item->text());
|
||||
VIncrementTableRow incr = data->GetIncrementTableRow(itemName->text());
|
||||
incr.setDescription(item->text());
|
||||
VIncrementTableRow *incr = new VIncrementTableRow(*data->GetIncrementTableRow(itemName->text()));
|
||||
Q_ASSERT(incr != 0);
|
||||
incr->setDescription(item->text());
|
||||
data->UpdateIncrementTableRow(itemName->text(), incr);
|
||||
ui->tableWidgetIncrement->resizeColumnsToContents();
|
||||
ui->tableWidgetIncrement->resizeRowsToContents();
|
||||
|
|
|
@ -54,8 +54,8 @@ DialogLine::~DialogLine()
|
|||
void DialogLine::setSecondPoint(const qint64 &value)
|
||||
{
|
||||
secondPoint = value;
|
||||
VPointF point = data->GetPoint(value);
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(value);
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
|
||||
if (index != -1)
|
||||
{
|
||||
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
||||
|
@ -65,8 +65,8 @@ void DialogLine::setSecondPoint(const qint64 &value)
|
|||
void DialogLine::setFirstPoint(const qint64 &value)
|
||||
{
|
||||
firstPoint = value;
|
||||
VPointF point = data->GetPoint(value);
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(value);
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
|
||||
if (index != -1)
|
||||
{
|
||||
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
||||
|
@ -87,10 +87,10 @@ void DialogLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
if (number == 0)
|
||||
{
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
||||
|
@ -101,7 +101,7 @@ void DialogLine::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 1)
|
||||
{
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
||||
|
|
|
@ -61,10 +61,10 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
if (number == 0)
|
||||
{
|
||||
qint32 index = ui->comboBoxP1Line1->findText(point.name());
|
||||
qint32 index = ui->comboBoxP1Line1->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxP1Line1->setCurrentIndex(index);
|
||||
|
@ -76,7 +76,7 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 1)
|
||||
{
|
||||
qint32 index = ui->comboBoxP2Line1->findText(point.name());
|
||||
qint32 index = ui->comboBoxP2Line1->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxP2Line1->setCurrentIndex(index);
|
||||
|
@ -88,7 +88,7 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 2)
|
||||
{
|
||||
qint32 index = ui->comboBoxP1Line2->findText(point.name());
|
||||
qint32 index = ui->comboBoxP1Line2->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxP1Line2->setCurrentIndex(index);
|
||||
|
@ -100,7 +100,7 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 3)
|
||||
{
|
||||
qint32 index = ui->comboBoxP2Line2->findText(point.name());
|
||||
qint32 index = ui->comboBoxP2Line2->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxP2Line2->setCurrentIndex(index);
|
||||
|
@ -176,13 +176,13 @@ void DialogLineIntersect::CheckState()
|
|||
|
||||
bool DialogLineIntersect::CheckIntersecion()
|
||||
{
|
||||
VPointF p1L1 = data->GetPoint(p1Line1);
|
||||
VPointF p2L1 = data->GetPoint(p2Line1);
|
||||
VPointF p1L2 = data->GetPoint(p1Line2);
|
||||
VPointF p2L2 = data->GetPoint(p2Line2);
|
||||
const VPointF *p1L1 = data->GeometricObject<const VPointF *>(p1Line1);
|
||||
const VPointF *p2L1 = data->GeometricObject<const VPointF *>(p2Line1);
|
||||
const VPointF *p1L2 = data->GeometricObject<const VPointF *>(p1Line2);
|
||||
const VPointF *p2L2 = data->GeometricObject<const VPointF *>(p2Line2);
|
||||
|
||||
QLineF line1(p1L1.toQPointF(), p2L1.toQPointF());
|
||||
QLineF line2(p1L2.toQPointF(), p2L2.toQPointF());
|
||||
QLineF line1(p1L1->toQPointF(), p2L1->toQPointF());
|
||||
QLineF line2(p1L2->toQPointF(), p2L2->toQPointF());
|
||||
QPointF fPoint;
|
||||
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
|
||||
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
|
||||
|
|
|
@ -102,10 +102,10 @@ void DialogNormal::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
if (number == 0)
|
||||
{
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
||||
|
@ -116,7 +116,7 @@ void DialogNormal::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 1)
|
||||
{
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
||||
|
|
|
@ -79,10 +79,10 @@ void DialogPointOfContact::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
if (number == 0)
|
||||
{
|
||||
qint32 index = ui.comboBoxFirstPoint->findText(point.name());
|
||||
qint32 index = ui.comboBoxFirstPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui.comboBoxFirstPoint->setCurrentIndex(index);
|
||||
|
@ -93,7 +93,7 @@ void DialogPointOfContact::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 1)
|
||||
{
|
||||
qint32 index = ui.comboBoxSecondPoint->findText(point.name());
|
||||
qint32 index = ui.comboBoxSecondPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui.comboBoxSecondPoint->setCurrentIndex(index);
|
||||
|
@ -104,7 +104,7 @@ void DialogPointOfContact::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 2)
|
||||
{
|
||||
qint32 index = ui.comboBoxCenter->findText(point.name());
|
||||
qint32 index = ui.comboBoxCenter->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui.comboBoxCenter->setCurrentIndex(index);
|
||||
|
|
|
@ -65,10 +65,10 @@ void DialogPointOfIntersection::ChoosedObject(qint64 id, const Scene::Scenes &ty
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
if (number == 0)
|
||||
{
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
||||
|
@ -79,7 +79,7 @@ void DialogPointOfIntersection::ChoosedObject(qint64 id, const Scene::Scenes &ty
|
|||
}
|
||||
if (number == 1)
|
||||
{
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
||||
|
|
|
@ -47,5 +47,6 @@
|
|||
#include "dialogheight.h"
|
||||
#include "dialogcutspline.h"
|
||||
#include "dialogcutsplinepath.h"
|
||||
#include "dialoguniondetails.h"
|
||||
|
||||
#endif // DIALOGS_H
|
||||
|
|
|
@ -87,10 +87,10 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
if (number == 0)
|
||||
{
|
||||
qint32 index = ui->comboBoxP1Line->findText(point.name());
|
||||
qint32 index = ui->comboBoxP1Line->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxP1Line->setCurrentIndex(index);
|
||||
|
@ -101,7 +101,7 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 1)
|
||||
{
|
||||
qint32 index = ui->comboBoxP2Line->findText(point.name());
|
||||
qint32 index = ui->comboBoxP2Line->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxP2Line->setCurrentIndex(index);
|
||||
|
@ -112,7 +112,7 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 2)
|
||||
{
|
||||
qint32 index = ui->comboBoxPShoulder->findText(point.name());
|
||||
qint32 index = ui->comboBoxPShoulder->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxPShoulder->setCurrentIndex(index);
|
||||
|
|
|
@ -51,14 +51,19 @@ DialogSpline::~DialogSpline()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
qint64 DialogSpline::getP1() const
|
||||
{
|
||||
return p1;
|
||||
}
|
||||
|
||||
void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
||||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
if (number == 0)
|
||||
{
|
||||
qint32 index = ui->comboBoxP1->findText(point.name());
|
||||
qint32 index = ui->comboBoxP1->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxP1->setCurrentIndex(index);
|
||||
|
@ -69,7 +74,7 @@ void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
}
|
||||
if (number == 1)
|
||||
{
|
||||
qint32 index = ui->comboBoxP4->findText(point.name());
|
||||
qint32 index = ui->comboBoxP4->findText(point->name());
|
||||
if ( index != -1 )
|
||||
{ // -1 for not found
|
||||
ui->comboBoxP4->setCurrentIndex(index);
|
||||
|
@ -78,8 +83,8 @@ void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
index = ui->comboBoxP1->currentIndex();
|
||||
qint64 p1Id = qvariant_cast<qint64>(ui->comboBoxP1->itemData(index));
|
||||
|
||||
QPointF p1 = data->GetPoint(p1Id).toQPointF();
|
||||
QPointF p4 = data->GetPoint(id).toQPointF();
|
||||
QPointF p1 = data->GeometricObject<const VPointF *>(p1Id)->toQPointF();
|
||||
QPointF p4 = data->GeometricObject<const VPointF *>(id)->toQPointF();
|
||||
|
||||
ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle()));
|
||||
ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle()));
|
||||
|
@ -145,3 +150,8 @@ void DialogSpline::setP1(const qint64 &value)
|
|||
p1 = value;
|
||||
ChangeCurrentData(ui->comboBoxP1, value);
|
||||
}
|
||||
|
||||
qint64 DialogSpline::getP4() const
|
||||
{
|
||||
return p4;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
* @brief getP1 return id first point of spline
|
||||
* @return id
|
||||
*/
|
||||
inline qint64 getP1() const {return p1;}
|
||||
qint64 getP1() const;
|
||||
/**
|
||||
* @brief setP1 set id first point of spline
|
||||
* @param value id
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
* @brief getP4 return id fourth point of spline
|
||||
* @return id
|
||||
*/
|
||||
inline qint64 getP4() const {return p4;}
|
||||
qint64 getP4() const;
|
||||
/**
|
||||
* @brief setP4 set id fourth point of spline
|
||||
* @param value id
|
||||
|
|
|
@ -44,8 +44,6 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, QWidget *parent)
|
|||
|
||||
FillComboBoxPoints(ui->comboBoxPoint);
|
||||
|
||||
path = VSplinePath(data->DataPoints());
|
||||
|
||||
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogSplinePath::PointChenged);
|
||||
connect(ui->comboBoxPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogSplinePath::currentPointChanged);
|
||||
|
@ -70,7 +68,7 @@ void DialogSplinePath::SetPath(const VSplinePath &value)
|
|||
ui->listWidget->clear();
|
||||
for (qint32 i = 0; i < path.CountPoint(); ++i)
|
||||
{
|
||||
NewItem(path[i].P(), path[i].KAsm1(), path[i].Angle2(), path[i].KAsm2());
|
||||
NewItem(path[i].P().id(), path[i].KAsm1(), path[i].Angle2(), path[i].KAsm2());
|
||||
}
|
||||
ui->listWidget->setFocus(Qt::OtherFocusReason);
|
||||
ui->doubleSpinBoxKcurve->setValue(path.getKCurve());
|
||||
|
@ -108,7 +106,7 @@ void DialogSplinePath::PointChenged(int row)
|
|||
}
|
||||
QListWidgetItem *item = ui->listWidget->item( row );
|
||||
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
||||
DataPoint(p.P(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
|
||||
DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
|
||||
EnableFields();
|
||||
}
|
||||
|
||||
|
@ -118,8 +116,9 @@ void DialogSplinePath::currentPointChanged(int index)
|
|||
qint32 row = ui->listWidget->currentRow();
|
||||
QListWidgetItem *item = ui->listWidget->item( row );
|
||||
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
||||
p.SetP(id);
|
||||
DataPoint(p.P(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
p.SetP(*point);
|
||||
DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
|
||||
EnableFields();
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
||||
}
|
||||
|
@ -154,11 +153,11 @@ void DialogSplinePath::KAsm2Changed(qreal d)
|
|||
|
||||
void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
QListWidgetItem *item = new QListWidgetItem(point.name());
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
QListWidgetItem *item = new QListWidgetItem(point->name());
|
||||
item->setFont(QFont("Times", 12, QFont::Bold));
|
||||
VSplinePoint p(id, kAsm1, angle, kAsm2);
|
||||
DataPoint(id, kAsm1, angle+180, kAsm2, angle);
|
||||
VSplinePoint p(*point, kAsm1, angle, kAsm2);
|
||||
DataPoint(point->id(), kAsm1, angle+180, kAsm2, angle);
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
||||
ui->listWidget->addItem(item);
|
||||
EnableFields();
|
||||
|
@ -222,6 +221,6 @@ void DialogSplinePath::SetAngle(qint32 angle)
|
|||
QListWidgetItem *item = ui->listWidget->item( row );
|
||||
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
||||
p.SetAngle(angle);
|
||||
DataPoint(p.P(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
|
||||
DataPoint(p.P().id(), p.KAsm1(), p.Angle1(), p.KAsm2(), p.Angle2());
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "dialogtool.h"
|
||||
#include "../container/calculator.h"
|
||||
#include "../geometry/vgobject.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
|
@ -66,15 +67,19 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const
|
|||
{
|
||||
Q_ASSERT(box != 0);
|
||||
box->clear();
|
||||
const QHash<qint64, VPointF> *points = data->DataPoints();
|
||||
QHashIterator<qint64, VPointF> i(*points);
|
||||
const QHash<qint64, VGObject*> *objs = data->DataGObjects();
|
||||
QHashIterator<qint64, VGObject*> i(*objs);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.key() != id)
|
||||
{
|
||||
VPointF point = i.value();
|
||||
box->addItem(point.name(), i.key());
|
||||
VGObject *obj = i.value();
|
||||
if(obj->getType() == GObject::Point && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(i.key());
|
||||
box->addItem(point->name(), i.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,8 +88,8 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, const qint64 &id, ComboMode
|
|||
{
|
||||
Q_ASSERT(box != 0);
|
||||
box->clear();
|
||||
const QHash<qint64, VSpline> *spls = data->DataSplines();
|
||||
QHashIterator<qint64, VSpline> i(*spls);
|
||||
const QHash<qint64, VGObject *> *objs = data->DataGObjects();
|
||||
QHashIterator<qint64, VGObject*> i(*objs);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
|
@ -92,16 +97,24 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, const qint64 &id, ComboMode
|
|||
{
|
||||
if (i.key() != id + 1 && i.key() != id + 2)
|
||||
{
|
||||
VSpline spl = i.value();
|
||||
box->addItem(spl.name(), i.key());
|
||||
VGObject *obj = i.value();
|
||||
if(obj->getType() == GObject::Spline && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const VSpline *spl = data->GeometricObject<const VSpline *>(i.key());
|
||||
box->addItem(spl->name(), i.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i.key() != id)
|
||||
{
|
||||
VSpline spl = i.value();
|
||||
box->addItem(spl.name(), i.key());
|
||||
VGObject *obj = i.value();
|
||||
if(obj->getType() == GObject::Spline && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const VSpline *spl = data->GeometricObject<const VSpline *>(i.key());
|
||||
box->addItem(spl->name(), i.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,8 +124,8 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const qint64 &id, Combo
|
|||
{
|
||||
Q_ASSERT(box != 0);
|
||||
box->clear();
|
||||
const QHash<qint64, VSplinePath> *splPaths = data->DataSplinePaths();
|
||||
QHashIterator<qint64, VSplinePath> i(*splPaths);
|
||||
const QHash<qint64, VGObject *> *objs = data->DataGObjects();
|
||||
QHashIterator<qint64, VGObject *> i(*objs);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
|
@ -120,16 +133,24 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const qint64 &id, Combo
|
|||
{
|
||||
if (i.key() != id + 1 && i.key() != id + 2)
|
||||
{
|
||||
VSplinePath splPath = i.value();
|
||||
box->addItem(splPath.name(), i.key());
|
||||
VGObject *obj = i.value();
|
||||
if(obj->getType() == GObject::SplinePath && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(i.key());
|
||||
box->addItem(splPath->name(), i.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i.key() != id)
|
||||
{
|
||||
VSplinePath splPath = i.value();
|
||||
box->addItem(splPath.name(), i.key());
|
||||
VGObject *obj = i.value();
|
||||
if(obj->getType() == GObject::SplinePath && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(i.key());
|
||||
box->addItem(splPath->name(), i.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -489,17 +510,17 @@ void DialogTool::ValChenged(int row)
|
|||
}
|
||||
if (radioButtonStandartTable->isChecked())
|
||||
{
|
||||
VStandartTableRow stable = data->GetStandartTableCell(item->text());
|
||||
const VStandartTableRow *stable = data->GetStandartTableCell(item->text());
|
||||
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueStandartTableCell(item->text()))
|
||||
.arg(stable.GetDescription());
|
||||
.arg(stable->GetDescription());
|
||||
labelDescription->setText(desc);
|
||||
return;
|
||||
}
|
||||
if (radioButtonIncrements->isChecked())
|
||||
{
|
||||
VIncrementTableRow itable = data->GetIncrementTableRow(item->text());
|
||||
const VIncrementTableRow *itable = data->GetIncrementTableRow(item->text());
|
||||
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueIncrementTableRow(item->text()))
|
||||
.arg(itable.getDescription());
|
||||
.arg(itable->getDescription());
|
||||
labelDescription->setText(desc);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -61,26 +61,26 @@ void DialogTriangle::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
{
|
||||
if (type == Scene::Point)
|
||||
{
|
||||
VPointF point = data->GetPoint(id);
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
switch (number)
|
||||
{
|
||||
case (0):
|
||||
ChangeCurrentText(ui->comboBoxAxisP1, point.name());
|
||||
ChangeCurrentText(ui->comboBoxAxisP1, point->name());
|
||||
number++;
|
||||
emit ToolTip(tr("Select second point of axis"));
|
||||
break;
|
||||
case (1):
|
||||
ChangeCurrentText(ui->comboBoxAxisP2, point.name());
|
||||
ChangeCurrentText(ui->comboBoxAxisP2, point->name());
|
||||
number++;
|
||||
emit ToolTip(tr("Select first point"));
|
||||
break;
|
||||
case (2):
|
||||
ChangeCurrentText(ui->comboBoxFirstPoint, point.name());
|
||||
ChangeCurrentText(ui->comboBoxFirstPoint, point->name());
|
||||
number++;
|
||||
emit ToolTip(tr("Select second point"));
|
||||
break;
|
||||
case (3):
|
||||
ChangeCurrentText(ui->comboBoxSecondPoint, point.name());
|
||||
ChangeCurrentText(ui->comboBoxSecondPoint, point->name());
|
||||
number = 0;
|
||||
emit ToolTip(tr(""));
|
||||
if (isInitialized == false)
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "ui_dialoguniondetails.h"
|
||||
|
||||
DialogUnionDetails::DialogUnionDetails(const VContainer *data, QWidget *parent) :
|
||||
DialogTool(data, parent), ui(new Ui::DialogUnionDetails), details(VDetail()), d1(0), d2(0), d1P1(0), d1P2(0),
|
||||
DialogTool(data, parent), ui(new Ui::DialogUnionDetails), d1(0), d2(0), d1P1(0), d1P2(0),
|
||||
d2P1(0), d2P2(0), numberD(0), numberP(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -59,7 +59,6 @@ void DialogUnionDetails::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
|||
|
||||
void DialogUnionDetails::DialogAccepted()
|
||||
{
|
||||
emit ToolTip("");
|
||||
emit DialogClosed(QDialog::Accepted);
|
||||
}
|
||||
|
||||
|
@ -69,8 +68,8 @@ bool DialogUnionDetails::CheckObject(const qint64 &id, const qint64 &idDetail) c
|
|||
{
|
||||
return false;
|
||||
}
|
||||
VDetail det = data->GetDetail(idDetail);
|
||||
return det.Containes(id);
|
||||
const VDetail *det = data->GetDetail(idDetail);
|
||||
return det->Containes(id);
|
||||
}
|
||||
|
||||
void DialogUnionDetails::ChoosedDetail(const qint64 &id, const Scene::Scenes &type, qint64 &idDetail, qint64 &p1,
|
||||
|
@ -99,6 +98,10 @@ void DialogUnionDetails::ChoosedDetail(const qint64 &id, const Scene::Scenes &ty
|
|||
}
|
||||
if (numberP == 1)
|
||||
{
|
||||
if(id == p1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
p2 = id;
|
||||
++numberD;
|
||||
if(numberD > 1)
|
||||
|
|
|
@ -41,6 +41,12 @@ class DialogUnionDetails : public DialogTool
|
|||
public:
|
||||
explicit DialogUnionDetails(const VContainer *data, QWidget *parent = 0);
|
||||
~DialogUnionDetails();
|
||||
inline qint64 getD1() const {return d1;}
|
||||
inline qint64 getD2() const {return d2;}
|
||||
inline qint64 getD1P1() const {return d1P1;}
|
||||
inline qint64 getD1P2() const {return d1P2;}
|
||||
inline qint64 getD2P1() const {return d2P1;}
|
||||
inline qint64 getD2P2() const {return d2P2;}
|
||||
public slots:
|
||||
/**
|
||||
* @brief ChoosedObject gets id and type of selected object. Save correct data and ignore wrong.
|
||||
|
@ -55,10 +61,6 @@ public slots:
|
|||
private:
|
||||
Q_DISABLE_COPY(DialogUnionDetails)
|
||||
Ui::DialogUnionDetails *ui;
|
||||
/**
|
||||
* @brief details detail
|
||||
*/
|
||||
VDetail details;
|
||||
qint64 d1;
|
||||
qint64 d2;
|
||||
qint64 d1P1;
|
||||
|
|
|
@ -4,7 +4,9 @@ HEADERS += \
|
|||
src/geometry/vspline.h \
|
||||
src/geometry/vnodedetail.h \
|
||||
src/geometry/vdetail.h \
|
||||
src/geometry/varc.h
|
||||
src/geometry/varc.h \
|
||||
src/geometry/vgobject.h \
|
||||
src/geometry/vpointf.h
|
||||
|
||||
SOURCES += \
|
||||
src/geometry/vsplinepoint.cpp \
|
||||
|
@ -12,4 +14,6 @@ SOURCES += \
|
|||
src/geometry/vspline.cpp \
|
||||
src/geometry/vnodedetail.cpp \
|
||||
src/geometry/vdetail.cpp \
|
||||
src/geometry/varc.cpp
|
||||
src/geometry/varc.cpp \
|
||||
src/geometry/vgobject.cpp \
|
||||
src/geometry/vpointf.cpp
|
||||
|
|
|
@ -27,33 +27,36 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "varc.h"
|
||||
#include "vspline.h"
|
||||
#include "../exception/vexception.h"
|
||||
|
||||
class QRectF;
|
||||
|
||||
VArc::VArc ()
|
||||
: f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
|
||||
center(0), points(QHash<qint64, VPointF>()), idObject(0), _name(QString()){}
|
||||
|
||||
VArc::VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
|
||||
qreal f1, QString formulaF1, qreal f2, QString formulaF2, qint64 idObject)
|
||||
: f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius),
|
||||
center(center), points(*points), idObject(idObject), _name(QString())
|
||||
:VGObject(GObject::Arc), f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0),
|
||||
formulaRadius(QString()), center(VPointF())
|
||||
{
|
||||
/**
|
||||
* @todo Change name of arc in formula. Name now not unique.
|
||||
*/
|
||||
_name = QString ("Arc_%1").arg(this->GetCenterVPoint().name());
|
||||
}
|
||||
|
||||
VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
|
||||
QString formulaF2, qint64 idObject, Draw::Draws mode)
|
||||
: VGObject(GObject::Arc, idObject, mode), f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius),
|
||||
formulaRadius(formulaRadius),center(center)
|
||||
{
|
||||
//TODO Change name of arc in formula. Name now not unique.
|
||||
_name = QString ("Arc_%1").arg(this->GetCenter().name());
|
||||
}
|
||||
|
||||
VArc::VArc(const VArc &arc)
|
||||
: f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()),
|
||||
: VGObject(arc), f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()),
|
||||
formulaF2(arc.GetFormulaF2()), radius(arc.GetRadius()), formulaRadius(arc.GetFormulaRadius()),
|
||||
center(arc.GetCenter()), points(arc.GetDataPoints()), idObject(arc.getIdObject()), _name(arc.name()){}
|
||||
center(arc.GetCenter())
|
||||
{
|
||||
}
|
||||
|
||||
VArc &VArc::operator =(const VArc &arc)
|
||||
{
|
||||
this->points = arc.GetDataPoints();
|
||||
VGObject::operator=(arc);
|
||||
this->f1 = arc.GetF1();
|
||||
this->formulaF1 = arc.GetFormulaF1();
|
||||
this->f2 = arc.GetF2();
|
||||
|
@ -61,55 +64,29 @@ VArc &VArc::operator =(const VArc &arc)
|
|||
this->radius = arc.GetRadius();
|
||||
this->formulaRadius = arc.GetFormulaRadius();
|
||||
this->center = arc.GetCenter();
|
||||
this->idObject = arc.getIdObject();
|
||||
this->_name = arc.name();
|
||||
return *this;
|
||||
}
|
||||
|
||||
QPointF VArc::GetCenterPoint() const
|
||||
{
|
||||
return GetCenterVPoint().toQPointF();
|
||||
}
|
||||
|
||||
VPointF VArc::GetCenterVPoint() const
|
||||
{
|
||||
if (points.contains(center))
|
||||
{
|
||||
return points.value(center);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString error = QString(tr("Can't find id = %1 in table.")).arg(center);
|
||||
throw VException(error);
|
||||
}
|
||||
return VPointF();
|
||||
}
|
||||
|
||||
QPointF VArc::GetP1() const
|
||||
{
|
||||
QPointF p1 ( GetCenterPoint().x () + radius, GetCenterPoint().y () );
|
||||
QLineF centerP1(GetCenterPoint(), p1);
|
||||
QPointF p1 ( GetCenter().x () + radius, GetCenter().y () );
|
||||
QLineF centerP1(GetCenter().toQPointF(), p1);
|
||||
centerP1.setAngle(f1);
|
||||
return centerP1.p2();
|
||||
}
|
||||
|
||||
QPointF VArc::GetP2 () const
|
||||
{
|
||||
QPointF p2 ( GetCenterPoint().x () + radius, GetCenterPoint().y () );
|
||||
QLineF centerP2(GetCenterPoint(), p2);
|
||||
QPointF p2 ( GetCenter().x () + radius, GetCenter().y () );
|
||||
QLineF centerP2(GetCenter().toQPointF(), p2);
|
||||
centerP2.setAngle(f2);
|
||||
return centerP2.p2();
|
||||
}
|
||||
|
||||
const QHash<qint64, VPointF> VArc::GetDataPoints() const
|
||||
{
|
||||
return points;
|
||||
}
|
||||
|
||||
QPainterPath VArc::GetPath() const
|
||||
{
|
||||
QPainterPath Path;
|
||||
QPointF center = GetCenterPoint();
|
||||
QPointF center = GetCenter().toQPointF();
|
||||
QRectF rect(center.x()-radius, center.y()-radius, radius*2, radius*2);
|
||||
Path.moveTo(GetP1());
|
||||
qreal angle = QLineF(center, GetP1()).angleTo(QLineF(center, GetP2()));
|
||||
|
|
|
@ -29,18 +29,18 @@
|
|||
#ifndef VARC_H
|
||||
#define VARC_H
|
||||
|
||||
#include "vspline.h"
|
||||
#include "vgobject.h"
|
||||
#include <QCoreApplication>
|
||||
#include "../options.h"
|
||||
#include "vpointf.h"
|
||||
class QString;
|
||||
class QLineF;
|
||||
class QPainterPath;
|
||||
class QPointF;
|
||||
|
||||
/**
|
||||
* @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою.
|
||||
*/
|
||||
class VArc
|
||||
class VArc: public VGObject
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VArc)
|
||||
public:
|
||||
|
@ -55,8 +55,8 @@ public:
|
|||
* @param f1 початковий кут в градусах.
|
||||
* @param f2 кінцевий кут в градусах.
|
||||
*/
|
||||
VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
|
||||
qreal f1, QString formulaF1, qreal f2, QString formulaF2, qint64 idObject = 0);
|
||||
VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
|
||||
QString formulaF2, qint64 idObject = 0, Draw::Draws mode = Draw::Calculation);
|
||||
/**
|
||||
* @brief VArc
|
||||
* @param arc
|
||||
|
@ -107,32 +107,17 @@ public:
|
|||
* @brief GetCenter повертає точку центра дуги.
|
||||
* @return повертає точку центра дуги.
|
||||
*/
|
||||
inline qint64 GetCenter () const {return center;}
|
||||
/**
|
||||
* @brief GetCenterPoint
|
||||
* @return
|
||||
*/
|
||||
QPointF GetCenterPoint() const;
|
||||
/**
|
||||
* @brief GetCenterVPoint
|
||||
* @return
|
||||
*/
|
||||
VPointF GetCenterVPoint() const;
|
||||
inline VPointF GetCenter () const {return center;}
|
||||
/**
|
||||
* @brief GetP1 повертає першу точку з якої починається дуга.
|
||||
* @return точку початку дуги.
|
||||
*/
|
||||
QPointF GetP1 () const;
|
||||
QPointF GetP1() const;
|
||||
/**
|
||||
* @brief GetP2 повертає другу точку в якій закінчується дуга.
|
||||
* @return точку кінця дуги.
|
||||
*/
|
||||
QPointF GetP2 () const;
|
||||
/**
|
||||
* @brief GetDataPoints
|
||||
* @return
|
||||
*/
|
||||
const QHash<qint64, VPointF> GetDataPoints() const;
|
||||
/**
|
||||
* @brief GetPath будує шлях по даній дузі.
|
||||
* @return повертає шлях.
|
||||
|
@ -158,27 +143,7 @@ public:
|
|||
* @param number
|
||||
* @return
|
||||
*/
|
||||
QVector<QPointF> SplOfArc( qint32 number ) const;
|
||||
/**
|
||||
* @brief getIdObject
|
||||
* @return
|
||||
*/
|
||||
inline qint64 getIdObject() const {return idObject;}
|
||||
/**
|
||||
* @brief setIdObject
|
||||
* @param value
|
||||
*/
|
||||
inline void setIdObject(const qint64 &value) {idObject = value;}
|
||||
/**
|
||||
* @brief name
|
||||
* @return
|
||||
*/
|
||||
QString name() const {return _name;}
|
||||
/**
|
||||
* @brief setName
|
||||
* @param name
|
||||
*/
|
||||
void setName(const QString &name) {_name = name;}
|
||||
QVector<QPointF> SplOfArc( qint32 number ) const;
|
||||
private:
|
||||
/**
|
||||
* @brief f1 початковий кут в градусах
|
||||
|
@ -207,19 +172,7 @@ private:
|
|||
/**
|
||||
* @brief center центральна точка дуги.
|
||||
*/
|
||||
qint64 center;
|
||||
/**
|
||||
* @brief points
|
||||
*/
|
||||
QHash<qint64, VPointF> points;
|
||||
/**
|
||||
* @brief idObject
|
||||
*/
|
||||
qint64 idObject;
|
||||
/**
|
||||
* @brief _name
|
||||
*/
|
||||
QString _name;
|
||||
VPointF center;
|
||||
};
|
||||
|
||||
#endif // VARC_H
|
||||
|
|
|
@ -29,16 +29,16 @@
|
|||
#include "vdetail.h"
|
||||
|
||||
VDetail::VDetail()
|
||||
:nodes(QVector<VNodeDetail>()), name(QString()), mx(0), my(0), supplement(true), closed(true), width(10){}
|
||||
:_id(0), nodes(QVector<VNodeDetail>()), name(QString()), mx(0), my(0), supplement(true), closed(true), width(10){}
|
||||
|
||||
VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes)
|
||||
:nodes(QVector<VNodeDetail>()), name(name), mx(0), my(0), supplement(true), closed(true), width(10)
|
||||
:_id(0), nodes(QVector<VNodeDetail>()), name(name), mx(0), my(0), supplement(true), closed(true), width(10)
|
||||
{
|
||||
this->nodes = nodes;
|
||||
}
|
||||
|
||||
VDetail::VDetail(const VDetail &detail)
|
||||
:nodes(detail.getNodes()), name(detail.getName()), mx(detail.getMx()), my(detail.getMy()),
|
||||
:_id(0), nodes(detail.getNodes()), name(detail.getName()), mx(detail.getMx()), my(detail.getMy()),
|
||||
supplement(detail.getSupplement()), closed(detail.getClosed()), width(detail.getWidth()){}
|
||||
|
||||
VDetail &VDetail::operator =(const VDetail &detail)
|
||||
|
@ -66,7 +66,7 @@ void VDetail::Clear()
|
|||
|
||||
bool VDetail::Containes(const qint64 &id) const
|
||||
{
|
||||
for (qint32 i = 0; i < nodes.size(); ++i)
|
||||
for (ptrdiff_t i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
VNodeDetail node = nodes[i];
|
||||
if (node.getId() == id)
|
||||
|
@ -81,3 +81,31 @@ VNodeDetail &VDetail::operator [](ptrdiff_t indx)
|
|||
{
|
||||
return nodes[indx];
|
||||
}
|
||||
|
||||
const VNodeDetail &VDetail::at(ptrdiff_t indx) const
|
||||
{
|
||||
return nodes[indx];
|
||||
}
|
||||
|
||||
ptrdiff_t VDetail::indexOfNode(const qint64 &id) const
|
||||
{
|
||||
for (ptrdiff_t i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
VNodeDetail node = nodes[i];
|
||||
if (node.getId() == id)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
qint64 VDetail::id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
void VDetail::setId(const qint64 &id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ public:
|
|||
* @return
|
||||
*/
|
||||
VNodeDetail & operator[](ptrdiff_t indx);
|
||||
const VNodeDetail & at ( ptrdiff_t indx ) const;
|
||||
/**
|
||||
* @brief getName
|
||||
* @return
|
||||
|
@ -174,7 +175,12 @@ public:
|
|||
* @param value
|
||||
*/
|
||||
inline void setNodes(const QVector<VNodeDetail> &value) {nodes = value;}
|
||||
ptrdiff_t indexOfNode(const qint64 &id) const;
|
||||
qint64 id() const;
|
||||
void setId(const qint64 &id);
|
||||
|
||||
private:
|
||||
qint64 _id;
|
||||
/**
|
||||
* @brief nodes
|
||||
*/
|
||||
|
|
99
src/geometry/vgobject.cpp
Normal file
99
src/geometry/vgobject.cpp
Normal file
|
@ -0,0 +1,99 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vgobject.cpp
|
||||
** @author Roman Telezhinsky <dismine@gmail.com>
|
||||
** @date 27 12, 2013
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2013 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vgobject.h"
|
||||
|
||||
VGObject::VGObject()
|
||||
:_id(0), type(GObject::Point), idObject(0), _name(QString()), mode(Draw::Calculation)
|
||||
{
|
||||
}
|
||||
|
||||
VGObject::VGObject(const GObject::Type &type, const qint64 &idObject, const Draw::Draws &mode)
|
||||
:_id(0), type(type), idObject(idObject), _name(QString()), mode(mode)
|
||||
{
|
||||
}
|
||||
|
||||
VGObject::VGObject(const VGObject &obj)
|
||||
:_id(obj.id()), type(obj.getType()), idObject(obj.getIdObject()), _name(obj.name()), mode(obj.getMode())
|
||||
{
|
||||
}
|
||||
|
||||
VGObject &VGObject::operator=(const VGObject &obj)
|
||||
{
|
||||
this->_id = obj.id();
|
||||
this->type = obj.getType();
|
||||
this->idObject = obj.getIdObject();
|
||||
this->_name = obj.name();
|
||||
this->mode = obj.getMode();
|
||||
return *this;
|
||||
}
|
||||
|
||||
qint64 VGObject::getIdObject() const
|
||||
{
|
||||
return idObject;
|
||||
}
|
||||
|
||||
void VGObject::setIdObject(const qint64 &value)
|
||||
{
|
||||
idObject = value;
|
||||
}
|
||||
|
||||
QString VGObject::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void VGObject::setName(const QString &name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
Draw::Draws VGObject::getMode() const
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
|
||||
void VGObject::setMode(const Draw::Draws &value)
|
||||
{
|
||||
mode = value;
|
||||
}
|
||||
|
||||
GObject::Type VGObject::getType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
qint64 VGObject::id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
void VGObject::setId(const qint64 &id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
89
src/geometry/vgobject.h
Normal file
89
src/geometry/vgobject.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vgobject.h
|
||||
** @author Roman Telezhinsky <dismine@gmail.com>
|
||||
** @date 27 12, 2013
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2013 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VGOBJECT_H
|
||||
#define VGOBJECT_H
|
||||
|
||||
#include "../options.h"
|
||||
#include "../exception/vexception.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QHash>
|
||||
|
||||
|
||||
namespace GObject
|
||||
{
|
||||
/**
|
||||
* @brief The NodeDetail enum
|
||||
*/
|
||||
enum Type { Point, Arc, Spline, SplinePath };
|
||||
Q_DECLARE_FLAGS(Types, Type)
|
||||
}
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(GObject::Types)
|
||||
|
||||
class VGObject
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VGObject)
|
||||
public:
|
||||
VGObject();
|
||||
VGObject(const GObject::Type &type, const qint64 &idObject = 0, const Draw::Draws &mode = Draw::Calculation);
|
||||
VGObject(const VGObject &obj);
|
||||
VGObject& operator= (const VGObject &obj);
|
||||
virtual ~VGObject(){}
|
||||
qint64 getIdObject() const;
|
||||
void setIdObject(const qint64 &value);
|
||||
virtual QString name() const;
|
||||
void setName(const QString &name);
|
||||
Draw::Draws getMode() const;
|
||||
void setMode(const Draw::Draws &value);
|
||||
GObject::Type getType() const;
|
||||
qint64 id() const;
|
||||
void setId(const qint64 &id);
|
||||
protected:
|
||||
/**
|
||||
* @brief _id id in container. Ned for arcs, spline and spline paths.
|
||||
*/
|
||||
qint64 _id;
|
||||
/**
|
||||
* @brief type type of graphical object
|
||||
*/
|
||||
GObject::Type type;
|
||||
/**
|
||||
* @brief idObject id of parent object. Only for modeling. All another return 0.
|
||||
*/
|
||||
qint64 idObject;
|
||||
/**
|
||||
* @brief _name object name
|
||||
*/
|
||||
QString _name;
|
||||
/**
|
||||
* @brief mode object created in calculation or drawing mode
|
||||
*/
|
||||
Draw::Draws mode;
|
||||
};
|
||||
|
||||
#endif // VGOBJECT_H
|
|
@ -28,13 +28,18 @@
|
|||
|
||||
#include "vpointf.h"
|
||||
|
||||
VPointF::VPointF(qreal x, qreal y, QString name, qreal mx, qreal my, qint64 idObject, Draw::Draws mode)
|
||||
:VGObject(GObject::Point, idObject, mode), _mx(mx), _my(my), _x(x), _y(y)
|
||||
{
|
||||
this->_name = name;
|
||||
}
|
||||
|
||||
VPointF &VPointF::operator =(const VPointF &point)
|
||||
{
|
||||
_name = point.name();
|
||||
VGObject::operator=(point);
|
||||
_mx = point.mx();
|
||||
_my = point.my();
|
||||
_x = point.x();
|
||||
_y = point.y();
|
||||
idObject = point.getIdObject();
|
||||
return *this;
|
||||
}
|
|
@ -32,36 +32,36 @@
|
|||
#include <QPointF>
|
||||
#include <QString>
|
||||
#include "../options.h"
|
||||
#include "vgobject.h"
|
||||
|
||||
/**
|
||||
* @brief The VPointF class keep data of point.
|
||||
*/
|
||||
class VPointF
|
||||
class VPointF:public VGObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief VPointF creat empty point
|
||||
*/
|
||||
inline VPointF ()
|
||||
:_name(QString()), _mx(0), _my(0), _x(0), _y(0), idObject(0){}
|
||||
:VGObject(GObject::Point, 0, Draw::Calculation), _mx(0), _my(0), _x(0), _y(0){}
|
||||
/**
|
||||
* @brief VPointF copy constructor
|
||||
* @param point
|
||||
*/
|
||||
inline VPointF (const VPointF &point )
|
||||
:_name(point.name()), _mx(point.mx()), _my(point.my()), _x(point.x()), _y(point.y()),
|
||||
idObject(point.getIdObject()){}
|
||||
:VGObject(point), _mx(point.mx()), _my(point.my()), _x(point.x()), _y(point.y()){}
|
||||
inline VPointF (const QPointF &point )
|
||||
:VGObject(VPointF()), _mx(0), _my(0), _x(point.x()), _y(point.y()){}
|
||||
/**
|
||||
* @brief VPointF create new point
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param name name of point
|
||||
* @param mx offset name respect to x
|
||||
* @param my offset name respect to y
|
||||
* @param idObject point modeling keep here id of parent point
|
||||
*/
|
||||
inline VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my, qint64 idObject = 0)
|
||||
:_name(name), _mx(mx), _my(my), _x(x), _y(y), idObject(idObject){}
|
||||
VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my, qint64 idObject = 0,
|
||||
Draw::Draws mode = Draw::Calculation);
|
||||
/**
|
||||
* @brief operator = assignment operator
|
||||
* @param point point
|
||||
|
@ -69,11 +69,6 @@ public:
|
|||
*/
|
||||
VPointF &operator=(const VPointF &point);
|
||||
~VPointF(){}
|
||||
/**
|
||||
* @brief name return name of point
|
||||
* @return name
|
||||
*/
|
||||
inline QString name() const { return _name;}
|
||||
/**
|
||||
* @brief mx return offset name respect to x
|
||||
* @return offset
|
||||
|
@ -84,11 +79,6 @@ public:
|
|||
* @return offset
|
||||
*/
|
||||
inline qreal my() const {return _my;}
|
||||
/**
|
||||
* @brief setName set name of point
|
||||
* @param name name
|
||||
*/
|
||||
inline void setName(const QString &name) {_name = name;}
|
||||
/**
|
||||
* @brief setMx set offset name respect to x
|
||||
* @param mx offset
|
||||
|
@ -124,21 +114,7 @@ public:
|
|||
* @param value y coordinate
|
||||
*/
|
||||
inline void setY(const qreal &value){_y = value;}
|
||||
/**
|
||||
* @brief getIdObject return id of parrent.
|
||||
* @return id
|
||||
*/
|
||||
inline qint64 getIdObject() const {return idObject;}
|
||||
/**
|
||||
* @brief setIdObject set id of parent
|
||||
* @param value id
|
||||
*/
|
||||
inline void setIdObject(const qint64 &value) {idObject = value;}
|
||||
private:
|
||||
/**
|
||||
* @brief _name name of point
|
||||
*/
|
||||
QString _name;
|
||||
/**
|
||||
* @brief _mx offset name respect to x
|
||||
*/
|
||||
|
@ -155,10 +131,6 @@ private:
|
|||
* @brief _y y coordinate
|
||||
*/
|
||||
qreal _y;
|
||||
/**
|
||||
* @brief idObject id of parent. Only for point modeling. All another return 0.
|
||||
*/
|
||||
qint64 idObject;
|
||||
};
|
||||
|
||||
#endif // VPOINTF_H
|
|
@ -31,34 +31,21 @@
|
|||
#include <QDebug>
|
||||
|
||||
VSpline::VSpline()
|
||||
:p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1),
|
||||
points(QHash<qint64, VPointF>()), idObject(0), _name(QString()){}
|
||||
:VGObject(GObject::Spline), p1(VPointF()), p2(QPointF()), p3(QPointF()), p4(VPointF()), angle1(0), angle2(0),
|
||||
kAsm1(1), kAsm2(1), kCurve(1){}
|
||||
|
||||
VSpline::VSpline ( const VSpline & spline )
|
||||
:p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()),
|
||||
angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()),
|
||||
points(spline.GetDataPoints()), idObject(spline.getIdObject()), _name(spline.name()){}
|
||||
:VGObject(spline), p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()), p4(spline.GetP4 ()),
|
||||
angle1(spline.GetAngle1 ()), angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()), kAsm2(spline.GetKasm2()),
|
||||
kCurve(spline.GetKcurve()){}
|
||||
|
||||
VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
|
||||
qreal kAsm1, qreal kAsm2, qreal kCurve, qint64 idObject)
|
||||
:p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2),
|
||||
kCurve(kCurve), points(*points), idObject(idObject), _name(QString())
|
||||
VSpline::VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve,
|
||||
qint64 idObject, Draw::Draws mode)
|
||||
:VGObject(GObject::Spline, idObject, mode), p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1),
|
||||
angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve)
|
||||
{
|
||||
_name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name());
|
||||
ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve );
|
||||
}
|
||||
CreateName();
|
||||
|
||||
VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
|
||||
qreal kCurve, qint64 idObject)
|
||||
:p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(*points),
|
||||
idObject(idObject), _name(QString())
|
||||
{
|
||||
_name = QString("Spl_%1_%2").arg(this->GetPointP1().name(), this->GetPointP4().name());
|
||||
ModifiSpl ( p1, p2, p3, p4, kCurve);
|
||||
}
|
||||
|
||||
void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve)
|
||||
{
|
||||
this->p1 = p1;
|
||||
this->p4 = p4;
|
||||
this->angle1 = angle1;
|
||||
|
@ -66,130 +53,80 @@ void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, qrea
|
|||
this->kAsm1 = kAsm1;
|
||||
this->kAsm2 = kAsm2;
|
||||
this->kCurve = kCurve;
|
||||
QLineF p1pX(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + 100, GetPointP1().y());
|
||||
QLineF p1pX(GetP1().x(), GetP1().y(), GetP1().x() + 100, GetP1().y());
|
||||
p1pX.setAngle( angle1 );
|
||||
qreal L = 0, radius = 0, angle = 90;
|
||||
// angle = QLineF(GetPointP1(), p1pX.p2()).angleTo(QLineF(GetPointP1(), GetPointP4()));
|
||||
// if ( angle > 180 ){
|
||||
// angle = 360 - angle;
|
||||
// }
|
||||
QPointF point1 = GetPointP1().toQPointF();
|
||||
QPointF point4 = GetPointP4().toQPointF();
|
||||
QPointF point1 = GetP1().toQPointF();
|
||||
QPointF point4 = GetP4().toQPointF();
|
||||
radius = QLineF(QPointF(point1.x(), point4.y()), point4).length();
|
||||
// radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 );
|
||||
L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 );
|
||||
QLineF p1p2(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + L * kAsm1, GetPointP1().y());
|
||||
QLineF p1p2(GetP1().x(), GetP1().y(), GetP1().x() + L * kAsm1, GetP1().y());
|
||||
p1p2.setAngle(angle1);
|
||||
QLineF p4p3(GetPointP4().x(), GetPointP4().y(), GetPointP4().x() + L * kAsm2, GetPointP4().y());
|
||||
QLineF p4p3(GetP4().x(), GetP4().y(), GetP4().x() + L * kAsm2, GetP4().y());
|
||||
p4p3.setAngle(angle2);
|
||||
this->p2 = p1p2.p2();
|
||||
this->p3 = p4p3.p2();
|
||||
}
|
||||
|
||||
void VSpline::ModifiSpl (const qint64 &p1, const QPointF &p2, const QPointF &p3, const qint64 &p4, const qreal &kCurve)
|
||||
VSpline::VSpline (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve, qint64 idObject, Draw::Draws mode)
|
||||
:VGObject(GObject::Spline, idObject, mode), p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1),
|
||||
kCurve(1)
|
||||
{
|
||||
CreateName();
|
||||
|
||||
this->p1 = p1;
|
||||
this->p2 = p2;
|
||||
this->p3 = p3;
|
||||
this->p4 = p4;
|
||||
this->angle1 = QLineF ( GetPointP1().toQPointF(), p2 ).angle();
|
||||
this->angle2 = QLineF ( GetPointP4().toQPointF(), p3 ).angle();
|
||||
this->angle1 = QLineF ( GetP1().toQPointF(), p2 ).angle();
|
||||
this->angle2 = QLineF ( GetP4().toQPointF(), p3 ).angle();
|
||||
|
||||
QLineF p1pX(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + 100, GetPointP1().y());
|
||||
QLineF p1pX(GetP1().x(), GetP1().y(), GetP1().x() + 100, GetP1().y());
|
||||
p1pX.setAngle( angle1 );
|
||||
qreal L = 0, radius = 0, angle = 90;
|
||||
// angle = QLineF(GetPointP1(), p1pX.p2()).angleTo(QLineF(GetPointP1(), GetPointP4()));
|
||||
// if ( angle >= 180 ){
|
||||
// angle = 360 - angle;
|
||||
// }
|
||||
QPointF point1 = GetPointP1().toQPointF();
|
||||
QPointF point4 = GetPointP4().toQPointF();
|
||||
QPointF point1 = GetP1().toQPointF();
|
||||
QPointF point4 = GetP4().toQPointF();
|
||||
radius = QLineF(QPointF(point1.x(), point4.y()), point4).length();
|
||||
// radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 );
|
||||
L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 );
|
||||
|
||||
this->kCurve = kCurve;
|
||||
this->kAsm1 = QLineF ( GetPointP1().toQPointF(), p2 ).length()/L;
|
||||
this->kAsm2 = QLineF ( GetPointP4().toQPointF(), p3 ).length()/L;
|
||||
}
|
||||
|
||||
//void VSpline::RotationSpl (QPointF pRotate, qreal angle ){
|
||||
// QLineF pRotateP1 (pRotate, p1);
|
||||
// pRotateP1.setAngle(angle);
|
||||
// p1 = pRotateP1.p2();
|
||||
// QLineF pRotateP2 (pRotate, p2);
|
||||
// pRotateP2.setAngle(angle);
|
||||
// p2 = pRotateP2.p2();
|
||||
// QLineF pRotateP3 (pRotate, p3);
|
||||
// pRotateP3.setAngle(angle);
|
||||
// p3 = pRotateP3.p2();
|
||||
// QLineF pRotateP4 (pRotate, p4);
|
||||
// pRotateP4.setAngle(angle);
|
||||
// p4 = pRotateP4.p2();
|
||||
// angle1 = QLineF(p1, p2).angle();
|
||||
// angle2 = QLineF(p4, p2).angle();
|
||||
//}
|
||||
|
||||
//void VSpline::BiasSpl ( qreal mx, qreal my ){
|
||||
// p1 = QPointF(p1.x()+mx, p1.y()+my);
|
||||
// p2 = QPointF(p2.x()+mx, p2.y()+my);
|
||||
// p3 = QPointF(p3.x()+mx, p3.y()+my);
|
||||
// p4 = QPointF(p4.x()+mx, p4.y()+my);
|
||||
//}
|
||||
|
||||
VPointF VSpline::GetPointP1() const
|
||||
{
|
||||
if (points.contains(p1))
|
||||
{
|
||||
return points.value(p1);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical()<<"Не можу знайти id = "<<p1<<" в таблиці.";
|
||||
throw "Не можу знайти точку за id.";
|
||||
}
|
||||
return VPointF();
|
||||
}
|
||||
|
||||
VPointF VSpline::GetPointP4() const
|
||||
{
|
||||
if (points.contains(p4))
|
||||
{
|
||||
return points.value(p4);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical()<<"Не можу знайти id = "<<p4<<" в таблиці.";
|
||||
throw "Не можу знайти точку за id.";
|
||||
}
|
||||
return VPointF();
|
||||
this->kAsm1 = QLineF ( GetP1().toQPointF(), p2 ).length()/L;
|
||||
this->kAsm2 = QLineF ( GetP4().toQPointF(), p3 ).length()/L;
|
||||
}
|
||||
|
||||
qreal VSpline::GetLength () const
|
||||
{
|
||||
return LengthBezier ( GetPointP1().toQPointF(), this->p2, this->p3, GetPointP4().toQPointF());
|
||||
return LengthBezier ( GetP1().toQPointF(), this->p2, this->p3, GetP4().toQPointF());
|
||||
}
|
||||
|
||||
QString VSpline::GetName() const
|
||||
QString VSpline::name() const
|
||||
{
|
||||
VPointF first = GetPointP1();
|
||||
VPointF second = GetPointP4();
|
||||
return QString("Spl_%1_%2").arg(first.name(), second.name());
|
||||
return _name;
|
||||
}
|
||||
|
||||
QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *intersectionPoint ) const
|
||||
{
|
||||
QVector<qreal> px;
|
||||
QVector<qreal> py;
|
||||
px.append ( GetPointP1 ().x () );
|
||||
py.append ( GetPointP1 ().y () );
|
||||
px.append ( GetP1 ().x () );
|
||||
py.append ( GetP1 ().y () );
|
||||
QVector<qreal>& wpx = px;
|
||||
QVector<qreal>& wpy = py;
|
||||
PointBezier_r ( GetPointP1 ().x (), GetPointP1 ().y (), GetP2 ().x (), GetP2 ().y (),
|
||||
GetP3 ().x (), GetP3 ().y (), GetPointP4 ().x (), GetPointP4 ().y (),
|
||||
PointBezier_r ( GetP1 ().x (), GetP1 ().y (), GetP2 ().x (), GetP2 ().y (),
|
||||
GetP3 ().x (), GetP3 ().y (), GetP4 ().x (), GetP4 ().y (),
|
||||
0, wpx, wpy);
|
||||
px.append ( GetPointP4 ().x () );
|
||||
py.append ( GetPointP4 ().y () );
|
||||
px.append ( GetP4 ().x () );
|
||||
py.append ( GetP4 ().y () );
|
||||
qint32 i = 0;
|
||||
QPointF crosPoint;
|
||||
QLineF::IntersectType type = QLineF::NoIntersection;
|
||||
|
@ -213,7 +150,7 @@ qreal VSpline::LengthT(qreal t) const
|
|||
qWarning()<<"Wrong value t.";
|
||||
return 0;
|
||||
}
|
||||
QLineF seg1_2 ( GetPointP1 ().toQPointF(), GetP2 () );
|
||||
QLineF seg1_2 ( GetP1 ().toQPointF(), GetP2 () );
|
||||
seg1_2.setLength(seg1_2.length () * t);
|
||||
QPointF p12 = seg1_2.p2();
|
||||
|
||||
|
@ -225,7 +162,7 @@ qreal VSpline::LengthT(qreal t) const
|
|||
seg12_23.setLength(seg12_23.length () * t);
|
||||
QPointF p123 = seg12_23.p2();
|
||||
|
||||
QLineF seg3_4 ( GetP3 (), GetPointP4 ().toQPointF() );
|
||||
QLineF seg3_4 ( GetP3 (), GetP4 ().toQPointF() );
|
||||
seg3_4.setLength(seg3_4.length () * t);
|
||||
QPointF p34 = seg3_4.p2();
|
||||
|
||||
|
@ -237,7 +174,7 @@ qreal VSpline::LengthT(qreal t) const
|
|||
seg123_234.setLength(seg123_234.length () * t);
|
||||
QPointF p1234 = seg123_234.p2();
|
||||
|
||||
return LengthBezier ( GetPointP1().toQPointF(), p12, p123, p1234);
|
||||
return LengthBezier ( GetP1().toQPointF(), p12, p123, p1234);
|
||||
}
|
||||
|
||||
QPointF VSpline::CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3 ) const
|
||||
|
@ -267,7 +204,7 @@ QPointF VSpline::CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPo
|
|||
}
|
||||
}
|
||||
|
||||
QLineF seg1_2 ( GetPointP1 ().toQPointF(), GetP2 () );
|
||||
QLineF seg1_2 ( GetP1 ().toQPointF(), GetP2 () );
|
||||
seg1_2.setLength(seg1_2.length () * parT);
|
||||
QPointF p12 = seg1_2.p2();
|
||||
|
||||
|
@ -279,7 +216,7 @@ QPointF VSpline::CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPo
|
|||
seg12_23.setLength(seg12_23.length () * parT);
|
||||
QPointF p123 = seg12_23.p2();
|
||||
|
||||
QLineF seg3_4 ( GetP3 (), GetPointP4 ().toQPointF() );
|
||||
QLineF seg3_4 ( GetP3 (), GetP4 ().toQPointF() );
|
||||
seg3_4.setLength(seg3_4.length () * parT);
|
||||
QPointF p34 = seg3_4.p2();
|
||||
|
||||
|
@ -298,59 +235,9 @@ QPointF VSpline::CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPo
|
|||
return p1234;
|
||||
}
|
||||
|
||||
//void VSpline::CutSpline ( QPointF point, VSpline* curFir, VSpline* curSec ) const{
|
||||
// qreal t = param_t (point);
|
||||
// qreal length = t*this->GetLength();
|
||||
// CutSpline ( length, curFir, curSec );
|
||||
//}
|
||||
|
||||
//void VSpline::PutAlongSpl (QPointF &moveP, qreal move ) const{
|
||||
// if ( GetLength () < move ){
|
||||
// qDebug()<<"Довжина більше довжини сплайну.";
|
||||
// qDebug()<<GetLength()<<"<"<<move;
|
||||
// throw "Довжина більше довжини сплайну.";
|
||||
// }
|
||||
// if ( move <= 0 ){
|
||||
// qDebug()<<"Довжина менше дорівнює нулю.";
|
||||
// throw "Довжина менше дорівнює нулю.";
|
||||
// }
|
||||
// qreal t = 0;
|
||||
// if ( move == 0 ){
|
||||
// t = 0;
|
||||
// } else {
|
||||
// t = move / GetLength ();
|
||||
// moveP.setX ( pow ( 1 - t, 3 ) * GetPointP1 ().x () + 3 * t * pow ( 1 - t, 2 ) *
|
||||
// GetP2 ().x () + 3 * t * t * ( 1 - t ) * GetP3 ().x () +
|
||||
// pow ( t, 3 ) * GetPointP4 ().x () );
|
||||
// moveP.setY ( pow ( 1 - t, 3 ) * GetPointP1 ().y () + 3 * t * pow ( 1 - t, 2 ) *
|
||||
// GetP2 ().y () + 3 * t * t * ( 1 - t ) * GetP3 ().y () +
|
||||
// pow ( t, 3 ) * GetPointP4 ().y () );
|
||||
// }
|
||||
//}
|
||||
|
||||
QVector<QPointF> VSpline::GetPoints () const
|
||||
{
|
||||
return GetPoints(GetPointP1().toQPointF(), p2, p3, GetPointP4().toQPointF());
|
||||
// QLineF line1(points.at(0).toPoint(), points.at(1).toPoint());
|
||||
// line1.setLength(500);
|
||||
// QLineF line2 = line1;
|
||||
// line2.setAngle(line2.angle()+90);
|
||||
// qreal xk1 = line1.p2().x();
|
||||
// qreal xk0 = line1.p1().x();
|
||||
// qreal y = line2.p2().y();
|
||||
// qreal yk0 = line1.p1().y();
|
||||
// qreal yk1 = line1.p2().y();
|
||||
// qreal x = line2.p2().x();
|
||||
// qreal check = (xk1 - xk0) * (y - yk0) - (yk1 - yk0) * (x - xk0);
|
||||
// if(check > 0){
|
||||
// return points;
|
||||
// } else {
|
||||
// QVector<QPointF> reversePoints;
|
||||
// for (qint32 i = points.size() - 1; i >= 0; --i) {
|
||||
// reversePoints.append(points.at(i));
|
||||
// }
|
||||
// return reversePoints;
|
||||
// }
|
||||
return GetPoints(GetP1().toQPointF(), p2, p3, GetP4().toQPointF());
|
||||
}
|
||||
|
||||
QVector<QPointF> VSpline::GetPoints (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
|
||||
|
@ -681,6 +568,11 @@ qreal VSpline::CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2)
|
|||
return dx * dx + dy * dy;
|
||||
}
|
||||
|
||||
void VSpline::CreateName()
|
||||
{
|
||||
_name = QString("Spl_%1_%2").arg(this->GetP1().name(), this->GetP4().name());
|
||||
}
|
||||
|
||||
QPainterPath VSpline::GetPath() const
|
||||
{
|
||||
QPainterPath splinePath;
|
||||
|
@ -700,130 +592,6 @@ QPainterPath VSpline::GetPath() const
|
|||
return splinePath;
|
||||
}
|
||||
|
||||
/* Cubic equation solution. Real coefficients case.
|
||||
int Cubic(double *x,double a,double b,double c);
|
||||
Parameters:
|
||||
x - solution array (size 3). On output:
|
||||
3 real roots -> then x is filled with them;
|
||||
1 real + 2 complex -> x[0] is real, x[1] is real part of
|
||||
complex roots, x[2] - non-negative
|
||||
imaginary part.
|
||||
a, b, c - coefficients, as described
|
||||
Returns: 3 - 3 real roots;
|
||||
1 - 1 real root + 2 complex;
|
||||
2 - 1 real root + complex roots imaginary part is zero
|
||||
(i.e. 2 real roots).
|
||||
*/
|
||||
//qint32 VSpline::Cubic(qreal *x, qreal a, qreal b, qreal c){
|
||||
// qreal q,r,r2,q3;
|
||||
//
|
||||
// q = (a*a - 3.*b)/9.;
|
||||
// r = (a*(2.*a*a - 9.*b) + 27.*c)/54.;
|
||||
// r2 = r*r;
|
||||
// q3 = pow(q,3);
|
||||
// if(r2<q3) {
|
||||
// qreal t = acos(r/sqrt(q3));
|
||||
// a/=3.;
|
||||
// q = -2.*sqrt(q);
|
||||
// x[0] = q*cos(t/3.)-a;
|
||||
// x[1] = q*cos((t + M_2PI)/3.) - a;
|
||||
// x[2] = q*cos((t - M_2PI)/3.) - a;
|
||||
// return(3);
|
||||
// } else {
|
||||
// qreal aa,bb;
|
||||
// if(r<=0.){
|
||||
// r=-r;
|
||||
// }
|
||||
// aa = -pow(r + sqrt(r2-q3),1./3.);
|
||||
// if(aa!=0.){
|
||||
// bb=q/aa;
|
||||
// } else {
|
||||
// bb=0.;
|
||||
// }
|
||||
// a/=3.;
|
||||
// q = aa+bb;
|
||||
// r = aa-bb;
|
||||
// x[0] = q-a;
|
||||
// x[1] = (-0.5)*q-a;
|
||||
// x[2] = (sqrt(3.)*0.5)*fabs(r);
|
||||
// if(x[2]==0.){
|
||||
// return(2);
|
||||
// }
|
||||
// return(1);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//qreal VSpline::calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3,
|
||||
// qreal curve_coord4, qreal point_coord) const{
|
||||
// qreal P1, P2, P3, P4, Bt;
|
||||
// qreal a, b, c, d, ret_t;
|
||||
//
|
||||
// qreal *t = static_cast<qreal *>(malloc(3*sizeof(qreal)));
|
||||
// P1 = curve_coord1;
|
||||
// P2 = curve_coord2;
|
||||
// P3 = curve_coord3;
|
||||
// P4 = curve_coord4;
|
||||
// Bt = point_coord;
|
||||
//
|
||||
// a = -P1 + 3*P2 - 3*P3 + P4;
|
||||
// b = 3*P1 - 6*P2 + 3*P3;
|
||||
// c = -3*P1 + 3*P2;
|
||||
// d = -Bt + P1;
|
||||
//
|
||||
// if(Cubic(t, b/a, c/a, d/a) == 3){
|
||||
// ret_t = t[2];
|
||||
// } else {
|
||||
// ret_t = t[0];
|
||||
// }
|
||||
// /*
|
||||
// * Повертається три значення, але експереминтально знайдено що шукане
|
||||
// * значення знаходиться в третьому.
|
||||
// */
|
||||
//
|
||||
// free(t);
|
||||
// if(ret_t<0 || ret_t>1){
|
||||
// qDebug()<<"Неправильне значення параметра. фунція calc_t";
|
||||
// throw"Неправильне значення параметра. фунція calc_t";
|
||||
// }
|
||||
// return ret_t;
|
||||
//}
|
||||
/*
|
||||
* Функція знаходить підходяще значення параметна t якому відповідає точка на сплайні.
|
||||
*/
|
||||
//qreal VSpline::param_t (QPointF pBt)const{
|
||||
// qreal t_x, t_y;
|
||||
// t_x = calc_t (GetPointP1().x(), p2.x(), p3.x(), GetPointP4().x(), pBt.x());
|
||||
// t_y = calc_t (GetPointP1().y(), p2.y(), p3.y(), GetPointP4().y(), pBt.y());
|
||||
// /*
|
||||
// * Порівнюємо значення по х і по у і визначаємо найбільше. Це значення і
|
||||
// * буде шуканим.
|
||||
// */
|
||||
// if(t_x>t_y)
|
||||
// return t_x;
|
||||
// else
|
||||
// return t_y;
|
||||
//}
|
||||
//
|
||||
//void VSpline::Mirror(const QPointF Pmirror){
|
||||
// QPointF P1 = p1;
|
||||
// P1 = QPointF(P1.x() - Pmirror.x(), P1.y() - Pmirror.y());
|
||||
// P1 = QPointF(P1.x() * -1.0, P1.y() * 1.0);
|
||||
// P1 = QPointF(P1.x() + Pmirror.x(), P1.y() + Pmirror.y());
|
||||
// QPointF P2 = p2;
|
||||
// P2 = QPointF(P2.x() - Pmirror.x(), P2.y() - Pmirror.y());
|
||||
// P2 = QPointF(P2.x() * -1.0, P2.y() * 1.0);
|
||||
// P2 = QPointF(P2.x() + Pmirror.x(), P2.y() + Pmirror.y());
|
||||
// QPointF P3 = p3;
|
||||
// P3 = QPointF(P3.x() - Pmirror.x(), P3.y() - Pmirror.y());
|
||||
// P3 = QPointF(P3.x() * -1.0, P3.y() * 1.0);
|
||||
// P3 = QPointF(P3.x() + Pmirror.x(), P3.y() + Pmirror.y());
|
||||
// QPointF P4 = p4;
|
||||
// P4 = QPointF(P4.x() - Pmirror.x(), P4.y() - Pmirror.y());
|
||||
// P4 = QPointF(P4.x() * -1.0, P4.y() * 1.0);
|
||||
// P4 = QPointF(P4.x() + Pmirror.x(), P4.y() + Pmirror.y());
|
||||
// this->ModifiSpl(P1, P2, P3, P4);
|
||||
//}
|
||||
|
||||
QVector<QPointF> VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
|
||||
qreal kAsm2, qreal kCurve)
|
||||
{
|
||||
|
@ -843,6 +611,7 @@ QVector<QPointF> VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qre
|
|||
|
||||
VSpline &VSpline::operator =(const VSpline &spline)
|
||||
{
|
||||
VGObject::operator=(spline);
|
||||
this->p1 = spline.GetP1 ();
|
||||
this->p2 = spline.GetP2 ();
|
||||
this->p3 = spline.GetP3 ();
|
||||
|
@ -852,8 +621,5 @@ VSpline &VSpline::operator =(const VSpline &spline)
|
|||
this->kAsm1 = spline.GetKasm1();
|
||||
this->kAsm2 = spline.GetKasm2();
|
||||
this->kCurve = spline.GetKcurve();
|
||||
this->points = spline.GetDataPoints();
|
||||
this->idObject = spline.getIdObject();
|
||||
this->_name = spline.name();
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
#ifndef VSPLINE_H
|
||||
#define VSPLINE_H
|
||||
|
||||
#include "../container/vpointf.h"
|
||||
#include "vpointf.h"
|
||||
#include "vgobject.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QLineF>
|
||||
|
@ -42,7 +43,7 @@ class QString;
|
|||
/**
|
||||
* @brief VSpline class that implements the spline.
|
||||
*/
|
||||
class VSpline
|
||||
class VSpline :public VGObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -64,8 +65,8 @@ public:
|
|||
* @param kAsm1 коефіцієнт довжини першої напрямної.
|
||||
* @param kAsm2 коефіцієнт довжини другої напрямної.
|
||||
*/
|
||||
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1,
|
||||
qreal kAsm2, qreal kCurve, qint64 idObject = 0);
|
||||
VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve,
|
||||
qint64 idObject = 0, Draw::Draws mode = Draw::Calculation);
|
||||
/**
|
||||
* @brief VSpline конструктор.
|
||||
* @param p1 початкова точка сплайну.
|
||||
|
@ -73,51 +74,13 @@ public:
|
|||
* @param p3 друга контролююча точка сплайну.
|
||||
* @param p4 кінцева точка сплайну.
|
||||
*/
|
||||
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
|
||||
qreal kCurve, qint64 idObject = 0);
|
||||
/**
|
||||
* @brief ModifiSpl модифікує сплайн.
|
||||
* @param p1 початкова точка сплайну.
|
||||
* @param p4 кінцева точка сплайну.
|
||||
* @param angle1 кут в градусах першої напрямної.
|
||||
* @param angle2 кут в градусах другої напрямної.
|
||||
* @param kCurve коефіцієнт кривизни сплайну.
|
||||
* @param kAsm1 коефіцієнт довжини першої напрямної.
|
||||
* @param kAsm2 коефіцієнт довжини другої напрямної.
|
||||
*/
|
||||
void ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2,
|
||||
qreal kCurve);
|
||||
/**
|
||||
* @brief ModifiSpl модифікує сплайн.
|
||||
* @param p1 початкова точка сплайну.
|
||||
* @param p2 перша контролююча точка сплайну.
|
||||
* @param p3 друга контролююча точка сплайну.
|
||||
* @param p4 кінцева точка сплайну.
|
||||
*/
|
||||
void ModifiSpl (const qint64 &p1, const QPointF &p2, const QPointF &p3, const qint64 &p4,
|
||||
const qreal &kCurve);
|
||||
// /**
|
||||
// * @brief RotationSpl поворот сплайна навколо точки на кут в градусах проти годиникової стрілки.
|
||||
// * @param pRotate точка навколо якої повертаємо.
|
||||
// * @param angle кут в градусах.
|
||||
// */
|
||||
// void RotationSpl ( QPointF pRotate, qreal angle );
|
||||
// /**
|
||||
// * @brief BiasSpl зміщує сплайн.
|
||||
// * @param mx зміщення по х координаті.
|
||||
// * @param my зміщення по у координаті.
|
||||
// */
|
||||
// void BiasSpl ( qreal mx, qreal my );
|
||||
VSpline (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve, qint64 idObject = 0,
|
||||
Draw::Draws mode = Draw::Calculation);
|
||||
/**
|
||||
* @brief GetP1 повертає першу точку сплайну.
|
||||
* @return перша точка сплайну.
|
||||
*/
|
||||
qint64 GetP1 () const {return p1;}
|
||||
/**
|
||||
* @brief GetPointP1
|
||||
* @return
|
||||
*/
|
||||
VPointF GetPointP1() const;
|
||||
VPointF GetP1 () const {return p1;}
|
||||
/**
|
||||
* @brief GetP2 повертує першу контрольну точку сплайну.
|
||||
* @return перша контрольна точка сплайну.
|
||||
|
@ -132,12 +95,7 @@ public:
|
|||
* @brief GetP4 повертає останню точку сплайну.
|
||||
* @return остання точка сплайну.
|
||||
*/
|
||||
inline qint64 GetP4 () const {return p4;}
|
||||
/**
|
||||
* @brief GetPointP4
|
||||
* @return
|
||||
*/
|
||||
VPointF GetPointP4 () const;
|
||||
inline VPointF GetP4 () const {return p4;}
|
||||
/**
|
||||
* @brief GetAngle1 повертає кут першої напрямної.
|
||||
* @return кут в градусах.
|
||||
|
@ -154,10 +112,10 @@ public:
|
|||
*/
|
||||
qreal GetLength () const;
|
||||
/**
|
||||
* @brief GetName
|
||||
* @brief name
|
||||
* @return
|
||||
*/
|
||||
QString GetName () const;
|
||||
QString name () const;
|
||||
/**
|
||||
* @brief GetKasm1
|
||||
* @return
|
||||
|
@ -173,11 +131,6 @@ public:
|
|||
* @return
|
||||
*/
|
||||
inline qreal GetKcurve() const {return kCurve;}
|
||||
/**
|
||||
* @brief GetDataPoints
|
||||
* @return
|
||||
*/
|
||||
inline const QHash<qint64, VPointF> GetDataPoints() const {return points;}
|
||||
/**
|
||||
* @brief CrossingSplLine перевіряє перетин сплайну з лінією.
|
||||
* @param line лінія з якою перевіряється перетин.
|
||||
|
@ -197,19 +150,6 @@ public:
|
|||
* @return point of cutting. This point is forth point of first spline and first point of second spline.
|
||||
*/
|
||||
QPointF CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const;
|
||||
/**
|
||||
* @brief CutSpline розрізає сплайн.
|
||||
* @param point точка що ділить сплайн.
|
||||
* @param curFir перший сплайн.
|
||||
* @param curSec другий сплайн.
|
||||
*/
|
||||
// void CutSpline (QPointF point, VSpline* curFir, VSpline* curSec ) const;
|
||||
/**
|
||||
* @brief PutAlongSpl розміщає точку на сплайні.
|
||||
* @param moveP точка яка розміщується на сплайні.
|
||||
* @param move довжина від початку сплайну.
|
||||
*/
|
||||
// void PutAlongSpl ( QPointF &moveP, qreal move ) const;
|
||||
/**
|
||||
* @brief GetPoints повертає точки з яких складається сплайн.
|
||||
* @return список точок.
|
||||
|
@ -220,11 +160,6 @@ public:
|
|||
* @return шлях.
|
||||
*/
|
||||
QPainterPath GetPath() const;
|
||||
/**
|
||||
* @brief Mirror вертикальне дзеркалення сплайну відносно точки.
|
||||
* @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну.
|
||||
*/
|
||||
// void Mirror(const QPointF Pmirror);
|
||||
/**
|
||||
* @brief SplinePoints
|
||||
* @param p1
|
||||
|
@ -238,32 +173,12 @@ public:
|
|||
*/
|
||||
static QVector<QPointF> SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
|
||||
qreal kAsm2, qreal kCurve);
|
||||
/**
|
||||
* @brief getIdObject
|
||||
* @return
|
||||
*/
|
||||
inline qint64 getIdObject() const {return idObject;}
|
||||
/**
|
||||
* @brief setIdObject
|
||||
* @param value
|
||||
*/
|
||||
inline void setIdObject(const qint64 &value) {idObject = value;}
|
||||
/**
|
||||
* @brief operator =
|
||||
* @param spl
|
||||
* @return
|
||||
*/
|
||||
VSpline &operator=(const VSpline &spl);
|
||||
/**
|
||||
* @brief name
|
||||
* @return
|
||||
*/
|
||||
QString name() const {return _name;}
|
||||
/**
|
||||
* @brief setName
|
||||
* @param name
|
||||
*/
|
||||
void setName(const QString &name) {_name = name;}
|
||||
protected:
|
||||
/**
|
||||
* @brief GetPoints повертає точки з яких складається сплайн.
|
||||
|
@ -278,7 +193,7 @@ private:
|
|||
/**
|
||||
* @brief p1 початкова точка сплайну
|
||||
*/
|
||||
qint64 p1; // перша точка
|
||||
VPointF p1; // перша точка
|
||||
/**
|
||||
* @brief p2 перша контрольна точка сплайну.
|
||||
*/
|
||||
|
@ -290,7 +205,7 @@ private:
|
|||
/**
|
||||
* @brief p4 кінцеві точка сплайну.
|
||||
*/
|
||||
qint64 p4; // четверта точка
|
||||
VPointF p4; // четверта точка
|
||||
/**
|
||||
* @brief angle1 кут в градусах першої напрямної.
|
||||
*/
|
||||
|
@ -311,18 +226,6 @@ private:
|
|||
* @brief kCurve
|
||||
*/
|
||||
qreal kCurve;
|
||||
/**
|
||||
* @brief points
|
||||
*/
|
||||
QHash<qint64, VPointF> points;
|
||||
/**
|
||||
* @brief idObject
|
||||
*/
|
||||
qint64 idObject;
|
||||
/**
|
||||
* @brief _name
|
||||
*/
|
||||
QString _name;
|
||||
/**
|
||||
* @brief LengthBezier повертає дожину сплайну за його чотирьма точками.
|
||||
* @param p1 початкова точка сплайну.
|
||||
|
@ -357,32 +260,7 @@ private:
|
|||
* @return довжину.
|
||||
*/
|
||||
static qreal CalcSqDistance ( qreal x1, qreal y1, qreal x2, qreal y2);
|
||||
// /**
|
||||
// * @brief Cubic знаходить розв'язок кубічного рівняння.
|
||||
// * @param x коефіцієнт.
|
||||
// * @param a коефіцієнт.
|
||||
// * @param b коефіцієнт.
|
||||
// * @param c коефіцієнт.
|
||||
// * @return повертає корені рівняння.
|
||||
// */
|
||||
// static qint32 Cubic(qreal *x, qreal a, qreal b, qreal c);
|
||||
/**
|
||||
* @brief calc_t знаходить параметр t якому відповідає точка на сплайні.
|
||||
* @param curve_coord1 координата Х або У кривої.
|
||||
* @param curve_coord2 координата Х або У кривої.
|
||||
* @param curve_coord3 координата Х або У кривої.
|
||||
* @param curve_coord4 координата Х або У кривої.
|
||||
* @param point_coord координата Х або У точки на кривій.
|
||||
* @return
|
||||
*/
|
||||
// static qreal calc_t (qreal curve_coord1, qreal curve_coord2, qreal curve_coord3, qreal curve_coord4,
|
||||
// qreal point_coord)const;
|
||||
/**
|
||||
* @brief param_t знаходить підходяще значення параметра t якому відповідає точка на сплайні
|
||||
* @param pBt точка для якої шукається значення параметра t.
|
||||
* @return підходяще значення t.
|
||||
*/
|
||||
// qreal param_t (QPointF pBt)const;
|
||||
void CreateName();
|
||||
};
|
||||
|
||||
#endif // VSPLINE_H
|
||||
|
|
|
@ -29,16 +29,15 @@
|
|||
#include "vsplinepath.h"
|
||||
#include "../exception/vexception.h"
|
||||
|
||||
VSplinePath::VSplinePath()
|
||||
: path(QVector<VSplinePoint>()), kCurve(1), points(QHash<qint64, VPointF>()), idObject(0), _name(QString()){}
|
||||
|
||||
VSplinePath::VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve, qint64 idObject)
|
||||
: path(QVector<VSplinePoint>()), kCurve(kCurve), points(*points), idObject(idObject), _name(QString())
|
||||
{}
|
||||
VSplinePath::VSplinePath(qreal kCurve, qint64 idObject, Draw::Draws mode)
|
||||
: VGObject(GObject::SplinePath, idObject, mode), path(QVector<VSplinePoint>()), kCurve(kCurve)
|
||||
{
|
||||
}
|
||||
|
||||
VSplinePath::VSplinePath(const VSplinePath &splPath)
|
||||
: path(*splPath.GetPoint()), kCurve(splPath.getKCurve()), points(splPath.GetDataPoints()),
|
||||
idObject(splPath.getIdObject()), _name(splPath.name()){}
|
||||
: VGObject(splPath), path(*splPath.GetPoint()), kCurve(splPath.getKCurve())
|
||||
{
|
||||
}
|
||||
|
||||
void VSplinePath::append(const VSplinePoint &point)
|
||||
{
|
||||
|
@ -47,8 +46,8 @@ void VSplinePath::append(const VSplinePoint &point)
|
|||
for (qint32 i = 1; i <= this->Count(); ++i)
|
||||
{
|
||||
VSpline spl = this->GetSpline(i);
|
||||
VPointF first = spl.GetPointP1();
|
||||
VPointF second = spl.GetPointP4();
|
||||
VPointF first = spl.GetP1();
|
||||
VPointF second = spl.GetP4();
|
||||
QString splName = QString("_%1_%2").arg(first.name(), second.name());
|
||||
_name.append(splName);
|
||||
}
|
||||
|
@ -76,7 +75,7 @@ VSpline VSplinePath::GetSpline(qint32 index) const
|
|||
{
|
||||
throw VException(tr("This spline does not exist."));
|
||||
}
|
||||
VSpline spl(&points, path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(),
|
||||
VSpline spl(path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(),
|
||||
path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve);
|
||||
return spl;
|
||||
}
|
||||
|
@ -86,7 +85,7 @@ QPainterPath VSplinePath::GetPath() const
|
|||
QPainterPath painterPath;
|
||||
for (qint32 i = 1; i <= Count(); ++i)
|
||||
{
|
||||
VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(),
|
||||
VSpline spl(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(),
|
||||
path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve);
|
||||
painterPath.addPath(spl.GetPath());
|
||||
}
|
||||
|
@ -98,8 +97,9 @@ QVector<QPointF> VSplinePath::GetPathPoints() const
|
|||
QVector<QPointF> pathPoints;
|
||||
for (qint32 i = 1; i <= Count(); ++i)
|
||||
{
|
||||
VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(),
|
||||
VSpline spl(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(),
|
||||
path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve);
|
||||
//TODO Use QVector<T> & QVector::operator+=(const QVector<T> & other) instead for.
|
||||
QVector<QPointF> splP = spl.GetPoints();
|
||||
for (qint32 j = 0; j < splP.size(); ++j)
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ qreal VSplinePath::GetLength() const
|
|||
qreal length = 0;
|
||||
for (qint32 i = 1; i <= Count(); ++i)
|
||||
{
|
||||
VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(),
|
||||
VSpline spl(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(),
|
||||
path[i].KAsm1(), kCurve);
|
||||
length += spl.GetLength();
|
||||
}
|
||||
|
@ -155,11 +155,9 @@ VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePoint::Positi
|
|||
|
||||
VSplinePath &VSplinePath::operator =(const VSplinePath &path)
|
||||
{
|
||||
VGObject::operator=(path);
|
||||
this->path = path.GetSplinePath();
|
||||
this->kCurve = path.getKCurve();
|
||||
this->points = path.GetDataPoints();
|
||||
this->idObject = path.getIdObject();
|
||||
this->_name = path.name();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -168,6 +166,11 @@ VSplinePoint & VSplinePath::operator[](ptrdiff_t indx)
|
|||
return path[indx];
|
||||
}
|
||||
|
||||
const VSplinePoint &VSplinePath::at(ptrdiff_t indx) const
|
||||
{
|
||||
return path[indx];
|
||||
}
|
||||
|
||||
QPointF VSplinePath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3,
|
||||
QPointF &spl2p2, QPointF &spl2p3) const
|
||||
{
|
||||
|
@ -190,8 +193,8 @@ QPointF VSplinePath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF
|
|||
fullLength = 0;
|
||||
for (qint32 i = 1; i <= Count(); ++i)
|
||||
{
|
||||
VSpline spl = VSpline(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(),
|
||||
path[i-1].KAsm2(), path[i].KAsm1(), kCurve);
|
||||
VSpline spl = VSpline(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(),
|
||||
path[i].KAsm1(), kCurve);
|
||||
fullLength += spl.GetLength();
|
||||
if(fullLength > length)
|
||||
{
|
||||
|
@ -202,14 +205,3 @@ QPointF VSplinePath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF
|
|||
}
|
||||
return QPointF();
|
||||
}
|
||||
|
||||
QHash<qint64, VPointF> VSplinePath::getPoints() const
|
||||
{
|
||||
return points;
|
||||
}
|
||||
|
||||
void VSplinePath::setPoints(const QHash<qint64, VPointF> *value)
|
||||
{
|
||||
points = *value;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,11 @@
|
|||
#define VSPLINEPATH_H
|
||||
|
||||
#include "vsplinepoint.h"
|
||||
#include "../container/vpointf.h"
|
||||
#include "vpointf.h"
|
||||
#include "vspline.h"
|
||||
#include "vgobject.h"
|
||||
#include <QApplication>
|
||||
#include "../container/vcontainer.h"
|
||||
|
||||
namespace SplinePoint
|
||||
{
|
||||
|
@ -47,18 +49,14 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( SplinePoint::Positions )
|
|||
/**
|
||||
* @brief The VSplinePath клас, що розраховує шлях сплайнів.
|
||||
*/
|
||||
class VSplinePath
|
||||
class VSplinePath :public VGObject
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VSplinePath)
|
||||
public:
|
||||
/**
|
||||
* @brief VSplinePath конструктор по замовчуванню.
|
||||
*/
|
||||
VSplinePath();
|
||||
/**
|
||||
* @brief VSplinePath конструктор по замовчуванню.
|
||||
*/
|
||||
VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve = 1, qint64 idObject = 0);
|
||||
VSplinePath(qreal kCurve = 1, qint64 idObject = 0, Draw::Draws mode = Draw::Calculation);
|
||||
/**
|
||||
* @brief VSplinePath
|
||||
* @param splPath
|
||||
|
@ -105,11 +103,6 @@ public:
|
|||
* @return
|
||||
*/
|
||||
qreal GetLength() const;
|
||||
/**
|
||||
* @brief GetDataPoints
|
||||
* @return
|
||||
*/
|
||||
inline QHash<qint64, VPointF> GetDataPoints() const {return points;}
|
||||
/**
|
||||
* @brief UpdatePoint
|
||||
* @param indexSpline
|
||||
|
@ -155,26 +148,7 @@ public:
|
|||
* @return
|
||||
*/
|
||||
VSplinePoint &operator[](ptrdiff_t indx);
|
||||
/**
|
||||
* @brief getIdObject
|
||||
* @return
|
||||
*/
|
||||
inline qint64 getIdObject() const {return idObject;}
|
||||
/**
|
||||
* @brief setIdObject
|
||||
* @param value
|
||||
*/
|
||||
inline void setIdObject(const qint64 &value) {idObject = value;}
|
||||
/**
|
||||
* @brief name
|
||||
* @return
|
||||
*/
|
||||
QString name() const {return _name;}
|
||||
/**
|
||||
* @brief setName
|
||||
* @param name
|
||||
*/
|
||||
void setName(const QString &name) {_name = name;}
|
||||
const VSplinePoint &at(ptrdiff_t indx) const;
|
||||
/**
|
||||
* @brief CutSplinePath
|
||||
* @param length
|
||||
|
@ -186,8 +160,6 @@ public:
|
|||
*/
|
||||
QPointF CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2,
|
||||
QPointF &spl2p3) const;
|
||||
QHash<qint64, VPointF> getPoints() const;
|
||||
void setPoints(const QHash<qint64, VPointF> *value);
|
||||
protected:
|
||||
/**
|
||||
* @brief path вектор з точок сплайна.
|
||||
|
@ -197,18 +169,6 @@ protected:
|
|||
* @brief kCurve
|
||||
*/
|
||||
qreal kCurve;
|
||||
/**
|
||||
* @brief points
|
||||
*/
|
||||
QHash<qint64, VPointF> points;
|
||||
/**
|
||||
* @brief idObject
|
||||
*/
|
||||
qint64 idObject;
|
||||
/**
|
||||
* @brief _name
|
||||
*/
|
||||
QString _name;
|
||||
};
|
||||
|
||||
#endif // VSPLINEPATH_H
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
#include "vsplinepoint.h"
|
||||
|
||||
VSplinePoint::VSplinePoint()
|
||||
:pSpline(0), angle(0), kAsm1(1), kAsm2(1){}
|
||||
:pSpline(VPointF()), angle(0), kAsm1(1), kAsm2(1){}
|
||||
|
||||
VSplinePoint::VSplinePoint(qint64 pSpline, qreal kAsm1, qreal angle, qreal kAsm2)
|
||||
VSplinePoint::VSplinePoint(VPointF pSpline, qreal kAsm1, qreal angle, qreal kAsm2)
|
||||
:pSpline(pSpline), angle(angle), kAsm1(kAsm1), kAsm2(kAsm2){}
|
||||
|
||||
VSplinePoint::VSplinePoint(const VSplinePoint &point)
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#define VSPLINEPOINT_H
|
||||
|
||||
#include <QMetaType>
|
||||
#include "vpointf.h"
|
||||
|
||||
/**
|
||||
* @brief The VSplinePoint клас, що містить у собі інформацію про точки сплайну.
|
||||
|
@ -47,7 +48,7 @@ public:
|
|||
* @param angle кут дотичної сплайна.
|
||||
* @param factor коефіцієнт довжини дотичної.
|
||||
*/
|
||||
VSplinePoint(qint64 pSpline, qreal kAsm1, qreal angle, qreal kAsm2);
|
||||
VSplinePoint(VPointF pSpline, qreal kAsm1, qreal angle, qreal kAsm2);
|
||||
/**
|
||||
* @brief VSplinePoint
|
||||
* @param point
|
||||
|
@ -58,12 +59,12 @@ public:
|
|||
* @brief P повертає точку.
|
||||
* @return точка.
|
||||
*/
|
||||
inline qint64 P() const {return pSpline;}
|
||||
inline VPointF P() const {return pSpline;}
|
||||
/**
|
||||
* @brief SetP
|
||||
* @param value
|
||||
*/
|
||||
inline void SetP(const qint64 &value) {pSpline = value;}
|
||||
inline void SetP(const VPointF &value) {pSpline = value;}
|
||||
/**
|
||||
* @brief Angle1 повертає кут дотичної сплайна.
|
||||
* @return кут в градусах.
|
||||
|
@ -103,7 +104,7 @@ protected:
|
|||
/**
|
||||
* @brief pSpline точка сплайну.
|
||||
*/
|
||||
qint64 pSpline;
|
||||
VPointF pSpline;
|
||||
/**
|
||||
* @brief angle кут дотичної сплайну.
|
||||
*/
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
#include <QFileDialog>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
:QMainWindow(parent), ui(new Ui::MainWindow), tool(Tool::ArrowTool), currentScene(0), sceneDraw(0),
|
||||
sceneDetails(0), mouseCoordinate(0), helpLabel(0), view(0), isInitialized(false), dialogTable(0),
|
||||
:QMainWindow(parent), ui(new Ui::MainWindow), pattern(0), doc(0), tool(Tool::ArrowTool), currentScene(0),
|
||||
sceneDraw(0), sceneDetails(0), mouseCoordinate(0), helpLabel(0), view(0), isInitialized(false), dialogTable(0),
|
||||
dialogEndLine(QSharedPointer<DialogEndLine>()), dialogLine(QSharedPointer<DialogLine>()),
|
||||
dialogAlongLine(QSharedPointer<DialogAlongLine>()),
|
||||
dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()), dialogNormal(QSharedPointer<DialogNormal>()),
|
||||
|
@ -58,7 +58,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
dialogTriangle(QSharedPointer<DialogTriangle>()),
|
||||
dialogPointOfIntersection(QSharedPointer<DialogPointOfIntersection>()),
|
||||
dialogCutSpline(QSharedPointer<DialogCutSpline>()), dialogCutSplinePath (QSharedPointer<DialogCutSplinePath>()),
|
||||
dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
|
||||
dialogUnionDetails(QSharedPointer<DialogUnionDetails>()),
|
||||
dialogHistory(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
|
||||
mode(Draw::Calculation)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -107,16 +108,14 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(ui->toolButtonPointOfIntersection, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersection);
|
||||
connect(ui->toolButtonSplineCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSpline);
|
||||
connect(ui->toolButtonSplinePathCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSplinePath);
|
||||
connect(ui->toolButtonUnionDetails, &QToolButton::clicked, this, &MainWindow::ToolUnionDetails);
|
||||
|
||||
data = new VContainer;
|
||||
pattern = new VContainer();
|
||||
|
||||
doc = new VDomDocument(data, comboBoxDraws, &mode);
|
||||
doc = new VDomDocument(pattern, comboBoxDraws, &mode);
|
||||
doc->CreateEmptyFile();
|
||||
connect(doc, &VDomDocument::haveChange, this, &MainWindow::haveChange);
|
||||
|
||||
fileName.clear();
|
||||
changeInFile = false;
|
||||
|
||||
//Autosaving file each 5 minutes
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->setTimerType(Qt::VeryCoarseTimer);
|
||||
|
@ -180,10 +179,10 @@ void MainWindow::ActionNewDraw()
|
|||
}
|
||||
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&MainWindow::currentDrawChanged);
|
||||
data->ClearObject();
|
||||
pattern->ClearObject();
|
||||
//Create single point
|
||||
qint64 id = data->AddPoint(VPointF(toPixel((10+comboBoxDraws->count()*5)), toPixel(10), "А", 5, 10));
|
||||
VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui);
|
||||
qint64 id = pattern->AddGObject(new VPointF(toPixel((10+comboBoxDraws->count()*5)), toPixel(10), "А", 5, 10));
|
||||
VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Tool::FromGui);
|
||||
sceneDraw->addItem(spoint);
|
||||
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
|
||||
|
@ -251,7 +250,7 @@ void MainWindow::SetToolButton(bool checked, Tool::Tools t, const QString &curso
|
|||
QCursor cur(pixmap, 2, 3);
|
||||
view->setCursor(cur);
|
||||
helpLabel->setText(toolTip);
|
||||
dialog = QSharedPointer<Dialog>(new Dialog(data));
|
||||
dialog = QSharedPointer<Dialog>(new Dialog(pattern));
|
||||
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
|
||||
connect(dialog.data(), &Dialog::DialogClosed, this, closeDialogSlot);
|
||||
connect(dialog.data(), &Dialog::ToolTip, this, &MainWindow::ShowToolTip);
|
||||
|
@ -282,7 +281,7 @@ void MainWindow::ClosedDialog(QSharedPointer<Dialog> &dialog, int result)
|
|||
{
|
||||
if (result == QDialog::Accepted)
|
||||
{
|
||||
DrawTool::Create(dialog, currentScene, doc, data);
|
||||
DrawTool::Create(dialog, currentScene, doc, pattern);
|
||||
}
|
||||
ArrowTool();
|
||||
}
|
||||
|
@ -443,7 +442,7 @@ void MainWindow::ToolDetail(bool checked)
|
|||
QCursor cur(pixmap, 2, 3);
|
||||
view->setCursor(cur);
|
||||
helpLabel->setText(tr("Select points, arcs, curves clockwise."));
|
||||
dialogDetail = QSharedPointer<DialogDetail>(new DialogDetail(data));
|
||||
dialogDetail = QSharedPointer<DialogDetail>(new DialogDetail(pattern));
|
||||
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogDetail.data(),
|
||||
&DialogDetail::ChoosedObject);
|
||||
connect(dialogDetail.data(), &DialogDetail::DialogClosed, this, &MainWindow::ClosedDialogDetail);
|
||||
|
@ -462,7 +461,7 @@ void MainWindow::ClosedDialogDetail(int result)
|
|||
{
|
||||
if (result == QDialog::Accepted)
|
||||
{
|
||||
VToolDetail::Create(dialogDetail, sceneDetails, doc, data);
|
||||
VToolDetail::Create(dialogDetail, sceneDetails, doc, pattern);
|
||||
}
|
||||
ArrowTool();
|
||||
}
|
||||
|
@ -501,6 +500,17 @@ void MainWindow::ClosedDialogPointOfIntersection(int result)
|
|||
ClosedDialog<VToolPointOfIntersection>(dialogPointOfIntersection, result);
|
||||
}
|
||||
|
||||
void MainWindow::ToolUnionDetails(bool checked)
|
||||
{
|
||||
SetToolButton(checked, Tool::UnionDetails, ":/cursor/union_cursor.png",
|
||||
tr("Select detail"), dialogUnionDetails, &MainWindow::ClosedDialogUnionDetails);
|
||||
}
|
||||
|
||||
void MainWindow::ClosedDialogUnionDetails(int result)
|
||||
{
|
||||
ClosedDialog<VToolUnionDetails>(dialogUnionDetails, result);
|
||||
}
|
||||
|
||||
void MainWindow::About()
|
||||
{
|
||||
QString fullName = QString("Valentina %1").arg(APP_VERSION);
|
||||
|
@ -956,7 +966,7 @@ void MainWindow::Clear()
|
|||
{
|
||||
setWindowTitle("Valentina");
|
||||
fileName.clear();
|
||||
data->Clear();
|
||||
pattern->Clear();
|
||||
doc->clear();
|
||||
sceneDraw->clear();
|
||||
sceneDetails->clear();
|
||||
|
@ -991,14 +1001,14 @@ void MainWindow::haveChange()
|
|||
void MainWindow::ChangedSize(const QString & text)
|
||||
{
|
||||
qint32 size = text.toInt();
|
||||
data->SetSize(size*10);
|
||||
pattern->SetSize(size*10);
|
||||
doc->FullUpdateTree();
|
||||
}
|
||||
|
||||
void MainWindow::ChangedGrowth(const QString &text)
|
||||
{
|
||||
qint32 growth = text.toInt();
|
||||
data->SetGrowth(growth*10);
|
||||
pattern->SetGrowth(growth*10);
|
||||
doc->FullUpdateTree();
|
||||
}
|
||||
|
||||
|
@ -1020,7 +1030,7 @@ void MainWindow::ActionTable(bool checked)
|
|||
{
|
||||
if (checked)
|
||||
{
|
||||
dialogTable = new DialogIncrements(data, doc, this);
|
||||
dialogTable = new DialogIncrements(pattern, doc, this);
|
||||
connect(dialogTable, &DialogIncrements::DialogClosed, this,
|
||||
&MainWindow::ClosedActionTable);
|
||||
dialogTable->show();
|
||||
|
@ -1042,7 +1052,7 @@ void MainWindow::ActionHistory(bool checked)
|
|||
{
|
||||
if (checked)
|
||||
{
|
||||
dialogHistory = new DialogHistory(data, doc, this);
|
||||
dialogHistory = new DialogHistory(pattern, doc, this);
|
||||
dialogHistory->setWindowFlags(Qt::Window);
|
||||
connect(dialogHistory, &DialogHistory::DialogClosed, this,
|
||||
&MainWindow::ClosedActionHistory);
|
||||
|
@ -1060,7 +1070,7 @@ void MainWindow::ActionLayout(bool checked)
|
|||
Q_UNUSED(checked);
|
||||
hide();
|
||||
QVector<VItem*> listDetails;
|
||||
data->PrepareDetails(listDetails);
|
||||
pattern->PrepareDetails(listDetails);
|
||||
emit ModelChosen(listDetails);
|
||||
}
|
||||
|
||||
|
@ -1205,7 +1215,7 @@ MainWindow::~MainWindow()
|
|||
CanselTool();
|
||||
delete ui;
|
||||
|
||||
delete data;
|
||||
delete pattern;
|
||||
if (doc->isNull() == false)
|
||||
{
|
||||
delete doc;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "widgets/vitem.h"
|
||||
#include "dialogs/dialogs.h"
|
||||
#include "tools/vtooldetail.h"
|
||||
#include "tools/vtooluniondetails.h"
|
||||
#include "tools/drawTools/drawtools.h"
|
||||
#include "xml/vdomdocument.h"
|
||||
|
||||
|
@ -232,6 +233,7 @@ public slots:
|
|||
* @param checked
|
||||
*/
|
||||
void ToolPointOfIntersection(bool checked);
|
||||
void ToolUnionDetails(bool checked);
|
||||
/**
|
||||
* @brief ClosedDialogEndLine
|
||||
* @param result
|
||||
|
@ -312,6 +314,7 @@ public slots:
|
|||
* @param result
|
||||
*/
|
||||
void ClosedDialogPointOfIntersection(int result);
|
||||
void ClosedDialogUnionDetails(int result);
|
||||
/**
|
||||
* @brief ClosedDialogCutSpline handler close event tool CutSpline
|
||||
* @param result result of working of dialog
|
||||
|
@ -367,6 +370,14 @@ private:
|
|||
* @brief ui keeps information about user interface
|
||||
*/
|
||||
Ui::MainWindow *ui;
|
||||
/**
|
||||
* @brief pattern container with data (points, arcs, splines, spline paths, variables)
|
||||
*/
|
||||
VContainer *pattern;
|
||||
/**
|
||||
* @brief doc dom document container
|
||||
*/
|
||||
VDomDocument *doc;
|
||||
/**
|
||||
* @brief tool
|
||||
*/
|
||||
|
@ -471,18 +482,14 @@ private:
|
|||
* @brief dialogCutSplinePath pointer to the dialog tool cut spline path
|
||||
*/
|
||||
QSharedPointer<DialogCutSplinePath> dialogCutSplinePath;
|
||||
/**
|
||||
* @brief dialogUnionDetails
|
||||
*/
|
||||
QSharedPointer<DialogUnionDetails> dialogUnionDetails;
|
||||
/**
|
||||
* @brief dialogHistory
|
||||
*/
|
||||
DialogHistory *dialogHistory;
|
||||
/**
|
||||
* @brief doc dom document container
|
||||
*/
|
||||
VDomDocument *doc;
|
||||
/**
|
||||
* @brief data container with data
|
||||
*/
|
||||
VContainer *data;
|
||||
/**
|
||||
* @brief comboBoxDraws
|
||||
*/
|
||||
|
|
|
@ -77,14 +77,15 @@ namespace Tool
|
|||
NodeSplinePath,
|
||||
Height,
|
||||
Triangle,
|
||||
PointOfIntersection
|
||||
PointOfIntersection,
|
||||
UnionDetails
|
||||
};
|
||||
Q_DECLARE_FLAGS(Tools, Tool)
|
||||
|
||||
/**
|
||||
* @brief The Source enum
|
||||
*/
|
||||
enum Source { FromGui, FromFile };
|
||||
enum Source { FromGui, FromFile, FromTool };
|
||||
Q_DECLARE_FLAGS(Sources, Source)
|
||||
}
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( Tool::Tools )
|
||||
|
|
|
@ -93,14 +93,14 @@ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolAlongLine::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrTypeLine, typeLine);
|
||||
AddAttribute(domElement, AttrLength, formula);
|
||||
|
@ -112,13 +112,13 @@ void VToolAlongLine::AddToFile()
|
|||
|
||||
void VToolAlongLine::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrMx, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrTypeLine, typeLine);
|
||||
domElement.setAttribute(AttrLength, formula);
|
||||
domElement.setAttribute(AttrFirstPoint, basePointId);
|
||||
|
@ -135,12 +135,12 @@ void VToolAlongLine::RemoveReferens()
|
|||
void VToolAlongLine::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogAlongLine.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogAlongLine->setTypeLine(typeLine);
|
||||
dialogAlongLine->setFormula(formula);
|
||||
dialogAlongLine->setFirstPointId(basePointId, id);
|
||||
dialogAlongLine->setSecondPointId(secondPointId, id);
|
||||
dialogAlongLine->setPointName(p.name());
|
||||
dialogAlongLine->setPointName(p->name());
|
||||
}
|
||||
|
||||
void VToolAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene,
|
||||
|
@ -160,9 +160,9 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
|
|||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||
QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF());
|
||||
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(firstPointId);
|
||||
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
|
||||
QLineF line = QLineF(firstPoint->toQPointF(), secondPoint->toQPointF());
|
||||
Calculator cal(data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
|
@ -172,13 +172,13 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
|
|||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||
id = data->AddGObject( new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(id, secondPointId);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(id, secondPointId);
|
||||
if (parse != Document::FullParse)
|
||||
|
|
|
@ -36,9 +36,9 @@ VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::S
|
|||
QGraphicsItem *parent)
|
||||
:VDrawTool(doc, data, id), QGraphicsPathItem(parent), dialogArc(QSharedPointer<DialogArc>())
|
||||
{
|
||||
VArc arc = data->GetArc(id);
|
||||
const VArc *arc = data->GeometricObject<const VArc *>(id);
|
||||
QPainterPath path;
|
||||
path.addPath(arc.GetPath());
|
||||
path.addPath(arc->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
this->setPath(path);
|
||||
this->setPen(QPen(Qt::black, widthHairLine/factor));
|
||||
|
@ -58,11 +58,11 @@ VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::S
|
|||
void VToolArc::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogArc.isNull() == false);
|
||||
VArc arc = VAbstractTool::data.GetArc(id);
|
||||
dialogArc->SetCenter(arc.GetCenter());
|
||||
dialogArc->SetF1(arc.GetFormulaF1());
|
||||
dialogArc->SetF2(arc.GetFormulaF2());
|
||||
dialogArc->SetRadius(arc.GetFormulaRadius());
|
||||
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
|
||||
dialogArc->SetCenter(arc->GetCenter().id());
|
||||
dialogArc->SetF1(arc->GetFormulaF1());
|
||||
dialogArc->SetF2(arc->GetFormulaF2());
|
||||
dialogArc->SetRadius(arc->GetFormulaRadius());
|
||||
}
|
||||
|
||||
void VToolArc::Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
|
@ -103,17 +103,19 @@ void VToolArc::Create(const qint64 _id, const qint64 ¢er, const QString &rad
|
|||
calcF2 = result;
|
||||
}
|
||||
|
||||
VArc arc = VArc(data->DataPoints(), center, calcRadius, radius, calcF1, f1, calcF2, f2 );
|
||||
VPointF c = *data->GeometricObject<const VPointF *>(center);
|
||||
VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 );
|
||||
Q_ASSERT(arc != 0);
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddArc(arc);
|
||||
data->AddLengthArc(arc.name(), toMM(arc.GetLength()));
|
||||
id = data->AddGObject(arc);
|
||||
data->AddLengthArc(arc->name(), toMM(arc->GetLength()));
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateArc(id, arc);
|
||||
data->AddLengthArc(arc.name(), toMM(arc.GetLength()));
|
||||
data->UpdateGObject(id, arc);
|
||||
data->AddLengthArc(arc->name(), toMM(arc->GetLength()));
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
|
@ -190,29 +192,29 @@ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolArc::AddToFile()
|
||||
{
|
||||
VArc arc = VAbstractTool::data.GetArc(id);
|
||||
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrCenter, arc.GetCenter());
|
||||
AddAttribute(domElement, AttrRadius, arc.GetFormulaRadius());
|
||||
AddAttribute(domElement, AttrAngle1, arc.GetFormulaF1());
|
||||
AddAttribute(domElement, AttrAngle2, arc.GetFormulaF2());
|
||||
AddAttribute(domElement, AttrCenter, arc->GetCenter().id());
|
||||
AddAttribute(domElement, AttrRadius, arc->GetFormulaRadius());
|
||||
AddAttribute(domElement, AttrAngle1, arc->GetFormulaF1());
|
||||
AddAttribute(domElement, AttrAngle2, arc->GetFormulaF2());
|
||||
|
||||
AddToCalculation(domElement);
|
||||
}
|
||||
|
||||
void VToolArc::RefreshDataInFile()
|
||||
{
|
||||
VArc arc = VAbstractTool::data.GetArc(id);
|
||||
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrCenter, arc.GetCenter());
|
||||
domElement.setAttribute(AttrRadius, arc.GetFormulaRadius());
|
||||
domElement.setAttribute(AttrAngle1, arc.GetFormulaF1());
|
||||
domElement.setAttribute(AttrAngle2, arc.GetFormulaF2());
|
||||
domElement.setAttribute(AttrCenter, arc->GetCenter().id());
|
||||
domElement.setAttribute(AttrRadius, arc->GetFormulaRadius());
|
||||
domElement.setAttribute(AttrAngle1, arc->GetFormulaF1());
|
||||
domElement.setAttribute(AttrAngle2, arc->GetFormulaF2());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,16 +241,16 @@ void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
|
||||
void VToolArc::RemoveReferens()
|
||||
{
|
||||
VArc arc = VAbstractTool::data.GetArc(id);
|
||||
doc->DecrementReferens(arc.GetCenter());
|
||||
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
|
||||
doc->DecrementReferens(arc->GetCenter().id());
|
||||
}
|
||||
|
||||
void VToolArc::RefreshGeometry()
|
||||
{
|
||||
this->setPen(QPen(currentColor, widthHairLine/factor));
|
||||
VArc arc = VAbstractTool::data.GetArc(id);
|
||||
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
|
||||
QPainterPath path;
|
||||
path.addPath(arc.GetPath());
|
||||
path.addPath(arc->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
this->setPath(path);
|
||||
}
|
||||
|
|
|
@ -73,13 +73,13 @@ QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secon
|
|||
void VToolBisector::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogBisector.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogBisector->setTypeLine(typeLine);
|
||||
dialogBisector->setFormula(formula);
|
||||
dialogBisector->setFirstPointId(firstPointId, id);
|
||||
dialogBisector->setSecondPointId(basePointId, id);
|
||||
dialogBisector->setThirdPointId(thirdPointId, id);
|
||||
dialogBisector->setPointName(p.name());
|
||||
dialogBisector->setPointName(p->name());
|
||||
}
|
||||
|
||||
void VToolBisector::Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
|
@ -101,26 +101,26 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
|
|||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||
VPointF thirdPoint = data->GetPoint(thirdPointId);
|
||||
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(firstPointId);
|
||||
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
|
||||
const VPointF *thirdPoint = data->GeometricObject<const VPointF *>(thirdPointId);
|
||||
|
||||
Calculator cal(data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
if (errorMsg.isEmpty())
|
||||
{
|
||||
QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||
thirdPoint.toQPointF(), toPixel(result));
|
||||
QPointF fPoint = VToolBisector::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
|
||||
thirdPoint->toQPointF(), toPixel(result));
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
|
@ -190,14 +190,14 @@ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolBisector::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrTypeLine, typeLine);
|
||||
AddAttribute(domElement, AttrLength, formula);
|
||||
|
@ -210,13 +210,13 @@ void VToolBisector::AddToFile()
|
|||
|
||||
void VToolBisector::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrMx, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrTypeLine, typeLine);
|
||||
domElement.setAttribute(AttrLength, formula);
|
||||
domElement.setAttribute(AttrFirstPoint, firstPointId);
|
||||
|
|
|
@ -67,10 +67,10 @@ VToolCutSpline::VToolCutSpline(VDomDocument *doc, VContainer *data, const qint64
|
|||
void VToolCutSpline::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogCutSpline.isNull() == false);
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogCutSpline->setFormula(formula);
|
||||
dialogCutSpline->setSplineId(splineId, id);
|
||||
dialogCutSpline->setPointName(point.name());
|
||||
dialogCutSpline->setPointName(point->name());
|
||||
}
|
||||
|
||||
void VToolCutSpline::Create(QSharedPointer<DialogCutSpline> &dialog, VMainGraphicsScene *scene,
|
||||
|
@ -87,53 +87,61 @@ void VToolCutSpline::Create(const qint64 _id, const QString &pointName,
|
|||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VSpline spl = data->GetSpline(splineId);
|
||||
const VSpline *spl = data->GeometricObject<const VSpline *>(splineId);
|
||||
Calculator cal(data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
if (errorMsg.isEmpty())
|
||||
{
|
||||
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
|
||||
QPointF point = spl.CutSpline(toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
|
||||
QPointF point = spl->CutSpline(toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
|
||||
|
||||
qint64 id = _id;
|
||||
qint64 spl1id = 0;
|
||||
qint64 spl2id = 0;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my);
|
||||
Q_ASSERT(p != 0);
|
||||
id = data->AddGObject(p);
|
||||
spl1id = id + 1;
|
||||
spl2id = id + 2;
|
||||
|
||||
VSpline spline1 = VSpline(data->DataPoints(), spl.GetP1(), spl1p2, spl1p3, id, spl.GetKcurve());
|
||||
spl1id = data->AddSpline(spline1);
|
||||
data->AddLengthSpline(spline1.name(), toMM(spline1.GetLength()));
|
||||
VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p, spl->GetKcurve());
|
||||
Q_ASSERT(spline1);
|
||||
spl1id = data->AddGObject(spline1);
|
||||
data->AddLengthSpline(spline1->name(), toMM(spline1->GetLength()));
|
||||
|
||||
VSpline spline2 = VSpline(data->DataPoints(), id, spl2p2, spl2p3, spl.GetP4(), spl.GetKcurve());
|
||||
spl2id = data->AddSpline(spline2);
|
||||
data->AddLengthSpline(spline2.name(), toMM(spline2.GetLength()));
|
||||
VSpline *spline2 = new VSpline(*p, spl2p2, spl2p3, spl->GetP4(), spl->GetKcurve());
|
||||
Q_ASSERT(spline2);
|
||||
spl2id = data->AddGObject(spline2);
|
||||
data->AddLengthSpline(spline2->name(), toMM(spline2->GetLength()));
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my);
|
||||
Q_ASSERT(p != 0);
|
||||
data->UpdateGObject(id, p);
|
||||
|
||||
spl1id = id + 1;
|
||||
spl2id = id + 2;
|
||||
|
||||
VSpline spline1 = VSpline(data->DataPoints(), spl.GetP1(), spl1p2, spl1p3, id, spl.GetKcurve());
|
||||
data->UpdateSpline(spl1id, spline1);
|
||||
data->AddLengthSpline(spline1.name(), toMM(spline1.GetLength()));
|
||||
VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p, spl->GetKcurve());
|
||||
Q_ASSERT(spline1);
|
||||
data->UpdateGObject(spl1id, spline1);
|
||||
data->AddLengthSpline(spline1->name(), toMM(spline1->GetLength()));
|
||||
|
||||
VSpline spline2 = VSpline(data->DataPoints(), id, spl2p2, spl2p3, spl.GetP4(), spl.GetKcurve());
|
||||
data->UpdateSpline(spl2id, spline2);
|
||||
data->AddLengthSpline(spline2.name(), toMM(spline2.GetLength()));
|
||||
VSpline *spline2 = new VSpline(*p, spl2p2, spl2p3, spl->GetP4(), spl->GetKcurve());
|
||||
Q_ASSERT(spline2);
|
||||
data->UpdateGObject(spl2id, spline2);
|
||||
data->AddLengthSpline(spline2->name(), toMM(spline2->GetLength()));
|
||||
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
}
|
||||
}
|
||||
//VDrawTool::AddRecord(id, Tool::CutSplineTool, doc);
|
||||
VDrawTool::AddRecord(id, Tool::CutSplineTool, doc);
|
||||
if (parse == Document::FullParse)
|
||||
{
|
||||
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation);
|
||||
|
@ -211,14 +219,14 @@ void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolCutSpline::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrLength, formula);
|
||||
AddAttribute(domElement, AttrSpline, splineId);
|
||||
|
@ -228,13 +236,13 @@ void VToolCutSpline::AddToFile()
|
|||
|
||||
void VToolCutSpline::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrMx, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
domElement.setAttribute(AttrLength, formula);
|
||||
domElement.setAttribute(AttrSpline, splineId);
|
||||
}
|
||||
|
@ -244,22 +252,22 @@ void VToolCutSpline::RefreshGeometry()
|
|||
{
|
||||
RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint);
|
||||
RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint);
|
||||
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolCutSpline::RefreshSpline(VSimpleSpline *spline, qint64 splid, SimpleSpline::Translation tr)
|
||||
{
|
||||
VSpline spl = VAbstractTool::data.GetSpline(splid);
|
||||
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(splid);
|
||||
QPainterPath path;
|
||||
path.addPath(spl.GetPath());
|
||||
path.addPath(spl->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
if(tr == SimpleSpline::FirstPoint)
|
||||
{
|
||||
path.translate(-spl.GetPointP1().toQPointF().x(), -spl.GetPointP1().toQPointF().y());
|
||||
path.translate(-spl->GetP1().toQPointF().x(), -spl->GetP1().toQPointF().y());
|
||||
}
|
||||
else
|
||||
{
|
||||
path.translate(-spl.GetPointP4().toQPointF().x(), -spl.GetPointP4().toQPointF().y());
|
||||
path.translate(-spl->GetP4().toQPointF().x(), -spl->GetP4().toQPointF().y());
|
||||
}
|
||||
spline->setPath(path);
|
||||
}
|
||||
|
|
|
@ -69,10 +69,10 @@ VToolCutSplinePath::VToolCutSplinePath(VDomDocument *doc, VContainer *data, cons
|
|||
void VToolCutSplinePath::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogCutSplinePath.isNull() == false);
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogCutSplinePath->setFormula(formula);
|
||||
dialogCutSplinePath->setSplinePathId(splinePathId, id);
|
||||
dialogCutSplinePath->setPointName(point.name());
|
||||
dialogCutSplinePath->setPointName(point->name());
|
||||
}
|
||||
|
||||
void VToolCutSplinePath::Create(QSharedPointer<DialogCutSplinePath> &dialog, VMainGraphicsScene *scene,
|
||||
|
@ -89,7 +89,7 @@ void VToolCutSplinePath::Create(const qint64 _id, const QString &pointName, cons
|
|||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VSplinePath splPath = data->GetSplinePath(splinePathId);
|
||||
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(splinePathId);
|
||||
Calculator cal(data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
|
@ -97,109 +97,115 @@ void VToolCutSplinePath::Create(const qint64 _id, const QString &pointName, cons
|
|||
{
|
||||
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
|
||||
qint32 p1 = 0, p2 = 0;
|
||||
QPointF point = splPath.CutSplinePath(toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
|
||||
QPointF point = splPath->CutSplinePath(toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
|
||||
|
||||
qint64 id = _id;
|
||||
qint64 splPath1id = 0;
|
||||
qint64 splPath2id = 0;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my);
|
||||
Q_ASSERT(p);
|
||||
id = data->AddGObject(p);
|
||||
splPath1id = id + 1;
|
||||
splPath2id = id + 2;
|
||||
|
||||
VSplinePoint splP1 = splPath[p1];
|
||||
VSplinePoint splP2 = splPath[p2];
|
||||
VSpline spl1 = VSpline(data->DataPoints(), splP1.P(), spl1p2, spl1p3, id, splPath.getKCurve());
|
||||
VSpline spl2 = VSpline(data->DataPoints(), id, spl2p2, spl2p3, splP2.P(), splPath.getKCurve());
|
||||
VSplinePoint splP1 = splPath->at(p1);
|
||||
VSplinePoint splP2 = splPath->at(p2);
|
||||
VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->getKCurve());
|
||||
VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve());
|
||||
|
||||
|
||||
VSplinePath splPath1, splPath2;
|
||||
splPath1.setPoints(data->DataPoints());
|
||||
splPath2.setPoints(data->DataPoints());
|
||||
for(qint32 i = 0; i < splPath.CountPoint(); i++)
|
||||
VSplinePath *splPath1 = new VSplinePath();
|
||||
Q_ASSERT(splPath1);
|
||||
VSplinePath *splPath2 = new VSplinePath();
|
||||
Q_ASSERT(splPath2);
|
||||
for(qint32 i = 0; i < splPath->CountPoint(); i++)
|
||||
{
|
||||
if(i <= p1 && i < p2){
|
||||
if(i == p1)
|
||||
{
|
||||
splPath1.append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1(), spl1.GetKasm1()));
|
||||
VSplinePoint cutPoint = VSplinePoint(id, spl1.GetKasm2(), spl1.GetAngle2()+180, spl2.GetKasm1());
|
||||
splPath1.append(cutPoint);
|
||||
splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1(), spl1.GetKasm1()));
|
||||
VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2()+180, spl2.GetKasm1());
|
||||
splPath1->append(cutPoint);
|
||||
continue;
|
||||
}
|
||||
splPath1.append(splPath[i]);
|
||||
splPath1->append(splPath->at(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(i == p2)
|
||||
{
|
||||
VSplinePoint cutPoint = VSplinePoint(id, spl1.GetKasm2(), spl2.GetAngle1(), spl2.GetKasm1());
|
||||
splPath2.append(cutPoint);
|
||||
splPath2.append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2()+180, splP2.KAsm2()));
|
||||
VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1(), spl2.GetKasm1());
|
||||
splPath2->append(cutPoint);
|
||||
splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2()+180, splP2.KAsm2()));
|
||||
continue;
|
||||
}
|
||||
splPath2.append(splPath[i]);
|
||||
splPath2->append(splPath->at(i));
|
||||
}
|
||||
}
|
||||
|
||||
splPath1id = data->AddSplinePath(splPath1);
|
||||
data->AddLengthSpline(splPath1.name(), toMM(splPath1.GetLength()));
|
||||
splPath1id = data->AddGObject(splPath1);
|
||||
data->AddLengthSpline(splPath1->name(), toMM(splPath1->GetLength()));
|
||||
|
||||
splPath2id = data->AddSplinePath(splPath2);
|
||||
data->AddLengthSpline(splPath2.name(), toMM(splPath2.GetLength()));
|
||||
splPath2id = data->AddGObject(splPath2);
|
||||
data->AddLengthSpline(splPath2->name(), toMM(splPath2->GetLength()));
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my);
|
||||
Q_ASSERT(p);
|
||||
data->UpdateGObject(id, p);
|
||||
|
||||
splPath1id = id + 1;
|
||||
splPath2id = id + 2;
|
||||
|
||||
VSplinePoint splP1 = splPath[p1];
|
||||
VSplinePoint splP2 = splPath[p2];
|
||||
VSpline spl1 = VSpline(data->DataPoints(), splP1.P(), spl1p2, spl1p3, id, splPath.getKCurve());
|
||||
VSpline spl2 = VSpline(data->DataPoints(), id, spl2p2, spl2p3, splP2.P(), splPath.getKCurve());
|
||||
VSplinePoint splP1 = splPath->at(p1);
|
||||
VSplinePoint splP2 = splPath->at(p2);
|
||||
VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->getKCurve());
|
||||
VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve());
|
||||
|
||||
VSplinePath splPath1, splPath2;
|
||||
splPath1.setPoints(data->DataPoints());
|
||||
splPath2.setPoints(data->DataPoints());
|
||||
for(qint32 i = 0; i < splPath.CountPoint(); i++)
|
||||
VSplinePath *splPath1 = new VSplinePath();
|
||||
Q_ASSERT(splPath1 != 0);
|
||||
VSplinePath *splPath2 = new VSplinePath();
|
||||
Q_ASSERT(splPath2 != 0);
|
||||
for(qint32 i = 0; i < splPath->CountPoint(); i++)
|
||||
{
|
||||
if(i <= p1 && i < p2){
|
||||
if(i == p1)
|
||||
{
|
||||
splPath1.append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1(), spl1.GetKasm1()));
|
||||
VSplinePoint cutPoint = VSplinePoint(id, spl1.GetKasm2(), spl1.GetAngle2()+180, spl2.GetKasm1());
|
||||
splPath1.append(cutPoint);
|
||||
splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1(), spl1.GetKasm1()));
|
||||
VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2()+180, spl2.GetKasm1());
|
||||
splPath1->append(cutPoint);
|
||||
continue;
|
||||
}
|
||||
splPath1.append(splPath[i]);
|
||||
splPath1->append(splPath->at(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(i == p2)
|
||||
{
|
||||
VSplinePoint cutPoint = VSplinePoint(id, spl1.GetKasm2(), spl2.GetAngle1(), spl2.GetKasm1());
|
||||
splPath2.append(cutPoint);
|
||||
splPath2.append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2()+180, splP2.KAsm2()));
|
||||
VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1(), spl2.GetKasm1());
|
||||
splPath2->append(cutPoint);
|
||||
splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2()+180, splP2.KAsm2()));
|
||||
continue;
|
||||
}
|
||||
splPath2.append(splPath[i]);
|
||||
splPath2->append(splPath->at(i));
|
||||
}
|
||||
}
|
||||
|
||||
data->UpdateSplinePath(splPath1id, splPath1);
|
||||
data->AddLengthSpline(splPath1.name(), toMM(splPath1.GetLength()));
|
||||
data->UpdateGObject(splPath1id, splPath1);
|
||||
data->AddLengthSpline(splPath1->name(), toMM(splPath1->GetLength()));
|
||||
|
||||
data->UpdateSplinePath(splPath2id, splPath2);
|
||||
data->AddLengthSpline(splPath2.name(), toMM(splPath2.GetLength()));
|
||||
data->UpdateGObject(splPath2id, splPath2);
|
||||
data->AddLengthSpline(splPath2->name(), toMM(splPath2->GetLength()));
|
||||
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
}
|
||||
}
|
||||
//VDrawTool::AddRecord(id, Tool::CutSplineTool, doc);
|
||||
VDrawTool::AddRecord(id, Tool::CutSplinePathTool, doc);
|
||||
if (parse == Document::FullParse)
|
||||
{
|
||||
VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id,
|
||||
|
@ -278,14 +284,14 @@ void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolCutSplinePath::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrLength, formula);
|
||||
AddAttribute(domElement, AttrSplinePath, splinePathId);
|
||||
|
@ -295,13 +301,13 @@ void VToolCutSplinePath::AddToFile()
|
|||
|
||||
void VToolCutSplinePath::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrMx, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
domElement.setAttribute(AttrLength, formula);
|
||||
domElement.setAttribute(AttrSplinePath, splinePathId);
|
||||
}
|
||||
|
@ -311,24 +317,24 @@ void VToolCutSplinePath::RefreshGeometry()
|
|||
{
|
||||
RefreshSpline(firstSpline, splPath1id, SimpleSpline::ForthPoint);
|
||||
RefreshSpline(secondSpline, splPath2id, SimpleSpline::FirstPoint);
|
||||
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolCutSplinePath::RefreshSpline(VSimpleSpline *spline, qint64 splPathid, SimpleSpline::Translation tr)
|
||||
{
|
||||
VSplinePath splPath = VAbstractTool::data.GetSplinePath(splPathid);
|
||||
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(splPathid);
|
||||
QPainterPath path;
|
||||
path.addPath(splPath.GetPath());
|
||||
path.addPath(splPath->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
if(tr == SimpleSpline::FirstPoint)
|
||||
{
|
||||
VSpline spl = splPath.GetSpline(1);
|
||||
path.translate(-spl.GetPointP1().toQPointF().x(), -spl.GetPointP1().toQPointF().y());
|
||||
VSpline spl = splPath->GetSpline(1);
|
||||
path.translate(-spl.GetP1().toQPointF().x(), -spl.GetP1().toQPointF().y());
|
||||
}
|
||||
else
|
||||
{
|
||||
VSpline spl = splPath.GetSpline(splPath.Count());
|
||||
path.translate(-spl.GetPointP4().toQPointF().x(), -spl.GetPointP4().toQPointF().y());
|
||||
VSpline spl = splPath->GetSpline(splPath->Count());
|
||||
path.translate(-spl.GetP4().toQPointF().x(), -spl.GetP4().toQPointF().y());
|
||||
}
|
||||
spline->setPath(path);
|
||||
}
|
||||
|
|
|
@ -52,12 +52,12 @@ VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id
|
|||
void VToolEndLine::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogEndLine.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogEndLine->setTypeLine(typeLine);
|
||||
dialogEndLine->setFormula(formula);
|
||||
dialogEndLine->setAngle(angle);
|
||||
dialogEndLine->setBasePointId(basePointId, id);
|
||||
dialogEndLine->setPointName(p.name());
|
||||
dialogEndLine->setPointName(p->name());
|
||||
}
|
||||
|
||||
void VToolEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
|
@ -77,8 +77,8 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
|
|||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VPointF basePoint = data->GetPoint(basePointId);
|
||||
QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y()));
|
||||
const VPointF *basePoint = data->GeometricObject<const VPointF *>(basePointId);
|
||||
QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y()));
|
||||
Calculator cal(data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
|
@ -89,12 +89,12 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
|
|||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||
id = data->AddGObject(new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
|
@ -154,14 +154,14 @@ void VToolEndLine::FullUpdateFromGui(int result)
|
|||
|
||||
void VToolEndLine::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrTypeLine, typeLine);
|
||||
AddAttribute(domElement, AttrLength, formula);
|
||||
|
@ -173,13 +173,13 @@ void VToolEndLine::AddToFile()
|
|||
|
||||
void VToolEndLine::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrMx, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
domElement.setAttribute(AttrTypeLine, typeLine);
|
||||
domElement.setAttribute(AttrLength, formula);
|
||||
domElement.setAttribute(AttrAngle, angle);
|
||||
|
|
|
@ -50,12 +50,12 @@ VToolHeight::VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id,
|
|||
void VToolHeight::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogHeight.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogHeight->setTypeLine(typeLine);
|
||||
dialogHeight->setBasePointId(basePointId, id);
|
||||
dialogHeight->setP1LineId(p1LineId, id);
|
||||
dialogHeight->setP2LineId(p2LineId, id);
|
||||
dialogHeight->setPointName(p.name());
|
||||
dialogHeight->setPointName(p->name());
|
||||
}
|
||||
|
||||
void VToolHeight::Create(QSharedPointer<DialogHeight> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
|
@ -76,22 +76,22 @@ void VToolHeight::Create(const qint64 _id, const QString &pointName, const QStri
|
|||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VPointF basePoint = data->GetPoint(basePointId);
|
||||
VPointF p1Line = data->GetPoint(p1LineId);
|
||||
VPointF p2Line = data->GetPoint(p2LineId);
|
||||
const VPointF *basePoint = data->GeometricObject<const VPointF *>(basePointId);
|
||||
const VPointF *p1Line = data->GeometricObject<const VPointF *>(p1LineId);
|
||||
const VPointF *p2Line = data->GeometricObject<const VPointF *>(p2LineId);
|
||||
|
||||
QPointF pHeight = FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()), basePoint.toQPointF());
|
||||
QPointF pHeight = FindPoint(QLineF(p1Line->toQPointF(), p2Line->toQPointF()), basePoint->toQPointF());
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(pHeight.x(), pHeight.y(), pointName, mx, my));
|
||||
id = data->AddGObject(new VPointF(pHeight.x(), pHeight.y(), pointName, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
data->AddLine(p1LineId, id);
|
||||
data->AddLine(p2LineId, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(pHeight.x(), pHeight.y(), pointName, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(pHeight.x(), pHeight.y(), pointName, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
data->AddLine(p1LineId, id);
|
||||
data->AddLine(p2LineId, id);
|
||||
|
@ -174,14 +174,14 @@ void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolHeight::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrTypeLine, typeLine);
|
||||
AddAttribute(domElement, AttrBasePoint, basePointId);
|
||||
|
@ -194,13 +194,13 @@ void VToolHeight::AddToFile()
|
|||
|
||||
void VToolHeight::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrMx, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
domElement.setAttribute(AttrTypeLine, typeLine);
|
||||
domElement.setAttribute(AttrBasePoint, basePointId);
|
||||
domElement.setAttribute(AttrP1Line, p1LineId);
|
||||
|
|
|
@ -36,10 +36,10 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs
|
|||
dialogLine(QSharedPointer<DialogLine>())
|
||||
{
|
||||
ignoreFullUpdate = true;
|
||||
//Лінія
|
||||
VPointF first = data->GetPoint(firstPoint);
|
||||
VPointF second = data->GetPoint(secondPoint);
|
||||
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
|
||||
//Line
|
||||
const VPointF *first = data->GeometricObject<const VPointF *>(firstPoint);
|
||||
const VPointF *second = data->GeometricObject<const VPointF *>(secondPoint);
|
||||
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
|
||||
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
@ -206,8 +206,8 @@ void VToolLine::RefreshGeometry()
|
|||
firstPoint = domElement.attribute(AttrFirstPoint, "").toLongLong();
|
||||
secondPoint = domElement.attribute(AttrSecondPoint, "").toLongLong();
|
||||
}
|
||||
VPointF first = VAbstractTool::data.GetPoint(firstPoint);
|
||||
VPointF second = VAbstractTool::data.GetPoint(secondPoint);
|
||||
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
|
||||
const VPointF *first = VAbstractTool::data.GeometricObject<const VPointF *>(firstPoint);
|
||||
const VPointF *second = VAbstractTool::data.GeometricObject<const VPointF *>(secondPoint);
|
||||
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
|
||||
this->setPen(QPen(currentColor, widthHairLine/factor));
|
||||
}
|
||||
|
|
|
@ -51,12 +51,12 @@ VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, cons
|
|||
void VToolLineIntersect::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogLineIntersect.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogLineIntersect->setP1Line1(p1Line1);
|
||||
dialogLineIntersect->setP2Line1(p2Line1);
|
||||
dialogLineIntersect->setP1Line2(p1Line2);
|
||||
dialogLineIntersect->setP2Line2(p2Line2);
|
||||
dialogLineIntersect->setPointName(p.name());
|
||||
dialogLineIntersect->setPointName(p->name());
|
||||
}
|
||||
|
||||
void VToolLineIntersect::Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene,
|
||||
|
@ -77,13 +77,13 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
|
|||
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
|
||||
const Tool::Sources &typeCreation)
|
||||
{
|
||||
VPointF p1Line1 = data->GetPoint(p1Line1Id);
|
||||
VPointF p2Line1 = data->GetPoint(p2Line1Id);
|
||||
VPointF p1Line2 = data->GetPoint(p1Line2Id);
|
||||
VPointF p2Line2 = data->GetPoint(p2Line2Id);
|
||||
const VPointF *p1Line1 = data->GeometricObject<const VPointF *>(p1Line1Id);
|
||||
const VPointF *p2Line1 = data->GeometricObject<const VPointF *>(p2Line1Id);
|
||||
const VPointF *p1Line2 = data->GeometricObject<const VPointF *>(p1Line2Id);
|
||||
const VPointF *p2Line2 = data->GeometricObject<const VPointF *>(p2Line2Id);
|
||||
|
||||
QLineF line1(p1Line1.toQPointF(), p2Line1.toQPointF());
|
||||
QLineF line2(p1Line2.toQPointF(), p2Line2.toQPointF());
|
||||
QLineF line1(p1Line1->toQPointF(), p2Line1->toQPointF());
|
||||
QLineF line2(p1Line2->toQPointF(), p2Line2->toQPointF());
|
||||
QPointF fPoint;
|
||||
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
|
||||
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
|
||||
|
@ -91,7 +91,7 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
|
|||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->AddLine(p1Line1Id, id);
|
||||
data->AddLine(id, p2Line1Id);
|
||||
data->AddLine(p1Line2Id, id);
|
||||
|
@ -99,7 +99,7 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
|
|||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->AddLine(p1Line1Id, id);
|
||||
data->AddLine(id, p2Line1Id);
|
||||
data->AddLine(p1Line2Id, id);
|
||||
|
@ -137,7 +137,7 @@ void VToolLineIntersect::FullUpdateFromFile()
|
|||
p1Line2 = domElement.attribute(AttrP1Line2, "").toLongLong();
|
||||
p2Line2 = domElement.attribute(AttrP2Line2, "").toLongLong();
|
||||
}
|
||||
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolLineIntersect::FullUpdateFromGui(int result)
|
||||
|
@ -161,7 +161,7 @@ void VToolLineIntersect::FullUpdateFromGui(int result)
|
|||
void VToolLineIntersect::SetFactor(qreal factor)
|
||||
{
|
||||
VDrawTool::SetFactor(factor);
|
||||
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
|
@ -171,14 +171,14 @@ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolLineIntersect::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrP1Line1, p1Line1);
|
||||
AddAttribute(domElement, AttrP2Line1, p2Line1);
|
||||
|
@ -190,13 +190,13 @@ void VToolLineIntersect::AddToFile()
|
|||
|
||||
void VToolLineIntersect::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrMx, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
domElement.setAttribute(AttrP1Line1, p1Line1);
|
||||
domElement.setAttribute(AttrP2Line1, p2Line1);
|
||||
domElement.setAttribute(AttrP1Line2, p1Line2);
|
||||
|
|
|
@ -35,8 +35,8 @@ VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64
|
|||
mainLine(0)
|
||||
{
|
||||
Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0");
|
||||
QPointF point1 = data->GetPoint(basePointId).toQPointF();
|
||||
QPointF point2 = data->GetPoint(id).toQPointF();
|
||||
QPointF point1 = data->GeometricObject<const VPointF *>(basePointId)->toQPointF();
|
||||
QPointF point2 = data->GeometricObject<const VPointF *>(id)->toQPointF();
|
||||
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
|
||||
mainLine->setPen(QPen(Qt::black, widthHairLine/factor));
|
||||
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||
|
@ -67,9 +67,9 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
|||
void VToolLinePoint::RefreshGeometry()
|
||||
{
|
||||
mainLine->setPen(QPen(currentColor, widthHairLine/factor));
|
||||
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
|
||||
QPointF point = VDrawTool::data.GetPoint(id).toQPointF();
|
||||
QPointF basePoint = VDrawTool::data.GetPoint(basePointId).toQPointF();
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
||||
QPointF point = VDrawTool::data.GeometricObject<const VPointF *>(id)->toQPointF();
|
||||
QPointF basePoint = VDrawTool::data.GeometricObject<const VPointF *>(basePointId)->toQPointF();
|
||||
mainLine->setLine(QLineF(basePoint - point, QPointF()));
|
||||
if (typeLine == TypeLineNone)
|
||||
{
|
||||
|
|
|
@ -51,13 +51,13 @@ VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
|
|||
void VToolNormal::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogNormal.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogNormal->setTypeLine(typeLine);
|
||||
dialogNormal->setFormula(formula);
|
||||
dialogNormal->setAngle(angle);
|
||||
dialogNormal->setFirstPointId(basePointId, id);
|
||||
dialogNormal->setSecondPointId(secondPointId, id);
|
||||
dialogNormal->setPointName(p.name());
|
||||
dialogNormal->setPointName(p->name());
|
||||
}
|
||||
|
||||
void VToolNormal::Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
|
@ -79,24 +79,24 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
|
|||
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
|
||||
const Tool::Sources &typeCreation)
|
||||
{
|
||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(firstPointId);
|
||||
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
|
||||
Calculator cal(data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
if (errorMsg.isEmpty())
|
||||
{
|
||||
QPointF fPoint = VToolNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||
QPointF fPoint = VToolNormal::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
|
||||
toPixel(result), angle);
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
|
@ -175,14 +175,14 @@ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolNormal::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrTypeLine, typeLine);
|
||||
AddAttribute(domElement, AttrLength, formula);
|
||||
|
@ -195,13 +195,13 @@ void VToolNormal::AddToFile()
|
|||
|
||||
void VToolNormal::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrMx, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
domElement.setAttribute(AttrTypeLine, typeLine);
|
||||
domElement.setAttribute(AttrLength, formula);
|
||||
domElement.setAttribute(AttrAngle, angle);
|
||||
|
|
|
@ -40,18 +40,19 @@ VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphics
|
|||
this->setBrush(QBrush(Qt::NoBrush));
|
||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
this->setAcceptHoverEvents(true);
|
||||
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolPoint::NameChangePosition(const QPointF &pos)
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
Q_ASSERT(point != 0);
|
||||
QPointF p = pos - this->pos();
|
||||
point.setMx(p.x());
|
||||
point.setMy(p.y());
|
||||
point->setMx(p.x());
|
||||
point->setMy(p.y());
|
||||
RefreshLine();
|
||||
UpdateNamePosition(point.mx(), point.my());
|
||||
VAbstractTool::data.UpdatePoint(id, point);
|
||||
UpdateNamePosition(point->mx(), point->my());
|
||||
VAbstractTool::data.UpdateGObject(id, point);
|
||||
}
|
||||
|
||||
void VToolPoint::UpdateNamePosition(qreal mx, qreal my)
|
||||
|
@ -59,8 +60,8 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my)
|
|||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrMx, QString().setNum(toMM(mx)));
|
||||
domElement.setAttribute(AttrMy, QString().setNum(toMM(my)));
|
||||
domElement.setAttribute(AttrMx, toMM(mx));
|
||||
domElement.setAttribute(AttrMy, toMM(my));
|
||||
emit toolhaveChange();
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +99,7 @@ void VToolPoint::ShowTool(qint64 id, Qt::GlobalColor color, bool enable)
|
|||
void VToolPoint::SetFactor(qreal factor)
|
||||
{
|
||||
VDrawTool::SetFactor(factor);
|
||||
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
|
|
@ -51,12 +51,12 @@ VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, co
|
|||
void VToolPointOfContact::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogPointOfContact.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogPointOfContact->setRadius(radius);
|
||||
dialogPointOfContact->setCenter(center, id);
|
||||
dialogPointOfContact->setFirstPoint(firstPointId, id);
|
||||
dialogPointOfContact->setSecondPoint(secondPointId, id);
|
||||
dialogPointOfContact->setPointName(p.name());
|
||||
dialogPointOfContact->setPointName(p->name());
|
||||
}
|
||||
|
||||
QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint,
|
||||
|
@ -103,28 +103,28 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
|
|||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VPointF centerP = data->GetPoint(center);
|
||||
VPointF firstP = data->GetPoint(firstPointId);
|
||||
VPointF secondP = data->GetPoint(secondPointId);
|
||||
const VPointF *centerP = data->GeometricObject<const VPointF *>(center);
|
||||
const VPointF *firstP = data->GeometricObject<const VPointF *>(firstPointId);
|
||||
const VPointF *secondP = data->GeometricObject<const VPointF *>(secondPointId);
|
||||
|
||||
Calculator cal(data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(radius, &errorMsg);
|
||||
if (errorMsg.isEmpty())
|
||||
{
|
||||
QPointF fPoint = VToolPointOfContact::FindPoint(toPixel(result), centerP.toQPointF(),
|
||||
firstP.toQPointF(), secondP.toQPointF());
|
||||
QPointF fPoint = VToolPointOfContact::FindPoint(toPixel(result), centerP->toQPointF(),
|
||||
firstP->toQPointF(), secondP->toQPointF());
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(secondPointId, id);
|
||||
data->AddLine(center, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(secondPointId, id);
|
||||
data->AddLine(center, id);
|
||||
|
@ -160,7 +160,7 @@ void VToolPointOfContact::FullUpdateFromFile()
|
|||
firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
|
||||
secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong();
|
||||
}
|
||||
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolPointOfContact::FullUpdateFromGui(int result)
|
||||
|
@ -184,7 +184,7 @@ void VToolPointOfContact::FullUpdateFromGui(int result)
|
|||
void VToolPointOfContact::SetFactor(qreal factor)
|
||||
{
|
||||
VDrawTool::SetFactor(factor);
|
||||
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
|
@ -194,14 +194,14 @@ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event
|
|||
|
||||
void VToolPointOfContact::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrRadius, radius);
|
||||
AddAttribute(domElement, AttrCenter, center);
|
||||
|
@ -213,13 +213,13 @@ void VToolPointOfContact::AddToFile()
|
|||
|
||||
void VToolPointOfContact::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrMx, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
domElement.setAttribute(AttrRadius, radius);
|
||||
domElement.setAttribute(AttrCenter, center);
|
||||
domElement.setAttribute(AttrFirstPoint, firstPointId);
|
||||
|
|
|
@ -50,10 +50,10 @@ VToolPointOfIntersection::VToolPointOfIntersection(VDomDocument *doc, VContainer
|
|||
void VToolPointOfIntersection::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogPointOfIntersection.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogPointOfIntersection->setFirstPointId(firstPointId, id);
|
||||
dialogPointOfIntersection->setSecondPointId(secondPointId, id);
|
||||
dialogPointOfIntersection->setPointName(p.name());
|
||||
dialogPointOfIntersection->setPointName(p->name());
|
||||
}
|
||||
|
||||
void VToolPointOfIntersection::Create(QSharedPointer<DialogPointOfIntersection> &dialog, VMainGraphicsScene *scene,
|
||||
|
@ -70,18 +70,18 @@ void VToolPointOfIntersection::Create(const qint64 _id, const QString &pointName
|
|||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(firstPointId);
|
||||
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
|
||||
|
||||
QPointF point(firstPoint.x(), secondPoint.y());
|
||||
QPointF point(firstPoint->x(), secondPoint->y());
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
id = data->AddGObject(new VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
|
@ -110,7 +110,7 @@ void VToolPointOfIntersection::FullUpdateFromFile()
|
|||
firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
|
||||
secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong();
|
||||
}
|
||||
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolPointOfIntersection::FullUpdateFromGui(int result)
|
||||
|
@ -142,14 +142,14 @@ void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *
|
|||
|
||||
void VToolPointOfIntersection::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrFirstPoint, firstPointId);
|
||||
AddAttribute(domElement, AttrSecondPoint, secondPointId);
|
||||
|
@ -159,13 +159,13 @@ void VToolPointOfIntersection::AddToFile()
|
|||
|
||||
void VToolPointOfIntersection::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrName, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrName, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrName, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrName, toMM(point->my()));
|
||||
domElement.setAttribute(AttrFirstPoint, firstPointId);
|
||||
domElement.setAttribute(AttrSecondPoint, secondPointId);
|
||||
}
|
||||
|
|
|
@ -51,13 +51,13 @@ VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, cons
|
|||
void VToolShoulderPoint::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogShoulderPoint.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogShoulderPoint->setTypeLine(typeLine);
|
||||
dialogShoulderPoint->setFormula(formula);
|
||||
dialogShoulderPoint->setP1Line(basePointId, id);
|
||||
dialogShoulderPoint->setP2Line(p2Line, id);
|
||||
dialogShoulderPoint->setPShoulder(pShoulder, id);
|
||||
dialogShoulderPoint->setPointName(p.name());
|
||||
dialogShoulderPoint->setPointName(p->name());
|
||||
}
|
||||
|
||||
QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
|
||||
|
@ -105,27 +105,27 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
|
|||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VPointF firstPoint = data->GetPoint(p1Line);
|
||||
VPointF secondPoint = data->GetPoint(p2Line);
|
||||
VPointF shoulderPoint = data->GetPoint(pShoulder);
|
||||
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(p1Line);
|
||||
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(p2Line);
|
||||
const VPointF *shoulderPoint = data->GeometricObject<const VPointF *>(pShoulder);
|
||||
|
||||
Calculator cal(data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
if (errorMsg.isEmpty())
|
||||
{
|
||||
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||
shoulderPoint.toQPointF(), toPixel(result));
|
||||
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
|
||||
shoulderPoint->toQPointF(), toPixel(result));
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->AddLine(p1Line, id);
|
||||
data->AddLine(p2Line, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
data->AddLine(p1Line, id);
|
||||
data->AddLine(p2Line, id);
|
||||
if (parse != Document::FullParse)
|
||||
|
@ -197,14 +197,14 @@ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolShoulderPoint::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrTypeLine, typeLine);
|
||||
AddAttribute(domElement, AttrLength, formula);
|
||||
|
@ -217,13 +217,13 @@ void VToolShoulderPoint::AddToFile()
|
|||
|
||||
void VToolShoulderPoint::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrName, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrName, toMM(point.my()));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrName, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrName, toMM(point->my()));
|
||||
domElement.setAttribute(AttrTypeLine, typeLine);
|
||||
domElement.setAttribute(AttrLength, formula);
|
||||
domElement.setAttribute(AttrP1Line, basePointId);
|
||||
|
|
|
@ -50,37 +50,37 @@ VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64
|
|||
void VToolSinglePoint::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogSinglePoint.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
dialogSinglePoint->setData(p.name(), p.toQPointF());
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogSinglePoint->setData(p->name(), p->toQPointF());
|
||||
}
|
||||
|
||||
void VToolSinglePoint::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrX, toMM(point.x()));
|
||||
AddAttribute(domElement, AttrY, toMM(point.y()));
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrX, toMM(point->x()));
|
||||
AddAttribute(domElement, AttrY, toMM(point->y()));
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddToCalculation(domElement);
|
||||
}
|
||||
|
||||
void VToolSinglePoint::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrX, QString().setNum(toMM(point.x())));
|
||||
domElement.setAttribute(AttrY, QString().setNum(toMM(point.y())));
|
||||
domElement.setAttribute(AttrMx, QString().setNum(toMM(point.mx())));
|
||||
domElement.setAttribute(AttrMy, QString().setNum(toMM(point.my())));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrX, QString().setNum(toMM(point->x())));
|
||||
domElement.setAttribute(AttrY, QString().setNum(toMM(point->y())));
|
||||
domElement.setAttribute(AttrMx, QString().setNum(toMM(point->mx())));
|
||||
domElement.setAttribute(AttrMy, QString().setNum(toMM(point->my())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event
|
|||
|
||||
void VToolSinglePoint::FullUpdateFromFile()
|
||||
{
|
||||
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolSinglePoint::FullUpdateFromGui(int result)
|
||||
|
@ -169,5 +169,5 @@ void VToolSinglePoint::ChangedActivDraw(const QString &newName)
|
|||
void VToolSinglePoint::SetFactor(qreal factor)
|
||||
{
|
||||
VDrawTool::SetFactor(factor);
|
||||
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
|
|
@ -39,25 +39,25 @@ VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, const T
|
|||
{
|
||||
ignoreFullUpdate = true;
|
||||
|
||||
VSpline spl = data->GetSpline(id);
|
||||
const VSpline *spl = data->GeometricObject<const VSpline *>(id);
|
||||
QPainterPath path;
|
||||
path.addPath(spl.GetPath());
|
||||
path.addPath(spl->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
this->setPath(path);
|
||||
this->setPen(QPen(Qt::black, widthHairLine/factor));
|
||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePoint::FirstPoint, spl.GetP2(),
|
||||
spl.GetPointP1().toQPointF(), this);
|
||||
VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePoint::FirstPoint, spl->GetP2(),
|
||||
spl->GetP1().toQPointF(), this);
|
||||
connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
connect(this, &VToolSpline::RefreshLine, controlPoint1, &VControlPointSpline::RefreshLine);
|
||||
connect(this, &VToolSpline::setEnabledPoint, controlPoint1, &VControlPointSpline::setEnabledPoint);
|
||||
controlPoints.append(controlPoint1);
|
||||
|
||||
VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePoint::LastPoint, spl.GetP3(),
|
||||
spl.GetPointP4().toQPointF(), this);
|
||||
VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePoint::LastPoint, spl->GetP3(),
|
||||
spl->GetP4().toQPointF(), this);
|
||||
connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
connect(this, &VToolSpline::RefreshLine, controlPoint2, &VControlPointSpline::RefreshLine);
|
||||
|
@ -77,14 +77,14 @@ VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, const T
|
|||
void VToolSpline::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogSpline.isNull() == false);
|
||||
VSpline spl = VAbstractTool::data.GetSpline(id);
|
||||
dialogSpline->setP1(spl.GetP1());
|
||||
dialogSpline->setP4(spl.GetP4());
|
||||
dialogSpline->setAngle1(spl.GetAngle1());
|
||||
dialogSpline->setAngle2(spl.GetAngle2());
|
||||
dialogSpline->setKAsm1(spl.GetKasm1());
|
||||
dialogSpline->setKAsm2(spl.GetKasm2());
|
||||
dialogSpline->setKCurve(spl.GetKcurve());
|
||||
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
||||
dialogSpline->setP1(spl->GetP1().id());
|
||||
dialogSpline->setP4(spl->GetP4().id());
|
||||
dialogSpline->setAngle1(spl->GetAngle1());
|
||||
dialogSpline->setAngle2(spl->GetAngle2());
|
||||
dialogSpline->setKAsm1(spl->GetKasm1());
|
||||
dialogSpline->setKAsm2(spl->GetKasm2());
|
||||
dialogSpline->setKCurve(spl->GetKcurve());
|
||||
}
|
||||
|
||||
void VToolSpline::Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
|
@ -106,17 +106,20 @@ void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, c
|
|||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VSpline spline = VSpline(data->DataPoints(), p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve);
|
||||
VPointF point1 = *data->GeometricObject<const VPointF *>(p1);
|
||||
VPointF point4 = *data->GeometricObject<const VPointF *>(p4);
|
||||
VSpline *spline = new VSpline(point1, point4, angle1, angle2, kAsm1, kAsm2, kCurve);
|
||||
Q_ASSERT(spline != 0);
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddSpline(spline);
|
||||
data->AddLengthSpline(spline.name(), toMM(spline.GetLength()));
|
||||
id = data->AddGObject(spline);
|
||||
data->AddLengthSpline(spline->name(), toMM(spline->GetLength()));
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateSpline(id, spline);
|
||||
data->AddLengthSpline(spline.name(), toMM(spline.GetLength()));
|
||||
data->UpdateGObject(id, spline);
|
||||
data->AddLengthSpline(spline->name(), toMM(spline->GetLength()));
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
|
@ -145,8 +148,9 @@ void VToolSpline::FullUpdateFromGui(int result)
|
|||
{
|
||||
if (result == QDialog::Accepted)
|
||||
{
|
||||
VSpline spl = VSpline (VAbstractTool::data.DataPoints(), dialogSpline->getP1(),
|
||||
dialogSpline->getP4(), dialogSpline->getAngle1(), dialogSpline->getAngle2(),
|
||||
VPointF point1 = *VAbstractTool::data.GeometricObject<const VPointF *>(dialogSpline->getP1());
|
||||
VPointF point4 = *VAbstractTool::data.GeometricObject<const VPointF *>(dialogSpline->getP4());
|
||||
VSpline spl = VSpline (point1, point4, dialogSpline->getAngle1(), dialogSpline->getAngle2(),
|
||||
dialogSpline->getKAsm1(), dialogSpline->getKAsm2(), dialogSpline->getKCurve());
|
||||
|
||||
disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
|
@ -160,18 +164,17 @@ void VToolSpline::FullUpdateFromGui(int result)
|
|||
connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
|
||||
spl = VSpline (VAbstractTool::data.DataPoints(), dialogSpline->getP1(), controlPoints[0]->pos(),
|
||||
controlPoints[1]->pos(), dialogSpline->getP4(), dialogSpline->getKCurve());
|
||||
spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogSpline->getKCurve());
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrPoint1, QString().setNum(spl.GetP1()));
|
||||
domElement.setAttribute(AttrPoint4, QString().setNum(spl.GetP4()));
|
||||
domElement.setAttribute(AttrAngle1, QString().setNum(spl.GetAngle1()));
|
||||
domElement.setAttribute(AttrAngle2, QString().setNum(spl.GetAngle2()));
|
||||
domElement.setAttribute(AttrKAsm1, QString().setNum(spl.GetKasm1()));
|
||||
domElement.setAttribute(AttrKAsm2, QString().setNum(spl.GetKasm2()));
|
||||
domElement.setAttribute(AttrKCurve, QString().setNum(spl.GetKcurve()));
|
||||
domElement.setAttribute(AttrPoint1, spl.GetP1().id());
|
||||
domElement.setAttribute(AttrPoint4, spl.GetP4().id());
|
||||
domElement.setAttribute(AttrAngle1, spl.GetAngle1());
|
||||
domElement.setAttribute(AttrAngle2, spl.GetAngle2());
|
||||
domElement.setAttribute(AttrKAsm1, spl.GetKasm1());
|
||||
domElement.setAttribute(AttrKAsm2, spl.GetKasm2());
|
||||
domElement.setAttribute(AttrKCurve, spl.GetKcurve());
|
||||
emit FullUpdateTree();
|
||||
}
|
||||
}
|
||||
|
@ -182,14 +185,15 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
|
|||
const QPointF &pos)
|
||||
{
|
||||
Q_UNUSED(indexSpline);
|
||||
VSpline spl = VAbstractTool::data.GetSpline(id);
|
||||
const VSpline *spline = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
||||
VSpline spl;
|
||||
if (position == SplinePoint::FirstPoint)
|
||||
{
|
||||
spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve());
|
||||
spl = VSpline(spline->GetP1(), pos, spline->GetP3(), spline->GetP4(), spline->GetKcurve());
|
||||
}
|
||||
else
|
||||
{
|
||||
spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve());
|
||||
spl = VSpline(spline->GetP1(), spline->GetP2(), pos, spline->GetP4(), spline->GetKcurve());
|
||||
}
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
|
@ -210,35 +214,35 @@ void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolSpline::AddToFile()
|
||||
{
|
||||
VSpline spl = VAbstractTool::data.GetSpline(id);
|
||||
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrPoint1, spl.GetP1());
|
||||
AddAttribute(domElement, AttrPoint4, spl.GetP4());
|
||||
AddAttribute(domElement, AttrAngle1, spl.GetAngle1());
|
||||
AddAttribute(domElement, AttrAngle2, spl.GetAngle2());
|
||||
AddAttribute(domElement, AttrKAsm1, spl.GetKasm1());
|
||||
AddAttribute(domElement, AttrKAsm2, spl.GetKasm2());
|
||||
AddAttribute(domElement, AttrKCurve, spl.GetKcurve());
|
||||
AddAttribute(domElement, AttrPoint1, spl->GetP1().id());
|
||||
AddAttribute(domElement, AttrPoint4, spl->GetP4().id());
|
||||
AddAttribute(domElement, AttrAngle1, spl->GetAngle1());
|
||||
AddAttribute(domElement, AttrAngle2, spl->GetAngle2());
|
||||
AddAttribute(domElement, AttrKAsm1, spl->GetKasm1());
|
||||
AddAttribute(domElement, AttrKAsm2, spl->GetKasm2());
|
||||
AddAttribute(domElement, AttrKCurve, spl->GetKcurve());
|
||||
|
||||
AddToCalculation(domElement);
|
||||
}
|
||||
|
||||
void VToolSpline::RefreshDataInFile()
|
||||
{
|
||||
VSpline spl = VAbstractTool::data.GetSpline(id);
|
||||
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrPoint1, QString().setNum(spl.GetP1()));
|
||||
domElement.setAttribute(AttrPoint4, QString().setNum(spl.GetP4()));
|
||||
domElement.setAttribute(AttrAngle1, QString().setNum(spl.GetAngle1()));
|
||||
domElement.setAttribute(AttrAngle2, QString().setNum(spl.GetAngle2()));
|
||||
domElement.setAttribute(AttrKAsm1, QString().setNum(spl.GetKasm1()));
|
||||
domElement.setAttribute(AttrKAsm2, QString().setNum(spl.GetKasm2()));
|
||||
domElement.setAttribute(AttrKCurve, QString().setNum(spl.GetKcurve()));
|
||||
domElement.setAttribute(AttrPoint1, spl->GetP1().id());
|
||||
domElement.setAttribute(AttrPoint4, spl->GetP4().id());
|
||||
domElement.setAttribute(AttrAngle1, spl->GetAngle1());
|
||||
domElement.setAttribute(AttrAngle2, spl->GetAngle2());
|
||||
domElement.setAttribute(AttrKAsm1, spl->GetKasm1());
|
||||
domElement.setAttribute(AttrKAsm2, spl->GetKasm2());
|
||||
domElement.setAttribute(AttrKCurve, spl->GetKcurve());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,32 +269,32 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
|
||||
void VToolSpline::RemoveReferens()
|
||||
{
|
||||
VSpline spl = VAbstractTool::data.GetSpline(id);
|
||||
doc->DecrementReferens(spl.GetP1());
|
||||
doc->DecrementReferens(spl.GetP4());
|
||||
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
||||
doc->DecrementReferens(spl->GetP1().id());
|
||||
doc->DecrementReferens(spl->GetP4().id());
|
||||
}
|
||||
|
||||
void VToolSpline::RefreshGeometry()
|
||||
{
|
||||
this->setPen(QPen(currentColor, widthHairLine/factor));
|
||||
VSpline spl = VAbstractTool::data.GetSpline(id);
|
||||
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
||||
QPainterPath path;
|
||||
path.addPath(spl.GetPath());
|
||||
path.addPath(spl->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
this->setPath(path);
|
||||
QPointF splinePoint = VAbstractTool::data.GetPoint(spl.GetP1()).toQPointF();
|
||||
QPointF controlPoint = spl.GetP2();
|
||||
QPointF splinePoint = VAbstractTool::data.GeometricObject<const VPointF *>(spl->GetP1().id())->toQPointF();
|
||||
QPointF controlPoint = spl->GetP2();
|
||||
emit RefreshLine(1, SplinePoint::FirstPoint, controlPoint, splinePoint);
|
||||
splinePoint = VAbstractTool::data.GetPoint(spl.GetP4()).toQPointF();
|
||||
controlPoint = spl.GetP3();
|
||||
splinePoint = VAbstractTool::data.GeometricObject<const VPointF *>(spl->GetP4().id())->toQPointF();
|
||||
controlPoint = spl->GetP3();
|
||||
emit RefreshLine(1, SplinePoint::LastPoint, controlPoint, splinePoint);
|
||||
|
||||
disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
controlPoints[0]->setPos(spl.GetP2());
|
||||
controlPoints[1]->setPos(spl.GetP3());
|
||||
controlPoints[0]->setPos(spl->GetP2());
|
||||
controlPoints[1]->setPos(spl->GetP3());
|
||||
connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSpline::ControlPointChangePosition);
|
||||
connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
|
|
|
@ -37,28 +37,27 @@ VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
|
|||
controlPoints(QVector<VControlPointSpline *>())
|
||||
{
|
||||
ignoreFullUpdate = true;
|
||||
VSplinePath splPath = data->GetSplinePath(id);
|
||||
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(id);
|
||||
QPainterPath path;
|
||||
path.addPath(splPath.GetPath());
|
||||
path.addPath(splPath->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
this->setPath(path);
|
||||
this->setPen(QPen(Qt::black, widthHairLine/factor));
|
||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
for (qint32 i = 1; i<=splPath.Count(); ++i)
|
||||
for (qint32 i = 1; i<=splPath->Count(); ++i)
|
||||
{
|
||||
VSpline spl = splPath.GetSpline(i);
|
||||
VSpline spl = splPath->GetSpline(i);
|
||||
VControlPointSpline *controlPoint = new VControlPointSpline(i, SplinePoint::FirstPoint, spl.GetP2(),
|
||||
spl.GetPointP1().toQPointF(), this);
|
||||
spl.GetP1().toQPointF(), this);
|
||||
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
|
||||
connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint);
|
||||
controlPoints.append(controlPoint);
|
||||
|
||||
controlPoint = new VControlPointSpline(i, SplinePoint::LastPoint, spl.GetP3(),
|
||||
spl.GetPointP4().toQPointF(), this);
|
||||
controlPoint = new VControlPointSpline(i, SplinePoint::LastPoint, spl.GetP3(), spl.GetP4().toQPointF(), this);
|
||||
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
|
||||
|
@ -78,35 +77,36 @@ VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
|
|||
void VToolSplinePath::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogSplinePath.isNull() == false);
|
||||
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
|
||||
dialogSplinePath->SetPath(splPath);
|
||||
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
|
||||
dialogSplinePath->SetPath(*splPath);
|
||||
}
|
||||
|
||||
void VToolSplinePath::Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene,
|
||||
VDomDocument *doc, VContainer *data)
|
||||
{
|
||||
VSplinePath path = dialog->GetPath();
|
||||
for (qint32 i = 0; i < path.CountPoint(); ++i)
|
||||
VSplinePath *path = new VSplinePath(dialog->GetPath());
|
||||
Q_ASSERT(path);
|
||||
for (qint32 i = 0; i < path->CountPoint(); ++i)
|
||||
{
|
||||
doc->IncrementReferens(path[i].P());
|
||||
doc->IncrementReferens((*path)[i].P().id());
|
||||
}
|
||||
Create(0, path, scene, doc, data, Document::FullParse, Tool::FromGui);
|
||||
}
|
||||
|
||||
void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene,
|
||||
void VToolSplinePath::Create(const qint64 _id, VSplinePath *path, VMainGraphicsScene *scene,
|
||||
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
|
||||
const Tool::Sources &typeCreation)
|
||||
{
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddSplinePath(path);
|
||||
data->AddLengthSpline(path.name(), toMM(path.GetLength()));
|
||||
id = data->AddGObject(path);
|
||||
data->AddLengthSpline(path->name(), toMM(path->GetLength()));
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateSplinePath(id, path);
|
||||
data->AddLengthSpline(path.name(), toMM(path.GetLength()));
|
||||
data->UpdateGObject(id, path);
|
||||
data->AddLengthSpline(path->name(), toMM(path->GetLength()));
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
|
@ -149,8 +149,8 @@ void VToolSplinePath::FullUpdateFromGui(int result)
|
|||
connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
|
||||
spl = VSpline (VAbstractTool::data.DataPoints(), spl.GetP1(), controlPoints[j-2]->pos(),
|
||||
controlPoints[j-1]->pos(), spl.GetP4(), splPath.getKCurve());
|
||||
spl = VSpline (spl.GetP1(), controlPoints[j-2]->pos(), controlPoints[j-1]->pos(), spl.GetP4(),
|
||||
splPath.getKCurve());
|
||||
CorectControlPoints(spl, splPath, i);
|
||||
CorectControlPoints(spl, splPath, i);
|
||||
|
||||
|
@ -170,15 +170,15 @@ void VToolSplinePath::FullUpdateFromGui(int result)
|
|||
void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePoint::Position &position,
|
||||
const QPointF &pos)
|
||||
{
|
||||
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
|
||||
VSpline spl = splPath.GetSpline(indexSpline);
|
||||
VSplinePath splPath = *VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
|
||||
VSpline spl;
|
||||
if (position == SplinePoint::FirstPoint)
|
||||
{
|
||||
spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve());
|
||||
spl = VSpline(spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve());
|
||||
}
|
||||
else
|
||||
{
|
||||
spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve());
|
||||
spl = VSpline(spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve());
|
||||
}
|
||||
|
||||
CorectControlPoints(spl, splPath, indexSpline);
|
||||
|
@ -214,10 +214,10 @@ void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path)
|
|||
if (domElement.isNull() == false)
|
||||
{
|
||||
VSplinePoint p = path[i];
|
||||
domElement.setAttribute(AttrPSpline, QString().setNum(p.P()));
|
||||
domElement.setAttribute(AttrKAsm1, QString().setNum(p.KAsm1()));
|
||||
domElement.setAttribute(AttrKAsm2, QString().setNum(p.KAsm2()));
|
||||
domElement.setAttribute(AttrAngle, QString().setNum(p.Angle2()));
|
||||
domElement.setAttribute(AttrPSpline, p.P().id());
|
||||
domElement.setAttribute(AttrKAsm1, p.KAsm1());
|
||||
domElement.setAttribute(AttrKAsm2, p.KAsm2());
|
||||
domElement.setAttribute(AttrAngle, p.Angle2());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolSplinePath::AddToFile()
|
||||
{
|
||||
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
|
||||
VSplinePath splPath = *VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
|
@ -277,7 +277,7 @@ void VToolSplinePath::AddToFile()
|
|||
|
||||
void VToolSplinePath::RefreshDataInFile()
|
||||
{
|
||||
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
|
||||
VSplinePath splPath = *VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
|
||||
for (qint32 i = 1; i<=splPath.Count(); ++i)
|
||||
{
|
||||
VSpline spl = splPath.GetSpline(i);
|
||||
|
@ -293,8 +293,8 @@ void VToolSplinePath::RefreshDataInFile()
|
|||
connect(controlPoints[j-1], &VControlPointSpline::ControlPointChangePosition, this,
|
||||
&VToolSplinePath::ControlPointChangePosition);
|
||||
|
||||
spl = VSpline (VAbstractTool::data.DataPoints(), spl.GetP1(), controlPoints[j-2]->pos(),
|
||||
controlPoints[j-1]->pos(), spl.GetP4(), splPath.getKCurve());
|
||||
spl = VSpline (spl.GetP1(), controlPoints[j-2]->pos(), controlPoints[j-1]->pos(), spl.GetP4(),
|
||||
splPath.getKCurve());
|
||||
CorectControlPoints(spl, splPath, i);
|
||||
CorectControlPoints(spl, splPath, i);
|
||||
|
||||
|
@ -312,7 +312,7 @@ void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &
|
|||
{
|
||||
QDomElement pathPoint = doc->createElement(AttrPathPoint);
|
||||
|
||||
AddAttribute(pathPoint, AttrPSpline, splPoint.P());
|
||||
AddAttribute(pathPoint, AttrPSpline, splPoint.P().id());
|
||||
AddAttribute(pathPoint, AttrKAsm1, splPoint.KAsm1());
|
||||
AddAttribute(pathPoint, AttrKAsm2, splPoint.KAsm2());
|
||||
AddAttribute(pathPoint, AttrAngle, splPoint.Angle2());
|
||||
|
@ -343,28 +343,28 @@ void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
|
||||
void VToolSplinePath::RemoveReferens()
|
||||
{
|
||||
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
|
||||
VSplinePath splPath = *VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
|
||||
for (qint32 i = 0; i < splPath.Count(); ++i)
|
||||
{
|
||||
doc->DecrementReferens(splPath[i].P());
|
||||
doc->DecrementReferens(splPath[i].P().id());
|
||||
}
|
||||
}
|
||||
|
||||
void VToolSplinePath::RefreshGeometry()
|
||||
{
|
||||
this->setPen(QPen(currentColor, widthHairLine/factor));
|
||||
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
|
||||
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
|
||||
QPainterPath path;
|
||||
path.addPath(splPath.GetPath());
|
||||
path.addPath(splPath->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
this->setPath(path);
|
||||
for (qint32 i = 1; i<=splPath.Count(); ++i)
|
||||
for (qint32 i = 1; i<=splPath->Count(); ++i)
|
||||
{
|
||||
VSpline spl = splPath.GetSpline(i);
|
||||
QPointF splinePoint = spl.GetPointP1().toQPointF();
|
||||
VSpline spl = splPath->GetSpline(i);
|
||||
QPointF splinePoint = spl.GetP1().toQPointF();
|
||||
QPointF controlPoint = spl.GetP2();
|
||||
emit RefreshLine(i, SplinePoint::FirstPoint, controlPoint, splinePoint);
|
||||
splinePoint = spl.GetPointP4().toQPointF();
|
||||
splinePoint = spl.GetP4().toQPointF();
|
||||
controlPoint = spl.GetP3();
|
||||
emit RefreshLine(i, SplinePoint::LastPoint, controlPoint, splinePoint);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
* @param parse
|
||||
* @param typeCreation
|
||||
*/
|
||||
static void Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene,
|
||||
static void Create(const qint64 _id, VSplinePath *path, VMainGraphicsScene *scene,
|
||||
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
|
||||
const Tool::Sources &typeCreation);
|
||||
/**
|
||||
|
|
|
@ -50,12 +50,12 @@ VToolTriangle::VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &
|
|||
void VToolTriangle::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogTriangle.isNull() == false);
|
||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
dialogTriangle->setAxisP1Id(axisP1Id, id);
|
||||
dialogTriangle->setAxisP2Id(axisP2Id, id);
|
||||
dialogTriangle->setFirstPointId(firstPointId, id);
|
||||
dialogTriangle->setSecondPointId(secondPointId, id);
|
||||
dialogTriangle->setPointName(p.name());
|
||||
dialogTriangle->setPointName(p->name());
|
||||
}
|
||||
|
||||
void VToolTriangle::Create(QSharedPointer<DialogTriangle> &dialog, VMainGraphicsScene *scene,
|
||||
|
@ -75,21 +75,21 @@ void VToolTriangle::Create(const qint64 _id, const QString &pointName, const qin
|
|||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VPointF axisP1 = data->GetPoint(axisP1Id);
|
||||
VPointF axisP2 = data->GetPoint(axisP2Id);
|
||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||
const VPointF *axisP1 = data->GeometricObject<const VPointF *>(axisP1Id);
|
||||
const VPointF *axisP2 = data->GeometricObject<const VPointF *>(axisP2Id);
|
||||
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(firstPointId);
|
||||
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
|
||||
|
||||
QPointF point = FindPoint(axisP1.toQPointF(), axisP2.toQPointF(), firstPoint.toQPointF(),
|
||||
secondPoint.toQPointF());
|
||||
QPointF point = FindPoint(axisP1->toQPointF(), axisP2->toQPointF(), firstPoint->toQPointF(),
|
||||
secondPoint->toQPointF());
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
id = data->AddGObject(new VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(point.x(), point.y(), pointName, mx, my));
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
|
@ -163,7 +163,7 @@ void VToolTriangle::FullUpdateFromFile()
|
|||
firstPointId = domElement.attribute(AttrFirstPoint, "").toLongLong();
|
||||
secondPointId = domElement.attribute(AttrSecondPoint, "").toLongLong();
|
||||
}
|
||||
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VToolTriangle::FullUpdateFromGui(int result)
|
||||
|
@ -200,14 +200,14 @@ void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void VToolTriangle::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrName, point.name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrName, point->name());
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddAttribute(domElement, AttrAxisP1, axisP1Id);
|
||||
AddAttribute(domElement, AttrAxisP2, axisP2Id);
|
||||
|
@ -219,16 +219,16 @@ void VToolTriangle::AddToFile()
|
|||
|
||||
void VToolTriangle::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrName, point.name());
|
||||
domElement.setAttribute(AttrMx, toMM(point.mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point.my()));
|
||||
domElement.setAttribute(AttrAxisP1, QString().setNum(axisP1Id));
|
||||
domElement.setAttribute(AttrAxisP2, QString().setNum(axisP2Id));
|
||||
domElement.setAttribute(AttrFirstPoint, QString().setNum(firstPointId));
|
||||
domElement.setAttribute(AttrSecondPoint, QString().setNum(secondPointId));
|
||||
domElement.setAttribute(AttrName, point->name());
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
domElement.setAttribute(AttrAxisP1, axisP1Id);
|
||||
domElement.setAttribute(AttrAxisP2, axisP2Id);
|
||||
domElement.setAttribute(AttrFirstPoint, firstPointId);
|
||||
domElement.setAttribute(AttrSecondPoint, secondPointId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,9 +114,9 @@ void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
|
||||
void VNodeArc::RefreshGeometry()
|
||||
{
|
||||
VArc arc = VAbstractTool::data.GetArc(id);
|
||||
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
|
||||
QPainterPath path;
|
||||
path.addPath(arc.GetPath());
|
||||
path.addPath(arc->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
this->setPath(path);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ VNodePoint::VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 id
|
|||
this->setBrush(QBrush(Qt::NoBrush));
|
||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
this->setAcceptHoverEvents(true);
|
||||
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
AddToFile();
|
||||
|
@ -75,32 +75,32 @@ void VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 i
|
|||
|
||||
void VNodePoint::FullUpdateFromFile()
|
||||
{
|
||||
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
}
|
||||
|
||||
void VNodePoint::AddToFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrIdObject, idNode);
|
||||
AddAttribute(domElement, AttrMx, toMM(point.mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point.my()));
|
||||
AddAttribute(domElement, AttrMx, toMM(point->mx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(point->my()));
|
||||
|
||||
AddToModeling(domElement);
|
||||
}
|
||||
|
||||
void VNodePoint::RefreshDataInFile()
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrIdObject, QString().setNum(idNode));
|
||||
domElement.setAttribute(AttrMx, QString().setNum(toMM(point.mx())));
|
||||
domElement.setAttribute(AttrMy, QString().setNum(toMM(point.my())));
|
||||
domElement.setAttribute(AttrIdObject, idNode);
|
||||
domElement.setAttribute(AttrMx, toMM(point->mx()));
|
||||
domElement.setAttribute(AttrMy, toMM(point->my()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,13 +128,13 @@ void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
|
||||
void VNodePoint::NameChangePosition(const QPointF &pos)
|
||||
{
|
||||
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
|
||||
QPointF p = pos - this->pos();
|
||||
point.setMx(p.x());
|
||||
point.setMy(p.y());
|
||||
point->setMx(p.x());
|
||||
point->setMy(p.y());
|
||||
RefreshLine();
|
||||
UpdateNamePosition(point.mx(), point.my());
|
||||
VAbstractTool::data.UpdatePoint(id, point);
|
||||
UpdateNamePosition(point->mx(), point->my());
|
||||
VAbstractTool::data.UpdateGObject(id, point);
|
||||
}
|
||||
|
||||
void VNodePoint::UpdateNamePosition(qreal mx, qreal my)
|
||||
|
|
|
@ -115,9 +115,9 @@ void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
|
||||
void VNodeSpline::RefreshGeometry()
|
||||
{
|
||||
VSpline spl = VAbstractTool::data.GetSpline(id);
|
||||
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
||||
QPainterPath path;
|
||||
path.addPath(spl.GetPath());
|
||||
path.addPath(spl->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
this->setPath(path);
|
||||
}
|
||||
|
|
|
@ -58,11 +58,11 @@ void VNodeSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id, qin
|
|||
VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeCreation);
|
||||
Q_ASSERT(splPath != 0);
|
||||
doc->AddTool(id, splPath);
|
||||
VSplinePath path = data->GetSplinePath(id);
|
||||
const QVector<VSplinePoint> *points = path.GetPoint();
|
||||
const VSplinePath *path = data->GeometricObject<const VSplinePath *>(id);
|
||||
const QVector<VSplinePoint> *points = path->GetPoint();
|
||||
for (qint32 i = 0; i<points->size(); ++i)
|
||||
{
|
||||
doc->IncrementReferens(points->at(i).P());
|
||||
doc->IncrementReferens(points->at(i).P().id());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -119,9 +119,9 @@ void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
|
||||
void VNodeSplinePath::RefreshGeometry()
|
||||
{
|
||||
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
|
||||
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
|
||||
QPainterPath path;
|
||||
path.addPath(splPath.GetPath());
|
||||
path.addPath(splPath->GetPath());
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
this->setPath(path);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ HEADERS += \
|
|||
src/tools/nodeDetails/vabstractnode.h \
|
||||
src/tools/nodeDetails/nodedetails.h \
|
||||
src/tools/drawTools/vtoolcutspline.h \
|
||||
src/tools/drawTools/vtoolcutsplinepath.h
|
||||
src/tools/drawTools/vtoolcutsplinepath.h \
|
||||
src/tools/vtooluniondetails.h
|
||||
|
||||
SOURCES += \
|
||||
src/tools/vtooldetail.cpp \
|
||||
|
@ -59,4 +60,5 @@ SOURCES += \
|
|||
src/tools/nodeDetails/vnodearc.cpp \
|
||||
src/tools/nodeDetails/vabstractnode.cpp \
|
||||
src/tools/drawTools/vtoolcutspline.cpp \
|
||||
src/tools/drawTools/vtoolcutsplinepath.cpp
|
||||
src/tools/drawTools/vtoolcutsplinepath.cpp \
|
||||
src/tools/vtooluniondetails.cpp
|
||||
|
|
|
@ -44,7 +44,7 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
|
|||
:VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialogDetail(QSharedPointer<DialogDetail>()),
|
||||
sceneDetails(scene)
|
||||
{
|
||||
VDetail detail = data->GetDetail(id);
|
||||
VDetail detail = VDetail(*data->GetDetail(id));
|
||||
for (ptrdiff_t i = 0; i< detail.CountNode(); ++i)
|
||||
{
|
||||
switch (detail[i].getTypeTool())
|
||||
|
@ -72,7 +72,7 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
|
|||
RefreshGeometry();
|
||||
this->setPos(detail.getMx(), detail.getMy());
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
if (typeCreation == Tool::FromGui)
|
||||
if (typeCreation == Tool::FromGui || typeCreation == Tool::FromTool)
|
||||
{
|
||||
AddToFile();
|
||||
}
|
||||
|
@ -81,15 +81,16 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
|
|||
void VToolDetail::setDialog()
|
||||
{
|
||||
Q_ASSERT(dialogDetail.isNull() == false);
|
||||
VDetail detail = VAbstractTool::data.GetDetail(id);
|
||||
dialogDetail->setDetails(detail);
|
||||
const VDetail *detail = VAbstractTool::data.GeometricObject<const VDetail *>(id);
|
||||
dialogDetail->setDetails(*detail);
|
||||
}
|
||||
|
||||
void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data)
|
||||
{
|
||||
VDetail detail = dialog->getDetails();
|
||||
VDetail det;
|
||||
VDetail *det = new VDetail();
|
||||
Q_ASSERT(det != 0);
|
||||
for (ptrdiff_t i = 0; i< detail.CountNode(); ++i)
|
||||
{
|
||||
qint64 id = 0;
|
||||
|
@ -97,29 +98,33 @@ void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScen
|
|||
{
|
||||
case (Tool::NodePoint):
|
||||
{
|
||||
VPointF point = data->GetPoint(detail[i].getId());
|
||||
id = data->AddPoint(point);
|
||||
VPointF *point = new VPointF(*data->GeometricObject<const VPointF *>(detail[i].getId()));
|
||||
Q_ASSERT(point != 0);
|
||||
id = data->AddGObject(point);
|
||||
VNodePoint::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui);
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeArc):
|
||||
{
|
||||
VArc arc = data->GetArc(detail[i].getId());
|
||||
id = data->AddArc(arc);
|
||||
VArc *arc = new VArc(*data->GeometricObject<const VArc *>(detail[i].getId()));
|
||||
Q_ASSERT(arc != 0);
|
||||
id = data->AddGObject(arc);
|
||||
VNodeArc::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui);
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeSpline):
|
||||
{
|
||||
VSpline spline = data->GetSpline(detail[i].getId());
|
||||
id = data->AddSpline(spline);
|
||||
VSpline *spline = new VSpline(*data->GeometricObject<const VSpline *>(detail[i].getId()));
|
||||
Q_ASSERT(spline != 0);
|
||||
id = data->AddGObject(spline);
|
||||
VNodeSpline::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui);
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeSplinePath):
|
||||
{
|
||||
VSplinePath splinePath = data->GetSplinePath(detail[i].getId());
|
||||
id = data->AddSplinePath(splinePath);
|
||||
VSplinePath *splinePath = new VSplinePath(*data->GeometricObject<const VSplinePath *>(detail[i].getId()));
|
||||
Q_ASSERT(splinePath != 0);
|
||||
id = data->AddGObject(splinePath);
|
||||
VNodeSplinePath::Create(doc, data, id, detail[i].getId(), Document::FullParse, Tool::FromGui);
|
||||
}
|
||||
break;
|
||||
|
@ -128,17 +133,17 @@ void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScen
|
|||
break;
|
||||
}
|
||||
VNodeDetail node(id, detail[i].getTypeTool(), NodeDetail::Contour);
|
||||
det.append(node);
|
||||
det->append(node);
|
||||
}
|
||||
det.setName(detail.getName());
|
||||
det->setName(detail.getName());
|
||||
Create(0, det, scene, doc, data, Document::FullParse, Tool::FromGui);
|
||||
}
|
||||
|
||||
void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
void VToolDetail::Create(const qint64 _id, VDetail *newDetail, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
if (typeCreation == Tool::FromGui || typeCreation == Tool::FromTool)
|
||||
{
|
||||
id = data->AddDetail(newDetail);
|
||||
}
|
||||
|
@ -161,6 +166,34 @@ void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScen
|
|||
}
|
||||
}
|
||||
|
||||
void VToolDetail::Remove()
|
||||
{
|
||||
//remove form xml file
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
QDomNode element = domElement.parentNode();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
//deincrement referens
|
||||
RemoveReferens();
|
||||
element.removeChild(domElement);
|
||||
//update xml file
|
||||
emit FullUpdateTree();
|
||||
//remove form scene
|
||||
emit RemoveTool(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"parentNode isNull"<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"Can't get element by id = "<<id<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
void VToolDetail::FullUpdateFromFile()
|
||||
{
|
||||
RefreshGeometry();
|
||||
|
@ -191,20 +224,20 @@ void VToolDetail::FullUpdateFromGui(int result)
|
|||
|
||||
void VToolDetail::AddToFile()
|
||||
{
|
||||
VDetail detail = VAbstractTool::data.GetDetail(id);
|
||||
const VDetail *detail = VAbstractTool::data.GetDetail(id);
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrName, detail.getName());
|
||||
AddAttribute(domElement, AttrMx, toMM(detail.getMx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(detail.getMy()));
|
||||
AddAttribute(domElement, AttrSupplement, detail.getSupplement());
|
||||
AddAttribute(domElement, AttrClosed, detail.getClosed());
|
||||
AddAttribute(domElement, AttrWidth, detail.getWidth());
|
||||
AddAttribute(domElement, AttrName, detail->getName());
|
||||
AddAttribute(domElement, AttrMx, toMM(detail->getMx()));
|
||||
AddAttribute(domElement, AttrMy, toMM(detail->getMy()));
|
||||
AddAttribute(domElement, AttrSupplement, detail->getSupplement());
|
||||
AddAttribute(domElement, AttrClosed, detail->getClosed());
|
||||
AddAttribute(domElement, AttrWidth, detail->getWidth());
|
||||
|
||||
for (ptrdiff_t i = 0; i < detail.CountNode(); ++i)
|
||||
for (ptrdiff_t i = 0; i < detail->CountNode(); ++i)
|
||||
{
|
||||
AddNode(domElement, detail[i]);
|
||||
AddNode(domElement, detail->at(i));
|
||||
}
|
||||
|
||||
QDomElement element;
|
||||
|
@ -220,15 +253,15 @@ void VToolDetail::RefreshDataInFile()
|
|||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
VDetail det = VAbstractTool::data.GetDetail(id);
|
||||
domElement.setAttribute(AttrName, det.getName());
|
||||
domElement.setAttribute(AttrSupplement, QString().setNum(det.getSupplement()));
|
||||
domElement.setAttribute(AttrClosed, QString().setNum(det.getClosed()));
|
||||
domElement.setAttribute(AttrWidth, QString().setNum(det.getWidth()));
|
||||
const VDetail *det = VAbstractTool::data.GetDetail(id);
|
||||
domElement.setAttribute(AttrName, det->getName());
|
||||
domElement.setAttribute(AttrSupplement, QString().setNum(det->getSupplement()));
|
||||
domElement.setAttribute(AttrClosed, QString().setNum(det->getClosed()));
|
||||
domElement.setAttribute(AttrWidth, QString().setNum(det->getWidth()));
|
||||
RemoveAllChild(domElement);
|
||||
for (ptrdiff_t i = 0; i < det.CountNode(); ++i)
|
||||
for (ptrdiff_t i = 0; i < det->CountNode(); ++i)
|
||||
{
|
||||
AddNode(domElement, det[i]);
|
||||
AddNode(domElement, det->at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -286,43 +319,20 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
}
|
||||
if (selectedAction == actionRemove)
|
||||
{
|
||||
//remove form xml file
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
QDomNode element = domElement.parentNode();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
//deincrement referens
|
||||
RemoveReferens();
|
||||
element.removeChild(domElement);
|
||||
//update xml file
|
||||
emit FullUpdateTree();
|
||||
//remove form scene
|
||||
emit RemoveTool(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"parentNode isNull"<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"Can't get element by id = "<<id<<Q_FUNC_INFO;
|
||||
}
|
||||
Remove();
|
||||
}
|
||||
}
|
||||
|
||||
void VToolDetail::RemoveReferens()
|
||||
{
|
||||
VDetail detail = VAbstractTool::data.GetDetail(id);
|
||||
for (ptrdiff_t i = 0; i< detail.CountNode(); ++i)
|
||||
const VDetail *detail = VAbstractTool::data.GetDetail(id);
|
||||
for (ptrdiff_t i = 0; i< detail->CountNode(); ++i)
|
||||
{
|
||||
doc->DecrementReferens(detail[i].getId());
|
||||
doc->DecrementReferens(detail->at(i).getId());
|
||||
}
|
||||
}
|
||||
|
||||
void VToolDetail::AddNode(QDomElement &domElement, VNodeDetail &node)
|
||||
void VToolDetail::AddNode(QDomElement &domElement, const VNodeDetail &node)
|
||||
{
|
||||
QDomElement nod = doc->createElement(TagNode);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
* @param parse
|
||||
* @param typeCreation
|
||||
*/
|
||||
static void Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScene *scene,
|
||||
static void Create(const qint64 _id, VDetail *newDetail, VMainGraphicsScene *scene,
|
||||
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
|
||||
const Tool::Sources &typeCreation);
|
||||
template <typename T>
|
||||
|
@ -90,8 +90,8 @@ public:
|
|||
tool->setParentItem(this);
|
||||
connect(tool, &T::ChoosedTool, sceneDetails, &VMainGraphicsScene::ChoosedItem);
|
||||
VNodeDetail node(id, typeTool, Draw::Modeling, NodeDetail::Modeling);
|
||||
VDetail det = VAbstractTool::data.GetDetail(this->id);
|
||||
det.append(node);
|
||||
VDetail *det = VAbstractTool::data.GetDetail(this->id);
|
||||
det->append(node);
|
||||
VAbstractTool::data.UpdateDetail(this->id, det);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(this->id));
|
||||
if (domElement.isElement())
|
||||
|
@ -135,6 +135,7 @@ public:
|
|||
* @brief NodeTypeModeling
|
||||
*/
|
||||
static const QString NodeTypeModeling;
|
||||
void Remove();
|
||||
public slots:
|
||||
/**
|
||||
* @brief FullUpdateFromFile
|
||||
|
@ -200,7 +201,7 @@ private:
|
|||
* @param domElement
|
||||
* @param node
|
||||
*/
|
||||
void AddNode(QDomElement &domElement, VNodeDetail &node);
|
||||
void AddNode(QDomElement &domElement, const VNodeDetail &node);
|
||||
template <typename Tool>
|
||||
/**
|
||||
* @brief InitTool
|
||||
|
|
721
src/tools/vtooluniondetails.cpp
Normal file
721
src/tools/vtooluniondetails.cpp
Normal file
|
@ -0,0 +1,721 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtooluniondetails.cpp
|
||||
** @author Roman Telezhinsky <dismine@gmail.com>
|
||||
** @date 26 12, 2013
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2013 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vtooluniondetails.h"
|
||||
#include "nodeDetails/nodedetails.h"
|
||||
#include "vtooldetail.h"
|
||||
|
||||
const QString VToolUnionDetails::TagName = QStringLiteral("tools");
|
||||
const QString VToolUnionDetails::ToolType = QStringLiteral("unionDetails");
|
||||
const QString VToolUnionDetails::TagDetail = QStringLiteral("det");
|
||||
const QString VToolUnionDetails::TagNode = QStringLiteral("node");
|
||||
const QString VToolUnionDetails::AttrD1P1 = QStringLiteral("d1P1");
|
||||
const QString VToolUnionDetails::AttrD1P2 = QStringLiteral("d1P2");
|
||||
const QString VToolUnionDetails::AttrD2P1 = QStringLiteral("d2P1");
|
||||
const QString VToolUnionDetails::AttrD2P2 = QStringLiteral("d2P2");
|
||||
const QString VToolUnionDetails::AttrIdObject = QStringLiteral("idObject");
|
||||
const QString VToolUnionDetails::AttrNodeType = QStringLiteral("nodeType");
|
||||
const QString VToolUnionDetails::NodeTypeContour = QStringLiteral("Contour");
|
||||
const QString VToolUnionDetails::NodeTypeModeling = QStringLiteral("Modeling");
|
||||
|
||||
VToolUnionDetails::VToolUnionDetails(VDomDocument *doc, VContainer *data, const qint64 &id, const VDetail &d1,
|
||||
const VDetail &d2, const qint64 &d1P1, const qint64 &d1P2, const qint64 &d2P1,
|
||||
const qint64 &d2P2, const Tool::Sources &typeCreation)
|
||||
:VAbstractTool(doc, data, id), d1(d1), d2(d2), d1P1(d1P1), d1P2(d1P2), d2P1(d2P1), d2P2(d2P2)
|
||||
{
|
||||
CorectPoints(this->d1, this->d1P1, this->d1P2);
|
||||
CorectPoints(this->d2, this->d2P1, this->d2P2);
|
||||
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
AddToFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
RefreshDataInFile();
|
||||
}
|
||||
}
|
||||
|
||||
void VToolUnionDetails::CorectPoints(const VDetail &detail, qint64 &p1, qint64 &p2)
|
||||
{
|
||||
if(p1 == p2)
|
||||
{
|
||||
qWarning()<<"Union points equal.";
|
||||
return;
|
||||
}
|
||||
bool p1flag = false;
|
||||
bool p2flag = false;
|
||||
for (ptrdiff_t i = 0; i< detail.CountNode(); ++i)
|
||||
{
|
||||
if(detail.at(i).getTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
if(p1 == detail.at(i).getId())
|
||||
{
|
||||
p1flag = true;
|
||||
}
|
||||
if(p2 == detail.at(i).getId())
|
||||
{
|
||||
p2flag = true;
|
||||
}
|
||||
if(p1flag == true && p2flag == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(p2flag == true && p1flag == false)
|
||||
{
|
||||
qint64 p = p1;
|
||||
p1 = p2;
|
||||
p2 = p;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VToolUnionDetails::AddToNewDetail(VContainer *data, VDetail *newDetail, const VDetail &det, const ptrdiff_t &a,
|
||||
const ptrdiff_t &b, const qreal &dx, const qreal &dy, const qint64 &pRotate,
|
||||
const qreal &angle) const
|
||||
{
|
||||
for (ptrdiff_t i = a; i <= b; ++i)
|
||||
{
|
||||
qint64 id = 0;
|
||||
switch (det.at(i).getTypeTool())
|
||||
{
|
||||
case (Tool::NodePoint):
|
||||
{
|
||||
if( qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && (pRotate == 0))
|
||||
{
|
||||
id = det.at(i).getId();
|
||||
}
|
||||
else
|
||||
{
|
||||
VPointF *point = new VPointF(*data->GeometricObject<const VPointF *>(det.at(i).getId()));
|
||||
Q_ASSERT(point != 0);
|
||||
BiasRotatePoint(point, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(),
|
||||
angle);
|
||||
id = data->AddGObject(point);
|
||||
VNodePoint::Create(doc, data, id, det.at(i).getId(), Document::FullParse, Tool::FromGui );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeArc):
|
||||
{
|
||||
if(qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0)
|
||||
{
|
||||
id = det.at(i).getId();
|
||||
}
|
||||
else
|
||||
{
|
||||
const VArc *arc = data->GeometricObject<const VArc *>(det.at(i).getId());
|
||||
VPointF p1 = VPointF(arc->GetP1().x(), arc->GetP1().y(), "A", 0, 0);
|
||||
BiasRotatePoint(&p1, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
VPointF p2 = VPointF(arc->GetP2().x(), arc->GetP2().y(), "A", 0, 0);
|
||||
BiasRotatePoint(&p2, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
VPointF *center = new VPointF(arc->GetCenter());
|
||||
Q_ASSERT(center != 0);
|
||||
BiasRotatePoint(center, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(),
|
||||
angle);
|
||||
|
||||
QLineF l1(center->toQPointF(), p1.toQPointF());
|
||||
QLineF l2(center->toQPointF(), p2.toQPointF());
|
||||
qint64 idCenter = data->AddGObject(center);
|
||||
Q_UNUSED(idCenter);
|
||||
VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(),
|
||||
l1.angle(), QString().setNum(l1.angle()), l2.angle(),
|
||||
QString().setNum(l2.angle()));
|
||||
Q_ASSERT(arc1 != 0);
|
||||
id = data->AddGObject(arc1);
|
||||
VNodeArc::Create(doc, data, id, det.at(i).getId(), Document::FullParse, Tool::FromGui);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeSpline):
|
||||
{
|
||||
if(qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0)
|
||||
{
|
||||
id = det.at(i).getId();
|
||||
}
|
||||
else
|
||||
{
|
||||
const VSpline *spline = data->GeometricObject<const VSpline *>(det.at(i).getId());
|
||||
|
||||
VPointF *p1 = new VPointF(spline->GetP1());
|
||||
Q_ASSERT(p1 != 0);
|
||||
BiasRotatePoint(p1, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
qint64 idP1 = data->AddGObject(p1);
|
||||
|
||||
VPointF p2 = VPointF(spline->GetP2().x(), spline->GetP2().y(), "A", 0, 0);
|
||||
BiasRotatePoint(&p2, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
VPointF p3 = VPointF(spline->GetP3().x(), spline->GetP3().y(), "A", 0, 0);
|
||||
BiasRotatePoint(&p3, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
VPointF *p4 = new VPointF(spline->GetP4());
|
||||
Q_ASSERT(p4 != 0);
|
||||
BiasRotatePoint(p4, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
qint64 idP4 = data->AddGObject(p4);
|
||||
|
||||
VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve());
|
||||
id = data->AddGObject(spl);
|
||||
VNodeSpline::Create(doc, data, id, det.at(i).getId(), Document::FullParse, Tool::FromGui);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeSplinePath):
|
||||
{
|
||||
if(qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0)
|
||||
{
|
||||
id = det.at(i).getId();
|
||||
}
|
||||
else
|
||||
{
|
||||
VSplinePath *path = new VSplinePath();
|
||||
Q_ASSERT(path != 0);
|
||||
const VSplinePath *splinePath = data->GeometricObject<const VSplinePath *>(det.at(i).getId());
|
||||
for (qint32 i = 1; i <= splinePath->Count(); ++i)
|
||||
{
|
||||
VSpline spline(splinePath->at(i-1).P(), splinePath->at(i).P(),
|
||||
splinePath->at(i-1).Angle2(), splinePath->at(i).Angle1(), splinePath->at(i-1).KAsm2(),
|
||||
splinePath->at(i).KAsm1(), splinePath->getKCurve());
|
||||
|
||||
VPointF *p1 = new VPointF(spline.GetP1());
|
||||
Q_ASSERT(p1 != 0);
|
||||
BiasRotatePoint(p1, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
qint64 idP1 = data->AddGObject(p1);
|
||||
|
||||
VPointF p2 = VPointF(spline.GetP2());
|
||||
BiasRotatePoint(&p2, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
VPointF p3 = VPointF(spline.GetP3());
|
||||
BiasRotatePoint(&p3, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
VPointF *p4 = new VPointF(spline.GetP4());
|
||||
Q_ASSERT(p4 != 0);
|
||||
BiasRotatePoint(p4, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
qint64 idP4 = data->AddGObject(p4);
|
||||
|
||||
VSpline spl = VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline.GetKcurve());
|
||||
if(i==1)
|
||||
{
|
||||
path->append(VSplinePoint(*p1, splinePath->at(i-1).KAsm1(), spl.GetAngle1(),
|
||||
splinePath->at(i-1).KAsm1()));
|
||||
}
|
||||
path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle1(),
|
||||
splinePath->at(i).KAsm1()));
|
||||
}
|
||||
id = data->AddGObject(path);
|
||||
VNodeSplinePath::Create(doc, data, id, det.at(i).getId(), Document::FullParse, Tool::FromGui);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
|
||||
break;
|
||||
}
|
||||
newDetail->append(VNodeDetail(id, det.at(i).getTypeTool(), NodeDetail::Contour));
|
||||
}
|
||||
}
|
||||
|
||||
void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, const VDetail &det, const ptrdiff_t &a,
|
||||
const ptrdiff_t &b, const qreal &dx, const qreal &dy, const qint64 &pRotate,
|
||||
const qreal &angle) const
|
||||
{
|
||||
qint64 idCount = 0;
|
||||
for (ptrdiff_t i = a; i <= b; ++i)
|
||||
{
|
||||
switch (det.at(i).getTypeTool())
|
||||
{
|
||||
case (Tool::NodePoint):
|
||||
{
|
||||
if(qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0)
|
||||
{
|
||||
++idCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
VPointF *point = new VPointF(*data->GeometricObject<const VPointF *>(det.at(i).getId()));
|
||||
Q_ASSERT(point != 0);
|
||||
BiasRotatePoint(point, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
++idCount;
|
||||
data->UpdateGObject(idDetail+idCount, point);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeArc):
|
||||
{
|
||||
if(qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0)
|
||||
{
|
||||
++idCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
const VArc *arc = data->GeometricObject<const VArc *>(det.at(i).getId());
|
||||
VPointF p1 = VPointF(arc->GetP1());
|
||||
BiasRotatePoint(&p1, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
VPointF p2 = VPointF(arc->GetP2());
|
||||
BiasRotatePoint(&p2, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
VPointF *center = new VPointF(arc->GetCenter());
|
||||
Q_ASSERT(center != 0);
|
||||
BiasRotatePoint(center, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
QLineF l1(center->toQPointF(), p1.toQPointF());
|
||||
QLineF l2(center->toQPointF(), p2.toQPointF());
|
||||
qint64 idCenter = data->AddGObject(center);
|
||||
VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(), l1.angle(),
|
||||
QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle()));
|
||||
Q_ASSERT(arc1);
|
||||
++idCount;
|
||||
data->UpdateGObject(idDetail+idCount, arc1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeSpline):
|
||||
{
|
||||
if(qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0)
|
||||
{
|
||||
++idCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
const VSpline *spline = data->GeometricObject<const VSpline *>(det.at(i).getId());
|
||||
|
||||
VPointF *p1 = new VPointF(spline->GetP1());
|
||||
Q_ASSERT(p1 != 0);
|
||||
BiasRotatePoint(p1, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
qint64 idP1 = data->AddGObject(p1);
|
||||
|
||||
VPointF p2 = VPointF(spline->GetP2());
|
||||
BiasRotatePoint(&p2, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
VPointF p3 = VPointF(spline->GetP3());
|
||||
BiasRotatePoint(&p3, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
VPointF *p4 = new VPointF(spline->GetP4());
|
||||
Q_ASSERT(p4 != 0);
|
||||
BiasRotatePoint(p4, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
qint64 idP4 = data->AddGObject(p4);
|
||||
|
||||
VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve());
|
||||
Q_ASSERT(spl != 0);
|
||||
++idCount;
|
||||
data->UpdateGObject(idDetail+idCount, spl);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeSplinePath):
|
||||
{
|
||||
if(qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0)
|
||||
{
|
||||
++idCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
VSplinePath *path = new VSplinePath();
|
||||
Q_ASSERT(path != 0);
|
||||
const VSplinePath *splinePath = data->GeometricObject<const VSplinePath *>(det.at(i).getId());
|
||||
for (qint32 i = 1; i <= splinePath->Count(); ++i)
|
||||
{
|
||||
VSpline spline(splinePath->at(i-1).P(), splinePath->at(i).P(),
|
||||
splinePath->at(i-1).Angle2(), splinePath->at(i).Angle1(), splinePath->at(i-1).KAsm2(),
|
||||
splinePath->at(i).KAsm1(), splinePath->getKCurve());
|
||||
|
||||
VPointF *p1 = new VPointF(spline.GetP1());
|
||||
Q_ASSERT(p1 != 0);
|
||||
BiasRotatePoint(p1, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
qint64 idP1 = data->AddGObject(p1);
|
||||
|
||||
VPointF p2 = VPointF(spline.GetP2());
|
||||
BiasRotatePoint(&p2, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
VPointF p3 = VPointF(spline.GetP3());
|
||||
BiasRotatePoint(&p3, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
|
||||
VPointF *p4 = new VPointF(spline.GetP4());
|
||||
Q_ASSERT(p4 != 0);
|
||||
BiasRotatePoint(p4, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(), angle);
|
||||
qint64 idP4 = data->AddGObject(p4);
|
||||
|
||||
VSpline spl = VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline.GetKcurve());
|
||||
if(i==1)
|
||||
{
|
||||
path->append(VSplinePoint(*p1, splinePath->at(i-1).KAsm1(), spl.GetAngle1(),
|
||||
splinePath->at(i-1).KAsm1()));
|
||||
}
|
||||
path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle1(),
|
||||
splinePath->at(i).KAsm1()));
|
||||
}
|
||||
++idCount;
|
||||
data->UpdateGObject(idDetail+idCount, path);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VToolUnionDetails::BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate,
|
||||
const qreal angle) const
|
||||
{
|
||||
point->setX(point->x()+dx);
|
||||
point->setY(point->y()+dy);
|
||||
QLineF l(pRotate, point->toQPointF());
|
||||
l.setAngle(angle);
|
||||
point->setX(l.p2().x());
|
||||
point->setY(l.p2().y());
|
||||
}
|
||||
|
||||
void VToolUnionDetails::Create(QSharedPointer<DialogUnionDetails> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data)
|
||||
{
|
||||
VDetail d1 = VDetail(*data->GetDetail(dialog->getD1()));
|
||||
VDetail d2 = VDetail(*data->GetDetail(dialog->getD2()));
|
||||
qint64 d1P1 = dialog->getD1P1();
|
||||
qint64 d1P2 = dialog->getD1P2();
|
||||
qint64 d2P1 = dialog->getD2P1();
|
||||
qint64 d2P2 = dialog->getD2P2();
|
||||
Create(0, d1, d2, dialog->getD1(), dialog->getD2(), d1P1, d1P2, d2P1, d2P2, scene, doc, data, Document::FullParse,
|
||||
Tool::FromGui);
|
||||
}
|
||||
|
||||
void VToolUnionDetails::Create(const qint64 _id, const VDetail &d1, const VDetail &d2, const qint64 &d1id,
|
||||
const qint64 &d2id, const qint64 &d1P1, const qint64 &d1P2, const qint64 &d2P1,
|
||||
const qint64 &d2P2, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, const Tool::Sources &typeCreation)
|
||||
{
|
||||
VToolUnionDetails *unionDetails = 0;
|
||||
qint64 id = _id;
|
||||
if (typeCreation == Tool::FromGui)
|
||||
{
|
||||
id = data->getNextId();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
}
|
||||
}
|
||||
if (parse == Document::FullParse)
|
||||
{
|
||||
unionDetails = new VToolUnionDetails(doc, data, id, d1, d2, d1P1, d1P2, d2P1, d2P2, typeCreation);
|
||||
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
||||
tools->insert(id, unionDetails);
|
||||
for (ptrdiff_t i = 0; i < d1.CountNode(); ++i)
|
||||
{
|
||||
doc->IncrementReferens(d1.at(i).getId());
|
||||
}
|
||||
for (ptrdiff_t i = 0; i < d2.CountNode(); ++i)
|
||||
{
|
||||
doc->IncrementReferens(d2.at(i).getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(typeCreation == Tool::FromGui)
|
||||
{
|
||||
//Update corected points
|
||||
qint64 d1P1 = unionDetails->getD1P1();
|
||||
qint64 d1P2 = unionDetails->getD1P2();
|
||||
qint64 d2P1 = unionDetails->getD2P1();
|
||||
qint64 d2P2 = unionDetails->getD2P2();
|
||||
|
||||
VDetail *newDetail = new VDetail();
|
||||
Q_ASSERT(newDetail != 0);
|
||||
unionDetails->AddToNewDetail(data, newDetail, d1, d1.indexOfNode(d1P1), d1.indexOfNode(d1P2));
|
||||
|
||||
const VNodeDetail det1p2 = d1.at(d1.indexOfNode(d1P2));
|
||||
const VPointF *point2 = data->GeometricObject<const VPointF *>(det1p2.getId());
|
||||
const VNodeDetail det2p1 = d2.at(d2.indexOfNode(d2P1));
|
||||
const VPointF *point1 = data->GeometricObject<const VPointF *>(det2p1.getId());
|
||||
qreal dx = point2->x() - point1->x();
|
||||
qreal dy = point2->y() - point1->y();
|
||||
const VNodeDetail det1p1 = d1.at(d1.indexOfNode(d1P1));
|
||||
const VPointF *point3 = data->GeometricObject<const VPointF *>(det1p1.getId());
|
||||
const VNodeDetail det2p2 = d1.at(d1.indexOfNode(d2P2));
|
||||
const VPointF *point4 = data->GeometricObject<const VPointF *>(det2p2.getId());
|
||||
QLineF l1(point3->toQPointF(), point2->toQPointF());
|
||||
QLineF l2(point4->toQPointF(), point1->toQPointF());
|
||||
qreal angle = l2.angle() + l2.angleTo(l1);
|
||||
|
||||
unionDetails->AddToNewDetail(data, newDetail, d2, d2.indexOfNode(d2P1)+1, d2.indexOfNode(d2P2)-1, dx, dy,
|
||||
d1P2, angle);
|
||||
|
||||
newDetail->setName("Detail");
|
||||
VToolDetail::Create(0, newDetail, scene, doc, data, parse, Tool::FromTool);
|
||||
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(d1id));
|
||||
toolDet->Remove();
|
||||
toolDet = qobject_cast<VToolDetail*>(tools->value(d2id));
|
||||
toolDet->Remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
unionDetails = qobject_cast<VToolUnionDetails *>(doc->getTool(id));
|
||||
|
||||
unionDetails->UpdatePoints(id, data, d1, d1.indexOfNode(d1P1), d1.indexOfNode(d1P2));
|
||||
|
||||
VNodeDetail det1p2 = d1.at(d1.indexOfNode(d1P2));
|
||||
const VPointF *point2 = data->GeometricObject<const VPointF *>(det1p2.getId());
|
||||
VNodeDetail det2p1 = d2.at(d2.indexOfNode(d2P1));
|
||||
const VPointF *point1 = data->GeometricObject<const VPointF *>(det2p1.getId());
|
||||
qreal dx = point2->x() - point1->x();
|
||||
qreal dy = point2->y() - point1->y();
|
||||
const VNodeDetail det1p1 = d1.at(d1.indexOfNode(d1P1));
|
||||
const VPointF *point3 = data->GeometricObject<const VPointF *>(det1p1.getId());
|
||||
const VNodeDetail det2p2 = d1.at(d1.indexOfNode(d2P2));
|
||||
const VPointF *point4 = data->GeometricObject<const VPointF *>(det2p2.getId());
|
||||
QLineF l1(point3->toQPointF(), point2->toQPointF());
|
||||
QLineF l2(point4->toQPointF(), point1->toQPointF());
|
||||
qreal angle = l2.angle() + l2.angleTo(l1);
|
||||
|
||||
unionDetails->UpdatePoints(id, data, d2, d2.indexOfNode(d2P1)+1, d2.indexOfNode(d2P2)-1, dx, dy,
|
||||
d1P2, angle);
|
||||
}
|
||||
}
|
||||
|
||||
QVector<VDetail> VToolUnionDetails::GetDetailFromFile(VDomDocument *doc, const QDomElement &domElement)
|
||||
{
|
||||
QVector<VDetail> vector;
|
||||
QDomNodeList detailList = domElement.childNodes();
|
||||
qint32 num = detailList.size();
|
||||
for (qint32 i = 0; i < num; ++i)
|
||||
{
|
||||
QDomElement element = detailList.at(i).toElement();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
if (element.tagName() == VToolUnionDetails::TagDetail)
|
||||
{
|
||||
QDomNodeList nodeList = domElement.childNodes();
|
||||
qint32 num = nodeList.size();
|
||||
for (qint32 j = 0; j < num; ++j)
|
||||
{
|
||||
QDomElement element = nodeList.at(j).toElement();
|
||||
if (element.isNull() == false)
|
||||
{
|
||||
if (element.tagName() == VToolUnionDetails::TagNode)
|
||||
{
|
||||
qint64 id = doc->GetParametrLongLong(element, VToolDetail::AttrIdObject, "0");
|
||||
qreal mx = toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMx, "0.0"));
|
||||
qreal my = toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMy, "0.0"));
|
||||
Tool::Tools tool;
|
||||
NodeDetail::NodeDetails nodeType = NodeDetail::Contour;
|
||||
QString t = doc->GetParametrString(element, "type", "NodePoint");
|
||||
if (t == "NodePoint")
|
||||
{
|
||||
tool = Tool::NodePoint;
|
||||
}
|
||||
else if (t == "NodeArc")
|
||||
{
|
||||
tool = Tool::NodeArc;
|
||||
}
|
||||
else if (t == "NodeSpline")
|
||||
{
|
||||
tool = Tool::NodeSpline;
|
||||
}
|
||||
else if (t == "NodeSplinePath")
|
||||
{
|
||||
tool = Tool::NodeSplinePath;
|
||||
}
|
||||
vector[i].append(VNodeDetail(id, tool, nodeType, mx, my));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
|
||||
void VToolUnionDetails::AddToFile()
|
||||
{
|
||||
QDomElement domElement = doc->createElement(TagName);
|
||||
|
||||
AddAttribute(domElement, AttrId, id);
|
||||
AddAttribute(domElement, AttrType, ToolType);
|
||||
AddAttribute(domElement, AttrD1P1, d1P1);
|
||||
AddAttribute(domElement, AttrD1P2, d1P2);
|
||||
AddAttribute(domElement, AttrD2P1, d2P1);
|
||||
AddAttribute(domElement, AttrD2P2, d2P2);
|
||||
|
||||
AddDetail(domElement, d1);
|
||||
AddDetail(domElement, d2);
|
||||
|
||||
AddToModeling(domElement);
|
||||
}
|
||||
|
||||
void VToolUnionDetails::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.setAttribute(AttrD1P1, d1P1);
|
||||
domElement.setAttribute(AttrD1P2, d1P2);
|
||||
domElement.setAttribute(AttrD2P1, d2P1);
|
||||
domElement.setAttribute(AttrD2P2, d2P2);
|
||||
|
||||
QDomNode domNode = domElement.firstChild();
|
||||
domNode = UpdateDetail(domNode, d1);
|
||||
UpdateDetail(domNode, d2);
|
||||
}
|
||||
}
|
||||
|
||||
void VToolUnionDetails::AddDetail(QDomElement &domElement, VDetail &d)
|
||||
{
|
||||
QDomElement det = doc->createElement(TagDetail);
|
||||
|
||||
for (ptrdiff_t i = 0; i < d.CountNode(); ++i)
|
||||
{
|
||||
AddNode(det, d[i]);
|
||||
}
|
||||
|
||||
domElement.appendChild(det);
|
||||
}
|
||||
|
||||
void VToolUnionDetails::AddNode(QDomElement &domElement, VNodeDetail &node)
|
||||
{
|
||||
QDomElement nod = doc->createElement(TagNode);
|
||||
|
||||
AddAttribute(nod, AttrIdObject, node.getId());
|
||||
AddAttribute(nod, AttrMx, toMM(node.getMx()));
|
||||
AddAttribute(nod, AttrMy, toMM(node.getMy()));
|
||||
if (node.getTypeNode() == NodeDetail::Contour)
|
||||
{
|
||||
AddAttribute(nod, AttrNodeType, NodeTypeContour);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddAttribute(nod, AttrNodeType, NodeTypeModeling);
|
||||
}
|
||||
switch (node.getTypeTool())
|
||||
{
|
||||
case (Tool::NodeArc):
|
||||
AddAttribute(nod, AttrType, QStringLiteral("NodeArc"));
|
||||
break;
|
||||
case (Tool::NodePoint):
|
||||
AddAttribute(nod, AttrType, QStringLiteral("NodePoint"));
|
||||
break;
|
||||
case (Tool::NodeSpline):
|
||||
AddAttribute(nod, AttrType, QStringLiteral("NodeSpline"));
|
||||
break;
|
||||
case (Tool::NodeSplinePath):
|
||||
AddAttribute(nod, AttrType, QStringLiteral("NodeSplinePath"));
|
||||
break;
|
||||
default:
|
||||
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
|
||||
break;
|
||||
}
|
||||
domElement.appendChild(nod);
|
||||
}
|
||||
|
||||
QDomNode VToolUnionDetails::UpdateDetail(QDomNode &domNode, VDetail &d)
|
||||
{
|
||||
//QDomNode domNode = domElement.firstChild();
|
||||
while (domNode.isNull() == false)
|
||||
{
|
||||
if (domNode.isElement())
|
||||
{
|
||||
QDomElement domElement = domNode.toElement();
|
||||
if (domElement.isNull() == false)
|
||||
{
|
||||
if (domElement.tagName() == VToolUnionDetails::TagDetail)
|
||||
{
|
||||
for (ptrdiff_t i = 0; i < d.CountNode(); ++i)
|
||||
{
|
||||
UpdateNode(domElement, d[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return domNode.nextSibling();
|
||||
}
|
||||
|
||||
void VToolUnionDetails::UpdateNode(QDomNode &domNode, VNodeDetail &node)
|
||||
{
|
||||
while (domNode.isNull() == false)
|
||||
{
|
||||
if (domNode.isElement())
|
||||
{
|
||||
QDomElement domElement = domNode.toElement();
|
||||
if (domElement.isNull() == false)
|
||||
{
|
||||
if (domElement.tagName() == VToolUnionDetails::TagNode)
|
||||
{
|
||||
domElement.setAttribute( AttrIdObject, node.getId());
|
||||
domElement.setAttribute(AttrMx, toMM(node.getMx()));
|
||||
domElement.setAttribute(AttrMy, toMM(node.getMy()));
|
||||
if (node.getTypeNode() == NodeDetail::Contour)
|
||||
{
|
||||
domElement.setAttribute(AttrNodeType, NodeTypeContour);
|
||||
}
|
||||
else
|
||||
{
|
||||
domElement.setAttribute(AttrNodeType, NodeTypeModeling);
|
||||
}
|
||||
switch (node.getTypeTool())
|
||||
{
|
||||
case (Tool::NodeArc):
|
||||
domElement.setAttribute(AttrType, QStringLiteral("NodeArc"));
|
||||
break;
|
||||
case (Tool::NodePoint):
|
||||
domElement.setAttribute(AttrType, QStringLiteral("NodePoint"));
|
||||
break;
|
||||
case (Tool::NodeSpline):
|
||||
domElement.setAttribute(AttrType, QStringLiteral("NodeSpline"));
|
||||
break;
|
||||
case (Tool::NodeSplinePath):
|
||||
domElement.setAttribute(AttrType, QStringLiteral("NodeSplinePath"));
|
||||
break;
|
||||
default:
|
||||
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
domNode = domNode.nextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
void VToolUnionDetails::AddToModeling(const QDomElement &domElement)
|
||||
{
|
||||
QDomElement modelingElement;
|
||||
bool ok = doc->GetActivModelingElement(modelingElement);
|
||||
if (ok)
|
||||
{
|
||||
modelingElement.appendChild(domElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical()<<tr("Can't find tag Modeling")<< Q_FUNC_INFO;
|
||||
}
|
||||
emit toolhaveChange();
|
||||
}
|
125
src/tools/vtooluniondetails.h
Normal file
125
src/tools/vtooluniondetails.h
Normal file
|
@ -0,0 +1,125 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtooluniondetails.h
|
||||
** @author Roman Telezhinsky <dismine@gmail.com>
|
||||
** @date 26 12, 2013
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2013 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VTOOLUNIONDETAILS_H
|
||||
#define VTOOLUNIONDETAILS_H
|
||||
|
||||
#include "vabstracttool.h"
|
||||
#include "../dialogs/dialoguniondetails.h"
|
||||
|
||||
class VToolUnionDetails : public VAbstractTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolUnionDetails(VDomDocument *doc, VContainer *data, const qint64 &id, const VDetail &d1, const VDetail &d2,
|
||||
const qint64 &d1P1, const qint64 &d1P2, const qint64 &d2P1, const qint64 &d2P2,
|
||||
const Tool::Sources &typeCreation);
|
||||
virtual void setDialog() {}
|
||||
/**
|
||||
* @brief Create
|
||||
* @param dialog
|
||||
* @param doc dom document container
|
||||
* @param data
|
||||
*/
|
||||
static void Create(QSharedPointer<DialogUnionDetails> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
/**
|
||||
* @brief Create
|
||||
* @param _id
|
||||
* @param newDetail
|
||||
* @param scene
|
||||
* @param doc dom document container
|
||||
* @param data
|
||||
* @param parse
|
||||
* @param typeCreation
|
||||
*/
|
||||
static void Create(const qint64 _id, const VDetail &d1, const VDetail &d2, const qint64 &d1id, const qint64 &d2id,
|
||||
const qint64 &d1P1, const qint64 &d1P2, const qint64 &d2P1, const qint64 &d2P2,
|
||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, const Tool::Sources &typeCreation);
|
||||
static QVector<VDetail> GetDetailFromFile(VDomDocument *doc, const QDomElement &domElement);
|
||||
/**
|
||||
* @brief TagName
|
||||
*/
|
||||
static const QString TagName;
|
||||
static const QString ToolType;
|
||||
static const QString TagDetail;
|
||||
static const QString TagNode;
|
||||
static const QString AttrD1P1;
|
||||
static const QString AttrD1P2;
|
||||
static const QString AttrD2P1;
|
||||
static const QString AttrD2P2;
|
||||
static const QString AttrIdObject;
|
||||
static const QString AttrNodeType;
|
||||
static const QString NodeTypeContour;
|
||||
static const QString NodeTypeModeling;
|
||||
|
||||
inline qint64 getD1P1() const{return d1P1;}
|
||||
inline qint64 getD1P2() const{return d1P2;}
|
||||
inline qint64 getD2P1() const{return d2P1;}
|
||||
inline qint64 getD2P2() const{return d2P2;}
|
||||
void AddToNewDetail(VContainer *data, VDetail *newDetail, const VDetail &det, const ptrdiff_t &a,
|
||||
const ptrdiff_t &b, const qreal &dx = 0, const qreal &dy = 0, const qint64 &pRotate = 0,
|
||||
const qreal &angle = 0) const;
|
||||
void UpdatePoints(const qint64 &idDetail, VContainer *data, const VDetail &det, const ptrdiff_t &a,
|
||||
const ptrdiff_t &b, const qreal &dx = 0, const qreal &dy = 0, const qint64 &pRotate = 0,
|
||||
const qreal &angle = 0) const;
|
||||
void BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate,
|
||||
const qreal angle)const;
|
||||
public slots:
|
||||
/**
|
||||
* @brief FullUpdateFromFile
|
||||
*/
|
||||
virtual void FullUpdateFromFile (){}
|
||||
protected:
|
||||
/**
|
||||
* @brief AddToFile
|
||||
*/
|
||||
virtual void AddToFile();
|
||||
/**
|
||||
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
|
||||
*/
|
||||
virtual void RefreshDataInFile();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolUnionDetails)
|
||||
VDetail d1;
|
||||
VDetail d2;
|
||||
qint64 d1P1;
|
||||
qint64 d1P2;
|
||||
qint64 d2P1;
|
||||
qint64 d2P2;
|
||||
void AddDetail(QDomElement &domElement, VDetail &d);
|
||||
void AddNode(QDomElement &domElement, VNodeDetail &node);
|
||||
QDomNode UpdateDetail(QDomNode &domNode, VDetail &d);
|
||||
void UpdateNode(QDomNode &domNode, VNodeDetail &node);
|
||||
void AddToModeling(const QDomElement &domElement);
|
||||
void CorectPoints(const VDetail &detail, qint64 &p1, qint64 &p2);
|
||||
|
||||
};
|
||||
|
||||
#endif // VTOOLUNIONDETAILS_H
|
|
@ -34,6 +34,7 @@
|
|||
#include "../exception/vexceptionobjecterror.h"
|
||||
#include "../exception/vexceptionbadid.h"
|
||||
#include "../tools/vtooldetail.h"
|
||||
#include "../tools/vtooluniondetails.h"
|
||||
#include "../tools/drawTools/drawtools.h"
|
||||
#include "../tools/nodeDetails/nodedetails.h"
|
||||
|
||||
|
@ -371,6 +372,20 @@ void VDomDocument::Parse(const Document::Documents &parse, VMainGraphicsScene *s
|
|||
}
|
||||
}
|
||||
|
||||
VDataTool *VDomDocument::getTool(const qint64 &id)
|
||||
{
|
||||
if (tools.contains(id))
|
||||
{
|
||||
return tools.value(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString error = QString(tr("Can't find tool id = %1 in table.")).arg(id);
|
||||
throw VException(error);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void VDomDocument::ParseIncrementsElement(const QDomNode &node)
|
||||
{
|
||||
QDomNode domNode = node.firstChild();
|
||||
|
@ -390,8 +405,7 @@ void VDomDocument::ParseIncrementsElement(const QDomNode &node)
|
|||
qreal kgrowth = GetParametrDouble(domElement, "kgrowth", "0");
|
||||
QString desc = GetParametrString(domElement, "description", "Description");
|
||||
data->UpdateId(id);
|
||||
data->AddIncrementTableRow(name,
|
||||
VIncrementTableRow(id, base, ksize, kgrowth, desc));
|
||||
data->AddIncrementTableRow(name, new VIncrementTableRow(id, base, ksize, kgrowth, desc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -551,6 +565,11 @@ void VDomDocument::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsSce
|
|||
ParseArcElement(scene, domElement, parse, domElement.attribute("type", ""));
|
||||
continue;
|
||||
}
|
||||
if (domElement.tagName() == "tools")
|
||||
{
|
||||
ParseToolsElement(scene, domElement, parse, domElement.attribute("type", ""));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -562,15 +581,16 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo
|
|||
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
||||
try
|
||||
{
|
||||
VDetail detail;
|
||||
VDetail *detail = new VDetail();
|
||||
Q_ASSERT(detail != 0);
|
||||
VDetail oldDetail;
|
||||
qint64 id = GetParametrId(domElement);
|
||||
detail.setName(GetParametrString(domElement, VAbstractTool::AttrName, ""));
|
||||
detail.setMx(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")));
|
||||
detail.setMy(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")));
|
||||
detail.setSupplement(GetParametrLongLong(domElement, VToolDetail::AttrSupplement, "1"));
|
||||
detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0"));
|
||||
detail.setClosed(GetParametrLongLong(domElement, VToolDetail::AttrClosed, "1"));
|
||||
detail->setName(GetParametrString(domElement, VAbstractTool::AttrName, ""));
|
||||
detail->setMx(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")));
|
||||
detail->setMy(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")));
|
||||
detail->setSupplement(GetParametrLongLong(domElement, VToolDetail::AttrSupplement, "1"));
|
||||
detail->setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0"));
|
||||
detail->setClosed(GetParametrLongLong(domElement, VToolDetail::AttrClosed, "1"));
|
||||
|
||||
QDomNodeList nodeList = domElement.childNodes();
|
||||
qint32 num = nodeList.size();
|
||||
|
@ -590,28 +610,28 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo
|
|||
if (t == "NodePoint")
|
||||
{
|
||||
tool = Tool::NodePoint;
|
||||
VPointF point = data->GetPoint(id);
|
||||
oldDetail.append(VNodeDetail(point.getIdObject(), tool, NodeDetail::Contour));
|
||||
// const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
||||
// oldDetail.append(VNodeDetail(point.getIdObject(), tool, NodeDetail::Contour));
|
||||
}
|
||||
else if (t == "NodeArc")
|
||||
{
|
||||
tool = Tool::NodeArc;
|
||||
VArc arc = data->GetArc(id);
|
||||
oldDetail.append(VNodeDetail(arc.getIdObject(), tool, NodeDetail::Contour));
|
||||
// VArc arc = data->GetArc(id);
|
||||
// oldDetail.append(VNodeDetail(arc.getIdObject(), tool, NodeDetail::Contour));
|
||||
}
|
||||
else if (t == "NodeSpline")
|
||||
{
|
||||
tool = Tool::NodeSpline;
|
||||
VSpline spl = data->GetSpline(id);
|
||||
oldDetail.append(VNodeDetail(spl.getIdObject(), tool, NodeDetail::Contour));
|
||||
// VSpline spl = data->GetSpline(id);
|
||||
// oldDetail.append(VNodeDetail(spl.getIdObject(), tool, NodeDetail::Contour));
|
||||
}
|
||||
else if (t == "NodeSplinePath")
|
||||
{
|
||||
tool = Tool::NodeSplinePath;
|
||||
VSplinePath splPath = data->GetSplinePath(id);
|
||||
oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, NodeDetail::Contour));
|
||||
// VSplinePath splPath = data->GetSplinePath(id);
|
||||
// oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, NodeDetail::Contour));
|
||||
}
|
||||
detail.append(VNodeDetail(id, tool, nodeType, mx, my));
|
||||
detail->append(VNodeDetail(id, tool, nodeType, mx, my));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -665,7 +685,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
|||
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
||||
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
||||
|
||||
data->UpdatePoint(id, VPointF(x, y, name, mx, my));
|
||||
data->UpdateGObject(id, new VPointF(x, y, name, mx, my));
|
||||
VDrawTool::AddRecord(id, Tool::SinglePointTool, this);
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
|
@ -866,10 +886,11 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
|||
{
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0");
|
||||
VPointF point = data->GetPoint(idObject );
|
||||
const VPointF *point = data->GeometricObject<const VPointF *>(idObject );
|
||||
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
||||
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
||||
data->UpdatePoint(id, VPointF(point.x(), point.y(), point.name(), mx, my, idObject ));
|
||||
data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), mx, my, idObject,
|
||||
Draw::Modeling));
|
||||
VNodePoint::Create(this, data, id, idObject, parse, Tool::FromFile);
|
||||
return;
|
||||
}
|
||||
|
@ -1052,7 +1073,8 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
|
|||
{
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0");
|
||||
VSplinePath path(data->DataPoints(), kCurve);
|
||||
VSplinePath *path = new VSplinePath(kCurve);
|
||||
Q_ASSERT(path != 0);
|
||||
|
||||
QDomNodeList nodeList = domElement.childNodes();
|
||||
qint32 num = nodeList.size();
|
||||
|
@ -1067,8 +1089,10 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
|
|||
qreal angle = GetParametrDouble(element, VAbstractTool::AttrAngle, "0");
|
||||
qreal kAsm2 = GetParametrDouble(element, VAbstractTool::AttrKAsm2, "1.0");
|
||||
qint64 pSpline = GetParametrLongLong(element, VAbstractTool::AttrPSpline, "0");
|
||||
VSplinePoint splPoint(pSpline, kAsm1, angle, kAsm2);
|
||||
path.append(splPoint);
|
||||
VPointF p = *data->GeometricObject<const VPointF *>(pSpline);
|
||||
|
||||
VSplinePoint splPoint(p, kAsm1, angle, kAsm2);
|
||||
path->append(splPoint);
|
||||
if (parse == Document::FullParse)
|
||||
{
|
||||
IncrementReferens(pSpline);
|
||||
|
@ -1093,9 +1117,10 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
|
|||
{
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0");
|
||||
VSpline spl = data->GetSpline(idObject);
|
||||
spl.setIdObject(idObject);
|
||||
data->UpdateSpline(id, spl);
|
||||
VSpline *spl = new VSpline(*data->GeometricObject<const VSpline *>(idObject));
|
||||
Q_ASSERT(spl != 0);
|
||||
spl->setIdObject(idObject);
|
||||
data->UpdateGObject(id, spl);
|
||||
VNodeSpline::Create(this, data, id, idObject, parse, Tool::FromFile);
|
||||
return;
|
||||
}
|
||||
|
@ -1112,9 +1137,10 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
|
|||
{
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0");
|
||||
VSplinePath path = data->GetSplinePath(idObject);
|
||||
path.setIdObject(idObject);
|
||||
data->UpdateSplinePath(id, path);
|
||||
VSplinePath *path = new VSplinePath(*data->GeometricObject<const VSplinePath *>(idObject));
|
||||
Q_ASSERT(path != 0);
|
||||
path->setIdObject(idObject);
|
||||
data->UpdateGObject(id, path);
|
||||
VNodeSplinePath::Create(this, data, id, idObject, parse, Tool::FromFile);
|
||||
return;
|
||||
}
|
||||
|
@ -1160,9 +1186,10 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
|
|||
{
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0");
|
||||
VArc arc = data->GetArc(idObject);
|
||||
arc.setIdObject(idObject);
|
||||
data->UpdateArc(id, arc);
|
||||
VArc *arc = new VArc(*data->GeometricObject<const VArc *>(idObject));
|
||||
Q_ASSERT(arc != 0);
|
||||
arc->setIdObject(idObject);
|
||||
data->UpdateGObject(id, arc);
|
||||
VNodeArc::Create(this, data, id, idObject, parse, Tool::FromFile);
|
||||
return;
|
||||
}
|
||||
|
@ -1175,6 +1202,38 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
|
|||
}
|
||||
}
|
||||
|
||||
void VDomDocument::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
||||
const Document::Documents &parse, const QString &type)
|
||||
{
|
||||
Q_ASSERT(scene != 0);
|
||||
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
||||
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
|
||||
if (type == VToolUnionDetails::ToolType)
|
||||
{
|
||||
try
|
||||
{
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 d1P1 = GetParametrLongLong(domElement, VToolUnionDetails::AttrD1P1, "0");
|
||||
qint64 d1P2 = GetParametrLongLong(domElement, VToolUnionDetails::AttrD1P2, "0");
|
||||
qint64 d2P1 = GetParametrLongLong(domElement, VToolUnionDetails::AttrD2P1, "0");
|
||||
qint64 d2P2 = GetParametrLongLong(domElement, VToolUnionDetails::AttrD2P2, "0");
|
||||
|
||||
QVector<VDetail> vector = VToolUnionDetails::GetDetailFromFile(this, domElement);
|
||||
|
||||
VToolUnionDetails::Create(id, vector[0], vector[1], 0, 0, d1P1, d1P2, d2P1, d2P2, scene, this, data, parse,
|
||||
Tool::FromFile);
|
||||
|
||||
return;
|
||||
}
|
||||
catch (const VExceptionBadId &e)
|
||||
{
|
||||
VExceptionObjectError excep(tr("Error creating or updating union details"), domElement);
|
||||
excep.AddMoreInformation(e.ErrorMessage());
|
||||
throw excep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VDomDocument::FullUpdateTree()
|
||||
{
|
||||
VMainGraphicsScene *scene = new VMainGraphicsScene();
|
||||
|
|
|
@ -155,6 +155,7 @@ public:
|
|||
* @return
|
||||
*/
|
||||
inline QHash<qint64, VDataTool*>* getTools() {return &tools;}
|
||||
VDataTool* getTool(const qint64 &id);
|
||||
/**
|
||||
* @brief getHistory
|
||||
* @return
|
||||
|
@ -403,6 +404,8 @@ private:
|
|||
*/
|
||||
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||
const Document::Documents &parse, const QString& type);
|
||||
void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||
const Document::Documents &parse, const QString& type);
|
||||
/**
|
||||
* @brief ParseIncrementsElement
|
||||
* @param node
|
||||
|
|
Loading…
Reference in New Issue
Block a user