Because Piece path is not visible and information about point names left on
Draw scene visualizations should show it too. It include not only point, but also label. --HG-- branch : feature
This commit is contained in:
parent
b3b957cf28
commit
5ab4169fa2
|
@ -89,7 +89,7 @@ QVector<QPointF> VPiece::MainPathPoints(const VContainer *data) const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VPiece::MainPathNodePoints(const VContainer *data) const
|
||||
QVector<VPointF> VPiece::MainPathNodePoints(const VContainer *data) const
|
||||
{
|
||||
return GetPath().PathNodePoints(data);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ class QPainterPath;
|
|||
class VPieceData;
|
||||
class VPieceNode;
|
||||
class QPointF;
|
||||
class VPointF;
|
||||
class VContainer;
|
||||
template <class T> class QVector;
|
||||
template <class T>class QSharedPointer;
|
||||
|
@ -57,7 +58,7 @@ public:
|
|||
void SetPath(const VPiecePath &path);
|
||||
|
||||
QVector<QPointF> MainPathPoints(const VContainer *data) const;
|
||||
QVector<QPointF> MainPathNodePoints(const VContainer *data) const;
|
||||
QVector<VPointF> MainPathNodePoints(const VContainer *data) const;
|
||||
QVector<QPointF> SeamAllowancePoints(const VContainer *data) const;
|
||||
|
||||
QPainterPath MainPathPath(const VContainer *data) const;
|
||||
|
|
|
@ -166,9 +166,9 @@ QVector<QPointF> VPiecePath::PathPoints(const VContainer *data) const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VPiecePath::PathNodePoints(const VContainer *data) const
|
||||
QVector<VPointF> VPiecePath::PathNodePoints(const VContainer *data) const
|
||||
{
|
||||
QVector<QPointF> points;
|
||||
QVector<VPointF> points;
|
||||
for (int i = 0; i < CountNodes(); ++i)
|
||||
{
|
||||
switch (at(i).GetTypeTool())
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
class VPiecePathData;
|
||||
class VPieceNode;
|
||||
class QPointF;
|
||||
class VPointF;
|
||||
class VContainer;
|
||||
class VSAPoint;
|
||||
class QPainterPath;
|
||||
|
@ -68,7 +69,7 @@ public:
|
|||
void SetName(const QString &name);
|
||||
|
||||
QVector<QPointF> PathPoints(const VContainer *data) const;
|
||||
QVector<QPointF> PathNodePoints(const VContainer *data) const;
|
||||
QVector<VPointF> PathNodePoints(const VContainer *data) const;
|
||||
QVector<VSAPoint> SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const;
|
||||
|
||||
QPainterPath PainterPath(const VContainer *data) const;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "vistoolpiece.h"
|
||||
#include "../vpatterndb/vpiecepath.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -54,12 +55,12 @@ void VisToolPiece::RefreshGeometry()
|
|||
{
|
||||
DrawPath(this, m_piece.MainPathPath(Visualization::data), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||
|
||||
const QVector<QPointF> nodes = m_piece.MainPathNodePoints(Visualization::data);
|
||||
const QVector<VPointF> nodes = m_piece.MainPathNodePoints(Visualization::data);
|
||||
|
||||
for (int i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(i), supportColor);
|
||||
DrawPoint(point, nodes.at(i), supportColor);
|
||||
DrawPoint(point, nodes.at(i).toQPointF(), supportColor);
|
||||
}
|
||||
|
||||
if (mode == Mode::Creation)
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolpiecepath.h"
|
||||
#include "../vwidgets/vsimplepoint.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPiecePath::VisToolPiecePath(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -51,12 +53,14 @@ void VisToolPiecePath::RefreshGeometry()
|
|||
{
|
||||
DrawPath(this, m_path.PainterPath(Visualization::data), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||
|
||||
const QVector<QPointF> nodes = m_path.PathNodePoints(Visualization::data);
|
||||
const QVector<VPointF> nodes = m_path.PathNodePoints(Visualization::data);
|
||||
|
||||
for (int i = 0; i < nodes.size(); ++i)
|
||||
{
|
||||
QGraphicsEllipseItem *point = GetPoint(static_cast<quint32>(i), supportColor);
|
||||
DrawPoint(point, nodes.at(i), supportColor);
|
||||
VSimplePoint *point = GetPoint(static_cast<quint32>(i), supportColor);
|
||||
point->SetOnlyPoint(mode == Mode::Creation);
|
||||
point->RefreshGeometry(nodes.at(i));
|
||||
point->setVisible(true);
|
||||
}
|
||||
|
||||
if (mode == Mode::Creation)
|
||||
|
@ -77,9 +81,22 @@ void VisToolPiecePath::SetPath(const VPiecePath &path)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsEllipseItem *VisToolPiecePath::GetPoint(quint32 i, const QColor &color)
|
||||
VSimplePoint *VisToolPiecePath::GetPoint(quint32 i, const QColor &color)
|
||||
{
|
||||
return GetPointItem(Visualization::data, factor, m_points, i, color, this);
|
||||
if (not m_points.isEmpty() && static_cast<quint32>(m_points.size() - 1) >= i)
|
||||
{
|
||||
return m_points.at(static_cast<int>(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimplePoint *point = new VSimplePoint(NULL_ID, color, *Visualization::data->GetPatternUnit(), &factor);
|
||||
point->SetPointHighlight(true);
|
||||
point->setParentItem(this);
|
||||
m_points.append(point);
|
||||
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include "vispath.h"
|
||||
#include "../vpatterndb/vpiecepath.h"
|
||||
|
||||
class VSimplePoint;
|
||||
|
||||
class VisToolPiecePath : public VisPath
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -49,13 +51,13 @@ public:
|
|||
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPiecePath)
|
||||
QVector<QGraphicsEllipseItem *> m_points;
|
||||
QVector<VSimplePoint *> m_points;
|
||||
|
||||
QGraphicsLineItem *m_line;
|
||||
|
||||
VPiecePath m_path;
|
||||
|
||||
QGraphicsEllipseItem* GetPoint(quint32 i, const QColor &color);
|
||||
VSimplePoint *GetPoint(quint32 i, const QColor &color);
|
||||
|
||||
void HideAllItems();
|
||||
};
|
||||
|
|
|
@ -53,8 +53,13 @@ class QKeyEvent;
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSimplePoint::VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor, QObject *parent)
|
||||
:VAbstractSimple(id, currentColor, patternUnit, factor, parent), QGraphicsEllipseItem(),
|
||||
radius(ToPixel(DefPointRadius/*mm*/, Unit::Mm)), namePoint(nullptr), lineName(nullptr)
|
||||
: VAbstractSimple(id, currentColor, patternUnit, factor, parent),
|
||||
QGraphicsEllipseItem(),
|
||||
radius(ToPixel(DefPointRadius/*mm*/, Unit::Mm)),
|
||||
namePoint(nullptr),
|
||||
lineName(nullptr),
|
||||
m_onlyPoint(false),
|
||||
m_isHighlight(false)
|
||||
{
|
||||
namePoint = new VGraphicsSimpleTextItem(this);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VSimplePoint::ContextMenu);
|
||||
|
@ -64,7 +69,7 @@ VSimplePoint::VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternU
|
|||
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VSimplePoint::ChangedPosition);
|
||||
lineName = new QGraphicsLineItem(this);
|
||||
this->setBrush(QBrush(Qt::NoBrush));
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
SetPen(this, currentColor, m_isHighlight ? WidthMainLine(patternUnit) : WidthHairLine(patternUnit));
|
||||
this->setAcceptHoverEvents(true);
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
}
|
||||
|
@ -73,6 +78,26 @@ VSimplePoint::VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternU
|
|||
VSimplePoint::~VSimplePoint()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::SetOnlyPoint(bool value)
|
||||
{
|
||||
m_onlyPoint = value;
|
||||
namePoint->setVisible(not m_onlyPoint);
|
||||
lineName->setVisible(not m_onlyPoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VSimplePoint::IsOnlyPoint() const
|
||||
{
|
||||
return m_onlyPoint;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::SetPointHighlight(bool value)
|
||||
{
|
||||
m_isHighlight = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::RefreshLine()
|
||||
{
|
||||
|
@ -106,7 +131,7 @@ void VSimplePoint::RefreshLine()
|
|||
void VSimplePoint::RefreshGeometry(const VPointF &point)
|
||||
{
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
SetPen(this, currentColor, m_isHighlight ? WidthMainLine(patternUnit) : WidthHairLine(patternUnit));
|
||||
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
||||
rec.translate(-rec.center().x(), -rec.center().y());
|
||||
this->setRect(rec);
|
||||
|
@ -127,7 +152,7 @@ void VSimplePoint::RefreshGeometry(const VPointF &point)
|
|||
void VSimplePoint::SetEnabled(bool enabled)
|
||||
{
|
||||
VAbstractSimple::SetEnabled(enabled);
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
SetPen(this, currentColor, m_isHighlight ? WidthMainLine(patternUnit) : WidthHairLine(patternUnit));
|
||||
SetPen(lineName, Qt::black, WidthHairLine(patternUnit));
|
||||
namePoint->setEnabled(enabled);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,11 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::SimplePoint)};
|
||||
|
||||
void SetOnlyPoint(bool value);
|
||||
bool IsOnlyPoint() const;
|
||||
|
||||
void SetPointHighlight(bool value);
|
||||
|
||||
void RefreshLine();
|
||||
void RefreshGeometry(const VPointF &point);
|
||||
virtual void SetEnabled(bool enabled) Q_DECL_OVERRIDE;
|
||||
|
@ -104,6 +109,9 @@ private:
|
|||
|
||||
/** @brief lineName line what we see if label moved too away from point. */
|
||||
QGraphicsLineItem *lineName;
|
||||
|
||||
bool m_onlyPoint;
|
||||
bool m_isHighlight;
|
||||
};
|
||||
|
||||
#endif // VSIMPLEPOINT_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user