From a121845407264c14fb322e79f227d4c6fa2a884a Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 14 Jan 2015 16:14:51 +0200 Subject: [PATCH] Dialog layout settings. --HG-- branch : feature --- src/app/core/vapplication.cpp | 48 +-- src/app/dialogs/app/dialoglayoutsettings.cpp | 376 ++++++++++++++++++ src/app/dialogs/app/dialoglayoutsettings.h | 90 +++++ src/app/dialogs/app/dialoglayoutsettings.ui | 343 ++++++++++++++++ src/app/dialogs/dialogs.pri | 9 +- src/app/share/resources/icon.qrc | 3 + .../share/resources/icon/16x16/landscape.png | Bin 0 -> 398 bytes .../share/resources/icon/16x16/portrait.png | Bin 0 -> 536 bytes .../share/resources/icon/16x16/template.png | Bin 0 -> 497 bytes src/app/tablewindow.cpp | 9 + src/app/tablewindow.h | 1 + src/app/tablewindow.ui | 6 + src/app/xml/vabstractmeasurements.cpp | 22 + src/libs/ifc/ifcdef.h | 2 +- src/libs/ifc/xml/vdomdocument.cpp | 16 +- src/libs/ifc/xml/vdomdocument.h | 1 + src/libs/vlayout/vlayoutpaper.cpp | 2 +- 17 files changed, 896 insertions(+), 32 deletions(-) create mode 100644 src/app/dialogs/app/dialoglayoutsettings.cpp create mode 100644 src/app/dialogs/app/dialoglayoutsettings.h create mode 100644 src/app/dialogs/app/dialoglayoutsettings.ui create mode 100644 src/app/share/resources/icon/16x16/landscape.png create mode 100644 src/app/share/resources/icon/16x16/portrait.png create mode 100644 src/app/share/resources/icon/16x16/template.png diff --git a/src/app/core/vapplication.cpp b/src/app/core/vapplication.cpp index 1167308ee..57a6feb96 100644 --- a/src/app/core/vapplication.cpp +++ b/src/app/core/vapplication.cpp @@ -292,22 +292,20 @@ bool VApplication::notify(QObject *receiver, QEvent *event) //--------------------------------------------------------------------------------------------------------------------- double VApplication::toPixel(double val, const Unit &unit) const { - double result = 0; switch (unit) { - case Unit::Mm: - result = (val / 25.4) * PrintDPI; - break; - case Unit::Cm: - result = ((val * 10.0) / 25.4) * PrintDPI; - break; - case Unit::Inch: - result = val * PrintDPI; - break; - default: - break; + case Unit::Mm: + return (val / 25.4) * PrintDPI; + case Unit::Cm: + return ((val * 10.0) / 25.4) * PrintDPI; + case Unit::Inch: + return val * PrintDPI; + case Unit::Px: + return val; + default: + break; } - return result; + return 0; } //--------------------------------------------------------------------------------------------------------------------- @@ -319,22 +317,20 @@ double VApplication::toPixel(double val) const //--------------------------------------------------------------------------------------------------------------------- double VApplication::fromPixel(double pix, const Unit &unit) const { - double result = 0; switch (unit) { - case Unit::Mm: - result = (pix / PrintDPI) * 25.4; - break; - case Unit::Cm: - result = ((pix / PrintDPI) * 25.4) / 10.0; - break; - case Unit::Inch: - result = pix / PrintDPI; - break; - default: - break; + case Unit::Mm: + return (pix / PrintDPI) * 25.4; + case Unit::Cm: + return ((pix / PrintDPI) * 25.4) / 10.0; + case Unit::Inch: + return pix / PrintDPI; + case Unit::Px: + return pix; + default: + break; } - return result; + return 0; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/app/dialoglayoutsettings.cpp b/src/app/dialogs/app/dialoglayoutsettings.cpp new file mode 100644 index 000000000..a233f6d22 --- /dev/null +++ b/src/app/dialogs/app/dialoglayoutsettings.cpp @@ -0,0 +1,376 @@ +/************************************************************************ + ** + ** @file dialoglayoutsettings.cpp + ** @author Roman Telezhynskyi + ** @date 13 1, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 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 "dialoglayoutsettings.h" +#include "ui_dialoglayoutsettings.h" +#include "../../core/vapplication.h" +#include "../../libs/ifc/xml/vdomdocument.h" +#include "../../core/vsettings.h" +#include "../../xml/vabstractmeasurements.h" + +#include + +enum class PaperSizeTemplate : char { A0, A1, A2, A3, A4 }; + +//--------------------------------------------------------------------------------------------------------------------- +DialogLayoutSettings::DialogLayoutSettings(QWidget *parent) + : QDialog(parent), ui(new Ui::DialogLayoutSettings), oldPaperUnit(Unit::Mm), oldLayoutUnit(Unit::Mm) +{ + ui->setupUi(this); + InitPaperUnits(); + InitLayoutUnits(); + InitTemplates(); + + connect(ui->comboBoxTemplates, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLayoutSettings::TemplateSelected); + connect(ui->comboBoxPaperSizeUnit, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLayoutSettings::ConvertPaperSize); + connect(ui->doubleSpinBoxPaperWidth, static_cast(&QDoubleSpinBox::valueChanged), + this, &DialogLayoutSettings::PaperSizeChanged); + connect(ui->doubleSpinBoxPaperHeight, static_cast(&QDoubleSpinBox::valueChanged), + this, &DialogLayoutSettings::PaperSizeChanged); + connect(ui->toolButtonPortrate, &QToolButton::toggled, this, &DialogLayoutSettings::Swap); + connect(ui->toolButtonLandscape, &QToolButton::toggled, this, &DialogLayoutSettings::Swap); + connect(ui->comboBoxLayoutUnit, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLayoutSettings::ConvertLayoutSize); + connect(ui->doubleSpinBoxLayoutWidth, static_cast(&QDoubleSpinBox::valueChanged), + this, &DialogLayoutSettings::LayoutWidthChanged); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogLayoutSettings::~DialogLayoutSettings() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +int DialogLayoutSettings::GetPaperHeight() const +{ + return qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxPaperHeight->value(), oldPaperUnit, Unit::Px)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::SetPaperHeight(int value) +{ + ui->doubleSpinBoxPaperHeight->setValue(VAbstractMeasurements::UnitConvertor(value, Unit::Px, PaperUnit())); +} + +//--------------------------------------------------------------------------------------------------------------------- +int DialogLayoutSettings::GetPaperWidth() const +{ + return qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxPaperWidth->value(), oldPaperUnit, Unit::Px)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::SetPaperWidth(int value) +{ + ui->doubleSpinBoxPaperWidth->setValue(VAbstractMeasurements::UnitConvertor(value, Unit::Px, PaperUnit())); +} + +//--------------------------------------------------------------------------------------------------------------------- +unsigned int DialogLayoutSettings::GetShift() const +{ + return qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxShift->value(), oldLayoutUnit, Unit::Px)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::SetShift(unsigned int value) +{ + ui->doubleSpinBoxShift->setValue(VAbstractMeasurements::UnitConvertor(value, Unit::Px, LayoutUnit())); +} + +//--------------------------------------------------------------------------------------------------------------------- +unsigned int DialogLayoutSettings::GetLayoutWidth() const +{ + return qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxLayoutWidth->value(), oldLayoutUnit, Unit::Px)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::SetLayoutWidth(unsigned int value) +{ + ui->doubleSpinBoxLayoutWidth->setValue(VAbstractMeasurements::UnitConvertor(value, Unit::Px, LayoutUnit())); +} + +//--------------------------------------------------------------------------------------------------------------------- +Cases DialogLayoutSettings::GetGroup() const +{ + if (ui->radioButtonThreeGroups->isChecked()) + { + return Cases::CaseThreeGroup; + } + else if (ui->radioButtonTwoGroups->isChecked()) + { + return Cases::CaseTwoGroup; + } + else + { + return Cases::CaseDesc; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::SetGroup(const Cases &value) +{ + switch (value) + { + case Cases::CaseThreeGroup: + ui->radioButtonThreeGroups->setChecked(true); + break; + case Cases::CaseTwoGroup: + ui->radioButtonTwoGroups->setChecked(true); + break; + case Cases::CaseDesc: + ui->radioButtonDescendingArea->setChecked(true); + break; + default: + ui->radioButtonDescendingArea->setChecked(true); + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::TemplateSelected() +{ + const QSizeF size = Template(); + ui->doubleSpinBoxPaperWidth->setValue(size.width()); + ui->doubleSpinBoxPaperHeight->setValue(size.height()); + oldPaperUnit = PaperUnit(); + CorrectDecimals(); + PaperSizeChanged(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::ConvertPaperSize() +{ + const Unit paperUnit = PaperUnit(); + const qreal width = ui->doubleSpinBoxPaperWidth->value(); + const qreal height = ui->doubleSpinBoxPaperHeight->value(); + ui->doubleSpinBoxPaperWidth->setValue(VAbstractMeasurements::UnitConvertor(width, oldPaperUnit, paperUnit)); + ui->doubleSpinBoxPaperHeight->setValue(VAbstractMeasurements::UnitConvertor(height, oldPaperUnit, paperUnit)); + oldPaperUnit = paperUnit; + CorrectDecimals(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::ConvertLayoutSize() +{ + const Unit unit = LayoutUnit(); + const qreal layoutWidth = ui->doubleSpinBoxLayoutWidth->value(); + const qreal shift = ui->doubleSpinBoxShift->value(); + ui->doubleSpinBoxLayoutWidth->setValue(VAbstractMeasurements::UnitConvertor(layoutWidth, oldLayoutUnit, unit)); + ui->doubleSpinBoxShift->setValue(VAbstractMeasurements::UnitConvertor(shift, oldLayoutUnit, unit)); + oldLayoutUnit = unit; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::PaperSizeChanged() +{ + QDoubleSpinBox *box = qobject_cast(sender()); + if (box != nullptr) + { + if (box->value() <= 0) + { + box->blockSignals(true); + box->setValue(1); + box->blockSignals(false); + } + } + + if (ui->doubleSpinBoxPaperHeight->value() > ui->doubleSpinBoxPaperWidth->value()) + { + ui->toolButtonPortrate->blockSignals(true); + ui->toolButtonPortrate->setChecked(true); + ui->toolButtonPortrate->blockSignals(false); + } + else + { + ui->toolButtonLandscape->blockSignals(true); + ui->toolButtonLandscape->setChecked(true); + ui->toolButtonLandscape->blockSignals(false); + } + + Label(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::LayoutWidthChanged() +{ + QDoubleSpinBox *box = qobject_cast(sender()); + if (box != nullptr) + { + if (box->value() <= 0) + { + box->blockSignals(true); + box->setValue(1); + box->blockSignals(false); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::Swap(bool checked) +{ + if (checked) + { + const qreal width = ui->doubleSpinBoxPaperWidth->value(); + const qreal height = ui->doubleSpinBoxPaperHeight->value(); + + ui->doubleSpinBoxPaperWidth->blockSignals(true); + ui->doubleSpinBoxPaperWidth->setValue(height); + ui->doubleSpinBoxPaperWidth->blockSignals(false); + + ui->doubleSpinBoxPaperHeight->blockSignals(true); + ui->doubleSpinBoxPaperHeight->setValue(width); + ui->doubleSpinBoxPaperHeight->blockSignals(false); + + Label(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::InitPaperUnits() +{ + ui->comboBoxPaperSizeUnit->addItem(tr("Millimiters"), QVariant(VDomDocument::UnitsToStr(Unit::Mm))); + ui->comboBoxPaperSizeUnit->addItem(tr("Centimeters"), QVariant(VDomDocument::UnitsToStr(Unit::Cm))); + ui->comboBoxPaperSizeUnit->addItem(tr("Inches"), QVariant(VDomDocument::UnitsToStr(Unit::Inch))); + ui->comboBoxPaperSizeUnit->addItem(tr("Pixels"), QVariant(VDomDocument::UnitsToStr(Unit::Px))); + + // set default unit + oldPaperUnit = VDomDocument::StrToUnits(qApp->getSettings()->GetUnit()); + const qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData(qApp->getSettings()->GetUnit()); + if (indexUnit != -1) + { + ui->comboBoxPaperSizeUnit->setCurrentIndex(indexUnit); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::InitLayoutUnits() +{ + ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(VDomDocument::UnitsToStr(Unit::Cm))); + ui->comboBoxLayoutUnit->addItem(tr("Millimiters"), QVariant(VDomDocument::UnitsToStr(Unit::Mm))); + ui->comboBoxLayoutUnit->addItem(tr("Inches"), QVariant(VDomDocument::UnitsToStr(Unit::Inch))); + + // set default unit + oldLayoutUnit = VDomDocument::StrToUnits(qApp->getSettings()->GetUnit()); + const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(qApp->getSettings()->GetUnit()); + if (indexUnit != -1) + { + ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::InitTemplates() +{ + const QIcon ico("://icon/16x16/template.png"); + const QString pdi = QString("(%1ppi)").arg(VApplication::PrintDPI); + + ui->comboBoxTemplates->addItem(ico, "A0 "+pdi, QVariant(static_cast(PaperSizeTemplate::A0))); + ui->comboBoxTemplates->addItem(ico, "A1 "+pdi, QVariant(static_cast(PaperSizeTemplate::A1))); + ui->comboBoxTemplates->addItem(ico, "A2 "+pdi, QVariant(static_cast(PaperSizeTemplate::A2))); + ui->comboBoxTemplates->addItem(ico, "A3 "+pdi, QVariant(static_cast(PaperSizeTemplate::A3))); + ui->comboBoxTemplates->addItem(ico, "A4 "+pdi, QVariant(static_cast(PaperSizeTemplate::A4))); + + TemplateSelected(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QSizeF DialogLayoutSettings::Template() +{ + const PaperSizeTemplate temp = static_cast(ui->comboBoxTemplates->currentData().toInt()); + const Unit paperUnit = PaperUnit(); + + qreal width = 0; + qreal height = 0; + + switch(temp) + { + case PaperSizeTemplate::A0: + width = VAbstractMeasurements::UnitConvertor(841, Unit::Mm, paperUnit); + height = VAbstractMeasurements::UnitConvertor(1189, Unit::Mm, paperUnit); + return QSizeF(width, height); + case PaperSizeTemplate::A1: + width = VAbstractMeasurements::UnitConvertor(594, Unit::Mm, paperUnit); + height = VAbstractMeasurements::UnitConvertor(841, Unit::Mm, paperUnit); + return QSizeF(width, height); + case PaperSizeTemplate::A2: + width = VAbstractMeasurements::UnitConvertor(420, Unit::Mm, paperUnit); + height = VAbstractMeasurements::UnitConvertor(594, Unit::Mm, paperUnit); + return QSizeF(width, height); + case PaperSizeTemplate::A3: + width = VAbstractMeasurements::UnitConvertor(297, Unit::Mm, paperUnit); + height = VAbstractMeasurements::UnitConvertor(420, Unit::Mm, paperUnit); + return QSizeF(width, height); + case PaperSizeTemplate::A4: + width = VAbstractMeasurements::UnitConvertor(210, Unit::Mm, paperUnit); + height = VAbstractMeasurements::UnitConvertor(297, Unit::Mm, paperUnit); + return QSizeF(width, height); + default: + break; + } + return QSizeF(); +} + +//--------------------------------------------------------------------------------------------------------------------- +Unit DialogLayoutSettings::PaperUnit() const +{ + return VDomDocument::StrToUnits(ui->comboBoxPaperSizeUnit->currentData().toString()); +} + +//--------------------------------------------------------------------------------------------------------------------- +Unit DialogLayoutSettings::LayoutUnit() const +{ + return VDomDocument::StrToUnits(ui->comboBoxLayoutUnit->currentData().toString()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::CorrectDecimals() +{ + if (oldPaperUnit == Unit::Px) + { + ui->doubleSpinBoxPaperWidth->setDecimals(0); + ui->doubleSpinBoxPaperHeight->setDecimals(0); + } + else + { + ui->doubleSpinBoxPaperWidth->setDecimals(2); + ui->doubleSpinBoxPaperHeight->setDecimals(2); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::Label() +{ + const int width = qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxPaperWidth->value(), PaperUnit(), + Unit::Px)); + const int height = qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxPaperHeight->value(), + PaperUnit(), Unit::Px)); + QString text = QString("%1 x %2 px, \n%3 ppi").arg(width).arg(height).arg(VApplication::PrintDPI); + ui->labelSizeDescription->setText(text); +} diff --git a/src/app/dialogs/app/dialoglayoutsettings.h b/src/app/dialogs/app/dialoglayoutsettings.h new file mode 100644 index 000000000..abed1ac3d --- /dev/null +++ b/src/app/dialogs/app/dialoglayoutsettings.h @@ -0,0 +1,90 @@ +/************************************************************************ + ** + ** @file dialoglayoutsettings.h + ** @author Roman Telezhynskyi + ** @date 13 1, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 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 . + ** + *************************************************************************/ + +#ifndef DIALOGLAYOUTSETTINGS_H +#define DIALOGLAYOUTSETTINGS_H + +#include + +#include "../../libs/vlayout/vbank.h" +#include "../../libs/ifc/ifcdef.h" + +namespace Ui +{ + class DialogLayoutSettings; +} + +class DialogLayoutSettings : public QDialog +{ + Q_OBJECT +public: + explicit DialogLayoutSettings(QWidget *parent = 0); + ~DialogLayoutSettings(); + + int GetPaperHeight() const; + void SetPaperHeight(int value); + + int GetPaperWidth() const; + void SetPaperWidth(int value); + + unsigned int GetShift() const; + void SetShift(unsigned int value); + + unsigned int GetLayoutWidth() const; + void SetLayoutWidth(unsigned int value); + + Cases GetGroup() const; + void SetGroup(const Cases &value); + +public slots: + void TemplateSelected(); + void ConvertPaperSize(); + void ConvertLayoutSize(); + void PaperSizeChanged(); + void LayoutWidthChanged(); + void Swap(bool checked); + +private: + Q_DISABLE_COPY(DialogLayoutSettings) + Ui::DialogLayoutSettings *ui; + Unit oldPaperUnit; + Unit oldLayoutUnit; + + void InitPaperUnits(); + void InitLayoutUnits(); + void InitTemplates(); + QSizeF Template(); + + Unit PaperUnit() const; + Unit LayoutUnit() const; + + void CorrectDecimals(); + void Label(); +}; + +#endif // DIALOGLAYOUTSETTINGS_H diff --git a/src/app/dialogs/app/dialoglayoutsettings.ui b/src/app/dialogs/app/dialoglayoutsettings.ui new file mode 100644 index 000000000..fdc4d829e --- /dev/null +++ b/src/app/dialogs/app/dialoglayoutsettings.ui @@ -0,0 +1,343 @@ + + + DialogLayoutSettings + + + + 0 + 0 + 659 + 273 + + + + Creation a layout + + + + + + + + Paper size + + + + + + 6 + + + + + + 0 + 0 + + + + Templates: + + + + + + + + + + + + + + + 0 + 0 + + + + + 124 + 0 + + + + + + + + + 0 + 0 + + + + Width: + + + + + + + + 0 + 0 + + + + Height: + + + + + + + + 94 + 0 + + + + 2 + + + 99999.000000000000000 + + + + + + + + 94 + 0 + + + + 2 + + + 99999.990000000005239 + + + + + + + TextLabel + + + + + + + + + ... + + + + :/icon/16x16/portrait.png:/icon/16x16/portrait.png + + + true + + + true + + + true + + + buttonGroup + + + + + + + ... + + + + :/icon/16x16/landscape.png:/icon/16x16/landscape.png + + + true + + + false + + + true + + + buttonGroup + + + + + + + + + + + + + + Creation options + + + + + + + + 0.000000000000000 + + + 99999.990000000005239 + + + 1.000000000000000 + + + + + + + Layout width: + + + + + + + Shift length: + + + + + + + 99999.990000000005239 + + + 10.000000000000000 + + + + + + + + + + + + Principle of choosing the next workpiece + + + + + + + + Three groups: big, middle, small + + + buttonGroupPrinciple + + + + + + + Two groups: big, small + + + false + + + buttonGroupPrinciple + + + + + + + Descending area + + + true + + + buttonGroupPrinciple + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogLayoutSettings + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogLayoutSettings + reject() + + + 316 + 260 + + + 286 + 274 + + + + + + + + + diff --git a/src/app/dialogs/dialogs.pri b/src/app/dialogs/dialogs.pri index 8201e7386..cfb7025cf 100644 --- a/src/app/dialogs/dialogs.pri +++ b/src/app/dialogs/dialogs.pri @@ -41,7 +41,8 @@ HEADERS += \ $$PWD/app/configpages/communitypage.h \ $$PWD/app/configpages/pathpage.h \ $$PWD/app/dialogundo.h \ - $$PWD/tools/dialogcurveintersectaxis.h + $$PWD/tools/dialogcurveintersectaxis.h \ + $$PWD/app/dialoglayoutsettings.h SOURCES += \ $$PWD/tools/dialogtriangle.cpp \ @@ -81,7 +82,8 @@ SOURCES += \ $$PWD/app/configpages/communitypage.cpp \ $$PWD/app/configpages/pathpage.cpp \ $$PWD/app/dialogundo.cpp \ - $$PWD/tools/dialogcurveintersectaxis.cpp + $$PWD/tools/dialogcurveintersectaxis.cpp \ + $$PWD/app/dialoglayoutsettings.cpp FORMS += \ $$PWD/tools/dialogtriangle.ui \ @@ -115,4 +117,5 @@ FORMS += \ $$PWD/app/dialogaboutapp.ui \ $$PWD/app/dialogpatternxmledit.ui \ $$PWD/app/dialogundo.ui \ - $$PWD/tools/dialogcurveintersectaxis.ui + $$PWD/tools/dialogcurveintersectaxis.ui \ + $$PWD/app/dialoglayoutsettings.ui diff --git a/src/app/share/resources/icon.qrc b/src/app/share/resources/icon.qrc index 073e985a0..329cd555f 100644 --- a/src/app/share/resources/icon.qrc +++ b/src/app/share/resources/icon.qrc @@ -52,5 +52,8 @@ icon/32x32/line_intersect_axis.png icon/32x32/arc_intersect_axis.png icon/32x32/curve_intersect_axis.png + icon/16x16/landscape.png + icon/16x16/portrait.png + icon/16x16/template.png diff --git a/src/app/share/resources/icon/16x16/landscape.png b/src/app/share/resources/icon/16x16/landscape.png new file mode 100644 index 0000000000000000000000000000000000000000..a30d3b0caadf33e8be7019a42e081c93e0669d88 GIT binary patch literal 398 zcmV;90df9`P)IvXr1igWgJ7 zCn(?|@!0@Xp&v&8MEwv&$@6?&@Ecx9`jxRC?(WOl*#?&vs>;FsAz${Bm)Df}e77n{ zhUc~L`^OuT$%LopM~;t9u$jem-OaD?Gqc%@R;xvpW!TKp-f44nJp$;K6ZpPgE6DSl s>2!*<7NCT~AR0IQ3*9h?#{7$X19wGrh9+5Q{{R3007*qoM6N<$f?nRE{Qv*} literal 0 HcmV?d00001 diff --git a/src/app/share/resources/icon/16x16/portrait.png b/src/app/share/resources/icon/16x16/portrait.png new file mode 100644 index 0000000000000000000000000000000000000000..75fbbab49b90c1fd1db188d8ad2dcd5d7e36599c GIT binary patch literal 536 zcmV+z0_XjSP)WFU8GbZ8({Xk{QrNlj4iWF>9@00DeSL_t(I%axJAN*hrW zhChuYV5-JSR@qD%-=do?bg6EFE)@C!tBbP)p?ZPfg5;r@s7f1JaaVW`hlw{pkZT0c7ccJrcIbt@_&FP^nlt+g6Oky>lD z>Q=PsR@TO|v*RWVLxLb6=mvDVUBX_-pZj|*uP*RAJ_q}U0N3M?1VB|$RRl#;QBjJY ziu8Itvh!K|j?doiSAgqLW-b8`MG;hiCzt{svWwIkzloxVe!rhsKLHROhC6?KYQIh~ zrj6q`Y;J53MSargG>Z#MTwY!9>I${mDXmtEIDX{ep~cyGlYBl;CX*qT%T1nO1Tbxr zXll0&AD34EC=?1zyn>3LsyI$D(e&I;1jy3_+vOcfrBza?6s6KC+vT120Y+*x>lot^ z$1%ouG@AA40G{y>k>OM#c*dI!Fc=IH-dZ~mF!#UW$&a7BR|&xL6HNoSb&tP)nId;P a`uqcwYu5((6+Hw10000sVX>dc&(Z~k*;MgXd{${ujVdR-nLog6OAR%;c#O7{Et$+@iZ1D2> zM&q&mbLcV$j^hvxhZzh8D5dChIwTSaQYnk=Ei2$)p$A%PY}+Otk7HRDrfHH+r-??R z03?&i)d0gVyc-Y^T-U`g45rg*puD93fNrf02q(QUObshyxuHR0MP680MJ@9pU-Kx+stM&FJG_M7XX2GP%f7P$wHy9 na_k4}pPirn #include "../../libs/vobj/vobjpaintdevice.h" +#include "../dialogs/app/dialoglayoutsettings.h" #ifdef Q_OS_WIN # define PDFTOPS "pdftops.exe" @@ -79,6 +80,7 @@ TableWindow::TableWindow(QWidget *parent) connect(ui->actionAdd, &QAction::triggered, this, &TableWindow::AddLength); connect(ui->actionRemove, &QAction::triggered, this, &TableWindow::RemoveLength); connect(ui->view, &VTableGraphicsView::itemChect, this, &TableWindow::itemChect); + connect(ui->actionLayout, &QAction::triggered, this, &TableWindow::Layout); } //--------------------------------------------------------------------------------------------------------------------- @@ -510,6 +512,13 @@ void TableWindow::RemoveLength() } } +//--------------------------------------------------------------------------------------------------------------------- +void TableWindow::Layout() +{ + DialogLayoutSettings layout(this); + layout.exec(); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief keyPressEvent handle key press events. diff --git a/src/app/tablewindow.h b/src/app/tablewindow.h index b820f9928..effc1fb48 100644 --- a/src/app/tablewindow.h +++ b/src/app/tablewindow.h @@ -74,6 +74,7 @@ public slots: void AddLength(); void RemoveLength(); + void Layout(); signals: /** * @brief closed emit if window is closing. diff --git a/src/app/tablewindow.ui b/src/app/tablewindow.ui index 8f237a1d5..327eebf44 100644 --- a/src/app/tablewindow.ui +++ b/src/app/tablewindow.ui @@ -70,6 +70,7 @@ + @@ -200,6 +201,11 @@ Zoom Out + + + Layout + + diff --git a/src/app/xml/vabstractmeasurements.cpp b/src/app/xml/vabstractmeasurements.cpp index fbf3339b7..4a6189fc1 100644 --- a/src/app/xml/vabstractmeasurements.cpp +++ b/src/app/xml/vabstractmeasurements.cpp @@ -27,6 +27,7 @@ *************************************************************************/ #include "vabstractmeasurements.h" +#include "../core/vapplication.h" const QString VAbstractMeasurements::TagUnit = QStringLiteral("unit"); const QString VAbstractMeasurements::AttrValue = QStringLiteral("value"); @@ -214,6 +215,8 @@ qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const return value / 10.0; case Unit::Inch: return value / 25.4; + case Unit::Px: + return (value / 25.4) * VApplication::PrintDPI; default: break; } @@ -227,6 +230,8 @@ qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const return value; case Unit::Inch: return value / 2.54; + case Unit::Px: + return ((value * 10.0) / 25.4) * VApplication::PrintDPI; default: break; } @@ -240,6 +245,23 @@ qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const return value * 2.54; case Unit::Inch: return value; + case Unit::Px: + return value * VApplication::PrintDPI; + default: + break; + } + break; + case Unit::Px: + switch (to) + { + case Unit::Mm: + return (value / VApplication::PrintDPI) * 25.4; + case Unit::Cm: + return ((value / VApplication::PrintDPI) * 25.4) / 10.0; + case Unit::Inch: + return value / VApplication::PrintDPI; + case Unit::Px: + return value; default: break; } diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 616772c5f..4ca03fff6 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -36,7 +36,7 @@ extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; #endif /*Q_OS_WIN32*/ -enum class Unit : char { Mm, Cm, Inch }; +enum class Unit : char { Mm, Cm, Inch, Px }; enum class MeasurementsType : char { Standard, Individual }; static const quint32 null_id = 0; diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 0f29fb26f..40480bf0f 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -96,6 +96,7 @@ const QString VDomDocument::AttrUnit = QStringLiteral("unit"); const QString VDomDocument::UnitMM = QStringLiteral("mm"); const QString VDomDocument::UnitCM = QStringLiteral("cm"); const QString VDomDocument::UnitINCH = QStringLiteral("inch"); +const QString VDomDocument::UnitPX = QStringLiteral("px"); const QString VDomDocument::TagVersion = QStringLiteral("version"); //--------------------------------------------------------------------------------------------------------------------- @@ -499,7 +500,7 @@ void VDomDocument::setXMLContent(const QString &fileName) //--------------------------------------------------------------------------------------------------------------------- Unit VDomDocument::StrToUnits(const QString &unit) { - QStringList units = QStringList() << UnitMM << UnitCM << UnitINCH; + QStringList units = QStringList() << UnitMM << UnitCM << UnitINCH << UnitPX; Unit result = Unit::Cm; switch (units.indexOf(unit)) { @@ -512,6 +513,9 @@ Unit VDomDocument::StrToUnits(const QString &unit) case 2:// inch result = Unit::Inch; break; + case 3:// px + result = Unit::Px; + break; default: result = Unit::Cm; break; @@ -563,6 +567,16 @@ QString VDomDocument::UnitsToStr(const Unit &unit, const bool translate) result = UnitINCH; } break; + case Unit::Px: + if (translate) + { + result = QObject::tr("px"); + } + else + { + result = UnitPX; + } + break; default: if (translate) { diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index ac2d5029a..633c33b74 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -73,6 +73,7 @@ public: static const QString UnitMM; static const QString UnitCM; static const QString UnitINCH; + static const QString UnitPX; static const QString TagVersion; /** * @param data container with variables diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index bb6621b41..a8b177b58 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -235,7 +235,7 @@ bool VLayoutPaper::AddToBlankSheet(const VLayoutDetail &detail) workDetail.GetMatrix()); } } - ++d->frame; + d->frame = d->frame + 2; for (int angle = 0; angle < 360; ++angle) {