-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathareazoomwidget.h
41 lines (37 loc) · 1.3 KB
/
areazoomwidget.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
//=============================================================================
/**
* Author: Jason Cipriani
* Website: https://github.com/JC3/ZScorePeakDetection
* License: https://github.com/JC3/ZScorePeakDetection/blob/master/LICENSE
*/
//=============================================================================
#ifndef AREAZOOMWIDGET_H
#define AREAZOOMWIDGET_H
#include <QWidget>
class AreaZoomWidget : public QWidget {
Q_OBJECT
public:
explicit AreaZoomWidget(QWidget *parent = nullptr);
float zoomFrom () const { return from_; }
float zoomTo () const { return to_; }
protected:
void mousePressEvent (QMouseEvent *event);
void mouseMoveEvent (QMouseEvent *event);
void mouseReleaseEvent (QMouseEvent *event);
void paintEvent (QPaintEvent *event);
public slots:
void setZoomWindow (float from, float to) { from_ = from; to_ = to; validate(); update(); }
void setZoomWindowFrom (float from) { from_ = from; validate(); update(); }
void setZoomWindowTo (float to) { to_ = to; validate(); update(); }
signals:
void zoomed (float from, float to);
private:
float from_, to_;
bool dragging_;
QPoint dragstart_;
float dragfrom_, dragto_;
void dragUpdate (QPoint pos);
QRect zoomWindowRect () const;
void validate ();
};
#endif // AREAZOOMWIDGET_H