Fix wrong disabling VSimplePoint and VSimpleCurve after changing a pattern
piece. --HG-- branch : develop
This commit is contained in:
parent
378ec5f4b7
commit
1ed9983ee7
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include "vabstractsimple.h"
|
||||
|
||||
const qreal VAbstractSimple::m_defFactor = 1;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractSimple::VAbstractSimple(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor,
|
||||
QObject *parent)
|
||||
|
@ -39,7 +41,12 @@ VAbstractSimple::VAbstractSimple(quint32 id, const QColor ¤tColor, Unit pa
|
|||
patternUnit(patternUnit),
|
||||
selectionType(SelectionType::ByMouseRelease),
|
||||
type(GOType::Unknown)
|
||||
{}
|
||||
{
|
||||
if (this->factor == nullptr)
|
||||
{
|
||||
this->factor = const_cast<qreal *>(&m_defFactor);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractSimple::~VAbstractSimple()
|
||||
|
@ -71,6 +78,12 @@ QColor VAbstractSimple::GetCurrentColor() const
|
|||
return currentColor;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractSimple::SetEnabled(bool enabled)
|
||||
{
|
||||
this->enabled = enabled;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractSimple::ContextMenu(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
|
|
|
@ -49,14 +49,14 @@ class VAbstractSimple : public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
VAbstractSimple(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor = nullptr,
|
||||
QObject *parent = 0);
|
||||
QObject *parent = nullptr);
|
||||
virtual ~VAbstractSimple();
|
||||
|
||||
virtual void ToolSelectionType(const SelectionType &type);
|
||||
|
||||
QColor GetCurrentColor() const;
|
||||
|
||||
virtual void SetEnabled(bool enabled) { Q_UNUSED(enabled); }
|
||||
virtual void SetEnabled(bool enabled);
|
||||
|
||||
GOType GetType() const;
|
||||
void SetType(const GOType &value);
|
||||
|
@ -91,45 +91,18 @@ protected:
|
|||
template <class T>
|
||||
void SetPen(T *item, const QColor &color, qreal width);
|
||||
|
||||
template <class T>
|
||||
void SimpleChangedActivDraw(T *item, const bool &flag);
|
||||
|
||||
template <class T>
|
||||
void SetSimpleCurrentColor(T *item, const QColor &value);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractSimple)
|
||||
|
||||
const static qreal m_defFactor;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
void VAbstractSimple::SetPen(T *item, const QColor &color, qreal width)
|
||||
{
|
||||
if (factor == nullptr)
|
||||
{
|
||||
item->setPen(QPen(CorrectColor(color), ToPixel(width, patternUnit), Qt::SolidLine, Qt::RoundCap));
|
||||
}
|
||||
else
|
||||
{
|
||||
SCASSERT(item);
|
||||
item->setPen(QPen(CorrectColor(color), ToPixel(width, patternUnit)/ *factor, Qt::SolidLine, Qt::RoundCap));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
void VAbstractSimple::SimpleChangedActivDraw(T *item, const bool &flag)
|
||||
{
|
||||
enabled = flag;
|
||||
item->setEnabled(enabled);
|
||||
SetPen(item, currentColor, WidthHairLine(patternUnit));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
void VAbstractSimple::SetSimpleCurrentColor(T *item, const QColor &value)
|
||||
{
|
||||
currentColor = value;
|
||||
SetPen(item, CorrectColor(currentColor), item->pen().widthF());
|
||||
}
|
||||
|
||||
#endif // VABSTRACTSIMPLE_H
|
||||
|
|
|
@ -66,18 +66,6 @@ VSimpleCurve::~VSimpleCurve()
|
|||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::SetCurrentColor(const QColor &value)
|
||||
{
|
||||
SetSimpleCurrentColor(this, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::ChangedActivDraw(bool flag)
|
||||
{
|
||||
SimpleChangedActivDraw(this, flag);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve)
|
||||
{
|
||||
|
@ -85,6 +73,13 @@ void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve)
|
|||
ShowPath();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::SetEnabled(bool enabled)
|
||||
{
|
||||
VAbstractSimple::SetEnabled(enabled);
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::CurveChoosed()
|
||||
{
|
||||
|
|
|
@ -61,10 +61,9 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::SimpleCurve)};
|
||||
|
||||
void SetCurrentColor(const QColor &value);
|
||||
|
||||
void ChangedActivDraw(bool flag);
|
||||
void RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve);
|
||||
|
||||
virtual void SetEnabled(bool enabled) Q_DECL_OVERRIDE;
|
||||
signals:
|
||||
/**
|
||||
* @brief Choosed send id when clicked.
|
||||
|
|
|
@ -73,18 +73,6 @@ VSimplePoint::VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternU
|
|||
VSimplePoint::~VSimplePoint()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::SetCurrentColor(const QColor &value)
|
||||
{
|
||||
SetSimpleCurrentColor(this, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::ChangedActivDraw(bool flag)
|
||||
{
|
||||
SimpleChangedActivDraw(this, flag);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::RefreshLine()
|
||||
{
|
||||
|
@ -97,7 +85,7 @@ void VSimplePoint::RefreshLine()
|
|||
VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2);
|
||||
const QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
|
||||
lineName->setLine(QLineF(p1, pRec - scenePos()));
|
||||
SetPen(lineName, QColor(Qt::black), WidthHairLine(patternUnit));
|
||||
SetPen(lineName, Qt::black, WidthHairLine(patternUnit));
|
||||
|
||||
if (QLineF(p1, pRec - scenePos()).length() <= ToPixel(4, Unit::Mm))
|
||||
{
|
||||
|
@ -126,14 +114,7 @@ void VSimplePoint::RefreshGeometry(const VPointF &point)
|
|||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
namePoint->blockSignals(true);
|
||||
QFont font = namePoint->font();
|
||||
if (factor == nullptr)
|
||||
{
|
||||
font.setPointSize(static_cast<qint32>(namePoint->FontSize()));
|
||||
}
|
||||
else
|
||||
{
|
||||
font.setPointSize(static_cast<qint32>(namePoint->FontSize()/ *factor));
|
||||
}
|
||||
namePoint->setFont(font);
|
||||
namePoint->setText(point.name());
|
||||
namePoint->setPos(QPointF(point.mx(), point.my()));
|
||||
|
@ -145,6 +126,9 @@ void VSimplePoint::RefreshGeometry(const VPointF &point)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::SetEnabled(bool enabled)
|
||||
{
|
||||
VAbstractSimple::SetEnabled(enabled);
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
SetPen(lineName, Qt::black, WidthHairLine(patternUnit));
|
||||
namePoint->setEnabled(enabled);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::SimplePoint)};
|
||||
|
||||
void ChangedActivDraw(bool flag);
|
||||
void RefreshLine();
|
||||
void RefreshGeometry(const VPointF &point);
|
||||
virtual void SetEnabled(bool enabled) Q_DECL_OVERRIDE;
|
||||
|
@ -70,8 +69,6 @@ public:
|
|||
void AllowLabelHover(bool enabled);
|
||||
void AllowLabelSelecting(bool enabled);
|
||||
virtual void ToolSelectionType(const SelectionType &type) Q_DECL_OVERRIDE;
|
||||
|
||||
void SetCurrentColor(const QColor &value);
|
||||
signals:
|
||||
/**
|
||||
* @brief Choosed send id when clicked.
|
||||
|
|
Loading…
Reference in New Issue
Block a user