blob: e093105603fae3c7a2967c061e87ea8dd6b87118 (
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
74
75
76
77
78
79
80
81
82
83
|
#ifndef WORKSPACE_H
#define WORKSPACE_H
#include <GL/gl.h>
#include <GL/glu.h>
#include <wx/dcclient.h>
#include <wx/msgdlg.h>
#include <wx/statusbr.h>
#include "WorkspaceBase.h"
class Camera;
class Element;
enum WorkspaceMode
{
MODE_EDIT = 0,
MODE_DRAG,
MODE_INSERT
};
class Workspace : public WorkspaceBase
{
protected:
virtual void OnLeftClickUp(wxMouseEvent& event);
virtual void OnScroll(wxMouseEvent& event);
virtual void OnMiddleDown(wxMouseEvent& event);
virtual void OnMiddleUp(wxMouseEvent& event);
virtual void OnMouseMotion(wxMouseEvent& event);
virtual void OnKeyDown(wxKeyEvent& event);
virtual void OnLeftClickDown(wxMouseEvent& event);
virtual void OnPaint(wxPaintEvent& event);
void SetViewport();
wxGLContext* m_glContext;
wxStatusBar* m_statusBar;
Camera* m_camera;
wxString m_name;
//bool m_insertMode = false;
//bool m_dragMode = false;
WorkspaceMode m_mode = MODE_EDIT;
std::vector<Element*> m_elementList;
void UpdateStatusBar();
public:
Workspace();
Workspace(wxWindow* parent, wxString name = wxEmptyString, wxStatusBar* statusBar = NULL);
~Workspace();
wxString GetName() const { return m_name; }
void SetName(wxString name) { m_name = name; }
std::vector<Element*> GetElementList() { return m_elementList; }
void Redraw() { m_glCanvas->Refresh(); }
};
class Camera
{
protected:
wxPoint2DDouble m_translation;
wxPoint2DDouble m_translationStartPt;
double m_scale;
wxPoint2DDouble m_mousePosition;
public:
Camera();
~Camera();
void SetScale(wxPoint2DDouble screenPoint, double delta);
void SetTranslation(wxPoint2DDouble screenPoint);
void StartTranslation(wxPoint2DDouble startPoint) { this->m_translationStartPt = startPoint; }
void UpdateMousePosition(wxPoint2DDouble mousePosition) {this->m_mousePosition = mousePosition;}
double GetScale() const { return m_scale; }
wxPoint2DDouble GetTranslation() const { return m_translation; }
wxPoint2DDouble GetMousePosition(bool worldCoords = true) const;
wxPoint2DDouble ScreenToWorld(wxPoint2DDouble screenCoords) const;
};
#endif // WORKSPACE_H
|