Remove unused length.

This commit is contained in:
Roman Telezhynskyi 2021-09-01 09:20:58 +03:00
parent 1e15d343a0
commit 8e9547da4a
26 changed files with 802 additions and 768 deletions

View File

@ -0,0 +1,92 @@
/************************************************************************
**
** @file layoutdef.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 31 8, 2021
**
** @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) 2021 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 "layoutdef.h"
#include <QString>
#include <QStringList>
//---------------------------------------------------------------------------------------------------------------------
auto GrainlineTypeToStr(GrainlineType type) -> QString
{
QString result;
switch (type)
{
case GrainlineType::Horizontal:
result = QStringLiteral("horizontal");
break;
case GrainlineType::Vertical:
result = QStringLiteral("vertical");
break;
case GrainlineType::NotFixed:
default:
result = QStringLiteral("notFixed");
break;
}
return result;
}
//---------------------------------------------------------------------------------------------------------------------
auto StrToGrainlineType(const QString &string) -> GrainlineType
{
const QStringList types
{
QStringLiteral("horizontal"), // 0
QStringLiteral("vertical"), // 1
QStringLiteral("notFixed") // 2
};
GrainlineType type = GrainlineType::NotFixed;
switch (types.indexOf(string))
{
case 0:// horizontal
type = GrainlineType::Horizontal;
break;
case 2:// vertical
type = GrainlineType::Vertical;
break;
case 3:// notFixed
default:
type = GrainlineType::NotFixed;
break;
}
return type;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPTransformationOrigon::operator==(const VPTransformationOrigon &origin) const
{
return this->origin == origin.origin && custom == origin.custom;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPTransformationOrigon::operator!=(const VPTransformationOrigon &origin) const
{
return !VPTransformationOrigon::operator==(origin);
}

View File

@ -48,9 +48,13 @@ using VPSheetWeakPtr = QWeakPointer<VPSheet>;
enum class GrainlineType : qint8 enum class GrainlineType : qint8
{ {
Vertical, Vertical,
Horizontal Horizontal,
NotFixed
}; };
auto GrainlineTypeToStr(GrainlineType type) -> QString;
auto StrToGrainlineType(const QString &string) -> GrainlineType;
struct VPTransformationOrigon struct VPTransformationOrigon
{ {
QPointF origin{}; QPointF origin{};
@ -60,16 +64,4 @@ struct VPTransformationOrigon
bool operator!=(const VPTransformationOrigon &origin) const; bool operator!=(const VPTransformationOrigon &origin) const;
}; };
//---------------------------------------------------------------------------------------------------------------------
inline bool VPTransformationOrigon::operator==(const VPTransformationOrigon &origin) const
{
return this->origin == origin.origin && custom == origin.custom;
}
//---------------------------------------------------------------------------------------------------------------------
inline bool VPTransformationOrigon::operator!=(const VPTransformationOrigon &origin) const
{
return !VPTransformationOrigon::operator==(origin);
}
#endif // LAYOUTDEF_H #endif // LAYOUTDEF_H

View File

@ -67,11 +67,6 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
layout->LayoutSettings().SetIgnoreTilesMargins(settings->GetLayoutTileIgnoreMargins()); layout->LayoutSettings().SetIgnoreTilesMargins(settings->GetLayoutTileIgnoreMargins());
layout->LayoutSettings().SetTilesMargins(settings->GetLayoutTileMargins()); layout->LayoutSettings().SetTilesMargins(settings->GetLayoutTileMargins());
layout->LayoutSettings().SetIgnoreMargins(settings->GetLayoutSheetIgnoreMargins());
layout->LayoutSettings().SetSheetMargins(settings->GetLayoutSheetMargins());
layout->LayoutSettings().SetSheetSize(QSizeF(settings->GetLayoutSheetPaperWidth(),
settings->GetLayoutSheetPaperHeight()));
layout->LayoutSettings().SetWarningSuperpositionOfPieces(settings->GetLayoutWarningPiecesSuperposition()); layout->LayoutSettings().SetWarningSuperpositionOfPieces(settings->GetLayoutWarningPiecesSuperposition());
layout->LayoutSettings().SetWarningPiecesOutOfBound(settings->GetLayoutWarningPiecesOutOfBound()); layout->LayoutSettings().SetWarningPiecesOutOfBound(settings->GetLayoutWarningPiecesOutOfBound());
layout->LayoutSettings().SetFollowGrainline(settings->GetLayoutFollowGrainline()); layout->LayoutSettings().SetFollowGrainline(settings->GetLayoutFollowGrainline());

View File

@ -202,336 +202,6 @@ void VPLayoutSettings::SetShowTiles(bool value)
m_showTiles = value; m_showTiles = value;
} }
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutSettings::GetTemplateSize(PaperSizeTemplate tmpl) -> QSizeF
{
qreal height = 0;
qreal width = 0;
switch (tmpl)
{
case PaperSizeTemplate::A0:
width = UnitConvertor(841, Unit::Mm, Unit::Px);
height = UnitConvertor(1189, Unit::Mm, Unit::Px);
break;
case PaperSizeTemplate::A1:
width = UnitConvertor(594, Unit::Mm, Unit::Px);
height = UnitConvertor(841, Unit::Mm, Unit::Px);
break;
case PaperSizeTemplate::A2:
width = UnitConvertor(420, Unit::Mm, Unit::Px);
height = UnitConvertor(594, Unit::Mm, Unit::Px);
break;
case PaperSizeTemplate::A3:
width = UnitConvertor(297, Unit::Mm, Unit::Px);
height = UnitConvertor(420, Unit::Mm, Unit::Px);
break;
case PaperSizeTemplate::A4:
width = UnitConvertor(210, Unit::Mm, Unit::Px);
height = UnitConvertor(297, Unit::Mm, Unit::Px);
break;
case PaperSizeTemplate::Letter:
width = UnitConvertor(8.5, Unit::Inch, Unit::Px);
height = UnitConvertor(11, Unit::Inch, Unit::Px);
break;
case PaperSizeTemplate::Legal:
width = UnitConvertor(8.5, Unit::Inch, Unit::Px);
height = UnitConvertor(14, Unit::Inch, Unit::Px);
break;
case PaperSizeTemplate::Tabloid:
width = UnitConvertor(11, Unit::Inch, Unit::Px);
height = UnitConvertor(17, Unit::Inch, Unit::Px);
break;
case PaperSizeTemplate::Roll24in:
width = UnitConvertor(24, Unit::Inch, Unit::Px);
height = UnitConvertor(48, Unit::Inch, Unit::Px);
break;
case PaperSizeTemplate::Roll30in:
width = UnitConvertor(30, Unit::Inch, Unit::Px);
height = UnitConvertor(60, Unit::Inch, Unit::Px);
break;
case PaperSizeTemplate::Roll36in:
width = UnitConvertor(36, Unit::Inch, Unit::Px);
height = UnitConvertor(72, Unit::Inch, Unit::Px);
break;
case PaperSizeTemplate::Roll42in:
width = UnitConvertor(42, Unit::Inch, Unit::Px);
height = UnitConvertor(84, Unit::Inch, Unit::Px);
break;
case PaperSizeTemplate::Roll44in:
width = UnitConvertor(44, Unit::Inch, Unit::Px);
height = UnitConvertor(88, Unit::Inch, Unit::Px);
break;
case PaperSizeTemplate::Roll48in:
width = UnitConvertor(48, Unit::Inch, Unit::Px);
height = UnitConvertor(96, Unit::Inch, Unit::Px);
break;
case PaperSizeTemplate::Roll62in:
width = UnitConvertor(62, Unit::Inch, Unit::Px);
height = UnitConvertor(124, Unit::Inch, Unit::Px);
break;
case PaperSizeTemplate::Roll72in:
width = UnitConvertor(72, Unit::Inch, Unit::Px);
height = UnitConvertor(144, Unit::Inch, Unit::Px);
break;
default:
break;
}
return QSizeF(width, height);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutSettings::GetTemplateName(PaperSizeTemplate tmpl) -> QString
{
QString tmplName;
switch (tmpl)
{
case PaperSizeTemplate::A0:
tmplName = QString("A0");
break;
case PaperSizeTemplate::A1:
tmplName = QString("A1");
break;
case PaperSizeTemplate::A2:
tmplName = QString("A2");
break;
case PaperSizeTemplate::A3:
tmplName = QString("A3");
break;
case PaperSizeTemplate::A4:
tmplName = QString("A4");
break;
case PaperSizeTemplate::Letter:
tmplName = tr("Letter");
break;
case PaperSizeTemplate::Legal:
tmplName = tr("Legal");
break;
case PaperSizeTemplate::Tabloid:
tmplName = tr("Tabloid");
break;
case PaperSizeTemplate::Roll24in:
tmplName = tr("Roll 24in");
break;
case PaperSizeTemplate::Roll30in:
tmplName = tr("Roll 30in");
break;
case PaperSizeTemplate::Roll36in:
tmplName = tr("Roll 36in");
break;
case PaperSizeTemplate::Roll42in:
tmplName = tr("Roll 42in");
break;
case PaperSizeTemplate::Roll44in:
tmplName = tr("Roll 44in");
break;
case PaperSizeTemplate::Roll48in:
tmplName = tr("Roll 48in");
break;
case PaperSizeTemplate::Roll62in:
tmplName = tr("Roll 62in");
break;
case PaperSizeTemplate::Roll72in:
tmplName = tr("Roll 72in");
break;
case PaperSizeTemplate::Custom:
tmplName = tr("Custom");
break;
default:
break;
}
if(not tmplName.isEmpty())
{
tmplName += " " + QStringLiteral("(%1ppi)").arg(PrintDPI);
}
return tmplName;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutSettings::GetTemplate(QSizeF size) -> PaperSizeTemplate
{
Q_UNUSED(size);
// TODO, float comparision not safe and problems with
// inch / cm
// const int max = static_cast<int>(PaperSizeTemplate::Custom);
// for (int i=0; i < max; i++)
// {
// PaperSizeTemplate tmpl = static_cast<PaperSizeTemplate>(i);
// const QSizeF tmplSize = GetTemplateSize(tmpl);
// if(size.width() == tmplSize.width())
// {
// if(isRollTemplate(tmpl))
// {
// return tmpl;
// }
// else if(size.height() == tmplSize.height())
// {
// return tmpl;
// }
// }
// }
return PaperSizeTemplate::Custom;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutSettings::isRollTemplate(PaperSizeTemplate tmpl) -> bool
{
switch (tmpl) {
case PaperSizeTemplate::Roll24in:
case PaperSizeTemplate::Roll30in:
case PaperSizeTemplate::Roll36in:
case PaperSizeTemplate::Roll42in:
case PaperSizeTemplate::Roll44in:
case PaperSizeTemplate::Roll48in:
case PaperSizeTemplate::Roll62in:
case PaperSizeTemplate::Roll72in:
return true;
default:
return false;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::PopulateComboBox(QVector<PaperSizeTemplate> *tmpls, QComboBox* comboBox)
{
const QIcon icoPaper("://puzzleicon/16x16/template.png");
const QIcon icoRoll("://puzzleicon/16x16/roll.png");
QIcon icon;
for (auto tmpl : *tmpls)
{
icon = (isRollTemplate(tmpl))? icoRoll : icoPaper;
comboBox->addItem(icon, GetTemplateName(tmpl), QVariant(static_cast<int>(tmpl)));
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::SetSheetSize(qreal width, qreal height)
{
m_size.setWidth(width);
m_size.setHeight(height);
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::SetSheetSizeConverted(qreal width, qreal height)
{
m_size.setWidth(UnitConvertor(width, m_unit, Unit::Px));
m_size.setHeight(UnitConvertor(height, m_unit, Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::SetSheetSize(const QSizeF &size)
{
m_size = size;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::SetSheetSizeConverted(const QSizeF &size)
{
m_size = QSizeF(
UnitConvertor(size.width(), m_unit, Unit::Px),
UnitConvertor(size.height(), m_unit, Unit::Px)
);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutSettings::GetSheetSize() const -> QSizeF
{
return m_size;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutSettings::GetSheetSizeConverted() const -> QSizeF
{
QSizeF convertedSize = QSizeF(
UnitConvertor(m_size.width(), Unit::Px, m_unit),
UnitConvertor(m_size.height(), Unit::Px, m_unit)
);
return convertedSize;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::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 VPLayoutSettings::SetSheetMarginsConverted(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 VPLayoutSettings::SetSheetMargins(const QMarginsF &margins)
{
m_margins = margins;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::SetSheetMarginsConverted(const QMarginsF &margins)
{
m_margins = UnitConvertor(margins, m_unit, Unit::Px);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutSettings::GetSheetMargins() const -> QMarginsF
{
return m_margins;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutSettings::GetSheetMarginsConverted() const -> QMarginsF
{
return UnitConvertor(m_margins, Unit::Px, m_unit);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::SetFollowGrainline(bool state) void VPLayoutSettings::SetFollowGrainline(bool state)
{ {
@ -652,15 +322,3 @@ void VPLayoutSettings::SetIgnoreTilesMargins(bool newIgnoreTilesMargins)
{ {
m_ignoreTilesMargins = newIgnoreTilesMargins; m_ignoreTilesMargins = newIgnoreTilesMargins;
} }
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutSettings::IgnoreMargins() const -> bool
{
return m_ignoreMargins;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::SetIgnoreMargins(bool newIgnoreMargins)
{
m_ignoreMargins = newIgnoreMargins;
}

View File

@ -35,26 +35,6 @@
#include "def.h" #include "def.h"
enum class PaperSizeTemplate : qint8 {
A0 = 0,
A1,
A2,
A3,
A4,
Letter,
Legal,
Tabloid,
Roll24in,
Roll30in,
Roll36in,
Roll42in,
Roll44in,
Roll48in,
Roll62in,
Roll72in,
Custom
};
class VPLayoutSettings class VPLayoutSettings
{ {
Q_DECLARE_TR_FUNCTIONS(VPLayoutSettings) Q_DECLARE_TR_FUNCTIONS(VPLayoutSettings)
@ -252,122 +232,7 @@ public:
*/ */
void SetShowTiles(bool value); void SetShowTiles(bool value);
/**
* @brief GetTemplateSize Returns the size in Px of the given template
* @param tmpl paper size template
* @return the size in Px
*/
static auto GetTemplateSize(PaperSizeTemplate tmpl) -> QSizeF;
/**
* @brief GetTemplateName Returns the name of the given template
* @param tmpl paper size template
* @return name of the given template
*/
static auto GetTemplateName(PaperSizeTemplate tmpl) -> QString;
/**
* @brief GetTemplate GetTemplate Returns the template that corresponds to the given size
* @param size the Size in Px
* @return template that corresponds to the given size
*/
static auto GetTemplate(QSizeF size) -> PaperSizeTemplate;
/**
* @brief PopulateComboBox Populates the given combo with the given templates
* @param tmpls list of paper size templates
* @param comboBox pointer to the combobox
*/
static void PopulateComboBox(QVector<PaperSizeTemplate> *tmpls, QComboBox* comboBox);
/**
* @brief isRollTemplate Returns wether the given template is a roll or not.
* @param tmpl paper size template
* @return true if the given template is a roll
*/
static auto isRollTemplate(PaperSizeTemplate tmpl) -> bool;
// Sheet // Sheet
/**
* @brief SetSheetSize sets the size of the sheet, the values have to be in Unit::Px
* @param width sheet width
* @param height sheet height
*/
void SetSheetSize(qreal width, qreal height);
/**
* @brief SetSheetSize sets the size of the sheet, the values have to be in the layout's unit
* @param width sheet width
* @param height sheet height
*/
void SetSheetSizeConverted(qreal width, qreal height);
/**
* @brief SetSheetSize sets the size of the sheet, the values have to be in Unit::Px
* @param size sheet size
*/
void SetSheetSize(const QSizeF &size);
/**
* @brief SetSheetSizeConverted sets the size of the sheet, the values have to be in the layout's unit
* @param size sheet size
*/
void SetSheetSizeConverted(const QSizeF &size);
/**
* @brief GetSheetSize Returns the size in Unit::Px
* @return sheet size in Unit::Px
*/
auto GetSheetSize() const -> QSizeF;
/**
* @brief GetSheetSizeConverted Returns the size in the layout's unit
* @return the size in the layout's unit
*/
auto GetSheetSizeConverted() const -> QSizeF;
/**
* @brief SetSheetMargins, set the margins of the sheet, the values have to be in Unit::Px
* @param left in Unit::Px
* @param top in Unit::Px
* @param right in Unit::Px
* @param bottom in Unit::Px
*/
void SetSheetMargins(qreal left, qreal top, qreal right, qreal bottom);
/**
* @brief SetSheetMargins, set the margins of the sheet, the values have to be in the unit of the layout
* @param left in Unit::Px
* @param top in Unit::Px
* @param right in Unit::Px
* @param bottom in Unit::Px
*/
void SetSheetMarginsConverted(qreal left, qreal top, qreal right, qreal bottom);
/**
* @brief SetSheetMargins set the margins of the sheet, the values have to be in Unit::Px
* @param margins sheet margins
*/
void SetSheetMargins(const QMarginsF &margins);
/**
* @brief SetSheetMargins set the margins of the sheet, the values have to be in the unit of the layout
* @param margins sheet margins
*/
void SetSheetMarginsConverted(const QMarginsF &margins);
/**
* @brief GetSheetMargins Returns the size in Unit::Px
* @return the size in Unit::Px
*/
auto GetSheetMargins() const -> QMarginsF;
/**
* @brief GetSheetMarginsConverted Returns the margins in the layout's unit
* @return the margins in the sheet's unit
*/
auto GetSheetMarginsConverted() const -> QMarginsF;
/** /**
* @brief GetShowGrid Returns true if the placement grid has to be shown on the current sheet * @brief GetShowGrid Returns true if the placement grid has to be shown on the current sheet
* @return true if the placement grid has to be shown on the current sheet * @return true if the placement grid has to be shown on the current sheet
@ -433,9 +298,6 @@ public:
auto IgnoreTilesMargins() const -> bool; auto IgnoreTilesMargins() const -> bool;
void SetIgnoreTilesMargins(bool newIgnoreTilesMargins); void SetIgnoreTilesMargins(bool newIgnoreTilesMargins);
auto IgnoreMargins() const -> bool;
void SetIgnoreMargins(bool newIgnoreMargins);
private: private:
Unit m_unit{Unit::Cm}; Unit m_unit{Unit::Cm};
@ -450,11 +312,6 @@ private:
*/ */
QSizeF m_tilesSize{}; QSizeF m_tilesSize{};
/**
* @brief holds the orientation of the tiles
*/
PageOrientation m_tilesOrientation {PageOrientation::Portrait};
// margins // margins
/** /**
* @brief m_margins the margins of the tiles in Unit::Px * @brief m_margins the margins of the tiles in Unit::Px
@ -465,19 +322,6 @@ private:
bool m_showTiles{false}; bool m_showTiles{false};
/**
* @brief m_size the Size in Unit::Px
*/
QSizeF m_size{};
// margins
/**
* @brief m_margins the margins in Unit::Px
*/
QMarginsF m_margins{};
bool m_ignoreMargins{false};
// control // control
bool m_followGrainLine{false}; bool m_followGrainLine{false};

