Add classes for layer,layout and piece

This commit is contained in:
Ronan Le Tiec 2020-04-13 18:58:16 +02:00
parent a258d5c7ed
commit d93e1ace92
7 changed files with 437 additions and 2 deletions

View File

@ -8,7 +8,10 @@ SOURCES += \
$$PWD/puzzleapplication.cpp \ $$PWD/puzzleapplication.cpp \
$$PWD/vpuzzlecommandline.cpp \ $$PWD/vpuzzlecommandline.cpp \
$$PWD/dialogs/dialogaboutpuzzle.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 *msvc*:SOURCES += $$PWD/stable.cpp
@ -19,7 +22,10 @@ HEADERS += \
$$PWD/puzzleapplication.h \ $$PWD/puzzleapplication.h \
$$PWD/vpuzzlecommandline.h \ $$PWD/vpuzzlecommandline.h \
$$PWD/dialogs/dialogaboutpuzzle.h \ $$PWD/dialogs/dialogaboutpuzzle.h \
$$PWD/vpiececarrousel.h $$PWD/vpiececarrousel.h \
$$PWD/vpuzzlelayout.h \
$$PWD/vpuzzlelayer.h \
$$PWD/vpuzzlepiece.h
FORMS += \ FORMS += \
$$PWD/puzzlemainwindow.ui \ $$PWD/puzzlemainwindow.ui \

View File

@ -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
** <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/>.
**
*************************************************************************/
#include "vpuzzlelayer.h"
VPuzzleLayer::VPuzzleLayer()
{
}

View File

@ -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
** <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 VPUZZLELAYER_H
#define VPUZZLELAYER_H
class VPuzzleLayer
{
public:
VPuzzleLayer();
};
#endif // VPUZZLELAYER_H

View File

@ -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
** <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/>.
**
*************************************************************************/
#include "vpuzzlelayout.h"
//---------------------------------------------------------------------------------------------------------------------
VPuzzleLayout::VPuzzleLayout() :
m_unplacedPiecesLayer(new VPuzzleLayer()),
m_layers(QList<VPuzzleLayer *>()),
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<VPuzzleLayer *> 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;
}

View File

@ -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
** <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 VPUZZLELAYOUT_H
#define VPUZZLELAYOUT_H
#include <QSizeF>
#include <QMarginsF>
#include <QList>
#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<VPuzzleLayer *> 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<VPuzzleLayer *> 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

View File

@ -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
** <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/>.
**
*************************************************************************/
#include "vpuzzlepiece.h"
VPuzzlePiece::VPuzzlePiece()
{
}

View File

@ -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
** <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 VPUZZLEPIECE_H
#define VPUZZLEPIECE_H
class VPuzzlePiece
{
public:
VPuzzlePiece();
};
#endif // VPUZZLEPIECE_H