From 8e9547da4a6fb1c6763734bb385d094c1bb88421 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 1 Sep 2021 09:20:58 +0300 Subject: [PATCH] Remove unused length. --- src/app/puzzle/layout/layoutdef.cpp | 92 +++++ src/app/puzzle/layout/layoutdef.h | 18 +- src/app/puzzle/layout/vplayout.cpp | 5 - src/app/puzzle/layout/vplayoutsettings.cpp | 342 ------------------ src/app/puzzle/layout/vplayoutsettings.h | 156 -------- src/app/puzzle/layout/vppiece.cpp | 2 +- src/app/puzzle/layout/vpsheet.cpp | 240 ++++++++++-- src/app/puzzle/layout/vpsheet.h | 107 +++++- src/app/puzzle/puzzle.pri | 1 + src/app/puzzle/scene/vpgraphicssheet.cpp | 26 +- src/app/puzzle/share/resources/puzzleicon.qrc | 4 + .../puzzleicon/32X32/horizontal_grainline.png | Bin 0 -> 2669 bytes .../32X32/horizontal_grainline@2x.png | Bin 0 -> 4906 bytes .../puzzleicon/32X32/vertical_grainline.png | Bin 0 -> 2719 bytes .../32X32/vertical_grainline@2x.png | Bin 0 -> 4356 bytes src/app/puzzle/vpexporter.cpp | 2 +- src/app/puzzle/vpmainwindow.cpp | 306 ++++++++++------ src/app/puzzle/vpmainwindow.h | 7 - src/app/puzzle/vpmainwindow.ui | 169 ++++++--- src/app/puzzle/vptilefactory.cpp | 7 +- src/app/puzzle/xml/vplayoutfilereader.cpp | 35 +- src/app/puzzle/xml/vplayoutfilewriter.cpp | 11 +- src/app/puzzle/xml/vplayoutfilewriter.h | 2 +- src/app/puzzle/xml/vplayoutliterals.cpp | 1 + src/app/puzzle/xml/vplayoutliterals.h | 1 + src/libs/ifc/schema/layout/v0.1.0.xsd | 36 +- 26 files changed, 802 insertions(+), 768 deletions(-) create mode 100644 src/app/puzzle/layout/layoutdef.cpp create mode 100644 src/app/puzzle/share/resources/puzzleicon/32X32/horizontal_grainline.png create mode 100644 src/app/puzzle/share/resources/puzzleicon/32X32/horizontal_grainline@2x.png create mode 100644 src/app/puzzle/share/resources/puzzleicon/32X32/vertical_grainline.png create mode 100644 src/app/puzzle/share/resources/puzzleicon/32X32/vertical_grainline@2x.png diff --git a/src/app/puzzle/layout/layoutdef.cpp b/src/app/puzzle/layout/layoutdef.cpp new file mode 100644 index 000000000..2b3b47df3 --- /dev/null +++ b/src/app/puzzle/layout/layoutdef.cpp @@ -0,0 +1,92 @@ +/************************************************************************ + ** + ** @file layoutdef.cpp + ** @author Roman Telezhynskyi + ** @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 + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "layoutdef.h" + +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +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); +} diff --git a/src/app/puzzle/layout/layoutdef.h b/src/app/puzzle/layout/layoutdef.h index 320d3cf0a..faa19b23c 100644 --- a/src/app/puzzle/layout/layoutdef.h +++ b/src/app/puzzle/layout/layoutdef.h @@ -48,9 +48,13 @@ using VPSheetWeakPtr = QWeakPointer; enum class GrainlineType : qint8 { Vertical, - Horizontal + Horizontal, + NotFixed }; +auto GrainlineTypeToStr(GrainlineType type) -> QString; +auto StrToGrainlineType(const QString &string) -> GrainlineType; + struct VPTransformationOrigon { QPointF origin{}; @@ -60,16 +64,4 @@ struct VPTransformationOrigon 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 diff --git a/src/app/puzzle/layout/vplayout.cpp b/src/app/puzzle/layout/vplayout.cpp index ab75992b8..97ffaedda 100644 --- a/src/app/puzzle/layout/vplayout.cpp +++ b/src/app/puzzle/layout/vplayout.cpp @@ -67,11 +67,6 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr layout->LayoutSettings().SetIgnoreTilesMargins(settings->GetLayoutTileIgnoreMargins()); 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().SetWarningPiecesOutOfBound(settings->GetLayoutWarningPiecesOutOfBound()); layout->LayoutSettings().SetFollowGrainline(settings->GetLayoutFollowGrainline()); diff --git a/src/app/puzzle/layout/vplayoutsettings.cpp b/src/app/puzzle/layout/vplayoutsettings.cpp index a112787ad..b67cc79aa 100644 --- a/src/app/puzzle/layout/vplayoutsettings.cpp +++ b/src/app/puzzle/layout/vplayoutsettings.cpp @@ -202,336 +202,6 @@ void VPLayoutSettings::SetShowTiles(bool 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(PaperSizeTemplate::Custom); - -// for (int i=0; i < max; i++) -// { -// PaperSizeTemplate tmpl = static_cast(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 *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(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) { @@ -652,15 +322,3 @@ void VPLayoutSettings::SetIgnoreTilesMargins(bool newIgnoreTilesMargins) { m_ignoreTilesMargins = newIgnoreTilesMargins; } - -//--------------------------------------------------------------------------------------------------------------------- -auto VPLayoutSettings::IgnoreMargins() const -> bool -{ - return m_ignoreMargins; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPLayoutSettings::SetIgnoreMargins(bool newIgnoreMargins) -{ - m_ignoreMargins = newIgnoreMargins; -} diff --git a/src/app/puzzle/layout/vplayoutsettings.h b/src/app/puzzle/layout/vplayoutsettings.h index aabfc9897..beb054378 100644 --- a/src/app/puzzle/layout/vplayoutsettings.h +++ b/src/app/puzzle/layout/vplayoutsettings.h @@ -35,26 +35,6 @@ #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 { Q_DECLARE_TR_FUNCTIONS(VPLayoutSettings) @@ -252,122 +232,7 @@ public: */ 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 *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 - - /** - * @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 * @return true if the placement grid has to be shown on the current sheet @@ -433,9 +298,6 @@ public: auto IgnoreTilesMargins() const -> bool; void SetIgnoreTilesMargins(bool newIgnoreTilesMargins); - auto IgnoreMargins() const -> bool; - void SetIgnoreMargins(bool newIgnoreMargins); - private: Unit m_unit{Unit::Cm}; @@ -450,11 +312,6 @@ private: */ QSizeF m_tilesSize{}; - /** - * @brief holds the orientation of the tiles - */ - PageOrientation m_tilesOrientation {PageOrientation::Portrait}; - // margins /** * @brief m_margins the margins of the tiles in Unit::Px @@ -465,19 +322,6 @@ private: 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 bool m_followGrainLine{false}; diff --git a/src/app/puzzle/layout/vppiece.cpp b/src/app/puzzle/layout/vppiece.cpp index a30a4bf94..f6f5b90ee 100644 --- a/src/app/puzzle/layout/vppiece.cpp +++ b/src/app/puzzle/layout/vppiece.cpp @@ -216,7 +216,7 @@ void VPPiece::RotateToGrainline(const VPTransformationOrigon &origin) QLineF canonical(grainlinePoints.first().x(), grainlinePoints.first().y(), grainlinePoints.first().x()+100, grainlinePoints.first().y()); - GrainlineType grainlineType = sheet->GrainlineType(); + GrainlineType grainlineType = sheet->GrainlineOrientation(); auto DegreesAtFront = [grainline, canonical, grainlineType]() { diff --git a/src/app/puzzle/layout/vpsheet.cpp b/src/app/puzzle/layout/vpsheet.cpp index a07911516..5bae67f3b 100644 --- a/src/app/puzzle/layout/vpsheet.cpp +++ b/src/app/puzzle/layout/vpsheet.cpp @@ -29,12 +29,18 @@ #include "vplayout.h" #include "vppiece.h" +#include "../vpapplication.h" //--------------------------------------------------------------------------------------------------------------------- VPSheet::VPSheet(const VPLayoutPtr &layout) : m_layout(layout) { SCASSERT(layout != nullptr) + + VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); + SetIgnoreMargins(settings->GetLayoutSheetIgnoreMargins()); + SetSheetMargins(settings->GetLayoutSheetMargins()); + SetSheetSize(QSizeF(settings->GetLayoutSheetPaperWidth(), settings->GetLayoutSheetPaperHeight())); } //--------------------------------------------------------------------------------------------------------------------- @@ -111,19 +117,31 @@ void VPSheet::SetVisible(bool visible) } //--------------------------------------------------------------------------------------------------------------------- -auto VPSheet::GrainlineType() const -> enum GrainlineType +GrainlineType VPSheet::GrainlineOrientation() const { - VPLayoutPtr layout = GetLayout(); - if (not layout.isNull()) + if (m_grainlineType == GrainlineType::NotFixed) { - QSizeF size = layout->LayoutSettings().GetSheetSize(); - if (size.height() < size.width()) + if (m_size.height() < m_size.width()) { 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; } //--------------------------------------------------------------------------------------------------------------------- @@ -244,48 +262,77 @@ void VPSheet::ValidatePiecesOutOfBound() const //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetSheetRect() const -> QRectF { - return GetSheetRect(GetLayout()); + return QRectF(QPoint(0, 0), m_size); } //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetMarginsRect() const -> QRectF { - return GetMarginsRect(GetLayout()); -} - -//--------------------------------------------------------------------------------------------------------------------- -auto VPSheet::GetSheetRect(const VPLayoutPtr &layout) -> QRectF -{ - if (layout.isNull()) + if (not m_ignoreMargins) { - return {}; - } - - QPoint topLeft = QPoint(0,0); - QSizeF size = layout->LayoutSettings().GetSheetSize(); - QRectF rect = QRectF(topLeft, size); - return rect; -} - -//--------------------------------------------------------------------------------------------------------------------- -auto VPSheet::GetMarginsRect(const VPLayoutPtr &layout) -> QRectF -{ - if (layout.isNull()) - { - return {}; - } - - QSizeF size = layout->LayoutSettings().GetSheetSize(); - - if (not layout->LayoutSettings().IgnoreMargins()) - { - QMarginsF margins = layout->LayoutSettings().GetSheetMargins(); - QRectF rect = QRectF(QPointF(margins.left(), margins.top()), - QPointF(size.width()-margins.right(), size.height()-margins.bottom())); + QRectF rect = QRectF(QPointF(m_margins.left(), m_margins.top()), + QPointF(m_size.width() - m_margins.right(), m_size.height() - m_margins.bottom())); return rect; } - return QRectF(0, 0, size.width(), size.height()); + return QRectF(0, 0, m_size.width(), m_size.height()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPSheet::RemoveUnusedLength() +{ + VPLayoutPtr layout = GetLayout(); + if (layout.isNull()) + { + return; + } + + QList pieces = GetPieces(); + if (pieces.isEmpty()) + { + return; + } + + 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(); } } + +//--------------------------------------------------------------------------------------------------------------------- +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; +} diff --git a/src/app/puzzle/layout/vpsheet.h b/src/app/puzzle/layout/vpsheet.h index febd396c7..ea8246e9d 100644 --- a/src/app/puzzle/layout/vpsheet.h +++ b/src/app/puzzle/layout/vpsheet.h @@ -1,4 +1,4 @@ -/************************************************************************ +/************************************************************************ ** ** @file vpsheet.h ** @author Ronan Le Tiec @@ -75,7 +75,9 @@ public: bool IsVisible() const; 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 &; void SetTransformationOrigin(const VPTransformationOrigon &newTransformationOrigin); @@ -92,8 +94,89 @@ public: auto GetSheetRect() const -> QRectF; auto GetMarginsRect() const -> QRectF; - static auto GetSheetRect(const VPLayoutPtr &layout) -> QRectF; - static auto GetMarginsRect(const VPLayoutPtr &layout) -> QRectF; + void RemoveUnusedLength(); + + /** + * @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: void CheckPiecePositionValidity(const VPPiecePtr &piece) const; @@ -112,6 +195,22 @@ private: 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; }; diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index d2a4b800d..33865dd6e 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -7,6 +7,7 @@ SOURCES += \ $$PWD/dialogs/configpages/puzzlepreferenceslayoutpage.cpp \ $$PWD/dialogs/dialogpuzzlepreferences.cpp \ $$PWD/dialogs/vpdialogabout.cpp \ + $$PWD/layout/layoutdef.cpp \ $$PWD/main.cpp \ $$PWD/undocommands/vpundoaddsheet.cpp \ $$PWD/undocommands/vpundocommand.cpp \ diff --git a/src/app/puzzle/scene/vpgraphicssheet.cpp b/src/app/puzzle/scene/vpgraphicssheet.cpp index 12810f888..3335369e2 100644 --- a/src/app/puzzle/scene/vpgraphicssheet.cpp +++ b/src/app/puzzle/scene/vpgraphicssheet.cpp @@ -105,13 +105,35 @@ void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *o //--------------------------------------------------------------------------------------------------------------------- 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 { - 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(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/share/resources/puzzleicon.qrc b/src/app/puzzle/share/resources/puzzleicon.qrc index 6c117d3fe..b99ed6215 100644 --- a/src/app/puzzle/share/resources/puzzleicon.qrc +++ b/src/app/puzzle/share/resources/puzzleicon.qrc @@ -16,5 +16,9 @@ puzzleicon/svg/icon_rotate_90_clockwise.svg puzzleicon/svg/icon_rotate_grainline_horizontal.svg puzzleicon/svg/icon_rotate_grainline_vertical.svg + puzzleicon/32X32/horizontal_grainline.png + puzzleicon/32X32/horizontal_grainline@2x.png + puzzleicon/32X32/vertical_grainline.png + puzzleicon/32X32/vertical_grainline@2x.png diff --git a/src/app/puzzle/share/resources/puzzleicon/32X32/horizontal_grainline.png b/src/app/puzzle/share/resources/puzzleicon/32X32/horizontal_grainline.png new file mode 100644 index 0000000000000000000000000000000000000000..09e0e5ddceccd5ebb55cccacac48f02c21de7331 GI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_@(*h|UUCN(wUjp{$l$72!fR^3n8tNQ(6IV@#)4Y{hfR+0Y)LoF}C literal 0 HcmV?d00001 diff --git a/src/app/puzzle/share/resources/puzzleicon/32X32/vertical_grainline.png b/src/app/puzzle/share/resources/puzzleicon/32X32/vertical_grainline.png new file mode 100644 index 0000000000000000000000000000000000000000..f332842f64384d035f4e3daf4578c6fdf39283de GIT binary patch literal 2719 zcmeHJ=Q|sY7EY)jBDE_<8`Rbszt$=m616o5Vzfr>y+umxP}EFXwbgEoRw+X5RoWz$luM=#}ytD5#S1U#d*2`0J!-&YtQU`Dagr~^d<`*{9?M; ztEX)}LeWLfb49l*H{0-ou#xZ_Zw!fE-O&{O7V#UB;_(=J3(>b_ z7hA__2q!CUvVaJs?-Cj7oF$T({^6^dzYg2OSM=HkC$GtkCUW{|MIrvE9SN=_J(#>z zcJv2vO!=XgIrF}G)3cDufEuNm3Hp#P#ouSotU9sn5mAkDn$sI7O%fI+W|UoE*Q+w* ztgS^n2Ei`n*@b;UD-OY!lm?+sB8_wU1?~nFHC||XQl1CmPpcV%A?}#&*0XI#eO+qE zao*C-6<|%}ynQ?-)`34N6sw&Q7FDOE^U_jwX3%|)_hsE;Ic(4QcK|zu&z%g#pLSdJ z!2NT1LG$Ajae>Kv|B83Py&41!WO7`ZHxQBV8a9GvVALz^$9&4)E_oE(NOp1Uosg+s_%w zv;|1(rbw#gT(rTaBv)e;P4Y<1)zw~>&t6DuAnGd&r);0uKnM>Y-mp!<8@4_*)WNzd zp7UNWp@*N_g5__K59WRQvp^I5QbCQnm3e{zwP>F!t&9g zO*{4^ATs_c8Jn6fT`U*u4x@Bq-<}y9fW;v7w!Wc9)YOA1b7o?3abiT5 zEeS}_Ai}ALCt|#?U1hVg-_G%b%YXMYm(6ss*zs}(eGs>LaE~suqWbmO)<(2#=C0 z>vH7IXB$!5Y7a*0_Z3RszPDY;2mrAv7^P+AKt8Cb4kwHcidhr}OtFqyr6ZwLE!6LAC9jw_FS(~w*|aE#oejUHO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+Av?$>i<*7}@_iOl-x}yArC65{TW6b*8 qd&1XyS4Mg!*5=n&yFVAAq8JaNRWxND$#Bxo0}OOcQS~~GasL5y_Q1UW literal 0 HcmV?d00001 diff --git a/src/app/puzzle/share/resources/puzzleicon/32X32/vertical_grainline@2x.png b/src/app/puzzle/share/resources/puzzleicon/32X32/vertical_grainline@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ccfd215a4de2d18d3276cbeb90f72388bfaf8ecd GIT binary patch literal 4356 zcmeH~*E<{x)5aH3g6K86=)GlakhOYWy+kK^FS~m0HA-|5y>}u?2p&DG=q)^0WhJ^L zOAw#;;5&W)f_JXDXRevEnfvIMr~_4bM);f%002BwQ&rS^?2!M60Ozq5bw(Zm0K{HF z1|~2)8-G?WA5RBoH+xoCpqD+XeSotA01&X&nD6Yj(?t^d;7i^2Bx9?K@g1s{sdo>9 zukLe1Y^Y|K%b)XNmLh@3+?>_n??d?H-H@#C5MQ@UPcMK9&pbzx=lw%whef z;eUIEPlZv4ov58GuPpSkLGx8Mdi$6NBkmUb+VcWFvUjMw9D5sArtKF(_g&fN-y+np zeIhUVj!Xmky$a~heCzHLcKfFD%}<$w)BT$m?EvQ|%pB8Ntv*MX5L4DaZ!3MKdWo1v zE!9GPXFiK(?c@aQ+6QCKK_8hek-N9=15fYAs{N<^ucU-eL+FKB&bQ}@fFUP$$H;2@ z$su-3Q0dy+(3R=q-Io`p=yi)L^0ZO@vd`_up$s%YbD>+;3}Yns*{fsY?d-H57%Pj4 z?DJ-iWOzwi%9Y=WOK#Eaiu;)2X_W?J(IKD`)y83LPCGJjI4P7{F%FR9-q6BHv0NXb z`BH558{LDD2{g%(nnVa#-CWp*!Oyvc+l`EAS6|46#9Baio{Lkx3U#E8Sb=ZTe2zX{ z#(g-al8xabh&$e&!aJOuHv43~X{!O8{-=4q|S)Zp!q z(ht!8<*82)nYwn5Ni5|x zUb-%(`z{jKSM)h$f#JIDf-QaJieG;{H`UUw|w-GCFQHb31h_ND%-@~{+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MW{^y<3X!fKgElzH@mW5ur_*-LwK7bvYrFF zo}CVO`O<#IWyC_TN2r6bYR$1&otN9fz56yeJg}jMv;+Rydw?gb0IX}zE$nKsA12pJ zqmsrweQ2!cG!SeY`IebQ;%CidygT>=jf4OC;!J^7_V;Ww3fI9gUjGK`!$Mo1V|zyH QGetFocusedSheet()->GetLayout()->LayoutSettings().GetSheetSize()); + QSizeF size = QSizeF(layout->GetFocusedSheet()->GetSheetSize()); const QRectF rect = QRectF(0, 0, size.width(), size.height()); SetImageRect(rect); diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 8e1290d16..45dddf4a0 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -139,6 +139,12 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : { 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) { @@ -393,6 +399,7 @@ void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts) } m_carrousel->Refresh(); + m_layout->CheckPiecesPositionValidity(); LayoutWasSaved(false); } else @@ -665,6 +672,67 @@ void VPMainWindow::InitPropertyTabCurrentSheet() connect(ui->toolButtonSheetLandscapeOrientation, &QToolButton::toggled, this, &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 ------------------------ ui->doubleSpinBoxSheetMarginLeft->setSuffix(suffix); ui->doubleSpinBoxSheetMarginRight->setSuffix(suffix); @@ -689,14 +757,14 @@ void VPMainWindow::InitPropertyTabCurrentSheet() ui->doubleSpinBoxSheetMarginTop->setDisabled(state != 0); ui->doubleSpinBoxSheetMarginBottom->setDisabled(state != 0); - m_layout->LayoutSettings().SetIgnoreMargins(state != 0); - LayoutWasSaved(false); - m_tileFactory->refreshTileInfos(); - m_graphicsView->RefreshLayout(); - VPSheetPtr sheet = m_layout->GetFocusedSheet(); if (not sheet.isNull()) { + sheet->SetIgnoreMargins(state != 0); + LayoutWasSaved(false); + m_tileFactory->refreshTileInfos(); + m_graphicsView->RefreshLayout(); + sheet->ValidatePiecesOutOfBound(); } } @@ -972,106 +1040,114 @@ void VPMainWindow::SetPropertyTabSheetData() { if (not m_layout.isNull()) { - ui->groupBoxSheetInfos->setDisabled(false); VPSheetPtr sheet = m_layout->GetFocusedSheet(); - SetLineEditValue(ui->lineEditSheetName, not sheet.isNull() ? sheet->GetName() : QString()); - - ui->groupBoxPaperFormat->setDisabled(false); - const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(UnitsToStr(m_layout->LayoutSettings().GetUnit())); - if (indexUnit != -1) + if (not sheet.isNull()) { - ui->comboBoxLayoutUnit->blockSignals(true); - ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit); - ui->comboBoxLayoutUnit->blockSignals(false); + ui->groupBoxSheetInfos->setDisabled(false); + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + SetLineEditValue(ui->lineEditSheetName, not sheet.isNull() ? sheet->GetName() : QString()); + + ui->groupBoxPaperFormat->setDisabled(false); + const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(UnitsToStr(m_layout->LayoutSettings().GetUnit())); + if (indexUnit != -1) + { + ui->comboBoxLayoutUnit->blockSignals(true); + ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit); + ui->comboBoxLayoutUnit->blockSignals(false); + } + else + { + ui->comboBoxLayoutUnit->setCurrentIndex(0); + } + + const QString suffix = " " + UnitsToStr(LayoutUnit(), true); + + ui->doubleSpinBoxSheetPaperWidth->setSuffix(suffix); + ui->doubleSpinBoxSheetPaperHeight->setSuffix(suffix); + + ui->doubleSpinBoxSheetMarginLeft->setSuffix(suffix); + ui->doubleSpinBoxSheetMarginRight->setSuffix(suffix); + ui->doubleSpinBoxSheetMarginTop->setSuffix(suffix); + ui->doubleSpinBoxSheetMarginBottom->setSuffix(suffix); + + // set Width / Length + QSizeF size = sheet->GetSheetSizeConverted(); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, size.width()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, size.height()); + + SheetPaperSizeChanged(); + FindSheetTemplate(); + + // set margins + ui->groupBoxSheetMargin->setDisabled(false); + QMarginsF margins = sheet->GetSheetMarginsConverted(); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, margins.left()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, margins.top()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, margins.right()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, margins.bottom()); + + CorrectSheetMaxMargins(); + + const bool ignoreMargins = sheet->IgnoreMargins(); + SetCheckBoxValue(ui->checkBoxLayoutIgnoreFileds, ignoreMargins); + + ui->doubleSpinBoxSheetMarginLeft->setDisabled(ignoreMargins); + ui->doubleSpinBoxSheetMarginRight->setDisabled(ignoreMargins); + ui->doubleSpinBoxSheetMarginTop->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 + ui->groupBoxSheetGrid->setDisabled(false); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridColWidth, + m_layout->LayoutSettings().GetGridColWidthConverted()); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridRowHeight, + m_layout->LayoutSettings().GetGridRowHeightConverted()); + + SetCheckBoxValue(ui->checkBoxSheetShowGrid, m_layout->LayoutSettings().GetShowGrid()); + + ui->groupBoxSheetExport->setDisabled(false); + + return; } - else - { - ui->comboBoxLayoutUnit->setCurrentIndex(0); - } - - const QString suffix = " " + UnitsToStr(LayoutUnit(), true); - - ui->doubleSpinBoxSheetPaperWidth->setSuffix(suffix); - ui->doubleSpinBoxSheetPaperHeight->setSuffix(suffix); - - ui->doubleSpinBoxSheetMarginLeft->setSuffix(suffix); - ui->doubleSpinBoxSheetMarginRight->setSuffix(suffix); - ui->doubleSpinBoxSheetMarginTop->setSuffix(suffix); - ui->doubleSpinBoxSheetMarginBottom->setSuffix(suffix); - - // set Width / Length - QSizeF size = m_layout->LayoutSettings().GetSheetSizeConverted(); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, size.width()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, size.height()); - - SheetPaperSizeChanged(); - FindSheetTemplate(); - - // set margins - ui->groupBoxSheetMargin->setDisabled(false); - QMarginsF margins = m_layout->LayoutSettings().GetSheetMarginsConverted(); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, margins.left()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, margins.top()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, margins.right()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, margins.bottom()); - - CorrectSheetMaxMargins(); - - const bool ignoreMargins = m_layout->LayoutSettings().IgnoreMargins(); - SetCheckBoxValue(ui->checkBoxLayoutIgnoreFileds, ignoreMargins); - - ui->doubleSpinBoxSheetMarginLeft->setDisabled(ignoreMargins); - ui->doubleSpinBoxSheetMarginRight->setDisabled(ignoreMargins); - ui->doubleSpinBoxSheetMarginTop->setDisabled(ignoreMargins); - ui->doubleSpinBoxSheetMarginBottom->setDisabled(ignoreMargins); - - // set placement grid - ui->groupBoxSheetGrid->setDisabled(false); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridColWidth, - m_layout->LayoutSettings().GetGridColWidthConverted()); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridRowHeight, - m_layout->LayoutSettings().GetGridRowHeightConverted()); - - SetCheckBoxValue(ui->checkBoxSheetShowGrid, m_layout->LayoutSettings().GetShowGrid()); - - ui->groupBoxSheetExport->setDisabled(false); } - else - { - ui->groupBoxSheetInfos->setDisabled(true); - SetLineEditValue(ui->lineEditSheetName, QString()); - ui->groupBoxPaperFormat->setDisabled(true); + ui->groupBoxSheetInfos->setDisabled(true); + SetLineEditValue(ui->lineEditSheetName, QString()); - ui->comboBoxLayoutUnit->blockSignals(true); - ui->comboBoxLayoutUnit->setCurrentIndex(-1); - ui->comboBoxLayoutUnit->blockSignals(false); + ui->groupBoxPaperFormat->setDisabled(true); - ui->comboBoxSheetTemplates->blockSignals(true); - ui->comboBoxSheetTemplates->setCurrentIndex(-1); - ui->comboBoxSheetTemplates->blockSignals(false); + ui->comboBoxLayoutUnit->blockSignals(true); + ui->comboBoxLayoutUnit->setCurrentIndex(-1); + ui->comboBoxLayoutUnit->blockSignals(false); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, 0); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, 0); + ui->comboBoxSheetTemplates->blockSignals(true); + ui->comboBoxSheetTemplates->setCurrentIndex(-1); + ui->comboBoxSheetTemplates->blockSignals(false); - ui->groupBoxSheetMargin->setDisabled(true); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, 0); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, 0); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, 0); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, 0); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, 0); + ui->groupBoxSheetMargin->setDisabled(true); - SetCheckBoxValue(ui->checkBoxLayoutIgnoreFileds, false); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, 0); - ui->groupBoxSheetGrid->setDisabled(true); + SetCheckBoxValue(ui->checkBoxLayoutIgnoreFileds, false); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridColWidth, 0); - SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridRowHeight, 0); + ui->groupBoxSheetGrid->setDisabled(true); - SetCheckBoxValue(ui->checkBoxSheetShowGrid, false); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridColWidth, 0); + SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetGridRowHeight, 0); - ui->groupBoxSheetExport->setDisabled(true); - } + SetCheckBoxValue(ui->checkBoxSheetShowGrid, false); + + ui->groupBoxSheetExport->setDisabled(true); } //--------------------------------------------------------------------------------------------------------------------- @@ -1874,6 +1950,11 @@ void VPMainWindow::CorrectMaxMargins() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::RotatePiecesToGrainline() { + if (not m_layout->LayoutSettings().GetFollowGrainline()) + { + return; + } + QList sheets = m_layout->GetSheets(); for(const auto& sheet : sheets) { @@ -2163,9 +2244,13 @@ void VPMainWindow::on_SheetSizeChanged() { if (not m_layout.isNull()) { - m_layout->LayoutSettings().SetSheetSizeConverted( - ui->doubleSpinBoxSheetPaperWidth->value(), - ui->doubleSpinBoxSheetPaperHeight->value()); + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + sheet->SetSheetSizeConverted(ui->doubleSpinBoxSheetPaperWidth->value(), + ui->doubleSpinBoxSheetPaperHeight->value()); + } + FindSheetTemplate(); SheetPaperSizeChanged(); CorrectMaxMargins(); @@ -2187,7 +2272,11 @@ void VPMainWindow::on_SheetOrientationChanged(bool checked) SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, height); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, width); - m_layout->LayoutSettings().SetSheetSizeConverted(height, width); + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + sheet->SetSheetSizeConverted(height, width); + } SheetPaperSizeChanged(); 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() { if (not m_layout.isNull()) { - m_layout->LayoutSettings().SetSheetMarginsConverted( - ui->doubleSpinBoxSheetMarginLeft->value(), - ui->doubleSpinBoxSheetMarginTop->value(), - ui->doubleSpinBoxSheetMarginRight->value(), - ui->doubleSpinBoxSheetMarginBottom->value()); - - LayoutWasSaved(false); - VPSheetPtr sheet = m_layout->GetFocusedSheet(); if (not sheet.isNull()) { + sheet->SetSheetMarginsConverted(ui->doubleSpinBoxSheetMarginLeft->value(), + ui->doubleSpinBoxSheetMarginTop->value(), + ui->doubleSpinBoxSheetMarginRight->value(), + ui->doubleSpinBoxSheetMarginBottom->value()); + + LayoutWasSaved(false); + sheet->ValidatePiecesOutOfBound(); } diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index d1f29de1e..7340c8557 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -174,13 +174,6 @@ private slots: */ 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 * in the sheet property tab. diff --git a/src/app/puzzle/vpmainwindow.ui b/src/app/puzzle/vpmainwindow.ui index 9255cdd16..790ed2f94 100644 --- a/src/app/puzzle/vpmainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -189,7 +189,7 @@ QTabWidget::Rounded - 0 + 1 @@ -249,7 +249,7 @@ 0 0 - 358 + 392 700 @@ -686,8 +686,8 @@ 0 0 - 344 - 748 + 378 + 829 @@ -787,6 +787,51 @@ + + + + + 94 + 0 + + + + 2 + + + 99999.000000000000000 + + + + + + + + 94 + 0 + + + + 2 + + + 99999.990000000005239 + + + + + + + + 0 + 0 + + + + Length: + + + @@ -850,50 +895,82 @@ - - - - - 0 - 0 - - + + + + + + - Length: + Grainline orientation: + + + true - - - - - 94 - 0 - - - - 2 - - - 99999.000000000000000 - - - - - - - - 94 - 0 - - - - 2 - - - 99999.990000000005239 - - + + + + + + Force the grainline orientation to always be horizontal + + + ... + + + + :/puzzleicon/32X32/horizontal_grainline.png:/puzzleicon/32X32/horizontal_grainline.png + + + + 24 + 24 + + + + true + + + + + + + Force the grainline orientation to always be vertical + + + ... + + + + :/puzzleicon/32X32/vertical_grainline.png:/puzzleicon/32X32/vertical_grainline.png + + + + 24 + 24 + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + @@ -1133,7 +1210,7 @@ 0 0 - 358 + 392 700 @@ -1505,7 +1582,7 @@ 0 0 - 358 + 392 700 diff --git a/src/app/puzzle/vptilefactory.cpp b/src/app/puzzle/vptilefactory.cpp index 452f13592..c3323b3f7 100644 --- a/src/app/puzzle/vptilefactory.cpp +++ b/src/app/puzzle/vptilefactory.cpp @@ -49,7 +49,12 @@ void VPTileFactory::refreshTileInfos() 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_nbRow = qCeil(sheetSize.height()/m_drawingAreaHeight); } diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 75f50fd7f..55a2c2b4d 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -241,10 +241,8 @@ void VPLayoutFileReader::ReadProperties(const VPLayoutPtr &layout) ML::TagUnit, // 0 ML::TagTitle, // 1 ML::TagDescription, // 2 - ML::TagSize, // 3 - ML::TagMargin, // 4 - ML::TagControl, // 5 - ML::TagTiles // 6 + ML::TagControl, // 3 + ML::TagTiles // 4 }; while (readNextStartElement()) @@ -265,17 +263,11 @@ void VPLayoutFileReader::ReadProperties(const VPLayoutPtr &layout) qDebug("read description"); layout->LayoutSettings().SetDescription(readElementText()); break; - case 3: // size - layout->LayoutSettings().SetSheetSize(ReadSize()); - break; - case 4: // margin - layout->LayoutSettings().SetSheetMargins(ReadMargins()); - break; - case 5: // control + case 3: // control qDebug("read control"); ReadControl(layout); break; - case 6: // tiles + case 4: // tiles qDebug("read tiles"); ReadTiles(layout); break; @@ -370,14 +362,19 @@ void VPLayoutFileReader::ReadSheet(const VPLayoutPtr &layout) { AssertRootTag(ML::TagSheet); + VPSheetPtr sheet(new VPSheet(layout)); + + QXmlStreamAttributes attribs = attributes(); + sheet->SetGrainlineType(StrToGrainlineType(ReadAttributeEmptyString(attribs, ML::AttrGrainlineType))); + const QStringList tags { ML::TagName, // 0 - ML::TagPieces // 1 + ML::TagSize, // 1 + ML::TagMargin, // 2 + ML::TagPieces // 3 }; - VPSheetPtr sheet(new VPSheet(layout)); - while (readNextStartElement()) { switch (tags.indexOf(name().toString())) @@ -385,7 +382,13 @@ void VPLayoutFileReader::ReadSheet(const VPLayoutPtr &layout) case 0: // name sheet->SetName(readElementText()); break; - case 1: // pieces + case 1: // size + sheet->SetSheetSize(ReadSize()); + break; + case 2: // margin + sheet->SetSheetMargins(ReadMargins()); + break; + case 3: // pieces ReadPieces(layout, sheet); break; default: diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index 2588e7336..2d0666b04 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -154,22 +154,20 @@ void VPLayoutFileWriter::WriteLayout(const VPLayoutPtr &layout) { writeStartElement(ML::TagLayout); SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr); - WriteProperties(layout); + WriteLayoutProperties(layout); WritePieceList(layout->GetUnplacedPieces(), ML::TagUnplacedPieces); WriteSheets(layout); writeEndElement(); //layout } //--------------------------------------------------------------------------------------------------------------------- -void VPLayoutFileWriter::WriteProperties(const VPLayoutPtr &layout) +void VPLayoutFileWriter::WriteLayoutProperties(const VPLayoutPtr &layout) { writeStartElement(ML::TagProperties); writeTextElement(ML::TagUnit, UnitsToStr(layout->LayoutSettings().GetUnit())); writeTextElement(ML::TagTitle, layout->LayoutSettings().GetTitle()); writeTextElement(ML::TagDescription, layout->LayoutSettings().GetDescription()); - WriteSize(layout->LayoutSettings().GetSheetSize()); - WriteMargins(layout->LayoutSettings().GetSheetMargins()); writeStartElement(ML::TagControl); SetAttribute(ML::AttrWarningSuperposition, layout->LayoutSettings().GetWarningSuperpositionOfPieces()); @@ -205,8 +203,13 @@ void VPLayoutFileWriter::WriteSheets(const VPLayoutPtr &layout) void VPLayoutFileWriter::WriteSheet(const VPSheetPtr &sheet) { writeStartElement(ML::TagSheet); + SetAttributeOrRemoveIf(ML::AttrGrainlineType, GrainlineTypeToStr(sheet->GetGrainlineType()), + [](const QString &type) + {return type == GrainlineTypeToStr(GrainlineType::NotFixed);}); writeTextElement(ML::TagName, sheet->GetName()); + WriteSize(sheet->GetSheetSize()); + WriteMargins(sheet->GetSheetMargins()); WritePieceList(sheet->GetPieces(), ML::TagPieces); writeEndElement(); // sheet diff --git a/src/app/puzzle/xml/vplayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h index 415b0da7e..6a327f28a 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -56,7 +56,7 @@ public: private: void WriteLayout(const VPLayoutPtr &layout); - void WriteProperties(const VPLayoutPtr &layout); + void WriteLayoutProperties(const VPLayoutPtr &layout); void WriteSheets(const VPLayoutPtr &layout); void WriteSheet(const VPSheetPtr &sheet); void WriteTiles(const VPLayoutPtr &layout); diff --git a/src/app/puzzle/xml/vplayoutliterals.cpp b/src/app/puzzle/xml/vplayoutliterals.cpp index b3445238c..bb182e4b5 100644 --- a/src/app/puzzle/xml/vplayoutliterals.cpp +++ b/src/app/puzzle/xml/vplayoutliterals.cpp @@ -97,6 +97,7 @@ const QString AttrItalic = QStringLiteral("italic"); const QString AttrAlignment = QStringLiteral("alignment"); const QString AttrGradationLabel = QStringLiteral("gradationLabel"); const QString AttrCopyNumber = QStringLiteral("copyNumber"); +const QString AttrGrainlineType = QStringLiteral("grainlineType"); const QString atFrontStr = QStringLiteral("atFront"); const QString atRearStr = QStringLiteral("atRear"); diff --git a/src/app/puzzle/xml/vplayoutliterals.h b/src/app/puzzle/xml/vplayoutliterals.h index e0eb540b6..f5cf4f6e2 100644 --- a/src/app/puzzle/xml/vplayoutliterals.h +++ b/src/app/puzzle/xml/vplayoutliterals.h @@ -102,6 +102,7 @@ extern const QString AttrItalic; extern const QString AttrAlignment; extern const QString AttrGradationLabel; extern const QString AttrCopyNumber; +extern const QString AttrGrainlineType; extern const QString atFrontStr; extern const QString atRearStr; diff --git a/src/libs/ifc/schema/layout/v0.1.0.xsd b/src/libs/ifc/schema/layout/v0.1.0.xsd index a9515c581..f907fc57a 100644 --- a/src/libs/ifc/schema/layout/v0.1.0.xsd +++ b/src/libs/ifc/schema/layout/v0.1.0.xsd @@ -8,20 +8,6 @@ - - - - - - - - - - - - - - @@ -199,6 +185,20 @@ + + + + + + + + + + + + + + @@ -336,6 +336,7 @@ + @@ -460,5 +461,12 @@ + + + + + + +