Quilting-lw/sharedviews/view/mygraphicsview.h
2026-01-23 16:37:18 +08:00

75 lines
2.1 KiB
C++

#ifndef MYGRAPHICSVIEW_H
#define MYGRAPHICSVIEW_H
#include <QObject>
#include <QGraphicsView>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QScrollBar>
#include <QGestureEvent>
#include <QPinchGesture>
#include "mygraphicsscene.h"
#define GRIDSIZE1 1 //一个格子代表1毫米
#define GRIDSIZE254 25.4 //一个格子代表25.4毫米
#define SCENESIZE 800.0
///
/// \brief The MyGraphicsView class 视图层
///
class MyGraphicsView : public QGraphicsView
{
Q_OBJECT
public:
explicit MyGraphicsView(QWidget *parent = NULL,double gridUnit = 0.0);
~MyGraphicsView();
private:
MyGraphicsScene *m_scene;
//鼠标左键按下点
QPoint m_leftPressPoint;
//鼠标左键抬起点
QPoint m_leftReleasePoint;
protected:
void resizeEvent(QResizeEvent *event);//窗口大小发生变化的时候,该函数触发
void mouseDoubleClickEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void showEvent(QShowEvent *event) override;
public:
void swithViewByPic(QPicture pic);
void creatViewByData(QByteArray ary);
void creatViewByList(QList<drawItem> list);
void setRangeXY(s32 maxX,s32 minX,s32 maxY,s32 minY);
void enlargeView();
void narrowView();
void forwardAndBackward(int idx);
int getItemNums();
void moveScene(int x,int y);//移动场景
void autoView();//自动调整大小
void insertPoint(int dir);
void removeSelectPoint();//删除选中点 默认删除最后一个点
void setShapeType(int type);
QList<QGraphicsEllipseItem *> getPointList();
void cleanView();
void setAdsorption(bool adsorption);
void setMaxSegmentLength(int value);
int getMaxSegmentLength();
void setXYMove(double valX,double valY);
void revokeLastItem();//撤销最后一个图元
QList<GLineItem> getLineItemList();
QList<GPathItem> getPathItemList();
void restoreView();
signals:
void siCurrentIndex(int idx);
public slots:
};
#endif // MYGRAPHICSVIEW_H