添加选中框和变换中心点的实时绘制
This commit is contained in:
parent
f59af2bf9d
commit
dd37676f2a
|
|
@ -235,6 +235,8 @@ public:
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_boundingRect_selected = boundRect.adjusted(-nMargin, -nMargin, nMargin, nMargin);
|
||||
}
|
||||
|
||||
virtual QRectF boundingRect() const { return m_boundingRect; }
|
||||
|
|
@ -250,6 +252,7 @@ protected:
|
|||
double m_dWidth;
|
||||
double m_dHeight;
|
||||
QRectF m_boundingRect;
|
||||
QRectF m_boundingRect_selected;//选中矩形框
|
||||
|
||||
QGraphicsPathItem* m_pOperationCopy; //图元移动和旋转时的操作副本
|
||||
QPointF m_movingIniPos; //移动副本开始移动初始点
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "graphicsItem/itemControlHandle.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
GraphicPolygonItem::GraphicPolygonItem(QGraphicsItem *parent)
|
||||
: GraphicsBaseItem(parent)
|
||||
|
|
@ -65,6 +66,18 @@ void GraphicPolygonItem::paint(QPainter* painter, const QStyleOptionGraphicsItem
|
|||
painter->setPen(m_pen);
|
||||
painter->setBrush(m_brush);
|
||||
painter->drawPolygon(m_points);
|
||||
//绘制变换原点
|
||||
QPointF originPoint = transformOriginPoint();
|
||||
painter->setBrush(Qt::red);
|
||||
painter->drawEllipse(originPoint, 4, 4);
|
||||
|
||||
if (option->state & QStyle::State_Selected) //是选中状态,绘制选中框
|
||||
{
|
||||
int nPenWidth = 1;
|
||||
painter->setPen(QPen(QColor(70,70,70), nPenWidth, Qt::DashLine)); //蓝色的外框
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->drawRect(m_boundingRect_selected);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicPolygonItem::resize(int nHandle,double dSX, double dSY, const QPointF& basePoint)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "graphicsItem/itemControlHandle.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
GraphicsRectItem::GraphicsRectItem(const QRect &rect, bool isRound, QGraphicsItem *parent)
|
||||
: GraphicsBaseItem(parent), m_bIsRound(isRound), m_dRatioX(1 / 10.0), m_dRatioY(1 / 10.0)
|
||||
|
|
@ -104,9 +105,17 @@ void GraphicsRectItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*
|
|||
painter->drawRect(m_boundingRect);
|
||||
|
||||
//绘制变换原点
|
||||
// QPointF originPoint = transformOriginPoint();
|
||||
// painter->setPen(Qt::red);
|
||||
// painter->drawEllipse(originPoint, 5, 5);
|
||||
QPointF originPoint = transformOriginPoint();
|
||||
painter->setBrush(Qt::red);
|
||||
painter->drawEllipse(originPoint, 4, 4);
|
||||
|
||||
if (option->state & QStyle::State_Selected) //是选中状态,绘制选中框
|
||||
{
|
||||
int nPenWidth = 1;
|
||||
painter->setPen(QPen(QColor(70,70,70), nPenWidth, Qt::DashLine)); //蓝色的外框
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->drawRect(m_boundingRect_selected);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsRectItem::resize(int nHandle,double dSX, double dSY, const QPointF& basePoint)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "graphicsItem/itemControlHandle.h"
|
||||
#include <QPainter>
|
||||
|
||||
#define HNDLE_SIZE 6
|
||||
#define HNDLE_SIZE 8
|
||||
|
||||
ItemControlHandle::ItemControlHandle(QGraphicsItem *parent)
|
||||
: QGraphicsRectItem(-HNDLE_SIZE / 2,
|
||||
|
|
|
|||
Loading…
Reference in New Issue