Optimize tool piece visualization.
--HG-- branch : develop
This commit is contained in:
parent
016883110f
commit
a0643e5712
|
@ -37,7 +37,11 @@ VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
|
||||||
m_points(),
|
m_points(),
|
||||||
m_line1(nullptr),
|
m_line1(nullptr),
|
||||||
m_line2(nullptr),
|
m_line2(nullptr),
|
||||||
m_piece()
|
m_piece(),
|
||||||
|
m_pieceCached(false),
|
||||||
|
m_cachedMainPath(),
|
||||||
|
m_cachedNodes(),
|
||||||
|
m_cachedMainPathPoints()
|
||||||
{
|
{
|
||||||
m_line1 = InitItem<VScaledLine>(supportColor, this);
|
m_line1 = InitItem<VScaledLine>(supportColor, this);
|
||||||
m_line2 = InitItem<VScaledLine>(supportColor, this);
|
m_line2 = InitItem<VScaledLine>(supportColor, this);
|
||||||
|
@ -50,24 +54,34 @@ void VisToolPiece::RefreshGeometry()
|
||||||
|
|
||||||
if (m_piece.GetPath().CountNodes() > 0)
|
if (m_piece.GetPath().CountNodes() > 0)
|
||||||
{
|
{
|
||||||
DrawPath(this, m_piece.MainPathPath(Visualization::data), mainColor, Qt::SolidLine, Qt::RoundCap);
|
if (not m_pieceCached)
|
||||||
|
{
|
||||||
|
m_cachedMainPath = m_piece.MainPathPath(Visualization::data);
|
||||||
|
m_cachedNodes = m_piece.MainPathNodePoints(Visualization::data);
|
||||||
|
if (mode == Mode::Creation)
|
||||||
|
{
|
||||||
|
m_cachedMainPathPoints = m_piece.MainPathPoints(Visualization::data);
|
||||||
|
}
|
||||||
|
m_pieceCached = true;
|
||||||
|
}
|
||||||
|
|
||||||
const QVector<VPointF> nodes = m_piece.MainPathNodePoints(Visualization::data);
|
DrawPath(this, m_cachedMainPath, mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||||
|
|
||||||
for (int i = 0; i < nodes.size(); ++i)
|
for (int i = 0; i < m_cachedNodes.size(); ++i)
|
||||||
{
|
{
|
||||||
VScaledEllipse *point = GetPoint(static_cast<quint32>(i), supportColor);
|
VScaledEllipse *point = GetPoint(static_cast<quint32>(i), supportColor);
|
||||||
DrawPoint(point, nodes.at(i).toQPointF(), supportColor);
|
DrawPoint(point, m_cachedNodes.at(i).toQPointF(), supportColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == Mode::Creation)
|
if (mode == Mode::Creation)
|
||||||
{
|
{
|
||||||
const QVector<QPointF> points = m_piece.MainPathPoints(Visualization::data);
|
DrawLine(m_line1, QLineF(m_cachedMainPathPoints.first(), Visualization::scenePos), supportColor,
|
||||||
DrawLine(m_line1, QLineF(points.first(), Visualization::scenePos), supportColor, Qt::DashLine);
|
Qt::DashLine);
|
||||||
|
|
||||||
if (points.size() > 1)
|
if (m_cachedMainPathPoints.size() > 1)
|
||||||
{
|
{
|
||||||
DrawLine(m_line2, QLineF(points.last(), Visualization::scenePos), supportColor, Qt::DashLine);
|
DrawLine(m_line2, QLineF(m_cachedMainPathPoints.last(), Visualization::scenePos), supportColor,
|
||||||
|
Qt::DashLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +91,7 @@ void VisToolPiece::RefreshGeometry()
|
||||||
void VisToolPiece::SetPiece(const VPiece &piece)
|
void VisToolPiece::SetPiece(const VPiece &piece)
|
||||||
{
|
{
|
||||||
m_piece = piece;
|
m_piece = piece;
|
||||||
|
m_pieceCached = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
#include "vispath.h"
|
#include "vispath.h"
|
||||||
#include "../vpatterndb/vpiece.h"
|
#include "../vpatterndb/vpiece.h"
|
||||||
|
#include "../vgeometry/vpointf.h"
|
||||||
|
|
||||||
class VisToolPiece : public VisPath
|
class VisToolPiece : public VisPath
|
||||||
{
|
{
|
||||||
|
@ -53,6 +54,10 @@ private:
|
||||||
VScaledLine *m_line1;
|
VScaledLine *m_line1;
|
||||||
VScaledLine *m_line2;
|
VScaledLine *m_line2;
|
||||||
VPiece m_piece;
|
VPiece m_piece;
|
||||||
|
bool m_pieceCached;
|
||||||
|
QPainterPath m_cachedMainPath;
|
||||||
|
QVector<VPointF> m_cachedNodes;
|
||||||
|
QVector<QPointF> m_cachedMainPathPoints;
|
||||||
|
|
||||||
VScaledEllipse* GetPoint(quint32 i, const QColor &color);
|
VScaledEllipse* GetPoint(quint32 i, const QColor &color);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user