Fix width of a grainline on export.
This commit is contained in:
parent
2406e98350
commit
d30ca54297
|
@ -1122,12 +1122,12 @@ void MainWindowsNoGUI::ExportScene(const QList<QGraphicsScene *> &scenes,
|
|||
paper->setVisible(true);
|
||||
break;
|
||||
case LayoutExportFormats::PDF:
|
||||
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap,
|
||||
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap,
|
||||
Qt::RoundJoin));
|
||||
exporter.ExportToPDF(scene);
|
||||
break;
|
||||
case LayoutExportFormats::PNG:
|
||||
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap,
|
||||
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap,
|
||||
Qt::RoundJoin));
|
||||
exporter.ExportToPNG(scene);
|
||||
break;
|
||||
|
@ -1137,12 +1137,12 @@ void MainWindowsNoGUI::ExportScene(const QList<QGraphicsScene *> &scenes,
|
|||
paper->setVisible(true);
|
||||
break;
|
||||
case LayoutExportFormats::PS:
|
||||
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap,
|
||||
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap,
|
||||
Qt::RoundJoin));
|
||||
exporter.ExportToPS(scene);
|
||||
break;
|
||||
case LayoutExportFormats::EPS:
|
||||
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap,
|
||||
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap,
|
||||
Qt::RoundJoin));
|
||||
exporter.ExportToEPS(scene);
|
||||
break;
|
||||
|
@ -1201,7 +1201,7 @@ void MainWindowsNoGUI::ExportScene(const QList<QGraphicsScene *> &scenes,
|
|||
paper->setVisible(true);
|
||||
break;
|
||||
case LayoutExportFormats::TIF:
|
||||
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthMainLine(), Qt::SolidLine, Qt::RoundCap,
|
||||
exporter.SetPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap,
|
||||
Qt::RoundJoin));
|
||||
exporter.ExportToTIF(scene);
|
||||
break;
|
||||
|
|
|
@ -43,10 +43,12 @@ void VGraphicsFillItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*
|
|||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
painter->save();
|
||||
|
||||
QPen pen = painter->pen();
|
||||
pen.setWidthF(width);
|
||||
painter->setPen(pen);
|
||||
|
||||
painter->setBrush(painter->pen().color());
|
||||
painter->drawPath(path());
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -50,6 +50,24 @@ public:
|
|||
* @param widget unused
|
||||
*/
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
auto GetWidth() const -> qreal;
|
||||
void SetWidth(const qreal &value);
|
||||
|
||||
private:
|
||||
qreal width{1};
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline auto VGraphicsFillItem::GetWidth() const -> qreal
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VGraphicsFillItem::SetWidth(const qreal &value)
|
||||
{
|
||||
width = value;
|
||||
}
|
||||
|
||||
#endif // VGRAPHICSFILLITEM_H
|
||||
|
|
|
@ -1152,12 +1152,16 @@ QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const
|
|||
|
||||
QPen pen = pathItem->pen();
|
||||
pen.setStyle(path.PenStyle());
|
||||
pen.setWidthF(qApp->Settings()->WidthHairLine());
|
||||
pathItem->setPen(pen);
|
||||
}
|
||||
|
||||
for (auto &label : d->m_placeLabels)
|
||||
{
|
||||
QGraphicsPathItem* pathItem = new QGraphicsPathItem(item);
|
||||
QPen pen = pathItem->pen();
|
||||
pen.setWidthF(qApp->Settings()->WidthHairLine());
|
||||
pathItem->setPen(pen);
|
||||
pathItem->setPath(d->matrix.map(VPlaceLabelItem::LabelShapePath(label.shape)));
|
||||
}
|
||||
|
||||
|
@ -1322,13 +1326,14 @@ void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const
|
|||
{
|
||||
return;
|
||||
}
|
||||
VGraphicsFillItem* item = new VGraphicsFillItem(parent);
|
||||
auto* item = new VGraphicsFillItem(parent);
|
||||
item->SetWidth(qApp->Settings()->WidthHairLine());
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
QVector<QPointF> gPoints = GetGrainline();
|
||||
path.moveTo(gPoints.at(0));
|
||||
for (auto p : gPoints)
|
||||
for (auto p : qAsConst(gPoints))
|
||||
{
|
||||
path.lineTo(p);
|
||||
}
|
||||
|
@ -1352,6 +1357,9 @@ QVector<QPointF> VLayoutPiece::DetailPath() const
|
|||
QGraphicsPathItem *VLayoutPiece::GetMainItem() const
|
||||
{
|
||||
QGraphicsPathItem *item = new QGraphicsPathItem();
|
||||
QPen pen = item->pen();
|
||||
pen.setWidthF(qApp->Settings()->WidthHairLine());
|
||||
item->setPen(pen);
|
||||
item->setPath(ContourPath());
|
||||
return item;
|
||||
}
|
||||
|
@ -1360,6 +1368,9 @@ QGraphicsPathItem *VLayoutPiece::GetMainItem() const
|
|||
QGraphicsPathItem *VLayoutPiece::GetMainPathItem() const
|
||||
{
|
||||
QGraphicsPathItem *item = new QGraphicsPathItem();
|
||||
QPen pen = item->pen();
|
||||
pen.setWidthF(qApp->Settings()->WidthHairLine());
|
||||
item->setPen(pen);
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vmisc/vmath.h"
|
||||
#include "../vmisc/vabstractvalapplication.h"
|
||||
#include "global.h"
|
||||
|
||||
#include "vgrainlineitem.h"
|
||||
|
||||
|
@ -61,7 +63,6 @@ VGrainlineItem::VGrainlineItem(QGraphicsItem* pParent)
|
|||
m_polyBound(),
|
||||
m_ptStartPos(),
|
||||
m_ptStartMove(),
|
||||
m_dScale(1),
|
||||
m_polyResize(),
|
||||
m_dStartLength(0),
|
||||
m_ptStart(),
|
||||
|
@ -69,7 +70,7 @@ VGrainlineItem::VGrainlineItem(QGraphicsItem* pParent)
|
|||
m_ptCenter(),
|
||||
m_dAngle(0),
|
||||
m_eArrowType(GrainlineArrowDirection::atBoth),
|
||||
m_penWidth(LINE_PEN_WIDTH)
|
||||
m_penWidth(qApp->Settings()->WidthMainLine())
|
||||
{
|
||||
setAcceptHoverEvents(true);
|
||||
m_inactiveZ = 5;
|
||||
|
@ -105,7 +106,9 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
|
|||
Q_UNUSED(pWidget)
|
||||
pP->save();
|
||||
QColor clr = Qt::black;
|
||||
pP->setPen(QPen(clr, m_penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
|
||||
const qreal width = ScaleWidth(qApp->Settings()->WidthHairLine(), SceneScale(scene()));
|
||||
pP->setPen(QPen(clr, width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
|
||||
pP->setRenderHints(QPainter::Antialiasing);
|
||||
// line
|
||||
|
@ -114,8 +117,7 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
|
|||
|
||||
pP->setBrush(clr);
|
||||
|
||||
m_dScale = GetScale();
|
||||
qreal dArrLen = ARROW_LENGTH*m_dScale;
|
||||
qreal dArrLen = ARROW_LENGTH;
|
||||
if (m_eArrowType != GrainlineArrowDirection::atRear)
|
||||
{
|
||||
// first arrow
|
||||
|
@ -153,7 +155,7 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
|
|||
if (m_eMode == mRotate)
|
||||
{
|
||||
QPointF ptC = (m_polyBound.at(0) + m_polyBound.at(2))/2;
|
||||
qreal dRad = m_dScale * ROTATE_CIRC_R;
|
||||
qreal dRad = ROTATE_CIRC_R;
|
||||
pP->setBrush(clr);
|
||||
pP->drawEllipse(ptC, dRad, dRad);
|
||||
|
||||
|
@ -526,7 +528,7 @@ void VGrainlineItem::hoverEnterEvent(QGraphicsSceneHoverEvent *pME)
|
|||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
|
||||
m_penWidth = LINE_PEN_WIDTH + 1;
|
||||
m_penWidth = qApp->Settings()->WidthMainLine() + 1;
|
||||
}
|
||||
VPieceItem::hoverEnterEvent(pME);
|
||||
}
|
||||
|
@ -536,7 +538,7 @@ void VGrainlineItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *pME)
|
|||
{
|
||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
m_penWidth = LINE_PEN_WIDTH;
|
||||
m_penWidth = qApp->Settings()->WidthMainLine();
|
||||
}
|
||||
VPieceItem::hoverLeaveEvent(pME);
|
||||
}
|
||||
|
@ -624,29 +626,6 @@ QPointF VGrainlineItem::GetInsideCorner(int i, qreal dDist) const
|
|||
return m_polyBound.at(i) + pt1 + pt2;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetScale gets the scale for keeping the arrows of constant size
|
||||
*/
|
||||
qreal VGrainlineItem::GetScale() const
|
||||
{
|
||||
if (scene()->views().count() > 0)
|
||||
{
|
||||
const QPoint pt0 = scene()->views().at(0)->mapFromScene(0, 0);
|
||||
const QPoint pt = scene()->views().at(0)->mapFromScene(0, 100);
|
||||
const QPoint p = pt - pt0;
|
||||
qreal dScale = qSqrt(QPoint::dotProduct(p, p));
|
||||
dScale = 100.0/dScale;
|
||||
if (dScale < 1.0)
|
||||
{
|
||||
dScale = 1.0;
|
||||
}
|
||||
return dScale;
|
||||
}
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QLineF VGrainlineItem::MainLine() const
|
||||
{
|
||||
|
@ -696,7 +675,7 @@ QPainterPath VGrainlineItem::MainShape() const
|
|||
path.addPath((stroker.createStroke(linePath) + linePath).simplified());
|
||||
path.closeSubpath();
|
||||
|
||||
const qreal dArrLen = ARROW_LENGTH*GetScale();
|
||||
const qreal dArrLen = ARROW_LENGTH;
|
||||
if (m_eArrowType != GrainlineArrowDirection::atRear)
|
||||
{
|
||||
// first arrow
|
||||
|
@ -761,7 +740,7 @@ void VGrainlineItem::UpdatePolyResize()
|
|||
m_polyResize.clear();
|
||||
QPointF ptA = m_polyBound.at(1);
|
||||
m_polyResize << ptA;
|
||||
const double dSize = m_dScale * RESIZE_RECT_SIZE;
|
||||
const double dSize = RESIZE_RECT_SIZE;
|
||||
|
||||
ptA.setX(ptA.x() - dSize*cos(m_dRotation - M_PI/2));
|
||||
ptA.setY(ptA.y() + dSize*sin(m_dRotation - M_PI/2));
|
||||
|
|
|
@ -78,7 +78,6 @@ private:
|
|||
QPolygonF m_polyBound;
|
||||
QPointF m_ptStartPos;
|
||||
QPointF m_ptStartMove;
|
||||
qreal m_dScale;
|
||||
QPolygonF m_polyResize;
|
||||
qreal m_dStartLength;
|
||||
QPointF m_ptStart;
|
||||
|
@ -86,9 +85,7 @@ private:
|
|||
QPointF m_ptCenter;
|
||||
qreal m_dAngle;
|
||||
GrainlineArrowDirection m_eArrowType;
|
||||
int m_penWidth;
|
||||
|
||||
qreal GetScale() const;
|
||||
double m_penWidth{1};
|
||||
|
||||
QLineF MainLine() const;
|
||||
QPolygonF FirstArrow(qreal dArrLen) const;
|
||||
|
|
Loading…
Reference in New Issue
Block a user