Improve API for class VNoBrushScalePathItem. Added method SetWidth().
--HG-- branch : develop
This commit is contained in:
parent
c4d07125dc
commit
263b99ff19
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "vnobrushscalepathitem.h"
|
#include "vnobrushscalepathitem.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "../vmisc/vabstractapplication.h"
|
||||||
|
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QMatrix>
|
#include <QMatrix>
|
||||||
|
@ -35,10 +36,17 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VNoBrushScalePathItem::VNoBrushScalePathItem(QGraphicsItem *parent) :
|
VNoBrushScalePathItem::VNoBrushScalePathItem(QGraphicsItem *parent) :
|
||||||
QGraphicsPathItem(parent)
|
QGraphicsPathItem(parent),
|
||||||
|
m_defaultWidth(qApp->Settings()->WidthHairLine())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VNoBrushScalePathItem::SetWidth(qreal width)
|
||||||
|
{
|
||||||
|
m_defaultWidth = width;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VNoBrushScalePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void VNoBrushScalePathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
|
@ -57,5 +65,10 @@ void VNoBrushScalePathItem::paint(QPainter *painter, const QStyleOptionGraphicsI
|
||||||
QBrush brush = this->brush();
|
QBrush brush = this->brush();
|
||||||
brush.setMatrix(painter->combinedMatrix().inverted());
|
brush.setMatrix(painter->combinedMatrix().inverted());
|
||||||
this->setBrush(brush);
|
this->setBrush(brush);
|
||||||
|
|
||||||
|
QPen toolPen = pen();
|
||||||
|
toolPen.setWidthF(ScaleWidth(m_defaultWidth, SceneScale(scene())));
|
||||||
|
setPen(toolPen);
|
||||||
|
|
||||||
PaintWithFixItemHighlightSelected<QGraphicsPathItem>(this, painter, option, widget);
|
PaintWithFixItemHighlightSelected<QGraphicsPathItem>(this, painter, option, widget);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ class VNoBrushScalePathItem : public QGraphicsPathItem
|
||||||
public:
|
public:
|
||||||
explicit VNoBrushScalePathItem(QGraphicsItem *parent = nullptr);
|
explicit VNoBrushScalePathItem(QGraphicsItem *parent = nullptr);
|
||||||
|
|
||||||
|
void SetWidth(qreal width);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option,
|
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option,
|
||||||
QWidget * widget = nullptr) override;
|
QWidget * widget = nullptr) override;
|
||||||
|
@ -49,6 +51,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VNoBrushScalePathItem)
|
Q_DISABLE_COPY(VNoBrushScalePathItem)
|
||||||
|
qreal m_defaultWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VNOBRUSHSCALEPATHITEM_H
|
#endif // VNOBRUSHSCALEPATHITEM_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user