View File

@ -216,7 +216,7 @@ void VPPiece::RotateToGrainline(const VPTransformationOrigon &origin)
QLineF canonical(grainlinePoints.first().x(), grainlinePoints.first().y(), QLineF canonical(grainlinePoints.first().x(), grainlinePoints.first().y(),
grainlinePoints.first().x()+100, grainlinePoints.first().y()); grainlinePoints.first().x()+100, grainlinePoints.first().y());
GrainlineType grainlineType = sheet->GrainlineType(); GrainlineType grainlineType = sheet->GrainlineOrientation();
auto DegreesAtFront = [grainline, canonical, grainlineType]() auto DegreesAtFront = [grainline, canonical, grainlineType]()
{ {

View File

@ -29,12 +29,18 @@
#include "vplayout.h" #include "vplayout.h"
#include "vppiece.h" #include "vppiece.h"
#include "../vpapplication.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPSheet::VPSheet(const VPLayoutPtr &layout) : VPSheet::VPSheet(const VPLayoutPtr &layout) :
m_layout(layout) m_layout(layout)
{ {
SCASSERT(layout != nullptr) SCASSERT(layout != nullptr)
VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
SetIgnoreMargins(settings->GetLayoutSheetIgnoreMargins());
SetSheetMargins(settings->GetLayoutSheetMargins());
SetSheetSize(QSizeF(settings->GetLayoutSheetPaperWidth(), settings->GetLayoutSheetPaperHeight()));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -111,21 +117,33 @@ void VPSheet::SetVisible(bool visible)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSheet::GrainlineType() const -> enum GrainlineType GrainlineType VPSheet::GrainlineOrientation() const
{ {
VPLayoutPtr layout = GetLayout(); if (m_grainlineType == GrainlineType::NotFixed)
if (not layout.isNull())
{ {
QSizeF size = layout->LayoutSettings().GetSheetSize(); if (m_size.height() < m_size.width())
if (size.height() < size.width())
{ {
return GrainlineType::Horizontal; return GrainlineType::Horizontal;
} }
}
return GrainlineType::Vertical; return GrainlineType::Vertical;
} }
return m_grainlineType;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPSheet::GetGrainlineType() const -> GrainlineType
{
return m_grainlineType;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetGrainlineType(GrainlineType type)
{
m_grainlineType = type;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSheet::TransformationOrigin() const -> const VPTransformationOrigon & auto VPSheet::TransformationOrigin() const -> const VPTransformationOrigon &
{ {
@ -244,48 +262,77 @@ void VPSheet::ValidatePiecesOutOfBound() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSheet::GetSheetRect() const -> QRectF auto VPSheet::GetSheetRect() const -> QRectF
{ {
return GetSheetRect(GetLayout()); return QRectF(QPoint(0, 0), m_size);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSheet::GetMarginsRect() const -> QRectF auto VPSheet::GetMarginsRect() const -> QRectF
{ {
return GetMarginsRect(GetLayout()); if (not m_ignoreMargins)
}
//---------------------------------------------------------------------------------------------------------------------
auto VPSheet::GetSheetRect(const VPLayoutPtr &layout) -> QRectF
{ {
if (layout.isNull()) QRectF rect = QRectF(QPointF(m_margins.left(), m_margins.top()),
{ QPointF(m_size.width() - m_margins.right(), m_size.height() - m_margins.bottom()));
return {};
}
QPoint topLeft = QPoint(0,0);
QSizeF size = layout->LayoutSettings().GetSheetSize();
QRectF rect = QRectF(topLeft, size);
return rect; return rect;
} }
return QRectF(0, 0, m_size.width(), m_size.height());
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSheet::GetMarginsRect(const VPLayoutPtr &layout) -> QRectF void VPSheet::RemoveUnusedLength()
{ {
VPLayoutPtr layout = GetLayout();
if (layout.isNull()) if (layout.isNull())
{ {
return {}; return;
} }
QSizeF size = layout->LayoutSettings().GetSheetSize(); QList<VPPiecePtr> pieces = GetPieces();
if (pieces.isEmpty())
if (not layout->LayoutSettings().IgnoreMargins())
{ {
QMarginsF margins = layout->LayoutSettings().GetSheetMargins(); return;
QRectF rect = QRectF(QPointF(margins.left(), margins.top()),
QPointF(size.width()-margins.right(), size.height()-margins.bottom()));
return rect;
} }
return QRectF(0, 0, size.width(), size.height()); QRectF piecesBoundingRect;
for (const auto& piece : pieces)
{
if (not piece.isNull())
{
piecesBoundingRect = piecesBoundingRect.united(piece->MappedDetailBoundingRect());
}
}
const qreal extra = 2;
QRectF sheetRect = GetSheetRect();
GrainlineType type = GrainlineOrientation();
if (type == GrainlineType::Vertical)
{
qreal margin = 0;
if (not m_ignoreMargins)
{
margin = m_margins.bottom();
}
if (sheetRect.bottomRight().y() - margin > piecesBoundingRect.bottomRight().y())
{
m_size = QSizeF(m_size.width(), piecesBoundingRect.bottomRight().y() + margin + extra);
}
}
else if (type == GrainlineType::Horizontal)
{
qreal margin = 0;
if (not m_ignoreMargins)
{
margin = m_margins.right();
}
if (sheetRect.topRight().x() - margin > piecesBoundingRect.topRight().x())
{
m_size = QSizeF(piecesBoundingRect.topRight().x() + margin + extra, m_size.height());
}
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -313,3 +360,118 @@ void VPSheet::CheckPiecePositionValidity(const VPPiecePtr &piece) const
ValidateSuperpositionOfPieces(); ValidateSuperpositionOfPieces();
} }
} }
//---------------------------------------------------------------------------------------------------------------------
Unit VPSheet::SheetUnits() const
{
VPLayoutPtr layout = GetLayout();
if (not layout.isNull())
{
return layout->LayoutSettings().GetUnit();
}
return Unit::Cm;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSize(qreal width, qreal height)
{
m_size.setWidth(width);
m_size.setHeight(height);
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSizeConverted(qreal width, qreal height)
{
Unit unit = SheetUnits();
m_size.setWidth(UnitConvertor(width, unit, Unit::Px));
m_size.setHeight(UnitConvertor(height, unit, Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSize(const QSizeF &size)
{
m_size = size;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetSizeConverted(const QSizeF &size)
{
Unit unit = SheetUnits();
m_size = QSizeF(UnitConvertor(size.width(), unit, Unit::Px),
UnitConvertor(size.height(), unit, Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
auto VPSheet::GetSheetSize() const -> QSizeF
{
return m_size;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPSheet::GetSheetSizeConverted() const -> QSizeF
{
Unit unit = SheetUnits();
QSizeF convertedSize = QSizeF(
UnitConvertor(m_size.width(), Unit::Px, unit),
UnitConvertor(m_size.height(), Unit::Px, unit)
);
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)
{
Unit unit = SheetUnits();
m_margins.setLeft(UnitConvertor(left, unit, Unit::Px));
m_margins.setTop(UnitConvertor(top, unit, Unit::Px));
m_margins.setRight(UnitConvertor(right, unit, Unit::Px));
m_margins.setBottom(UnitConvertor(bottom, unit, Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetMargins(const QMarginsF &margins)
{
m_margins = margins;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetSheetMarginsConverted(const QMarginsF &margins)
{
Unit unit = SheetUnits();
m_margins = UnitConvertor(margins, unit, Unit::Px);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPSheet::GetSheetMargins() const -> QMarginsF
{
return m_margins;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPSheet::GetSheetMarginsConverted() const -> QMarginsF
{
Unit unit = SheetUnits();
return UnitConvertor(m_margins, Unit::Px, unit);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPSheet::IgnoreMargins() const -> bool
{
return m_ignoreMargins;
}
//---------------------------------------------------------------------------------------------------------------------
void VPSheet::SetIgnoreMargins(bool newIgnoreMargins)
{
m_ignoreMargins = newIgnoreMargins;
}

View File

@ -1,4 +1,4 @@
/************************************************************************ /************************************************************************
** **
** @file vpsheet.h ** @file vpsheet.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
@ -75,7 +75,9 @@ public:
bool IsVisible() const; bool IsVisible() const;
void SetVisible(bool visible); void SetVisible(bool visible);
auto GrainlineType() const -> GrainlineType; auto GrainlineOrientation() const -> GrainlineType;
auto GetGrainlineType() const -> GrainlineType;
void SetGrainlineType(GrainlineType type);
auto TransformationOrigin() const -> const VPTransformationOrigon &; auto TransformationOrigin() const -> const VPTransformationOrigon &;
void SetTransformationOrigin(const VPTransformationOrigon &newTransformationOrigin); void SetTransformationOrigin(const VPTransformationOrigon &newTransformationOrigin);
@ -92,8 +94,89 @@ public:
auto GetSheetRect() const -> QRectF; auto GetSheetRect() const -> QRectF;
auto GetMarginsRect() const -> QRectF; auto GetMarginsRect() const -> QRectF;
static auto GetSheetRect(const VPLayoutPtr &layout) -> QRectF; void RemoveUnusedLength();
static auto GetMarginsRect(const VPLayoutPtr &layout) -> QRectF;
/**
* @brief SetSheetSize sets the size of the sheet, the values have to be in Unit::Px
* @param width sheet width
* @param height sheet height
*/
void SetSheetSize(qreal width, qreal height);
/**
* @brief SetSheetSize sets the size of the sheet, the values have to be in the layout's unit
* @param width sheet width
* @param height sheet height
*/
void SetSheetSizeConverted(qreal width, qreal height);
/**
* @brief SetSheetSize sets the size of the sheet, the values have to be in Unit::Px
* @param size sheet size
*/
void SetSheetSize(const QSizeF &size);
/**
* @brief SetSheetSizeConverted sets the size of the sheet, the values have to be in the layout's unit
* @param size sheet size
*/
void SetSheetSizeConverted(const QSizeF &size);
/**
* @brief GetSheetSize Returns the size in Unit::Px
* @return sheet size in Unit::Px
*/
auto GetSheetSize() const -> QSizeF;
/**
* @brief GetSheetSizeConverted Returns the size in the layout's unit
* @return the size in the layout's unit
*/
auto GetSheetSizeConverted() const -> QSizeF;
/**
* @brief SetSheetMargins, set the margins of the sheet, the values have to be in Unit::Px
* @param left in Unit::Px
* @param top in Unit::Px
* @param right in Unit::Px
* @param bottom in Unit::Px
*/
void SetSheetMargins(qreal left, qreal top, qreal right, qreal bottom);
/**
* @brief SetSheetMargins, set the margins of the sheet, the values have to be in the unit of the layout
* @param left in Unit::Px
* @param top in Unit::Px
* @param right in Unit::Px
* @param bottom in Unit::Px
*/
void SetSheetMarginsConverted(qreal left, qreal top, qreal right, qreal bottom);
/**
* @brief SetSheetMargins set the margins of the sheet, the values have to be in Unit::Px
* @param margins sheet margins
*/
void SetSheetMargins(const QMarginsF &margins);
/**
* @brief SetSheetMargins set the margins of the sheet, the values have to be in the unit of the layout
* @param margins sheet margins
*/
void SetSheetMarginsConverted(const QMarginsF &margins);
/**
* @brief GetSheetMargins Returns the size in Unit::Px
* @return the size in Unit::Px
*/
auto GetSheetMargins() const -> QMarginsF;
/**
* @brief GetSheetMarginsConverted Returns the margins in the layout's unit
* @return the margins in the sheet's unit
*/
auto GetSheetMarginsConverted() const -> QMarginsF;
auto IgnoreMargins() const -> bool;
void SetIgnoreMargins(bool newIgnoreMargins);
public slots: public slots:
void CheckPiecePositionValidity(const VPPiecePtr &piece) const; void CheckPiecePositionValidity(const VPPiecePtr &piece) const;
@ -112,6 +195,22 @@ private:
VPTransformationOrigon m_transformationOrigin{}; VPTransformationOrigon m_transformationOrigin{};
/**
* @brief m_size the Size in Unit::Px
*/
QSizeF m_size{};
// margins
/**
* @brief m_margins the margins in Unit::Px
*/
QMarginsF m_margins{};
bool m_ignoreMargins{false};
GrainlineType m_grainlineType{GrainlineType::NotFixed};
auto SheetUnits() const -> Unit;
}; };

View File

@ -7,6 +7,7 @@ SOURCES += \
$$PWD/dialogs/configpages/puzzlepreferenceslayoutpage.cpp \ $$PWD/dialogs/configpages/puzzlepreferenceslayoutpage.cpp \
$$PWD/dialogs/dialogpuzzlepreferences.cpp \ $$PWD/dialogs/dialogpuzzlepreferences.cpp \
$$PWD/dialogs/vpdialogabout.cpp \ $$PWD/dialogs/vpdialogabout.cpp \
$$PWD/layout/layoutdef.cpp \
$$PWD/main.cpp \ $$PWD/main.cpp \
$$PWD/undocommands/vpundoaddsheet.cpp \ $$PWD/undocommands/vpundoaddsheet.cpp \
$$PWD/undocommands/vpundocommand.cpp \ $$PWD/undocommands/vpundocommand.cpp \

View File

@ -105,13 +105,35 @@ void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPGraphicsSheet::GetSheetRect() const -> QRectF auto VPGraphicsSheet::GetSheetRect() const -> QRectF
{ {
return VPSheet::GetSheetRect(m_layout.toStrongRef()); VPLayoutPtr layout = m_layout.toStrongRef();
if (layout.isNull())
{
return {};
}
VPSheetPtr sheet = layout->GetFocusedSheet();
if (sheet.isNull())
{
return {};
}
return sheet->GetSheetRect();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPGraphicsSheet::GetMarginsRect() const -> QRectF auto VPGraphicsSheet::GetMarginsRect() const -> QRectF
{ {
return VPSheet::GetMarginsRect(m_layout.toStrongRef()); VPLayoutPtr layout = m_layout.toStrongRef();
if (layout.isNull())
{
return {};
}
VPSheetPtr sheet = layout->GetFocusedSheet();
if (sheet.isNull())
{
return {};
}
return sheet->GetMarginsRect();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -16,5 +16,9 @@
<file>puzzleicon/svg/icon_rotate_90_clockwise.svg</file> <file>puzzleicon/svg/icon_rotate_90_clockwise.svg</file>
<file>puzzleicon/svg/icon_rotate_grainline_horizontal.svg</file> <file>puzzleicon/svg/icon_rotate_grainline_horizontal.svg</file>
<file>puzzleicon/svg/icon_rotate_grainline_vertical.svg</file> <file>puzzleicon/svg/icon_rotate_grainline_vertical.svg</file>
<file>puzzleicon/32X32/horizontal_grainline.png</file>
<file>puzzleicon/32X32/horizontal_grainline@2x.png</file>
<file>puzzleicon/32X32/vertical_grainline.png</file>
<file>puzzleicon/32X32/vertical_grainline@2x.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -43,7 +43,7 @@ void VPExporter::Export(VPLayout* layout, LayoutExportFormats format, VPMainGrap
SetFileName(fileName); SetFileName(fileName);
QSizeF size = QSizeF(layout->GetFocusedSheet()->GetLayout()->LayoutSettings().GetSheetSize()); QSizeF size = QSizeF(layout->GetFocusedSheet()->GetSheetSize());
const QRectF rect = QRectF(0, 0, size.width(), size.height()); const QRectF rect = QRectF(0, 0, size.width(), size.height());
SetImageRect(rect); SetImageRect(rect);

View File

@ -139,6 +139,12 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
{ {
SetPropertyTabCurrentPieceData(); SetPropertyTabCurrentPieceData();
}); });
connect(m_layout.get(), &VPLayout::ActiveSheetChanged, this, [this]()
{
m_tileFactory->refreshTileInfos();
m_graphicsView->RefreshLayout();
SetPropertyTabSheetData();
});
connect(m_undoStack, &QUndoStack::cleanChanged, this, [this](bool clean) connect(m_undoStack, &QUndoStack::cleanChanged, this, [this](bool clean)
{ {
@ -393,6 +399,7 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
} }
m_carrousel->Refresh(); m_carrousel->Refresh();
m_layout->CheckPiecesPositionValidity();
LayoutWasSaved(false); LayoutWasSaved(false);
} }
else else
@ -665,6 +672,67 @@ void VPMainWindow::InitPropertyTabCurrentSheet()
connect(ui->toolButtonSheetLandscapeOrientation, &QToolButton::toggled, this, connect(ui->toolButtonSheetLandscapeOrientation, &QToolButton::toggled, this,
&VPMainWindow::on_SheetOrientationChanged); &VPMainWindow::on_SheetOrientationChanged);
connect(ui->toolButtonGrainlineHorizontalOrientation, &QToolButton::clicked, this, [this](bool checked)
{
VPSheetPtr sheet = m_layout->GetFocusedSheet();
if (sheet.isNull())
{
return;
}
if (checked)
{
sheet->SetGrainlineType(GrainlineType::Horizontal);
ui->toolButtonGrainlineVerticalOrientation->setChecked(false);
}
else
{
sheet->SetGrainlineType(GrainlineType::NotFixed);
}
RotatePiecesToGrainline();
LayoutWasSaved(false);
});
connect(ui->toolButtonGrainlineVerticalOrientation, &QToolButton::clicked, this, [this](bool checked)
{
VPSheetPtr sheet = m_layout->GetFocusedSheet();
if (sheet.isNull())
{
return;
}
if (checked)
{
sheet->SetGrainlineType(GrainlineType::Vertical);
ui->toolButtonGrainlineHorizontalOrientation->setChecked(false);
}
else
{
sheet->SetGrainlineType(GrainlineType::NotFixed);
}
RotatePiecesToGrainline();
LayoutWasSaved(false);
});
connect(ui->pushButtonSheetRemoveUnusedLength, &QPushButton::clicked, this, [this]()
{
if (not m_layout.isNull())
{
VPSheetPtr sheet = m_layout->GetFocusedSheet();
if (not sheet.isNull())
{
sheet->RemoveUnusedLength();
LayoutWasSaved(false);
m_tileFactory->refreshTileInfos();
m_graphicsView->RefreshLayout();
m_graphicsView->RefreshPieces();
SetPropertyTabSheetData();
}
}
});
// -------------------- margins ------------------------ // -------------------- margins ------------------------
ui->doubleSpinBoxSheetMarginLeft->setSuffix(suffix); ui->doubleSpinBoxSheetMarginLeft->setSuffix(suffix);
ui->doubleSpinBoxSheetMarginRight->setSuffix(suffix); ui->doubleSpinBoxSheetMarginRight->setSuffix(suffix);
@ -689,14 +757,14 @@ void VPMainWindow::InitPropertyTabCurrentSheet()
ui->doubleSpinBoxSheetMarginTop->setDisabled(state != 0); ui->doubleSpinBoxSheetMarginTop->setDisabled(state != 0);
ui->doubleSpinBoxSheetMarginBottom->setDisabled(state != 0); ui->doubleSpinBoxSheetMarginBottom->setDisabled(state != 0);
m_layout->LayoutSettings().SetIgnoreMargins(state != 0); VPSheetPtr sheet = m_layout->GetFocusedSheet();
if (not sheet.isNull())
{
sheet->SetIgnoreMargins(state != 0);
LayoutWasSaved(false); LayoutWasSaved(false);
m_tileFactory->refreshTileInfos(); m_tileFactory->refreshTileInfos();
m_graphicsView->RefreshLayout(); m_graphicsView->RefreshLayout();
VPSheetPtr sheet = m_layout->GetFocusedSheet();
if (not sheet.isNull())
{
sheet->ValidatePiecesOutOfBound(); sheet->ValidatePiecesOutOfBound();
} }
} }
@ -971,6 +1039,9 @@ void VPMainWindow::SetPropertyTabCurrentPieceData()
void VPMainWindow::SetPropertyTabSheetData() void VPMainWindow::SetPropertyTabSheetData()
{ {
if (not m_layout.isNull()) if (not m_layout.isNull())
{
VPSheetPtr sheet = m_layout->GetFocusedSheet();
if (not sheet.isNull())
{ {
ui->groupBoxSheetInfos->setDisabled(false); ui->groupBoxSheetInfos->setDisabled(false);
VPSheetPtr sheet = m_layout->GetFocusedSheet(); VPSheetPtr sheet = m_layout->GetFocusedSheet();
@ -1000,7 +1071,7 @@ void VPMainWindow::SetPropertyTabSheetData()
ui->doubleSpinBoxSheetMarginBottom->setSuffix(suffix); ui->doubleSpinBoxSheetMarginBottom->setSuffix(suffix);
// set Width / Length // set Width / Length
QSizeF size = m_layout->LayoutSettings().GetSheetSizeConverted(); QSizeF size = sheet->GetSheetSizeConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, size.width()); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, size.width());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, size.height()); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, size.height());
@ -1009,7 +1080,7 @@ void VPMainWindow::SetPropertyTabSheetData()
// set margins // set margins
ui->groupBoxSheetMargin->setDisabled(false); ui->groupBoxSheetMargin->setDisabled(false);
QMarginsF margins = m_layout->LayoutSettings().GetSheetMarginsConverted(); QMarginsF margins = sheet->GetSheetMarginsConverted();
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, margins.left()); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, margins.left());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, margins.top()); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, margins.top());
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, margins.right()); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, margins.right());
@ -1017,7 +1088,7 @@ void VPMainWindow::SetPropertyTabSheetData()
CorrectSheetMaxMargins(); CorrectSheetMaxMargins();
const bool ignoreMargins = m_layout->LayoutSettings().IgnoreMargins(); const bool ignoreMargins = sheet->IgnoreMargins();
SetCheckBoxValue(ui->checkBoxLayoutIgnoreFileds, ignoreMargins); SetCheckBoxValue(ui->checkBoxLayoutIgnoreFileds, ignoreMargins);
ui->doubleSpinBoxSheetMarginLeft->setDisabled(ignoreMargins); ui->doubleSpinBoxSheetMarginLeft->setDisabled(ignoreMargins);
@ -1025,6 +1096,10 @@ void VPMainWindow::SetPropertyTabSheetData()
ui->doubleSpinBoxSheetMarginTop->setDisabled(ignoreMargins); ui->doubleSpinBoxSheetMarginTop->setDisabled(ignoreMargins);
ui->doubleSpinBoxSheetMarginBottom->setDisabled(ignoreMargins); ui->doubleSpinBoxSheetMarginBottom->setDisabled(ignoreMargins);
GrainlineType type = sheet->GetGrainlineType();
ui->toolButtonGrainlineHorizontalOrientation->setChecked(type == GrainlineType::Horizontal);
ui->toolButtonGrainlineVerticalOrientation->setChecked(type == GrainlineType::Vertical);
// set placement grid // set placement grid
ui->groupBoxSheetGrid->setDisabled(false); ui->groupBoxSheetGrid->setDisabled(false);
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridColWidth, SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridColWidth,
@ -1035,9 +1110,11 @@ void VPMainWindow::SetPropertyTabSheetData()
SetCheckBoxValue(ui->checkBoxSheetShowGrid, m_layout->LayoutSettings().GetShowGrid()); SetCheckBoxValue(ui->checkBoxSheetShowGrid, m_layout->LayoutSettings().GetShowGrid());
ui->groupBoxSheetExport->setDisabled(false); ui->groupBoxSheetExport->setDisabled(false);
return;
} }
else }
{
ui->groupBoxSheetInfos->setDisabled(true); ui->groupBoxSheetInfos->setDisabled(true);
SetLineEditValue(ui->lineEditSheetName, QString()); SetLineEditValue(ui->lineEditSheetName, QString());
@ -1072,7 +1149,6 @@ void VPMainWindow::SetPropertyTabSheetData()
ui->groupBoxSheetExport->setDisabled(true); ui->groupBoxSheetExport->setDisabled(true);
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::SetPropertyTabTilesData() void VPMainWindow::SetPropertyTabTilesData()
@ -1874,6 +1950,11 @@ void VPMainWindow::CorrectMaxMargins()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::RotatePiecesToGrainline() void VPMainWindow::RotatePiecesToGrainline()
{ {
if (not m_layout->LayoutSettings().GetFollowGrainline())
{
return;
}
QList<VPSheetPtr> sheets = m_layout->GetSheets(); QList<VPSheetPtr> sheets = m_layout->GetSheets();
for(const auto& sheet : sheets) for(const auto& sheet : sheets)
{ {
@ -2163,9 +2244,13 @@ void VPMainWindow::on_SheetSizeChanged()
{ {
if (not m_layout.isNull()) if (not m_layout.isNull())
{ {
m_layout->LayoutSettings().SetSheetSizeConverted( VPSheetPtr sheet = m_layout->GetFocusedSheet();
ui->doubleSpinBoxSheetPaperWidth->value(), if (not sheet.isNull())
{
sheet->SetSheetSizeConverted(ui->doubleSpinBoxSheetPaperWidth->value(),
ui->doubleSpinBoxSheetPaperHeight->value()); ui->doubleSpinBoxSheetPaperHeight->value());
}
FindSheetTemplate(); FindSheetTemplate();
SheetPaperSizeChanged(); SheetPaperSizeChanged();
CorrectMaxMargins(); CorrectMaxMargins();
@ -2187,7 +2272,11 @@ void VPMainWindow::on_SheetOrientationChanged(bool checked)
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, height); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, height);
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, width); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, width);
m_layout->LayoutSettings().SetSheetSizeConverted(height, width); VPSheetPtr sheet = m_layout->GetFocusedSheet();
if (not sheet.isNull())
{
sheet->SetSheetSizeConverted(height, width);
}
SheetPaperSizeChanged(); SheetPaperSizeChanged();
CorrectMaxMargins(); CorrectMaxMargins();
@ -2197,36 +2286,21 @@ void VPMainWindow::on_SheetOrientationChanged(bool checked)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked()
{
// just for test purpuses, to be removed:
QMessageBox msgBox;
msgBox.setText("TODO VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked");
int ret = msgBox.exec();
Q_UNUSED(ret);
// TODO
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_SheetMarginChanged() void VPMainWindow::on_SheetMarginChanged()
{ {
if (not m_layout.isNull()) if (not m_layout.isNull())
{ {
m_layout->LayoutSettings().SetSheetMarginsConverted( VPSheetPtr sheet = m_layout->GetFocusedSheet();
ui->doubleSpinBoxSheetMarginLeft->value(), if (not sheet.isNull())
{
sheet->SetSheetMarginsConverted(ui->doubleSpinBoxSheetMarginLeft->value(),
ui->doubleSpinBoxSheetMarginTop->value(), ui->doubleSpinBoxSheetMarginTop->value(),
ui->doubleSpinBoxSheetMarginRight->value(), ui->doubleSpinBoxSheetMarginRight->value(),
ui->doubleSpinBoxSheetMarginBottom->value()); ui->doubleSpinBoxSheetMarginBottom->value());
LayoutWasSaved(false); LayoutWasSaved(false);
VPSheetPtr sheet = m_layout->GetFocusedSheet();
if (not sheet.isNull())
{
sheet->ValidatePiecesOutOfBound(); sheet->ValidatePiecesOutOfBound();
} }

View File

@ -174,13 +174,6 @@ private slots:
*/ */
void on_SheetOrientationChanged(bool checked); void on_SheetOrientationChanged(bool checked);
/**
* @brief on_pushButtonLayoutRemoveUnusedLength_clicked When the button
* "Remove unused length" in the sheet property tab is clicked.
* The slot is automatically connected through name convention.
*/
void on_pushButtonSheetRemoveUnusedLength_clicked();
/** /**
* @brief on_SheetMarginChanged When one of the margin values has been changed * @brief on_SheetMarginChanged When one of the margin values has been changed
* in the sheet property tab. * in the sheet property tab.

View File

@ -189,7 +189,7 @@
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -249,7 +249,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>358</width> <width>392</width>
<height>700</height> <height>700</height>
</rect> </rect>
</property> </property>
@ -686,8 +686,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>344</width> <width>378</width>
<height>748</height> <height>829</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_12"> <layout class="QVBoxLayout" name="verticalLayout_12">
@ -787,6 +787,51 @@
</item> </item>
<item> <item>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetPaperHeight">
<property name="minimumSize">
<size>
<width>94</width>
<height>0</height>
</size>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>99999.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetPaperWidth">
<property name="minimumSize">
<size>
<width>94</width>
<height>0</height>
</size>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>99999.990000000005239</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Length:</string>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
@ -850,50 +895,82 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> </layout>
<widget class="QLabel" name="labelLength"> </item>
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="Fixed" vsizetype="Preferred"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<horstretch>0</horstretch> <item>
<verstretch>0</verstretch> <widget class="QLabel" name="label_5">
</sizepolicy> <property name="text">
<string>Grainline orientation:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="toolButtonGrainlineHorizontalOrientation">
<property name="toolTip">
<string>Force the grainline orientation to always be horizontal</string>
</property> </property>
<property name="text"> <property name="text">
<string>Length:</string> <string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/puzzleicon.qrc">
<normaloff>:/puzzleicon/32X32/horizontal_grainline.png</normaloff>:/puzzleicon/32X32/horizontal_grainline.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetPaperHeight"> <widget class="QToolButton" name="toolButtonGrainlineVerticalOrientation">
<property name="minimumSize"> <property name="toolTip">
<string>Force the grainline orientation to always be vertical</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/puzzleicon.qrc">
<normaloff>:/puzzleicon/32X32/vertical_grainline.png</normaloff>:/puzzleicon/32X32/vertical_grainline.png</iconset>
</property>
<property name="iconSize">
<size> <size>
<width>94</width> <width>24</width>
<height>0</height> <height>24</height>
</size> </size>
</property> </property>
<property name="decimals"> <property name="checkable">
<number>2</number> <bool>true</bool>
</property>
<property name="maximum">
<double>99999.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSheetPaperWidth"> <spacer name="horizontalSpacer_2">
<property name="minimumSize"> <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size> <size>
<width>94</width> <width>40</width>
<height>0</height> <height>20</height>
</size> </size>
</property> </property>
<property name="decimals"> </spacer>
<number>2</number> </item>
</property> </layout>
<property name="maximum">
<double>99999.990000000005239</double>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -1133,7 +1210,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>358</width> <width>392</width>
<height>700</height> <height>700</height>
</rect> </rect>
</property> </property>
@ -1505,7 +1582,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>358</width> <width>392</width>
<height>700</height> <height>700</height>
</rect> </rect>
</property> </property>

View File

@ -49,7 +49,12 @@ void VPTileFactory::refreshTileInfos()
m_drawingAreaWidth += m_infoStripeWidth; m_drawingAreaWidth += m_infoStripeWidth;
} }
QSizeF sheetSize = layout->LayoutSettings().GetSheetSize(); QSizeF sheetSize;
VPSheetPtr sheet = layout->GetFocusedSheet();
if (not sheet.isNull())
{
sheetSize = sheet->GetSheetSize();
}
m_nbCol = qCeil(sheetSize.width()/m_drawingAreaWidth); m_nbCol = qCeil(sheetSize.width()/m_drawingAreaWidth);
m_nbRow = qCeil(sheetSize.height()/m_drawingAreaHeight); m_nbRow = qCeil(sheetSize.height()/m_drawingAreaHeight);
} }

View File

@ -241,10 +241,8 @@ void VPLayoutFileReader::ReadProperties(const VPLayoutPtr &layout)
ML::TagUnit, // 0 ML::TagUnit, // 0
ML::TagTitle, // 1 ML::TagTitle, // 1
ML::TagDescription, // 2 ML::TagDescription, // 2
ML::TagSize, // 3 ML::TagControl, // 3
ML::TagMargin, // 4 ML::TagTiles // 4
ML::TagControl, // 5
ML::TagTiles // 6
}; };
while (readNextStartElement()) while (readNextStartElement())
@ -265,17 +263,11 @@ void VPLayoutFileReader::ReadProperties(const VPLayoutPtr &layout)
qDebug("read description"); qDebug("read description");
layout->LayoutSettings().SetDescription(readElementText()); layout->LayoutSettings().SetDescription(readElementText());
break; break;
case 3: // size case 3: // control
layout->LayoutSettings().SetSheetSize(ReadSize());
break;
case 4: // margin
layout->LayoutSettings().SetSheetMargins(ReadMargins());
break;
case 5: // control
qDebug("read control"); qDebug("read control");
ReadControl(layout); ReadControl(layout);
break; break;
case 6: // tiles case 4: // tiles
qDebug("read tiles"); qDebug("read tiles");
ReadTiles(layout); ReadTiles(layout);
break; break;
@ -370,14 +362,19 @@ void VPLayoutFileReader::ReadSheet(const VPLayoutPtr &layout)
{ {
AssertRootTag(ML::TagSheet); AssertRootTag(ML::TagSheet);
VPSheetPtr sheet(new VPSheet(layout));
QXmlStreamAttributes attribs = attributes();
sheet->SetGrainlineType(StrToGrainlineType(ReadAttributeEmptyString(attribs, ML::AttrGrainlineType)));
const QStringList tags const QStringList tags
{ {
ML::TagName, // 0 ML::TagName, // 0
ML::TagPieces // 1 ML::TagSize, // 1
ML::TagMargin, // 2
ML::TagPieces // 3
}; };
VPSheetPtr sheet(new VPSheet(layout));
while (readNextStartElement()) while (readNextStartElement())
{ {
switch (tags.indexOf(name().toString())) switch (tags.indexOf(name().toString()))
@ -385,7 +382,13 @@ void VPLayoutFileReader::ReadSheet(const VPLayoutPtr &layout)
case 0: // name case 0: // name
sheet->SetName(readElementText()); sheet->SetName(readElementText());
break; break;
case 1: // pieces case 1: // size
sheet->SetSheetSize(ReadSize());
break;
case 2: // margin
sheet->SetSheetMargins(ReadMargins());
break;
case 3: // pieces
ReadPieces(layout, sheet); ReadPieces(layout, sheet);
break; break;
default: default:

View File

@ -154,22 +154,20 @@ void VPLayoutFileWriter::WriteLayout(const VPLayoutPtr &layout)
{ {
writeStartElement(ML::TagLayout); writeStartElement(ML::TagLayout);
SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr); SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr);
WriteProperties(layout); WriteLayoutProperties(layout);
WritePieceList(layout->GetUnplacedPieces(), ML::TagUnplacedPieces); WritePieceList(layout->GetUnplacedPieces(), ML::TagUnplacedPieces);
WriteSheets(layout); WriteSheets(layout);
writeEndElement(); //layout writeEndElement(); //layout
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteProperties(const VPLayoutPtr &layout) void VPLayoutFileWriter::WriteLayoutProperties(const VPLayoutPtr &layout)
{ {
writeStartElement(ML::TagProperties); writeStartElement(ML::TagProperties);
writeTextElement(ML::TagUnit, UnitsToStr(layout->LayoutSettings().GetUnit())); writeTextElement(ML::TagUnit, UnitsToStr(layout->LayoutSettings().GetUnit()));
writeTextElement(ML::TagTitle, layout->LayoutSettings().GetTitle()); writeTextElement(ML::TagTitle, layout->LayoutSettings().GetTitle());
writeTextElement(ML::TagDescription, layout->LayoutSettings().GetDescription()); writeTextElement(ML::TagDescription, layout->LayoutSettings().GetDescription());
WriteSize(layout->LayoutSettings().GetSheetSize());
WriteMargins(layout->LayoutSettings().GetSheetMargins());
writeStartElement(ML::TagControl); writeStartElement(ML::TagControl);
SetAttribute(ML::AttrWarningSuperposition, layout->LayoutSettings().GetWarningSuperpositionOfPieces()); SetAttribute(ML::AttrWarningSuperposition, layout->LayoutSettings().GetWarningSuperpositionOfPieces());
@ -205,8 +203,13 @@ void VPLayoutFileWriter::WriteSheets(const VPLayoutPtr &layout)
void VPLayoutFileWriter::WriteSheet(const VPSheetPtr &sheet) void VPLayoutFileWriter::WriteSheet(const VPSheetPtr &sheet)
{ {
writeStartElement(ML::TagSheet); writeStartElement(ML::TagSheet);
SetAttributeOrRemoveIf<QString>(ML::AttrGrainlineType, GrainlineTypeToStr(sheet->GetGrainlineType()),
[](const QString &type)
{return type == GrainlineTypeToStr(GrainlineType::NotFixed);});
writeTextElement(ML::TagName, sheet->GetName()); writeTextElement(ML::TagName, sheet->GetName());
WriteSize(sheet->GetSheetSize());
WriteMargins(sheet->GetSheetMargins());
WritePieceList(sheet->GetPieces(), ML::TagPieces); WritePieceList(sheet->GetPieces(), ML::TagPieces);
writeEndElement(); // sheet writeEndElement(); // sheet

View File

@ -56,7 +56,7 @@ public:
private: private:
void WriteLayout(const VPLayoutPtr &layout); void WriteLayout(const VPLayoutPtr &layout);
void WriteProperties(const VPLayoutPtr &layout); void WriteLayoutProperties(const VPLayoutPtr &layout);
void WriteSheets(const VPLayoutPtr &layout); void WriteSheets(const VPLayoutPtr &layout);
void WriteSheet(const VPSheetPtr &sheet); void WriteSheet(const VPSheetPtr &sheet);
void WriteTiles(const VPLayoutPtr &layout); void WriteTiles(const VPLayoutPtr &layout);

View File

@ -97,6 +97,7 @@ const QString AttrItalic = QStringLiteral("italic");
const QString AttrAlignment = QStringLiteral("alignment"); const QString AttrAlignment = QStringLiteral("alignment");
const QString AttrGradationLabel = QStringLiteral("gradationLabel"); const QString AttrGradationLabel = QStringLiteral("gradationLabel");
const QString AttrCopyNumber = QStringLiteral("copyNumber"); const QString AttrCopyNumber = QStringLiteral("copyNumber");
const QString AttrGrainlineType = QStringLiteral("grainlineType");
const QString atFrontStr = QStringLiteral("atFront"); const QString atFrontStr = QStringLiteral("atFront");
const QString atRearStr = QStringLiteral("atRear"); const QString atRearStr = QStringLiteral("atRear");

View File

@ -102,6 +102,7 @@ extern const QString AttrItalic;
extern const QString AttrAlignment; extern const QString AttrAlignment;
extern const QString AttrGradationLabel; extern const QString AttrGradationLabel;
extern const QString AttrCopyNumber; extern const QString AttrCopyNumber;
extern const QString AttrGrainlineType;
extern const QString atFrontStr; extern const QString atFrontStr;
extern const QString atRearStr; extern const QString atRearStr;

View File

@ -8,20 +8,6 @@
<xs:element type="units" name="unit"/> <xs:element type="units" name="unit"/>
<xs:element type="xs:string" name="title"/> <xs:element type="xs:string" name="title"/>
<xs:element type="xs:string" name="description"/> <xs:element type="xs:string" name="description"/>
<xs:element name="size">
<xs:complexType>
<xs:attribute type="xs:float" name="width" use="required"/>
<xs:attribute type="xs:float" name="length" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="margin">
<xs:complexType>
<xs:attribute type="xs:float" name="top"/>
<xs:attribute type="xs:float" name="right"/>
<xs:attribute type="xs:float" name="bottom"/>
<xs:attribute type="xs:float" name="left"/>
</xs:complexType>
</xs:element>
<xs:element name="control"> <xs:element name="control">
<xs:complexType> <xs:complexType>
<xs:attribute type="xs:boolean" name="warningSuperposition"/> <xs:attribute type="xs:boolean" name="warningSuperposition"/>
@ -199,6 +185,20 @@
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element type="xs:string" name="name"/> <xs:element type="xs:string" name="name"/>
<xs:element name="size">
<xs:complexType>
<xs:attribute type="xs:float" name="width" use="required"/>
<xs:attribute type="xs:float" name="length" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="margin">
<xs:complexType>
<xs:attribute type="xs:float" name="top"/>
<xs:attribute type="xs:float" name="right"/>
<xs:attribute type="xs:float" name="bottom"/>
<xs:attribute type="xs:float" name="left"/>
</xs:complexType>
</xs:element>
<xs:element name="pieces"> <xs:element name="pieces">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
@ -336,6 +336,7 @@
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
<xs:attribute type="GrainlineType" name="grainlineType"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
@ -461,4 +462,11 @@
<xs:pattern value="(([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\s){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\*){0,}([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\s){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/> <xs:pattern value="(([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\s){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\*){0,}([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\s){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
<xs:simpleType name="GrainlineType">
<xs:restriction base="xs:string">
<xs:enumeration value="horizontal"/>
<xs:enumeration value="vertical"/>
<xs:enumeration value="notFixed"/>
</xs:restriction>
</xs:simpleType>
</xs:schema> </xs:schema>