-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZoomWidget.h
81 lines (69 loc) · 1.98 KB
/
ZoomWidget.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef ZOOMWIDGET_H
#define ZOOMWIDGET_H
#include <QWidget>
#include <QPixmap>
#include <QList>
#include <QColor>
#include "ColorCount.h"
class SelWin;
class QTimer;
struct Line {
int position;
QFlags<Qt::Orientation> orientation;
};
enum Tool { ToolNone, ToolDraw, ToolColorPicker };
class ZoomWidget : public QWidget
{
Q_OBJECT
public:
ZoomWidget(SelWin* sw, QWidget* parent=0);
~ZoomWidget();
void pause();
void play();
int zoomFactor() { return m_zoomFactor; }
int updateInterval();
QColor markColor() { return m_markColor; }
QColor gridColor() { return m_gridColor; }
Tool currentTool() { return m_currentTool; }
void doPainting(QPainter& painter);
public slots:
void grabPixmap();
void setZoomFactor(int factor);
void setUpdateInterval(int i);
void setMarkColor(QColor i) {
m_markColor = i;
update();
}
void setGridColor(QColor i) { m_gridColor = i; update(); }
void setPixmap(const QPixmap& pixmap) { m_pixmap = pixmap; update(); }
void setCurrentTool(Tool tool) { m_currentTool = tool; }
signals:
void colorsChanged(const QList<ColorCount>& colors);
void markColorChanged(const QColor& color);
private:
QPixmap m_pixmap;
int m_zoomFactor;
static const int rulerWidth=20;
QColor m_markColor;
QColor m_gridColor;
bool hasCurrentLine;
int currentLine;
QList<Line*> lines;
void updateCursor( QMouseEvent * event );
void drawLineTo(const QPoint &endPoint);
void resizeImage(QImage &image, const QSize &newSize);
SelWin* selWin;
QTimer* timer;
Tool m_currentTool;
bool m_isDrawing;
QPoint m_drawingLastPoint;
QImage m_drawingImage;
protected:
void paintEvent(QPaintEvent * event);
void mouseMoveEvent ( QMouseEvent * event );
void mousePressEvent ( QMouseEvent * event );
void mouseReleaseEvent ( QMouseEvent * event );
void resizeEvent(QResizeEvent * event);
void closeEvent(QCloseEvent* event);
};
#endif