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
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)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
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2013-11-15 13:41:26 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/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"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
2021-04-09 16:51:45 +02:00
|
|
|
#include <climits>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QVector>
|
|
|
|
#include <QtDebug>
|
2018-09-18 15:38:16 +02:00
|
|
|
#include <QUuid>
|
2019-04-05 14:42:22 +02:00
|
|
|
#include <QLoggingCategory>
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
#include "../ifc/exception/vexception.h"
|
|
|
|
#include "../vgeometry/vabstractcubicbezierpath.h"
|
|
|
|
#include "../vgeometry/vabstractcurve.h"
|
|
|
|
#include "../vgeometry/vgeometrydef.h"
|
|
|
|
#include "../vgeometry/vgobject.h"
|
|
|
|
#include "../vgeometry/vpointf.h"
|
|
|
|
#include "../vgeometry/vspline.h"
|
2015-06-12 10:55:44 +02:00
|
|
|
#include "../vgeometry/varc.h"
|
2016-12-17 02:40:17 +01:00
|
|
|
#include "../vgeometry/vellipticalarc.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../vmisc/diagnostic.h"
|
2015-10-15 11:49:15 +02:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "variables/varcradius.h"
|
|
|
|
#include "variables/vcurveangle.h"
|
|
|
|
#include "variables/vcurvelength.h"
|
2016-09-24 19:44:06 +02:00
|
|
|
#include "variables/vcurveclength.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "variables/vincrement.h"
|
|
|
|
#include "variables/vlineangle.h"
|
|
|
|
#include "variables/vlinelength.h"
|
|
|
|
#include "variables/vmeasurement.h"
|
|
|
|
#include "variables/vvariable.h"
|
2015-06-11 14:40:43 +02:00
|
|
|
#include "vtranslatevars.h"
|
2015-04-01 14:51:54 +02:00
|
|
|
|
2016-08-06 20:42:40 +02:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
|
|
|
QT_WARNING_DISABLE_INTEL(1418)
|
2015-10-19 15:21:06 +02:00
|
|
|
|
2014-12-25 20:04:10 +01:00
|
|
|
Q_LOGGING_CATEGORY(vCon, "v.container")
|
2013-11-21 13:05:26 +01:00
|
|
|
|
2016-08-06 20:42:40 +02:00
|
|
|
QT_WARNING_POP
|
2015-10-19 15:21:06 +02:00
|
|
|
|
2018-09-18 15:38:16 +02:00
|
|
|
QMap<QString, quint32> VContainer::_id = QMap<QString, quint32>();
|
|
|
|
QMap<QString, QSet<QString>> VContainer::uniqueNames = QMap<QString, QSet<QString>>();
|
|
|
|
QMap<QString, quint32> VContainer::copyCounter = QMap<QString, quint32>();
|
2013-08-15 22:39:00 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
|
|
|
* @brief VContainer create empty container
|
|
|
|
*/
|
2018-09-18 15:38:16 +02:00
|
|
|
VContainer::VContainer(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace)
|
|
|
|
:d(new VContainerData(trVars, patternUnit, nspace))
|
|
|
|
{
|
|
|
|
if (nspace.isEmpty())
|
|
|
|
{
|
|
|
|
qFatal("Namesapce is empty.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VContainer::_id.contains(nspace))
|
|
|
|
{
|
|
|
|
qFatal("Namespace is not unique.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not _id.contains(d->nspace))
|
|
|
|
{
|
|
|
|
_id[d->nspace] = NULL_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not uniqueNames.contains(d->nspace))
|
|
|
|
{
|
|
|
|
uniqueNames[d->nspace] = QSet<QString>();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not copyCounter.contains(d->nspace))
|
|
|
|
{
|
|
|
|
copyCounter[d->nspace] = 1;
|
|
|
|
}
|
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
|
|
|
* @brief operator = copy constructor
|
|
|
|
* @param data container
|
|
|
|
* @return copy container
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
VContainer &VContainer::operator =(const VContainer &data)
|
|
|
|
{
|
2014-07-27 14:30:28 +02:00
|
|
|
if ( &data == this )
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
2014-08-21 14:44:40 +02:00
|
|
|
d = data.d;
|
2018-09-18 15:38:16 +02:00
|
|
|
++copyCounter[d->nspace];
|
2013-08-15 22:39:00 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-12-30 12:00:57 +01:00
|
|
|
#ifdef Q_COMPILER_RVALUE_REFS
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-12-30 16:13:18 +01:00
|
|
|
VContainer::VContainer(const VContainer &&data) Q_DECL_NOTHROW
|
|
|
|
:d(data.d)
|
|
|
|
{}
|
2019-12-30 12:00:57 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2019-12-30 16:13:18 +01:00
|
|
|
VContainer &VContainer::operator=(VContainer &&data) Q_DECL_NOTHROW
|
2019-12-30 12:00:57 +01:00
|
|
|
{
|
|
|
|
std::swap(d, data.d);
|
2019-12-30 16:13:18 +01:00
|
|
|
return *this;
|
2019-12-30 12:00:57 +01:00
|
|
|
}
|
2019-12-30 16:13:18 +01:00
|
|
|
#endif
|
2019-12-30 12:00:57 +01:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
|
|
|
* @brief VContainer create container from another container
|
|
|
|
* @param data container
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
VContainer::VContainer(const VContainer &data)
|
2014-08-21 14:44:40 +02:00
|
|
|
:d(data.d)
|
2018-09-18 15:38:16 +02:00
|
|
|
{
|
|
|
|
++copyCounter[d->nspace];
|
|
|
|
}
|
2013-08-29 12:31:50 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-12-30 19:59:33 +01:00
|
|
|
VContainer::~VContainer()
|
2017-10-26 11:54:08 +02:00
|
|
|
{}
|
2013-12-30 19:59:33 +01:00
|
|
|
|
2018-09-18 15:38:16 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VContainer::UniqueNamespace()
|
|
|
|
{
|
|
|
|
QString candidate;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
candidate = QUuid::createUuid().toString();
|
|
|
|
}
|
2020-10-16 11:02:32 +02:00
|
|
|
while(_id.contains(candidate));
|
2018-09-18 15:38:16 +02:00
|
|
|
|
|
|
|
return candidate;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::ClearNamespace(const QString &nspace)
|
|
|
|
{
|
|
|
|
_id.remove(nspace);
|
|
|
|
uniqueNames.remove(nspace);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
|
|
|
* @brief GetGObject returns a point by id
|
|
|
|
* @param id id of point
|
|
|
|
* @return point
|
|
|
|
*/
|
2014-05-02 10:09:10 +02:00
|
|
|
// cppcheck-suppress unusedFunction
|
2017-10-26 11:54:08 +02:00
|
|
|
const QSharedPointer<VGObject> VContainer::GetGObject(quint32 id) const
|
2013-11-15 18:38:29 +01:00
|
|
|
{
|
2017-10-26 11:54:08 +02:00
|
|
|
if (d->calculationObjects.contains(id))
|
|
|
|
{
|
|
|
|
return d->calculationObjects.value(id);
|
|
|
|
}
|
|
|
|
else if (d->modelingObjects->contains(id))
|
|
|
|
{
|
|
|
|
return d->modelingObjects->value(id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw VExceptionBadId(tr("Can't find object"), id);
|
|
|
|
}
|
2013-11-15 18:38:29 +01:00
|
|
|
}
|
|
|
|
|
2015-06-20 18:14:04 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-10-12 13:52:48 +02:00
|
|
|
const QSharedPointer<VGObject> VContainer::GetFakeGObject(quint32 id)
|
2015-06-20 18:14:04 +02:00
|
|
|
{
|
2022-02-05 11:22:49 +01:00
|
|
|
auto *obj = new VGObject();
|
2015-06-20 18:14:04 +02:00
|
|
|
obj->setId(id);
|
|
|
|
QSharedPointer<VGObject> pointer(obj);
|
|
|
|
return pointer;
|
|
|
|
}
|
|
|
|
|
2016-11-08 11:52:07 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPiece VContainer::GetPiece(quint32 id) const
|
|
|
|
{
|
|
|
|
if (d->pieces->contains(id))
|
|
|
|
{
|
|
|
|
return d->pieces->value(id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw VExceptionBadId(tr("Can't find object"), id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-24 20:30:26 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPiecePath VContainer::GetPiecePath(quint32 id) const
|
|
|
|
{
|
|
|
|
if (d->piecePaths->contains(id))
|
|
|
|
{
|
|
|
|
return d->piecePaths->value(id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw VExceptionBadId(tr("Can't find object"), id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-07-26 19:00:24 +02:00
|
|
|
quint32 VContainer::GetPieceForPiecePath(quint32 id) const
|
|
|
|
{
|
|
|
|
auto i = d->pieces->constBegin();
|
|
|
|
while (i != d->pieces->constEnd())
|
|
|
|
{
|
|
|
|
if (i.value().GetInternalPaths().contains(id))
|
|
|
|
{
|
|
|
|
return i.key();
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL_ID;
|
|
|
|
}
|
|
|
|
|
2020-11-04 16:58:06 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-11-07 16:43:49 +01:00
|
|
|
void VContainer::RegisterUniqueName(VGObject *obj) const
|
2020-11-04 16:58:06 +01:00
|
|
|
{
|
|
|
|
SCASSERT(obj != nullptr)
|
|
|
|
QSharedPointer<VGObject> pointer(obj);
|
|
|
|
RegisterUniqueName(pointer);
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:14:21 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-11-07 16:43:49 +01:00
|
|
|
void VContainer::RegisterUniqueName(const QSharedPointer<VGObject> &obj) const
|
2020-11-04 17:14:21 +01:00
|
|
|
{
|
|
|
|
SCASSERT(not obj.isNull())
|
|
|
|
|
|
|
|
uniqueNames[d->nspace].insert(obj->name());
|
|
|
|
|
|
|
|
if (not obj->GetAlias().isEmpty())
|
|
|
|
{
|
|
|
|
uniqueNames[d->nspace].insert(obj->GetAlias());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-26 19:00:24 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
2014-06-02 09:43:27 +02:00
|
|
|
* @brief AddGObject add new GObject to container
|
|
|
|
* @param obj new object
|
|
|
|
* @return return id of new object in container
|
2014-05-21 10:51:16 +02:00
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 VContainer::AddGObject(VGObject *obj)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(obj != nullptr)
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<VGObject> pointer(obj);
|
2017-10-15 11:25:20 +02:00
|
|
|
return AddGObject(pointer);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 VContainer::AddGObject(const QSharedPointer<VGObject> &obj)
|
|
|
|
{
|
|
|
|
SCASSERT(not obj.isNull())
|
2017-10-26 11:54:08 +02:00
|
|
|
|
|
|
|
if (obj->getMode() == Draw::Layout)
|
|
|
|
{
|
|
|
|
qWarning("Can't add an object with mode 'Layout'");
|
|
|
|
return NULL_ID;
|
|
|
|
}
|
|
|
|
|
2020-11-04 17:14:21 +01:00
|
|
|
RegisterUniqueName(obj);
|
2020-11-04 16:36:40 +01:00
|
|
|
|
2017-10-26 11:54:08 +02:00
|
|
|
const quint32 id = getNextId();
|
|
|
|
obj->setId(id);
|
|
|
|
|
|
|
|
if (obj->getMode() == Draw::Calculation)
|
|
|
|
{
|
|
|
|
d->calculationObjects.insert(id, obj);
|
|
|
|
}
|
|
|
|
else if (obj->getMode() == Draw::Modeling)
|
|
|
|
{
|
|
|
|
d->modelingObjects->insert(id, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
|
|
|
|
2016-11-08 11:52:07 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 VContainer::AddPiece(const VPiece &detail)
|
|
|
|
{
|
|
|
|
const quint32 id = getNextId();
|
|
|
|
d->pieces->insert(id, detail);
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2016-11-24 20:30:26 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 VContainer::AddPiecePath(const VPiecePath &path)
|
|
|
|
{
|
|
|
|
const quint32 id = getNextId();
|
|
|
|
d->piecePaths->insert(id, path);
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2015-06-04 15:58:38 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-09-18 15:38:16 +02:00
|
|
|
quint32 VContainer::getId() const
|
2015-06-04 15:58:38 +02:00
|
|
|
{
|
2018-09-18 15:38:16 +02:00
|
|
|
return _id.value(d->nspace);
|
2015-06-04 15:58:38 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
|
|
|
* @brief getNextId generate next unique id
|
|
|
|
* @return next unique id
|
|
|
|
*/
|
2018-09-18 15:38:16 +02:00
|
|
|
quint32 VContainer::getNextId() const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-03-19 15:54:27 +01:00
|
|
|
//TODO. Current count of ids are very big and allow us save time before someone will reach its max value.
|
|
|
|
//Better way, of cource, is to seek free ids inside the set of values and reuse them.
|
|
|
|
//But for now better to keep it as it is now.
|
2018-09-18 15:38:16 +02:00
|
|
|
if (_id.value(d->nspace) == UINT_MAX)
|
2016-03-19 15:54:27 +01:00
|
|
|
{
|
|
|
|
qCritical()<<(tr("Number of free id exhausted."));
|
|
|
|
}
|
2018-09-18 15:38:16 +02:00
|
|
|
_id[d->nspace]++;
|
|
|
|
return _id.value(d->nspace);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::UpdateId(quint32 newId, const QString &nspace)
|
|
|
|
{
|
|
|
|
if (_id.contains(nspace))
|
|
|
|
{
|
|
|
|
if (newId > _id.value(nspace))
|
|
|
|
{
|
|
|
|
_id[nspace] = newId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw VException(QStringLiteral("Unknown namespace"));
|
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
|
|
|
* @brief UpdateId update id. If new id bigger when current save new like current.
|
|
|
|
* @param newId id
|
|
|
|
*/
|
2018-09-18 15:38:16 +02:00
|
|
|
void VContainer::UpdateId(quint32 newId) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2018-09-18 15:38:16 +02:00
|
|
|
VContainer::UpdateId(newId, d->nspace);
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
|
|
|
* @brief Clear clear data in container. Id will be 0.
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void VContainer::Clear()
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
qCDebug(vCon, "Clearing container data.");
|
2018-09-18 15:38:16 +02:00
|
|
|
_id[d->nspace] = NULL_ID;
|
2014-07-29 13:28:18 +02:00
|
|
|
|
2017-01-18 09:15:51 +01:00
|
|
|
d->pieces->clear();
|
|
|
|
d->piecePaths->clear();
|
2014-07-29 13:28:18 +02:00
|
|
|
ClearVariables();
|
2014-01-02 16:50:01 +01:00
|
|
|
ClearGObjects();
|
2014-09-04 07:20:41 +02:00
|
|
|
ClearUniqueNames();
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
|
|
|
|
2015-08-26 20:14:47 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::ClearForFullParse()
|
|
|
|
{
|
|
|
|
qCDebug(vCon, "Clearing container data for full parse.");
|
2018-09-18 15:38:16 +02:00
|
|
|
_id[d->nspace] = NULL_ID;
|
2015-08-26 20:14:47 +02:00
|
|
|
|
2016-11-16 08:15:16 +01:00
|
|
|
d->pieces->clear();
|
2016-11-24 20:30:26 +01:00
|
|
|
d->piecePaths->clear();
|
2019-01-16 15:24:41 +01:00
|
|
|
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 9, "Check that you used all types");
|
2018-01-20 13:01:35 +01:00
|
|
|
ClearVariables(QVector<VarType>({VarType::Increment,
|
2019-01-16 15:24:41 +01:00
|
|
|
VarType::IncrementSeparator,
|
2018-01-20 13:01:35 +01:00
|
|
|
VarType::LineAngle,
|
|
|
|
VarType::LineLength,
|
|
|
|
VarType::CurveLength,
|
|
|
|
VarType::CurveCLength,
|
|
|
|
VarType::ArcRadius,
|
|
|
|
VarType::CurveAngle}));
|
2015-08-26 20:14:47 +02:00
|
|
|
ClearGObjects();
|
|
|
|
ClearUniqueNames();
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
|
|
|
* @brief ClearObject points, splines, arcs, spline paths will be cleared.
|
|
|
|
*/
|
2014-01-02 16:50:01 +01:00
|
|
|
void VContainer::ClearGObjects()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2017-10-26 11:54:08 +02:00
|
|
|
d->calculationObjects.clear();
|
|
|
|
d->modelingObjects->clear();
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-01-02 16:50:01 +01:00
|
|
|
void VContainer::ClearCalculationGObjects()
|
|
|
|
{
|
2017-10-26 11:54:08 +02:00
|
|
|
d->calculationObjects.clear();
|
2014-01-02 16:50:01 +01:00
|
|
|
}
|
|
|
|
|
2014-07-29 13:28:18 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::ClearVariables(const VarType &type)
|
|
|
|
{
|
2018-01-20 13:01:35 +01:00
|
|
|
ClearVariables(QVector<VarType>({type}));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::ClearVariables(const QVector<VarType> &types)
|
|
|
|
{
|
|
|
|
if (not d->variables.isEmpty()) //-V807
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2018-01-20 13:01:35 +01:00
|
|
|
if (types.isEmpty() || types.contains(VarType::Unknown))
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
d->variables.clear();
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QHash<QString, QSharedPointer<VInternalVariable> >::iterator i;
|
2018-01-20 13:01:35 +01:00
|
|
|
for (i = d->variables.begin(); i != d->variables.end();)
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2018-01-20 13:01:35 +01:00
|
|
|
if (types.contains(i.value()->GetType()))
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2018-01-20 13:01:35 +01:00
|
|
|
i = d->variables.erase(i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++i;
|
2014-08-21 14:44:40 +02:00
|
|
|
}
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
|
|
|
* @brief AddLine add line to container
|
|
|
|
* @param firstPointId id of first point of line
|
|
|
|
* @param secondPointId id of second point of line
|
|
|
|
*/
|
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
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VPointF> first = GeometricObject<VPointF>(firstPointId);
|
|
|
|
const QSharedPointer<VPointF> second = GeometricObject<VPointF>(secondPointId);
|
2014-07-29 13:28:18 +02:00
|
|
|
|
2019-11-24 12:09:16 +01:00
|
|
|
AddVariable(new VLengthLine(first.data(), firstPointId, second.data(), secondPointId, *GetPatternUnit()));
|
|
|
|
AddVariable(new VLineAngle(first.data(), firstPointId, second.data(), secondPointId));
|
2013-07-30 15:09:34 +02:00
|
|
|
}
|
|
|
|
|
2015-05-31 11:17:09 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-12-20 12:04:56 +01:00
|
|
|
void VContainer::AddArc(const QSharedPointer<VAbstractCurve> &arc, const quint32 &id, const quint32 &parentId)
|
2015-05-31 11:17:09 +02:00
|
|
|
{
|
2016-04-01 21:34:57 +02:00
|
|
|
AddCurve(arc, id, parentId);
|
2015-06-02 15:53:19 +02:00
|
|
|
|
2016-12-20 12:04:56 +01:00
|
|
|
if (arc->getType() == GOType::Arc)
|
|
|
|
{
|
|
|
|
const QSharedPointer<VArc> casted = arc.staticCast<VArc>();
|
2016-04-01 21:34:57 +02:00
|
|
|
|
2019-11-24 12:09:16 +01:00
|
|
|
AddVariable(new VArcRadius(id, parentId, casted.data(), *GetPatternUnit()));
|
2016-12-20 12:04:56 +01:00
|
|
|
}
|
|
|
|
else if (arc->getType() == GOType::EllipticalArc)
|
|
|
|
{
|
|
|
|
const QSharedPointer<VEllipticalArc> casted = arc.staticCast<VEllipticalArc>();
|
2016-12-17 02:40:17 +01:00
|
|
|
|
2019-11-24 12:09:16 +01:00
|
|
|
AddVariable(new VArcRadius(id, parentId, casted.data(), 1, *GetPatternUnit()));
|
|
|
|
AddVariable(new VArcRadius(id, parentId, casted.data(), 2, *GetPatternUnit()));
|
|
|
|
AddVariable(new VEllipticalArcRotation(id, parentId, casted.data()));
|
2016-12-20 12:04:56 +01:00
|
|
|
}
|
2016-04-01 21:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-04-01 23:15:04 +02:00
|
|
|
void VContainer::AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id, quint32 parentId)
|
2016-04-01 21:34:57 +02:00
|
|
|
{
|
|
|
|
const GOType curveType = curve->getType();
|
|
|
|
if (curveType != GOType::Spline && curveType != GOType::SplinePath &&
|
|
|
|
curveType != GOType::CubicBezier && curveType != GOType::CubicBezierPath &&
|
2016-12-17 02:40:17 +01:00
|
|
|
curveType != GOType::Arc && curveType != GOType::EllipticalArc)
|
2016-04-01 21:34:57 +02:00
|
|
|
{
|
|
|
|
throw VException(tr("Can't create a curve with type '%1'").arg(static_cast<int>(curveType)));
|
|
|
|
}
|
|
|
|
|
2019-11-24 12:09:16 +01:00
|
|
|
AddVariable(new VCurveLength(id, parentId, curve.data(), *GetPatternUnit()));
|
|
|
|
AddVariable(new VCurveAngle(id, parentId, curve.data(), CurveAngle::StartAngle));
|
|
|
|
AddVariable(new VCurveAngle(id, parentId, curve.data(), CurveAngle::EndAngle));
|
2015-05-31 11:17:09 +02:00
|
|
|
}
|
|
|
|
|
2016-09-24 19:44:06 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::AddSpline(const QSharedPointer<VAbstractBezier> &curve, quint32 id, quint32 parentId)
|
|
|
|
{
|
|
|
|
AddCurve(curve, id, parentId);
|
2019-11-24 12:09:16 +01:00
|
|
|
AddVariable(new VCurveCLength(id, parentId, curve.data(), CurveCLength::C1, *GetPatternUnit()));
|
|
|
|
AddVariable(new VCurveCLength(id, parentId, curve.data(), CurveCLength::C2, *GetPatternUnit()));
|
2016-09-24 19:44:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-04-01 23:15:04 +02:00
|
|
|
void VContainer::AddCurveWithSegments(const QSharedPointer<VAbstractCubicBezierPath> &curve, const quint32 &id,
|
|
|
|
quint32 parentId)
|
|
|
|
{
|
2016-09-24 19:44:06 +02:00
|
|
|
AddSpline(curve, id, parentId);
|
2016-04-01 23:15:04 +02:00
|
|
|
|
|
|
|
for (qint32 i = 1; i <= curve->CountSubSpl(); ++i)
|
|
|
|
{
|
|
|
|
const VSpline spl = curve->GetSpline(i);
|
|
|
|
|
2020-11-04 14:26:22 +01:00
|
|
|
AddVariable(new VCurveLength(id, parentId, curve.data(), spl, *GetPatternUnit(), i));
|
|
|
|
AddVariable(new VCurveAngle(id, parentId, curve.data(), spl, CurveAngle::StartAngle, i));
|
|
|
|
AddVariable(new VCurveAngle(id, parentId, curve.data(), spl, CurveAngle::EndAngle, i));
|
|
|
|
AddVariable(new VCurveCLength(id, parentId, curve.data(), spl, CurveCLength::C1, *GetPatternUnit(), i));
|
|
|
|
AddVariable(new VCurveCLength(id, parentId, curve.data(), spl, CurveCLength::C2, *GetPatternUnit(), i));
|
2016-04-01 23:15:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-23 19:20:21 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::RemoveVariable(const QString &name)
|
|
|
|
{
|
|
|
|
d->variables.remove(name);
|
|
|
|
}
|
|
|
|
|
2017-01-18 11:22:02 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::RemovePiece(quint32 id)
|
|
|
|
{
|
|
|
|
d->pieces->remove(id);
|
|
|
|
}
|
|
|
|
|
2016-11-08 11:52:07 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::UpdatePiece(quint32 id, const VPiece &detail)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
|
|
|
|
d->pieces->insert(id, detail);
|
|
|
|
UpdateId(id);
|
|
|
|
}
|
|
|
|
|
2016-11-24 20:30:26 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::UpdatePiecePath(quint32 id, const VPiecePath &path)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
|
|
|
|
d->piecePaths->insert(id, path);
|
|
|
|
UpdateId(id);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-05-21 10:51:16 +02:00
|
|
|
/**
|
2014-07-29 13:28:18 +02:00
|
|
|
* @brief RemoveIncrement remove increment by name from increment table
|
|
|
|
* @param name name of existing increment
|
2014-05-21 10:51:16 +02:00
|
|
|
*/
|
2014-07-29 13:28:18 +02:00
|
|
|
void VContainer::RemoveIncrement(const QString &name)
|
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
d->variables[name].clear();
|
|
|
|
d->variables.remove(name);
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-08-21 14:44:40 +02:00
|
|
|
const QMap<QString, QSharedPointer<VMeasurement> > VContainer::DataMeasurements() const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-07-29 14:19:11 +02:00
|
|
|
return DataVar<VMeasurement>(VarType::Measurement);
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-08-21 14:44:40 +02:00
|
|
|
const QMap<QString, QSharedPointer<VIncrement> > VContainer::DataIncrements() const
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2014-07-29 14:19:11 +02:00
|
|
|
return DataVar<VIncrement>(VarType::Increment);
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
|
|
|
|
2019-01-16 15:24:41 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const QMap<QString, QSharedPointer<VIncrement> > VContainer::DataIncrementsWithSeparators() const
|
|
|
|
{
|
|
|
|
QMap<QString, QSharedPointer<VIncrement> > increments = DataVar<VIncrement>(VarType::Increment);
|
|
|
|
QMap<QString, QSharedPointer<VIncrement> > separators = DataVar<VIncrement>(VarType::IncrementSeparator);
|
|
|
|
|
|
|
|
QMap<QString, QSharedPointer<VIncrement>>::const_iterator i = separators.constBegin();
|
|
|
|
while (i != separators.constEnd())
|
|
|
|
{
|
|
|
|
increments.insert(i.key(), i.value());
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return increments;
|
|
|
|
}
|
|
|
|
|
2014-07-29 13:28:18 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-08-21 14:44:40 +02:00
|
|
|
const QMap<QString, QSharedPointer<VLengthLine> > VContainer::DataLengthLines() const
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2014-08-15 19:27:30 +02:00
|
|
|
return DataVar<VLengthLine>(VarType::LineLength);
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-04-01 21:34:57 +02:00
|
|
|
const QMap<QString, QSharedPointer<VCurveLength> > VContainer::DataLengthCurves() const
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2016-04-01 21:34:57 +02:00
|
|
|
return DataVar<VCurveLength>(VarType::CurveLength);
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
|
|
|
|
2016-09-24 19:44:06 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const QMap<QString, QSharedPointer<VCurveCLength> > VContainer::DataCurvesCLength() const
|
|
|
|
{
|
|
|
|
return DataVar<VCurveCLength>(VarType::CurveCLength);
|
|
|
|
}
|
|
|
|
|
2014-07-29 13:28:18 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-08-21 14:44:40 +02:00
|
|
|
const QMap<QString, QSharedPointer<VLineAngle> > VContainer::DataAngleLines() const
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2014-07-29 14:19:11 +02:00
|
|
|
return DataVar<VLineAngle>(VarType::LineAngle);
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
|
|
|
|
2015-05-31 11:17:09 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const QMap<QString, QSharedPointer<VArcRadius> > VContainer::DataRadiusesArcs() const
|
|
|
|
{
|
|
|
|
return DataVar<VArcRadius>(VarType::ArcRadius);
|
|
|
|
}
|
|
|
|
|
2015-06-02 15:53:19 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-04-01 21:34:57 +02:00
|
|
|
const QMap<QString, QSharedPointer<VCurveAngle> > VContainer::DataAnglesCurves() const
|
2015-06-02 15:53:19 +02:00
|
|
|
{
|
2016-04-01 21:34:57 +02:00
|
|
|
return DataVar<VCurveAngle>(VarType::CurveAngle);
|
2015-06-02 15:53:19 +02:00
|
|
|
}
|
|
|
|
|
2014-09-04 07:20:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-09-18 15:38:16 +02:00
|
|
|
bool VContainer::IsUnique(const QString &name) const
|
|
|
|
{
|
|
|
|
return VContainer::IsUnique(name, d->nspace);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VContainer::IsUnique(const QString &name, const QString &nspace)
|
2014-09-04 07:20:41 +02:00
|
|
|
{
|
2018-09-18 15:38:16 +02:00
|
|
|
if (uniqueNames.contains(nspace))
|
|
|
|
{
|
|
|
|
return (!uniqueNames.value(nspace).contains(name) && !builInFunctions.contains(name));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw VException(QStringLiteral("Unknown namespace"));
|
|
|
|
}
|
2014-09-04 07:20:41 +02:00
|
|
|
}
|
|
|
|
|
2016-05-18 14:35:07 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-09-18 15:38:16 +02:00
|
|
|
QStringList VContainer::AllUniqueNames() const
|
2016-05-18 14:35:07 +02:00
|
|
|
{
|
2018-09-18 15:38:16 +02:00
|
|
|
return AllUniqueNames(d->nspace);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList VContainer::AllUniqueNames(const QString &nspace)
|
|
|
|
{
|
|
|
|
if (uniqueNames.contains(nspace))
|
|
|
|
{
|
|
|
|
QStringList names = builInFunctions;
|
2020-01-06 19:10:09 +01:00
|
|
|
names.append(uniqueNames.value(nspace).values());
|
2018-09-18 15:38:16 +02:00
|
|
|
return names;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw VException(QStringLiteral("Unknown namespace"));
|
|
|
|
}
|
2016-05-18 14:35:07 +02:00
|
|
|
}
|
|
|
|
|
2015-06-11 19:36:17 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const Unit *VContainer::GetPatternUnit() const
|
|
|
|
{
|
|
|
|
return d->patternUnit;
|
|
|
|
}
|
|
|
|
|
2015-08-17 14:36:55 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const VTranslateVars *VContainer::GetTrVars() const
|
|
|
|
{
|
|
|
|
return d->trVars;
|
|
|
|
}
|
|
|
|
|
2014-07-29 13:28:18 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
2014-08-21 14:44:40 +02:00
|
|
|
const QMap<QString, QSharedPointer<T> > VContainer::DataVar(const VarType &type) const
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QMap<QString, QSharedPointer<T> > map;
|
2014-07-29 13:28:18 +02:00
|
|
|
//Sorting QHash by id
|
2014-08-21 14:44:40 +02:00
|
|
|
QHash<QString, QSharedPointer<VInternalVariable> >::const_iterator i;
|
|
|
|
for (i = d->variables.constBegin(); i != d->variables.constEnd(); ++i)
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2014-09-10 19:57:08 +02:00
|
|
|
if (i.value()->GetType() == type)
|
2014-07-29 13:28:18 +02:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
QSharedPointer<T> var = GetVariable<T>(i.key());
|
2015-06-11 14:40:43 +02:00
|
|
|
map.insert(d->trVars->VarToUser(i.key()), var);
|
2014-07-29 13:28:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return map;
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
2014-08-21 14:44:40 +02:00
|
|
|
|
2014-09-04 07:20:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-09-18 15:38:16 +02:00
|
|
|
void VContainer::ClearUniqueNames() const
|
2014-09-04 07:20:41 +02:00
|
|
|
{
|
2018-09-18 15:38:16 +02:00
|
|
|
uniqueNames[d->nspace].clear();
|
2014-09-04 07:20:41 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 15:52:57 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2018-09-18 15:38:16 +02:00
|
|
|
void VContainer::ClearUniqueIncrementNames() const
|
2017-07-23 15:52:57 +02:00
|
|
|
{
|
2020-01-06 19:10:09 +01:00
|
|
|
const QList<QString> list = uniqueNames.value(d->nspace).values();
|
2017-07-23 15:52:57 +02:00
|
|
|
ClearUniqueNames();
|
|
|
|
|
2018-04-02 19:38:56 +02:00
|
|
|
for(auto &name : list)
|
2017-07-23 15:52:57 +02:00
|
|
|
{
|
2018-04-02 19:38:56 +02:00
|
|
|
if (not name.startsWith('#'))
|
2017-07-23 15:52:57 +02:00
|
|
|
{
|
2018-09-18 15:38:16 +02:00
|
|
|
uniqueNames[d->nspace].insert(name);
|
2020-01-09 14:14:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VContainer::ClearExceptUniqueIncrementNames() const
|
|
|
|
{
|
|
|
|
const QList<QString> list = uniqueNames.value(d->nspace).values();
|
|
|
|
ClearUniqueNames();
|
|
|
|
|
|
|
|
for(auto &name : list)
|
|
|
|
{
|
|
|
|
if (name.startsWith('#'))
|
|
|
|
{
|
|
|
|
uniqueNames[d->nspace].insert(name);
|
2017-07-23 15:52:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-21 14:44:40 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief data container with datagObjects return container of gObjects
|
|
|
|
* @return pointer on container of gObjects
|
|
|
|
*/
|
2017-10-26 11:54:08 +02:00
|
|
|
const QHash<quint32, QSharedPointer<VGObject> > *VContainer::CalculationGObjects() const
|
2014-08-21 14:44:40 +02:00
|
|
|
{
|
2017-10-26 11:54:08 +02:00
|
|
|
return &d->calculationObjects;
|
2014-08-21 14:44:40 +02:00
|
|
|
}
|
|
|
|
|
2016-11-08 11:52:07 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const QHash<quint32, VPiece> *VContainer::DataPieces() const
|
|
|
|
{
|
|
|
|
return d->pieces.data();
|
|
|
|
}
|
|
|
|
|
2014-08-21 14:44:40 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
const QHash<QString, QSharedPointer<VInternalVariable> > *VContainer::DataVariables() const
|
|
|
|
{
|
|
|
|
return &d->variables;
|
|
|
|
}
|
2014-09-11 18:52:02 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VContainerData::~VContainerData()
|
2018-09-18 15:38:16 +02:00
|
|
|
{
|
2020-01-06 19:10:09 +01:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
|
|
|
if (ref.loadRelaxed() == 0)
|
|
|
|
#else
|
2018-09-18 16:24:00 +02:00
|
|
|
if (ref.load() == 0)
|
2020-01-06 19:10:09 +01:00
|
|
|
#endif
|
2018-09-18 15:38:16 +02:00
|
|
|
{
|
|
|
|
--VContainer::copyCounter[nspace];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VContainer::copyCounter.value(nspace) == 0)
|
|
|
|
{
|
|
|
|
VContainer::ClearNamespace(nspace);
|
|
|
|
}
|
|
|
|
}
|