2016-06-26 13:36:12 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
2016-11-09 14:53:22 +01:00
|
|
|
** @file
|
2016-06-26 13:36:12 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2016-11-09 14:53:22 +01:00
|
|
|
** @date 9 11, 2016
|
2016-06-26 13:36:12 +02:00
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2016-06-26 13:36:12 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2016 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2016-06-26 13:36:12 +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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
#ifndef VABSTRACTPIECE_P_H
|
|
|
|
#define VABSTRACTPIECE_P_H
|
2016-06-26 13:36:12 +02:00
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
#include <QSharedData>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QString>
|
2016-11-29 13:18:23 +01:00
|
|
|
#include <QCoreApplication>
|
2016-08-08 13:44:49 +02:00
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
#include "../vmisc/diagnostic.h"
|
2020-01-07 13:21:47 +01:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
2020-01-07 08:45:26 +01:00
|
|
|
# include "../vmisc/vdatastreamenum.h"
|
|
|
|
#endif
|
2019-07-01 10:33:29 +02:00
|
|
|
#include "../vmisc/defglobal.h"
|
2019-07-01 11:26:08 +02:00
|
|
|
#include "../ifc/exception/vexception.h"
|
2016-06-26 13:36:12 +02:00
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
2017-05-30 17:44:16 +02:00
|
|
|
QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
2016-08-08 13:44:49 +02:00
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
class VAbstractPieceData : public QSharedData
|
2016-06-26 13:36:12 +02:00
|
|
|
{
|
2016-11-29 13:18:23 +01:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(VAbstractPieceData)
|
2016-06-26 13:36:12 +02:00
|
|
|
public:
|
2016-11-09 14:53:22 +01:00
|
|
|
VAbstractPieceData()
|
|
|
|
{}
|
2016-10-14 16:11:15 +02:00
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
VAbstractPieceData(const VAbstractPieceData &piece)
|
|
|
|
: QSharedData(piece),
|
2016-11-10 10:56:40 +01:00
|
|
|
m_name(piece.m_name),
|
2016-11-10 11:53:02 +01:00
|
|
|
m_forbidFlipping(piece.m_forbidFlipping),
|
2017-12-17 14:06:46 +01:00
|
|
|
m_forceFlipping(piece.m_forceFlipping),
|
2016-11-10 11:53:02 +01:00
|
|
|
m_seamAllowance(piece.m_seamAllowance),
|
2017-04-05 12:22:33 +02:00
|
|
|
m_seamAllowanceBuiltIn(piece.m_seamAllowanceBuiltIn),
|
2017-05-16 14:16:50 +02:00
|
|
|
m_hideMainPath(piece.m_hideMainPath),
|
2017-07-09 21:27:54 +02:00
|
|
|
m_width(piece.m_width),
|
|
|
|
m_mx(piece.m_mx),
|
2019-07-19 09:45:57 +02:00
|
|
|
m_my(piece.m_my),
|
|
|
|
m_priority(piece.m_priority)
|
2016-11-09 14:53:22 +01:00
|
|
|
{}
|
|
|
|
|
2017-04-01 16:27:55 +02:00
|
|
|
~VAbstractPieceData() Q_DECL_EQ_DEFAULT;
|
2016-06-26 13:36:12 +02:00
|
|
|
|
2019-07-01 11:26:08 +02:00
|
|
|
friend QDataStream& operator<<(QDataStream& dataStream, const VAbstractPieceData& piece);
|
|
|
|
friend QDataStream& operator>>(QDataStream& dataStream, VAbstractPieceData& piece);
|
|
|
|
|
2019-07-19 09:45:57 +02:00
|
|
|
QString m_name{tr("Detail")};
|
2016-11-10 10:56:40 +01:00
|
|
|
/** @brief forbidFlipping forbid piece be mirrored in a layout. */
|
2019-07-19 09:45:57 +02:00
|
|
|
bool m_forbidFlipping{false};
|
|
|
|
bool m_forceFlipping{false};
|
|
|
|
bool m_seamAllowance{false};
|
|
|
|
bool m_seamAllowanceBuiltIn{false};
|
|
|
|
bool m_hideMainPath{false};
|
|
|
|
qreal m_width{0};
|
|
|
|
qreal m_mx{0};
|
|
|
|
qreal m_my{0};
|
|
|
|
uint m_priority{0};
|
2016-11-09 14:53:22 +01:00
|
|
|
|
|
|
|
private:
|
2019-07-01 10:33:29 +02:00
|
|
|
Q_DISABLE_ASSIGN(VAbstractPieceData)
|
2019-07-01 11:26:08 +02:00
|
|
|
|
|
|
|
static const quint32 streamHeader;
|
|
|
|
static const quint16 classVersion;
|
2016-06-26 13:36:12 +02:00
|
|
|
};
|
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
QT_WARNING_POP
|
|
|
|
|
2019-07-01 11:26:08 +02:00
|
|
|
// Friend functions
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline QDataStream &operator<<(QDataStream &dataStream, const VAbstractPieceData &piece)
|
|
|
|
{
|
|
|
|
dataStream << VAbstractPieceData::streamHeader << VAbstractPieceData::classVersion;
|
|
|
|
|
|
|
|
// Added in classVersion = 1
|
|
|
|
dataStream << piece.m_name;
|
|
|
|
dataStream << piece.m_forbidFlipping;
|
|
|
|
dataStream << piece.m_forceFlipping;
|
|
|
|
dataStream << piece.m_seamAllowance;
|
|
|
|
dataStream << piece.m_seamAllowanceBuiltIn;
|
|
|
|
dataStream << piece.m_hideMainPath;
|
|
|
|
dataStream << piece.m_width;
|
|
|
|
dataStream << piece.m_mx;
|
|
|
|
dataStream << piece.m_my;
|
|
|
|
|
|
|
|
// Added in classVersion = 2
|
2019-07-19 09:45:57 +02:00
|
|
|
dataStream << piece.m_priority;
|
2019-07-01 11:26:08 +02:00
|
|
|
|
|
|
|
return dataStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline QDataStream &operator>>(QDataStream &dataStream, VAbstractPieceData &piece)
|
|
|
|
{
|
|
|
|
quint32 actualStreamHeader = 0;
|
|
|
|
dataStream >> actualStreamHeader;
|
|
|
|
|
|
|
|
if (actualStreamHeader != VAbstractPieceData::streamHeader)
|
|
|
|
{
|
|
|
|
QString message = QCoreApplication::tr("VAbstractPieceData prefix mismatch error: actualStreamHeader = 0x%1 "
|
|
|
|
"and streamHeader = 0x%2")
|
|
|
|
.arg(actualStreamHeader, 8, 0x10, QChar('0'))
|
|
|
|
.arg(VAbstractPieceData::streamHeader, 8, 0x10, QChar('0'));
|
|
|
|
throw VException(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
quint16 actualClassVersion = 0;
|
|
|
|
dataStream >> actualClassVersion;
|
|
|
|
|
|
|
|
if (actualClassVersion > VAbstractPieceData::classVersion)
|
|
|
|
{
|
|
|
|
QString message = QCoreApplication::tr("VAbstractPieceData compatibility error: actualClassVersion = %1 and "
|
|
|
|
"classVersion = %2")
|
|
|
|
.arg(actualClassVersion).arg(VAbstractPieceData::classVersion);
|
|
|
|
throw VException(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
dataStream >> piece.m_name;
|
|
|
|
dataStream >> piece.m_forbidFlipping;
|
|
|
|
dataStream >> piece.m_forceFlipping;
|
|
|
|
dataStream >> piece.m_seamAllowance;
|
|
|
|
dataStream >> piece.m_seamAllowanceBuiltIn;
|
|
|
|
dataStream >> piece.m_hideMainPath;
|
|
|
|
dataStream >> piece.m_width;
|
|
|
|
dataStream >> piece.m_mx;
|
|
|
|
dataStream >> piece.m_my;
|
|
|
|
|
2019-07-19 09:45:57 +02:00
|
|
|
if (actualClassVersion >= 2)
|
|
|
|
{
|
|
|
|
dataStream >> piece.m_priority;
|
|
|
|
}
|
2019-07-01 11:26:08 +02:00
|
|
|
|
|
|
|
return dataStream;
|
|
|
|
}
|
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
#endif // VABSTRACTPIECE_P_H
|
|
|
|
|