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
|
|
|
|
2023-07-13 16:49:20 +02:00
|
|
|
#include <QCoreApplication>
|
2016-11-09 14:53:22 +01:00
|
|
|
#include <QSharedData>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QString>
|
2020-04-22 13:32:25 +02:00
|
|
|
#include <QUuid>
|
2016-08-08 13:44:49 +02:00
|
|
|
|
2019-07-01 11:26:08 +02:00
|
|
|
#include "../ifc/exception/vexception.h"
|
2023-07-13 16:49:20 +02:00
|
|
|
#include "../vmisc/defglobal.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
|
|
|
{
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(VAbstractPieceData) // NOLINT
|
2023-07-13 16:49:20 +02:00
|
|
|
|
2016-06-26 13:36:12 +02:00
|
|
|
public:
|
2022-11-04 15:12:58 +01:00
|
|
|
VAbstractPieceData() = default;
|
|
|
|
VAbstractPieceData(const VAbstractPieceData &piece) = default;
|
2022-08-22 15:36:01 +02:00
|
|
|
~VAbstractPieceData() = default;
|
2016-06-26 13:36:12 +02:00
|
|
|
|
2023-07-13 16:49:20 +02:00
|
|
|
friend auto operator<<(QDataStream &dataStream, const VAbstractPieceData &piece) -> QDataStream &;
|
|
|
|
friend auto operator>>(QDataStream &dataStream, VAbstractPieceData &piece) -> QDataStream &;
|
2019-07-01 11:26:08 +02:00
|
|
|
|
2022-11-04 15:12:58 +01:00
|
|
|
QString m_name{tr("Detail")}; // NOLINT (misc-non-private-member-variables-in-classes)
|
2023-10-10 13:14:23 +02:00
|
|
|
/** @brief forbidFlipping forbid piece to be mirrored in a layout. */
|
2024-01-06 13:20:56 +01:00
|
|
|
bool m_forbidFlipping{false}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
bool m_forceFlipping{false}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
bool m_followGrainline{false}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
bool m_seamAllowance{false}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
bool m_seamAllowanceBuiltIn{false}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
bool m_hideMainPath{false}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
qreal m_width{0}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
qreal m_mx{0}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
qreal m_my{0}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
uint m_priority{0}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
QUuid m_uuid{QUuid::createUuid()}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
bool m_onDrawing{false}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
bool m_showFullPiece{true}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
unsigned int m_foldLineSvgFontSize{defFoldLineFontSize}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
bool m_foldLineLabelFontItalic{false}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
bool m_foldLineLabelFontBold{false}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
QString m_foldLineLabel{}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
int m_foldLineLabelAlignment{Qt::AlignHCenter}; // NOLINT (misc-non-private-member-variables-in-classes)
|
|
|
|
|
|
|
|
// NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
|
|
|
|
FoldLineType m_foldLineType{FoldLineType::TwoArrowsTextAbove};
|
2016-11-09 14:53:22 +01:00
|
|
|
|
|
|
|
private:
|
2022-11-04 15:12:58 +01:00
|
|
|
Q_DISABLE_ASSIGN_MOVE(VAbstractPieceData) // NOLINT
|
2019-07-01 11:26:08 +02:00
|
|
|
|
2022-11-04 15:12:58 +01:00
|
|
|
static constexpr quint32 streamHeader = 0x05CDD73A; // CRC-32Q string "VAbstractPieceData"
|
2024-01-06 13:20:56 +01:00
|
|
|
static constexpr quint16 classVersion = 6;
|
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
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-11-04 15:12:58 +01:00
|
|
|
inline auto operator<<(QDataStream &dataStream, const VAbstractPieceData &piece) -> QDataStream &
|
2019-07-01 11:26:08 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2020-04-22 13:32:25 +02:00
|
|
|
// Added in classVersion = 3
|
|
|
|
dataStream << piece.m_uuid;
|
|
|
|
|
2022-11-04 16:16:50 +01:00
|
|
|
// Added in classVersion = 4
|
|
|
|
dataStream << piece.m_onDrawing;
|
|
|
|
|
2023-10-10 13:14:23 +02:00
|
|
|
// Added in classVersion = 5
|
|
|
|
dataStream << piece.m_followGrainline;
|
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
// Added in classVersion = 6
|
|
|
|
dataStream << piece.m_showFullPiece;
|
|
|
|
dataStream << piece.m_foldLineSvgFontSize;
|
|
|
|
dataStream << piece.m_foldLineType;
|
|
|
|
dataStream << piece.m_foldLineLabelFontItalic;
|
|
|
|
dataStream << piece.m_foldLineLabelFontBold;
|
|
|
|
dataStream << piece.m_foldLineLabel;
|
|
|
|
dataStream << piece.m_foldLineLabelAlignment;
|
|
|
|
|
2019-07-01 11:26:08 +02:00
|
|
|
return dataStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-11-04 15:12:58 +01:00
|
|
|
inline auto operator>>(QDataStream &dataStream, VAbstractPieceData &piece) -> QDataStream &
|
2019-07-01 11:26:08 +02:00
|
|
|
{
|
|
|
|
quint32 actualStreamHeader = 0;
|
|
|
|
dataStream >> actualStreamHeader;
|
|
|
|
|
|
|
|
if (actualStreamHeader != VAbstractPieceData::streamHeader)
|
|
|
|
{
|
|
|
|
QString message = QCoreApplication::tr("VAbstractPieceData prefix mismatch error: actualStreamHeader = 0x%1 "
|
|
|
|
"and streamHeader = 0x%2")
|
2023-10-07 17:56:39 +02:00
|
|
|
.arg(actualStreamHeader, 8, 0x10, QLatin1Char('0'))
|
|
|
|
.arg(VAbstractPieceData::streamHeader, 8, 0x10, QLatin1Char('0'));
|
2019-07-01 11:26:08 +02:00
|
|
|
throw VException(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
quint16 actualClassVersion = 0;
|
|
|
|
dataStream >> actualClassVersion;
|
|
|
|
|
|
|
|
if (actualClassVersion > VAbstractPieceData::classVersion)
|
|
|
|
{
|
|
|
|
QString message = QCoreApplication::tr("VAbstractPieceData compatibility error: actualClassVersion = %1 and "
|
|
|
|
"classVersion = %2")
|
2023-07-13 16:49:20 +02:00
|
|
|
.arg(actualClassVersion)
|
|
|
|
.arg(VAbstractPieceData::classVersion);
|
2019-07-01 11:26:08 +02:00
|
|
|
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
|
|
|
|
2020-04-22 13:32:25 +02:00
|
|
|
if (actualClassVersion >= 3)
|
|
|
|
{
|
|
|
|
dataStream >> piece.m_uuid;
|
|
|
|
}
|
|
|
|
|
2022-11-04 16:16:50 +01:00
|
|
|
if (actualClassVersion >= 4)
|
|
|
|
{
|
|
|
|
dataStream >> piece.m_onDrawing;
|
|
|
|
}
|
|
|
|
|
2023-10-10 13:14:23 +02:00
|
|
|
if (actualClassVersion >= 5)
|
|
|
|
{
|
|
|
|
dataStream >> piece.m_followGrainline;
|
|
|
|
}
|
|
|
|
|
2024-01-06 13:20:56 +01:00
|
|
|
if (actualClassVersion >= 6)
|
|
|
|
{
|
|
|
|
dataStream >> piece.m_showFullPiece;
|
|
|
|
dataStream >> piece.m_foldLineSvgFontSize;
|
|
|
|
dataStream >> piece.m_foldLineType;
|
|
|
|
dataStream >> piece.m_foldLineLabelFontItalic;
|
|
|
|
dataStream >> piece.m_foldLineLabelFontBold;
|
|
|
|
dataStream >> piece.m_foldLineLabel;
|
|
|
|
dataStream >> piece.m_foldLineLabelAlignment;
|
|
|
|
}
|
|
|
|
|
2019-07-01 11:26:08 +02:00
|
|
|
return dataStream;
|
|
|
|
}
|
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
#endif // VABSTRACTPIECE_P_H
|