38 lines
1008 B
C++
38 lines
1008 B
C++
#ifndef GRAPHICSPOLYGONITEM_H
|
|
#define GRAPHICSPOLYGONITEM_H
|
|
|
|
#include "graphicsBaseItem.h"
|
|
|
|
class GraphicPolygonItem : public GraphicsBaseItem
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
GraphicPolygonItem(QGraphicsItem *parent = 0);
|
|
virtual ~GraphicPolygonItem();
|
|
|
|
void resize(int,double, double, const QPointF&) override;
|
|
void updateCoordinate() override;
|
|
void move(const QPointF&) override;
|
|
QJsonObject serialize() const override;
|
|
static QGraphicsItem *createFromJson(const QJsonObject &obj);
|
|
void editShape(int, const QPointF&) override;
|
|
|
|
void addPoint(const QPointF&) override;
|
|
bool endDrawing() override;
|
|
QPolygonF getPoints(void) { return m_points; }
|
|
|
|
protected:
|
|
QPainterPath shape() override;
|
|
QRectF boundingRect();
|
|
void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
|
|
|
private:
|
|
void updateHandles() override;
|
|
|
|
QPolygonF m_lastPoints; //记录上一时刻的点集数据,用于缩放等操作
|
|
QPolygonF m_points;
|
|
};
|
|
|
|
#endif
|