summaryrefslogtreecommitdiffstats
path: root/Project/Element.h
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2016-12-29 02:32:50 -0200
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2016-12-29 02:32:50 -0200
commitd792fcf7b2a5862ac86ee69aa86021b5637ca8ee (patch)
treec00bb1d27666ee7d42839efbd420369b2a0d24e3 /Project/Element.h
parentfb9de1b7935376897f1c93676ab1faeb1ea25f25 (diff)
downloadPSP.git-d792fcf7b2a5862ac86ee69aa86021b5637ca8ee.tar.gz
PSP.git-d792fcf7b2a5862ac86ee69aa86021b5637ca8ee.tar.xz
PSP.git-d792fcf7b2a5862ac86ee69aa86021b5637ca8ee.zip
Copy paste implemented
Some bugs on the text
Diffstat (limited to 'Project/Element.h')
-rw-r--r--Project/Element.h103
1 files changed, 60 insertions, 43 deletions
diff --git a/Project/Element.h b/Project/Element.h
index 0dd7dea..d5443de 100644
--- a/Project/Element.h
+++ b/Project/Element.h
@@ -11,7 +11,8 @@
#include <wx/log.h>
-enum PickboxID {
+enum PickboxID
+{
ID_PB_NONE = 0,
ID_PB_RIGHT,
ID_PB_LEFT,
@@ -21,7 +22,8 @@ enum PickboxID {
ID_PB_LEFT_TOP
};
-enum ContextMenuID {
+enum ContextMenuID
+{
ID_EDIT_BUS = 0,
ID_EDIT_LINE,
ID_EDIT_TRANSFORMER,
@@ -40,7 +42,8 @@ enum ContextMenuID {
ID_DELETE
};
-enum ElectricalUnit {
+enum ElectricalUnit
+{
UNIT_PU = 0,
UNIT_V,
UNIT_kV,
@@ -63,7 +66,8 @@ enum ElectricalUnit {
UNIT_RADIAN
};
-enum FaultData {
+enum FaultData
+{
FAULT_THREEPHASE = 0,
FAULT_2LINE,
FAULT_2LINE_GROUND,
@@ -73,31 +77,42 @@ enum FaultData {
FAULT_LINE_C
};
-enum SwitchingType { SW_INSERT = 0, SW_REMOVE };
+enum SwitchingType
+{
+ SW_INSERT = 0,
+ SW_REMOVE
+};
-enum PowerFlowDirection { PF_NONE = 0, PF_TO_BUS, PF_TO_ELEMENT, PF_BUS1_TO_BUS2, PF_BUS2_TO_BUS1 };
+enum PowerFlowDirection
+{
+ PF_NONE = 0,
+ PF_TO_BUS,
+ PF_TO_ELEMENT,
+ PF_BUS1_TO_BUS2,
+ PF_BUS2_TO_BUS1
+};
-struct SwitchingData {
+struct SwitchingData
+{
std::vector<SwitchingType> swType;
std::vector<double> swTime;
};
class OpenGLColour
{
-public:
- OpenGLColour() {}
- OpenGLColour(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha) { SetRGBA(red, green, blue, alpha); }
+ public:
+ OpenGLColour();
+ OpenGLColour(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
virtual ~OpenGLColour() {}
void SetRGBA(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
- GLdouble* GetRGBA() const { return rgba; }
-
-protected:
- GLdouble* rgba = new GLdouble(4);
+ const GLdouble* GetRGBA() const { return rgba; }
+ protected:
+ GLdouble rgba[4];
};
class Element
{
-public:
+ public:
Element();
virtual ~Element();
@@ -124,13 +139,13 @@ public:
bool IsPickboxShown() const { return m_showPickbox; }
bool IsOnline() const { return m_online; }
virtual std::vector<wxPoint2DDouble> GetPointList() const { return m_pointList; }
-
// Pure-virtuals methods
virtual bool AddParent(Element* parent, wxPoint2DDouble position) = 0;
virtual bool Contains(wxPoint2DDouble position) const = 0;
virtual bool Intersects(wxRect2DDouble rect) const = 0;
// General methods
+ virtual Element* GetCopy() { return NULL; }
virtual void Draw(wxPoint2DDouble translation, double scale) const {};
virtual void Rotate(bool clockwise = true) {}
virtual bool GetContextMenu(wxMenu& menu) { return false; }
@@ -144,8 +159,9 @@ public:
virtual void RemoveParent(Element* parent) {}
virtual void ReplaceParent(Element* oldParent, Element* newParent);
virtual void RotateNode(Element* parent, bool clockwise = true) {}
- virtual wxPoint2DDouble
- GetSwitchPoint(Element* parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const;
+ virtual wxPoint2DDouble GetSwitchPoint(Element* parent,
+ wxPoint2DDouble parentPoint,
+ wxPoint2DDouble secondPoint) const;
virtual bool SwitchesContains(wxPoint2DDouble position) const;
virtual void UpdateSwitches();
virtual void DrawSwitches() const;
@@ -158,23 +174,27 @@ public:
virtual wxCursor GetBestPickboxCursor() const { return wxCURSOR_ARROW; }
virtual void ResetPickboxes() { m_activePickboxID = ID_PB_NONE; }
virtual void ResetNodes() { m_activeNodeID = 0; }
- virtual wxPoint2DDouble
- WorldToScreen(wxPoint2DDouble translation, double scale, double offsetX = 0.0, double offsetY = 0.0) const;
+ virtual wxPoint2DDouble WorldToScreen(wxPoint2DDouble translation,
+ 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 bool
- RotatedRectanglesIntersects(wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const;
+ wxPoint2DDouble translation,
+ double scale,
+ double offsetX = 0.0,
+ double offsetY = 0.0) 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;
+ 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;
@@ -186,13 +206,11 @@ public:
virtual std::vector<Element*> GetParentList() const { return m_parentList; }
virtual wxPoint2DDouble GetMoveStartPosition() const { return m_moveStartPt; }
virtual wxPoint2DDouble GetMovePosition() const { return m_movePos; }
-
virtual void CalculateBoundaries(wxPoint2DDouble& leftUp, wxPoint2DDouble& rightBottom) const;
virtual void GeneralMenuItens(wxMenu& menu);
virtual bool ShowForm(wxWindow* parent, Element* element) { return false; }
-
bool DoubleFromString(wxWindow* parent, wxString strValue, double& value, wxString errorMsg);
bool IntFromString(wxWindow* parent, wxString strValue, int& value, wxString errorMsg);
@@ -204,11 +222,10 @@ public:
virtual SwitchingData GetSwitchingData() { return m_swData; }
virtual void SetPowerFlowDirection(PowerFlowDirection pfDirection) { m_pfDirection = pfDirection; }
virtual PowerFlowDirection GetPowerFlowDirection() const { return m_pfDirection; }
-
// Static methods
static wxString StringFromDouble(double value, int minDecimal = 1);
-protected:
+ protected:
std::vector<Element*> m_parentList;
wxRect2DDouble m_rect;
@@ -220,13 +237,13 @@ protected:
double m_rotationAngle = 45.0;
double m_switchSize = 10.0;
- OpenGLColour* m_busColour;
- OpenGLColour* m_onlineElementColour;
- OpenGLColour* m_offlineElementColour;
- OpenGLColour* m_closedSwitchColour;
- OpenGLColour* m_openedSwitchColour;
- OpenGLColour* m_selectionColour;
- OpenGLColour* m_powerFlowArrowColour;
+ OpenGLColour m_busColour;
+ OpenGLColour m_onlineElementColour;
+ OpenGLColour m_offlineElementColour;
+ OpenGLColour m_closedSwitchColour;
+ OpenGLColour m_openedSwitchColour;
+ OpenGLColour m_selectionColour;
+ OpenGLColour m_powerFlowArrowColour;
std::vector<wxRect2DDouble> m_switchRect;
@@ -251,4 +268,4 @@ protected:
SwitchingData m_swData;
};
-#endif // ELEMENT_H
+#endif // ELEMENT_H