2015-07-14 19:22:31 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vmeasurements.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 14 7, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-07-14 19:22:31 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-07-14 19:22:31 +02:00
|
|
|
**
|
|
|
|
** Valentina 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.
|
|
|
|
**
|
|
|
|
** Valentina 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 <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VMEASUREMENTS_H
|
|
|
|
#define VMEASUREMENTS_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QDomElement>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
#include "../ifc/xml/vdomdocument.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../vmisc/def.h"
|
2020-10-01 12:32:02 +02:00
|
|
|
#include "vdimensions.h"
|
2019-07-10 11:42:37 +02:00
|
|
|
|
|
|
|
class VContainer;
|
2015-07-14 19:22:31 +02:00
|
|
|
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class GenderType : qint8 { Male, Female, Unknown };
|
2015-07-16 11:38:54 +02:00
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
class VMeasurements : public VDomDocument
|
2015-07-14 19:22:31 +02:00
|
|
|
{
|
2015-10-03 00:49:15 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(VMeasurements)
|
2015-07-14 19:22:31 +02:00
|
|
|
public:
|
2015-10-12 13:52:48 +02:00
|
|
|
explicit VMeasurements(VContainer *data);
|
2015-07-16 11:38:54 +02:00
|
|
|
VMeasurements(Unit unit, VContainer *data);
|
2020-10-01 12:32:02 +02:00
|
|
|
VMeasurements(Unit unit, const QVector<MeasurementDimension_p > &dimensions,
|
|
|
|
VContainer *data);
|
2017-04-01 16:27:55 +02:00
|
|
|
virtual ~VMeasurements() Q_DECL_EQ_DEFAULT;
|
2015-07-15 09:16:59 +02:00
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void setXMLContent(const QString &fileName) override;
|
|
|
|
virtual bool SaveDocument(const QString &fileName, QString &error) override;
|
2015-07-25 14:59:40 +02:00
|
|
|
|
2015-08-01 13:25:05 +02:00
|
|
|
void AddEmpty(const QString &name, const QString &formula = QString());
|
|
|
|
void AddEmptyAfter(const QString &after, const QString &name, const QString &formula = QString());
|
2015-07-22 08:41:04 +02:00
|
|
|
void Remove(const QString &name);
|
2015-10-12 16:57:11 +02:00
|
|
|
void MoveTop(const QString &name);
|
2015-07-22 09:01:34 +02:00
|
|
|
void MoveUp(const QString &name);
|
|
|
|
void MoveDown(const QString &name);
|
2015-10-12 16:57:11 +02:00
|
|
|
void MoveBottom(const QString &name);
|
2015-07-19 14:28:01 +02:00
|
|
|
|
2020-01-09 14:14:05 +01:00
|
|
|
void StoreNames(bool store);
|
|
|
|
|
2020-10-03 17:52:31 +02:00
|
|
|
void ReadMeasurements(qreal baseA, qreal baseB=0, qreal baseC=0) const;
|
2015-10-15 14:37:10 +02:00
|
|
|
void ClearForExport();
|
2015-07-24 12:06:39 +02:00
|
|
|
|
2015-07-16 11:38:54 +02:00
|
|
|
MeasurementsType Type() const;
|
2021-01-18 19:43:53 +01:00
|
|
|
qreal DimensionABase() const;
|
|
|
|
qreal DimensionBBase() const;
|
|
|
|
qreal DimensionCBase() const;
|
2015-07-16 11:38:54 +02:00
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
qreal DimensionAStep() const;
|
|
|
|
qreal DimensionBStep() const;
|
|
|
|
qreal DimensionCStep() const;
|
2020-10-03 17:52:31 +02:00
|
|
|
|
2015-07-16 11:38:54 +02:00
|
|
|
QString Notes() const;
|
|
|
|
void SetNotes(const QString &text);
|
|
|
|
|
2017-09-19 15:07:48 +02:00
|
|
|
QString Customer() const;
|
|
|
|
void SetCustomer(const QString &text);
|
2015-07-16 11:38:54 +02:00
|
|
|
|
|
|
|
QDate BirthDate() const;
|
|
|
|
void SetBirthDate(const QDate &date);
|
|
|
|
|
2015-10-13 10:13:43 +02:00
|
|
|
GenderType Gender() const;
|
2020-10-15 17:05:21 +02:00
|
|
|
void SetGender(const GenderType &gender);
|
2015-07-16 11:38:54 +02:00
|
|
|
|
2015-10-16 19:26:05 +02:00
|
|
|
QString PMSystem() const;
|
|
|
|
void SetPMSystem(const QString &system);
|
|
|
|
|
2015-07-16 11:38:54 +02:00
|
|
|
QString Email() const;
|
|
|
|
void SetEmail(const QString &text);
|
|
|
|
|
2017-02-04 12:28:47 +01:00
|
|
|
bool IsReadOnly() const;
|
2015-07-18 13:08:44 +02:00
|
|
|
void SetReadOnly(bool ro);
|
|
|
|
|
2020-10-01 13:16:21 +02:00
|
|
|
bool IsFullCircumference() const;
|
|
|
|
void SetFullCircumference(bool fc);
|
|
|
|
|
2015-07-22 11:44:31 +02:00
|
|
|
void SetMName(const QString &name, const QString &text);
|
|
|
|
void SetMValue(const QString &name, const QString &text);
|
2015-07-25 08:10:56 +02:00
|
|
|
void SetMBaseValue(const QString &name, double value);
|
2020-10-03 17:52:31 +02:00
|
|
|
void SetMShiftA(const QString &name, double value);
|
|
|
|
void SetMShiftB(const QString &name, double value);
|
|
|
|
void SetMShiftC(const QString &name, double value);
|
|
|
|
void SetMSpecialUnits(const QString &name, bool special);
|
|
|
|
void SetMCorrectionValue(const QString &name, qreal baseA, qreal baseB, qreal baseC, double value);
|
2015-07-22 11:44:31 +02:00
|
|
|
void SetMDescription(const QString &name, const QString &text);
|
2015-07-25 10:54:39 +02:00
|
|
|
void SetMFullName(const QString &name, const QString &text);
|
2020-10-15 08:35:08 +02:00
|
|
|
void SetMDimension(const QString &name, IMD type);
|
|
|
|
|
|
|
|
QString MeasurementForDimension(IMD type) const;
|
2015-07-22 11:44:31 +02:00
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
auto Dimensions() const -> QMap<MeasurementDimension, MeasurementDimension_p >;
|
2020-10-01 12:32:02 +02:00
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
auto GetRestrictions() const -> QMap<QString, QPair<qreal, qreal> >;
|
|
|
|
void SetRestrictions(const QMap<QString, QPair<qreal, qreal> > &restrictions);
|
|
|
|
auto Restriction(qreal base, qreal base2=0) const -> QPair<double, double>;
|
2020-10-03 06:34:25 +02:00
|
|
|
|
2020-10-08 12:34:38 +02:00
|
|
|
void SetDimensionLabels(const QMap<MeasurementDimension, DimesionLabels> &labels);
|
|
|
|
|
2015-07-16 11:38:54 +02:00
|
|
|
static const QString TagVST;
|
|
|
|
static const QString TagVIT;
|
|
|
|
static const QString TagBodyMeasurements;
|
|
|
|
static const QString TagNotes;
|
|
|
|
static const QString TagPersonal;
|
2017-09-19 15:07:48 +02:00
|
|
|
static const QString TagCustomer;
|
2015-07-16 11:38:54 +02:00
|
|
|
static const QString TagBirthDate;
|
2015-10-13 10:13:43 +02:00
|
|
|
static const QString TagGender;
|
2015-10-16 19:26:05 +02:00
|
|
|
static const QString TagPMSystem;
|
2015-07-16 11:38:54 +02:00
|
|
|
static const QString TagEmail;
|
2015-07-18 13:08:44 +02:00
|
|
|
static const QString TagReadOnly;
|
2015-07-19 14:28:01 +02:00
|
|
|
static const QString TagMeasurement;
|
2020-10-01 12:32:02 +02:00
|
|
|
static const QString TagDimensions;
|
|
|
|
static const QString TagDimension;
|
|
|
|
static const QString TagRestrictions;
|
2020-10-05 14:14:38 +02:00
|
|
|
static const QString TagRestriction;
|
2020-10-03 17:52:31 +02:00
|
|
|
static const QString TagCorrections;
|
|
|
|
static const QString TagCorrection;
|
2020-10-08 12:34:38 +02:00
|
|
|
static const QString TagLabels;
|
|
|
|
static const QString TagLabel;
|
2015-07-16 11:38:54 +02:00
|
|
|
|
|
|
|
static const QString AttrBase;
|
2015-07-19 14:28:01 +02:00
|
|
|
static const QString AttrValue;
|
2020-10-03 17:52:31 +02:00
|
|
|
static const QString AttrShiftA;
|
|
|
|
static const QString AttrShiftB;
|
|
|
|
static const QString AttrShiftC;
|
|
|
|
static const QString AttrCorrection;
|
|
|
|
static const QString AttrCoordinates;
|
|
|
|
static const QString AttrSpecialUnits;
|
2015-07-19 14:28:01 +02:00
|
|
|
static const QString AttrDescription;
|
|
|
|
static const QString AttrName;
|
2015-07-25 10:54:39 +02:00
|
|
|
static const QString AttrFullName;
|
2020-10-01 12:32:02 +02:00
|
|
|
static const QString AttrMin;
|
|
|
|
static const QString AttrMax;
|
|
|
|
static const QString AttrStep;
|
|
|
|
static const QString AttrCircumference;
|
2020-10-01 13:16:21 +02:00
|
|
|
static const QString AttrFullCircumference;
|
2020-10-08 12:34:38 +02:00
|
|
|
static const QString AttrLabel;
|
2020-10-15 08:35:08 +02:00
|
|
|
static const QString AttrDimension;
|
2015-07-16 11:38:54 +02:00
|
|
|
|
2015-10-13 10:13:43 +02:00
|
|
|
static const QString GenderMale;
|
|
|
|
static const QString GenderFemale;
|
|
|
|
static const QString GenderUnknown;
|
2015-07-16 11:38:54 +02:00
|
|
|
|
2020-10-15 08:35:08 +02:00
|
|
|
static const QString DimensionN;
|
2020-10-01 12:32:02 +02:00
|
|
|
static const QString DimensionX;
|
|
|
|
static const QString DimensionY;
|
|
|
|
static const QString DimensionW;
|
|
|
|
static const QString DimensionZ;
|
|
|
|
|
2015-10-13 10:13:43 +02:00
|
|
|
static QString GenderToStr(const GenderType &sex);
|
|
|
|
static GenderType StrToGender(const QString &sex);
|
2015-07-16 11:38:54 +02:00
|
|
|
|
2020-10-01 12:32:02 +02:00
|
|
|
static QString DimensionTypeToStr(const MeasurementDimension &type);
|
|
|
|
static MeasurementDimension StrToDimensionType(const QString &type);
|
|
|
|
|
2020-10-15 08:35:08 +02:00
|
|
|
static QString IMDToStr(const IMD &type);
|
|
|
|
static IMD StrToIMD(const QString &type);
|
|
|
|
|
|
|
|
static QString IMDName(IMD type);
|
|
|
|
|
2015-07-26 09:17:53 +02:00
|
|
|
QStringList ListAll() const;
|
|
|
|
QStringList ListKnown() const;
|
|
|
|
|
2015-09-22 16:41:05 +02:00
|
|
|
bool IsDefinedKnownNamesValid() const;
|
|
|
|
|
2017-08-04 19:29:43 +02:00
|
|
|
VContainer *GetData() const;
|
2015-08-18 09:24:51 +02:00
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VMeasurements)
|
|
|
|
|
|
|
|
/** @brief data container with data. */
|
|
|
|
VContainer *data;
|
2015-07-16 11:38:54 +02:00
|
|
|
MeasurementsType type;
|
|
|
|
|
2020-01-09 14:14:05 +01:00
|
|
|
/** @brief m_keepNames store names in container to check uniqueness. */
|
|
|
|
bool m_keepNames{true};
|
|
|
|
|
2020-10-01 12:32:02 +02:00
|
|
|
void CreateEmptyMultisizeFile(Unit unit, const QVector<MeasurementDimension_p > &dimensions);
|
2015-07-16 11:38:54 +02:00
|
|
|
void CreateEmptyIndividualFile(Unit unit);
|
|
|
|
|
2020-10-01 12:32:02 +02:00
|
|
|
QDomElement CreateDimensions(const QVector<MeasurementDimension_p > &dimensions);
|
|
|
|
|
2015-07-16 11:38:54 +02:00
|
|
|
qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const;
|
2015-07-21 19:26:33 +02:00
|
|
|
|
2015-08-01 13:25:05 +02:00
|
|
|
QDomElement MakeEmpty(const QString &name, const QString &formula);
|
2015-07-21 19:26:33 +02:00
|
|
|
QDomElement FindM(const QString &name) const;
|
2015-07-25 14:59:40 +02:00
|
|
|
MeasurementsType ReadType() const;
|
2015-07-24 12:06:39 +02:00
|
|
|
|
|
|
|
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;
|
2015-10-16 19:26:05 +02:00
|
|
|
|
|
|
|
QString ClearPMCode(const QString &code) const;
|
2020-10-03 17:52:31 +02:00
|
|
|
|
|
|
|
QMap<QString, qreal> ReadCorrections(const QDomElement &mElement) const;
|
|
|
|
void WriteCorrections(QDomElement &mElement, const QMap<QString, qreal> &corrections);
|
2020-10-08 12:34:38 +02:00
|
|
|
|
|
|
|
void SaveDimesionLabels(QDomElement &dElement, const DimesionLabels &labels);
|
|
|
|
DimesionLabels ReadDimensionLabels(const QDomElement &dElement) const;
|
2020-10-15 08:35:08 +02:00
|
|
|
|
|
|
|
void ClearDimension(IMD type);
|
2015-07-14 19:22:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VMEASUREMENTS_H
|