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/Element.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Project/Element.h (limited to 'Project/Element.h') diff --git a/Project/Element.h b/Project/Element.h new file mode 100644 index 0000000..56b2621 --- /dev/null +++ b/Project/Element.h @@ -0,0 +1,60 @@ +#ifndef ELEMENT_H +#define ELEMENT_H + +#include +#include +#include + +class Element +{ + protected: + wxRect2DDouble m_rect; + wxPoint2DDouble m_position; + double m_width = 0.0; + double m_height = 0.0; + double m_angle = 0.0; + double m_borderSize = 2.0; + + bool m_selected = false; + bool m_dragging = false; + bool m_showPickbox = false; + + public: + Element(); + virtual ~Element(); + + // Setters + void SetDragging(bool dragging = true) { this->m_dragging = dragging; } + void SetHeight(double height) { this->m_height = height; } + void SetPosition(const wxPoint2DDouble position); + void SetSelected(bool selected = true) { this->m_selected = selected; } + void SetWidth(double width) { this->m_width = width; } + void SetAngle(double angle) { this->m_angle = angle; } + void ShowPickbox(bool showPickbox = true) { this->m_showPickbox = showPickbox; } + void SetBorderSize(double borderSize) { this->m_borderSize = borderSize; } + // Getters + wxRect2DDouble GetRect() const { return m_rect; } + wxPoint2DDouble GetPosition() const { return m_position; } + bool IsDragging() const { return m_dragging; } + double GetHeight() const { return m_height; } + bool IsSelected() const { return m_selected; } + double GetWidth() const { return m_width; } + double GetAngle() const { return m_angle; } + bool IsPickboxShown() const { return m_showPickbox; } + // Métodos virtuais + virtual void Draw(wxPoint2DDouble translation, double scale) const = 0; + virtual bool Contains(wxPoint2DDouble position) const = 0; + virtual int PickboxContains(wxPoint2DDouble position) const = 0; + virtual void MovePickbox(wxPoint2DDouble position, int pickboxID) = 0; + virtual wxCursor GetBestPickboxCursor() const = 0; + + // Métodos gerais + wxPoint2DDouble WorldToScreen(wxPoint2DDouble translation, + double scale, + double offsetX = 0.0, + double offsetY = 0.0) const; + void DrawCircle(wxPoint2DDouble position, double radius, int numSegments, GLenum mode = GL_LINE_LOOP) const; + void DrawRectangle(wxPoint2DDouble position, double width, double height, GLenum mode = GL_QUADS) const; +}; + +#endif // ELEMENT_H -- 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/Element.h | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'Project/Element.h') diff --git a/Project/Element.h b/Project/Element.h index 56b2621..7023704 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -7,18 +7,6 @@ class Element { - protected: - wxRect2DDouble m_rect; - wxPoint2DDouble m_position; - double m_width = 0.0; - double m_height = 0.0; - double m_angle = 0.0; - double m_borderSize = 2.0; - - bool m_selected = false; - bool m_dragging = false; - bool m_showPickbox = false; - public: Element(); virtual ~Element(); @@ -41,20 +29,36 @@ class Element double GetWidth() const { return m_width; } double GetAngle() const { return m_angle; } bool IsPickboxShown() const { return m_showPickbox; } - // Métodos virtuais + // Pure-virtuals methods virtual void Draw(wxPoint2DDouble translation, double scale) const = 0; + virtual void Rotate() = 0; virtual bool Contains(wxPoint2DDouble position) const = 0; virtual int PickboxContains(wxPoint2DDouble position) const = 0; virtual void MovePickbox(wxPoint2DDouble position, int pickboxID) = 0; virtual wxCursor GetBestPickboxCursor() const = 0; - // Métodos gerais + // General methods wxPoint2DDouble WorldToScreen(wxPoint2DDouble translation, double scale, double offsetX = 0.0, double offsetY = 0.0) const; void DrawCircle(wxPoint2DDouble position, double radius, int numSegments, GLenum mode = GL_LINE_LOOP) const; void DrawRectangle(wxPoint2DDouble position, double width, double height, GLenum mode = GL_QUADS) const; + void DrawRectangle(wxPoint2DDouble* points, GLenum mode = GL_QUADS) const; + void DrawPickbox(wxPoint2DDouble position) const; + wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees = true) const; + + protected: + wxRect2DDouble m_rect; + wxPoint2DDouble m_position; + double m_width = 0.0; + double m_height = 0.0; + double m_angle = 0.0; + double m_borderSize = 2.0; + + bool m_selected = false; + bool m_dragging = false; + bool m_showPickbox = false; }; #endif // ELEMENT_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/Element.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'Project/Element.h') diff --git a/Project/Element.h b/Project/Element.h index 7023704..bb74910 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -5,6 +5,17 @@ #include #include +enum PickboxID +{ + ID_PB_NONE = 0, + ID_PB_RIGHT, + ID_PB_LEFT, + ID_PB_RIGHT_BOTTOM, + ID_PB_RIGHT_TOP, + ID_PB_LEFT_BOTTOM, + ID_PB_LEFT_TOP +}; + class Element { public: @@ -33,8 +44,8 @@ class Element virtual void Draw(wxPoint2DDouble translation, double scale) const = 0; virtual void Rotate() = 0; virtual bool Contains(wxPoint2DDouble position) const = 0; - virtual int PickboxContains(wxPoint2DDouble position) const = 0; - virtual void MovePickbox(wxPoint2DDouble position, int pickboxID) = 0; + virtual bool PickboxContains(wxPoint2DDouble position) = 0; + virtual void MovePickbox(wxPoint2DDouble position) = 0; virtual wxCursor GetBestPickboxCursor() const = 0; // General methods @@ -59,6 +70,8 @@ class Element bool m_selected = false; bool m_dragging = false; bool m_showPickbox = false; + + PickboxID m_activePickboxID = ID_PB_NONE; }; #endif // ELEMENT_H -- 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/Element.h | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'Project/Element.h') diff --git a/Project/Element.h b/Project/Element.h index bb74910..1196f64 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -7,13 +7,13 @@ enum PickboxID { - ID_PB_NONE = 0, - ID_PB_RIGHT, - ID_PB_LEFT, - ID_PB_RIGHT_BOTTOM, - ID_PB_RIGHT_TOP, - ID_PB_LEFT_BOTTOM, - ID_PB_LEFT_TOP + ID_PB_NONE = 0, + ID_PB_RIGHT, + ID_PB_LEFT, + ID_PB_RIGHT_BOTTOM, + ID_PB_RIGHT_TOP, + ID_PB_LEFT_BOTTOM, + ID_PB_LEFT_TOP }; class Element @@ -49,17 +49,20 @@ class Element virtual wxCursor GetBestPickboxCursor() const = 0; // General methods + virtual void StartMove(wxPoint2DDouble position); + virtual void Move(wxPoint2DDouble position); + void ResetPickboxes() { m_activePickboxID = ID_PB_NONE; } wxPoint2DDouble WorldToScreen(wxPoint2DDouble translation, double scale, double offsetX = 0.0, double offsetY = 0.0) const; void DrawCircle(wxPoint2DDouble position, double radius, int numSegments, GLenum mode = GL_LINE_LOOP) const; void DrawRectangle(wxPoint2DDouble position, double width, double height, GLenum mode = GL_QUADS) const; - void DrawRectangle(wxPoint2DDouble* points, GLenum mode = GL_QUADS) const; - void DrawPickbox(wxPoint2DDouble position) const; + void DrawRectangle(wxPoint2DDouble* points, GLenum mode = GL_QUADS) const; + void DrawPickbox(wxPoint2DDouble position) const; wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees = true) const; - - protected: + + protected: wxRect2DDouble m_rect; wxPoint2DDouble m_position; double m_width = 0.0; @@ -70,8 +73,11 @@ class Element bool m_selected = false; bool m_dragging = false; bool m_showPickbox = false; - - PickboxID m_activePickboxID = ID_PB_NONE; + + int m_activePickboxID = ID_PB_NONE; + + wxPoint2DDouble m_moveStartPt; + wxPoint2DDouble m_movePos; }; #endif // ELEMENT_H -- cgit From 139b076149594e6cf508aea269b061aa8b428d9c Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Sun, 7 Aug 2016 21:36:40 -0300 Subject: Some minor fixes --- Project/Element.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Project/Element.h') diff --git a/Project/Element.h b/Project/Element.h index 1196f64..3080703 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -44,6 +44,7 @@ class Element virtual void Draw(wxPoint2DDouble translation, double scale) const = 0; virtual void Rotate() = 0; virtual bool Contains(wxPoint2DDouble position) const = 0; + virtual bool Intersects(wxRect2DDouble rect) const = 0; virtual bool PickboxContains(wxPoint2DDouble position) = 0; virtual void MovePickbox(wxPoint2DDouble position) = 0; virtual wxCursor GetBestPickboxCursor() const = 0; -- 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/Element.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Project/Element.h') diff --git a/Project/Element.h b/Project/Element.h index 3080703..a104ec5 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -41,6 +41,7 @@ class Element double GetAngle() const { return m_angle; } bool IsPickboxShown() const { return m_showPickbox; } // Pure-virtuals methods + virtual void Insert(Element* parent, wxPoint2DDouble position) = 0; virtual void Draw(wxPoint2DDouble translation, double scale) const = 0; virtual void Rotate() = 0; virtual bool Contains(wxPoint2DDouble position) const = 0; -- cgit From 0a85e05fa7aa0e2b950c2c3bcec5d45f25b1c0e2 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Tue, 9 Aug 2016 17:45:09 -0300 Subject: Line under implementation --- Project/Element.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Project/Element.h') diff --git a/Project/Element.h b/Project/Element.h index a104ec5..dfffba2 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -41,7 +41,7 @@ class Element double GetAngle() const { return m_angle; } bool IsPickboxShown() const { return m_showPickbox; } // Pure-virtuals methods - virtual void Insert(Element* parent, wxPoint2DDouble position) = 0; + virtual bool AddParent(Element* parent, wxPoint2DDouble position) = 0; virtual void Draw(wxPoint2DDouble translation, double scale) const = 0; virtual void Rotate() = 0; virtual bool Contains(wxPoint2DDouble position) const = 0; @@ -51,6 +51,7 @@ class Element virtual wxCursor GetBestPickboxCursor() const = 0; // General methods + virtual void AddPoint(wxPoint2DDouble point) {}; virtual void StartMove(wxPoint2DDouble position); virtual void Move(wxPoint2DDouble position); void ResetPickboxes() { m_activePickboxID = ID_PB_NONE; } -- cgit From e58cec073cbd982246898c733ae21b9f2b92b2b7 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Wed, 17 Aug 2016 17:19:58 -0300 Subject: Line under implementation --- Project/Element.h | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'Project/Element.h') diff --git a/Project/Element.h b/Project/Element.h index dfffba2..1287bc4 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -41,31 +41,42 @@ class Element double GetAngle() const { return m_angle; } bool IsPickboxShown() const { return m_showPickbox; } // Pure-virtuals methods - virtual bool AddParent(Element* parent, wxPoint2DDouble position) = 0; + virtual bool AddParent(Element* parent, wxPoint2DDouble position) = 0; virtual void Draw(wxPoint2DDouble translation, double scale) const = 0; virtual void Rotate() = 0; virtual bool Contains(wxPoint2DDouble position) const = 0; - virtual bool Intersects(wxRect2DDouble rect) const = 0; + virtual bool Intersects(wxRect2DDouble rect) const = 0; virtual bool PickboxContains(wxPoint2DDouble position) = 0; virtual void MovePickbox(wxPoint2DDouble position) = 0; virtual wxCursor GetBestPickboxCursor() const = 0; // General methods - virtual void AddPoint(wxPoint2DDouble point) {}; + virtual void AddPoint(wxPoint2DDouble point){}; virtual void StartMove(wxPoint2DDouble position); - virtual void Move(wxPoint2DDouble position); - void ResetPickboxes() { m_activePickboxID = ID_PB_NONE; } - wxPoint2DDouble WorldToScreen(wxPoint2DDouble translation, - double scale, - double offsetX = 0.0, - double offsetY = 0.0) const; - void DrawCircle(wxPoint2DDouble position, double radius, int numSegments, GLenum mode = GL_LINE_LOOP) const; - void DrawRectangle(wxPoint2DDouble position, double width, double height, GLenum mode = GL_QUADS) const; - void DrawRectangle(wxPoint2DDouble* points, GLenum mode = GL_QUADS) const; - void DrawPickbox(wxPoint2DDouble position) const; - wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees = true) const; + virtual void Move(wxPoint2DDouble position); + virtual void MoveNode(Element* parent, wxPoint2DDouble position){}; + virtual wxPoint2DDouble GetSwitchPoint(Element* parent, + wxPoint2DDouble parentPoint, + wxPoint2DDouble secondPoint) const; + virtual void ResetPickboxes() { m_activePickboxID = ID_PB_NONE; } + virtual wxPoint2DDouble WorldToScreen(wxPoint2DDouble translation, + double scale, + double offsetX = 0.0, + double offsetY = 0.0) const; + virtual void DrawCircle(wxPoint2DDouble position, double radius, int numSegments, GLenum mode = GL_LINE_LOOP) const; + virtual void DrawRectangle(wxPoint2DDouble position, double width, double height, GLenum mode = GL_QUADS) const; + virtual void DrawRectangle(wxPoint2DDouble* points, GLenum mode = GL_QUADS) const; + virtual void DrawLine(std::vector points, GLenum mode = GL_LINE_STRIP) const; + virtual void DrawPickbox(wxPoint2DDouble position) const; + virtual wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees = true) const; + + virtual std::vector GetParentList() const { return m_parentList; } + virtual wxPoint2DDouble GetMoveStartPosition() const { return m_moveStartPt; } + virtual wxPoint2DDouble GetMovePosition() const { return m_movePos; } protected: + std::vector m_parentList; + wxRect2DDouble m_rect; wxPoint2DDouble m_position; double m_width = 0.0; @@ -80,7 +91,7 @@ class Element int m_activePickboxID = ID_PB_NONE; wxPoint2DDouble m_moveStartPt; - wxPoint2DDouble m_movePos; + wxPoint2DDouble m_movePos; }; #endif // ELEMENT_H -- 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/Element.h | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'Project/Element.h') diff --git a/Project/Element.h b/Project/Element.h index 1287bc4..eb89640 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -3,6 +3,7 @@ #include #include +#include #include enum PickboxID @@ -16,6 +17,17 @@ enum PickboxID ID_PB_LEFT_TOP }; +enum ContextMenuID +{ + ID_EDIT_BUS = 0, + ID_EDIT_LINE, + + ID_LINE_ADD_NODE, + ID_LINE_REMOVE_NODE, + + ID_ROTATE +}; + class Element { public: @@ -51,10 +63,12 @@ class Element virtual wxCursor GetBestPickboxCursor() const = 0; // General methods - virtual void AddPoint(wxPoint2DDouble point){}; + virtual bool GetContextMenu(wxMenu& menu) { return false; } + virtual void AddPoint(wxPoint2DDouble point) {} virtual void StartMove(wxPoint2DDouble position); virtual void Move(wxPoint2DDouble position); virtual void MoveNode(Element* parent, wxPoint2DDouble position){}; + virtual void RotateNode(Element* parent) {} virtual wxPoint2DDouble GetSwitchPoint(Element* parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const; @@ -63,17 +77,21 @@ class Element double scale, double offsetX = 0.0, double offsetY = 0.0) const; + virtual wxPoint2DDouble WorldToScreen(wxPoint2DDouble position, + wxPoint2DDouble translation, + double scale, + double offsetX = 0.0, + double offsetY = 0.0) const; virtual void DrawCircle(wxPoint2DDouble position, double radius, int numSegments, GLenum mode = GL_LINE_LOOP) const; virtual void DrawRectangle(wxPoint2DDouble position, double width, double height, GLenum mode = GL_QUADS) const; virtual void DrawRectangle(wxPoint2DDouble* points, GLenum mode = GL_QUADS) const; virtual void DrawLine(std::vector points, GLenum mode = GL_LINE_STRIP) const; virtual void DrawPickbox(wxPoint2DDouble position) const; virtual wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees = true) const; - - virtual std::vector GetParentList() const { return m_parentList; } - virtual wxPoint2DDouble GetMoveStartPosition() const { return m_moveStartPt; } - virtual wxPoint2DDouble GetMovePosition() const { return m_movePos; } + virtual std::vector GetParentList() const { return m_parentList; } + virtual wxPoint2DDouble GetMoveStartPosition() const { return m_moveStartPt; } + virtual wxPoint2DDouble GetMovePosition() const { return m_movePos; } protected: std::vector m_parentList; @@ -83,6 +101,7 @@ class Element double m_height = 0.0; double m_angle = 0.0; double m_borderSize = 2.0; + double m_rotationAngle = 45.0; bool m_selected = false; bool m_dragging = false; -- cgit