diff options
author | Thales1330 <thaleslima.ufu@gmail.com> | 2016-08-19 09:20:19 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-19 09:20:19 -0300 |
commit | ae95a3dbc230e2fc1e2e02e0ee920dc908f3ef2f (patch) | |
tree | e05100d4711e4050985e3d550bf9053a3c22942f /Project/Workspace.h | |
parent | b23b552bac7a5c5a5e934ab3181180877bf93a72 (diff) | |
parent | 05525745c0b0d189484da3c45f95356d7558e2cf (diff) | |
download | PSP.git-ae95a3dbc230e2fc1e2e02e0ee920dc908f3ef2f.tar.gz PSP.git-ae95a3dbc230e2fc1e2e02e0ee920dc908f3ef2f.tar.xz PSP.git-ae95a3dbc230e2fc1e2e02e0ee920dc908f3ef2f.zip |
Merge pull request #1 from Thales1330/wip/svnprob
Wip/svnprob
Diffstat (limited to 'Project/Workspace.h')
-rw-r--r-- | Project/Workspace.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/Project/Workspace.h b/Project/Workspace.h new file mode 100644 index 0000000..e240206 --- /dev/null +++ b/Project/Workspace.h @@ -0,0 +1,92 @@ +#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; +class Bus; +class Line; + +enum WorkspaceMode +{ + MODE_EDIT = 0, + MODE_MOVE_ELEMENT, + MODE_MOVE_PICKBOX, + MODE_DRAG, + MODE_INSERT, + MODE_SELECTION_RECT +}; + +class Workspace : public WorkspaceBase +{ + 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(); } + + protected: + virtual void OnRightClickDown(wxMouseEvent& event); + 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); + virtual void OnPopupClick(wxCommandEvent& event); + + void SetViewport(); + + wxGLContext* m_glContext; + wxStatusBar* m_statusBar; + Camera* m_camera; + wxString m_name; + + WorkspaceMode m_mode = MODE_EDIT; + + std::vector<Element*> m_elementList; + + void UpdateStatusBar(); + + private: + wxRect2DDouble m_selectionRect; + wxPoint2DDouble m_startSelRect; +}; + +class Camera +{ + 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; + + protected: + wxPoint2DDouble m_translation; + wxPoint2DDouble m_translationStartPt; + double m_scale; + + wxPoint2DDouble m_mousePosition; +}; + +#endif // WORKSPACE_H |