Refactor triangle position marks for tiled pdf
This commit is contained in:
parent
dd5970f8ba
commit
cdff123231
|
@ -74,66 +74,31 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
|
|
||||||
QSvgRenderer* svgRenderer = new QSvgRenderer();
|
QSvgRenderer* svgRenderer = new QSvgRenderer();
|
||||||
|
|
||||||
// FIXME here instead of creating 4 triangle, maybe create one and rotate it
|
// ------------- prepare triangles for position marks
|
||||||
|
QRectF rectBasic = QRectF(-UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
||||||
// ------------- prepare triangles for positioning
|
0,
|
||||||
|
|
||||||
// top triangle
|
|
||||||
QRectF rectTop = QRectF(tilesMargins.left()+ m_drawingAreaWidth/2 - UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
|
||||||
tilesMargins.top(),
|
|
||||||
UnitConvertor(1, Unit::Cm, Unit::Px),
|
UnitConvertor(1, Unit::Cm, Unit::Px),
|
||||||
UnitConvertor(0.5, Unit::Cm, Unit::Px)
|
UnitConvertor(0.5, Unit::Cm, Unit::Px)
|
||||||
);
|
);
|
||||||
QPainterPath triangleTop;
|
QPainterPath triangleBasic;
|
||||||
triangleTop.moveTo(rectTop.topLeft());
|
triangleBasic.moveTo(rectBasic.topLeft());
|
||||||
triangleTop.lineTo(rectTop.topRight());
|
triangleBasic.lineTo(rectBasic.topRight());
|
||||||
triangleTop.lineTo(rectTop.left() + (rectTop.width() / 2), rectTop.bottom());
|
triangleBasic.lineTo(rectBasic.left() + (rectBasic.width() / 2), rectBasic.bottom());
|
||||||
triangleTop.lineTo(rectTop.topLeft());
|
triangleBasic.lineTo(rectBasic.topLeft());
|
||||||
|
|
||||||
// left triangle
|
|
||||||
QRectF rectLeft = QRectF(tilesMargins.left(),
|
|
||||||
tilesMargins.top() + m_drawingAreaHeight/2 - UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
|
||||||
UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
|
||||||
UnitConvertor(1, Unit::Cm, Unit::Px)
|
|
||||||
);
|
|
||||||
QPainterPath triangleLeft;
|
|
||||||
triangleLeft.moveTo(rectLeft.topLeft());
|
|
||||||
triangleLeft.lineTo(rectLeft.right(), rectLeft.top() + (rectLeft.height() / 2));
|
|
||||||
triangleLeft.lineTo(rectLeft.bottomLeft());
|
|
||||||
triangleLeft.lineTo(rectLeft.topLeft());
|
|
||||||
|
|
||||||
// bottom triangle
|
|
||||||
QRectF rectBottom = QRectF(tilesMargins.left()+ m_drawingAreaWidth/2 - UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
|
||||||
tilesMargins.top()+m_drawingAreaHeight - UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
|
||||||
UnitConvertor(1, Unit::Cm, Unit::Px),
|
|
||||||
UnitConvertor(0.5, Unit::Cm, Unit::Px)
|
|
||||||
);
|
|
||||||
QPainterPath triangleBottom;
|
|
||||||
triangleBottom.moveTo(rectBottom.bottomLeft());
|
|
||||||
triangleBottom.lineTo(rectBottom.left() + (rectBottom.width() / 2), rectBottom.top());
|
|
||||||
triangleBottom.lineTo(rectBottom.bottomRight());
|
|
||||||
triangleBottom.lineTo(rectBottom.bottomLeft());
|
|
||||||
|
|
||||||
// right triangle
|
|
||||||
QRectF rectRight = QRectF(tilesMargins.left() + m_drawingAreaWidth - UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
|
||||||
tilesMargins.top() + m_drawingAreaHeight/2 - UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
|
||||||
UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
|
||||||
UnitConvertor(1, Unit::Cm, Unit::Px)
|
|
||||||
);
|
|
||||||
QPainterPath triangleRight;
|
|
||||||
triangleRight.moveTo(rectRight.topRight());
|
|
||||||
triangleRight.lineTo(rectRight.bottomRight());
|
|
||||||
triangleRight.lineTo(rectRight.left(), rectRight.top() + (rectRight.height() / 2));
|
|
||||||
triangleRight.lineTo(rectRight.topRight());
|
|
||||||
|
|
||||||
QBrush triangleBush = QBrush(QColor(200,200,200));
|
QBrush triangleBush = QBrush(QColor(200,200,200));
|
||||||
|
|
||||||
|
|
||||||
// add the tiles decorations (cutting and gluing lines, scissors, infos etc.)
|
// add the tiles decorations (cutting and gluing lines, scissors, infos etc.)
|
||||||
painter->setPen(penTileInfos);
|
painter->setPen(penTileInfos);
|
||||||
|
|
||||||
if(row > 0)
|
if(row > 0)
|
||||||
{
|
{
|
||||||
// add top triangle
|
// add top triangle
|
||||||
|
QPainterPath triangleTop =
|
||||||
|
QTransform()
|
||||||
|
.translate(tilesMargins.left()+m_drawingAreaWidth/2, tilesMargins.top())
|
||||||
|
.map(triangleBasic);
|
||||||
painter->fillPath(triangleTop, triangleBush);
|
painter->fillPath(triangleTop, triangleBush);
|
||||||
|
|
||||||
// scissors along the top line
|
// scissors along the top line
|
||||||
|
@ -168,6 +133,11 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
if(col > 0)
|
if(col > 0)
|
||||||
{
|
{
|
||||||
// add left triangle
|
// add left triangle
|
||||||
|
QPainterPath triangleLeft =
|
||||||
|
QTransform()
|
||||||
|
.translate(tilesMargins.left(), tilesMargins.top()+ m_drawingAreaHeight/2)
|
||||||
|
.rotate(-90)
|
||||||
|
.map(triangleBasic);
|
||||||
painter->fillPath(triangleLeft, triangleBush);
|
painter->fillPath(triangleLeft, triangleBush);
|
||||||
|
|
||||||
// scissors along the left line
|
// scissors along the left line
|
||||||
|
@ -202,6 +172,12 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
if(row < m_nbRow-1)
|
if(row < m_nbRow-1)
|
||||||
{
|
{
|
||||||
// add bottom triangle
|
// add bottom triangle
|
||||||
|
QPainterPath triangleBottom =
|
||||||
|
QTransform()
|
||||||
|
.translate(tilesMargins.left()+ m_drawingAreaWidth/2, tilesMargins.top()+ m_drawingAreaHeight)
|
||||||
|
.rotate(180)
|
||||||
|
.map(triangleBasic);
|
||||||
|
|
||||||
painter->fillPath(triangleBottom, triangleBush);
|
painter->fillPath(triangleBottom, triangleBush);
|
||||||
|
|
||||||
// dotted bottom line (for glueing)
|
// dotted bottom line (for glueing)
|
||||||
|
@ -227,6 +203,11 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
if(col < m_nbCol-1)
|
if(col < m_nbCol-1)
|
||||||
{
|
{
|
||||||
// add right triangle
|
// add right triangle
|
||||||
|
QPainterPath triangleRight =
|
||||||
|
QTransform()
|
||||||
|
.translate(tilesMargins.left()+ m_drawingAreaWidth, tilesMargins.top()+ m_drawingAreaHeight/2)
|
||||||
|
.rotate(90)
|
||||||
|
.map(triangleBasic);
|
||||||
painter->fillPath(triangleRight, triangleBush);
|
painter->fillPath(triangleRight, triangleBush);
|
||||||
|
|
||||||
// dotted right line (for glueing)
|
// dotted right line (for glueing)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user