Setting scale factor for export and print.

This commit is contained in:
Roman Telezhynskyi 2020-03-21 18:15:29 +02:00
parent 47b3eab0ad
commit c8526f2eb0
29 changed files with 1257 additions and 158 deletions

View File

@ -44,6 +44,7 @@
- Tool Point at distance and angle now allows negative length.
- Export pattern to DXF-ASTM.
- [smart-pattern/valentina#18] Auto-created Visibility Group for group operation.
- Setting scale factor for export and print.
# Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path.

View File

@ -1,6 +1,6 @@
.\" Manpage for valentina.
.\" Contact dismine@gmail.com to correct errors.
.TH valentina 1 "15 March, 2020" "valentina man page"
.TH valentina 1 "21 March, 2020" "valentina man page"
.SH NAME
Valentina \- Pattern making program.
.SH SYNOPSIS
@ -213,6 +213,10 @@ The path to output destination folder. By default the directory at which the app
.RB "Page top margin in current units like 3.0 (" "export mode" "). If not set will be used value from default printer. Or 0 if none printers was found."
.IP "-B, --bmargin <The bottom margin>"
.RB "Page bottom margin in current units like 3.0 (" "export mode" "). If not set will be used value from default printer. Or 0 if none printers was found."
.IP "--xscale <Horizontal scale>"
.RB "Set horizontal scale factor from 0.01 to 3.0 (default = 1.0, " "export mode" ")."
.IP "--yscale <Vertical scale>"
.RB "Set vertical scale factor from 0.01 to 3.0 (default = 1.0, " "export mode" ")."
.IP "--followGrainline"
.RB "Order detail to follow grainline direction (" "export mode" ").
.IP "--manualPriority"

View File

@ -1,6 +1,6 @@
.\" Manpage for valentina.
.\" Contact dismine@gmail.com to correct errors.
.TH valentina 1 "15 March, 2020" "valentina man page"
.TH valentina 1 "21 March, 2020" "valentina man page"
.SH NAME
Valentina \- Pattern making program.
.SH SYNOPSIS
@ -213,6 +213,10 @@ The path to output destination folder. By default the directory at which the app
.RB "Page top margin in current units like 3.0 (" "export mode" "). If not set will be used value from default printer. Or 0 if none printers was found."
.IP "-B, --bmargin <The bottom margin>"
.RB "Page bottom margin in current units like 3.0 (" "export mode" "). If not set will be used value from default printer. Or 0 if none printers was found."
.IP "--xscale <Horizontal scale>"
.RB "Set horizontal scale factor from 0.01 to 3.0 (default = 1.0, " "export mode" ")."
.IP "--yscale <Vertical scale>"
.RB "Set vertical scale factor from 0.01 to 3.0 (default = 1.0, " "export mode" ")."
.IP "--followGrainline"
.RB "Order detail to follow grainline direction (" "export mode" ").
.IP "--manualPriority"

View File

@ -408,6 +408,28 @@ bool VCommandLine::IsCSVWithHeader() const
return IsOptionSet(LONG_OPTION_CSVWITHHEADER);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCommandLine::ExportXScale() const
{
qreal xs = 0;
if (IsOptionSet(LONG_OPTION_EXPXSCALE))
{
xs = OptionValue(LONG_OPTION_EXPXSCALE).toDouble();
}
return xs;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCommandLine::ExportYScale() const
{
qreal ys = 0;
if (IsOptionSet(LONG_OPTION_EXPYSCALE))
{
ys = OptionValue(LONG_OPTION_EXPYSCALE).toDouble();
}
return ys;
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptExportSuchDetails() const
{
@ -664,6 +686,12 @@ void VCommandLine::InitCommandLineOptions()
translate("VCommandLine", "Page bottom margin in current units like 3.0 (export mode). If not set will be "
"used value from default printer. Or 0 if none printers was found."),
translate("VCommandLine", "The bottom margin")},
{LONG_OPTION_EXPXSCALE,
translate("VCommandLine", "Set horizontal scale factor from 0.01 to 3.0 (default = 1.0, export mode)."),
translate("VCommandLine", "Horizontal scale")},
{LONG_OPTION_EXPYSCALE,
translate("VCommandLine", "Set vertical scale factor from 0.01 to 3.0 (default = 1.0, export mode)."),
translate("VCommandLine", "Vertical scale")},
//=================================================================================================================
{LONG_OPTION_FOLLOW_GRAINLINE,
translate("VCommandLine", "Order detail to follow grainline direction (export mode).")},

View File

@ -88,6 +88,9 @@ public:
bool IsExportOnlyDetails() const;
bool IsCSVWithHeader() const;
qreal ExportXScale() const;
qreal ExportYScale() const;
//@brief returns the piece name regex or empty string if not set
QString OptExportSuchDetails() const;

View File

@ -0,0 +1,214 @@
/************************************************************************
**
** @file dialoglayoutscale.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 21 3, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "dialoglayoutscale.h"
#include "ui_dialoglayoutscale.h"
#include "../core/vapplication.h"
#include "../vmisc/vsettings.h"
#include <QPushButton>
//---------------------------------------------------------------------------------------------------------------------
DialogLayoutScale::DialogLayoutScale(bool printTiled, QWidget *parent)
:QDialog(parent),
ui(new Ui::DialogLayoutScale)
{
ui->setupUi(this);
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
SCASSERT(bOk != nullptr)
connect(bOk, &QPushButton::clicked, this, &DialogLayoutScale::Save);
if (not printTiled)
{
ui->groupBoxMargins->setVisible(false);
}
connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, &DialogLayoutScale::ToggleScaleConnection);
connect(ui->doubleSpinBoxHorizontalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogLayoutScale::HorizontalScaleChanged);
connect(ui->doubleSpinBoxVerticalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogLayoutScale::VerticalScaleChanged);
ReadSettings();
}
//---------------------------------------------------------------------------------------------------------------------
DialogLayoutScale::~DialogLayoutScale()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::SetTiledMargins(QMarginsF margins)
{
// read Margins top, right, bottom, left
margins = UnitConvertor(margins, Unit::Mm, qApp->patternUnit());
ui->doubleSpinBoxLeftField->setValue(margins.left());
ui->doubleSpinBoxTopField->setValue(margins.top());
ui->doubleSpinBoxRightField->setValue(margins.right());
ui->doubleSpinBoxBottomField->setValue(margins.bottom());
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF DialogLayoutScale::GetTiledMargins() const
{
QMarginsF margins = QMarginsF(
ui->doubleSpinBoxLeftField->value(),
ui->doubleSpinBoxTopField->value(),
ui->doubleSpinBoxRightField->value(),
ui->doubleSpinBoxBottomField->value()
);
return UnitConvertor(margins, qApp->patternUnit(), Unit::Mm);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::SetXScale(qreal scale)
{
ui->doubleSpinBoxHorizontalScale->setValue(scale * 100.);
}
//---------------------------------------------------------------------------------------------------------------------
qreal DialogLayoutScale::GetXScale() const
{
return ui->doubleSpinBoxHorizontalScale->value() / 100.;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::SetYScale(qreal scale)
{
ui->doubleSpinBoxVerticalScale->setValue(scale * 100.);
}
//---------------------------------------------------------------------------------------------------------------------
qreal DialogLayoutScale::GetYScale() const
{
return ui->doubleSpinBoxVerticalScale->value() / 100.;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::showEvent(QShowEvent *event)
{
QDialog::showEvent( event );
if ( event->spontaneous() )
{
return;
}
if (isInitialized)
{
return;
}
// do your init stuff here
setFixedSize(size());
isInitialized = true;//first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::Save()
{
WriteSettings();
accept();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::ToggleScaleConnection()
{
m_scaleConnected = not m_scaleConnected;
QIcon icon;
icon.addFile(m_scaleConnected ? QStringLiteral(":/icon/32x32/link.png")
: QStringLiteral(":/icon/32x32/broken_link.png"));
ui->toolButtonScaleConnected->setIcon(icon);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::HorizontalScaleChanged(double d)
{
if (m_scaleConnected)
{
ui->doubleSpinBoxVerticalScale->blockSignals(true);
ui->doubleSpinBoxVerticalScale->setValue(d);
ui->doubleSpinBoxVerticalScale->blockSignals(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::VerticalScaleChanged(double d)
{
if (m_scaleConnected)
{
ui->doubleSpinBoxHorizontalScale->blockSignals(true);
ui->doubleSpinBoxHorizontalScale->setValue(d);
ui->doubleSpinBoxHorizontalScale->blockSignals(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::ReadSettings()
{
VSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit();
// read Margins top, right, bottom, left
const QMarginsF margins = settings->GetTiledPDFMargins(unit);
ui->doubleSpinBoxLeftField->setValue(margins.left());
ui->doubleSpinBoxTopField->setValue(margins.top());
ui->doubleSpinBoxRightField->setValue(margins.right());
ui->doubleSpinBoxBottomField->setValue(margins.bottom());
ui->doubleSpinBoxLeftField->setSuffix(UnitsToStr(unit, true));
ui->doubleSpinBoxTopField->setSuffix(UnitsToStr(unit, true));
ui->doubleSpinBoxRightField->setSuffix(UnitsToStr(unit, true));
ui->doubleSpinBoxBottomField->setSuffix(UnitsToStr(unit, true));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::WriteSettings() const
{
VSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit();
// write Margins top, right, bottom, left
QMarginsF margins = QMarginsF(
ui->doubleSpinBoxLeftField->value(),
ui->doubleSpinBoxTopField->value(),
ui->doubleSpinBoxRightField->value(),
ui->doubleSpinBoxBottomField->value()
);
settings->SetTiledPDFMargins(margins,unit);
}

View File

@ -0,0 +1,74 @@
/************************************************************************
**
** @file dialoglayoutscale.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 21 3, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef DIALOGLAYOUTSCALE_H
#define DIALOGLAYOUTSCALE_H
#include <QDialog>
namespace Ui
{
class DialogLayoutScale;
}
class DialogLayoutScale : public QDialog
{
Q_OBJECT
public:
explicit DialogLayoutScale(bool printTiled, QWidget *parent = nullptr);
~DialogLayoutScale();
void SetTiledMargins(QMarginsF margins);
QMarginsF GetTiledMargins() const;
void SetXScale(qreal scale);
qreal GetXScale() const;
void SetYScale(qreal scale);
qreal GetYScale() const;
protected:
virtual void showEvent(QShowEvent *event) override;
private slots:
void Save();
void ToggleScaleConnection();
void HorizontalScaleChanged(double d);
void VerticalScaleChanged(double d);
private:
Q_DISABLE_COPY(DialogLayoutScale)
Ui::DialogLayoutScale *ui;
bool isInitialized{false};
bool m_scaleConnected{true};
void ReadSettings();
void WriteSettings() const;
};
#endif // DIALOGLAYOUTSCALE_H

View File

@ -0,0 +1,334 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogLayoutScale</class>
<widget class="QDialog" name="DialogLayoutScale">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>404</width>
<height>211</height>
</rect>
</property>
<property name="windowTitle">
<string>Layout scale</string>
</property>
<property name="windowIcon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="groupBoxMargins">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Margins</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelLeftField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Left:</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLeftField">
<property name="suffix">
<string>cm</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelRightField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Right:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="doubleSpinBoxRightField">
<property name="suffix">
<string>cm</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelTopField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Top:</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="doubleSpinBoxTopField">
<property name="suffix">
<string>cm</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelBottomField">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bottom:</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="doubleSpinBoxBottomField">
<property name="suffix">
<string>cm</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBoxScale">
<property name="title">
<string>Scale</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Horizontal:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Vertical:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxHorizontalScale">
<property name="suffix">
<string>%</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>300.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>100.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxVerticalScale">
<property name="suffix">
<string>%</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>300.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>100.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;┐&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QToolButton" name="toolButtonScaleConnected">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/link.png</normaloff>:/icon/32x32/link.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::DelayedPopup</enum>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_8">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;┘&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogLayoutScale</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogLayoutScale</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -36,5 +36,6 @@
#include "dialogaboutapp.h"
#include "dialogpreferences.h"
#include "dialogfinalmeasurements.h"
#include "dialoglayoutscale.h"
#endif // DIALOGS_H

View File

@ -2,6 +2,7 @@
# This need for corect working file translations.pro
HEADERS += \
$$PWD/dialoglayoutscale.h \
$$PWD/dialogs.h \
$$PWD/dialogincrements.h \
$$PWD/dialoghistory.h \
@ -26,6 +27,7 @@ HEADERS += \
SOURCES += \
$$PWD/dialogincrements.cpp \
$$PWD/dialoghistory.cpp \
$$PWD/dialoglayoutscale.cpp \
$$PWD/dialogpatternproperties.cpp \
$$PWD/dialognewpattern.cpp \
$$PWD/dialogaboutapp.cpp \
@ -47,6 +49,7 @@ SOURCES += \
FORMS += \
$$PWD/dialogincrements.ui \
$$PWD/dialoghistory.ui \
$$PWD/dialoglayoutscale.ui \
$$PWD/dialogpatternproperties.ui \
$$PWD/dialognewpattern.ui \
$$PWD/dialogaboutapp.ui \

View File

@ -151,26 +151,15 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
InitTemplates(ui->comboBoxTemplates);
connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, &DialogSaveLayout::ToggleScaleConnection);
connect(ui->doubleSpinBoxHorizontalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogSaveLayout::HorizontalScaleChanged);
connect(ui->doubleSpinBoxVerticalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogSaveLayout::VerticalScaleChanged);
ReadSettings();
// connect for the template drop down box of the tiled pds
connect(ui->comboBoxTemplates, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogSaveLayout::WriteSettings);
// connects for the margins of the tiled pdf
connect(ui->doubleSpinBoxLeftField, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogSaveLayout::WriteSettings);
connect(ui->doubleSpinBoxTopField, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogSaveLayout::WriteSettings);
connect(ui->doubleSpinBoxRightField, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogSaveLayout::WriteSettings);
connect(ui->doubleSpinBoxBottomField, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogSaveLayout::WriteSettings);
// connects for the orientation buttons for the tiled pdf
connect(ui->toolButtonPortrait, &QToolButton::toggled, this, &DialogSaveLayout::WriteSettings);
connect(ui->toolButtonLandscape, &QToolButton::toggled, this, &DialogSaveLayout::WriteSettings);
ShowExample();//Show example for current format.
}
@ -520,6 +509,8 @@ LayoutExportFormats DialogSaveLayout::Format() const
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::Save()
{
WriteSettings();
for (int i=0; i < count; ++i)
{
const QString name = Path()+'/'+FileName()+QString::number(i+1)+ExportFormatSuffix(Format());
@ -623,6 +614,39 @@ void DialogSaveLayout::ShowExample()
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::ToggleScaleConnection()
{
m_scaleConnected = not m_scaleConnected;
QIcon icon;
icon.addFile(m_scaleConnected ? QStringLiteral(":/icon/32x32/link.png")
: QStringLiteral(":/icon/32x32/broken_link.png"));
ui->toolButtonScaleConnected->setIcon(icon);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::HorizontalScaleChanged(double d)
{
if (m_scaleConnected)
{
ui->doubleSpinBoxVerticalScale->blockSignals(true);
ui->doubleSpinBoxVerticalScale->setValue(d);
ui->doubleSpinBoxVerticalScale->blockSignals(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::VerticalScaleChanged(double d)
{
if (m_scaleConnected)
{
ui->doubleSpinBoxHorizontalScale->blockSignals(true);
ui->doubleSpinBoxHorizontalScale->setValue(d);
ui->doubleSpinBoxHorizontalScale->blockSignals(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogSaveLayout::IsTextAsPaths() const
{
@ -719,6 +743,30 @@ PageOrientation DialogSaveLayout::GetTiledPageOrientation() const
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::SetXScale(qreal scale)
{
ui->doubleSpinBoxHorizontalScale->setValue(scale * 100.);
}
//---------------------------------------------------------------------------------------------------------------------
qreal DialogSaveLayout::GetXScale() const
{
return ui->doubleSpinBoxHorizontalScale->value() / 100.;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::SetYScale(qreal scale)
{
ui->doubleSpinBoxVerticalScale->setValue(scale * 100.);
}
//---------------------------------------------------------------------------------------------------------------------
qreal DialogSaveLayout::GetYScale() const
{
return ui->doubleSpinBoxVerticalScale->value() / 100.;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::showEvent(QShowEvent *event)
{

View File

@ -86,6 +86,12 @@ public:
void SetTiledPageOrientation(PageOrientation orientation);
PageOrientation GetTiledPageOrientation() const;
void SetXScale(qreal scale);
qreal GetXScale() const;
void SetYScale(qreal scale);
qreal GetYScale() const;
protected:
virtual void showEvent(QShowEvent *event) override;
void InitTemplates(QComboBox *comboBoxTemplates);
@ -94,6 +100,9 @@ private slots:
void Save();
void PathChanged(const QString &text);
void ShowExample();
void ToggleScaleConnection();
void HorizontalScaleChanged(double d);
void VerticalScaleChanged(double d);
private:
Q_DISABLE_COPY(DialogSaveLayout)
Ui::DialogSaveLAyout *ui;
@ -101,6 +110,7 @@ private:
bool isInitialized;
Draw m_mode;
bool m_tiledExportMode;
bool m_scaleConnected{true};
static bool havePdf;
static bool tested;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>719</width>
<height>314</height>
<width>493</width>
<height>391</height>
</rect>
</property>
<property name="windowTitle">
@ -17,20 +17,20 @@
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditPath">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -46,7 +46,7 @@
<item>
<widget class="QPushButton" name="pushButtonBrowse">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -61,44 +61,229 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>File format:</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>File format:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxFormat">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxFormat">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QGroupBox" name="groupBoxFormatOptions">
<property name="title">
<string>Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="checkBoxBinaryDXF">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Binary form</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxTextAsPaths">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Text as paths</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="groupBoxScale">
<property name="title">
<string>Scale</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Horizontal:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Vertical:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxHorizontalScale">
<property name="suffix">
<string>%</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>300.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>100.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxVerticalScale">
<property name="suffix">
<string>%</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>300.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>100.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;┐&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QToolButton" name="toolButtonScaleConnected">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/link.png</normaloff>:/icon/32x32/link.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::DelayedPopup</enum>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_8">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;┘&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBoxBinaryDXF">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Binary form</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxTextAsPaths">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Text as paths</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QGroupBox" name="groupBoxMargins">
@ -148,6 +333,9 @@
<property name="suffix">
<string>cm</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="0" column="1">
@ -164,6 +352,9 @@
<property name="suffix">
<string>cm</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
@ -204,6 +395,9 @@
<property name="suffix">
<string>cm</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
@ -224,6 +418,9 @@
<property name="suffix">
<string>cm</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
@ -239,79 +436,75 @@
<property name="title">
<string>Paper format</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QFormLayout" name="formLayout_4">
<item row="1" column="0">
<widget class="QLabel" name="labelTemplates">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelTemplates">
<property name="text">
<string>Templates:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxTemplates"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Orientation:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QToolButton" name="toolButtonPortrait">
<property name="text">
<string>Templates:</string>
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/portrait.png</normaloff>:/icon/16x16/portrait.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxTemplates"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<item>
<widget class="QToolButton" name="toolButtonLandscape">
<property name="text">
<string>Orientation:</string>
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/landscape.png</normaloff>:/icon/16x16/landscape.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QToolButton" name="toolButtonPortrait">
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/portrait.png</normaloff>:/icon/16x16/portrait.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonLandscape">
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/landscape.png</normaloff>:/icon/16x16/landscape.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
@ -320,19 +513,28 @@
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>File name:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>File name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditFileName">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -347,6 +549,12 @@
</item>
<item>
<widget class="QLabel" name="labelExample">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
@ -363,7 +571,7 @@
</item>
</layout>
</item>
<item row="6" column="0" colspan="2">
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>

View File

@ -5527,6 +5527,8 @@ bool MainWindow::DoExport(const VCommandLinePtr &expParams)
m_dialogSaveLayout->SelectFormat(static_cast<LayoutExportFormats>(expParams->OptExportType()));
m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF());
m_dialogSaveLayout->SetTextAsPaths(expParams->IsTextAsPaths());
m_dialogSaveLayout->SetXScale(expParams->ExportXScale());
m_dialogSaveLayout->SetYScale(expParams->ExportYScale());
if (static_cast<LayoutExportFormats>(expParams->OptExportType()) == LayoutExportFormats::PDFTiled)
{
@ -5562,6 +5564,8 @@ bool MainWindow::DoExport(const VCommandLinePtr &expParams)
m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath());
m_dialogSaveLayout->SelectFormat(static_cast<LayoutExportFormats>(expParams->OptExportType()));
m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF());
m_dialogSaveLayout->SetXScale(expParams->ExportXScale());
m_dialogSaveLayout->SetYScale(expParams->ExportYScale());
if (static_cast<LayoutExportFormats>(expParams->OptExportType()) == LayoutExportFormats::PDFTiled)
{

View File

@ -41,6 +41,7 @@
#include "../vlayout/vlayoutgenerator.h"
#include "dialogs/dialoglayoutprogress.h"
#include "dialogs/dialogsavelayout.h"
#include "dialogs/dialoglayoutscale.h"
#include "../vlayout/vposter.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#include "../vpatterndb/floatItemData/vpatternlabeldata.h"
@ -868,7 +869,9 @@ void MainWindowsNoGUI::PrintPages(QPrinter *printer)
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
if (paper)
{
*poster += posterazor->Calc(paper->rect().toRect(), i, orientation);
QRectF paperRect = paper->rect();
QSizeF image(paperRect.width() * m_xscale, paperRect.height() * m_yscale);
*poster += posterazor->Calc(image.toSize(), i, orientation);
}
}
@ -1213,8 +1216,8 @@ void MainWindowsNoGUI::SvgFile(const QString &name, QGraphicsRectItem *paper, QG
const QRectF r = paper->rect();
QSvgGenerator generator;
generator.setFileName(name);
generator.setSize(QSize(qFloor(r.width() + margins.left() + margins.right()),
qFloor(r.height() + margins.top() + margins.bottom())));
generator.setSize(QSize(qFloor(r.width() * m_dialogSaveLayout->GetXScale() + margins.left() + margins.right()),
qFloor(r.height() * m_dialogSaveLayout->GetYScale() + margins.top() + margins.bottom())));
generator.setViewBox(QRectF(0, 0, r.width() + margins.left() + margins.right(),
r.height() + margins.top() + margins.bottom()));
generator.setTitle(tr("Pattern"));
@ -1226,6 +1229,7 @@ void MainWindowsNoGUI::SvgFile(const QString &name, QGraphicsRectItem *paper, QG
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
painter.scale(m_dialogSaveLayout->GetXScale(), m_dialogSaveLayout->GetYScale());
scene->render(&painter, r, r, Qt::IgnoreAspectRatio);
painter.end();
}
@ -1240,8 +1244,8 @@ void MainWindowsNoGUI::PngFile(const QString &name, QGraphicsRectItem *paper, QG
{
const QRectF r = paper->rect();
// Create the image with the exact size of the shrunk scene
QImage image(QSize(qFloor(r.width() + margins.left() + margins.right()),
qFloor(r.height() + margins.top() + margins.bottom())),
QImage image(QSize(qFloor(r.width() * m_dialogSaveLayout->GetXScale() + margins.left() + margins.right()),
qFloor(r.height() * m_dialogSaveLayout->GetYScale() + margins.top() + margins.bottom())),
QImage::Format_ARGB32);
image.fill(Qt::white);
QPainter painter(&image);
@ -1249,6 +1253,7 @@ void MainWindowsNoGUI::PngFile(const QString &name, QGraphicsRectItem *paper, QG
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
painter.scale(m_dialogSaveLayout->GetXScale(), m_dialogSaveLayout->GetYScale());
scene->render(&painter, r, r, Qt::IgnoreAspectRatio);
image.save(name);
}
@ -1271,9 +1276,11 @@ void MainWindowsNoGUI::PdfFile(const QString &name, QGraphicsRectItem *paper, QG
printer.setResolution(static_cast<int>(PrintDPI));
printer.setOrientation(QPrinter::Portrait);
printer.setFullPage(ignorePrinterFields);
if (not printer.setPageSize(QPageSize(QSizeF(FromPixel(r.width() + margins.left() + margins.right(), Unit::Mm),
FromPixel(r.height() + margins.top() + margins.bottom(), Unit::Mm)),
QPageSize::Millimeter)))
qreal width = FromPixel(r.width() * m_dialogSaveLayout->GetXScale() + margins.left() + margins.right(), Unit::Mm);
qreal height = FromPixel(r.height() * m_dialogSaveLayout->GetYScale() + margins.top() + margins.bottom(), Unit::Mm);
if (not printer.setPageSize(QPageSize(QSizeF(width, height), QPageSize::Millimeter)))
{
qWarning() << tr("Cannot set printer page size");
}
@ -1298,6 +1305,7 @@ void MainWindowsNoGUI::PdfFile(const QString &name, QGraphicsRectItem *paper, QG
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
painter.scale(m_dialogSaveLayout->GetXScale(), m_dialogSaveLayout->GetYScale());
scene->render(&painter, r, r, Qt::IgnoreAspectRatio);
painter.end();
}
@ -1323,6 +1331,9 @@ void MainWindowsNoGUI::PdfTiledFile(const QString &name)
qWarning()<<tr("Pages will be cropped because they do not fit printer paper size.");
}
m_xscale = m_dialogSaveLayout->GetXScale();
m_yscale = m_dialogSaveLayout->GetYScale();
printer.setOutputFileName(name);
printer.setResolution(static_cast<int>(PrintDPI));
PrintPages(&printer);
@ -1421,13 +1432,18 @@ void MainWindowsNoGUI::FlatDxfFile(const QString &name, int version, bool binary
PrepareTextForDXF(endStringPlaceholder, details);
VDxfPaintDevice generator;
generator.setFileName(name);
generator.setSize(paper->rect().size().toSize());
const QRectF r = paper->rect();
generator.setSize(QSize(qFloor(r.width() * m_dialogSaveLayout->GetXScale()),
qFloor(r.height() * m_dialogSaveLayout->GetYScale())));
generator.setResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(version));
generator.SetBinaryFormat(binary);
generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745
QPainter painter;
painter.scale(m_dialogSaveLayout->GetXScale(), m_dialogSaveLayout->GetYScale());
if (painter.begin(&generator))
{
scene->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio);
@ -1442,11 +1458,14 @@ void MainWindowsNoGUI::AAMADxfFile(const QString &name, int version, bool binary
{
VDxfPaintDevice generator;
generator.setFileName(name);
generator.setSize(size);
generator.setSize(QSize(qCeil(size.width() * m_dialogSaveLayout->GetXScale()),
qCeil(size.height() * m_dialogSaveLayout->GetYScale())));
generator.setResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(version));
generator.SetBinaryFormat(binary);
generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745
generator.SetXScale(m_dialogSaveLayout->GetXScale());
generator.SetYScale(m_dialogSaveLayout->GetYScale());
generator.ExportToAAMA(details);
}
@ -1461,6 +1480,8 @@ void MainWindowsNoGUI::ASTMDxfFile(const QString &name, int version, bool binary
generator.SetVersion(static_cast<DRW::Version>(version));
generator.SetBinaryFormat(binary);
generator.setInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745
generator.SetXScale(m_dialogSaveLayout->GetXScale());
generator.SetYScale(m_dialogSaveLayout->GetYScale());
generator.ExportToASTM(details);
}
@ -1477,6 +1498,17 @@ void MainWindowsNoGUI::PreparePaper(int index) const
shadows.at(index)->setVisible(false);
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));// border
}
QTransform matrix;
matrix.scale(m_xscale, m_yscale);
QList<QGraphicsItem *> paperDetails = details.at(index);
for (auto detail : paperDetails)
{
QTransform m = detail->transform();
m *= matrix;
detail->setTransform(m);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -1491,6 +1523,17 @@ void MainWindowsNoGUI::RestorePaper(int index) const
scenes.at(index)->setBackgroundBrush(brush);
shadows.at(index)->setVisible(true);
}
QTransform matrix;
matrix.scale(1./m_xscale, 1./m_yscale);
QList<QGraphicsItem *> paperDetails = details.at(index);
for (auto detail : paperDetails)
{
QTransform m = detail->transform();
m *= matrix;
detail->setTransform(m);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -1581,8 +1624,19 @@ void MainWindowsNoGUI::PrintPreview()
return;
}
{
DialogLayoutScale layoutScale(isTiled, this);
layoutScale.SetXScale(1);
layoutScale.SetYScale(1);
layoutScale.exec();
m_xscale = layoutScale.GetXScale();
m_yscale = layoutScale.GetYScale();
}
SetPrinterSettings(printer.data(), PrintType::PrintPreview);
printer->setResolution(static_cast<int>(PrintDPI));
// display print preview dialog
QPrintPreviewDialog preview(printer.data());
connect(&preview, &QPrintPreviewDialog::paintRequested, this, &MainWindowsNoGUI::PrintPages);
@ -1613,6 +1667,16 @@ void MainWindowsNoGUI::LayoutPrint()
return;
}
{
DialogLayoutScale layoutScale(isTiled, this);
layoutScale.SetXScale(1);
layoutScale.SetYScale(1);
layoutScale.exec();
m_xscale = layoutScale.GetXScale();
m_yscale = layoutScale.GetYScale();
}
SetPrinterSettings(printer.data(), PrintType::PrintNative);
QPrintDialog dialog(printer.data(), this );
// If only user couldn't change page margins we could use method setMinMax();

View File

@ -162,6 +162,9 @@ private:
QString layoutPrinterName;
qreal m_xscale{1};
qreal m_yscale{1};
static QList<QGraphicsItem *> CreateShadows(const QList<QGraphicsItem *> &papers);
static QList<QGraphicsScene *> CreateScenes(const QList<QGraphicsItem *> &papers,
const QList<QGraphicsItem *> &shadows,

View File

@ -587,6 +587,30 @@ void VDxfEngine::setInsunits(const VarInsunits &var)
varInsunits = var;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VDxfEngine::GetXScale() const
{
return m_xscale;
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::SetXScale(const qreal &xscale)
{
m_xscale = xscale;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VDxfEngine::GetYScale() const
{
return m_yscale;
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::SetYScale(const qreal &yscale)
{
m_yscale = yscale;
}
//---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
@ -642,7 +666,7 @@ bool VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details)
ExportStyleSystemText(input, details);
for(auto &detail : details)
for(auto detail : details)
{
dx_ifaceBlock *detailBlock = new dx_ifaceBlock();
@ -655,6 +679,8 @@ bool VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details)
detailBlock->name = blockName.toStdString();
detailBlock->layer = '1';
detail.Scale(m_xscale, m_yscale);
ExportAAMAOutline(detailBlock, detail);
ExportAAMADraw(detailBlock, detail);
ExportAAMAIntcut(detailBlock, detail);
@ -775,7 +801,7 @@ void VDxfEngine::ExportPieceText(dx_ifaceBlock *detailBlock, const VLayoutPiece
for (int i = 0; i < list.size(); ++i)
{
QPointF pos(startPos.x(), startPos.y() - ToPixel(AAMATextHeight, varInsunits)*(list.size() - i-1));
QPointF pos(startPos.x(), startPos.y() - ToPixel(AAMATextHeight * m_yscale, varInsunits)*(list.size() - i-1));
detailBlock->ent.push_back(AAMAText(pos, list.at(i), QChar('1')));
}
}
@ -790,7 +816,8 @@ void VDxfEngine::ExportStyleSystemText(const QSharedPointer<dx_iface> &input, co
{
for (int j = 0; j < strings.size(); ++j)
{
QPointF pos(0, getSize().height() - ToPixel(AAMATextHeight, varInsunits)*(strings.size() - j-1));
QPointF pos(0, getSize().height() -
ToPixel(AAMATextHeight * m_yscale, varInsunits)*(strings.size() - j-1));
input->AddEntity(AAMAText(pos, strings.at(j), QChar('1')));
}
return;
@ -840,7 +867,7 @@ bool VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details)
ExportStyleSystemText(input, details);
for(auto &detail : details)
for(auto detail : details)
{
dx_ifaceBlock *detailBlock = new dx_ifaceBlock();
@ -853,6 +880,8 @@ bool VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details)
detailBlock->name = blockName.toStdString();
detailBlock->layer = '1';
detail.Scale(m_xscale, m_yscale);
ExportASTMPieceBoundary(detailBlock, detail);
ExportASTMSewLine(detailBlock, detail);
ExportASTMInternalLine(detailBlock, detail);

View File

@ -92,6 +92,12 @@ public:
void setMeasurement(const VarMeasurement &var);
void setInsunits(const VarInsunits &var);
qreal GetXScale() const;
void SetXScale(const qreal &xscale);
qreal GetYScale() const;
void SetYScale(const qreal &yscale);
private:
Q_DISABLE_COPY(VDxfEngine)
QSize size;
@ -104,6 +110,8 @@ private:
VarMeasurement varMeasurement;
VarInsunits varInsunits;
DRW_Text *textBuffer;
qreal m_xscale{1};
qreal m_yscale{1};
Q_REQUIRED_RESULT double FromPixel(double pix, const VarInsunits &unit) const;
Q_REQUIRED_RESULT double ToPixel(double val, const VarInsunits &unit) const;

View File

@ -162,6 +162,40 @@ void VDxfPaintDevice::setInsunits(const VarInsunits &var)
engine->setInsunits(var);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VDxfPaintDevice::GetXScale() const
{
return engine->GetYScale();
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfPaintDevice::SetXScale(const qreal &xscale)
{
if (engine->isActive())
{
qWarning("VDxfPaintDevice::SetXScale(), cannot set x scale while Dxf is being generated");
return;
}
engine->SetXScale(xscale);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VDxfPaintDevice::GetYScale() const
{
return engine->GetXScale();
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfPaintDevice::SetYScale(const qreal &yscale)
{
if (engine->isActive())
{
qWarning("VDxfPaintDevice::SetYScale(), cannot set y scale while Dxf is being generated");
return;
}
engine->SetYScale(yscale);
}
//---------------------------------------------------------------------------------------------------------------------
bool VDxfPaintDevice::ExportToAAMA(const QVector<VLayoutPiece> &details) const
{

View File

@ -66,6 +66,12 @@ public:
void setMeasurement(const VarMeasurement &var);
void setInsunits(const VarInsunits &var);
qreal GetXScale() const;
void SetXScale(const qreal &xscale);
qreal GetYScale() const;
void SetYScale(const qreal &yscale);
bool ExportToAAMA(const QVector<VLayoutPiece> &details) const;
bool ExportToASTM(const QVector<VLayoutPiece> &details) const;

View File

@ -830,6 +830,14 @@ void VLayoutPiece::Translate(qreal dx, qreal dy)
d->matrix *= m;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::Scale(qreal sx, qreal sy)
{
QTransform m;
m.scale(sx, sy);
d->matrix *= m;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::Rotate(const QPointF &originPoint, qreal degrees)
{

View File

@ -126,6 +126,7 @@ public:
void SetMirror(bool value);
void Translate(qreal dx, qreal dy);
void Scale(qreal sx, qreal sy);
void Rotate(const QPointF &originPoint, qreal degrees);
void Mirror(const QLineF &edge);
void Mirror();

View File

@ -53,6 +53,8 @@ const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf");
const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths");
const QString LONG_OPTION_EXPORTONLYDETAILS = QStringLiteral("exportOnlyDetails");
const QString LONG_OPTION_EXPORTSUCHDETAILS = QStringLiteral("exportSuchDetails");
const QString LONG_OPTION_EXPXSCALE = QStringLiteral("xscale");
const QString LONG_OPTION_EXPYSCALE = QStringLiteral("yscale");
const QString LONG_OPTION_CROP_LENGTH = QStringLiteral("crop");
const QString SINGLE_OPTION_CROP_LENGTH = QStringLiteral("c");
@ -153,6 +155,8 @@ QStringList AllKeys()
LONG_OPTION_TEXT2PATHS,
LONG_OPTION_EXPORTONLYDETAILS,
LONG_OPTION_EXPORTSUCHDETAILS,
LONG_OPTION_EXPXSCALE,
LONG_OPTION_EXPYSCALE,
LONG_OPTION_CROP_LENGTH, SINGLE_OPTION_CROP_LENGTH,
LONG_OPTION_CROP_WIDTH,
LONG_OPTION_UNITE, SINGLE_OPTION_UNITE,

View File

@ -50,6 +50,8 @@ extern const QString LONG_OPTION_BINARYDXF;
extern const QString LONG_OPTION_TEXT2PATHS;
extern const QString LONG_OPTION_EXPORTONLYDETAILS;
extern const QString LONG_OPTION_EXPORTSUCHDETAILS;
extern const QString LONG_OPTION_EXPXSCALE;
extern const QString LONG_OPTION_EXPYSCALE;
extern const QString LONG_OPTION_CROP_LENGTH;
extern const QString SINGLE_OPTION_CROP_LENGTH;

View File

@ -85,5 +85,9 @@
<file>icon/32x32/font_preferences.png</file>
<file>icon/24x24/font_preferences@2x.png</file>
<file>icon/24x24/font_preferences.png</file>
<file>icon/32x32/broken_link.png</file>
<file>icon/32x32/broken_link@2x.png</file>
<file>icon/32x32/link.png</file>
<file>icon/32x32/link@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB