2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file vcontainer.cpp
|
2013-11-15 13:41:26 +01:00
|
|
|
** @author Roman Telezhinsky <dismine@gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @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.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
#include "vcontainer.h"
|
2013-11-06 16:49:07 +01:00
|
|
|
#include "../exception/vexceptionbadid.h"
|
2013-07-17 13:38:11 +02:00
|
|
|
|
2013-08-15 22:39:00 +02:00
|
|
|
qint64 VContainer::_id = 0;
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
VContainer::VContainer()
|
|
|
|
:base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()),
|
2013-11-18 17:37:17 +01:00
|
|
|
pointsModeling(QHash<qint64, VPointF>()),
|
2013-10-04 13:32:42 +02:00
|
|
|
standartTable(QHash<QString, VStandartTableCell>()), incrementTable(QHash<QString, VIncrementTableRow>()),
|
|
|
|
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()),
|
2013-11-18 17:37:17 +01:00
|
|
|
splinesModeling(QHash<qint64, VSpline>()),
|
|
|
|
lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), arcsModeling(QHash<qint64, VArc>()),
|
2013-10-04 13:32:42 +02:00
|
|
|
lengthArcs(QHash<QString, qreal>()),
|
2013-11-18 17:37:17 +01:00
|
|
|
splinePaths(QHash<qint64, VSplinePath>()), splinePathsModeling(QHash<qint64, VSplinePath>()),
|
2013-11-04 21:35:15 +01:00
|
|
|
details(QHash<qint64, VDetail>())
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
SetSize(500);
|
|
|
|
SetGrowth(1760);
|
2013-08-13 18:48:36 +02:00
|
|
|
CreateManTableIGroup ();
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
VContainer &VContainer::operator =(const VContainer &data)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
setData(data);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
VContainer::VContainer(const VContainer &data)
|
|
|
|
:base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()),
|
2013-11-18 17:37:17 +01:00
|
|
|
pointsModeling(QHash<qint64, VPointF>()),
|
2013-10-04 13:32:42 +02:00
|
|
|
standartTable(QHash<QString, VStandartTableCell>()), incrementTable(QHash<QString, VIncrementTableRow>()),
|
|
|
|
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()),
|
2013-11-18 17:37:17 +01:00
|
|
|
splinesModeling(QHash<qint64, VSpline>()),
|
|
|
|
lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), arcsModeling(QHash<qint64, VArc>()),
|
2013-10-04 13:32:42 +02:00
|
|
|
lengthArcs(QHash<QString, qreal>()),
|
2013-11-18 17:37:17 +01:00
|
|
|
splinePaths(QHash<qint64, VSplinePath>()), splinePathsModeling(QHash<qint64, VSplinePath>()),
|
2013-11-04 21:35:15 +01:00
|
|
|
details(QHash<qint64, VDetail>())
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
setData(data);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::setData(const VContainer &data)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
base = *data.DataBase();
|
|
|
|
points = *data.DataPoints();
|
2013-11-18 17:37:17 +01:00
|
|
|
pointsModeling = *data.DataPointsModeling();
|
2013-08-15 22:39:00 +02:00
|
|
|
standartTable = *data.DataStandartTable();
|
|
|
|
incrementTable = *data.DataIncrementTable();
|
|
|
|
lengthLines = *data.DataLengthLines();
|
2013-10-09 20:11:25 +02:00
|
|
|
lineAngles = *data.DataLineAngles();
|
2013-08-15 22:39:00 +02:00
|
|
|
splines = *data.DataSplines();
|
2013-11-18 17:37:17 +01:00
|
|
|
splinesModeling = *data.DataSplinesModeling();
|
2013-08-15 22:39:00 +02:00
|
|
|
lengthSplines = *data.DataLengthSplines();
|
|
|
|
arcs = *data.DataArcs();
|
2013-11-18 17:37:17 +01:00
|
|
|
arcsModeling = *data.DataArcsModeling();
|
2013-08-15 22:39:00 +02:00
|
|
|
lengthArcs = *data.DataLengthArcs();
|
|
|
|
splinePaths = *data.DataSplinePaths();
|
2013-11-18 17:37:17 +01:00
|
|
|
splinePathsModeling = *data.DataSplinePathsModeling();
|
2013-08-28 10:55:11 +02:00
|
|
|
details = *data.DataDetails();
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
2013-11-15 18:38:29 +01:00
|
|
|
VPointF VContainer::GetPoint(qint64 id) const
|
|
|
|
{
|
|
|
|
return GetObject(points, id);
|
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
VPointF VContainer::GetPointModeling(qint64 id) const
|
2013-11-15 18:38:29 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
return GetObject(pointsModeling, id);
|
2013-11-15 18:38:29 +01:00
|
|
|
}
|
|
|
|
|
2013-08-13 18:48:36 +02:00
|
|
|
template <typename key, typename val>
|
2013-11-04 21:35:15 +01:00
|
|
|
val VContainer::GetObject(const QHash<key, val> &obj, key id)
|
|
|
|
{
|
|
|
|
if (obj.contains(id))
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
return obj.value(id);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
throw VExceptionBadId(tr("Can't find object"), id);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
VStandartTableCell VContainer::GetStandartTableCell(const QString &name) const
|
|
|
|
{
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2013-08-13 18:48:36 +02:00
|
|
|
return GetObject(standartTable, name);
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
VIncrementTableRow VContainer::GetIncrementTableRow(const QString& name) const
|
|
|
|
{
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2013-08-13 18:48:36 +02:00
|
|
|
return GetObject(incrementTable, name);
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal VContainer::GetLine(const QString &name) const
|
|
|
|
{
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2013-08-13 18:48:36 +02:00
|
|
|
return GetObject(lengthLines, name);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal VContainer::GetLengthArc(const QString &name) const
|
|
|
|
{
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2013-10-13 17:31:42 +02:00
|
|
|
return GetObject(lengthArcs, name);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal VContainer::GetLengthSpline(const QString &name) const
|
|
|
|
{
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2013-10-13 17:31:42 +02:00
|
|
|
return GetObject(lengthSplines, name);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal VContainer::GetLineAngle(const QString &name) const
|
|
|
|
{
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2013-08-21 10:03:53 +02:00
|
|
|
return GetObject(lineAngles, name);
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2013-11-15 18:38:29 +01:00
|
|
|
VSpline VContainer::GetSpline(qint64 id) const
|
|
|
|
{
|
|
|
|
return GetObject(splines, id);
|
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
VSpline VContainer::GetSplineModeling(qint64 id) const
|
2013-11-15 18:38:29 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
return GetObject(splinesModeling, id);
|
2013-11-15 18:38:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VArc VContainer::GetArc(qint64 id) const
|
|
|
|
{
|
|
|
|
return GetObject(arcs, id);
|
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
VArc VContainer::GetArcModeling(qint64 id) const
|
2013-11-15 18:38:29 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
return GetObject(arcsModeling, id);
|
2013-11-15 18:38:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VSplinePath VContainer::GetSplinePath(qint64 id) const
|
|
|
|
{
|
|
|
|
return GetObject(splinePaths, id);
|
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
VSplinePath VContainer::GetSplinePathModeling(qint64 id) const
|
2013-11-15 18:38:29 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
return GetObject(splinePathsModeling, id);
|
2013-11-15 18:38:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VDetail VContainer::GetDetail(qint64 id) const
|
|
|
|
{
|
|
|
|
return GetObject(details, id);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qint64 VContainer::AddPoint(const VPointF &point)
|
|
|
|
{
|
2013-10-27 11:22:44 +01:00
|
|
|
return AddObject(points, point);
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
qint64 VContainer::AddPointModeling(const VPointF &point)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
return AddObject(pointsModeling, point);
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qint64 VContainer::AddDetail(const VDetail &detail)
|
|
|
|
{
|
2013-10-27 11:22:44 +01:00
|
|
|
return AddObject(details, detail);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qint64 VContainer::getNextId()
|
|
|
|
{
|
2013-09-12 16:18:31 +02:00
|
|
|
_id++;
|
2013-07-13 12:51:31 +02:00
|
|
|
return _id;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::UpdateId(qint64 newId)
|
|
|
|
{
|
|
|
|
if (newId > _id)
|
|
|
|
{
|
2013-09-12 16:18:31 +02:00
|
|
|
_id = newId;
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QPainterPath VContainer::ContourPath(qint64 idDetail) const
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
VDetail detail = GetDetail(idDetail);
|
|
|
|
QVector<QPointF> points;
|
2013-10-25 13:10:45 +02:00
|
|
|
QVector<QPointF> pointsEkv;
|
2013-11-07 15:40:39 +01:00
|
|
|
for (ptrdiff_t i = 0; i< detail.CountNode(); ++i)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
switch (detail[i].getTypeTool())
|
|
|
|
{
|
|
|
|
case (Tool::NodePoint):
|
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
VPointF point = GetPointModeling(detail[i].getId());
|
2013-11-04 21:35:15 +01:00
|
|
|
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());
|
|
|
|
pointsEkv.append(pEkv);
|
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
2013-08-29 12:31:50 +02:00
|
|
|
break;
|
2013-11-04 21:35:15 +01:00
|
|
|
case (Tool::NodeArc):
|
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
VArc arc = GetArcModeling(detail[i].getId());
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal len1 = GetLengthContour(points, arc.GetPoints());
|
|
|
|
qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints()));
|
|
|
|
if (len1 <= lenReverse)
|
|
|
|
{
|
|
|
|
points << arc.GetPoints();
|
|
|
|
if (detail.getSupplement() == true)
|
|
|
|
{
|
|
|
|
pointsEkv << biasPoints(arc.GetPoints(), detail[i].getMx(), detail[i].getMy());
|
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
points << GetReversePoint(arc.GetPoints());
|
|
|
|
if (detail.getSupplement() == true)
|
|
|
|
{
|
|
|
|
pointsEkv << biasPoints(GetReversePoint(arc.GetPoints()), detail[i].getMx(), detail[i].getMy());
|
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2013-08-29 12:31:50 +02:00
|
|
|
break;
|
2013-11-04 21:35:15 +01:00
|
|
|
case (Tool::NodeSpline):
|
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
VSpline spline = GetSplineModeling(detail[i].getId());
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal len1 = GetLengthContour(points, spline.GetPoints());
|
|
|
|
qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints()));
|
|
|
|
if (len1 <= lenReverse)
|
|
|
|
{
|
|
|
|
points << spline.GetPoints();
|
|
|
|
if (detail.getSupplement() == true)
|
|
|
|
{
|
|
|
|
pointsEkv << biasPoints(spline.GetPoints(), detail[i].getMx(), detail[i].getMy());
|
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
points << GetReversePoint(spline.GetPoints());
|
|
|
|
if (detail.getSupplement() == true)
|
|
|
|
{
|
|
|
|
pointsEkv << biasPoints(GetReversePoint(spline.GetPoints()), detail[i].getMx(),
|
|
|
|
detail[i].getMy());
|
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2013-08-29 12:31:50 +02:00
|
|
|
break;
|
2013-11-04 21:35:15 +01:00
|
|
|
case (Tool::NodeSplinePath):
|
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
VSplinePath splinePath = GetSplinePathModeling(detail[i].getId());
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal len1 = GetLengthContour(points, splinePath.GetPathPoints());
|
|
|
|
qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints()));
|
|
|
|
if (len1 <= lenReverse)
|
|
|
|
{
|
|
|
|
points << splinePath.GetPathPoints();
|
|
|
|
if (detail.getSupplement() == true)
|
|
|
|
{
|
|
|
|
pointsEkv << biasPoints(splinePath.GetPathPoints(), detail[i].getMx(), detail[i].getMy());
|
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
points << GetReversePoint(splinePath.GetPathPoints());
|
|
|
|
if (detail.getSupplement() == true)
|
|
|
|
{
|
|
|
|
pointsEkv << biasPoints(GetReversePoint(splinePath.GetPathPoints()), detail[i].getMx(),
|
|
|
|
detail[i].getMy());
|
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
}
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2013-09-12 16:18:31 +02:00
|
|
|
break;
|
2013-11-04 21:35:15 +01:00
|
|
|
case (Tool::SplineTool):
|
|
|
|
break;//Nothing to do, just ignore.
|
|
|
|
default:
|
|
|
|
qWarning()<<"Get wrong tool type. Ignore."<<detail[i].getTypeTool();
|
|
|
|
break;
|
|
|
|
}
|
2013-08-29 12:31:50 +02:00
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
|
2013-08-29 12:31:50 +02:00
|
|
|
QPainterPath path;
|
|
|
|
path.moveTo(points[0]);
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 1; i < points.count(); ++i)
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
path.lineTo(points[i]);
|
|
|
|
}
|
|
|
|
path.lineTo(points[0]);
|
2013-10-25 13:10:45 +02:00
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
if (detail.getSupplement() == true)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
QPainterPath ekv;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (detail.getClosed() == true)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
ekv = Equidistant(pointsEkv, Detail::CloseEquidistant, toPixel(detail.getWidth()));
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
ekv = Equidistant(pointsEkv, Detail::OpenEquidistant, toPixel(detail.getWidth()));
|
|
|
|
}
|
|
|
|
path.addPath(ekv);
|
|
|
|
path.setFillRule(Qt::WindingFill);
|
|
|
|
}
|
2013-08-29 12:31:50 +02:00
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QVector<QPointF> VContainer::biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my) const
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
QVector<QPointF> p;
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < points.size(); ++i)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
QPointF point = points.at(i);
|
|
|
|
point.setX(point.x() + mx);
|
2013-11-04 21:35:15 +01:00
|
|
|
point.setY(point.y() + my);
|
2013-10-25 13:10:45 +02:00
|
|
|
p.append(point);
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QPainterPath VContainer::Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, const qreal &width) const
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
QPainterPath ekv;
|
|
|
|
QVector<QPointF> ekvPoints;
|
2013-11-04 21:35:15 +01:00
|
|
|
if ( points.size() < 3 )
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
qDebug()<<"Not enough points for build equidistant.\n";
|
|
|
|
return ekv;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < points.size(); ++i )
|
|
|
|
{
|
|
|
|
if (i != points.size()-1)
|
|
|
|
{
|
|
|
|
if (points[i] == points[i+1])
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
points.remove(i+1);
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (points[i] == points[0])
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
points.remove(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (eqv == Detail::CloseEquidistant)
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
points.append(points.at(0));
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < points.size(); ++i )
|
|
|
|
{
|
|
|
|
if ( i == 0 && eqv == Detail::CloseEquidistant)
|
|
|
|
{//перша точка, ламана замкнена
|
|
|
|
ekvPoints<<EkvPoint(QLineF(points[points.size()-2], points[points.size()-1]), QLineF(points[1], points[0]),
|
|
|
|
width);
|
2013-09-11 16:14:21 +02:00
|
|
|
continue;
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else if (i == 0 && eqv == Detail::OpenEquidistant)
|
|
|
|
{//перша точка, ламана не замкнена
|
2013-09-11 16:14:21 +02:00
|
|
|
ekvPoints.append(SingleParallelPoint(QLineF(points[0], points[1]), 90, width));
|
|
|
|
continue;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (i == points.size()-1 && eqv == Detail::CloseEquidistant)
|
|
|
|
{//остання точка, ламана замкнена
|
2013-09-11 16:14:21 +02:00
|
|
|
ekvPoints.append(ekvPoints.at(0));
|
|
|
|
continue;
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else if (i == points.size()-1 && eqv == Detail::OpenEquidistant)
|
|
|
|
{//остання точка, ламана не замкнена
|
|
|
|
ekvPoints.append(SingleParallelPoint(QLineF(points[points.size()-1], points[points.size()-2]), -90,
|
|
|
|
width));
|
2013-09-11 16:14:21 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//точка яка не лежить ні на початку ні в кінці
|
|
|
|
ekvPoints<<EkvPoint(QLineF(points[i-1], points[i]), QLineF(points[i+1], points[i]), width);
|
|
|
|
}
|
2013-09-17 19:11:43 +02:00
|
|
|
ekvPoints = CheckLoops(ekvPoints);
|
2013-09-11 16:14:21 +02:00
|
|
|
ekv.moveTo(ekvPoints[0]);
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 1; i < ekvPoints.count(); ++i)
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
ekv.lineTo(ekvPoints[i]);
|
|
|
|
}
|
|
|
|
return ekv;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QLineF VContainer::ParallelLine(const QLineF &line, qreal width)
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
Q_ASSERT(width > 0);
|
2013-11-04 21:35:15 +01:00
|
|
|
QLineF paralel = QLineF (SingleParallelPoint(line, 90, width), SingleParallelPoint(QLineF(line.p2(), line.p1()),
|
|
|
|
-90, width));
|
2013-09-11 16:14:21 +02:00
|
|
|
return paralel;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QPointF VContainer::SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width)
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
Q_ASSERT(width > 0);
|
2013-11-04 21:35:15 +01:00
|
|
|
QLineF pLine = line;
|
|
|
|
pLine.setAngle( pLine.angle() + angle );
|
|
|
|
pLine.setLength( width );
|
|
|
|
return pLine.p2();
|
2013-09-11 16:14:21 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QVector<QPointF> VContainer::EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width) const
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
Q_ASSERT(width > 0);
|
|
|
|
QVector<QPointF> points;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (line1.p2() != line2.p2())
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
qWarning()<<"Last point of two lines must be equal.";
|
|
|
|
}
|
|
|
|
QPointF CrosPoint;
|
|
|
|
QLineF bigLine1 = ParallelLine(line1, width );
|
|
|
|
QLineF bigLine2 = ParallelLine(QLineF(line2.p2(), line2.p1()), width );
|
|
|
|
QLineF::IntersectType type = bigLine1.intersect( bigLine2, &CrosPoint );
|
2013-11-04 21:35:15 +01:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case (QLineF::BoundedIntersection):
|
2013-09-11 16:14:21 +02:00
|
|
|
points.append(CrosPoint);
|
|
|
|
return points;
|
2013-11-04 21:35:15 +01:00
|
|
|
break;
|
|
|
|
case (QLineF::UnboundedIntersection):
|
|
|
|
{
|
|
|
|
QLineF line( line1.p2(), CrosPoint );
|
|
|
|
if (line.length() > width + toPixel(8))
|
|
|
|
{
|
|
|
|
QLineF lineL;
|
|
|
|
lineL = QLineF(bigLine1.p2(), CrosPoint);
|
|
|
|
lineL.setLength(width);
|
|
|
|
points.append(lineL.p2());
|
|
|
|
|
|
|
|
lineL = QLineF(bigLine2.p1(), CrosPoint);
|
|
|
|
lineL.setLength(width);
|
|
|
|
points.append(lineL.p2());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
points.append(CrosPoint);
|
|
|
|
return points;
|
|
|
|
}
|
|
|
|
break;
|
2013-09-11 16:14:21 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
case (QLineF::NoIntersection):
|
|
|
|
/*If we have correct lines this means lines lie on a line.*/
|
|
|
|
points.append(bigLine1.p2());
|
|
|
|
return points;
|
|
|
|
break;
|
2013-11-12 19:29:03 +01:00
|
|
|
default:
|
|
|
|
break;
|
2013-09-11 16:14:21 +02:00
|
|
|
}
|
|
|
|
return points;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QVector<QPointF> VContainer::CheckLoops(const QVector<QPointF> &points) const
|
|
|
|
{
|
2013-09-17 19:11:43 +02:00
|
|
|
QVector<QPointF> ekvPoints;
|
|
|
|
/*If we got less than 4 points no need seek loops.*/
|
2013-11-04 21:35:15 +01:00
|
|
|
if (points.size() < 4)
|
|
|
|
{
|
2013-09-17 19:11:43 +02:00
|
|
|
return ekvPoints;
|
|
|
|
}
|
|
|
|
bool closed = false;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (points.at(0) == points.at(points.size()-1))
|
|
|
|
{
|
2013-09-17 19:11:43 +02:00
|
|
|
closed = true;
|
|
|
|
}
|
|
|
|
qint32 i, j;
|
2013-11-04 21:35:15 +01:00
|
|
|
for (i = 0; i < points.size(); ++i)
|
|
|
|
{
|
2013-09-17 19:11:43 +02:00
|
|
|
/*Last three points no need check.*/
|
2013-11-04 21:35:15 +01:00
|
|
|
if (i >= points.size()-3)
|
|
|
|
{
|
2013-09-17 19:11:43 +02:00
|
|
|
ekvPoints.append(points.at(i));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
QPointF crosPoint;
|
|
|
|
QLineF::IntersectType intersect = QLineF::NoIntersection;
|
2013-11-04 21:35:15 +01:00
|
|
|
QLineF line1(points.at(i), points.at(i+1));
|
|
|
|
for (j = i+2; j < points.size()-1; ++j)
|
|
|
|
{
|
|
|
|
QLineF line2(points.at(j), points.at(j+1));
|
2013-09-17 19:11:43 +02:00
|
|
|
intersect = line1.intersect(line2, &crosPoint);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (intersect == QLineF::BoundedIntersection)
|
|
|
|
{
|
2013-09-17 19:11:43 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (intersect == QLineF::BoundedIntersection)
|
|
|
|
{
|
|
|
|
if (i == 0 && j+1 == points.size()-1 && closed)
|
|
|
|
{
|
2013-09-17 19:11:43 +02:00
|
|
|
/*We got closed contour.*/
|
|
|
|
ekvPoints.append(points.at(i));
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-17 19:11:43 +02:00
|
|
|
/*We found loop.*/
|
|
|
|
ekvPoints.append(points.at(i));
|
|
|
|
ekvPoints.append(crosPoint);
|
|
|
|
ekvPoints.append(points.at(j+1));
|
|
|
|
i = j + 2;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-17 19:11:43 +02:00
|
|
|
/*We did not found loop.*/
|
|
|
|
ekvPoints.append(points.at(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ekvPoints;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::PrepareDetails(QVector<VItem *> &list) const
|
|
|
|
{
|
2013-10-04 13:32:42 +02:00
|
|
|
QHashIterator<qint64, VDetail> iDetail(details);
|
2013-11-04 21:35:15 +01:00
|
|
|
while (iDetail.hasNext())
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
iDetail.next();
|
|
|
|
list.append(new VItem(ContourPath(iDetail.key()), list.size()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-13 18:48:36 +02:00
|
|
|
template <typename val>
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::UpdateObject(QHash<qint64, val> &obj, const qint64 &id, const val& point)
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
2013-08-13 18:48:36 +02:00
|
|
|
obj[id] = point;
|
|
|
|
UpdateId(id);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::AddLengthSpline(const QString &name, const qreal &value)
|
|
|
|
{
|
|
|
|
Q_ASSERT(name.isEmpty() == false);
|
2013-08-13 18:48:36 +02:00
|
|
|
lengthSplines[name] = value;
|
|
|
|
}
|
|
|
|
|
2013-11-12 14:04:18 +01:00
|
|
|
void VContainer::AddLengthArc(const qint64 &id)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-11-12 14:04:18 +01:00
|
|
|
AddLengthArc(GetArc(id).name(), toMM(GetArc(id).GetLength()));
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::AddLengthArc(const QString &name, const qreal &value)
|
|
|
|
{
|
|
|
|
Q_ASSERT(name.isEmpty() == false);
|
2013-08-13 18:48:36 +02:00
|
|
|
lengthArcs[name] = value;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::AddLineAngle(const QString &name, const qreal &value)
|
|
|
|
{
|
|
|
|
Q_ASSERT(name.isEmpty() == false);
|
2013-08-21 10:03:53 +02:00
|
|
|
lineAngles[name] = value;
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal VContainer::GetValueStandartTableCell(const QString& name) const
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
VStandartTableCell cell = GetStandartTableCell(name);
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal k_size = ( static_cast<qreal> (size()/10.0) - 50.0 ) / 2.0;
|
2013-08-20 12:26:02 +02:00
|
|
|
qreal k_growth = ( static_cast<qreal> (growth()/10.0) - 176.0 ) / 6.0;
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal value = cell.GetBase() + k_size*cell.GetKsize() + k_growth*cell.GetKgrowth();
|
2013-07-17 13:38:11 +02:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal VContainer::GetValueIncrementTableRow(const QString& name) const
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
VIncrementTableRow cell = GetIncrementTableRow(name);
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal k_size = ( static_cast<qreal> (size()/10.0) - 50.0 ) / 2.0;
|
2013-08-20 12:26:02 +02:00
|
|
|
qreal k_growth = ( static_cast<qreal> (growth()/10.0) - 176.0 ) / 6.0;
|
2013-07-17 13:38:11 +02:00
|
|
|
qreal value = cell.getBase() + k_size*cell.getKsize() + k_growth*cell.getKgrowth();
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::Clear()
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
_id = 0;
|
2013-07-17 13:38:11 +02:00
|
|
|
standartTable.clear();
|
|
|
|
incrementTable.clear();
|
2013-07-25 14:00:51 +02:00
|
|
|
lengthLines.clear();
|
2013-08-05 10:37:56 +02:00
|
|
|
lengthArcs.clear();
|
2013-08-21 10:03:53 +02:00
|
|
|
lineAngles.clear();
|
2013-08-28 10:55:11 +02:00
|
|
|
details.clear();
|
2013-11-18 17:37:17 +01:00
|
|
|
arcsModeling.clear();
|
|
|
|
pointsModeling.clear();
|
|
|
|
splinePathsModeling.clear();
|
|
|
|
splinesModeling.clear();
|
2013-08-15 22:39:00 +02:00
|
|
|
ClearObject();
|
2013-08-13 18:48:36 +02:00
|
|
|
CreateManTableIGroup ();
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::ClearObject()
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
points.clear();
|
|
|
|
splines.clear();
|
|
|
|
arcs.clear();
|
2013-08-28 10:55:11 +02:00
|
|
|
splinePaths.clear();
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal VContainer::FindVar(const QString &name, bool *ok)const
|
|
|
|
{
|
|
|
|
if (base.contains(name))
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
*ok = true;
|
2013-07-25 14:00:51 +02:00
|
|
|
return base.value(name);
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
if (standartTable.contains(name))
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
*ok = true;
|
2013-07-25 14:00:51 +02:00
|
|
|
return GetValueStandartTableCell(name);
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (incrementTable.contains(name))
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
*ok = true;
|
2013-07-25 14:00:51 +02:00
|
|
|
return GetValueIncrementTableRow(name);
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (lengthLines.contains(name))
|
|
|
|
{
|
2013-07-25 14:00:51 +02:00
|
|
|
*ok = true;
|
|
|
|
return lengthLines.value(name);
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (lengthArcs.contains(name))
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
*ok = true;
|
|
|
|
return lengthArcs.value(name);
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (lineAngles.contains(name))
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
*ok = true;
|
2013-08-21 10:03:53 +02:00
|
|
|
return lineAngles.value(name);
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (lengthSplines.contains(name))
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
*ok = true;
|
|
|
|
return lengthSplines.value(name);
|
|
|
|
}
|
2013-07-17 13:38:11 +02:00
|
|
|
*ok = false;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-11-06 22:11:12 +01:00
|
|
|
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId, const Draw::Draws &mode)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
QString nameLine = GetNameLine(firstPointId, secondPointId, mode);
|
|
|
|
VPointF first;
|
|
|
|
VPointF second;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (mode == Draw::Calculation)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
first = GetPoint(firstPointId);
|
|
|
|
second = GetPoint(secondPointId);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
first = GetPointModeling(firstPointId);
|
|
|
|
second = GetPointModeling(secondPointId);
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2013-10-13 20:51:59 +02:00
|
|
|
AddLengthLine(nameLine, toMM(QLineF(first.toQPointF(), second.toQPointF()).length()));
|
2013-09-10 14:29:06 +02:00
|
|
|
nameLine = GetNameLineAngle(firstPointId, secondPointId, mode);
|
|
|
|
AddLineAngle(nameLine, QLineF(first.toQPointF(), second.toQPointF()).angle());
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qint64 VContainer::AddSpline(const VSpline &spl)
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
return AddObject(splines, spl);
|
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
qint64 VContainer::AddSplineModeling(const VSpline &spl)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
return AddObject(splinesModeling, spl);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qint64 VContainer::AddSplinePath(const VSplinePath &splPath)
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
return AddObject(splinePaths, splPath);
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
qint64 VContainer::AddSplinePathModeling(const VSplinePath &splPath)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
return AddObject(splinePathsModeling, splPath);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qint64 VContainer::AddArc(const VArc &arc)
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
return AddObject(arcs, arc);
|
2013-07-30 15:09:34 +02:00
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
qint64 VContainer::AddArcModeling(const VArc &arc)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
return AddObject(arcsModeling, arc);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2013-10-27 11:22:44 +01:00
|
|
|
template <typename key, typename val>
|
2013-11-04 21:35:15 +01:00
|
|
|
qint64 VContainer::AddObject(QHash<key, val> &obj, const val& value)
|
|
|
|
{
|
2013-10-27 11:22:44 +01:00
|
|
|
qint64 id = getNextId();
|
|
|
|
obj[id] = value;
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2013-11-06 22:11:12 +01:00
|
|
|
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, const Draw::Draws &mode) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
VPointF first;
|
|
|
|
VPointF second;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (mode == Draw::Calculation)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
first = GetPoint(firstPoint);
|
|
|
|
second = GetPoint(secondPoint);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
first = GetPointModeling(firstPoint);
|
|
|
|
second = GetPointModeling(secondPoint);
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2013-07-30 15:09:34 +02:00
|
|
|
return QString("Line_%1_%2").arg(first.name(), second.name());
|
|
|
|
}
|
|
|
|
|
2013-11-06 22:11:12 +01:00
|
|
|
QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint, const Draw::Draws &mode) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
VPointF first;
|
|
|
|
VPointF second;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (mode == Draw::Calculation)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
first = GetPoint(firstPoint);
|
|
|
|
second = GetPoint(secondPoint);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
first = GetPointModeling(firstPoint);
|
|
|
|
second = GetPointModeling(secondPoint);
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2013-08-21 10:03:53 +02:00
|
|
|
return QString("AngleLine_%1_%2").arg(first.name(), second.name());
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::UpdatePoint(qint64 id, const VPointF &point)
|
|
|
|
{
|
2013-10-27 11:22:44 +01:00
|
|
|
UpdateObject(points, id, point);
|
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
void VContainer::UpdatePointModeling(qint64 id, const VPointF &point)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
UpdateObject(pointsModeling, id, point);
|
2013-10-27 11:22:44 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::UpdateDetail(qint64 id, const VDetail &detail)
|
|
|
|
{
|
2013-10-27 11:22:44 +01:00
|
|
|
UpdateObject(details, id, detail);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::UpdateSpline(qint64 id, const VSpline &spl)
|
|
|
|
{
|
2013-10-27 11:22:44 +01:00
|
|
|
UpdateObject(splines, id, spl);
|
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
void VContainer::UpdateSplineModeling(qint64 id, const VSpline &spl)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
UpdateObject(splinesModeling, id, spl);
|
2013-10-27 11:22:44 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::UpdateSplinePath(qint64 id, const VSplinePath &splPath)
|
|
|
|
{
|
2013-10-27 11:22:44 +01:00
|
|
|
UpdateObject(splinePaths, id, splPath);
|
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
void VContainer::UpdateSplinePathModeling(qint64 id, const VSplinePath &splPath)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
UpdateObject(splinePathsModeling, id, splPath);
|
2013-10-27 11:22:44 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::UpdateArc(qint64 id, const VArc &arc)
|
|
|
|
{
|
2013-10-27 11:22:44 +01:00
|
|
|
UpdateObject(arcs, id, arc);
|
|
|
|
}
|
|
|
|
|
2013-11-18 17:37:17 +01:00
|
|
|
void VContainer::UpdateArcModeling(qint64 id, const VArc &arc)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-11-18 17:37:17 +01:00
|
|
|
UpdateObject(arcsModeling, id, arc);
|
2013-10-27 11:22:44 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::AddLengthLine(const QString &name, const qreal &value)
|
|
|
|
{
|
|
|
|
Q_ASSERT(name.isEmpty() == false);
|
2013-08-06 09:56:09 +02:00
|
|
|
lengthLines[name] = value;
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::CreateManTableIGroup ()
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
AddStandartTableCell("Pkor", VStandartTableCell(84, 0, 3));
|
|
|
|
AddStandartTableCell("Pkor", VStandartTableCell(84, 0, 3));
|
|
|
|
AddStandartTableCell("Vtos", VStandartTableCell(1450, 2, 51));
|
|
|
|
AddStandartTableCell("Vtosh", VStandartTableCell(1506, 2, 54));
|
|
|
|
AddStandartTableCell("Vpt", VStandartTableCell(1438, 3, 52));
|
|
|
|
AddStandartTableCell("Vst", VStandartTableCell(1257, -1, 49));
|
|
|
|
AddStandartTableCell("Vlt", VStandartTableCell(1102, 0, 43));
|
|
|
|
AddStandartTableCell("Vk", VStandartTableCell(503, 0, 22));
|
|
|
|
AddStandartTableCell("Vsht", VStandartTableCell(1522, 2, 54));
|
|
|
|
AddStandartTableCell("Vzy", VStandartTableCell(1328, 0, 49));
|
|
|
|
AddStandartTableCell("Vlop", VStandartTableCell(1320, 0, 49));
|
|
|
|
AddStandartTableCell("Vps", VStandartTableCell(811, -1, 36));
|
2013-11-04 21:35:15 +01:00
|
|
|
AddStandartTableCell("Ssh", VStandartTableCell(202, 4, 1));
|
2013-10-21 09:45:49 +02:00
|
|
|
AddStandartTableCell("SgI", VStandartTableCell(517, 18, 2));
|
|
|
|
AddStandartTableCell("SgII", VStandartTableCell(522, 19, 1));
|
|
|
|
AddStandartTableCell("SgIII", VStandartTableCell(500, 20, 0));
|
|
|
|
AddStandartTableCell("St", VStandartTableCell(390, 20, 0));
|
|
|
|
AddStandartTableCell("Sb", VStandartTableCell(492, 15, 5));
|
|
|
|
AddStandartTableCell("SbI", VStandartTableCell(482, 12, 6));
|
2013-08-13 18:48:36 +02:00
|
|
|
AddStandartTableCell("Obed", VStandartTableCell(566, 18, 6));
|
|
|
|
AddStandartTableCell("Ok", VStandartTableCell(386, 8, 8));
|
|
|
|
AddStandartTableCell("Oi", VStandartTableCell(380, 8, 6));
|
|
|
|
AddStandartTableCell("Osch", VStandartTableCell(234, 4, 4));
|
|
|
|
AddStandartTableCell("Dsb", VStandartTableCell(1120, 0, 44));
|
|
|
|
AddStandartTableCell("Dsp", VStandartTableCell(1110, 0, 43));
|
|
|
|
AddStandartTableCell("Dn", VStandartTableCell(826, -3, 37));
|
|
|
|
AddStandartTableCell("Dps", VStandartTableCell(316, 4, 7));
|
|
|
|
AddStandartTableCell("Dpob", VStandartTableCell(783, 14, 15));
|
|
|
|
AddStandartTableCell("Ds", VStandartTableCell(260, 1, 6));
|
|
|
|
AddStandartTableCell("Op", VStandartTableCell(316, 12, 0));
|
|
|
|
AddStandartTableCell("Ozap", VStandartTableCell(180, 4, 0));
|
|
|
|
AddStandartTableCell("Pkis", VStandartTableCell(250, 4, 0));
|
|
|
|
AddStandartTableCell("SHp", VStandartTableCell(160, 1, 4));
|
|
|
|
AddStandartTableCell("Dlych", VStandartTableCell(500, 2, 15));
|
|
|
|
AddStandartTableCell("Dzap", VStandartTableCell(768, 2, 24));
|
|
|
|
AddStandartTableCell("DIIIp", VStandartTableCell(970, 2, 29));
|
|
|
|
AddStandartTableCell("Vprp", VStandartTableCell(214, 3, 3));
|
|
|
|
AddStandartTableCell("Vg", VStandartTableCell(262, 8, 3));
|
|
|
|
AddStandartTableCell("Dtp", VStandartTableCell(460, 7, 9));
|
|
|
|
AddStandartTableCell("Dp", VStandartTableCell(355, 5, 5));
|
|
|
|
AddStandartTableCell("Vprz", VStandartTableCell(208, 3, 5));
|
|
|
|
AddStandartTableCell("Dts", VStandartTableCell(438, 2, 10));
|
|
|
|
AddStandartTableCell("DtsI", VStandartTableCell(469, 2, 10));
|
|
|
|
AddStandartTableCell("Dvcht", VStandartTableCell(929, 9, 19));
|
|
|
|
AddStandartTableCell("SHg", VStandartTableCell(370, 14, 4));
|
|
|
|
AddStandartTableCell("Cg", VStandartTableCell(224, 6, 0));
|
|
|
|
AddStandartTableCell("SHs", VStandartTableCell(416, 10, 2));
|
|
|
|
AddStandartTableCell("dpzr", VStandartTableCell(121, 6, 0));
|
|
|
|
AddStandartTableCell("Ogol", VStandartTableCell(576, 4, 4));
|
|
|
|
AddStandartTableCell("Ssh1", VStandartTableCell(205, 5, 0));
|
|
|
|
AddStandartTableCell("St", VStandartTableCell(410, 20, 0));
|
|
|
|
AddStandartTableCell("Drzap", VStandartTableCell(594, 3, 19));
|
|
|
|
AddStandartTableCell("DbII", VStandartTableCell(1020, 0, 44));
|
|
|
|
AddStandartTableCell("Sb", VStandartTableCell(504, 15, 4));
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
2013-09-10 14:29:06 +02:00
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QVector<QPointF> VContainer::GetReversePoint(const QVector<QPointF> &points) const
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
Q_ASSERT(points.size() > 0);
|
|
|
|
QVector<QPointF> reversePoints;
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = points.size() - 1; i >= 0; --i)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
reversePoints.append(points.at(i));
|
|
|
|
}
|
|
|
|
return reversePoints;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qreal VContainer::GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints) const
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
qreal length = 0;
|
|
|
|
QVector<QPointF> points;
|
|
|
|
points << contour << newPoints;
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < points.size()-1; ++i)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
QLineF line(points.at(i), points.at(i+1));
|
|
|
|
length += line.length();
|
|
|
|
}
|
|
|
|
return length;
|
|
|
|
}
|