summaryrefslogtreecommitdiffstats
path: root/Project/ControlElement.h
blob: 063b2a5127ddf1c2f987410b21f0ef04d183f771 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
#ifndef CONTROLELEMENT_H
#define CONTROLELEMENT_H

#include "Element.h"

class Node
{
public:
    enum NodeType { NODE_IN = 0, NODE_OUT };

    Node(wxPoint2DDouble position = wxPoint2DDouble(0, 0), NodeType nodeType = NODE_IN, double borderSize = 0.0);
    ~Node();

    wxRect2DDouble GetRect() const { return m_rect; }
    void SetRect(wxRect2DDouble rect) { m_rect = rect; }

    wxPoint2DDouble GetPosition() const;
    void SetPosition(wxPoint2DDouble position);

    NodeType GetNodeType() const { return m_nodeType; }
    void SetNodeType(NodeType nodeType) { m_nodeType = nodeType; }

    double GetRadius() const { return m_radius; }
    std::vector<wxPoint2DDouble> GetInTrianglePts() const { return m_triPts; }

    void StartMove(wxPoint2DDouble position);
    void Move(wxPoint2DDouble position);
    bool Contains(wxPoint2DDouble position) const { return m_rect.Contains(position); }

protected:
    wxRect2DDouble m_rect;
    NodeType m_nodeType;

    wxPoint2DDouble m_moveStartPt;
    wxPoint2DDouble m_movePos;

    double m_radius = 3.0;
    std::vector<wxPoint2DDouble> m_triPts;
};

class ControlElement : public Element
{
public:
    ControlElement();
    ~ControlElement();

    virtual void StartMove(wxPoint2DDouble position);
    virtual void Move(wxPoint2DDouble position);

    void SetNodeList(std::vector<Node> nodeList) { m_nodeList = nodeList; }
    std::vector<Node> GetNodeList() const { return m_nodeList; }

    virtual void DrawNodes() const;

protected:
    std::vector<Node> m_nodeList;
};

#endif // CONTROLELEMENT_H