/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see .
**
****************************************************************************/
#ifndef VCONTAINER_H
#define VCONTAINER_H
#include
#include "vstandarttablecell.h"
#include "vincrementtablerow.h"
#include "geometry/varc.h"
#include "geometry/vsplinepath.h"
#include "geometry/vdetail.h"
#include "widgets/vitem.h"
#include
/**
* @brief The VContainer class
*/
class VContainer
{
Q_DECLARE_TR_FUNCTIONS(VContainer)
public:
/**
* @brief VContainer
*/
VContainer();
VContainer &operator=(const VContainer &data);
VContainer(const VContainer &data);
void setData(const VContainer &data);
/**
* @brief GetPoint
* @param id
* @return
*/
VPointF GetPoint(qint64 id) const;
VPointF GetModelingPoint(qint64 id) const;
VStandartTableCell GetStandartTableCell(const QString& name) const;
VIncrementTableRow GetIncrementTableRow(const QString& name) const;
qreal GetLine(const QString &name) const;
qreal GetLengthArc(const QString &name) const;
qreal GetLengthSpline(const QString &name) const;
qreal GetLineAngle(const QString &name) const;
VSpline GetSpline(qint64 id) const;
VSpline GetModelingSpline(qint64 id) const;
VArc GetArc(qint64 id) const;
VArc GetModelingArc(qint64 id) const;
VSplinePath GetSplinePath(qint64 id) const;
VSplinePath GetModelingSplinePath(qint64 id) const;
VDetail GetDetail(qint64 id) const;
static qint64 getId();
qint64 AddPoint(const VPointF& point);
qint64 AddModelingPoint(const VPointF& point);
qint64 AddDetail(const VDetail& detail);
void AddStandartTableCell(const QString& name, const VStandartTableCell& cell);
void AddIncrementTableRow(const QString& name, const VIncrementTableRow &cell);
void AddLengthLine(const QString &name, const qreal &value);
void AddLengthSpline(const QString &name, const qreal &value);
void AddLengthArc(const qint64 ¢er, const qint64 &id);
void AddLengthArc(const QString &name, const qreal &value);
void AddLineAngle(const QString &name, const qreal &value);
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId,
Draw::Draws mode = Draw::Calculation);
qint64 AddSpline(const VSpline& spl);
qint64 AddModelingSpline(const VSpline& spl);
qint64 AddSplinePath(const VSplinePath& splPath);
qint64 AddModelingSplinePath(const VSplinePath& splPath);
qint64 AddArc(const VArc& arc);
qint64 AddModelingArc(const VArc& arc);
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Draws mode = Draw::Calculation) const;
QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Draws mode = Draw::Calculation) const;
QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint,
Draw::Draws mode = Draw::Calculation) const;
QString GetNameSplinePath(const VSplinePath &path,
Draw::Draws mode = Draw::Calculation) const;
QString GetNameArc(const qint64 ¢er, const qint64 &id,
Draw::Draws mode = Draw::Calculation) const;
void UpdatePoint(qint64 id, const VPointF& point);
void UpdateModelingPoint(qint64 id, const VPointF& point);
void UpdateDetail(qint64 id, const VDetail& detail);
void UpdateSpline(qint64 id, const VSpline& spl);
void UpdateModelingSpline(qint64 id, const VSpline& spl);
void UpdateSplinePath(qint64 id, const VSplinePath& splPath);
void UpdateModelingSplinePath(qint64 id, const VSplinePath& splPath);
void UpdateArc(qint64 id, const VArc& arc);
void UpdateModelingArc(qint64 id, const VArc& arc);
void UpdateStandartTableCell(const QString& name, const VStandartTableCell& cell);
void UpdateIncrementTableRow(const QString& name, const VIncrementTableRow& cell);
qreal GetValueStandartTableCell(const QString& name) const;
qreal GetValueIncrementTableRow(const QString& name) const;
void Clear();
void ClearObject();
void ClearIncrementTable();
void ClearLengthLines();
void ClearLengthSplines();
void ClearLengthArcs();
void ClearLineAngles();
void SetSize(qint32 size);
void SetGrowth(qint32 growth);
qint32 size() const;
qint32 growth() const;
qreal FindVar(const QString& name, bool *ok)const;
bool IncrementTableContains(const QString& name);
static qint64 getNextId();
void RemoveIncrementTableRow(const QString& name);
const QHash *DataPoints() const;
const QHash *DataModelingPoints() const;
const QHash *DataSplines() const;
const QHash *DataModelingSplines() const;
const QHash *DataArcs() const;
const QHash *DataModelingArcs() const;
const QHash *DataBase() const;
const QHash *DataStandartTable() const;
const QHash *DataIncrementTable() const;
const QHash *DataLengthLines() const;
const QHash *DataLengthSplines() const;
const QHash *DataLengthArcs() const;
const QHash *DataLineAngles() const;
const QHash *DataSplinePaths() const;
const QHash *DataModelingSplinePaths() const;
const QHash *DataDetails() const;
static void UpdateId(qint64 newId);
QPainterPath ContourPath(qint64 idDetail) const;
QPainterPath Equidistant(QVector points, const Detail::Equidistant &eqv,
const qreal &width)const;
static QLineF ParallelLine(const QLineF &line, qreal width );
static QPointF SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width);
QVector EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width)const;
QVector CheckLoops(const QVector &points) const;
void PrepareDetails(QVector & list)const;
private:
static qint64 _id;
QHash base;
QHash points;
QHash modelingPoints;
QHash standartTable;
QHash incrementTable;
QHash lengthLines;
QHash lineAngles;
QHash splines;
QHash modelingSplines;
QHash lengthSplines;
QHash arcs;
QHash modelingArcs;
QHash lengthArcs;
QHash splinePaths;
QHash modelingSplinePaths;
QHash details;
template static val GetObject(const QHash &obj, key id);
template static void UpdateObject(QHash &obj, const qint64 &id,
const val& point);
template static qint64 AddObject(QHash &obj, const val& value);
void CreateManTableIGroup ();
QVector GetReversePoint(const QVector &points)const;
qreal GetLengthContour(const QVector &contour, const QVector &newPoints)const;
};
#endif // VCONTAINER_H