Introducing VPSheet and refactoring part 2

This commit is contained in:
Ronan Le Tiec 2020-05-23 17:47:04 +02:00
parent 803a7b6caa
commit 61a2e17a78
21 changed files with 921 additions and 594 deletions

View File

@ -20,6 +20,7 @@ SOURCES += \
$$PWD/vppiece.cpp \ $$PWD/vppiece.cpp \
$$PWD/vppiecelist.cpp \ $$PWD/vppiecelist.cpp \
$$PWD/vpsettings.cpp \ $$PWD/vpsettings.cpp \
$$PWD/vpsheet.cpp \
$$PWD/xml/vplayoutfilereader.cpp \ $$PWD/xml/vplayoutfilereader.cpp \
$$PWD/xml/vplayoutfilewriter.cpp \ $$PWD/xml/vplayoutfilewriter.cpp \
$$PWD/xml/vplayoutliterals.cpp $$PWD/xml/vplayoutliterals.cpp
@ -44,6 +45,7 @@ HEADERS += \
$$PWD/vppiece.h \ $$PWD/vppiece.h \
$$PWD/vppiecelist.h \ $$PWD/vppiecelist.h \
$$PWD/vpsettings.h \ $$PWD/vpsettings.h \
$$PWD/vpsheet.h \
$$PWD/vpstable.h \ $$PWD/vpstable.h \
$$PWD/xml/vplayoutfilereader.h \ $$PWD/xml/vplayoutfilereader.h \
$$PWD/xml/vplayoutfilewriter.h \ $$PWD/xml/vplayoutfilewriter.h \

View File

