61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
#ifndef GRAPHICSBASEITEM_H
|
|
#define GRAPHICSBASEITEM_H
|
|
|
|
#include "itemControlHandle.h"
|
|
|
|
#include <QObject>
|
|
#include <QGraphicsItem>
|
|
#include <QGraphicsSceneMouseEvent>
|
|
#include <QPen>
|
|
|
|
class GraphicsBaseItem : public QObject, public QGraphicsItem
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
GraphicsBaseItem(QGraphicsItem *parent);
|
|
virtual ~GraphicsBaseItem();
|
|
|
|
public:
|
|
QPen pen() { return m_pen; }
|
|
void setPen(const QPen &pen) { m_pen = pen; }
|
|
QColor penColor() { return m_pen.color(); }
|
|
void setPenColor(const QColor &color) { m_pen.setColor(color); }
|
|
|
|
QBrush brush() { return m_brush; }
|
|
void setBrush(const QBrush &brush) { m_brush = brush; }
|
|
QColor brushColor() { return m_brush.color(); }
|
|
void setBrushColor(const QColor &color) { m_brush.setColor(color); }
|
|
|
|
double width() { return m_dWidth; }
|
|
void setWidth(double);
|
|
|
|
double height() { return m_dHeight; }
|
|
void setHeight(double);
|
|
|
|
virtual QRectF boundingRect() const { return m_boundingRect; }
|
|
|
|
virtual void updateHandles();
|
|
virtual void resize(int,double, double, const QPointF&) {}
|
|
virtual void updateCoordinate() {}
|
|
virtual void move(const QPointF& point) { Q_UNUSED(point); }
|
|
|
|
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange, const QVariant&);
|
|
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
|
|
|
|
//handle相关
|
|
virtual void setHandleVisible(bool);
|
|
virtual QPointF getSymmetricPointPos(int); //获取对称点的坐标位置,缩放的时候需要以对称点为锚点
|
|
|
|
protected:
|
|
QPen m_pen;
|
|
QBrush m_brush;
|
|
double m_dWidth;
|
|
double m_dHeight;
|
|
QRectF m_boundingRect;
|
|
|
|
QVector<ItemControlHandle*> m_vecHanle;
|
|
};
|
|
|
|
#endif
|