Correct scale when export tiled PDF.

This commit is contained in:
Roman Telezhynskyi 2021-09-06 16:56:56 +03:00
parent d5a02ac48c
commit b71253738c
16 changed files with 414 additions and 273 deletions

View File

@ -126,13 +126,6 @@ DialogSaveManualLayout::DialogSaveManualLayout(int count, bool consoleExport, co
ui->lineEditPath->setText(VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts()); ui->lineEditPath->setText(VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts());
connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, &DialogSaveManualLayout::ToggleScaleConnection);
connect(ui->doubleSpinBoxHorizontalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogSaveManualLayout::HorizontalScaleChanged);
connect(ui->doubleSpinBoxVerticalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogSaveManualLayout::VerticalScaleChanged);
ReadSettings(); ReadSettings();
ShowExample();//Show example for current format. ShowExample();//Show example for current format.
@ -145,19 +138,19 @@ DialogSaveManualLayout::~DialogSaveManualLayout()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogSaveManualLayout::Path() const auto DialogSaveManualLayout::Path() const -> QString
{ {
return ui->lineEditPath->text(); return ui->lineEditPath->text();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogSaveManualLayout::FileName() const auto DialogSaveManualLayout::FileName() const -> QString
{ {
return ui->lineEditFileName->text(); return ui->lineEditFileName->text();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
LayoutExportFormats DialogSaveManualLayout::Format() const auto DialogSaveManualLayout::Format() const -> LayoutExportFormats
{ {
return static_cast<LayoutExportFormats>(ui->comboBoxFormat->currentData().toInt()); return static_cast<LayoutExportFormats>(ui->comboBoxFormat->currentData().toInt());
} }
@ -229,7 +222,7 @@ void DialogSaveManualLayout::SetBinaryDXFFormat(bool binary)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogSaveManualLayout::IsBinaryDXFFormat() const auto DialogSaveManualLayout::IsBinaryDXFFormat() const -> bool
{ {
switch(Format()) switch(Format())
{ {
@ -303,7 +296,7 @@ void DialogSaveManualLayout::SetDestinationPath(const QString &cmdDestinationPat
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogSaveManualLayout::IsTextAsPaths() const auto DialogSaveManualLayout::IsTextAsPaths() const -> bool
{ {
return ui->checkBoxTextAsPaths->isChecked(); return ui->checkBoxTextAsPaths->isChecked();
} }
@ -314,30 +307,6 @@ void DialogSaveManualLayout::SetTextAsPaths(bool textAsPaths)
ui->checkBoxTextAsPaths->setChecked(textAsPaths); ui->checkBoxTextAsPaths->setChecked(textAsPaths);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::SetXScale(qreal scale)
{
ui->doubleSpinBoxHorizontalScale->setValue(scale * 100.);
}
//---------------------------------------------------------------------------------------------------------------------
qreal DialogSaveManualLayout::GetXScale() const
{
return ui->doubleSpinBoxHorizontalScale->value() / 100.;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::SetYScale(qreal scale)
{
ui->doubleSpinBoxVerticalScale->setValue(scale * 100.);
}
//---------------------------------------------------------------------------------------------------------------------
qreal DialogSaveManualLayout::GetYScale() const
{
return ui->doubleSpinBoxVerticalScale->value() / 100.;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::SetExportUnified(bool value) void DialogSaveManualLayout::SetExportUnified(bool value)
{ {
@ -390,7 +359,7 @@ void DialogSaveManualLayout::SetExportUnified(bool value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogSaveManualLayout::IsExportUnified() const auto DialogSaveManualLayout::IsExportUnified() const -> bool
{ {
switch(Format()) switch(Format())
{ {
@ -586,40 +555,7 @@ void DialogSaveManualLayout::ShowExample()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::ToggleScaleConnection() auto DialogSaveManualLayout::SupportPSTest() -> bool
{
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 DialogSaveManualLayout::HorizontalScaleChanged(double d)
{
if (m_scaleConnected)
{
ui->doubleSpinBoxVerticalScale->blockSignals(true);
ui->doubleSpinBoxVerticalScale->setValue(d);
ui->doubleSpinBoxVerticalScale->blockSignals(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::VerticalScaleChanged(double d)
{
if (m_scaleConnected)
{
ui->doubleSpinBoxHorizontalScale->blockSignals(true);
ui->doubleSpinBoxHorizontalScale->setValue(d);
ui->doubleSpinBoxHorizontalScale->blockSignals(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogSaveManualLayout::SupportPSTest()
{ {
if (!tested) if (!tested)
{ {
@ -630,7 +566,7 @@ bool DialogSaveManualLayout::SupportPSTest()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<std::pair<QString, LayoutExportFormats> > DialogSaveManualLayout::InitFormats() auto DialogSaveManualLayout::InitFormats() -> QVector<std::pair<QString, LayoutExportFormats> >
{ {
QVector<std::pair<QString, LayoutExportFormats>> list; QVector<std::pair<QString, LayoutExportFormats>> list;

View File

@ -52,21 +52,15 @@ public:
void SelectFormat(LayoutExportFormats format); void SelectFormat(LayoutExportFormats format);
void SetBinaryDXFFormat(bool binary); void SetBinaryDXFFormat(bool binary);
bool IsBinaryDXFFormat() const; auto IsBinaryDXFFormat() const -> bool;
void SetDestinationPath(const QString& cmdDestinationPath); void SetDestinationPath(const QString& cmdDestinationPath);
bool IsTextAsPaths() const; auto IsTextAsPaths() const -> bool;
void SetTextAsPaths(bool textAsPaths); void SetTextAsPaths(bool textAsPaths);
void SetXScale(qreal scale);
qreal GetXScale() const;
void SetYScale(qreal scale);
qreal GetYScale() const;
void SetExportUnified(bool value); void SetExportUnified(bool value);
bool IsExportUnified() const; auto IsExportUnified() const -> bool;
protected: protected:
virtual void showEvent(QShowEvent *event) override; virtual void showEvent(QShowEvent *event) override;
@ -75,9 +69,6 @@ private slots:
void Save(); void Save();
void PathChanged(const QString &text); void PathChanged(const QString &text);
void ShowExample(); void ShowExample();
void ToggleScaleConnection();
void HorizontalScaleChanged(double d);
void VerticalScaleChanged(double d);
private: private:
Q_DISABLE_COPY(DialogSaveManualLayout) Q_DISABLE_COPY(DialogSaveManualLayout)

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>503</width> <width>413</width>
<height>383</height> <height>290</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -144,155 +144,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer_6">
<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_2">
<property name="title">
<string>Scale</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Horizontal:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Vertical:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxHorizontalScale">
<property name="suffix">
<string notr="true">%</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 notr="true">%</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_8">
<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_13">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string notr="true">&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 notr="true">...</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_14">
<property name="text">
<string notr="true">&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> </layout>
</item> </item>
<item> <item>
@ -356,6 +207,19 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
@ -368,9 +232,7 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> <resources/>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
</resources>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>

View File

@ -328,3 +328,27 @@ void VPLayoutSettings::SetIgnoreTilesMargins(bool newIgnoreTilesMargins)
{ {
m_ignoreTilesMargins = newIgnoreTilesMargins; m_ignoreTilesMargins = newIgnoreTilesMargins;
} }
//---------------------------------------------------------------------------------------------------------------------
qreal VPLayoutSettings::HorizontalScale() const
{
return m_horizontalScale;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::SetHorizontalScale(qreal newHorizontalScale)
{
m_horizontalScale = newHorizontalScale;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPLayoutSettings::VerticalScale() const
{
return m_verticalScale;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::SetVerticalScale(qreal newVerticalScale)
{
m_verticalScale = newVerticalScale;
}

View File

@ -300,6 +300,12 @@ public:
auto IgnoreTilesMargins() const -> bool; auto IgnoreTilesMargins() const -> bool;
void SetIgnoreTilesMargins(bool newIgnoreTilesMargins); void SetIgnoreTilesMargins(bool newIgnoreTilesMargins);
auto HorizontalScale() const -> qreal;
void SetHorizontalScale(qreal newHorizontalScale);
auto VerticalScale() const -> qreal;
void SetVerticalScale(qreal newVerticalScale);
private: private:
Unit m_unit{Unit::Cm}; Unit m_unit{Unit::Cm};
@ -348,6 +354,9 @@ private:
qreal m_gridRowHeight{0}; qreal m_gridRowHeight{0};
bool m_stickyEdges{false}; bool m_stickyEdges{false};
qreal m_horizontalScale{1.0};
qreal m_verticalScale{1.0};
}; };
#endif // VPLAYOUTSETTINGS_H #endif // VPLAYOUTSETTINGS_H

View File

@ -24,9 +24,12 @@ auto VPGraphicsTileGrid::boundingRect() const -> QRectF
{ {
VPSheetPtr sheet = layout->GetSheet(m_sheetUuid); VPSheetPtr sheet = layout->GetSheet(m_sheetUuid);
qreal xScale = layout->LayoutSettings().HorizontalScale();
qreal yScale = layout->LayoutSettings().VerticalScale();
QRectF rect(0, 0, QRectF rect(0, 0,
layout->TileFactory()->ColNb(sheet) * layout->TileFactory()->DrawingAreaWidth(), layout->TileFactory()->ColNb(sheet) * (layout->TileFactory()->DrawingAreaWidth() / xScale),
layout->TileFactory()->RowNb(sheet) * layout->TileFactory()->DrawingAreaHeight() ); layout->TileFactory()->RowNb(sheet) * (layout->TileFactory()->DrawingAreaHeight() / yScale));
constexpr qreal halfPenWidth = penWidth/2.; constexpr qreal halfPenWidth = penWidth/2.;
@ -54,29 +57,22 @@ void VPGraphicsTileGrid::paint(QPainter *painter, const QStyleOptionGraphicsItem
painter->setPen(pen); painter->setPen(pen);
painter->setBrush(noBrush); painter->setBrush(noBrush);
qreal xScale = layout->LayoutSettings().HorizontalScale();
qreal yScale = layout->LayoutSettings().VerticalScale();
const qreal drawingAreaWidth = layout->TileFactory()->DrawingAreaWidth() / xScale;
const qreal drawingAreaHeight = layout->TileFactory()->DrawingAreaHeight() / yScale;
for(int i=0;i<=layout->TileFactory()->ColNb(sheet);i++) for(int i=0;i<=layout->TileFactory()->ColNb(sheet);i++)
{ {
painter->drawLine(QPointF( painter->drawLine(QPointF(i*drawingAreaWidth, 0),
i*layout->TileFactory()->DrawingAreaWidth(), QPointF(i*drawingAreaWidth, layout->TileFactory()->RowNb(sheet)*drawingAreaHeight));
0),
QPointF(
i*layout->TileFactory()->DrawingAreaWidth(),
layout->TileFactory()->RowNb(sheet)*layout->TileFactory()->DrawingAreaHeight()
)
);
} }
for(int j=0;j<=layout->TileFactory()->RowNb(sheet);j++) for(int j=0;j<=layout->TileFactory()->RowNb(sheet);j++)
{ {
painter->drawLine(QPointF( painter->drawLine(QPointF(0, j*drawingAreaHeight),
0, QPointF(layout->TileFactory()->ColNb(sheet)*drawingAreaWidth, j*drawingAreaHeight));
j*layout->TileFactory()->DrawingAreaHeight()
),
QPointF(
layout->TileFactory()->ColNb(sheet)*layout->TileFactory()->DrawingAreaWidth(),
j*layout->TileFactory()->DrawingAreaHeight()
)
);
} }
} }
} }

View File

@ -979,6 +979,65 @@ void VPMainWindow::InitPropertyTabLayout()
} }
}); });
connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, [this]()
{
m_scaleConnected = not m_scaleConnected;
UpdateScaleConnection();
});
connect(ui->doubleSpinBoxHorizontalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, [this](double d)
{
if (m_layout.isNull())
{
return;
}
m_layout->LayoutSettings().SetHorizontalScale(d / 100.);
if (m_scaleConnected)
{
ui->doubleSpinBoxVerticalScale->blockSignals(true);
ui->doubleSpinBoxVerticalScale->setValue(d);
ui->doubleSpinBoxVerticalScale->blockSignals(false);
m_layout->LayoutSettings().SetVerticalScale(d / 100.);
}
LayoutWasSaved(false);
m_layout->TileFactory()->refreshTileInfos();
m_graphicsView->RefreshLayout();
VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView);
});
connect(ui->doubleSpinBoxVerticalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
[this](double d)
{
if (m_layout.isNull())
{
return;
}
m_layout->LayoutSettings().SetVerticalScale(d / 100.);
if (m_scaleConnected)
{
ui->doubleSpinBoxHorizontalScale->blockSignals(true);
ui->doubleSpinBoxHorizontalScale->setValue(d);
ui->doubleSpinBoxHorizontalScale->blockSignals(false);
m_layout->LayoutSettings().SetHorizontalScale(d / 100.);
}
LayoutWasSaved(false);
m_layout->TileFactory()->refreshTileInfos();
m_graphicsView->RefreshLayout();
VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView);
});
connect(ui->pushButtonLayoutExport, &QPushButton::clicked, this, &VPMainWindow::on_ExportLayout); connect(ui->pushButtonLayoutExport, &QPushButton::clicked, this, &VPMainWindow::on_ExportLayout);
} }
@ -1276,6 +1335,17 @@ void VPMainWindow::SetPropertyTabLayoutData()
ui->doubleSpinBoxSheetPiecesGap->setSuffix(" " + UnitsToStr(LayoutUnit(), true)); ui->doubleSpinBoxSheetPiecesGap->setSuffix(" " + UnitsToStr(LayoutUnit(), true));
ui->groupBoxLayoutScale->setDisabled(false);
const qreal xScale = m_layout->LayoutSettings().HorizontalScale();
SetDoubleSpinBoxValue(ui->doubleSpinBoxHorizontalScale, xScale * 100.);
const qreal yScale = m_layout->LayoutSettings().VerticalScale();
SetDoubleSpinBoxValue(ui->doubleSpinBoxVerticalScale, yScale * 100.);
m_scaleConnected = qFuzzyCompare(xScale, yScale);
UpdateScaleConnection();
ui->groupBoxLayoutExport->setDisabled(false); ui->groupBoxLayoutExport->setDisabled(false);
} }
else else
@ -1298,6 +1368,8 @@ void VPMainWindow::SetPropertyTabLayoutData()
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPiecesGap, 0); SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPiecesGap, 0);
ui->groupBoxLayoutScale->setDisabled(true);
ui->groupBoxLayoutExport->setDisabled(true); ui->groupBoxLayoutExport->setDisabled(true);
} }
} }
@ -2139,7 +2211,7 @@ void VPMainWindow::ExportScene(const VPExportData &data)
for (int i=0; i < sheets.size(); ++i) for (int i=0; i < sheets.size(); ++i)
{ {
VPSheetPtr sheet = sheets.at(i); const VPSheetPtr& sheet = sheets.at(i);
if (sheet.isNull()) if (sheet.isNull())
{ {
continue; continue;
@ -2390,8 +2462,9 @@ void VPMainWindow::ExportPdfTiledFile(const VPExportData &data)
if (not m_layout->LayoutSettings().IgnoreTilesMargins()) if (not m_layout->LayoutSettings().IgnoreTilesMargins())
{ {
QMarginsF tiledMargins = m_layout->LayoutSettings().GetTilesMargins();
QMarginsF printerMargins; QMarginsF printerMargins;
QMarginsF tiledMargins = m_layout->LayoutSettings().GetTilesMargins();
if(tiledPDFOrientation == QPageLayout::Landscape) if(tiledPDFOrientation == QPageLayout::Landscape)
{ {
// because when painting we have a -90rotation in landscape mode, // because when painting we have a -90rotation in landscape mode,
@ -2510,6 +2583,15 @@ void VPMainWindow::GeneratePdfTiledFile(const VPSheetPtr &sheet, QPainter *paint
sheet->SceneData()->CleanAfterExport(); sheet->SceneData()->CleanAfterExport();
} }
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::UpdateScaleConnection() const
{
QIcon icon;
icon.addFile(m_scaleConnected ? QStringLiteral(":/icon/32x32/link.png")
: QStringLiteral(":/icon/32x32/broken_link.png"));
ui->toolButtonScaleConnected->setIcon(icon);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_actionNew_triggered() void VPMainWindow::on_actionNew_triggered()
{ {
@ -3363,8 +3445,8 @@ void VPMainWindow::on_ExportLayout()
data.path = dialog.Path(); data.path = dialog.Path();
data.fileName = dialog.FileName(); data.fileName = dialog.FileName();
data.sheets = sheets; data.sheets = sheets;
data.xScale = dialog.GetXScale(); data.xScale = m_layout->LayoutSettings().HorizontalScale();
data.yScale = dialog.GetYScale(); data.yScale = m_layout->LayoutSettings().VerticalScale();
data.isBinaryDXF = dialog.IsBinaryDXFFormat(); data.isBinaryDXF = dialog.IsBinaryDXFFormat();
data.textAsPaths = dialog.IsTextAsPaths(); data.textAsPaths = dialog.IsTextAsPaths();
data.exportUnified = dialog.IsExportUnified(); data.exportUnified = dialog.IsExportUnified();
@ -3400,8 +3482,8 @@ void VPMainWindow::on_ExportSheet()
data.path = dialog.Path(); data.path = dialog.Path();
data.fileName = dialog.FileName(); data.fileName = dialog.FileName();
data.sheets = QList<VPSheetPtr>{sheet}; data.sheets = QList<VPSheetPtr>{sheet};
data.xScale = dialog.GetXScale(); data.xScale = m_layout->LayoutSettings().HorizontalScale();
data.yScale = dialog.GetYScale(); data.yScale = m_layout->LayoutSettings().VerticalScale();
data.isBinaryDXF = dialog.IsBinaryDXFFormat(); data.isBinaryDXF = dialog.IsBinaryDXFFormat();
data.textAsPaths = dialog.IsTextAsPaths(); data.textAsPaths = dialog.IsTextAsPaths();
data.exportUnified = dialog.IsExportUnified(); data.exportUnified = dialog.IsExportUnified();

View File

@ -316,6 +316,8 @@ private:
Unit m_oldPieceTranslationUnit{Unit::Mm}; Unit m_oldPieceTranslationUnit{Unit::Mm};
Unit m_oldLayoutUnit{Unit::Mm}; Unit m_oldLayoutUnit{Unit::Mm};
bool m_scaleConnected{true};
/** /**
* @brief InitMenuBar Inits the menu bar (File, Edit, Help ...) * @brief InitMenuBar Inits the menu bar (File, Edit, Help ...)
*/ */
@ -446,6 +448,8 @@ private:
void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name); void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name);
void ExportPdfTiledFile(const VPExportData &data); void ExportPdfTiledFile(const VPExportData &data);
void GeneratePdfTiledFile(const VPSheetPtr &sheet, QPainter *painter, QPrinter *printer, bool firstSheet); void GeneratePdfTiledFile(const VPSheetPtr &sheet, QPainter *painter, QPrinter *printer, bool firstSheet);
void UpdateScaleConnection() const;
}; };
#endif // VPMAINWINDOW_H #endif // VPMAINWINDOW_H

View File

@ -208,7 +208,7 @@
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>3</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -1589,7 +1589,7 @@
<height>700</height> <height>700</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_22"> <layout class="QVBoxLayout" name="verticalLayout_27">
<item> <item>
<widget class="QLabel" name="labelLayout"> <widget class="QLabel" name="labelLayout">
<property name="styleSheet"> <property name="styleSheet">
@ -1691,6 +1691,179 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBoxLayoutScale">
<property name="title">
<string>Scale</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Horizontal:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Vertical:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_20">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxHorizontalScale">
<property name="suffix">
<string notr="true">%</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 notr="true">%</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_22">
<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_13">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string notr="true">&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 notr="true">...</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_14">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">&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>
<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>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBoxLayoutExport"> <widget class="QGroupBox" name="groupBoxLayoutExport">
<property name="title"> <property name="title">

View File

@ -83,16 +83,23 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
QPen penTileDrawing = QPen(Qt::black, m_commonSettings->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, QPen penTileDrawing = QPen(Qt::black, m_commonSettings->WidthMainLine(), Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin); Qt::RoundJoin);
painter->setPen(penTileDrawing);
// paint the content of the page // paint the content of the page
QRectF source = QRectF(col*m_drawingAreaWidth, qreal xScale = layout->LayoutSettings().HorizontalScale();
qreal yScale = layout->LayoutSettings().VerticalScale();
QRectF source = QRectF(col*m_drawingAreaWidth / xScale,
row*m_drawingAreaHeight / yScale,
m_drawingAreaWidth / xScale + m_infoStripeWidth,
m_drawingAreaHeight / yScale + m_infoStripeWidth
);
QRectF target = QRectF(col*m_drawingAreaWidth,
row*m_drawingAreaHeight, row*m_drawingAreaHeight,
m_drawingAreaWidth + m_infoStripeWidth, m_drawingAreaWidth + m_infoStripeWidth,
m_drawingAreaHeight + m_infoStripeWidth m_drawingAreaHeight + m_infoStripeWidth
); );
sheet->SceneData()->Scene()->render(painter, VPrintLayout::SceneTargetRect(printer, target), source,
painter->setPen(penTileDrawing);
sheet->SceneData()->Scene()->render(painter, VPrintLayout::SceneTargetRect(printer, source), source,
Qt::IgnoreAspectRatio); Qt::IgnoreAspectRatio);
QScopedPointer<QSvgRenderer> svgRenderer(new QSvgRenderer()); QScopedPointer<QSvgRenderer> svgRenderer(new QSvgRenderer());
@ -306,8 +313,16 @@ auto VPTileFactory::RowNb(const VPSheetPtr &sheet) const -> int
{ {
return 0; return 0;
} }
qreal yScale = 1;
VPLayoutPtr layout = m_layout.toStrongRef();
if(not layout.isNull())
{
yScale = layout->LayoutSettings().VerticalScale();
}
QSizeF sheetSize = sheet->GetSheetSize(); QSizeF sheetSize = sheet->GetSheetSize();
return qCeil(sheetSize.height() / m_drawingAreaHeight); return qCeil(sheetSize.height() * yScale / m_drawingAreaHeight);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -317,8 +332,16 @@ auto VPTileFactory::ColNb(const VPSheetPtr &sheet) const -> int
{ {
return 0; return 0;
} }
qreal xScale = 1;
VPLayoutPtr layout = m_layout.toStrongRef();
if(not layout.isNull())
{
xScale = layout->LayoutSettings().HorizontalScale();
}
QSizeF sheetSize = sheet->GetSheetSize(); QSizeF sheetSize = sheet->GetSheetSize();
return qCeil(sheetSize.width() / m_drawingAreaWidth); return qCeil(sheetSize.width() * xScale / m_drawingAreaWidth);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -242,7 +242,8 @@ void VPLayoutFileReader::ReadProperties(const VPLayoutPtr &layout)
ML::TagTitle, // 1 ML::TagTitle, // 1
ML::TagDescription, // 2 ML::TagDescription, // 2
ML::TagControl, // 3 ML::TagControl, // 3
ML::TagTiles // 4 ML::TagTiles, // 4
ML::TagScale // 5
}; };
while (readNextStartElement()) while (readNextStartElement())
@ -271,6 +272,10 @@ void VPLayoutFileReader::ReadProperties(const VPLayoutPtr &layout)
qDebug("read tiles"); qDebug("read tiles");
ReadTiles(layout); ReadTiles(layout);
break; break;
case 5: // scale
qDebug("read scale");
ReadScale(layout);
break;
default: default:
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString())); qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
skipCurrentElement(); skipCurrentElement();
@ -338,6 +343,18 @@ void VPLayoutFileReader::ReadTiles(const VPLayoutPtr &layout)
readElementText(); readElementText();
} }
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadScale(const VPLayoutPtr &layout)
{
AssertRootTag(ML::TagScale);
QXmlStreamAttributes attribs = attributes();
layout->LayoutSettings().SetHorizontalScale(ReadAttributeDouble(attribs, ML::AttrXScale, QChar('1')));
layout->LayoutSettings().SetVerticalScale(ReadAttributeDouble(attribs, ML::AttrYScale, QChar('1')));
readElementText();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadSheets(const VPLayoutPtr &layout) void VPLayoutFileReader::ReadSheets(const VPLayoutPtr &layout)
{ {

View File

@ -56,6 +56,7 @@ private:
void ReadProperties(const VPLayoutPtr &layout); void ReadProperties(const VPLayoutPtr &layout);
void ReadControl(const VPLayoutPtr &layout); void ReadControl(const VPLayoutPtr &layout);
void ReadTiles(const VPLayoutPtr &layout); void ReadTiles(const VPLayoutPtr &layout);
void ReadScale(const VPLayoutPtr &layout);
void ReadUnplacedPieces(const VPLayoutPtr &layout); void ReadUnplacedPieces(const VPLayoutPtr &layout);
void ReadSheets(const VPLayoutPtr &layout); void ReadSheets(const VPLayoutPtr &layout);
void ReadSheet(const VPLayoutPtr &layout); void ReadSheet(const VPLayoutPtr &layout);

View File

@ -179,6 +179,11 @@ void VPLayoutFileWriter::WriteLayoutProperties(const VPLayoutPtr &layout)
WriteTiles(layout); WriteTiles(layout);
writeStartElement(ML::TagScale);
SetAttribute(ML::AttrXScale, layout->LayoutSettings().HorizontalScale());
SetAttribute(ML::AttrYScale, layout->LayoutSettings().VerticalScale());
writeEndElement(); // scale
writeEndElement(); // properties writeEndElement(); // properties
} }

View File

@ -58,6 +58,7 @@ const QString TagPieceLabel = QStringLiteral("pieceLabel");
const QString TagPatternLabel = QStringLiteral("patternLabel"); const QString TagPatternLabel = QStringLiteral("patternLabel");
const QString TagLines = QStringLiteral("lines"); const QString TagLines = QStringLiteral("lines");
const QString TagLine = QStringLiteral("line"); const QString TagLine = QStringLiteral("line");
const QString TagScale = QStringLiteral("scale");
const QString AttrVersion = QStringLiteral("version"); const QString AttrVersion = QStringLiteral("version");
const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition"); const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition");
@ -98,6 +99,8 @@ const QString AttrAlignment = QStringLiteral("alignment");
const QString AttrGradationLabel = QStringLiteral("gradationLabel"); const QString AttrGradationLabel = QStringLiteral("gradationLabel");
const QString AttrCopyNumber = QStringLiteral("copyNumber"); const QString AttrCopyNumber = QStringLiteral("copyNumber");
const QString AttrGrainlineType = QStringLiteral("grainlineType"); const QString AttrGrainlineType = QStringLiteral("grainlineType");
const QString AttrXScale = QStringLiteral("xScale");
const QString AttrYScale = QStringLiteral("yScale");
const QString atFrontStr = QStringLiteral("atFront"); const QString atFrontStr = QStringLiteral("atFront");
const QString atRearStr = QStringLiteral("atRear"); const QString atRearStr = QStringLiteral("atRear");

View File

@ -63,6 +63,7 @@ extern const QString TagPieceLabel;
extern const QString TagPatternLabel; extern const QString TagPatternLabel;
extern const QString TagLines; extern const QString TagLines;
extern const QString TagLine; extern const QString TagLine;
extern const QString TagScale;
extern const QString AttrVersion; extern const QString AttrVersion;
extern const QString AttrWarningSuperposition; extern const QString AttrWarningSuperposition;
@ -103,6 +104,8 @@ extern const QString AttrAlignment;
extern const QString AttrGradationLabel; extern const QString AttrGradationLabel;
extern const QString AttrCopyNumber; extern const QString AttrCopyNumber;
extern const QString AttrGrainlineType; extern const QString AttrGrainlineType;
extern const QString AttrXScale;
extern const QString AttrYScale;
extern const QString atFrontStr; extern const QString atFrontStr;
extern const QString atRearStr; extern const QString atRearStr;

View File

@ -39,6 +39,12 @@
<xs:attribute type="xs:string" name="matchingMarks"/> <xs:attribute type="xs:string" name="matchingMarks"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="scale">
<xs:complexType>
<xs:attribute type="LayoutScale" name="xScale"/>
<xs:attribute type="LayoutScale" name="yScale"/>
</xs:complexType>
</xs:element>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
@ -489,4 +495,10 @@
<xs:enumeration value="notFixed"/> <xs:enumeration value="notFixed"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
<xs:simpleType name="LayoutScale">
<xs:restriction base="xs:float">
<xs:minInclusive value="0.01"/>
<xs:maxInclusive value="3"/>
</xs:restriction>
</xs:simpleType>
</xs:schema> </xs:schema>