-
Notifications
You must be signed in to change notification settings - Fork 0
/
Curve.h
39 lines (25 loc) · 918 Bytes
/
Curve.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
#pragma once
#include "Point.h"
#include "AppObject.h"
class Curve : public AppObject
{
public:
static const int nPoints = 4;
Point pts[nPoints];
Curve() { _type = Type::Curve; }
int hoverPoint = -1;
int dragPoint = -1;
int createPoint = -1;
void onCreate(const MouseEvent& ev);
inline bool isCreated() const { return createPoint >= nPoints; }
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
bool updateHoverPoint(const MouseEvent ev, const Point* points, int nPoints);
void onLeftBtnDrag(const MouseEvent& ev);
virtual void draw(HDC hdc) const override;
void drawCurve(HDC hdc) const;
virtual bool onMouseEvent(const MouseEvent& ev);
void save(std::ofstream& f);
static void load(std::ifstream& f);
};