-
Notifications
You must be signed in to change notification settings - Fork 0
/
Line.h
43 lines (26 loc) · 1.05 KB
/
Line.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 "Point.h"
#include "AppObject.h"
class Line : public AppObject
{
public:
Point pt[2];
int dragPoint = -1;
int hoverPoint = -1;
bool isDragLine = false;
bool ishoverLine = false;
Line() { _type = Type::Line; }
virtual bool onMouseEvent(const MouseEvent& ev) override;
void onCreate(const MouseEvent& ev);
inline void clearHoverPoint() { clearDragPoint(); }
inline void clearDragPoint() { dragPoint = -1; hoverPoint = -1; } // no drag, no hover
inline void setDragPoint(int i) { dragPoint = i; hoverPoint = i; } // no drag, no hover
inline void setDragLine(bool b) { isDragLine = b; ishoverLine = b; } // no drag, no hover
bool updateHoverPoint(const MouseEvent ev, const Point* points, int nPoints);
bool updateHoverLine(const MouseEvent& ev, int distance);
static Point lerp(const Point& p0, const Point& p1, float t = 0);
void draw(HDC hdc_) const override;
static void drawLine(HDC hdc_, const Point& pt0, const Point& pt1, HPEN hpen);
void save(std::ofstream& f);
static void load(std::ifstream& f);
};