-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScribble.hpp
48 lines (44 loc) · 1.2 KB
/
Scribble.hpp
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
#ifndef H_Scribble
#define H_Scribble
//----------------------------------------------------------------------------
#include <QColor>
#include <vector>
//----------------------------------------------------------------------------
class QPainter;
class QRect;
//----------------------------------------------------------------------------
/// A simple line drawing
class Scribble
{
private:
/// A line
struct Line {
/// The coordinates
int x1,y1,x2,y2;
/// Line color
QColor color;
/// Line width
unsigned width;
/// Get the bounding box
QRect getBB() const;
/// Compute distance
double distanceToSquared(int x,int y) const;
};
/// The lines
std::vector<Line> lines;
public:
/// Constructor
Scribble();
/// Destructor
~Scribble();
/// Draw the scribble
void paint(QPainter& painter,const QRect& target);
/// Delete all lines
void clear();
/// Add a line
QRect drawLine(int x1,int y1,int x2,int y2,unsigned width,QColor color);
/// Erase a previously drawn line
QRect eraseLine(int x1,int y1,int x2,int y2,unsigned width);
};
//----------------------------------------------------------------------------
#endif