@ -33,6 +33,7 @@
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#include "vppiecelist.h" #include "vppiecelist.h"
#include "vpsheet.h"
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QMenu> #include <QMenu>
@ -68,8 +69,12 @@ void VPCarrousel::Refresh()
// --- add the content saved in the layout to the carrousel. // --- add the content saved in the layout to the carrousel.
// Do not rely on m_layout because we do not control it. // Do not rely on m_layout because we do not control it.
m_pieceLists = m_layout->GetPiecesLists(); m_pieceLists = QList<VPPieceList*>();
m_pieceLists.prepend(m_layout->GetUnplacedPieceList()); m_pieceLists.append(m_layout->GetUnplacedPieceList());
for(auto sheet : m_layout->GetSheets())
{
m_pieceLists.append(sheet->GetPieceList());
}
for (auto pieceList : m_pieceLists) for (auto pieceList : m_pieceLists)
{ {

View File

@ -40,6 +40,7 @@
#include "vpmimedatapiece.h" #include "vpmimedatapiece.h"
#include "vpcarrouselpiecelist.h" #include "vpcarrouselpiecelist.h"
#include "vpcarrousel.h" #include "vpcarrousel.h"
#include "vpsheet.h"
#include <QLoggingCategory> #include <QLoggingCategory>
@ -240,7 +241,12 @@ void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event)
QMenu contextMenu; QMenu contextMenu;
VPPieceList* unplacedPieces = m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList(); VPPieceList* unplacedPieces = m_piece->GetPieceList()->GetLayout()->GetUnplacedPieceList();
QList<VPPieceList*> pieceLists = m_piece->GetPieceList()->GetLayout()->GetPiecesLists(); QList<VPSheet*> sheets = m_piece->GetPieceList()->GetLayout()->GetSheets();
QList<VPPieceList*> pieceLists = QList<VPPieceList*>();
for (auto sheet : sheets)
{
pieceLists.append(sheet->GetPieceList());
}
// move to piece list actions -- TODO : To be tested properly when we have several piece lists // move to piece list actions -- TODO : To be tested properly when we have several piece lists
pieceLists.removeAll(m_piece->GetPieceList()); pieceLists.removeAll(m_piece->GetPieceList());

View File

@ -42,6 +42,7 @@
#include "vppiece.h" #include "vppiece.h"
#include "vppiecelist.h" #include "vppiecelist.h"
#include "vplayout.h" #include "vplayout.h"
#include "vpsheet.h"
#include <QLoggingCategory> #include <QLoggingCategory>
Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece")
@ -294,10 +295,19 @@ void VPGraphicsPiece::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VPGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
// TODO/FIXME context menu needs to be refactored
QMenu contextMenu; QMenu contextMenu;
// move to piece list actions -- TODO : To be tested properly when we have several piece lists // move to piece list actions -- TODO : To be tested properly when we have several piece lists
QList<VPPieceList*> pieceLists = m_piece->GetPieceList()->GetLayout()->GetPiecesLists(); QList<VPPieceList*> pieceLists = QList<VPPieceList*>();
for(auto sheet : m_piece->GetPieceList()->GetLayout()->GetSheets())
{
pieceLists.append(sheet->GetPieceList());
}
pieceLists.removeAll(m_piece->GetPieceList()); pieceLists.removeAll(m_piece->GetPieceList());
if(pieceLists.count() > 0) if(pieceLists.count() > 0)

View File

@ -29,10 +29,10 @@
#include "vpgraphicssheet.h" #include "vpgraphicssheet.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPGraphicsSheet::VPGraphicsSheet(VPLayout *layout, QGraphicsItem *parent): VPGraphicsSheet::VPGraphicsSheet(VPSheet *sheet, QGraphicsItem *parent):
QGraphicsItem(parent), QGraphicsItem(parent),
m_layout(layout), m_sheet(sheet),
m_boundingRect(GetLayoutRect()) m_boundingRect(GetSheetRect())
{ {
} }
@ -60,23 +60,23 @@ void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
pen.setColor(Qt::black); pen.setColor(Qt::black);
painter->setPen(pen); painter->setPen(pen);
painter->drawRect(GetLayoutRect()); painter->drawRect(GetSheetRect());
m_boundingRect = GetLayoutRect(); m_boundingRect = GetSheetRect();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QRectF VPGraphicsSheet::GetLayoutRect() const QRectF VPGraphicsSheet::GetSheetRect() const
{ {
QRectF rect = QRectF(QPointF(0,0), m_layout->GetLayoutSize()); QRectF rect = QRectF(QPointF(0,0), m_sheet->GetSheetSize());
return rect; return rect;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QRectF VPGraphicsSheet::GetMarginsRect() const QRectF VPGraphicsSheet::GetMarginsRect() const
{ {
QMarginsF margins = m_layout->GetLayoutMargins(); QMarginsF margins = m_sheet->GetSheetMargins();
QSizeF size = m_layout->GetLayoutSize(); QSizeF size = m_sheet->GetSheetSize();
QRectF rect = QRectF( QRectF rect = QRectF(
QPointF(margins.left(),margins.top()), QPointF(margins.left(),margins.top()),
QPointF(size.width()-margins.right(), size.height()-margins.bottom()) QPointF(size.width()-margins.right(), size.height()-margins.bottom())

View File

@ -32,26 +32,26 @@
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QPainter> #include <QPainter>
#include "vplayout.h" #include "vpsheet.h"
class VPGraphicsSheet : public QGraphicsItem class VPGraphicsSheet : public QGraphicsItem
{ {
public: public:
explicit VPGraphicsSheet(VPLayout *layout, QGraphicsItem *parent = nullptr); explicit VPGraphicsSheet(VPSheet *sheet, QGraphicsItem *parent = nullptr);
~VPGraphicsSheet(); ~VPGraphicsSheet();
QRectF boundingRect() const override; QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override;
QRectF GetLayoutRect() const; QRectF GetSheetRect() const;
QRectF GetMarginsRect() const; QRectF GetMarginsRect() const;
private: private:
Q_DISABLE_COPY(VPGraphicsSheet) Q_DISABLE_COPY(VPGraphicsSheet)
VPLayout *m_layout{nullptr}; VPSheet *m_sheet{nullptr};
QRectF m_boundingRect; QRectF m_boundingRect;
}; };

View File

@ -28,26 +28,19 @@
#include "vplayout.h" #include "vplayout.h"
#include "vppiecelist.h" #include "vppiecelist.h"
#include "vppiece.h" #include "vppiece.h"
#include "vpsheet.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPLayout::VPLayout() : VPLayout::VPLayout() :
m_unplacedPieceList(new VPPieceList(this)) m_unplacedPieceList(new VPPieceList(this))
{ {
m_unplacedPieceList->SetName(QObject::tr("Unplaced pieces")); m_unplacedPieceList->SetName(QObject::tr("Unplaced pieces"));
// create a standard default piecelist:
VPPieceList *pieceList = new VPPieceList(this);
pieceList->SetName(QObject::tr("Layout"));
AddPieceList(pieceList);
// sets the default active piece list
SetFocusedPieceList();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPLayout::~VPLayout() VPLayout::~VPLayout()
{ {
qDeleteAll(m_pieceLists); qDeleteAll(m_sheets);
delete m_unplacedPieceList; delete m_unplacedPieceList;
} }
@ -58,24 +51,24 @@ VPPieceList* VPLayout::GetUnplacedPieceList()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPPieceList* VPLayout::AddPieceList() VPSheet* VPLayout::AddSheet()
{ {
VPPieceList *newPieceList = new VPPieceList(this); VPSheet *newSheet = new VPSheet(this);
m_pieceLists.append(newPieceList); m_sheets.append(newSheet);
return newPieceList; return newSheet;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPPieceList* VPLayout::AddPieceList(VPPieceList *pieceList) VPSheet* VPLayout::AddSheet(VPSheet *sheet)
{ {
m_pieceLists.append(pieceList); m_sheets.append(sheet);
return pieceList; return sheet;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QList<VPPieceList *> VPLayout::GetPiecesLists() QList<VPSheet *> VPLayout::GetSheets()
{ {
return m_pieceLists; return m_sheets;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -83,8 +76,12 @@ QList<VPPiece *> VPLayout::GetSelectedPieces()
{ {
QList<VPPiece *> result = QList<VPPiece *>(); QList<VPPiece *> result = QList<VPPiece *>();
QList<VPPieceList *> pieceLists = m_pieceLists; QList<VPPieceList *> pieceLists = QList<VPPieceList *>();
pieceLists.prepend(m_unplacedPieceList); pieceLists.append(m_unplacedPieceList);
for (auto sheet : m_sheets)
{
pieceLists.append(sheet->GetPieceList());
}
for (auto pieceList : pieceLists) for (auto pieceList : pieceLists)
{ {
@ -113,128 +110,6 @@ Unit VPLayout::GetUnit() const
return m_unit; return m_unit;
} }
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetLayoutSize(qreal width, qreal height)
{
m_size.setWidth(width);
m_size.setHeight(height);
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetLayoutSizeConverted(qreal width, qreal height)
{
m_size.setWidth(UnitConvertor(width, m_unit, Unit::Px));
m_size.setHeight(UnitConvertor(height, m_unit, Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetLayoutSize(const QSizeF &size)
{
m_size = size;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetLayoutSizeConverted(const QSizeF &size)
{
m_size = QSizeF(
UnitConvertor(size.width(), m_unit, Unit::Px),
UnitConvertor(size.height(), m_unit, Unit::Px)
);
}
//---------------------------------------------------------------------------------------------------------------------
QSizeF VPLayout::GetLayoutSize() const
{
return m_size;
}
//---------------------------------------------------------------------------------------------------------------------
QSizeF VPLayout::GetLayoutSizeConverted() const
{
QSizeF convertedSize = QSizeF(
UnitConvertor(m_size.width(), Unit::Px, m_unit),
UnitConvertor(m_size.height(), Unit::Px, m_unit)
);
return convertedSize;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetLayoutMargins(qreal left, qreal top, qreal right, qreal bottom)
{
m_margins.setLeft(left);
m_margins.setTop(top);
m_margins.setRight(right);
m_margins.setBottom(bottom);
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetLayoutMarginsConverted(qreal left, qreal top, qreal right, qreal bottom)
{
m_margins.setLeft(UnitConvertor(left, m_unit, Unit::Px));
m_margins.setTop(UnitConvertor(top, m_unit, Unit::Px));
m_margins.setRight(UnitConvertor(right, m_unit, Unit::Px));
m_margins.setBottom(UnitConvertor(bottom, m_unit, Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetLayoutMargins(const QMarginsF &margins)
{
m_margins = margins;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetLayoutMarginsConverted(const QMarginsF &margins)
{
m_margins = UnitConvertor(margins, m_unit, Unit::Px);
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VPLayout::GetLayoutMargins() const
{
return m_margins;
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VPLayout::GetLayoutMarginsConverted() const
{
return UnitConvertor(m_margins, Unit::Px, m_unit);
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetFollowGrainline(FollowGrainline state)
{
m_followGrainLine = state;
}
//---------------------------------------------------------------------------------------------------------------------
FollowGrainline VPLayout::GetFollowGrainline() const
{
return m_followGrainLine;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetPiecesGap(qreal value)
{
m_piecesGap = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetPiecesGapConverted(qreal value)
{
m_piecesGap = UnitConvertor(value, m_unit, Unit::Px);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPLayout::GetPiecesGap() const
{
return m_piecesGap;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPLayout::GetPiecesGapConverted() const
{
return UnitConvertor(m_piecesGap, Unit::Px, m_unit);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetWarningSuperpositionOfPieces(bool state) void VPLayout::SetWarningSuperpositionOfPieces(bool state)
@ -260,48 +135,17 @@ bool VPLayout::GetWarningPiecesOutOfBound() const
return m_warningPiecesOutOfBound; return m_warningPiecesOutOfBound;
} }
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetStickyEdges(bool state)
{
m_stickyEdges = state;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPLayout::GetStickyEdges() const
{
return m_stickyEdges;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayout::ClearSelection() void VPLayout::ClearSelection()
{ {
m_unplacedPieceList->ClearSelection(); m_unplacedPieceList->ClearSelection();
for (auto pieceList : m_pieceLists) for (auto sheet : m_sheets)
{ {
pieceList->ClearSelection(); sheet->ClearSelection();
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetFocusedPieceList(VPPieceList* focusedPieceList)
{
if(focusedPieceList == nullptr)
{
m_focusedPieceList = m_pieceLists.first();
}
else
{
m_focusedPieceList = focusedPieceList;
}
}
//---------------------------------------------------------------------------------------------------------------------
VPPieceList* VPLayout::GetFocusedPieceList()
{
return m_focusedPieceList;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayout::MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList) void VPLayout::MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList)
{ {
@ -316,3 +160,23 @@ void VPLayout::MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList)
// signal, that a piece was moved // signal, that a piece was moved
emit PieceMovedToPieceList(piece, pieceListBefore,pieceList); emit PieceMovedToPieceList(piece, pieceListBefore,pieceList);
} }
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetFocusedSheet(VPSheet *focusedSheet)
{
if(focusedSheet == nullptr)
{
m_focusedSheet = m_sheets.first();
}
else
{
m_focusedSheet = focusedSheet;
}
}
//---------------------------------------------------------------------------------------------------------------------
VPSheet* VPLayout::GetFocusedSheet()
{
return m_focusedSheet;
}

View File

@ -28,17 +28,14 @@
#ifndef VPLAYOUT_H #ifndef VPLAYOUT_H
#define VPLAYOUT_H #define VPLAYOUT_H
#include <QSizeF>
#include <QMarginsF>
#include <QList> #include <QList>
#include "def.h" #include "def.h"
class VPPieceList; class VPPieceList;
class VPPiece; class VPPiece;
class VPSheet;
// is this the right place for the definition?
enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2};
class VPLayout : public QObject class VPLayout : public QObject
{ {
@ -53,9 +50,9 @@ public:
*/ */
VPPieceList* GetUnplacedPieceList(); VPPieceList* GetUnplacedPieceList();
VPPieceList* AddPieceList(); VPSheet* AddSheet();
VPPieceList* AddPieceList(VPPieceList *pieceList); VPSheet* AddSheet(VPSheet *sheet);
QList<VPPieceList *> GetPiecesLists(); QList<VPSheet *> GetSheets();
/** /**
* @brief GetSelectedPieces Returns the list of the selected pieces * @brief GetSelectedPieces Returns the list of the selected pieces
@ -75,150 +72,18 @@ public:
*/ */
Unit GetUnit() const; Unit GetUnit() const;
/**
* @brief SetLayoutSize sets the size of the layout, the values have to be in Unit::Px
* @param width layout width
* @param height layout height
*/
void SetLayoutSize(qreal width, qreal height);
/**
* @brief SetLayoutSize sets the size of the layout, the values have to be in the layout's unit
* @param width layout width
* @param height layout height
*/
void SetLayoutSizeConverted(qreal width, qreal height);
/**
* @brief SetLayoutSize sets the size of the layout, the values have to be in Unit::Px
* @param size layout size
*/
void SetLayoutSize(const QSizeF &size);
/**
* @brief SetLayoutSizeConverted sets the size of the layout, the values have to be in the layout's unit
* @param size layout size
*/
void SetLayoutSizeConverted(const QSizeF &size);
/**
* @brief GetLayoutSize Returns the size in Unit::Px
* @return layout size in Unit::Px
*/
QSizeF GetLayoutSize() const;
/**
* @brief GetLayoutSizeConverted Returns the size in the layout's unit
* @return the size in the layout's unit
*/
QSizeF GetLayoutSizeConverted() const;
/**
* @brief SetLayoutMargins, set the margins of the layout, 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 SetLayoutMargins(qreal left, qreal top, qreal right, qreal bottom);
/**
* @brief SetLayoutMargins, set the margins of the layout, 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 SetLayoutMarginsConverted(qreal left, qreal top, qreal right, qreal bottom);
/**
* @brief SetLayoutMargins set the margins of the layout, the values have to be in Unit::Px
* @param margins layout margins
*/
void SetLayoutMargins(const QMarginsF &margins);
/**
* @brief SetLayoutMargins set the margins of the layout, the values have to be in the unit of the layout
* @param margins layout margins
*/
void SetLayoutMarginsConverted(const QMarginsF &margins);
/**
* @brief GetLayoutMargins Returns the size in Unit::Px
* @return the size in Unit::Px
*/
QMarginsF GetLayoutMargins() const;
/**
* @brief GetLayoutMarginsConverted Returns the margins in the layout's unit
* @return the margins in the layout's unit
*/
QMarginsF GetLayoutMarginsConverted() const;
/**
* @brief SetFollowGrainline Sets the type of grainline for the pieces to follow
* @param state the type of grainline
*/
void SetFollowGrainline(FollowGrainline state);
/**
* @brief GetFollowGrainline Returns if the layout's pieces follow a grainline or not
* @return wether the pieces follow a grainline and if so, which grainline
*/
FollowGrainline GetFollowGrainline() const;
/**
* @brief SetPiecesGap sets the pieces gap to the given value, the unit has to be in Unit::Px
* @param value pieces gap
*/
void SetPiecesGap(qreal value);
/**
* @brief SetPiecesGapConverted sets the pieces gap to the given value, the unit has to be in the layout's unit
* @param value pieces gap
*/
void SetPiecesGapConverted(qreal value);
/**
* @brief GetPiecesGap returns the pieces gap in Unit::Px
* @return the pieces gap in Unit::Px
*/
qreal GetPiecesGap() const;
/**
* @brief GetPiecesGapConverted returns the pieces gap in the layout's unit
* @return the pieces gap in the layout's unit
*/
qreal GetPiecesGapConverted() const;
void SetWarningSuperpositionOfPieces(bool state); void SetWarningSuperpositionOfPieces(bool state);
bool GetWarningSuperpositionOfPieces() const; bool GetWarningSuperpositionOfPieces() const;
void SetWarningPiecesOutOfBound(bool state); void SetWarningPiecesOutOfBound(bool state);
bool GetWarningPiecesOutOfBound() const; bool GetWarningPiecesOutOfBound() const;
void SetStickyEdges(bool state);
bool GetStickyEdges() const;
/** /**
* @brief ClearSelection goes through the piece list and pieces and calls * @brief ClearSelection goes through the unplaced pieces and through the sheets and calls
* SetIsSelected(false) for the pieces that were selected. * SetIsSelected(false) for the pieces that were selected.
*/ */
void ClearSelection(); void ClearSelection();
/**
* @brief SetFocusedPieceList Sets the focused piece klist, to which pieces are added from the carrousel via drag
* and drop
* @param focusedPieceList the new active piece list. If nullptr, then it sets automaticaly the first piece list from m_pieceLists
*/
void SetFocusedPieceList(VPPieceList* focusedPieceList = nullptr);
/**
* @brief GetFocusedPieceList Returns the focused piece list, to which pieces are added from the carrousel via drag
* and drop
* @return the focused piece list
*/
VPPieceList* GetFocusedPieceList();
/** /**
* @brief MovePieceToPieceList Moves the given piece to the given piece list * @brief MovePieceToPieceList Moves the given piece to the given piece list
* @param piece the piece to move * @param piece the piece to move
@ -226,6 +91,21 @@ public:
*/ */
void MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList); void MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList);
/**
* @brief SetFocusedSheet Sets the focused sheet, to which pieces are added from the carrousel via drag
* and drop
* @param focusedSheet the new active sheet. If nullptr, then it sets automaticaly the first sheet from m_sheets
*/
void SetFocusedSheet(VPSheet *focusedSheet = nullptr);
/**
* @brief GetFocusedSheet Returns the focused sheet, to which pieces are added from the carrousel via drag
* and drop
* @return the focused sheet
*/
VPSheet* GetFocusedSheet();
signals: signals:
void PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter); void PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter);
@ -234,37 +114,25 @@ private:
Q_DISABLE_COPY(VPLayout) Q_DISABLE_COPY(VPLayout)
VPPieceList *m_unplacedPieceList; VPPieceList *m_unplacedPieceList;
QList<VPPieceList *> m_pieceLists{};
QList<VPSheet*> m_sheets;
/** /**
TODO : To be replaced by m_focusedSheet
* @brief m_focusedPieceList pointer the the focused piece list, to which pieces will be * @brief m_focusedPieceList pointer the the focused piece list, to which pieces will be
* added via drag and drop, or if no piece list is defined. * added via drag and drop, or if no piece list is defined.
*/ */
VPPieceList *m_focusedPieceList{nullptr}; VPPieceList *m_focusedPieceList{nullptr};
VPSheet *m_focusedSheet{nullptr};
// format // format
Unit m_unit{Unit::Cm}; Unit m_unit{Unit::Cm};
/**
* @brief m_size the Size in Unit::Px
*/
QSizeF m_size{};
// margins
/**
* @brief m_margins the margins in Unit::Px
*/
QMarginsF m_margins{};
// control
FollowGrainline m_followGrainLine{FollowGrainline::No};
/**
* @brief m_piecesGap the pieces gap in Unit::Px
*/
qreal m_piecesGap{0};
bool m_warningSuperpositionOfPieces{false}; bool m_warningSuperpositionOfPieces{false};
bool m_warningPiecesOutOfBound{false}; bool m_warningPiecesOutOfBound{false};
bool m_stickyEdges{false};
}; };

View File

@ -34,6 +34,8 @@
#include "vpmimedatapiece.h" #include "vpmimedatapiece.h"
#include "vppiecelist.h" #include "vppiecelist.h"
#include "vplayout.h"
#include "vpsheet.h"
#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsscene.h"
#include <QLoggingCategory> #include <QLoggingCategory>
@ -46,10 +48,11 @@ VPMainGraphicsView::VPMainGraphicsView(VPLayout *layout, QWidget *parent) :
VMainGraphicsView(parent), VMainGraphicsView(parent),
m_layout(layout) m_layout(layout)
{ {
// TODO : list of scenes
m_scene = new VMainGraphicsScene(this); m_scene = new VMainGraphicsScene(this);
setScene(m_scene); setScene(m_scene);
m_graphicsSheet = new VPGraphicsSheet(layout); m_graphicsSheet = new VPGraphicsSheet(layout->GetFocusedSheet());
m_graphicsSheet->setPos(0, 0); m_graphicsSheet->setPos(0, 0);
m_scene->addItem(m_graphicsSheet); m_scene->addItem(m_graphicsSheet);
@ -123,7 +126,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
piece->SetPosition(mapToScene(point)); piece->SetPosition(mapToScene(point));
// change the piecelist of the piece // change the piecelist of the piece
VPPieceList *focusedPieceList = m_layout->GetFocusedPieceList(); VPPieceList *focusedPieceList = m_layout->GetFocusedSheet()->GetPieceList();
if(focusedPieceList != nullptr) if(focusedPieceList != nullptr)
{ {
m_layout->MovePieceToPieceList(piece, focusedPieceList); m_layout->MovePieceToPieceList(piece, focusedPieceList);

View File

@ -40,6 +40,7 @@
#include "../vmisc/projectversion.h" #include "../vmisc/projectversion.h"
#include "../ifc/xml/vlayoutconverter.h" #include "../ifc/xml/vlayoutconverter.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "vpsheet.h"
#include <QLoggingCategory> #include <QLoggingCategory>
@ -57,13 +58,19 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
ui(new Ui::VPMainWindow), ui(new Ui::VPMainWindow),
m_cmd(cmd) m_cmd(cmd)
{ {
m_layout = new VPLayout(); m_layout = new VPLayout();
// create a standard sheet
VPSheet *sheet = new VPSheet(m_layout);
sheet->SetName(QObject::tr("Sheet #1"));
m_layout->AddSheet(sheet);
m_layout->SetFocusedSheet();
// ----- for test purposes, to be removed------------------ // ----- for test purposes, to be removed------------------
m_layout->SetLayoutMarginsConverted(2, 2, 2, 2); sheet->SetSheetMarginsConverted(2, 2, 2, 2);
m_layout->SetLayoutSizeConverted(30.0, 45); sheet->SetSheetSizeConverted(30.0, 45);
m_layout->SetPiecesGapConverted(1); sheet->SetPiecesGapConverted(1);
m_layout->SetUnit(Unit::Cm); m_layout->SetUnit(Unit::Cm);
m_layout->SetWarningSuperpositionOfPieces(true); m_layout->SetWarningSuperpositionOfPieces(true);
// -------------------------------------------------------- // --------------------------------------------------------
@ -270,32 +277,32 @@ void VPMainWindow::InitPropertyTabLayout()
// see https://doc.qt.io/qt-5/designer-using-a-ui-file.html#widgets-and-dialogs-with-auto-connect // see https://doc.qt.io/qt-5/designer-using-a-ui-file.html#widgets-and-dialogs-with-auto-connect
// -------------------- layout width, length, orientation ------------------------ // -------------------- layout width, length, orientation ------------------------
connect(ui->doubleSpinBoxLayoutWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutSizeChanged); &VPMainWindow::on_SheetSizeChanged);
connect(ui->doubleSpinBoxLayoutLength, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetLength, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutSizeChanged); &VPMainWindow::on_SheetSizeChanged);
connect(ui->radioButtonLayoutPortrait, QOverload<bool>::of(&QRadioButton::clicked), this, connect(ui->radioButtonSheetPortrait, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_LayoutOrientationChanged); &VPMainWindow::on_SheetOrientationChanged);
connect(ui->radioButtonLayoutLandscape, QOverload<bool>::of(&QRadioButton::clicked), this, connect(ui->radioButtonSheetLandscape, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_LayoutOrientationChanged); &VPMainWindow::on_SheetOrientationChanged);
// -------------------- margins ------------------------ // -------------------- margins ------------------------
connect(ui->doubleSpinBoxLayoutMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutMarginChanged); &VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxLayoutMarginRight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetMarginRight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutMarginChanged); &VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxLayoutMarginBottom, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetMarginBottom, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutMarginChanged); &VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxLayoutMarginLeft, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, connect(ui->doubleSpinBoxSheetMarginLeft, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutMarginChanged); &VPMainWindow::on_SheetMarginChanged);
// ------------------- follow grainline ----------------------- // ------------------- follow grainline -----------------------
connect(ui->radioButtonLayoutFollowGrainlineNo, QOverload<bool>::of(&QRadioButton::clicked), this, connect(ui->radioButtonSheetFollowGrainlineNo, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_LayoutFollowGrainlineChanged); &VPMainWindow::on_SheetFollowGrainlineChanged);
connect(ui->radioButtonLayoutFollowGrainlineVertical, QOverload<bool>::of(&QRadioButton::clicked), this, connect(ui->radioButtonSheetFollowGrainlineVertical, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_LayoutFollowGrainlineChanged); &VPMainWindow::on_SheetFollowGrainlineChanged);
connect(ui->radioButtonLayoutFollowGrainlineHorizontal, QOverload<bool>::of(&QRadioButton::clicked), this, connect(ui->radioButtonSheetFollowGrainlineHorizontal, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_LayoutFollowGrainlineChanged); &VPMainWindow::on_SheetFollowGrainlineChanged);
// -------------------- export --------------------------- // -------------------- export ---------------------------
@ -332,8 +339,9 @@ void VPMainWindow::SetPropertiesData()
else else
{ {
SetPropertyTabCurrentPieceData(); SetPropertyTabCurrentPieceData();
SetPropertyTabLayoutData(); SetPropertyTabSheetData();
SetPropertyTabTilesData(); SetPropertyTabTilesData();
SetPropertyTabLayoutData();
} }
} }
@ -384,9 +392,43 @@ void VPMainWindow::SetPropertyTabCurrentPieceData()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::SetPropertyTabSheetData()
{
// set Width / Length
QSizeF size = m_layout->GetFocusedSheet()->GetSheetSizeConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetWidth, size.width());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetLength, size.height());
// Set Orientation
if(size.width() <= size.height())
{
ui->radioButtonSheetPortrait->setChecked(true);
}
else
{
ui->radioButtonSheetLandscape->setChecked(true);
}
// set margins
QMarginsF margins = m_layout->GetFocusedSheet()->GetSheetMarginsConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, margins.left());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, margins.top());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, margins.right());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, margins.bottom());
// set pieces gap
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPiecesGap, m_layout->GetFocusedSheet()->GetPiecesGapConverted());
// set the checkboxes
SetCheckBoxValue(ui->checkBoxSheetStickyEdges, m_layout->GetFocusedSheet()->GetStickyEdges());
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::SetPropertyTabLayoutData() void VPMainWindow::SetPropertyTabLayoutData()
{ {
// TODO FIXME : Set name and description
// set Unit // set Unit
int index = ui->comboBoxLayoutUnit->findData(QVariant(UnitsToStr(m_layout->GetUnit()))); int index = ui->comboBoxLayoutUnit->findData(QVariant(UnitsToStr(m_layout->GetUnit())));
if(index != -1) if(index != -1)
@ -396,35 +438,9 @@ void VPMainWindow::SetPropertyTabLayoutData()
ui->comboBoxLayoutUnit->blockSignals(false); ui->comboBoxLayoutUnit->blockSignals(false);
} }
// set Width / Length // set controls
QSizeF size = m_layout->GetLayoutSizeConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutWidth, size.width());
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutLength, size.height());
// Set Orientation
if(size.width() <= size.height())
{
ui->radioButtonLayoutPortrait->setChecked(true);
}
else
{
ui->radioButtonLayoutLandscape->setChecked(true);
}
// set margins
QMarginsF margins = m_layout->GetLayoutMarginsConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutMarginLeft, margins.left());
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutMarginTop, margins.top());
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutMarginRight, margins.right());
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutMarginBottom, margins.bottom());
// set pieces gap
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutPiecesGap, m_layout->GetPiecesGapConverted());
// set the checkboxes
SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, m_layout->GetWarningPiecesOutOfBound()); SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, m_layout->GetWarningPiecesOutOfBound());
SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, m_layout->GetWarningSuperpositionOfPieces()); SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, m_layout->GetWarningSuperpositionOfPieces());
SetCheckBoxValue(ui->checkBoxLayoutStickyEdges, m_layout->GetStickyEdges());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -763,16 +779,16 @@ void VPMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index)
m_layout->SetUnit(Unit::Inch); m_layout->SetUnit(Unit::Inch);
} }
SetPropertyTabLayoutData(); SetPropertyTabSheetData();
SetPropertyTabCurrentPieceData(); SetPropertyTabCurrentPieceData();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index) void VPMainWindow::on_comboBoxSheetTemplate_currentIndexChanged(int index)
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("TODO VPMainWindow::LayoutTemplateChanged"); msgBox.setText("TODO VPMainWindow::SheetTemplateChanged");
int ret = msgBox.exec(); int ret = msgBox.exec();
Q_UNUSED(index); Q_UNUSED(index);
@ -783,20 +799,20 @@ void VPMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_LayoutSizeChanged() void VPMainWindow::on_SheetSizeChanged()
{ {
m_layout->SetLayoutSizeConverted(ui->doubleSpinBoxLayoutWidth->value(), ui->doubleSpinBoxLayoutLength->value()); m_layout->GetFocusedSheet()->SetSheetSizeConverted(ui->doubleSpinBoxSheetWidth->value(), ui->doubleSpinBoxSheetLength->value());
// updates orientation - no need to block signals because the signal reacts on "clicked" // updates orientation - no need to block signals because the signal reacts on "clicked"
if(ui->doubleSpinBoxLayoutWidth->value() <= ui->doubleSpinBoxLayoutLength->value()) if(ui->doubleSpinBoxSheetWidth->value() <= ui->doubleSpinBoxSheetLength->value())
{ {
//portrait //portrait
ui->radioButtonLayoutPortrait->setChecked(true); ui->radioButtonSheetPortrait->setChecked(true);
} }
else else
{ {
//landscape //landscape
ui->radioButtonLayoutLandscape->setChecked(true); ui->radioButtonSheetLandscape->setChecked(true);
} }
// TODO Undo / Redo // TODO Undo / Redo
@ -805,16 +821,16 @@ void VPMainWindow::on_LayoutSizeChanged()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_LayoutOrientationChanged() void VPMainWindow::on_SheetOrientationChanged()
{ {
// swap the width and length // swap the width and length
qreal width_before = ui->doubleSpinBoxLayoutWidth->value(); qreal width_before = ui->doubleSpinBoxSheetWidth->value();
qreal length_before = ui->doubleSpinBoxLayoutLength->value(); qreal length_before = ui->doubleSpinBoxSheetLength->value();
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutWidth, length_before); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetWidth, length_before);
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutLength, width_before); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetLength, width_before);
m_layout->SetLayoutSizeConverted(ui->doubleSpinBoxLayoutWidth->value(), ui->doubleSpinBoxLayoutLength->value()); m_layout->GetFocusedSheet()->SetSheetSizeConverted(ui->doubleSpinBoxSheetWidth->value(), ui->doubleSpinBoxSheetLength->value());
// TODO Undo / Redo // TODO Undo / Redo
@ -822,7 +838,7 @@ void VPMainWindow::on_LayoutOrientationChanged()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked() void VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked()
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;
@ -836,13 +852,13 @@ void VPMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_LayoutMarginChanged() void VPMainWindow::on_SheetMarginChanged()
{ {
m_layout->SetLayoutMarginsConverted( m_layout->GetFocusedSheet()->SetSheetMarginsConverted(
ui->doubleSpinBoxLayoutMarginLeft->value(), ui->doubleSpinBoxSheetMarginLeft->value(),
ui->doubleSpinBoxLayoutMarginTop->value(), ui->doubleSpinBoxSheetMarginTop->value(),
ui->doubleSpinBoxLayoutMarginRight->value(), ui->doubleSpinBoxSheetMarginRight->value(),
ui->doubleSpinBoxLayoutMarginBottom->value() ui->doubleSpinBoxSheetMarginBottom->value()
); );
// TODO Undo / Redo // TODO Undo / Redo
@ -852,7 +868,7 @@ void VPMainWindow::on_LayoutMarginChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_LayoutFollowGrainlineChanged() void VPMainWindow::on_SheetFollowGrainlineChanged()
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;
@ -866,9 +882,9 @@ void VPMainWindow::on_LayoutFollowGrainlineChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_doubleSpinBoxLayoutPiecesGap_valueChanged(double value) void VPMainWindow::on_doubleSpinBoxSheetPiecesGap_valueChanged(double value)
{ {
m_layout->SetPiecesGapConverted(value); m_layout->GetFocusedSheet()->SetPiecesGapConverted(value);
// TODO Undo / Redo // TODO Undo / Redo
// TODO update the QGraphicView // TODO update the QGraphicView
@ -893,16 +909,16 @@ void VPMainWindow::on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool checked
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_checkBoxLayoutStickyEdges_toggled(bool checked) void VPMainWindow::on_checkBoxSheetStickyEdges_toggled(bool checked)
{ {
m_layout->SetStickyEdges(checked); m_layout->GetFocusedSheet()->SetStickyEdges(checked);
// TODO Undo / Redo // TODO Undo / Redo
// TODO update the QGraphicView // TODO update the QGraphicView
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonLayoutExport_clicked() void VPMainWindow::on_pushButtonSheetExport_clicked()
{ {
// just for test purpuses, to be removed: // just for test purpuses, to be removed:
QMessageBox msgBox; QMessageBox msgBox;

View File

@ -152,10 +152,10 @@ private:
void SetPropertyTabCurrentPieceData(); void SetPropertyTabCurrentPieceData();
/** /**
* @brief SetPropertyTabLayoutData Sets the values of UI elements * @brief SetPropertyTabSheetData Sets the values of UI elements
* in the Layout Tab to the values saved in m_layout * in the Sheet Tab to the values saved in focused sheet
*/ */
void SetPropertyTabLayoutData(); void SetPropertyTabSheetData();
/** /**
* @brief SetPropertyTabTilesData Sets the values of UI elements * @brief SetPropertyTabTilesData Sets the values of UI elements
@ -163,6 +163,12 @@ private:
*/ */
void SetPropertyTabTilesData(); void SetPropertyTabTilesData();
/**
* @brief SetPropertyTabLayoutData Sets the values of UI elements
* in the Layout Tab to the values saved in m_layout
*/
void SetPropertyTabLayoutData();
/** /**
* @brief SetDoubleSpinBoxValue sets the given spinbox to the given value. * @brief SetDoubleSpinBoxValue sets the given spinbox to the given value.
* the signals are blocked before changing the value and unblocked after * the signals are blocked before changing the value and unblocked after
@ -248,38 +254,38 @@ private slots:
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
* @param index the index of the selected templated * @param index the index of the selected templated
*/ */
void on_comboBoxLayoutTemplate_currentIndexChanged(int index); void on_comboBoxSheetTemplate_currentIndexChanged(int index);
/** /**
* @brief LayoutSizeChanged When the width or the length has been changed in * @brief LayoutSizeChanged When the width or the length has been changed in
* the layout property tab * the layout property tab
*/ */
void on_LayoutSizeChanged(); void on_SheetSizeChanged();
/** /**
* @brief LayoutOrientationChanged When one of the radio boxes for the layout * @brief LayoutOrientationChanged When one of the radio boxes for the layout
* orientation has been clicked * orientation has been clicked
*/ */
void on_LayoutOrientationChanged(); void on_SheetOrientationChanged();
/** /**
* @brief on_pushButtonLayoutRemoveUnusedLength_clicked When the button * @brief on_pushButtonLayoutRemoveUnusedLength_clicked When the button
* "Remove unused length" in the layout property tab is clicked. * "Remove unused length" in the layout property tab is clicked.
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
*/ */
void on_pushButtonLayoutRemoveUnusedLength_clicked(); void on_pushButtonSheetRemoveUnusedLength_clicked();
/** /**
* @brief on_LayoutMarginChanged When one of the margin values has been changed * @brief on_LayoutMarginChanged When one of the margin values has been changed
* in the layout property tab. * in the layout property tab.
*/ */
void on_LayoutMarginChanged(); void on_SheetMarginChanged();
/** /**
* @brief LayoutFollowGrainlineChanged When one of the radio boxes for the * @brief LayoutFollowGrainlineChanged When one of the radio boxes for the
* "Follow grainline" has been clicked in the layout property tab. * "Follow grainline" has been clicked in the layout property tab.
*/ */
void on_LayoutFollowGrainlineChanged(); void on_SheetFollowGrainlineChanged();
/** /**
* @brief on_doubleSpinBoxLayoutPiecesGap_valueChanged When the "pieces gap" * @brief on_doubleSpinBoxLayoutPiecesGap_valueChanged When the "pieces gap"
@ -287,7 +293,7 @@ private slots:
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
* @param value the new value of the pieces gap * @param value the new value of the pieces gap
*/ */
void on_doubleSpinBoxLayoutPiecesGap_valueChanged(double value); void on_doubleSpinBoxSheetPiecesGap_valueChanged(double value);
/** /**
* @brief on_checkBoxLayoutWarningPiecesSuperposition_toggled When the * @brief on_checkBoxLayoutWarningPiecesSuperposition_toggled When the
@ -313,14 +319,14 @@ private slots:
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
* @param checked the new checked value * @param checked the new checked value
*/ */
void on_checkBoxLayoutStickyEdges_toggled(bool checked); void on_checkBoxSheetStickyEdges_toggled(bool checked);
/** /**
* @brief on_pushButtonLayoutExport_clicked When the button * @brief on_pushButtonLayoutExport_clicked When the button
* "Export layout" in the layout property is clicked. * "Export layout" in the layout property is clicked.
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
*/ */
void on_pushButtonLayoutExport_clicked(); void on_pushButtonSheetExport_clicked();
/** /**
* @brief on_checkBoxCurrentPieceShowSeamline_toggled When the * @brief on_checkBoxCurrentPieceShowSeamline_toggled When the

View File

@ -172,7 +172,7 @@
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>1</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -458,7 +458,7 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabLayoutProperty"> <widget class="QWidget" name="tabSheetProperty">
<attribute name="icon"> <attribute name="icon">
<iconset resource="share/resources/puzzleicon.qrc"> <iconset resource="share/resources/puzzleicon.qrc">
<normaloff>:/puzzleicon/64x64/iconLayout.png</normaloff>:/puzzleicon/64x64/iconLayout.png</iconset> <normaloff>:/puzzleicon/64x64/iconLayout.png</normaloff>:/puzzleicon/64x64/iconLayout.png</iconset>
@ -483,7 +483,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QScrollArea" name="scrollAreaLayout"> <widget class="QScrollArea" name="scrollAreaSheet">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
@ -507,12 +507,12 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QLabel" name="labelLayout"> <widget class="QLabel" name="labelSheet">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font-weight: bold;</string> <string notr="true">font-weight: bold;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Layout</string> <string>Current sheet</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -520,7 +520,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxLayoutFormat"> <widget class="QGroupBox" name="groupBoxSheetFormat">
<property name="title"> <property name="title">
<string>Format</string> <string>Format</string>
</property> </property>
@ -528,64 +528,54 @@
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelLayoutUnit"> <widget class="QLabel" name="labelSheetTemplate">
<property name="text">
<string>Unit</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxLayoutUnit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelLayoutTemplate">
<property name="text"> <property name="text">
<string>Template</string> <string>Template</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="comboBoxLayoutTemplate"/> <widget class="QComboBox" name="comboBoxSheetTemplate"/>
</item> </item>
<item row="2" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelLayoutwidth"> <widget class="QLabel" name="labelSheetwidth">
<property name="text"> <property name="text">
<string>Width</string> <string>Width</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutWidth"> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetWidth">
<property name="maximum"> <property name="maximum">
<double>100000.000000000000000</double> <double>100000.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="2" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutLength"> <widget class="QLabel" name="labelSheetLength">
<property name="text">
<string>Length</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetLength">
<property name="maximum"> <property name="maximum">
<double>100000.000000000000000</double> <double>100000.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="labelLayoutLength"> <widget class="QLabel" name="labelSheetOrientation">
<property name="text">
<string>Length</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelLayoutOrientation">
<property name="text"> <property name="text">
<string>Orientation</string> <string>Orientation</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QRadioButton" name="radioButtonLayoutPortrait"> <widget class="QRadioButton" name="radioButtonSheetPortrait">
<property name="toolTip"> <property name="toolTip">
<string>Portrait</string> <string>Portrait</string>
</property> </property>
@ -608,7 +598,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButtonLayoutLandscape"> <widget class="QRadioButton" name="radioButtonSheetLandscape">
<property name="toolTip"> <property name="toolTip">
<string>Landscape</string> <string>Landscape</string>
</property> </property>
@ -632,7 +622,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButtonLayoutRemoveUnusedLength"> <widget class="QPushButton" name="pushButtonSheetRemoveUnusedLength">
<property name="text"> <property name="text">
<string>Remove unused length</string> <string>Remove unused length</string>
</property> </property>
@ -642,13 +632,13 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxLayoutMargin"> <widget class="QGroupBox" name="groupBoxSheetMargin">
<property name="title"> <property name="title">
<string>Margins</string> <string>Margins</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLabel" name="labelLayoutMarginRight"> <widget class="QLabel" name="labelSheetMarginRight">
<property name="text"> <property name="text">
<string>Right:</string> <string>Right:</string>
</property> </property>
@ -658,7 +648,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="labelLayoutMarginTop"> <widget class="QLabel" name="labelSheetMarginTop">
<property name="text"> <property name="text">
<string>Top:</string> <string>Top:</string>
</property> </property>
@ -668,21 +658,21 @@
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="1" column="3">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutMarginRight"> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetMarginRight">
<property name="singleStep"> <property name="singleStep">
<double>0.100000000000000</double> <double>0.100000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutMarginLeft"> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetMarginLeft">
<property name="singleStep"> <property name="singleStep">
<double>0.100000000000000</double> <double>0.100000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelLayoutMarginLeft"> <widget class="QLabel" name="labelSheetMarginLeft">
<property name="text"> <property name="text">
<string>Left:</string> <string>Left:</string>
</property> </property>
@ -692,7 +682,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutMarginTop"> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetMarginTop">
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property> </property>
@ -702,14 +692,14 @@
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutMarginBottom"> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetMarginBottom">
<property name="singleStep"> <property name="singleStep">
<double>0.100000000000000</double> <double>0.100000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLabel" name="labelLayoutMarginBottom"> <widget class="QLabel" name="labelSheetMarginBottom">
<property name="text"> <property name="text">
<string>Bottom:</string> <string>Bottom:</string>
</property> </property>
@ -722,7 +712,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxLayoutControl"> <widget class="QGroupBox" name="groupBoxSheetControl">
<property name="title"> <property name="title">
<string>Control</string> <string>Control</string>
</property> </property>
@ -730,7 +720,7 @@
<item> <item>
<layout class="QFormLayout" name="formLayout_2"> <layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelLayoutFollowGrainline"> <widget class="QLabel" name="labelSheetFollowGrainline">
<property name="text"> <property name="text">
<string>Follow grainline</string> <string>Follow grainline</string>
</property> </property>
@ -739,7 +729,7 @@
<item row="0" column="1"> <item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QRadioButton" name="radioButtonLayoutFollowGrainlineNo"> <widget class="QRadioButton" name="radioButtonSheetFollowGrainlineNo">
<property name="text"> <property name="text">
<string>No</string> <string>No</string>
</property> </property>
@ -749,7 +739,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButtonLayoutFollowGrainlineVertical"> <widget class="QRadioButton" name="radioButtonSheetFollowGrainlineVertical">
<property name="toolTip"> <property name="toolTip">
<string>Vertical grainline</string> <string>Vertical grainline</string>
</property> </property>
@ -769,7 +759,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButtonLayoutFollowGrainlineHorizontal"> <widget class="QRadioButton" name="radioButtonSheetFollowGrainlineHorizontal">
<property name="toolTip"> <property name="toolTip">
<string>Horizontal grainline</string> <string>Horizontal grainline</string>
</property> </property>
@ -791,33 +781,19 @@
</layout> </layout>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelLayoutPiecesGap"> <widget class="QLabel" name="labelSheetPiecesGap">
<property name="text"> <property name="text">
<string>Pieces gap</string> <string>Pieces gap</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutPiecesGap"/> <widget class="QDoubleSpinBox" name="doubleSpinBoxSheetPiecesGap"/>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBoxLayoutWarningPiecesSuperposition"> <widget class="QCheckBox" name="checkBoxSheetStickyEdges">
<property name="text">
<string>Warning superposition of pieces</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxLayoutWarningPiecesOutOfBound">
<property name="text">
<string>Warning pieces out of bound</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxLayoutStickyEdges">
<property name="text"> <property name="text">
<string>Sticky edges</string> <string>Sticky edges</string>
</property> </property>
@ -827,7 +803,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="LayoutExport"> <widget class="QGroupBox" name="SheetExport">
<property name="title"> <property name="title">
<string>Export</string> <string>Export</string>
</property> </property>
@ -835,21 +811,21 @@
<item> <item>
<layout class="QFormLayout" name="formLayout_3"> <layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelLayoutExportFormat"> <widget class="QLabel" name="labelSheetExportFormat">
<property name="text"> <property name="text">
<string>Format</string> <string>Format</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="comboBoxLayoutExportFormat"/> <widget class="QComboBox" name="comboBoxSheetExportFormat"/>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButtonLayoutExport"> <widget class="QPushButton" name="pushButtonSheetExport">
<property name="text"> <property name="text">
<string>Export Layout</string> <string>Export Sheet</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -857,7 +833,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacerLayout"> <spacer name="verticalSpacerSheet">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -929,7 +905,7 @@
<string notr="true">font-weight: bold;</string> <string notr="true">font-weight: bold;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Tiles</string> <string>Tiles of current sheet</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
@ -955,6 +931,162 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabLayoutProperty">
<attribute name="title">
<string>Prop.</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayoutLayoutProperty">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollAreaLayout">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>356</width>
<height>760</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="labelLayout">
<property name="styleSheet">
<string notr="true">font-weight: bold;</string>
</property>
<property name="text">
<string>Layout</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxLayoutInfos">
<property name="title">
<string>Infos</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<layout class="QFormLayout" name="formLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="labelLayoutName">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditLayoutName">
<property name="text">
<string>My layout</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEditLayoutDescription"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxLayoutFormat">
<property name="title">
<string>Format</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QFormLayout" name="formLayoutLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelLayoutUnit">
<property name="text">
<string>Unit</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxLayoutUnit"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxLayoutControl">
<property name="title">
<string>Control</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QCheckBox" name="checkBoxLayoutWarningPiecesSuperposition">
<property name="text">
<string>Warning superposition of pieces</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxLayoutWarningPiecesOutOfBound">
<property name="text">
<string>Warning pieces out of bound</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacerLayout">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -1041,11 +1173,11 @@
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<tabstops> <tabstops>
<tabstop>scrollAreaLayout</tabstop> <tabstop>scrollAreaSheet</tabstop>
<tabstop>doubleSpinBoxLayoutMarginTop</tabstop> <tabstop>doubleSpinBoxSheetMarginTop</tabstop>
<tabstop>doubleSpinBoxLayoutMarginLeft</tabstop> <tabstop>doubleSpinBoxSheetMarginLeft</tabstop>
<tabstop>doubleSpinBoxLayoutMarginRight</tabstop> <tabstop>doubleSpinBoxSheetMarginRight</tabstop>
<tabstop>doubleSpinBoxLayoutMarginBottom</tabstop> <tabstop>doubleSpinBoxSheetMarginBottom</tabstop>
<tabstop>scrollAreaTiles</tabstop> <tabstop>scrollAreaTiles</tabstop>
</tabstops> </tabstops>
<resources> <resources>

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpiece.h ** @file vppiece.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 13 4, 2020 ** @date 13 4, 2020
** **

View File

@ -1,6 +1,204 @@
/************************************************************************
**
** @file vpsheet.cpp
** @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
** <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 "vpsheet.h" #include "vpsheet.h"
VPSheet::VPSheet() #include "vppiecelist.h"
{ #include "vplayout.h"
//---------------------------------------------------------------------------------------------------------------------
VPSheet::VPSheet(VPLayout* layout) :
m_layout(layout)
{
m_pieceList = new VPPieceList(layout);
}
//---------------------------------------------------------------------------------------------------------------------
VPSheet::~VPSheet()
{
delete m_pieceList;
}
//---------------------------------------------------------------------------------------------------------------------
VPPieceList* VPSheet::GetPieceList()
{
return m_pieceList;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPSheet::GetName() const
{
return m_name;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetName(const QString &name)
{
m_name = name;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSize(qreal width, qreal height)
{
m_size.setWidth(width);
m_size.setHeight(height);
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSizeConverted(qreal width, qreal height)
{
m_size.setWidth(UnitConvertor(width, m_layout->GetUnit(), Unit::Px));
m_size.setHeight(UnitConvertor(height, m_layout->GetUnit(), Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSize(const QSizeF &size)
{
m_size = size;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSizeConverted(const QSizeF &size)
{
m_size = QSizeF(
UnitConvertor(size.width(), m_layout->GetUnit(), Unit::Px),
UnitConvertor(size.height(), m_layout->GetUnit(), Unit::Px)
);
}
//---------------------------------------------------------------------------------------------------------------------
QSizeF VPSheet::GetSheetSize() const
{
return m_size;
}
//---------------------------------------------------------------------------------------------------------------------
QSizeF VPSheet::GetSheetSizeConverted() const
{
QSizeF convertedSize = QSizeF(
UnitConvertor(m_size.width(), Unit::Px, m_layout->GetUnit()),
UnitConvertor(m_size.height(), Unit::Px, m_layout->GetUnit())
);
return convertedSize;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetMargins(qreal left, qreal top, qreal right, qreal bottom)
{
m_margins.setLeft(left);
m_margins.setTop(top);
m_margins.setRight(right);
m_margins.setBottom(bottom);
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetMarginsConverted(qreal left, qreal top, qreal right, qreal bottom)
{
m_margins.setLeft(UnitConvertor(left, m_layout->GetUnit(), Unit::Px));
m_margins.setTop(UnitConvertor(top, m_layout->GetUnit(), Unit::Px));
m_margins.setRight(UnitConvertor(right, m_layout->GetUnit(), Unit::Px));
m_margins.setBottom(UnitConvertor(bottom, m_layout->GetUnit(), Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetMargins(const QMarginsF &margins)
{
m_margins = margins;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetMarginsConverted(const QMarginsF &margins)
{
m_margins = UnitConvertor(margins, m_layout->GetUnit(), Unit::Px);
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VPSheet::GetSheetMargins() const
{
return m_margins;
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VPSheet::GetSheetMarginsConverted() const
{
return UnitConvertor(m_margins, Unit::Px, m_layout->GetUnit());
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetFollowGrainline(FollowGrainline state)
{
m_followGrainLine = state;
}
//---------------------------------------------------------------------------------------------------------------------
FollowGrainline VPSheet::GetFollowGrainline() const
{
return m_followGrainLine;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetPiecesGap(qreal value)
{
m_piecesGap = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetPiecesGapConverted(qreal value)
{
m_piecesGap = UnitConvertor(value, m_layout->GetUnit(), Unit::Px);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPSheet::GetPiecesGap() const
{
return m_piecesGap;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPSheet::GetPiecesGapConverted() const
{
return UnitConvertor(m_piecesGap, Unit::Px, m_layout->GetUnit());
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetStickyEdges(bool state)
{
m_stickyEdges = state;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPSheet::GetStickyEdges() const
{
return m_stickyEdges;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::ClearSelection()
{
m_pieceList->ClearSelection();
} }

View File

@ -1,11 +1,225 @@
/************************************************************************
**
** @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
** <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 VPSHEET_H #ifndef VPSHEET_H
#define VPSHEET_H #define VPSHEET_H
#include <QObject>
#include <QSizeF>
#include <QMarginsF>
#include <QList>
class VPSheet #include "def.h"
// is this the right place for the definition?
enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2};
class VPLayout;
class VPPieceList;
class VPSheet : public QObject
{ {
Q_OBJECT
public: public:
VPSheet(); VPSheet(VPLayout* layout);
~VPSheet();
/**
* @brief GetPieceList returns the piece list of the sheet
* @return
*/
VPPieceList* GetPieceList();
/**
* @brief GetName Returns the name of the sheet
* @return the name
*/
QString GetName() const;
/**
* @brief SetName Sets the name of the sheet to the given name
* @param name the new sheet's name
*/
void SetName(const QString &name);
/**
* @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
*/
QSizeF GetSheetSize() const;
/**
* @brief GetSheetSizeConverted Returns the size in the layout's unit
* @return the size in the layout's unit
*/
QSizeF GetSheetSizeConverted() const;
/**
* @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
*/
QMarginsF GetSheetMargins() const;
/**
* @brief GetSheetMarginsConverted Returns the margins in the layout's unit
* @return the margins in the sheet's unit
*/
QMarginsF GetSheetMarginsConverted() const;
/**
* @brief SetFollowGrainline Sets the type of grainline for the pieces to follow
* @param state the type of grainline
*/
void SetFollowGrainline(FollowGrainline state);
/**
* @brief GetFollowGrainline Returns if the sheet's pieces follow a grainline or not
* @return wether the pieces follow a grainline and if so, which grainline
*/
FollowGrainline GetFollowGrainline() const;
/**
* @brief SetPiecesGap sets the pieces gap to the given value, the unit has to be in Unit::Px
* @param value pieces gap
*/
void SetPiecesGap(qreal value);
/**
* @brief SetPiecesGapConverted sets the pieces gap to the given value, the unit has to be in the layout's unit
* @param value pieces gap
*/
void SetPiecesGapConverted(qreal value);
/**
* @brief GetPiecesGap returns the pieces gap in Unit::Px
* @return the pieces gap in Unit::Px
*/
qreal GetPiecesGap() const;
/**
* @brief GetPiecesGapConverted returns the pieces gap in the layout's unit
* @return the pieces gap in the layout's unit
*/
qreal GetPiecesGapConverted() const;
/**
* @brief ClearSelection goes through the piece list and pieces and calls
* SetIsSelected(false) for the pieces that were selected.
*/
void ClearSelection();
void SetStickyEdges(bool state);
bool GetStickyEdges() const;
private:
Q_DISABLE_COPY(VPSheet)
VPLayout *m_layout;
VPPieceList *m_pieceList {nullptr};
QString m_name{};
/**
* @brief m_size the Size in Unit::Px
*/
QSizeF m_size{};
// margins
/**
* @brief m_margins the margins in Unit::Px
*/
QMarginsF m_margins{};
// control
FollowGrainline m_followGrainLine{FollowGrainline::No};
/**
* @brief m_piecesGap the pieces gap in Unit::Px
*/
qreal m_piecesGap{0};
bool m_stickyEdges{false};
}; };
#endif // VPSHEET_H #endif // VPSHEET_H

View File

@ -72,7 +72,11 @@ void VPLayoutFileReader::ReadLayout(VPLayout *layout)
} }
else if (name() == ML::TagPieceLists) else if (name() == ML::TagPieceLists)
{ {
ReadPieceLists(layout); ReadSheets(layout);
}
else if (name() == ML::TagUnplacedPieceList)
{
ReadUnplacedPieces(layout);
} }
else else
{ {
@ -94,8 +98,6 @@ void VPLayoutFileReader::ReadProperties(VPLayout *layout)
{ {
ML::TagUnit, ML::TagUnit,
ML::TagDescription, ML::TagDescription,
ML::TagSize,
ML::TagMargin,
ML::TagControl, ML::TagControl,
ML::TagTiles ML::TagTiles
}); });
@ -113,38 +115,17 @@ void VPLayoutFileReader::ReadProperties(VPLayout *layout)
// TODO read the description info // TODO read the description info
break; break;
} }
case 2:// size case 2:// control
{
qDebug("read size");
QSizeF size = ReadSize();
layout->SetLayoutSize(size);
readElementText();
break;
}
case 3:// margin
{
qDebug("read margin");
QMarginsF margins = ReadMargins();
layout->SetLayoutMargins(margins);
readElementText();
break;
}
case 4:// control
{ {
qDebug("read control"); qDebug("read control");
QXmlStreamAttributes attribs = attributes(); QXmlStreamAttributes attribs = attributes();
// attribs.value("followGrainLine"); // TODO
layout->SetWarningSuperpositionOfPieces(ReadAttributeBool(attribs, ML::AttrWarningSuperposition, trueStr)); layout->SetWarningSuperpositionOfPieces(ReadAttributeBool(attribs, ML::AttrWarningSuperposition, trueStr));
layout->SetWarningPiecesOutOfBound(ReadAttributeBool(attribs, ML::AttrWarningOutOfBound, trueStr)); layout->SetWarningPiecesOutOfBound(ReadAttributeBool(attribs, ML::AttrWarningOutOfBound, trueStr));
layout->SetStickyEdges(ReadAttributeBool(attribs, ML::AttrStickyEdges, trueStr));
layout->SetPiecesGap(ReadAttributeDouble(attribs, ML::AttrPiecesGap, QChar('0')));
readElementText(); readElementText();
break; break;
} }
case 5:// tiles case 3:// tiles
qDebug("read tiles"); qDebug("read tiles");
ReadTiles(layout); ReadTiles(layout);
readElementText(); readElementText();
@ -157,6 +138,12 @@ void VPLayoutFileReader::ReadProperties(VPLayout *layout)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadUnplacedPieces(VPLayout *layout)
{
ReadPieceList(layout->GetUnplacedPieceList());
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadTiles(VPLayout *layout) void VPLayoutFileReader::ReadTiles(VPLayout *layout)
{ {
@ -193,20 +180,15 @@ void VPLayoutFileReader::ReadTiles(VPLayout *layout)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadPieceLists(VPLayout *layout) void VPLayoutFileReader::ReadSheets(VPLayout *layout)
{ {
SCASSERT(isStartElement() && name() == ML::TagPieceLists); SCASSERT(isStartElement() && name() == ML::TagSheets);
while (readNextStartElement()) while (readNextStartElement())
{ {
if (name() == ML::TagUnplacedPieceList) if (name() == ML::TagSheet)
{ {
ReadPieceList(layout->GetUnplacedPieceList()); ReadSheet(layout);
}
else if (name() == ML::TagPieceList)
{
VPPieceList *pieceList = layout->AddPieceList();
ReadPieceList(pieceList);
} }
else else
{ {
@ -216,6 +198,14 @@ void VPLayoutFileReader::ReadPieceLists(VPLayout *layout)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadSheet(VPLayout *layout)
{
Q_UNUSED(layout);
// TODO
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadPieceList(VPPieceList *pieceList) void VPLayoutFileReader::ReadPieceList(VPPieceList *pieceList)
{ {

View File

@ -50,7 +50,9 @@ private:
void ReadLayout(VPLayout *layout); void ReadLayout(VPLayout *layout);
void ReadProperties(VPLayout *layout); void ReadProperties(VPLayout *layout);
void ReadTiles(VPLayout *layout); void ReadTiles(VPLayout *layout);
void ReadPieceLists(VPLayout *layout); void ReadUnplacedPieces(VPLayout *layout);
void ReadSheets(VPLayout *layout);
void ReadSheet(VPLayout *layout);
void ReadPieceList(VPPieceList *pieceList); void ReadPieceList(VPPieceList *pieceList);
void ReadPiece(VPPiece *piece); void ReadPiece(VPPiece *piece);

View File

@ -28,6 +28,7 @@
#include "vplayoutfilewriter.h" #include "vplayoutfilewriter.h"
#include "vplayout.h" #include "vplayout.h"
#include "vpsheet.h"
#include "vppiecelist.h" #include "vppiecelist.h"
#include "vppiece.h" #include "vppiece.h"
#include "vplayoutliterals.h" #include "vplayoutliterals.h"
@ -65,7 +66,7 @@ void VPLayoutFileWriter::WriteLayout(VPLayout *layout)
SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr); SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr);
WriteProperties(layout); WriteProperties(layout);
WritePieceLists(layout); WriteUnplacePiecesList(layout);
writeEndElement(); //layout writeEndElement(); //layout
} }
@ -79,16 +80,10 @@ void VPLayoutFileWriter::WriteProperties(VPLayout *layout)
writeTextElement(ML::TagDescription, QString()); // TODO : define the value in layout writeTextElement(ML::TagDescription, QString()); // TODO : define the value in layout
WriteSize(layout->GetLayoutSize());
WriteMargins(layout->GetLayoutMargins());
writeStartElement(ML::TagControl); writeStartElement(ML::TagControl);
SetAttribute(ML::AttrFollowGrainLine, "no"); // TODO / Fixme get the right value
SetAttribute(ML::AttrWarningSuperposition, layout->GetWarningSuperpositionOfPieces()); SetAttribute(ML::AttrWarningSuperposition, layout->GetWarningSuperpositionOfPieces());
SetAttribute(ML::AttrWarningOutOfBound, layout->GetWarningPiecesOutOfBound()); SetAttribute(ML::AttrWarningOutOfBound, layout->GetWarningPiecesOutOfBound());
SetAttribute(ML::AttrStickyEdges, layout->GetStickyEdges());
SetAttribute(ML::AttrPiecesGap, layout->GetPiecesGap());
writeEndElement(); // control writeEndElement(); // control
// WriteTiles(layout); TODO: when tile functionality implemented, then uncomment this line // WriteTiles(layout); TODO: when tile functionality implemented, then uncomment this line
@ -96,6 +91,32 @@ void VPLayoutFileWriter::WriteProperties(VPLayout *layout)
writeEndElement(); // properties writeEndElement(); // properties
} }
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteUnplacePiecesList(VPLayout *layout)
{
Q_UNUSED(layout);
// TODO
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteSheets(VPLayout *layout)
{
Q_UNUSED(layout);
// TODO
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteSheet(VPSheet* sheet)
{
Q_UNUSED(sheet);
// TODO
// WritePieceList(pieceList);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteTiles(VPLayout *layout) void VPLayoutFileWriter::WriteTiles(VPLayout *layout)
{ {
@ -115,23 +136,6 @@ void VPLayoutFileWriter::WriteTiles(VPLayout *layout)
} }
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WritePieceLists(VPLayout *layout)
{
writeStartElement(ML::TagPieceLists);
WritePieceList(layout->GetUnplacedPieceList(), ML::TagUnplacedPieceList);
QList<VPPieceList*> pieceLists = layout->GetPiecesLists();
for (auto pieceList : pieceLists)
{
WritePieceList(pieceList);
}
writeEndElement(); // piece list
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList) void VPLayoutFileWriter::WritePieceList(VPPieceList *pieceList)
{ {

View File

@ -35,6 +35,7 @@
#include "../vmisc/literals.h" #include "../vmisc/literals.h"
class VPLayout; class VPLayout;
class VPSheet;
class VPPieceList; class VPPieceList;
class VPPiece; class VPPiece;
class QFile; class QFile;
@ -52,8 +53,10 @@ private:
void WriteLayout(VPLayout *layout); void WriteLayout(VPLayout *layout);
void WriteProperties(VPLayout *layout); void WriteProperties(VPLayout *layout);
void WriteUnplacePiecesList(VPLayout *layout);
void WriteSheets(VPLayout *layout);
void WriteSheet(VPSheet* sheet);
void WriteTiles(VPLayout *layout); void WriteTiles(VPLayout *layout);
void WritePieceLists(VPLayout *layout);
void WritePieceList(VPPieceList *pieceList); void WritePieceList(VPPieceList *pieceList);
void WritePieceList(VPPieceList *pieceList, const QString &tagName); void WritePieceList(VPPieceList *pieceList, const QString &tagName);
void WritePiece(VPPiece *piece); void WritePiece(VPPiece *piece);

View File

@ -41,6 +41,8 @@ const QString TagTiles = QStringLiteral("tiles");
const QString TagUnplacedPieceList = QStringLiteral("unplacedPieceList"); const QString TagUnplacedPieceList = QStringLiteral("unplacedPieceList");
const QString TagPieceList = QStringLiteral("pieceList"); const QString TagPieceList = QStringLiteral("pieceList");
const QString TagPiece = QStringLiteral("piece"); const QString TagPiece = QStringLiteral("piece");
const QString TagSheets = QStringLiteral("sheets");
const QString TagSheet = QStringLiteral("sheet");
const QString AttrVersion = QStringLiteral("version"); const QString AttrVersion = QStringLiteral("version");
const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition"); const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition");

View File

@ -46,6 +46,8 @@ extern const QString TagTiles;
extern const QString TagUnplacedPieceList; extern const QString TagUnplacedPieceList;
extern const QString TagPieceList; extern const QString TagPieceList;
extern const QString TagPiece; extern const QString TagPiece;
extern const QString TagSheets;
extern const QString TagSheet;
extern const QString AttrVersion; extern const QString AttrVersion;
extern const QString AttrWarningSuperposition; extern const QString AttrWarningSuperposition;