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/vppiecelist.cpp \
$$PWD/vpsettings.cpp \
$$PWD/vpsheet.cpp \
$$PWD/xml/vplayoutfilereader.cpp \
$$PWD/xml/vplayoutfilewriter.cpp \
$$PWD/xml/vplayoutliterals.cpp
@ -44,6 +45,7 @@ HEADERS += \
$$PWD/vppiece.h \
$$PWD/vppiecelist.h \
$$PWD/vpsettings.h \
$$PWD/vpsheet.h \
$$PWD/vpstable.h \
$$PWD/xml/vplayoutfilereader.h \
$$PWD/xml/vplayoutfilewriter.h \

View file

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

View file

@ -40,6 +40,7 @@
#include "vpmimedatapiece.h"
#include "vpcarrouselpiecelist.h"
#include "vpcarrousel.h"
#include "vpsheet.h"
#include <QLoggingCategory>
@ -240,7 +241,12 @@ void VPCarrouselPiece::contextMenuEvent(QContextMenuEvent *event)
QMenu contextMenu;
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
pieceLists.removeAll(m_piece->GetPieceList());

View file

@ -42,6 +42,7 @@
#include "vppiece.h"
#include "vppiecelist.h"
#include "vplayout.h"
#include "vpsheet.h"
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece")
@ -294,10 +295,19 @@ void VPGraphicsPiece::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
// TODO/FIXME context menu needs to be refactored
QMenu contextMenu;
// 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());
if(pieceLists.count() > 0)

View file

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

View file

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

View file

