/************************************************************************ ** ** @file vpsheet.h ** @author Ronan Le Tiec ** @date 23 5, 2020 ** ** @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) 2020 Valentina project ** 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 . ** *************************************************************************/ #ifndef VPSHEET_H #define VPSHEET_H #include #include #include #include #include #include #include "layoutdef.h" #include "../vmisc/def.h" #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #include "../vmisc/defglobal.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) class VPLayout; class VPPiece; class VMainGraphicsScene; class VPGraphicsPieceControls; class VPGraphicsTransformationOrigin; class VPGraphicsPiece; class VPGraphicsTileGrid; class VPGraphicsSheet; class VLayoutPiece; class QGraphicsItem; class VPSheetSceneData { public: explicit VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheetUuid); ~VPSheetSceneData(); auto Scene() const -> VMainGraphicsScene *; /** * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin */ void RefreshLayout(); void RefreshPieces(); /** * @brief PrepareForExport prepares the graphic for an export (i.e hide margin etc) */ void PrepareForExport(); /** * @brief CleanAfterExport cleans the graphic for an export (i.e show margin etc) */ void CleanAfterExport(); auto GraphicsPieces() const -> const QList &; auto GraphicsPiecesAsItems() const -> QList; auto RotationControls() const -> VPGraphicsPieceControls *; auto ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece *; void RemovePiece(VPGraphicsPiece *piece); void AddPiece(VPGraphicsPiece *piece); void SetTextAsPaths(bool textAsPaths) const; void PrepareTilesScheme(); void ClearTilesScheme(); void RefreshSheetSize(); private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPSheetSceneData) // NOLINT VPLayoutWeakPtr m_layout{}; VMainGraphicsScene *m_scene; VPGraphicsSheet *m_graphicsSheet{nullptr}; VPGraphicsTileGrid *m_graphicsTileGrid{nullptr}; VPGraphicsPieceControls *m_rotationControls{nullptr}; VPGraphicsTransformationOrigin *m_rotationOrigin{nullptr}; QList m_graphicsPieces{}; /** * variable to hold temporarly hte value of the show tiles */ bool m_showTilesTmp{false}; bool m_showTilesSchemeTmp{false}; bool m_showTilesWatermarkSchemeTmp{false}; /** * variable to hold temporarly hte value of the show grid */ bool m_showGridTmp{false}; QUuid m_sheetUuid; QList m_slectedPiecesTmp{}; bool m_outOfBoundTmp{false}; bool m_pieceSuperpositionTmp{false}; void ConnectPiece(VPGraphicsPiece *piece); }; class VPSheet : public QObject { Q_OBJECT // NOLINT public: explicit VPSheet(const VPLayoutPtr &layout, QObject *parent = nullptr); ~VPSheet() override = default; /** * @brief GetLayout Returns the Layout of the sheet * @return Layout of the sheet */ auto GetLayout() const -> VPLayoutPtr; auto GetPieces() const -> QList; auto GetSelectedPieces() const -> QList; auto GetAsLayoutPieces() const -> QVector; /** * @brief GetName Returns the name of the sheet * @return the name */ auto GetName() const -> QString; /** * @brief SetName Sets the name of the sheet to the given name * @param name the new sheet's name */ void SetName(const QString &name); auto Uuid() const -> const QUuid &; auto IsVisible() const -> bool; void SetVisible(bool visible); auto GrainlineOrientation() const -> GrainlineType; auto GetGrainlineType() const -> GrainlineType; void SetGrainlineType(GrainlineType type); auto TransformationOrigin() const -> const VPTransformationOrigon &; void SetTransformationOrigin(const VPTransformationOrigon &newTransformationOrigin); void Clear(); auto TrashSheet() const -> bool; void SetTrashSheet(bool newTrashSheet); void ValidateSuperpositionOfPieces() const; void ValidatePieceOutOfBound(const VPPiecePtr &piece) const; void ValidatePiecesOutOfBound() const; auto GetSheetRect() const -> QRectF; auto GetMarginsRect() const -> QRectF; void RemoveUnusedLength(); /** * @brief SetSheetSize sets the size of the sheet, the values have to be in Unit::Px * @param width sheet width * @param height sheet height */ void SetSheetSize(qreal width, qreal height); /** * @brief SetSheetSize sets the size of the sheet, the values have to be in the layout's unit * @param width sheet width * @param height sheet height */ void SetSheetSizeConverted(qreal width, qreal height); /** * @brief SetSheetSize sets the size of the sheet, the values have to be in Unit::Px * @param size sheet size */ void SetSheetSize(const QSizeF &size); /** * @brief SetSheetSizeConverted sets the size of the sheet, the values have to be in the layout's unit * @param size sheet size */ void SetSheetSizeConverted(const QSizeF &size); /** * @brief GetSheetSize Returns the size in Unit::Px * @return sheet size in Unit::Px */ auto GetSheetSize() const -> QSizeF; /** * @brief GetSheetSizeConverted Returns the size in the layout's unit * @return the size in the layout's unit */ auto GetSheetSizeConverted() const -> QSizeF; /** * @brief SetSheetMargins, set the margins of the sheet, the values have to be in Unit::Px * @param left in Unit::Px * @param top in Unit::Px * @param right in Unit::Px * @param bottom in Unit::Px */ void SetSheetMargins(qreal left, qreal top, qreal right, qreal bottom); /** * @brief SetSheetMargins, set the margins of the sheet, the values have to be in the unit of the layout * @param left in Unit::Px * @param top in Unit::Px * @param right in Unit::Px * @param bottom in Unit::Px */ void SetSheetMarginsConverted(qreal left, qreal top, qreal right, qreal bottom); /** * @brief SetSheetMargins set the margins of the sheet, the values have to be in Unit::Px * @param margins sheet margins */ void SetSheetMargins(const QMarginsF &margins); /** * @brief SetSheetMargins set the margins of the sheet, the values have to be in the unit of the layout * @param margins sheet margins */ void SetSheetMarginsConverted(const QMarginsF &margins); /** * @brief GetSheetMargins Returns the size in Unit::Px * @return the size in Unit::Px */ auto GetSheetMargins() const -> QMarginsF; /** * @brief GetSheetMarginsConverted Returns the margins in the layout's unit * @return the margins in the sheet's unit */ auto GetSheetMarginsConverted() const -> QMarginsF; auto IgnoreMargins() const -> bool; void SetIgnoreMargins(bool newIgnoreMargins); auto SceneData() const -> VPSheetSceneData *; void ClearSelection() const; auto GetSheetOrientation() const -> QPageLayout::Orientation; public slots: void CheckPiecePositionValidity(const VPPiecePtr &piece) const; private: Q_DISABLE_COPY_MOVE(VPSheet) // NOLINT VPLayoutWeakPtr m_layout{}; QString m_name{}; QUuid m_uuid{QUuid::createUuid()}; bool m_visible{true}; bool m_trashSheet{false}; VPTransformationOrigon m_transformationOrigin{}; /** * @brief m_size the Size in Unit::Px */ QSizeF m_size{}; // margins /** * @brief m_margins the margins in Unit::Px */ QMarginsF m_margins{}; bool m_ignoreMargins{false}; GrainlineType m_grainlineType{GrainlineType::NotFixed}; VPSheetSceneData *m_sceneData{nullptr}; auto SheetUnits() const -> Unit; }; Q_DECLARE_METATYPE(VPSheetPtr) // NOLINT #endif // VPSHEET_H