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