Showing internal paths
This commit is contained in:
parent
a0cd4e9a31
commit
b90a99a0aa
|
@ -44,6 +44,8 @@
|
||||||
#include "vplayout.h"
|
#include "vplayout.h"
|
||||||
#include "vpsheet.h"
|
#include "vpsheet.h"
|
||||||
|
|
||||||
|
#include "vlayoutpiecepath.h"
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece")
|
Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece")
|
||||||
|
|
||||||
|
@ -54,6 +56,8 @@ VPGraphicsPiece::VPGraphicsPiece(VPPiece *piece, QGraphicsItem *parent) :
|
||||||
m_cuttingLine(QPainterPath()),
|
m_cuttingLine(QPainterPath()),
|
||||||
m_seamLine(QPainterPath()),
|
m_seamLine(QPainterPath()),
|
||||||
m_grainline(QPainterPath()),
|
m_grainline(QPainterPath()),
|
||||||
|
m_internalPaths(QVector<QPainterPath>()),
|
||||||
|
m_internalPathsPenStyle(QVector<Qt::PenStyle>()),
|
||||||
m_rotationStartPoint(QPointF())
|
m_rotationStartPoint(QPointF())
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
@ -78,7 +82,7 @@ void VPGraphicsPiece::Init()
|
||||||
if(!seamLinePoints.isEmpty())
|
if(!seamLinePoints.isEmpty())
|
||||||
{
|
{
|
||||||
m_seamLine.moveTo(seamLinePoints.first());
|
m_seamLine.moveTo(seamLinePoints.first());
|
||||||
for (int i = 1; i < seamLinePoints.size(); ++i)
|
for (int i = 0; i < seamLinePoints.size(); i++)
|
||||||
m_seamLine.lineTo(seamLinePoints.at(i));
|
m_seamLine.lineTo(seamLinePoints.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +91,7 @@ void VPGraphicsPiece::Init()
|
||||||
if(!cuttingLinepoints.isEmpty())
|
if(!cuttingLinepoints.isEmpty())
|
||||||
{
|
{
|
||||||
m_cuttingLine.moveTo(cuttingLinepoints.first());
|
m_cuttingLine.moveTo(cuttingLinepoints.first());
|
||||||
for (int i = 1; i < cuttingLinepoints.size(); ++i)
|
for (int i = 0; i < cuttingLinepoints.size(); i++)
|
||||||
m_cuttingLine.lineTo(cuttingLinepoints.at(i));
|
m_cuttingLine.lineTo(cuttingLinepoints.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +102,21 @@ void VPGraphicsPiece::Init()
|
||||||
if(!grainLinepoints.isEmpty())
|
if(!grainLinepoints.isEmpty())
|
||||||
{
|
{
|
||||||
m_grainline.moveTo(grainLinepoints.first());
|
m_grainline.moveTo(grainLinepoints.first());
|
||||||
for (int i = 1; i < grainLinepoints.size(); ++i)
|
for (int i = 0; i < grainLinepoints.size(); i++)
|
||||||
m_grainline.lineTo(grainLinepoints.at(i));
|
m_grainline.lineTo(grainLinepoints.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialises the internal paths
|
||||||
|
QVector<VLayoutPiecePath> internalPaths = m_piece->GetInternalPaths();
|
||||||
|
for (int i = 0; i < internalPaths.size(); i++)
|
||||||
|
{
|
||||||
|
VLayoutPiecePath piecePath = internalPaths.at(i);
|
||||||
|
QPainterPath path = m_piece->GetMatrix().map(piecePath.GetPainterPath());
|
||||||
|
m_internalPaths.append(path);
|
||||||
|
m_internalPathsPenStyle.append(piecePath.PenStyle());
|
||||||
|
}
|
||||||
|
|
||||||
// TODO : initialises the other elements labels, passmarks etc.
|
// TODO : initialises the other elements labels, passmarks etc.
|
||||||
|
|
||||||
// Initialises the connectors
|
// Initialises the connectors
|
||||||
|
@ -149,9 +163,11 @@ void VPGraphicsPiece::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||||
QPen pen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
QPen pen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||||||
QBrush noBrush(Qt::NoBrush);
|
QBrush noBrush(Qt::NoBrush);
|
||||||
QBrush selectionBrush(QColor(255,160,160,60));
|
QBrush selectionBrush(QColor(255,160,160,60));
|
||||||
|
QBrush blackBrush(Qt::black);
|
||||||
|
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
|
|
||||||
|
// selection
|
||||||
if(isSelected())
|
if(isSelected())
|
||||||
{
|
{
|
||||||
painter->setBrush(selectionBrush);
|
painter->setBrush(selectionBrush);
|
||||||
|
@ -179,8 +195,27 @@ void VPGraphicsPiece::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||||
// paint the grainline
|
// paint the grainline
|
||||||
if(!m_grainline.isEmpty())
|
if(!m_grainline.isEmpty())
|
||||||
{
|
{
|
||||||
|
painter->setBrush(blackBrush);
|
||||||
painter->drawPath(m_grainline);
|
painter->drawPath(m_grainline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// paint the internal paths
|
||||||
|
painter->setBrush(noBrush);
|
||||||
|
if(!m_internalPaths.isEmpty())
|
||||||
|
{
|
||||||
|
Qt::PenStyle penStyleTmp = pen.style();
|
||||||
|
|
||||||
|
for (int i = 0; i < m_internalPaths.size(); i++)
|
||||||
|
{
|
||||||
|
painter->setPen(m_internalPathsPenStyle.at(i));
|
||||||
|
painter->drawPath(m_internalPaths.at(i));
|
||||||
|
}
|
||||||
|
pen.setStyle(penStyleTmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// when using m_piece->GetItem(), the results were quite bad
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -98,8 +98,10 @@ private:
|
||||||
QPainterPath m_seamLine;
|
QPainterPath m_seamLine;
|
||||||
QPainterPath m_grainline;
|
QPainterPath m_grainline;
|
||||||
|
|
||||||
QPointF m_rotationStartPoint;
|
QVector<QPainterPath> m_internalPaths;
|
||||||
|
QVector<Qt::PenStyle> m_internalPathsPenStyle;
|
||||||
|
|
||||||
|
QPointF m_rotationStartPoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VPGRAPHICSPIECE_H
|
#endif // VPGRAPHICSPIECE_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user