From 3a246308dcd76f70a1b6c3e6b08f0d597b255dba Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Sat, 30 Jul 2016 00:29:03 -0300 Subject: Adding the basics graphics elements The base is done, bus under contruction --- Project/Workspace.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Project/Workspace.h (limited to 'Project/Workspace.h') diff --git a/Project/Workspace.h b/Project/Workspace.h new file mode 100644 index 0000000..193d370 --- /dev/null +++ b/Project/Workspace.h @@ -0,0 +1,35 @@ +#ifndef WORKSPACE_H +#define WORKSPACE_H + +#include +#include +#include +#include + +#include "WorkspaceBase.h" +#include "Bus.h" + +class Workspace : public WorkspaceBase +{ + protected: + virtual void OnLeftClickDown(wxMouseEvent& event); + virtual void OnPaint(wxPaintEvent& event); + + void SetViewport(); + + wxGLContext* m_glContext; + wxString m_name; + + std::vector m_elementList; + + public: + Workspace(wxWindow* parent, wxString name = wxEmptyString); + ~Workspace(); + + void Redraw() { this->Refresh(); } + + wxString GetName() const { return m_name; } + void SetName(wxString name) { m_name = name; } +}; + +#endif // WORKSPACE_H -- cgit From 5e0be3d0a505781c31b3d23450fd92d4cc7b7ce7 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Mon, 1 Aug 2016 18:05:11 -0300 Subject: Attempt to implement Event Handler in Workspace fail --- Project/Workspace.h | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'Project/Workspace.h') diff --git a/Project/Workspace.h b/Project/Workspace.h index 193d370..ca4245f 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -6,12 +6,19 @@ #include #include +class MouseEventsHandler; + #include "WorkspaceBase.h" +//#include "MouseEventsHandler.h" #include "Bus.h" +class Camera; + class Workspace : public WorkspaceBase { protected: + virtual void OnMouseMotion(wxMouseEvent& event); + virtual void OnKeyDown(wxKeyEvent& event) = 0; virtual void OnLeftClickDown(wxMouseEvent& event); virtual void OnPaint(wxPaintEvent& event); @@ -19,17 +26,44 @@ class Workspace : public WorkspaceBase wxGLContext* m_glContext; wxString m_name; - - std::vector m_elementList; + + bool m_insertMode = false; + bool m_dragMode = false; + + std::vector m_elementList; public: Workspace(wxWindow* parent, wxString name = wxEmptyString); ~Workspace(); - - void Redraw() { this->Refresh(); } + + MouseEventsHandler* m_mouseEventsHandler; + Camera* m_camera; wxString GetName() const { return m_name; } void SetName(wxString name) { m_name = name; } + void SetDragMode(bool dragMode) { this->m_dragMode = dragMode; } + void SetInsertMode(bool insertMode) { this->m_insertMode = insertMode; } + bool IsDragMode() const { return m_dragMode; } + const std::vector& GetElementList() const { 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 -- cgit From 0ac91e091e52cae5745b14d62f77f905e559cf92 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Tue, 2 Aug 2016 01:01:20 -0300 Subject: Cycle dependence fixed. Next step: remove mouse handler --- Project/Workspace.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'Project/Workspace.h') diff --git a/Project/Workspace.h b/Project/Workspace.h index ca4245f..ef837fb 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -6,11 +6,14 @@ #include #include +#include "WorkspaceBase.h" + class MouseEventsHandler; +class Element; +class Bus; -#include "WorkspaceBase.h" //#include "MouseEventsHandler.h" -#include "Bus.h" +//#include "Bus.h" class Camera; @@ -18,7 +21,7 @@ class Workspace : public WorkspaceBase { protected: virtual void OnMouseMotion(wxMouseEvent& event); - virtual void OnKeyDown(wxKeyEvent& event) = 0; + virtual void OnKeyDown(wxKeyEvent& event) { event.Skip(); }; virtual void OnLeftClickDown(wxMouseEvent& event); virtual void OnPaint(wxPaintEvent& event); @@ -33,18 +36,19 @@ class Workspace : public WorkspaceBase std::vector m_elementList; public: + Workspace(); Workspace(wxWindow* parent, wxString name = wxEmptyString); ~Workspace(); MouseEventsHandler* m_mouseEventsHandler; - Camera* m_camera; + Camera* m_camera; // why public? wxString GetName() const { return m_name; } void SetName(wxString name) { m_name = name; } - void SetDragMode(bool dragMode) { this->m_dragMode = dragMode; } - void SetInsertMode(bool insertMode) { this->m_insertMode = insertMode; } + void SetDragMode(bool dragMode = true) { this->m_dragMode = dragMode; } + void SetInsertMode(bool insertMode = true) { this->m_insertMode = insertMode; } bool IsDragMode() const { return m_dragMode; } - const std::vector& GetElementList() const { return m_elementList; } + std::vector GetElementList() { return m_elementList; } bool IsInsertMode() const { return m_insertMode; } void Redraw() { this->Refresh(); } }; -- cgit From 78aac544e1e77f5405260797cee4b94d7a0dfe32 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Tue, 2 Aug 2016 17:34:42 -0300 Subject: Bus controllers under implementation Events handler removed --- Project/Workspace.h | 56 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'Project/Workspace.h') diff --git a/Project/Workspace.h b/Project/Workspace.h index ef837fb..e093105 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -5,69 +5,79 @@ #include #include #include +#include #include "WorkspaceBase.h" -class MouseEventsHandler; +class Camera; class Element; -class Bus; - -//#include "MouseEventsHandler.h" -//#include "Bus.h" -class Camera; +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) { event.Skip(); }; + 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; + //bool m_insertMode = false; + //bool m_dragMode = false; + WorkspaceMode m_mode = MODE_EDIT; std::vector m_elementList; + + void UpdateStatusBar(); public: Workspace(); - Workspace(wxWindow* parent, wxString name = wxEmptyString); + Workspace(wxWindow* parent, wxString name = wxEmptyString, wxStatusBar* statusBar = NULL); ~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 GetElementList() { return m_elementList; } - bool IsInsertMode() const { return m_insertMode; } - void Redraw() { this->Refresh(); } + void Redraw() { m_glCanvas->Refresh(); } }; class Camera { - private: + protected: wxPoint2DDouble m_translation; + wxPoint2DDouble m_translationStartPt; double m_scale; + + wxPoint2DDouble m_mousePosition; public: Camera(); ~Camera(); - void SetScale(double scale) { this->m_scale = scale; } - void SetTranslation(const wxPoint2DDouble& translation) { this->m_translation = translation; } + 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; } - const wxPoint2DDouble GetTranslation() const { return m_translation; } - wxPoint2DDouble ScreenToWorld(wxPoint2DDouble screenCoords); + wxPoint2DDouble GetTranslation() const { return m_translation; } + wxPoint2DDouble GetMousePosition(bool worldCoords = true) const; + wxPoint2DDouble ScreenToWorld(wxPoint2DDouble screenCoords) const; }; #endif // WORKSPACE_H -- cgit From 0b720e578e0e91262e04651ce81cd2e7f6828967 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Wed, 3 Aug 2016 00:15:54 -0300 Subject: More controllers add to bus Next step: move elements --- Project/Workspace.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Project/Workspace.h') diff --git a/Project/Workspace.h b/Project/Workspace.h index e093105..3c847a3 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -15,6 +15,7 @@ class Element; enum WorkspaceMode { MODE_EDIT = 0, + MODE_EDIT_ELEMENT, MODE_DRAG, MODE_INSERT }; -- cgit From 46c9d3fe586fb5c8ac75384b62a79971f96a5b88 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Wed, 3 Aug 2016 17:43:25 -0300 Subject: Bus implemented, selection not working Selection to move fail --- Project/Workspace.h | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'Project/Workspace.h') diff --git a/Project/Workspace.h b/Project/Workspace.h index 3c847a3..a7eca1b 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -14,14 +14,24 @@ class Element; enum WorkspaceMode { - MODE_EDIT = 0, - MODE_EDIT_ELEMENT, - MODE_DRAG, - MODE_INSERT + MODE_EDIT = 0, + MODE_MOVE_ELEMENT, + MODE_MOVE_PICKBOX, + MODE_DRAG, + MODE_INSERT }; 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 GetElementList() { return m_elementList; } + void Redraw() { m_glCanvas->Refresh(); } protected: virtual void OnLeftClickUp(wxMouseEvent& event); virtual void OnScroll(wxMouseEvent& event); @@ -35,38 +45,19 @@ class Workspace : public WorkspaceBase void SetViewport(); wxGLContext* m_glContext; - wxStatusBar* m_statusBar; + wxStatusBar* m_statusBar; Camera* m_camera; wxString m_name; - //bool m_insertMode = false; - //bool m_dragMode = false; - WorkspaceMode m_mode = MODE_EDIT; + WorkspaceMode m_mode = MODE_EDIT; std::vector 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 GetElementList() { return m_elementList; } - void Redraw() { m_glCanvas->Refresh(); } + void UpdateStatusBar(); }; class Camera { - protected: - wxPoint2DDouble m_translation; - wxPoint2DDouble m_translationStartPt; - double m_scale; - - wxPoint2DDouble m_mousePosition; - public: Camera(); ~Camera(); @@ -74,11 +65,18 @@ class 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;} + 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 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 -- cgit From 0899cd2aea1fe2e71184bd9c6a86f3bd988304e5 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Fri, 5 Aug 2016 17:30:57 -0300 Subject: Selection retangle implemented Some selections problems --- Project/Workspace.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Project/Workspace.h') diff --git a/Project/Workspace.h b/Project/Workspace.h index a7eca1b..2e47f3b 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -18,7 +18,8 @@ enum WorkspaceMode MODE_MOVE_ELEMENT, MODE_MOVE_PICKBOX, MODE_DRAG, - MODE_INSERT + MODE_INSERT, + MODE_SELECTION_RECT }; class Workspace : public WorkspaceBase @@ -54,6 +55,10 @@ class Workspace : public WorkspaceBase std::vector m_elementList; void UpdateStatusBar(); + + private: + wxRect2DDouble m_selectionRect; + wxPoint2DDouble m_startSelRect; }; class Camera -- cgit From b5324f48c855b0c82ccf6da7d5a008fe5cf1c17e Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Mon, 8 Aug 2016 17:01:53 -0300 Subject: Start Power Line implementation gogogogo --- Project/Workspace.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Project/Workspace.h') diff --git a/Project/Workspace.h b/Project/Workspace.h index 2e47f3b..8667fa5 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -11,6 +11,8 @@ class Camera; class Element; +class Bus; +class Line; enum WorkspaceMode { -- cgit From 05525745c0b0d189484da3c45f95356d7558e2cf Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Thu, 18 Aug 2016 19:10:04 -0300 Subject: Line improvements, context menu implemented Line still under construction, contex menu base implemented --- Project/Workspace.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Project/Workspace.h') diff --git a/Project/Workspace.h b/Project/Workspace.h index 8667fa5..e240206 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -21,7 +21,7 @@ enum WorkspaceMode MODE_MOVE_PICKBOX, MODE_DRAG, MODE_INSERT, - MODE_SELECTION_RECT + MODE_SELECTION_RECT }; class Workspace : public WorkspaceBase @@ -35,7 +35,9 @@ class Workspace : public WorkspaceBase void SetName(wxString name) { m_name = name; } std::vector 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); @@ -44,6 +46,7 @@ class Workspace : public WorkspaceBase virtual void OnKeyDown(wxKeyEvent& event); virtual void OnLeftClickDown(wxMouseEvent& event); virtual void OnPaint(wxPaintEvent& event); + virtual void OnPopupClick(wxCommandEvent& event); void SetViewport(); -- cgit