-
Notifications
You must be signed in to change notification settings - Fork 0
/
qtdrawer.h
62 lines (53 loc) · 1.41 KB
/
qtdrawer.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
#ifndef QTDRAWER_H
#define QTDRAWER_H
#include "interfaces.h"
#include <memory>
#include <vector>
#include <QWidget>
#include <QMouseEvent>
#include <algorithm>
class QTDrawer : public QWidget, public IDrawer
{
Q_OBJECT
public:
explicit QTDrawer(QWidget *parent = 0);
//IDrawer
DLimits GetDrawingLimits() override;
std::vector<std::shared_ptr<IGraph>> GetGraphs() override;
std::shared_ptr<QPainter> GetPainter() override;
bool IsNeedRedraw() override;
void mouseReleaseEvent ( QMouseEvent * event ) override;
void resizeEvent(QResizeEvent* event) override;
void AddDrawable(std::shared_ptr<IGraph> drawable);
void AddDrawable(std::shared_ptr<IAxes> drawable);
void AddDrawable(std::shared_ptr<ILegend> drawable);
void Zoom(const DLimits & limits);
void ResetLimits();
void Clear()
{
_graphs.clear();
ResetLimits();
}
QImage GetImage()
{
return _image.toImage();
}
void RemoveLastGraph()
{
if(!_graphs.empty())
_graphs.pop_back();
ResetLimits();
}
protected:
void paintEvent(QPaintEvent *event) override;
void paint();
signals:
public slots:
private:
std::vector<std::shared_ptr<IGraph>> _graphs;
std::vector<std::shared_ptr<IDrawable>> _overDrawables;
DLimits _drawerInfo = DLimits::Invalid();
QPixmap _image;
bool _needRepaint = true;
};
#endif // QTDRAWER_H