-
Notifications
You must be signed in to change notification settings - Fork 3
/
layout_widget.h
42 lines (32 loc) · 1018 Bytes
/
layout_widget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include <qdebug.h>
#include <QApplication>
#include <QMouseEvent>
#include <QOpenGLFunctions>
#include <QOpenGLWidget>
#include <QPainter>
#include <QTableWidget>
#include <QWheelEvent>
#include <QPolygon>
class LayoutWidget : public QOpenGLWidget, protected QOpenGLFunctions {
Q_OBJECT
public:
LayoutWidget(QWidget* parent = nullptr) : QOpenGLWidget(parent) {}
void initialize_transform();
void set_sheet(qreal w, qreal h);
public slots:
void layoutUpdate(QTableWidgetItem* n, QTableWidgetItem* o);
protected:
void initializeGL() override;
void resizeGL(int w, int h) override { glViewport(0, 0, w, h); }
void paintEvent(QPaintEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
private:
QPointF m_lastPos;
QTransform globalTransform;
QRectF sheet;
QList<QPolygonF> layout;
qreal length{-1};
};