59 #include "../ifc/exception/vexception.h"
60 #include "../vgeometry/vabstractcubicbezierpath.h"
61 #include "../vgeometry/vabstractcurve.h"
62 #include "../vgeometry/vgeometrydef.h"
63 #include "../vgeometry/vgobject.h"
64 #include "../vgeometry/vpointf.h"
65 #include "../vgeometry/vspline.h"
66 #include "../vgeometry/varc.h"
67 #include "../vgeometry/vellipticalarc.h"
68 #include "../vmisc/diagnostic.h"
69 #include "../vmisc/logging.h"
70 #include "../vmisc/vabstractapplication.h"
83 QT_WARNING_DISABLE_CLANG(
"-Wmissing-prototypes")
84 QT_WARNING_DISABLE_INTEL(1418)
86 Q_LOGGING_CATEGORY(vCon, "v.container")
93 QSet<QString>
VContainer::uniqueNames = QSet<QString>();
95 #ifdef Q_COMPILER_RVALUE_REFS
97 { Swap(data);
return *
this; }
101 { std::swap(d, data.d); }
171 template <
typename key,
typename val>
174 if (obj.contains(
id))
176 return obj.value(
id);
187 if (
d->pieces->contains(
id))
189 return d->pieces->value(
id);
200 if (
d->piecePaths->contains(
id))
202 return d->piecePaths->value(
id);
228 d->pieces->insert(
id, piece);
236 d->piecePaths->insert(
id, path);
258 qCritical()<<(tr(
"Number of free id exhausted."));
283 qCDebug(vCon,
"Clearing container data.");
287 d->piecePaths->clear();
296 qCDebug(vCon,
"Clearing container data for full parse.");
300 d->piecePaths->clear();
324 if (not
d->gObjects.isEmpty())
328 for (i =
d->gObjects.begin(); i !=
d->gObjects.end(); ++i)
333 keys.append(i.key());
337 if (not keys.isEmpty())
339 for (
int i = 0; i < keys.size(); ++i)
341 d->gObjects.remove(keys.at(i));
350 if (
d->variables.size()>0)
354 d->variables.clear();
360 for (i =
d->variables.begin(); i !=
d->variables.end(); ++i)
362 if (i.value()->GetType() == type)
364 keys.append(i.key());
368 for (
int i = 0; i < keys.size(); ++i)
370 d->variables.remove(keys.at(i));
421 const GOType curveType = curve->getType();
426 throw VException(tr(
"Can't create a curve with type '%1'").arg(
static_cast<int>(curveType)));
457 for (qint32 i = 1; i <= curve->CountSubSpl(); ++i)
459 const VSpline spl = curve->GetSpline(i);
483 d->variables.remove(name);
489 d->pieces->remove(
id);
499 template <
typename key,
typename val>
512 Q_ASSERT_X(
id !=
NULL_ID, Q_FUNC_INFO,
"id == 0");
513 d->pieces->insert(
id, piece);
520 Q_ASSERT_X(
id !=
NULL_ID, Q_FUNC_INFO,
"id == 0");
521 d->piecePaths->insert(
id, path);
532 d->variables[name].clear();
533 d->variables.remove(name);
601 return d->patternUnit;
611 template <
typename T>
617 for (i =
d->variables.constBegin(); i !=
d->variables.constEnd(); ++i)
619 if (i.value()->GetType() == type)
622 map.insert(
d->trVars->VarToUser(i.key()), var);
640 for(
int i = 0; i < list.size(); ++i)
642 if (not list.at(i).startsWith(
'#'))
714 return d->pieces.data();
720 return &
d->variables;
VArc class for anticlockwise arc.
virtual ~VContainerData()
The VContainer class container of all variables.
const QMap< QString, QSharedPointer< VArcRadius > > arcRadiusesData() const
const QMap< QString, QSharedPointer< VLineAngle > > lineAnglesData() const
const QMap< QString, QSharedPointer< VCurveAngle > > curveAnglesData() const
void AddVariable(const QString &name, T *var)
static qreal height()
height return height
static void SetSize(qreal size)
SetSize set value of size.
static QSet< QString > uniqueNames
const VTranslateVars * GetTrVars() const
const QHash< quint32, VPiece > * DataPieces() const
static quint32 _id
_id current id. New object will have value +1. For empty class equal 0.
const QMap< QString, QSharedPointer< VCurveCLength > > controlPointLengthsData() const
void AddArc(const QSharedPointer< VAbstractCurve > &arc, const quint32 &id, const quint32 &parentId=null_id)
VContainer & operator=(const VContainer &data)
operator = copy constructor
static void ClearUniqueNames()
void UpdatePiece(quint32 id, const VPiece &piece)
void RemovePiece(quint32 id)
void RemoveVariable(const QString &name)
static quint32 getNextId()
getNextId generate next unique id
void AddLine(const quint32 &firstPointId, const quint32 &secondPointId)
AddLine add line to container.
static void UpdateId(quint32 newId)
UpdateId update id. If new id bigger when current save new like current.
VContainer(const VTranslateVars *trVars, const Unit *patternUnit)
VContainer create empty container.
void UpdatePiecePath(quint32 id, const VPiecePath &path)
void ClearCalculationGObjects()
static bool IsUnique(const QString &name)
void ClearVariables(const VarType &type=VarType::Unknown)
void Clear()
Clear clear data in container. Id will be 0.
void AddCurve(const QSharedPointer< VAbstractCurve > &curve, const quint32 &id, quint32 parentId=null_id)
void ClearGObjects()
ClearObject points, splines, arcs, spline paths will be cleared.
const QMap< QString, QSharedPointer< VCurveLength > > curveLengthsData() const
const QMap< QString, QSharedPointer< VLengthLine > > lineLengthsData() const
const QHash< QString, QSharedPointer< VInternalVariable > > * DataVariables() const
static qreal size()
size return size
static quint32 AddObject(QHash< key, val > &obj, val value)
AddObject add object to container.
const QSharedPointer< VGObject > GetGObject(quint32 id) const
GetGObject returns a point by id.
quint32 AddPiece(const VPiece &piece)
const val GetObject(const QHash< key, val > &obj, key id) const
GetObject return object from container.
void AddSpline(const QSharedPointer< VAbstractBezier > &curve, quint32 id, quint32 parentId=null_id)
static QStringList AllUniqueNames()
const QMap< QString, QSharedPointer< VIncrement > > variablesData() const
VPiecePath GetPiecePath(quint32 id) const
const QHash< quint32, QSharedPointer< VGObject > > * DataGObjects() const
data container with datagObjects return container of gObjects
void AddCurveWithSegments(const QSharedPointer< VAbstractCubicBezierPath > &curve, const quint32 &id, quint32 parentId=null_id)
quint32 AddGObject(VGObject *obj)
AddGObject add new GObject to container.
QSharedDataPointer< VContainerData > d
const Unit * GetPatternUnit() const
static void SetHeight(qreal height)
SetGrowth set value of growth.
static const QSharedPointer< VGObject > GetFakeGObject(quint32 id)
void Swap(VContainer &data) Q_DECL_NOTHROW
quint32 AddPiecePath(const VPiecePath &path)
void removeCustomVariable(const QString &name)
removeCustomVariable remove increment by name from increment table
static void ClearUniqueIncrementNames()
const QMap< QString, QSharedPointer< VMeasurement > > DataMeasurements() const
const QMap< QString, QSharedPointer< T > > DataVar(const VarType &type) const
VPiece GetPiece(quint32 id) const
The VExceptionBadId class for exception bad id.
The VException class parent for all exception. Could be use for abstract exception.
The VGObject class keep information graphical objects.
virtual QString name() const
name return name graphical object.
virtual void setId(const quint32 &id)
setId set id object.
VSpline class that implements the spline.
const QStringList builInFunctions