valentina/src/libs/vformat/vmeasurements.h

244 lines
8.4 KiB
C
Raw Normal View History

/************************************************************************
**
** @file vmeasurements.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 14 7, 2015
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** 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
#include <qcompilerdetection.h>
#include <QCoreApplication>
#include <QDomElement>
#include <QString>
#include <QStringList>
#include <QtGlobal>
#include "../ifc/xml/vdomdocument.h"
#include "../vmisc/def.h"
2020-10-01 12:32:02 +02:00
#include "vdimensions.h"
class VContainer;
enum class GenderType : qint8 { Male, Female, Unknown };
using VDimensions = QMap<MeasurementDimension, MeasurementDimension_p>;
class VMeasurements : public VDomDocument
{
Q_DECLARE_TR_FUNCTIONS(VMeasurements)
public:
2015-10-12 13:52:48 +02:00
explicit VMeasurements(VContainer *data);
VMeasurements(Unit unit, VContainer *data);
2020-10-01 12:32:02 +02:00
VMeasurements(Unit unit, const QVector<MeasurementDimension_p > &dimensions,
VContainer *data);
virtual ~VMeasurements() Q_DECL_EQ_DEFAULT;
virtual void setXMLContent(const QString &fileName) override;
virtual bool SaveDocument(const QString &fileName, QString &error) override;
void AddEmpty(const QString &name, const QString &formula = QString());
void AddEmptyAfter(const QString &after, const QString &name, const QString &formula = QString());
2022-02-05 14:00:22 +01:00
void AddSeparator(const QString &name);
void AddSeparatorAfter(const QString &after, const QString &name);
void Remove(const QString &name);
void MoveTop(const QString &name);
void MoveUp(const QString &name);
void MoveDown(const QString &name);
void MoveBottom(const QString &name);
auto Units() const -> Unit;
void StoreNames(bool store);
2020-10-03 17:52:31 +02:00
void ReadMeasurements(qreal baseA, qreal baseB=0, qreal baseC=0) const;
void ClearForExport();
MeasurementsType Type() const;
qreal DimensionABase() const;
qreal DimensionBBase() const;
qreal DimensionCBase() const;
qreal DimensionAStep() const;
qreal DimensionBStep() const;
qreal DimensionCStep() const;
2020-10-03 17:52:31 +02:00
QString Notes() const;
void SetNotes(const QString &text);
QString Customer() const;
void SetCustomer(const QString &text);
QDate BirthDate() const;
void SetBirthDate(const QDate &date);
GenderType Gender() const;
2020-10-15 17:05:21 +02:00
void SetGender(const GenderType &gender);
QString PMSystem() const;
void SetPMSystem(const QString &system);
QString Email() const;
void SetEmail(const QString &text);
bool IsReadOnly() const;
void SetReadOnly(bool ro);
2020-10-01 13:16:21 +02:00
bool IsFullCircumference() const;
void SetFullCircumference(bool fc);
void SetMName(const QString &name, const QString &text);
void SetMValue(const QString &name, const QString &text);
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);
void SetMDescription(const QString &name, const QString &text);
void SetMFullName(const QString &name, const QString &text);
void SetMDimension(const QString &name, IMD type);
QString MeasurementForDimension(IMD type) const;
auto Dimensions() const -> VDimensions;
2020-10-01 12:32:02 +02:00
auto GetRestrictions() const -> QMap<QString, VDimensionRestriction >;
void SetRestrictions(const QMap<QString, VDimensionRestriction > &restrictions);
auto Restriction(qreal base, qreal base2=0) const -> VDimensionRestriction;
2020-10-03 06:34:25 +02:00
2020-10-08 12:34:38 +02:00
void SetDimensionLabels(const QMap<MeasurementDimension, DimesionLabels> &labels);
static const QString TagVST;
static const QString TagVIT;
static const QString TagBodyMeasurements;
static const QString TagNotes;
static const QString TagPersonal;
static const QString TagCustomer;
static const QString TagBirthDate;
static const QString TagGender;
static const QString TagPMSystem;
static const QString TagEmail;
static const QString TagReadOnly;
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;
static const QString AttrBase;
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 AttrExclude;
2020-10-03 17:52:31 +02:00
static const QString AttrSpecialUnits;
static const QString AttrDescription;
static const QString AttrName;
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;
static const QString AttrDimension;
static const QString GenderMale;
static const QString GenderFemale;
static const QString GenderUnknown;
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;
static QString GenderToStr(const GenderType &sex);
static GenderType StrToGender(const QString &sex);
2020-10-01 12:32:02 +02:00
static QString DimensionTypeToStr(const MeasurementDimension &type);
static MeasurementDimension StrToDimensionType(const QString &type);
static QString IMDToStr(const IMD &type);
static IMD StrToIMD(const QString &type);
static QString IMDName(IMD type);
QStringList ListAll() const;
QStringList ListKnown() const;
bool IsDefinedKnownNamesValid() const;
VContainer *GetData() const;
private:
Q_DISABLE_COPY(VMeasurements)
/** @brief data container with data. */
VContainer *data;
MeasurementsType type;
// Cache data to quick access
Unit m_units{Unit::LAST_UNIT_DO_NOT_USE};
VDimensions m_dimensions{};
/** @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);
void CreateEmptyIndividualFile(Unit unit);
2020-10-01 12:32:02 +02:00
QDomElement CreateDimensions(const QVector<MeasurementDimension_p > &dimensions);
qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const;
2022-02-05 14:00:22 +01:00
QDomElement MakeEmpty(const QString &name, const QString &formula, MeasurementType varType);
QDomElement FindM(const QString &name) const;
MeasurementsType ReadType() const;
auto ReadUnits() const -> Unit;
auto ReadDimensions() const -> VDimensions;
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;
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;
void ClearDimension(IMD type);
};
#endif // VMEASUREMENTS_H