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-07-17 13:38:11 +02:00
|
|
|
|
|
2013-11-21 13:05:26 +01:00
|
|
|
|
#include <QDebug>
|
2013-12-29 17:48:57 +01:00
|
|
|
|
#include <QtAlgorithms>
|
2013-11-21 13:05:26 +01:00
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
quint32 VContainer::_id = 0;
|
2013-08-15 22:39:00 +02:00
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
VContainer::VContainer()
|
2014-03-11 21:19:13 +01:00
|
|
|
|
:_size(50), sizeName("Сг"), _height(176), heightName("P"), gObjects(QHash<quint32, VGObject *>()),
|
2014-03-16 14:17:39 +01:00
|
|
|
|
measurements(QHash<QString, VMeasurement>()), incrementTable(QHash<QString, VIncrementTableRow>()),
|
2013-12-31 09:44:54 +01:00
|
|
|
|
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
|
2014-02-25 15:40:24 +01:00
|
|
|
|
lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>())
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
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)
|
2014-03-11 21:19:13 +01:00
|
|
|
|
:_size(50), sizeName("Сг"), _height(176), heightName("P"), gObjects(QHash<quint32, VGObject *>()),
|
2014-03-16 14:17:39 +01:00
|
|
|
|
measurements(QHash<QString, VMeasurement>()), incrementTable(QHash<QString, VIncrementTableRow>()),
|
2013-12-29 17:48:57 +01:00
|
|
|
|
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
|
2014-02-25 15:40:24 +01:00
|
|
|
|
lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>())
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
|
setData(data);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-30 19:59:33 +01:00
|
|
|
|
VContainer::~VContainer()
|
|
|
|
|
{
|
|
|
|
|
qDeleteAll(gObjects);
|
|
|
|
|
gObjects.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void VContainer::setData(const VContainer &data)
|
|
|
|
|
{
|
2014-03-11 21:19:13 +01:00
|
|
|
|
_size = data.size();
|
|
|
|
|
sizeName = data.SizeName();
|
|
|
|
|
_height = data.height();
|
|
|
|
|
heightName = data.HeightName();
|
2013-12-30 12:28:33 +01:00
|
|
|
|
|
|
|
|
|
qDeleteAll(gObjects);
|
|
|
|
|
gObjects.clear();
|
2014-02-25 15:40:24 +01:00
|
|
|
|
const QHash<quint32, VGObject*> *obj = data.DataGObjects();
|
2014-01-30 14:47:41 +01:00
|
|
|
|
Q_CHECK_PTR(obj);
|
2014-02-25 15:40:24 +01:00
|
|
|
|
QHashIterator<quint32, VGObject*> i(*obj);
|
2013-12-30 12:28:33 +01:00
|
|
|
|
while (i.hasNext())
|
|
|
|
|
{
|
|
|
|
|
i.next();
|
2013-12-31 09:44:54 +01:00
|
|
|
|
switch (i.value()->getType())
|
2013-12-30 12:28:33 +01:00
|
|
|
|
{
|
2013-12-31 09:44:54 +01:00
|
|
|
|
case (GObject::Arc):
|
2013-12-30 19:59:33 +01:00
|
|
|
|
{
|
2013-12-31 09:08:14 +01:00
|
|
|
|
CopyGObject<VArc>(data, i.key());
|
2013-12-30 12:28:33 +01:00
|
|
|
|
break;
|
2013-12-30 19:59:33 +01:00
|
|
|
|
}
|
2013-12-31 09:44:54 +01:00
|
|
|
|
case (GObject::Point):
|
2013-12-30 19:59:33 +01:00
|
|
|
|
{
|
2013-12-31 09:08:14 +01:00
|
|
|
|
CopyGObject<VPointF>(data, i.key());
|
2013-12-30 12:28:33 +01:00
|
|
|
|
break;
|
2013-12-30 19:59:33 +01:00
|
|
|
|
}
|
2013-12-31 09:44:54 +01:00
|
|
|
|
case (GObject::Spline):
|
2013-12-30 19:59:33 +01:00
|
|
|
|
{
|
2013-12-31 09:08:14 +01:00
|
|
|
|
CopyGObject<VSpline>(data, i.key());
|
2013-12-30 12:28:33 +01:00
|
|
|
|
break;
|
2013-12-30 19:59:33 +01:00
|
|
|
|
}
|
2013-12-31 09:44:54 +01:00
|
|
|
|
case (GObject::SplinePath):
|
2013-12-30 19:59:33 +01:00
|
|
|
|
{
|
2013-12-31 09:08:14 +01:00
|
|
|
|
CopyGObject<VSplinePath>(data, i.key());
|
2013-12-30 12:28:33 +01:00
|
|
|
|
break;
|
2013-12-30 19:59:33 +01:00
|
|
|
|
}
|
2013-12-31 09:08:14 +01:00
|
|
|
|
default:
|
|
|
|
|
qWarning()<<"Don't know how copy this type.";
|
2013-12-30 12:28:33 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-16 14:17:39 +01:00
|
|
|
|
measurements = *data.DataMeasurements();
|
2013-08-15 22:39:00 +02:00
|
|
|
|
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
|
|
|
|
lengthSplines = *data.DataLengthSplines();
|
|
|
|
|
lengthArcs = *data.DataLengthArcs();
|
2013-08-28 10:55:11 +02:00
|
|
|
|
details = *data.DataDetails();
|
2013-08-15 22:39:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
const VGObject *VContainer::GetGObject(quint32 id)const
|
2013-11-15 18:38:29 +01:00
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
|
return GetObject(gObjects, id);
|
2013-11-15 18:38:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-13 18:48:36 +02:00
|
|
|
|
template <typename key, typename val>
|
2013-12-30 12:28:33 +01:00
|
|
|
|
const val VContainer::GetObject(const QHash<key, val> &obj, key id) const
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
|
|
|
|
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-12-29 17:48:57 +01:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 15:12:53 +01:00
|
|
|
|
const VMeasurement VContainer::GetMeasurement(const QString &name) const
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2014-03-16 14:17:39 +01:00
|
|
|
|
return GetVariable(measurements, name);
|
2013-07-17 13:38:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-30 19:59:33 +01:00
|
|
|
|
const VIncrementTableRow VContainer::GetIncrementTableRow(const QString& name) const
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2013-12-30 19:59:33 +01:00
|
|
|
|
return GetVariable(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-12-29 17:48:57 +01:00
|
|
|
|
return GetVariable(lengthLines, name);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
qreal VContainer::GetLengthArc(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2013-12-29 17:48:57 +01:00
|
|
|
|
return GetVariable(lengthArcs, name);
|
2013-10-13 17:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
qreal VContainer::GetLengthSpline(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2013-12-29 17:48:57 +01:00
|
|
|
|
return GetVariable(lengthSplines, name);
|
2013-10-13 17:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
qreal VContainer::GetLineAngle(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(name.isEmpty()==false);
|
2013-12-29 17:48:57 +01:00
|
|
|
|
return GetVariable(lineAngles, name);
|
2013-11-15 18:38:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
const VDetail VContainer::GetDetail(quint32 id) const
|
2013-11-15 18:38:29 +01:00
|
|
|
|
{
|
2013-12-30 19:59:33 +01:00
|
|
|
|
return GetVariable(details, id);
|
2013-11-15 18:38:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
quint32 VContainer::AddGObject(VGObject *obj)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
|
return AddObject(gObjects, obj);
|
2013-07-17 13:38:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
quint32 VContainer::AddDetail(VDetail detail)
|
2013-12-30 19:59:33 +01:00
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
|
quint32 id = getNextId();
|
2013-12-30 19:59:33 +01:00
|
|
|
|
details[id] = detail;
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VContainer::AddIncrementTableRow(const QString &name, VIncrementTableRow row)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-12-30 19:59:33 +01:00
|
|
|
|
incrementTable[name] = row;
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
quint32 VContainer::getNextId()
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-09-12 16:18:31 +02:00
|
|
|
|
_id++;
|
2013-07-13 12:51:31 +02:00
|
|
|
|
return _id;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
void VContainer::UpdateId(quint32 newId)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
|
|
|
|
if (newId > _id)
|
|
|
|
|
{
|
2013-09-12 16:18:31 +02:00
|
|
|
|
_id = newId;
|
2013-08-13 18:48:36 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename val>
|
2014-02-25 15:40:24 +01:00
|
|
|
|
void VContainer::UpdateObject(QHash<quint32, val> &obj, const quint32 &id, val point)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
2014-01-30 14:47:41 +01:00
|
|
|
|
Q_CHECK_PTR(point);
|
2013-12-31 09:44:54 +01:00
|
|
|
|
point->setId(id);
|
2014-01-02 16:50:01 +01:00
|
|
|
|
if (gObjects.contains(id))
|
|
|
|
|
{
|
|
|
|
|
delete gObjects.value(id);
|
|
|
|
|
gObjects.remove(id);
|
|
|
|
|
}
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
void VContainer::AddLengthArc(const quint32 &id)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
|
const VArc * arc = GeometricObject<const VArc *>(id);
|
2014-03-11 16:04:04 +01:00
|
|
|
|
lengthArcs[arc->name()] = fromPixel(arc->GetLength());
|
2013-08-13 18:48:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 21:19:13 +01:00
|
|
|
|
qreal VContainer::GetValueStandardTableRow(const QString& name) const
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2014-03-16 14:17:39 +01:00
|
|
|
|
const VMeasurement m = GetMeasurement(name);
|
2014-03-14 15:12:53 +01:00
|
|
|
|
if (patternType == Pattern::Individual)
|
|
|
|
|
{
|
|
|
|
|
return m.GetValue();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return m.GetValue(size(), height());
|
|
|
|
|
}
|
2013-07-17 13:38:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
qreal VContainer::GetValueIncrementTableRow(const QString& name) const
|
|
|
|
|
{
|
2014-03-11 21:19:13 +01:00
|
|
|
|
const VIncrementTableRow row = GetIncrementTableRow(name);
|
|
|
|
|
const qreal k_size = ( size() - 50.0 ) / 2.0;
|
|
|
|
|
const qreal k_growth = ( height() - 176.0 ) / 6.0;
|
|
|
|
|
const qreal value = row.getBase() + k_size * row.getKsize() + k_growth * row.getKgrowth();
|
2013-07-17 13:38:11 +02:00
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void VContainer::Clear()
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
_id = 0;
|
2014-03-16 14:17:39 +01:00
|
|
|
|
measurements.clear();
|
2013-07-17 13:38:11 +02:00
|
|
|
|
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();
|
2014-02-25 15:02:09 +01:00
|
|
|
|
lengthSplines.clear();
|
2014-01-02 16:50:01 +01:00
|
|
|
|
ClearGObjects();
|
2013-07-17 13:38:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-02 16:50:01 +01:00
|
|
|
|
void VContainer::ClearGObjects()
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-12-31 09:44:54 +01:00
|
|
|
|
if (gObjects.size()>0)
|
2013-12-30 12:28:33 +01:00
|
|
|
|
{
|
|
|
|
|
qDeleteAll(gObjects);
|
|
|
|
|
}
|
2013-12-29 17:48:57 +01:00
|
|
|
|
gObjects.clear();
|
2013-08-15 22:39:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-02 16:50:01 +01:00
|
|
|
|
void VContainer::ClearCalculationGObjects()
|
|
|
|
|
{
|
|
|
|
|
if (gObjects.size()>0)
|
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
|
QHashIterator<quint32, VGObject*> i(gObjects);
|
2014-01-02 16:50:01 +01:00
|
|
|
|
while (i.hasNext())
|
|
|
|
|
{
|
|
|
|
|
i.next();
|
2014-03-11 12:43:24 +01:00
|
|
|
|
if (i.value()->getMode() == Valentina::Calculation)
|
2014-01-02 16:50:01 +01:00
|
|
|
|
{
|
|
|
|
|
delete i.value();
|
|
|
|
|
gObjects.remove(i.key());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
qreal VContainer::FindVar(const QString &name, bool *ok)const
|
|
|
|
|
{
|
2014-03-11 21:19:13 +01:00
|
|
|
|
if (sizeName == name)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
|
*ok = true;
|
2014-03-11 21:19:13 +01:00
|
|
|
|
return _size;
|
|
|
|
|
}
|
|
|
|
|
if (heightName == name)
|
|
|
|
|
{
|
|
|
|
|
*ok = true;
|
|
|
|
|
return _height;
|
2013-07-17 13:38:11 +02:00
|
|
|
|
}
|
2014-03-16 14:17:39 +01:00
|
|
|
|
if (measurements.contains(name))
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
|
*ok = true;
|
2014-03-11 21:19:13 +01:00
|
|
|
|
return GetValueStandardTableRow(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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
void VContainer::AddLine(const quint32 &firstPointId, const quint32 &secondPointId)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
QString nameLine = GetNameLine(firstPointId, secondPointId);
|
2013-12-29 17:48:57 +01:00
|
|
|
|
const VPointF *first = GeometricObject<const VPointF *>(firstPointId);
|
|
|
|
|
const VPointF *second = GeometricObject<const VPointF *>(secondPointId);
|
2014-03-11 16:04:04 +01:00
|
|
|
|
AddLengthLine(nameLine, fromPixel(QLineF(first->toQPointF(), second->toQPointF()).length()));
|
2013-12-21 12:36:51 +01:00
|
|
|
|
nameLine = GetNameLineAngle(firstPointId, secondPointId);
|
2013-12-29 17:48:57 +01:00
|
|
|
|
AddLineAngle(nameLine, QLineF(first->toQPointF(), second->toQPointF()).angle());
|
2013-07-30 15:09:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-27 11:22:44 +01:00
|
|
|
|
template <typename key, typename val>
|
2014-02-25 15:40:24 +01:00
|
|
|
|
quint32 VContainer::AddObject(QHash<key, val> &obj, val value)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2014-01-30 14:47:41 +01:00
|
|
|
|
Q_CHECK_PTR(value);
|
2014-02-25 15:40:24 +01:00
|
|
|
|
quint32 id = getNextId();
|
2013-12-29 17:48:57 +01:00
|
|
|
|
value->setId(id);
|
2013-10-27 11:22:44 +01:00
|
|
|
|
obj[id] = value;
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
QString VContainer::GetNameLine(const quint32 &firstPoint, const quint32 &secondPoint) const
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
|
const VPointF *first = GeometricObject<const VPointF *>(firstPoint);
|
|
|
|
|
const VPointF *second = GeometricObject<const VPointF *>(secondPoint);
|
2013-12-21 12:36:51 +01:00
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
|
return QString("Line_%1_%2").arg(first->name(), second->name());
|
2013-07-30 15:09:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
QString VContainer::GetNameLineAngle(const quint32 &firstPoint, const quint32 &secondPoint) const
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
|
const VPointF *first = GeometricObject<const VPointF *>(firstPoint);
|
|
|
|
|
const VPointF *second = GeometricObject<const VPointF *>(secondPoint);
|
2013-12-21 12:36:51 +01:00
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
|
return QString("AngleLine_%1_%2").arg(first->name(), second->name());
|
2013-08-05 10:37:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
void VContainer::UpdateGObject(quint32 id, VGObject* obj)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
|
UpdateObject(gObjects, id, obj);
|
2013-10-27 11:22:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
|
void VContainer::UpdateDetail(quint32 id, const VDetail &detail)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-12-30 19:59:33 +01:00
|
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
|
|
|
|
details[id] = detail;
|
|
|
|
|
UpdateId(id);
|
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
|
|
|
|
}
|