diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2017-04-24 17:39:03 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-24 17:39:03 -0300 |
commit | 7804c1bd2c0bd2a5f135c30b20991e8187581cc6 (patch) | |
tree | 725e524253d6fd714460402194b408cb33b80b3f /Project/Element.h | |
parent | 69131a727782090ffd7cb467f449e8f26d3d2949 (diff) | |
parent | 9529a6ed44645842adc6f938478acc1dfa17a284 (diff) | |
download | PSP.git-7804c1bd2c0bd2a5f135c30b20991e8187581cc6.tar.gz PSP.git-7804c1bd2c0bd2a5f135c30b20991e8187581cc6.tar.xz PSP.git-7804c1bd2c0bd2a5f135c30b20991e8187581cc6.zip |
Merge pull request #28 from Thales1330/wip/generic-controllers
Wip generic controllers. Chart view implementation required, creating new branch....
Diffstat (limited to 'Project/Element.h')
-rw-r--r-- | Project/Element.h | 69 |
1 files changed, 43 insertions, 26 deletions
diff --git a/Project/Element.h b/Project/Element.h index 8a9f56f..4935f11 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -9,7 +9,7 @@ #include <complex> -#include <wx/log.h> +//#include <wx/log.h> /** * @enum PickboxID @@ -225,12 +225,19 @@ public: virtual std::vector<wxPoint2DDouble> GetPointList() const { return m_pointList; } /** - * @brief Add a parent to the element. The parent must be a bus. The element basic points are calculated in this - * method, so apply this when the element is being inserted. + * @brief Add a parent to the element. This method must be used on power elements that connect to a bus, so the + * parent must be a bus. + * The element basic points are calculated in this method, so apply this when the element is being inserted. * @param parent Element parent. * @param position Node position in the parent. */ - virtual bool AddParent(Element* parent, wxPoint2DDouble position) = 0; + virtual bool AddParent(Element* parent, wxPoint2DDouble position) { return false; } + + /** + * @brief Add a parent to the element. + * @param parent Element parent. + */ + virtual void AddParent(Element* parent) { m_parentList.push_back(parent); } /** * @brief Checks if the element contains a position. @@ -380,29 +387,29 @@ public: * @return True if the element constains the pickbox, false otherwise. */ virtual bool PickboxContains(wxPoint2DDouble position) { return false; } - + /** * @brief Move the pickbox. * @param position position that the pickbox will be moved. */ virtual void MovePickbox(wxPoint2DDouble position) {} - + /** * @brief Get the best cursor to shown to the user when the mouse is above a pickbox. * @return Cursor. */ virtual wxCursor GetBestPickboxCursor() const { return wxCURSOR_ARROW; } - + /** * @brief Remove the pickboxes. */ virtual void ResetPickboxes() { m_activePickboxID = ID_PB_NONE; } - + /** * @brief Remove the active nodes. */ virtual void ResetNodes() { m_activeNodeID = 0; } - + /** * @brief Convert the element position to screen position. * @param translation System translation. @@ -412,7 +419,7 @@ public: */ virtual wxPoint2DDouble WorldToScreen(wxPoint2DDouble translation, double scale, double offsetX = 0.0, double offsetY = 0.0) const; - + /** * @brief Convert a generic position to screen position. * @param position Position to be converted. @@ -426,8 +433,7 @@ public: double scale, double offsetX = 0.0, double offsetY = 0.0) const; - virtual bool - + /** * @brief Check if two roteted rectangles intersect. * @param rect1 First rect. @@ -435,6 +441,7 @@ public: * @param angle1 Rotation algle of first rectangle. * @param angle2 Rotation angle of second rectangle. */ + virtual bool RotatedRectanglesIntersects(wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const; /** @@ -451,7 +458,7 @@ public: double finalAngle, int numSegments, GLenum mode = GL_LINE_LOOP) const; - + /** * @brief Draw rectangle. * @param position Rectangle position. @@ -460,41 +467,41 @@ public: * @param mode OpenGl primitive. */ virtual void DrawRectangle(wxPoint2DDouble position, double width, double height, GLenum mode = GL_QUADS) const; - + /** * @brief Draw rectangle. * @param points Rectangle vertices. * @param mode OpenGl primitive. */ virtual void DrawRectangle(wxPoint2DDouble* points, GLenum mode = GL_QUADS) const; - + /** * @brief Draw a triangle. * @param points Triangle vertices. * @param mode OpenGl primitive. */ virtual void DrawTriangle(std::vector<wxPoint2DDouble> points, GLenum mode = GL_TRIANGLES) const; - + /** * @brief Draw a point. * @param position Point position. * @param size Point size. */ virtual void DrawPoint(wxPoint2DDouble position, double size) const; - + /** * @brief Draw line. * @param points Line vertices. * @param mode OpenGl primitive. */ virtual void DrawLine(std::vector<wxPoint2DDouble> points, GLenum mode = GL_LINE_STRIP) const; - + /** * @brief Draw pickbox. * @param position Pickbox position. */ virtual void DrawPickbox(wxPoint2DDouble position) const; - + /** * @brief Rotate a point as element position being the origin. * @param pointToRotate Point that will be rotated. @@ -508,16 +515,16 @@ public: * @return Parent list. */ virtual std::vector<Element*> GetParentList() const { return m_parentList; } - + /** * @brief Get the Child list. * @return Child List. */ virtual std::vector<Element*> GetChildList() const { return m_childList; } - - //virtual wxPoint2DDouble GetMoveStartPosition() const { return m_moveStartPt; } - //virtual wxPoint2DDouble GetMovePosition() const { return m_movePos; } - + + // virtual wxPoint2DDouble GetMoveStartPosition() const { return m_moveStartPt; } + // virtual wxPoint2DDouble GetMovePosition() const { return m_movePos; } + /** * @brief Calculate the element boundaries. * @param leftUp Top-left position of the element. @@ -538,7 +545,7 @@ public: * @return True if the form is shown, false otherwise. */ virtual bool ShowForm(wxWindow* parent, Element* element) { return false; } - + /** * @brief Get a double value from a string. Show a error message if the conversion fail. * @param parent Message box parent. @@ -547,7 +554,7 @@ public: * @param errorMsg Error message. */ bool DoubleFromString(wxWindow* parent, wxString strValue, double& value, wxString errorMsg); - + /** * @brief Convert a string to int. Show a error message if the conversion fail. * @param parent Message box parent. @@ -564,6 +571,14 @@ public: */ static wxString StringFromDouble(double value, int minDecimal = 1); + /** + * @brief Calculate the distance between a line (formed by point list) and a point. + * @param point origin point. + * @param segmentNumber Sotores the segment number clicked + * @return The distance between the point and the line. + */ + virtual double PointToLineDistance(wxPoint2DDouble point, int* segmentNumber = NULL) const; + protected: int m_elementID = 0; std::vector<Element*> m_parentList; @@ -594,6 +609,8 @@ protected: wxPoint2DDouble m_movePos; bool m_online = true; + + OpenGLColour m_selectionColour; }; #endif // ELEMENT_H |