2024-02-06 06:19:53 +00:00
|
|
|
#ifndef MYGRAPHICSITEM_H
|
|
|
|
#define MYGRAPHICSITEM_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QGraphicsItem>
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
#include <QGraphicsSceneMouseEvent>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QPicture>
|
|
|
|
#include <QList>
|
|
|
|
#include <QtGui>
|
|
|
|
#include "machine/bmp/creatprintbmp.h"
|
2024-03-08 08:33:05 +00:00
|
|
|
#include "datafile/view/drawdata.h"
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
class MyGraphicsItem : public QObject, public QGraphicsItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_INTERFACES(QGraphicsItem) //通知要实现的类构成何种界面的宏
|
|
|
|
|
|
|
|
public:
|
|
|
|
MyGraphicsItem();
|
|
|
|
~MyGraphicsItem();
|
|
|
|
|
|
|
|
//绘图区域
|
|
|
|
QRectF boundingRect() const;
|
|
|
|
//绘制按钮图像的函数
|
|
|
|
void paint(QPainter *painter,
|
|
|
|
const QStyleOptionGraphicsItem *option,
|
|
|
|
QWidget *widget = 0);
|
|
|
|
|
|
|
|
protected: //事件
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QPicture m_picture;
|
2024-03-08 08:33:05 +00:00
|
|
|
QPainterPath m_drawPath;
|
2024-02-06 06:19:53 +00:00
|
|
|
QPixmap m_blockPixmap;
|
|
|
|
QPoint m_point;
|
|
|
|
QRectF m_boundingRect;//返回形状
|
2024-03-08 08:33:05 +00:00
|
|
|
int m_fileType;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
|
|
|
public:
|
2024-03-08 08:33:05 +00:00
|
|
|
QPicture getPictureByDat(Marker marker,int penWidth = 1);
|
|
|
|
QPicture getPictureByBmp(QPixmap pixmap,int penWidth = 1);
|
|
|
|
QPainterPath getDrawPath();
|
2024-02-06 06:19:53 +00:00
|
|
|
void setPicture(QPicture pic);
|
2024-03-08 08:33:05 +00:00
|
|
|
void setPaintPath(QPainterPath path);
|
|
|
|
void setPaintPathAndPic(QPainterPath path,QPicture pic);
|
2024-02-06 06:19:53 +00:00
|
|
|
void reflushBlockPos(QPoint p);//更显打印块位置
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MYGRAPHICSITEM_H
|