summaryrefslogtreecommitdiffstats
path: root/Project/Element.h
diff options
context:
space:
mode:
Diffstat (limited to 'Project/Element.h')
-rw-r--r--Project/Element.h62
1 files changed, 43 insertions, 19 deletions
diff --git a/Project/Element.h b/Project/Element.h
index 1a6b73e..6c07ec9 100644
--- a/Project/Element.h
+++ b/Project/Element.h
@@ -21,18 +21,19 @@ enum ContextMenuID
{
ID_EDIT_BUS = 0,
ID_EDIT_LINE,
- ID_EDIT_TRANSFORMER,
- ID_EDIT_SYNCGENERATOR,
- ID_EDIT_INDMOTOR,
- ID_EDIT_SYNCMOTOR,
- ID_EDIT_LOAD,
- ID_EDIT_INDUCTOR,
+ ID_EDIT_TRANSFORMER,
+ ID_EDIT_SYNCGENERATOR,
+ ID_EDIT_INDMOTOR,
+ ID_EDIT_SYNCMOTOR,
+ ID_EDIT_LOAD,
+ ID_EDIT_INDUCTOR,
+ ID_EDIT_CAPACITOR,
ID_LINE_ADD_NODE,
ID_LINE_REMOVE_NODE,
ID_ROTATE,
- ID_DELETE
+ ID_DELETE
};
class Element
@@ -50,6 +51,7 @@ class Element
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; }
+ void SetOnline(bool online = true);
// Getters
wxRect2DDouble GetRect() const { return m_rect; }
wxPoint2DDouble GetPosition() const { return m_position; }
@@ -59,6 +61,7 @@ class Element
double GetWidth() const { return m_width; }
double GetAngle() const { return m_angle; }
bool IsPickboxShown() const { return m_showPickbox; }
+ bool IsOnline() const { return m_online; }
// Pure-virtuals methods
virtual bool AddParent(Element* parent, wxPoint2DDouble position) = 0;
virtual void Draw(wxPoint2DDouble translation, double scale) const = 0;
@@ -66,25 +69,29 @@ class Element
virtual bool Intersects(wxRect2DDouble rect) const = 0;
// General methods
- virtual void Rotate() {}
+ virtual void Rotate() {}
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 MoveNode(Element* parent, wxPoint2DDouble position) {}
virtual bool NodeContains(wxPoint2DDouble position) { return false; }
- virtual void UpdateNodes() {}
- virtual bool SetNodeParent(Element* parent) { return false; }
- virtual void RemoveParent(Element* parent) {}
+ virtual void UpdateNodes() {}
+ virtual bool SetNodeParent(Element* parent) { return false; }
+ virtual void RemoveParent(Element* parent) {}
virtual void RotateNode(Element* parent) {}
virtual wxPoint2DDouble GetSwitchPoint(Element* parent,
wxPoint2DDouble parentPoint,
wxPoint2DDouble secondPoint) const;
- virtual bool PickboxContains(wxPoint2DDouble position) { return false;}
+ virtual bool SwitchesContains(wxPoint2DDouble position) const;
+ virtual void UpdateSwitches();
+ virtual void DrawSwitches() const;
+
+ virtual bool PickboxContains(wxPoint2DDouble position) { return false; }
virtual void MovePickbox(wxPoint2DDouble position) {}
- virtual wxCursor GetBestPickboxCursor() const {return wxCURSOR_ARROW;}
+ virtual wxCursor GetBestPickboxCursor() const { return wxCURSOR_ARROW; }
virtual void ResetPickboxes() { m_activePickboxID = ID_PB_NONE; }
- virtual void ResetNodes() { m_activeNodeID= 0; }
+ virtual void ResetNodes() { m_activeNodeID = 0; }
virtual wxPoint2DDouble WorldToScreen(wxPoint2DDouble translation,
double scale,
double offsetX = 0.0,
@@ -94,13 +101,22 @@ class Element
double scale,
double offsetX = 0.0,
double offsetY = 0.0) const;
- virtual bool RotatedRectanglesIntersects(wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const;
+ virtual bool RotatedRectanglesIntersects(wxRect2DDouble rect1,
+ wxRect2DDouble rect2,
+ double angle1,
+ double angle2) const;
+
virtual void DrawCircle(wxPoint2DDouble position, double radius, int numSegments, GLenum mode = GL_LINE_LOOP) const;
- virtual void DrawArc(wxPoint2DDouble position, double radius, double initAngle, double finalAngle, int numSegments, GLenum mode = GL_LINE_LOOP) const;
+ virtual void DrawArc(wxPoint2DDouble position,
+ double radius,
+ double initAngle,
+ double finalAngle,
+ 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 DrawTriangle(std::vector<wxPoint2DDouble> points, GLenum mode = GL_TRIANGLES) const;
- virtual void DrawPoint(wxPoint2DDouble position, double size) const;
+ virtual void DrawTriangle(std::vector<wxPoint2DDouble> points, GLenum mode = GL_TRIANGLES) const;
+ virtual void DrawPoint(wxPoint2DDouble position, double size) const;
virtual void DrawLine(std::vector<wxPoint2DDouble> points, GLenum mode = GL_LINE_STRIP) const;
virtual void DrawPickbox(wxPoint2DDouble position) const;
virtual wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees = true) const;
@@ -118,6 +134,9 @@ class Element
double m_angle = 0.0;
double m_borderSize = 2.0;
double m_rotationAngle = 45.0;
+ double m_switchSize = 10.0;
+
+ std::vector<wxRect2DDouble> m_switchRect;
bool m_selected = false;
bool m_dragging = false;
@@ -126,8 +145,13 @@ class Element
int m_activePickboxID = ID_PB_NONE;
int m_activeNodeID = 0;
+ std::vector<wxPoint2DDouble> m_pointList;
+ std::vector<wxPoint2DDouble> m_movePts;
+
wxPoint2DDouble m_moveStartPt;
wxPoint2DDouble m_movePos;
+
+ bool m_online = true;
};
#endif // ELEMENT_H