summaryrefslogtreecommitdiffstats
path: root/Project/Workspace.h
blob: ef837fb1854469ad312146161b94e08b4128cfce (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef WORKSPACE_H
#define WORKSPACE_H

#include <GL/gl.h>
#include <GL/glu.h>
#include <wx/dcclient.h>
#include <wx/msgdlg.h>

#include "WorkspaceBase.h"

class MouseEventsHandler;
class Element;
class Bus;

//#include "MouseEventsHandler.h"
//#include "Bus.h"

class Camera;

class Workspace : public WorkspaceBase
{
   protected:
    virtual void OnMouseMotion(wxMouseEvent& event);
    virtual void OnKeyDown(wxKeyEvent& event) { event.Skip(); };
    virtual void OnLeftClickDown(wxMouseEvent& event);
    virtual void OnPaint(wxPaintEvent& event);

    void SetViewport();

    wxGLContext* m_glContext;
    wxString m_name;

    bool m_insertMode = false;
    bool m_dragMode = false;

    std::vector<Element*> m_elementList;

   public:
    Workspace();
    Workspace(wxWindow* parent, wxString name = wxEmptyString);
    ~Workspace();

    MouseEventsHandler* m_mouseEventsHandler;
    Camera* m_camera;  // why public?

    wxString GetName() const { return m_name; }
    void SetName(wxString name) { m_name = name; }
    void SetDragMode(bool dragMode = true) { this->m_dragMode = dragMode; }
    void SetInsertMode(bool insertMode = true) { this->m_insertMode = insertMode; }
    bool IsDragMode() const { return m_dragMode; }
    std::vector<Element*> GetElementList() { return m_elementList; }
    bool IsInsertMode() const { return m_insertMode; }
    void Redraw() { this->Refresh(); }
};

class Camera
{
   private:
    wxPoint2DDouble m_translation;
    double m_scale;

   public:
    Camera();
    ~Camera();

    void SetScale(double scale) { this->m_scale = scale; }
    void SetTranslation(const wxPoint2DDouble& translation) { this->m_translation = translation; }
    double GetScale() const { return m_scale; }
    const wxPoint2DDouble GetTranslation() const { return m_translation; }
    wxPoint2DDouble ScreenToWorld(wxPoint2DDouble screenCoords);
};

#endif  // WORKSPACE_H