mirror of
https://gitlab.com/smart-pattern/valentina.git
synced 2024-09-08 01:54:37 +02:00
Compare commits
3 commits
8c3de72a51
...
7d276461ed
Author | SHA1 | Date | |
---|---|---|---|
|
7d276461ed | ||
|
94a2bcb005 | ||
|
5f8b46da5b |
|
@ -18,6 +18,7 @@
|
|||
- Support for options Force Flipping and Forbid Flipping in Puzzle.
|
||||
- Remember selected dimension values.
|
||||
- Fix segmenting a simple curve.
|
||||
- Fix export tiled pdf on Mac OS.
|
||||
|
||||
# Valentina 0.7.51 April 18, 2022
|
||||
- Z value change for a layout piece.
|
||||
|
|
|
@ -134,12 +134,8 @@ auto VPLayoutSettings::GetTilesSize() const -> QSizeF
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPLayoutSettings::GetTilesSize(Unit unit) const -> QSizeF
|
||||
{
|
||||
QSizeF convertedSize = QSizeF(
|
||||
UnitConvertor(m_tilesSize.width(), Unit::Px, unit),
|
||||
UnitConvertor(m_tilesSize.height(), Unit::Px, unit)
|
||||
);
|
||||
|
||||
return convertedSize;
|
||||
return {UnitConvertor(m_tilesSize.width(), Unit::Px, unit),
|
||||
UnitConvertor(m_tilesSize.height(), Unit::Px, unit)};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -2574,7 +2574,10 @@ void VPMainWindow::ExportPdfTiledFile(const VPExportData &data)
|
|||
bool firstPage = true;
|
||||
for (const auto& sheet : data.sheets)
|
||||
{
|
||||
GeneratePdfTiledFile(sheet, data.showTilesScheme, &painter, printer, firstPage);
|
||||
if (not GeneratePdfTiledFile(sheet, data.showTilesScheme, &painter, printer, firstPage))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2589,14 +2592,17 @@ void VPMainWindow::ExportPdfTiledFile(const VPExportData &data)
|
|||
|
||||
QPainter painter;
|
||||
bool firstPage = true;
|
||||
GeneratePdfTiledFile(data.sheets.at(i), data.showTilesScheme, &painter, printer, firstPage);
|
||||
if (not GeneratePdfTiledFile(data.sheets.at(i), data.showTilesScheme, &painter, printer, firstPage))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesScheme, QPainter *painter,
|
||||
const QSharedPointer<QPrinter> &printer, bool &firstPage)
|
||||
auto VPMainWindow::GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesScheme, QPainter *painter,
|
||||
const QSharedPointer<QPrinter> &printer, bool &firstPage) -> bool
|
||||
{
|
||||
SCASSERT(not sheet.isNull())
|
||||
SCASSERT(painter != nullptr)
|
||||
|
@ -2621,7 +2627,7 @@ void VPMainWindow::GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesS
|
|||
if (not painter->begin(printer.data()))
|
||||
{ // failed to open file
|
||||
qCritical() << tr("Failed to open file, is it writable?");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
painter->setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthMainLine(), Qt::SolidLine,
|
||||
|
@ -2634,7 +2640,7 @@ void VPMainWindow::GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesS
|
|||
{
|
||||
if (not DrawTilesScheme(printer.data(), painter, sheet, firstPage))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
firstPage = false;
|
||||
}
|
||||
|
@ -2651,7 +2657,7 @@ void VPMainWindow::GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesS
|
|||
if (not printer->newPage())
|
||||
{
|
||||
qWarning("failed in flushing page to disk, disk full?");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2662,6 +2668,8 @@ void VPMainWindow::GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesS
|
|||
}
|
||||
|
||||
sheet->SceneData()->CleanAfterExport();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -2770,8 +2778,9 @@ auto VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const V
|
|||
target = QRectF(0, 0, width, height);
|
||||
}
|
||||
|
||||
sheet->SceneData()->Scene()->render(painter, VPrintLayout::SceneTargetRect(printer, target), source,
|
||||
Qt::KeepAspectRatio);
|
||||
target = VPrintLayout::SceneTargetRect(printer, target);
|
||||
|
||||
sheet->SceneData()->Scene()->render(painter, target, source, Qt::KeepAspectRatio);
|
||||
|
||||
VWatermarkData watermarkData = m_layout->TileFactory()->WatermarkData();
|
||||
if (watermarkData.opacity > 0)
|
||||
|
|
|
@ -479,8 +479,8 @@ private:
|
|||
static void ExportUnifiedPdfFile(const VPExportData &data);
|
||||
static void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name);
|
||||
void ExportPdfTiledFile(const VPExportData &data);
|
||||
void GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesScheme, QPainter *painter,
|
||||
const QSharedPointer<QPrinter> &printer, bool &firstPage);
|
||||
auto GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesScheme, QPainter *painter,
|
||||
const QSharedPointer<QPrinter> &printer, bool &firstPage) -> bool;
|
||||
|
||||
void UpdateScaleConnection() const;
|
||||
|
||||
|
|
|
@ -174,6 +174,11 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
|
|||
// add the tiles decorations (cutting and gluing lines, scissors, infos etc.)
|
||||
painter->setPen(PenTileInfos());
|
||||
|
||||
painter->save();
|
||||
|
||||
const QPair<qreal, qreal> scale = VPrintLayout::PrinterScaleDiff(printer);
|
||||
painter->scale(scale.first, scale.second);
|
||||
|
||||
if(row > 0)
|
||||
{
|
||||
// add top triangle
|
||||
|
@ -217,7 +222,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
|
|||
DrawSolidBottomLine(painter, col, nbCol);
|
||||
}
|
||||
|
||||
DrawRuler(painter);
|
||||
DrawRuler(painter, scale.first);
|
||||
DrawWatermark(painter);
|
||||
|
||||
if(col < nbCol-1)
|
||||
|
@ -235,6 +240,8 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
|
|||
|
||||
// prepare the painting for the text information
|
||||
DrawTextInformation(painter, row, col, nbRow, nbCol, sheet->GetName());
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -294,7 +301,7 @@ auto VPTileFactory::WatermarkData() const -> const VWatermarkData &
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPTileFactory::DrawRuler(QPainter *painter) const
|
||||
void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const
|
||||
{
|
||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||
if(layout.isNull())
|
||||
|
@ -330,15 +337,21 @@ void VPTileFactory::DrawRuler(QPainter *painter) const
|
|||
}
|
||||
else
|
||||
{
|
||||
QString units = rulerUnits != Unit::Inch ? tr("cm", "unit") : tr("in", "unit");
|
||||
painter->save();
|
||||
|
||||
QFont fnt = painter->font();
|
||||
fnt.setPointSize(10);
|
||||
const int size = qRound(10/scale);
|
||||
size > 0 ? fnt.setPointSize(size) : fnt.setPointSize(10);
|
||||
painter->setFont(fnt);
|
||||
|
||||
qreal unitsWidth = 0;
|
||||
QFontMetrics fm(fnt);
|
||||
QString units = rulerUnits != Unit::Inch ? tr("cm", "unit") : tr("in", "unit");
|
||||
unitsWidth = TextWidth(fm, units);
|
||||
painter->drawText(QPointF(step*0.5-unitsWidth*0.6,
|
||||
m_drawingAreaHeight - tileStripeWidth + notchHeight+shortNotchHeight), units);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ private:
|
|||
|
||||
VWatermarkData m_watermarkData{};
|
||||
|
||||
void DrawRuler(QPainter *painter) const;
|
||||
void DrawRuler(QPainter *painter, qreal scale) const;
|
||||
void DrawWatermark(QPainter *painter) const;
|
||||
|
||||
auto PenTileInfos() const -> QPen;
|
||||
|
|
|
@ -750,7 +750,7 @@ auto VPrintLayout::ContinueIfLayoutStale(QWidget *parent) -> int
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VPrintLayout::SceneTargetRect(QPrinter *printer, const QRectF &source)
|
||||
auto VPrintLayout::SceneTargetRect(QPrinter *printer, const QRectF &source) -> QRectF
|
||||
{
|
||||
SCASSERT(printer != nullptr)
|
||||
|
||||
|
@ -769,6 +769,18 @@ QRectF VPrintLayout::SceneTargetRect(QPrinter *printer, const QRectF &source)
|
|||
x = 0; y = 0;
|
||||
}
|
||||
|
||||
QPair<qreal, qreal> scaleDiff = PrinterScaleDiff(printer);
|
||||
const double xscale = scaleDiff.first;
|
||||
const double yscale = scaleDiff.second;
|
||||
|
||||
return {x * xscale, y * yscale, source.width() * xscale, source.height() * yscale};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPrintLayout::PrinterScaleDiff(QPrinter *printer) -> QPair<qreal, qreal>
|
||||
{
|
||||
SCASSERT(printer != nullptr)
|
||||
|
||||
// Here we try understand difference between printer's dpi and our.
|
||||
// Get printer rect according to our dpi.
|
||||
const QRectF printerPageRect(0, 0, ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm),
|
||||
|
@ -777,5 +789,5 @@ QRectF VPrintLayout::SceneTargetRect(QPrinter *printer, const QRectF &source)
|
|||
const double xscale = pageRect.width() / printerPageRect.width();
|
||||
const double yscale = pageRect.height() / printerPageRect.height();
|
||||
|
||||
return QRectF(x * xscale, y * yscale, source.width() * xscale, source.height() * yscale);
|
||||
return qMakePair(xscale, yscale);
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ public:
|
|||
|
||||
static auto ContinueIfLayoutStale(QWidget *parent) -> int;
|
||||
static auto SceneTargetRect(QPrinter *printer, const QRectF &source) -> QRectF;
|
||||
static auto PrinterScaleDiff(QPrinter *printer) -> QPair<qreal, qreal>;
|
||||
|
||||
private slots:
|
||||
void PrintPages (QPrinter *printer);
|
||||
|
|
Loading…
Reference in a new issue