From d93e1ace92073fba39a7a132365fde65f58aa952 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Mon, 13 Apr 2020 18:58:16 +0200 Subject: [PATCH] Add classes for layer,layout and piece --- src/app/puzzle/puzzle.pri | 10 +- src/app/puzzle/vpuzzlelayer.cpp | 33 ++++++ src/app/puzzle/vpuzzlelayer.h | 38 +++++++ src/app/puzzle/vpuzzlelayout.cpp | 188 +++++++++++++++++++++++++++++++ src/app/puzzle/vpuzzlelayout.h | 99 ++++++++++++++++ src/app/puzzle/vpuzzlepiece.cpp | 33 ++++++ src/app/puzzle/vpuzzlepiece.h | 38 +++++++ 7 files changed, 437 insertions(+), 2 deletions(-) create mode 100644 src/app/puzzle/vpuzzlelayer.cpp create mode 100644 src/app/puzzle/vpuzzlelayer.h create mode 100644 src/app/puzzle/vpuzzlelayout.cpp create mode 100644 src/app/puzzle/vpuzzlelayout.h create mode 100644 src/app/puzzle/vpuzzlepiece.cpp create mode 100644 src/app/puzzle/vpuzzlepiece.h diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 66396d8cc..6ca67a366 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -8,7 +8,10 @@ SOURCES += \ $$PWD/puzzleapplication.cpp \ $$PWD/vpuzzlecommandline.cpp \ $$PWD/dialogs/dialogaboutpuzzle.cpp \ - $$PWD/vpiececarrousel.cpp + $$PWD/vpiececarrousel.cpp \ + $$PWD/vpuzzlelayout.cpp \ + $$PWD/vpuzzlelayer.cpp \ + $$PWD/vpuzzlepiece.cpp *msvc*:SOURCES += $$PWD/stable.cpp @@ -19,7 +22,10 @@ HEADERS += \ $$PWD/puzzleapplication.h \ $$PWD/vpuzzlecommandline.h \ $$PWD/dialogs/dialogaboutpuzzle.h \ - $$PWD/vpiececarrousel.h + $$PWD/vpiececarrousel.h \ + $$PWD/vpuzzlelayout.h \ + $$PWD/vpuzzlelayer.h \ + $$PWD/vpuzzlepiece.h FORMS += \ $$PWD/puzzlemainwindow.ui \ diff --git a/src/app/puzzle/vpuzzlelayer.cpp b/src/app/puzzle/vpuzzlelayer.cpp new file mode 100644 index 000000000..f3265cf1b --- /dev/null +++ b/src/app/puzzle/vpuzzlelayer.cpp @@ -0,0 +1,33 @@ +/************************************************************************ + ** + ** @file vpuzzlelayer.cpp + ** @author Ronan Le Tiec + ** @date 13 4, 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 . + ** + *************************************************************************/ +#include "vpuzzlelayer.h" + +VPuzzleLayer::VPuzzleLayer() +{ + +} diff --git a/src/app/puzzle/vpuzzlelayer.h b/src/app/puzzle/vpuzzlelayer.h new file mode 100644 index 000000000..356cf1f13 --- /dev/null +++ b/src/app/puzzle/vpuzzlelayer.h @@ -0,0 +1,38 @@ +/************************************************************************ + ** + ** @file vpuzzlelayer.h + ** @author Ronan Le Tiec + ** @date 13 4, 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 VPUZZLELAYER_H +#define VPUZZLELAYER_H + + +class VPuzzleLayer +{ +public: + VPuzzleLayer(); +}; + +#endif // VPUZZLELAYER_H diff --git a/src/app/puzzle/vpuzzlelayout.cpp b/src/app/puzzle/vpuzzlelayout.cpp new file mode 100644 index 000000000..1d4631c98 --- /dev/null +++ b/src/app/puzzle/vpuzzlelayout.cpp @@ -0,0 +1,188 @@ +/************************************************************************ + ** + ** @file vpuzzlelayout.cpp + ** @author Ronan Le Tiec + ** @date 13 4, 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 . + ** + *************************************************************************/ +#include "vpuzzlelayout.h" + +//--------------------------------------------------------------------------------------------------------------------- +VPuzzleLayout::VPuzzleLayout() : + m_unplacedPiecesLayer(new VPuzzleLayer()), + m_layers(QList()), + m_layoutSize(QSizeF()), + m_layoutMargins(QMarginsF()), + m_followGrainLine(FollowGrainline::No), + m_piecesGap(0), + m_warningSuperpositionOfPieces(false), + m_warningPiecesOutOfBound(false), + m_stickyEdges(false) +{ + m_piecesGap = 0; +} + +//--------------------------------------------------------------------------------------------------------------------- +VPuzzleLayout::~VPuzzleLayout() +{ + // TODO +} + +//--------------------------------------------------------------------------------------------------------------------- +VPuzzleLayer* VPuzzleLayout::GetUnplacedPiecesLayer() +{ + return m_unplacedPiecesLayer; +} + +//--------------------------------------------------------------------------------------------------------------------- +VPuzzleLayer* VPuzzleLayout::AddLayer() +{ + VPuzzleLayer *newLayer = new VPuzzleLayer(); + m_layers.append(newLayer); + return newLayer; +} + +//--------------------------------------------------------------------------------------------------------------------- +VPuzzleLayer* VPuzzleLayout::AddLayer(VPuzzleLayer *layer) +{ + m_layers.append(layer); + return layer; +} + +//--------------------------------------------------------------------------------------------------------------------- +QList VPuzzleLayout::GetLayers() +{ + return m_layers; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzleLayout::SetUnit(Unit unit) +{ + m_layoutUnit = unit; +} + +//--------------------------------------------------------------------------------------------------------------------- +Unit VPuzzleLayout::getUnit() +{ + return m_layoutUnit; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzleLayout::SetLayoutSize(qreal width, qreal height) +{ + m_layoutSize.setWidth(width); + m_layoutSize.setHeight(height); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzleLayout::SetLayoutSize(QSizeF size) +{ + m_layoutSize = size; +} + +//--------------------------------------------------------------------------------------------------------------------- +QSizeF VPuzzleLayout::GetLayoutSize() +{ + return m_layoutSize; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzleLayout::SetLayoutMargins(qreal left, qreal top, qreal right, qreal bottom) +{ + m_layoutMargins.setLeft(left); + m_layoutMargins.setTop(top); + m_layoutMargins.setRight(right); + m_layoutMargins.setRight(bottom); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzleLayout::SetLayoutMargins(QMarginsF margins) +{ + m_layoutMargins = margins; +} + +//--------------------------------------------------------------------------------------------------------------------- +QMarginsF VPuzzleLayout::GetLayoutMargins() +{ + return m_layoutMargins; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzleLayout::SetFollowGrainline(FollowGrainline state) +{ + m_followGrainLine = state; +} + +//--------------------------------------------------------------------------------------------------------------------- +FollowGrainline VPuzzleLayout::SetFollowGrainline() +{ + return m_followGrainLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzleLayout::SetPiecesGap(qreal value) +{ + m_piecesGap = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VPuzzleLayout::GetPiecesGap() +{ + return m_piecesGap; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzleLayout::SetWarningSuperpositionOfPieces(bool state) +{ + m_warningSuperpositionOfPieces = state; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPuzzleLayout::GetWarningSuperpositionOfPieces() +{ + return m_warningSuperpositionOfPieces; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzleLayout::SetWarningPiecesOutOfBound(bool state) +{ + m_warningPiecesOutOfBound = state; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPuzzleLayout::GetWarningPiecesOutOfBound() +{ + return m_warningPiecesOutOfBound; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzleLayout::SetStickyEdges(bool state) +{ + m_stickyEdges = state; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPuzzleLayout::GetStickyEdges() +{ + return m_stickyEdges; +} diff --git a/src/app/puzzle/vpuzzlelayout.h b/src/app/puzzle/vpuzzlelayout.h new file mode 100644 index 000000000..7c75fa6c8 --- /dev/null +++ b/src/app/puzzle/vpuzzlelayout.h @@ -0,0 +1,99 @@ +/************************************************************************ + ** + ** @file vpuzzlelayout.h + ** @author Ronan Le Tiec + ** @date 13 4, 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 VPUZZLELAYOUT_H +#define VPUZZLELAYOUT_H + +#include +#include +#include +#include "vpuzzlelayer.h" +#include "def.h" + +// is this the right place for the definition? +enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2}; + +class VPuzzleLayout +{ + +public: + VPuzzleLayout(); + virtual ~VPuzzleLayout(); + + VPuzzleLayer* GetUnplacedPiecesLayer(); + + VPuzzleLayer* AddLayer(); + VPuzzleLayer* AddLayer(VPuzzleLayer *layer); + QList GetLayers(); + + void SetUnit(Unit unit); + Unit getUnit(); + + void SetLayoutSize(qreal width, qreal height); + void SetLayoutSize(QSizeF size); + QSizeF GetLayoutSize(); + + void SetLayoutMargins(qreal left, qreal top, qreal right, qreal bottom); + void SetLayoutMargins(QMarginsF margins); + QMarginsF GetLayoutMargins(); + + void SetFollowGrainline(FollowGrainline state); + FollowGrainline SetFollowGrainline(); + + void SetPiecesGap(qreal value); + qreal GetPiecesGap(); + + void SetWarningSuperpositionOfPieces(bool state); + bool GetWarningSuperpositionOfPieces(); + + void SetWarningPiecesOutOfBound(bool state); + bool GetWarningPiecesOutOfBound(); + + void SetStickyEdges(bool state); + bool GetStickyEdges(); + +private: + VPuzzleLayer *m_unplacedPiecesLayer; + QList m_layers; + + // format + Unit m_layoutUnit; + QSizeF m_layoutSize; + + // margins + QMarginsF m_layoutMargins; + + // control + FollowGrainline m_followGrainLine; + qreal m_piecesGap; + bool m_warningSuperpositionOfPieces; + bool m_warningPiecesOutOfBound; + bool m_stickyEdges; + +}; + +#endif // VPUZZLELAYOUT_H diff --git a/src/app/puzzle/vpuzzlepiece.cpp b/src/app/puzzle/vpuzzlepiece.cpp new file mode 100644 index 000000000..fd5974a65 --- /dev/null +++ b/src/app/puzzle/vpuzzlepiece.cpp @@ -0,0 +1,33 @@ +/************************************************************************ + ** + ** @file vpuzzlepiece.cpp + ** @author Ronan Le Tiec + ** @date 13 4, 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 . + ** + *************************************************************************/ +#include "vpuzzlepiece.h" + +VPuzzlePiece::VPuzzlePiece() +{ + +} diff --git a/src/app/puzzle/vpuzzlepiece.h b/src/app/puzzle/vpuzzlepiece.h new file mode 100644 index 000000000..177ee0cc1 --- /dev/null +++ b/src/app/puzzle/vpuzzlepiece.h @@ -0,0 +1,38 @@ +/************************************************************************ + ** + ** @file vpuzzlepiece.h + ** @author Ronan Le Tiec + ** @date 13 4, 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 VPUZZLEPIECE_H +#define VPUZZLEPIECE_H + + +class VPuzzlePiece +{ +public: + VPuzzlePiece(); +}; + +#endif // VPUZZLEPIECE_H