/
arrow.hpp
48 lines (38 loc) · 1.32 KB
/
arrow.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 __ARROW_HPP__
#define __ARROW_HPP__
#include <list>
#include <cassert>
#include "draw_gl.hpp"
#include "curves.hpp"
class Arrow {
public:
class Renderer {
Arrow& m_arrow;
ShowableBezier m_arrowBody;
ShowableLine m_tip[2];
unsigned int m_begin, m_end;
public:
Renderer(RendererGL& rendererGL, Arrow& arrow, float p0x, float p0y, float p1x, float p1y, float t0x, float t0y, float t1x, float t1y, int layer,
unsigned int begin, unsigned int end);
void changePoints(float p0x, float p0y, float p1x, float p1y, float t0x, float t0y, float t1x, float t1y);
void setBeginEnd(unsigned int begin, unsigned int end) {
m_begin = begin;
m_end = end;
}
void setLayer(int newLayer);
unsigned int begin() const {return m_begin;}
unsigned int end() const {return m_end;}
Arrow& getArrow() const {return m_arrow;}
};
private:
unsigned int m_begin, m_end;
public:
Arrow(unsigned int begin, unsigned int end) : m_begin(begin), m_end(end) {assert(m_begin!=m_end);}
unsigned int begin() const {return m_begin;}
unsigned int end() const {return m_end;}
unsigned int lenght() const {return (m_begin>m_end) ? m_begin-m_end : m_end-m_begin;}
bool isUp() const {return m_end<m_begin;}
bool isDown() const {return m_begin<m_end;}
friend Renderer;
};
#endif // __ARROW_HPP__