@ -28,26 +28,19 @@
#include "vplayout.h"
#include "vppiecelist.h"
#include "vppiece.h"
#include "vpsheet.h"
//---------------------------------------------------------------------------------------------------------------------
VPLayout::VPLayout() :
m_unplacedPieceList(new VPPieceList(this))
{
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()
{
qDeleteAll(m_pieceLists);
qDeleteAll(m_sheets);
delete m_unplacedPieceList;
}
@ -58,24 +51,24 @@ VPPieceList* VPLayout::GetUnplacedPieceList()
}
//---------------------------------------------------------------------------------------------------------------------
VPPieceList* VPLayout::AddPieceList()
VPSheet* VPLayout::AddSheet()
{
VPPieceList *newPieceList = new VPPieceList(this);
m_pieceLists.append(newPieceList);
return newPieceList;
VPSheet *newSheet = new VPSheet(this);
m_sheets.append(newSheet);
return newSheet;
}
//---------------------------------------------------------------------------------------------------------------------
VPPieceList* VPLayout::AddPieceList(VPPieceList *pieceList)
VPSheet* VPLayout::AddSheet(VPSheet *sheet)
{
m_pieceLists.append(pieceList);
return pieceList;
m_sheets.append(sheet);
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<VPPieceList *> pieceLists = m_pieceLists;
pieceLists.prepend(m_unplacedPieceList);
QList<VPPieceList *> pieceLists = QList<VPPieceList *>();
pieceLists.append(m_unplacedPieceList);
for (auto sheet : m_sheets)
{
pieceLists.append(sheet->GetPieceList());
}
for (auto pieceList : pieceLists)
{
@ -113,128 +110,6 @@ Unit VPLayout::GetUnit() const
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)
@ -260,48 +135,17 @@ bool VPLayout::GetWarningPiecesOutOfBound() const
return m_warningPiecesOutOfBound;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::SetStickyEdges(bool state)
{
m_stickyEdges = state;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPLayout::GetStickyEdges() const
{
return m_stickyEdges;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayout::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)
{
@ -316,3 +160,23 @@ void VPLayout::MovePieceToPieceList(VPPiece* piece, VPPieceList* pieceList)
// signal, that a piece was moved
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
#define VPLAYOUT_H
#include <QSizeF>
#include <QMarginsF>
#include <QList>
#include "def.h"
class VPPieceList;
class VPPiece;
// is this the right place for the definition?
enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2};
class VPSheet;
class VPLayout : public QObject
{
@ -53,9 +50,9 @@ public:
*/
VPPieceList* GetUnplacedPieceList();
VPPieceList* AddPieceList();
VPPieceList* AddPieceList(VPPieceList *pieceList);
QList<VPPieceList *> GetPiecesLists();
VPSheet* AddSheet();
VPSheet* AddSheet(VPSheet *sheet);
QList<VPSheet *> GetSheets();
/**
* @brief GetSelectedPieces Returns the list of the selected pieces
@ -75,150 +72,18 @@ public:
*/
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);
bool GetWarningSuperpositionOfPieces() const;
void SetWarningPiecesOutOfBound(bool state);
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.
*/
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
* @param piece the piece to move
@ -226,6 +91,21 @@ public:
*/
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:
void PieceMovedToPieceList(VPPiece *piece, VPPieceList *pieceListBefore, VPPieceList *pieceListAfter);
@ -234,37 +114,25 @@ private:
Q_DISABLE_COPY(VPLayout)
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
* added via drag and drop, or if no piece list is defined.
*/
VPPieceList *m_focusedPieceList{nullptr};
VPSheet *m_focusedSheet{nullptr};
// format
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_warningPiecesOutOfBound{false};
bool m_stickyEdges{false};
};

View file

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

View file

@ -40,6 +40,7 @@
#include "../vmisc/projectversion.h"
#include "../ifc/xml/vlayoutconverter.h"
#include "../ifc/exception/vexception.h"
#include "vpsheet.h"
#include <QLoggingCategory>
@ -57,13 +58,19 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
ui(new Ui::VPMainWindow),
m_cmd(cmd)
{
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------------------
m_layout->SetLayoutMarginsConverted(2, 2, 2, 2);
m_layout->SetLayoutSizeConverted(30.0, 45);
m_layout->SetPiecesGapConverted(1);
sheet->SetSheetMarginsConverted(2, 2, 2, 2);
sheet->SetSheetSizeConverted(30.0, 45);
sheet->SetPiecesGapConverted(1);
m_layout->SetUnit(Unit::Cm);
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
// -------------------- layout width, length, orientation ------------------------
connect(ui->doubleSpinBoxLayoutWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutSizeChanged);
connect(ui->doubleSpinBoxLayoutLength, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutSizeChanged);
connect(ui->radioButtonLayoutPortrait, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_LayoutOrientationChanged);
connect(ui->radioButtonLayoutLandscape, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_LayoutOrientationChanged);
connect(ui->doubleSpinBoxSheetWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetSizeChanged);
connect(ui->doubleSpinBoxSheetLength, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetSizeChanged);
connect(ui->radioButtonSheetPortrait, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_SheetOrientationChanged);
connect(ui->radioButtonSheetLandscape, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_SheetOrientationChanged);
// -------------------- margins ------------------------
connect(ui->doubleSpinBoxLayoutMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutMarginChanged);
connect(ui->doubleSpinBoxLayoutMarginRight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutMarginChanged);
connect(ui->doubleSpinBoxLayoutMarginBottom, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutMarginChanged);
connect(ui->doubleSpinBoxLayoutMarginLeft, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_LayoutMarginChanged);
connect(ui->doubleSpinBoxSheetMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxSheetMarginRight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxSheetMarginBottom, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetMarginChanged);
connect(ui->doubleSpinBoxSheetMarginLeft, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&VPMainWindow::on_SheetMarginChanged);
// ------------------- follow grainline -----------------------
connect(ui->radioButtonLayoutFollowGrainlineNo, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_LayoutFollowGrainlineChanged);
connect(ui->radioButtonLayoutFollowGrainlineVertical, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_LayoutFollowGrainlineChanged);
connect(ui->radioButtonLayoutFollowGrainlineHorizontal, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_LayoutFollowGrainlineChanged);
connect(ui->radioButtonSheetFollowGrainlineNo, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_SheetFollowGrainlineChanged);
connect(ui->radioButtonSheetFollowGrainlineVertical, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_SheetFollowGrainlineChanged);
connect(ui->radioButtonSheetFollowGrainlineHorizontal, QOverload<bool>::of(&QRadioButton::clicked), this,
&VPMainWindow::on_SheetFollowGrainlineChanged);
// -------------------- export ---------------------------
@ -332,8 +339,9 @@ void VPMainWindow::SetPropertiesData()
else
{
SetPropertyTabCurrentPieceData();
SetPropertyTabLayoutData();
SetPropertyTabSheetData();
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()
{
// TODO FIXME : Set name and description
// set Unit
int index = ui->comboBoxLayoutUnit->findData(QVariant(UnitsToStr(m_layout->GetUnit())));
if(index != -1)
@ -396,35 +438,9 @@ void VPMainWindow::SetPropertyTabLayoutData()
ui->comboBoxLayoutUnit->blockSignals(false);
}
// set Width / Length
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
// set controls
SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, m_layout->GetWarningPiecesOutOfBound());
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);
}
SetPropertyTabLayoutData();
SetPropertyTabSheetData();
SetPropertyTabCurrentPieceData();
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index)
void VPMainWindow::on_comboBoxSheetTemplate_currentIndexChanged(int index)
{
// just for test purpuses, to be removed:
QMessageBox msgBox;
msgBox.setText("TODO VPMainWindow::LayoutTemplateChanged");
msgBox.setText("TODO VPMainWindow::SheetTemplateChanged");
int ret = msgBox.exec();
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"
if(ui->doubleSpinBoxLayoutWidth->value() <= ui->doubleSpinBoxLayoutLength->value())
if(ui->doubleSpinBoxSheetWidth->value() <= ui->doubleSpinBoxSheetLength->value())
{
//portrait
ui->radioButtonLayoutPortrait->setChecked(true);
ui->radioButtonSheetPortrait->setChecked(true);
}
else
{
//landscape
ui->radioButtonLayoutLandscape->setChecked(true);
ui->radioButtonSheetLandscape->setChecked(true);
}
// TODO Undo / Redo
@ -805,16 +821,16 @@ void VPMainWindow::on_LayoutSizeChanged()
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_LayoutOrientationChanged()
void VPMainWindow::on_SheetOrientationChanged()
{
// swap the width and length
qreal width_before = ui->doubleSpinBoxLayoutWidth->value();
qreal length_before = ui->doubleSpinBoxLayoutLength->value();
qreal width_before = ui->doubleSpinBoxSheetWidth->value();
qreal length_before = ui->doubleSpinBoxSheetLength->value();
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutWidth, length_before);
SetDoubleSpinBoxValue(ui->doubleSpinBoxLayoutLength, width_before);
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetWidth, length_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
@ -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:
QMessageBox msgBox;
@ -836,13 +852,13 @@ void VPMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked()
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_LayoutMarginChanged()
void VPMainWindow::on_SheetMarginChanged()
{
m_layout->SetLayoutMarginsConverted(
ui->doubleSpinBoxLayoutMarginLeft->value(),
ui->doubleSpinBoxLayoutMarginTop->value(),
ui->doubleSpinBoxLayoutMarginRight->value(),
ui->doubleSpinBoxLayoutMarginBottom->value()
m_layout->GetFocusedSheet()->SetSheetMarginsConverted(
ui->doubleSpinBoxSheetMarginLeft->value(),
ui->doubleSpinBoxSheetMarginTop->value(),
ui->doubleSpinBoxSheetMarginRight->value(),
ui->doubleSpinBoxSheetMarginBottom->value()
);
// 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:
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 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 update the QGraphicView
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonLayoutExport_clicked()
void VPMainWindow::on_pushButtonSheetExport_clicked()
{
// just for test purpuses, to be removed:
QMessageBox msgBox;

View file

@ -152,10 +152,10 @@ private:
void SetPropertyTabCurrentPieceData();
/**
* @brief SetPropertyTabLayoutData Sets the values of UI elements
* in the Layout Tab to the values saved in m_layout
* @brief SetPropertyTabSheetData Sets the values of UI elements
* in the Sheet Tab to the values saved in focused sheet
*/
void SetPropertyTabLayoutData();
void SetPropertyTabSheetData();
/**
* @brief SetPropertyTabTilesData Sets the values of UI elements
@ -163,6 +163,12 @@ private:
*/
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.
* 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.
* @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
* the layout property tab
*/
void on_LayoutSizeChanged();
void on_SheetSizeChanged();
/**
* @brief LayoutOrientationChanged When one of the radio boxes for the layout
* orientation has been clicked
*/
void on_LayoutOrientationChanged();
void on_SheetOrientationChanged();
/**
* @brief on_pushButtonLayoutRemoveUnusedLength_clicked When the button
* "Remove unused length" in the layout property tab is clicked.
* 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
* in the layout property tab.
*/
void on_LayoutMarginChanged();
void on_SheetMarginChanged();
/**
* @brief LayoutFollowGrainlineChanged When one of the radio boxes for the
* "Follow grainline" has been clicked in the layout property tab.
*/
void on_LayoutFollowGrainlineChanged();
void on_SheetFollowGrainlineChanged();
/**
* @brief on_doubleSpinBoxLayoutPiecesGap_valueChanged When the "pieces gap"
@ -287,7 +293,7 @@ private slots:
* The slot is automatically connected through name convention.
* @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
@ -313,14 +319,14 @@ private slots:
* The slot is automatically connected through name convention.
* @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
* "Export layout" in the layout property is clicked.
* The slot is automatically connected through name convention.
*/
void on_pushButtonLayoutExport_clicked();
void on_pushButtonSheetExport_clicked();
/**
* @brief on_checkBoxCurrentPieceShowSeamline_toggled When the

View file

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

View file

@ -1,6 +1,6 @@
/************************************************************************
**
** @file vpiece.h
** @file vppiece.h
** @author Ronan Le Tiec
** @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"
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
#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:
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

View file

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

View file

@ -50,7 +50,9 @@ private:
void ReadLayout(VPLayout *layout);
void ReadProperties(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 ReadPiece(VPPiece *piece);

View file

@ -28,6 +28,7 @@
#include "vplayoutfilewriter.h"
#include "vplayout.h"
#include "vpsheet.h"
#include "vppiecelist.h"
#include "vppiece.h"
#include "vplayoutliterals.h"
@ -65,7 +66,7 @@ void VPLayoutFileWriter::WriteLayout(VPLayout *layout)
SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr);
WriteProperties(layout);
WritePieceLists(layout);
WriteUnplacePiecesList(layout);
writeEndElement(); //layout
}
@ -79,16 +80,10 @@ void VPLayoutFileWriter::WriteProperties(VPLayout *layout)
writeTextElement(ML::TagDescription, QString()); // TODO : define the value in layout
WriteSize(layout->GetLayoutSize());
WriteMargins(layout->GetLayoutMargins());
writeStartElement(ML::TagControl);
SetAttribute(ML::AttrFollowGrainLine, "no"); // TODO / Fixme get the right value
SetAttribute(ML::AttrWarningSuperposition, layout->GetWarningSuperpositionOfPieces());
SetAttribute(ML::AttrWarningOutOfBound, layout->GetWarningPiecesOutOfBound());
SetAttribute(ML::AttrStickyEdges, layout->GetStickyEdges());
SetAttribute(ML::AttrPiecesGap, layout->GetPiecesGap());
writeEndElement(); // control
// WriteTiles(layout); TODO: when tile functionality implemented, then uncomment this line
@ -96,6 +91,32 @@ void VPLayoutFileWriter::WriteProperties(VPLayout *layout)
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)
{
@ -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)
{

View file

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

View file

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

View file

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