54 #include <QGraphicsLineItem>
55 #include <QGraphicsPixmapItem>
56 #include <QGraphicsTextItem>
66 #include "../vmisc/vmath.h"
67 #include "../vmisc/def.h"
71 :printer(printer), allowance(static_cast<quint32>(qRound(10./25.4*
PrintDPI)))
85 const int rows =
CountRows(imageRect.height(), orientation);
86 const int columns =
CountColumns(imageRect.width(), orientation);
88 for (
int i=0; i < rows; i++)
90 for (
int j=0; j< columns; j++)
93 data.
index =
static_cast<quint32
>(page);
94 data.
rows =
static_cast<quint32
>(rows);
95 data.
columns =
static_cast<quint32
>(columns);
107 QPen pen(Qt::NoBrush, 1, Qt::DashLine);
108 pen.setColor(Qt::black);
110 const QRect rec = img.
rect;
113 auto *line =
new QGraphicsLineItem(parent);
115 line->setLine(rec.x(), rec.y(), rec.x(), rec.y() + rec.height());
118 auto *scissors =
new QGraphicsPixmapItem(QPixmap(
"://scissors_vertical.png"), parent);
119 scissors->setPos(rec.x(), rec.y() + rec.height()-
static_cast<int>(
allowance));
120 data.append(scissors);
125 auto *line =
new QGraphicsLineItem(parent);
127 line->setLine(rec.x() + rec.width()-
static_cast<int>(
allowance), rec.y(),
128 rec.x() + rec.width()-
static_cast<int>(
allowance), rec.y() + rec.height());
134 auto *line =
new QGraphicsLineItem(parent);
136 line->setLine(rec.x(), rec.y(), rec.x() + rec.width(), rec.y());
139 auto *scissors =
new QGraphicsPixmapItem(QPixmap(
"://scissors_horizontal.png"), parent);
140 scissors->setPos(rec.x() + rec.width()-
static_cast<int>(
allowance), rec.y());
141 data.append(scissors);
147 auto *line =
new QGraphicsLineItem(parent);
149 line->setLine(rec.x(), rec.y() + rec.height()-
static_cast<int>(
allowance),
150 rec.x() + rec.width(), rec.y() + rec.height()-
static_cast<int>(
allowance));
155 auto *scissors =
new QGraphicsPixmapItem(QPixmap(
"://scissors_horizontal.png"), parent);
156 scissors->setPos(rec.x() + rec.width()-
static_cast<int>(
allowance),
157 rec.y() + rec.height()-
static_cast<int>(
allowance));
158 data.append(scissors);
163 auto *labels =
new QGraphicsTextItem(parent);
165 const int layoutX = 15;
166 const int layoutY = 5;
167 labels->setPos(rec.x() + layoutX, rec.y() + rec.height()-
static_cast<int>(
allowance)+layoutY);
168 labels->setTextWidth(rec.width()-(
static_cast<int>(
allowance)+layoutX));
170 const QString grid = tr(
"Grid ( %1 , %2 )").arg(img.
row+1).arg(img.
column+1);
176 sheet = tr(
"Sheet %1 of %2").arg(img.
index+1).arg(sheets);
179 labels->setHtml(QString(
"<table width='100%'>"
181 "<td>%1</td><td align='center'>%2</td><td align='right'>%3</td>"
184 .arg(grid, page, sheet));
194 const qreal imgLength = height;
195 qreal pageLength = 0;
235 return qCeil(imgLength/(pageLength -
static_cast<int>(
allowance)));
241 const qreal imgLength = width;
242 qreal pageLength = 0;
262 return qCeil(imgLength/(pageLength-
static_cast<int>(
allowance)));
270 int pageLengthX, pageLengthY;
283 const int x = j*pageLengthX - j*
static_cast<int>(
allowance);
284 const int y = i*pageLengthY - i*
static_cast<int>(
allowance);
290 data.
row =
static_cast<quint32
>(i);
291 data.column =
static_cast<quint32
>(j);
292 data.rect = QRect(x, y, pageLengthX, pageLengthY);
303 const QRectF rect =
printer->pageRect(QPrinter::Millimeter);
307 QMarginsF pMargins =
printer->pageLayout().margins();
308 QRectF newRect = rect.marginsRemoved(pMargins);
309 const QRect pageRectFP(0, 0, qFloor(
ToPixel(newRect.width())), qFloor(
ToPixel(newRect.height())));
314 const QRect pageRect(0, 0, qFloor(
ToPixel(rect.width())), qFloor(
ToPixel(rect.height())));
QVector< PosterData > Calc(const QRect &imageRect, int page, PageOrientation orientation) const
int CountColumns(int width, PageOrientation orientation) const
quint32 allowance
allowance is the width of the strip that holds the tiled grid information and that is used for the gl...
VPoster(const QPrinter *printer)
PosterData Cut(int i, int j, const QRect &imageRect, PageOrientation orientation) const
QVector< QGraphicsItem * > Borders(QGraphicsItem *parent, const PosterData &img, int sheets) const
static qreal ToPixel(qreal val)
int CountRows(int height, PageOrientation orientation) const