summaryrefslogtreecommitdiffstats
path: root/Project
diff options
context:
space:
mode:
Diffstat (limited to 'Project')
-rw-r--r--Project/Element.cpp121
-rw-r--r--Project/Element.h65
-rw-r--r--Project/PowerElement.cpp128
-rw-r--r--Project/PowerElement.h158
-rw-r--r--Project/Project.mk2
-rw-r--r--Project/SwitchingForm.cpp4
-rw-r--r--Project/SwitchingForm.h6
-rw-r--r--Project/Text.h1
-rw-r--r--Project/Workspace.cpp28
-rw-r--r--Project/Workspace.h4
10 files changed, 312 insertions, 205 deletions
diff --git a/Project/Element.cpp b/Project/Element.cpp
index 53eaa26..76afab2 100644
--- a/Project/Element.cpp
+++ b/Project/Element.cpp
@@ -111,26 +111,6 @@ void Element::StartMove(wxPoint2DDouble position)
}
void Element::Move(wxPoint2DDouble position) { SetPosition(m_movePos + position - m_moveStartPt); }
-wxPoint2DDouble Element::GetSwitchPoint(Element* parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
-{
- double swLineSize = 25.0;
- wxPoint2DDouble swPoint = wxPoint2DDouble(parentPoint.m_x, parentPoint.m_y - swLineSize);
-
- // Rotate the second point (to compare).
- double angle = parent->GetAngle();
-
- secondPoint = wxPoint2DDouble(std::cos(wxDegToRad(-angle)) * (secondPoint.m_x - parentPoint.m_x) -
- std::sin(wxDegToRad(-angle)) * (secondPoint.m_y - parentPoint.m_y) + parentPoint.m_x,
- std::sin(wxDegToRad(-angle)) * (secondPoint.m_x - parentPoint.m_x) +
- std::cos(wxDegToRad(-angle)) * (secondPoint.m_y - parentPoint.m_y) + parentPoint.m_y);
-
- // Rotate
- if(secondPoint.m_y > parentPoint.m_y) angle -= 180.0;
- return wxPoint2DDouble(std::cos(wxDegToRad(angle)) * (swPoint.m_x - parentPoint.m_x) -
- std::sin(wxDegToRad(angle)) * (swPoint.m_y - parentPoint.m_y) + parentPoint.m_x,
- std::sin(wxDegToRad(angle)) * (swPoint.m_x - parentPoint.m_x) +
- std::cos(wxDegToRad(angle)) * (swPoint.m_y - parentPoint.m_y) + parentPoint.m_y);
-}
wxPoint2DDouble Element::WorldToScreen(wxPoint2DDouble translation, double scale, double offsetX, double offsetY) const
{
@@ -241,53 +221,6 @@ bool Element::RotatedRectanglesIntersects(wxRect2DDouble rect1,
return true;
}
-void Element::UpdateSwitches()
-{
- // General method, to one switch only.
- wxPoint2DDouble swCenter = wxPoint2DDouble(
- (m_pointList[0].m_x + m_pointList[1].m_x) / 2.0, (m_pointList[0].m_y + m_pointList[1].m_y) / 2.0);
- m_switchRect[0] = wxRect2DDouble(
- swCenter.m_x - m_switchSize / 2.0, swCenter.m_y - m_switchSize / 2.0, m_switchSize, m_switchSize);
-}
-
-void Element::DrawSwitches() const
-{
- int i = 0;
- for(auto it = m_parentList.begin(); it != m_parentList.end(); it++) {
- Element* parent = *it;
- if(parent) {
- if(m_online) {
- glColor4dv(m_closedSwitchColour.GetRGBA());
- } else {
- glColor4dv(m_openedSwitchColour.GetRGBA());
- }
-
- glPushMatrix();
- glTranslated(m_switchRect[i].GetPosition().m_x + m_switchSize / 2.0,
- m_switchRect[i].GetPosition().m_y + m_switchSize / 2.0, 0.0);
- glRotated(parent->GetAngle(), 0.0, 0.0, 1.0);
- glTranslated(-m_switchRect[i].GetPosition().m_x - m_switchSize / 2.0,
- -m_switchRect[i].GetPosition().m_y - m_switchSize / 2.0, 0.0);
-
- DrawRectangle(m_switchRect[i].GetPosition() + wxPoint2DDouble(m_switchSize / 2.0, m_switchSize / 2.0),
- m_switchSize, m_switchSize);
-
- glPopMatrix();
- }
- i++;
- }
-}
-
-bool Element::SwitchesContains(wxPoint2DDouble position) const
-{
- for(int i = 0; i < (int)m_switchRect.size(); i++) {
- if(m_parentList[i]) {
- if(m_switchRect[i].Contains(position)) return true;
- }
- }
- return false;
-}
-
void Element::SetOnline(bool online)
{
// Check if any parent is null.
@@ -395,60 +328,6 @@ wxString Element::StringFromDouble(double value, int minDecimal)
return formatedStr;
}
-void Element::CalculatePowerFlowPts(std::vector<wxPoint2DDouble> edges)
-{
- double arrowRate = 100.0; // One arrow to each "arrowRate" distance in pixels.
-
- if(edges.size() < 2) return;
-
- // Clear all power flow points
- for(int i = 0; i < (int)m_powerFlowArrow.size(); i++) m_powerFlowArrow[i].clear();
- m_powerFlowArrow.clear();
-
- for(int i = 1; i < (int)edges.size(); i++) {
- wxPoint2DDouble pt1 = edges[i - 1];
- wxPoint2DDouble pt2 = edges[i];
-
- double angle = std::atan2(pt2.m_y - pt1.m_y, pt2.m_x - pt1.m_x);
-
- wxPoint2DDouble rotPt2(
- std::cos(-angle) * (pt2.m_x - pt1.m_x) - std::sin(-angle) * (pt2.m_y - pt1.m_y) + pt1.m_x,
- std::sin(-angle) * (pt2.m_x - pt1.m_x) + std::cos(-angle) * (pt2.m_y - pt1.m_y) + pt1.m_y);
-
- int numArrows = std::abs(pt1.m_x - rotPt2.m_x) / arrowRate;
- if(numArrows == 0) numArrows = 1;
-
- for(int i = 0; i < numArrows; i++) {
- wxPoint2DDouble arrowCenter(pt1.m_x + ((rotPt2.m_x - pt1.m_x) / double(numArrows + 1)) * double(i + 1),
- pt1.m_y + ((rotPt2.m_y - pt1.m_y) / double(numArrows + 1)) * double(i + 1));
-
- std::vector<wxPoint2DDouble> triPts;
- triPts.push_back(arrowCenter + wxPoint2DDouble(5.0, 0.0));
- triPts.push_back(arrowCenter + wxPoint2DDouble(-5.0, 5.0));
- triPts.push_back(arrowCenter + wxPoint2DDouble(-5.0, -5.0));
-
- // Rotate back.
- for(int i = 0; i < 3; i++) {
- triPts[i] = wxPoint2DDouble(
- std::cos(angle) * (triPts[i].m_x - pt1.m_x) - std::sin(angle) * (triPts[i].m_y - pt1.m_y) + pt1.m_x,
- std::sin(angle) * (triPts[i].m_x - pt1.m_x) + std::cos(angle) * (triPts[i].m_y - pt1.m_y) +
- pt1.m_y);
- }
- m_powerFlowArrow.push_back(triPts);
- }
- }
-}
-
-void Element::DrawPowerFlowPts() const
-{
- if(m_online) {
- glColor4dv(m_powerFlowArrowColour.GetRGBA());
- for(int i = 0; i < (int)m_powerFlowArrow.size(); i++) {
- DrawTriangle(m_powerFlowArrow[i]);
- }
- }
-}
-
void Element::ReplaceParent(Element* oldParent, Element* newParent)
{
for(int i = 0; i < (int)m_parentList.size(); i++) {
diff --git a/Project/Element.h b/Project/Element.h
index 01fef43..124e1a0 100644
--- a/Project/Element.h
+++ b/Project/Element.h
@@ -32,48 +32,6 @@ enum ContextMenuID {
ID_DELETE
};
-enum ElectricalUnit {
- UNIT_PU = 0,
- UNIT_V,
- UNIT_kV,
- UNIT_A,
- UNIT_kA,
- UNIT_W,
- UNIT_kW,
- UNIT_MW,
- UNIT_VA,
- UNIT_kVA,
- UNIT_MVA,
- UNIT_VAr,
- UNIT_kVAr,
- UNIT_MVAr,
- UNIT_OHM,
- UNIT_OHM_km,
- UNIT_S,
- UNIT_S_km,
- UNIT_DEGREE,
- UNIT_RADIAN
-};
-
-enum FaultData {
- FAULT_THREEPHASE = 0,
- FAULT_2LINE,
- FAULT_2LINE_GROUND,
- FAULT_LINE_GROUND,
- FAULT_LINE_A,
- FAULT_LINE_B,
- FAULT_LINE_C
-};
-
-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 };
-
-struct SwitchingData {
- std::vector<SwitchingType> swType;
- std::vector<double> swTime;
-};
-
class OpenGLColour
{
public:
@@ -141,14 +99,6 @@ 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 bool SwitchesContains(wxPoint2DDouble position) const;
- virtual void UpdateSwitches();
- virtual void DrawSwitches() const;
-
- virtual void CalculatePowerFlowPts(std::vector<wxPoint2DDouble> edges);
- virtual void DrawPowerFlowPts() const;
virtual bool PickboxContains(wxPoint2DDouble position) { return false; }
virtual void MovePickbox(wxPoint2DDouble position) {}
@@ -191,15 +141,7 @@ public:
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);
-
- // Electrical only methods
- virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit)
- {
- }
- virtual void SetSwitchingData(SwitchingData data) { m_swData = data; }
- 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);
@@ -227,9 +169,6 @@ protected:
std::vector<wxRect2DDouble> m_switchRect;
- std::vector<std::vector<wxPoint2DDouble> > m_powerFlowArrow;
- PowerFlowDirection m_pfDirection = PF_NONE;
-
bool m_selected = false;
bool m_dragging = false;
bool m_showPickbox = false;
@@ -244,8 +183,6 @@ protected:
wxPoint2DDouble m_movePos;
bool m_online = true;
-
- SwitchingData m_swData;
};
#endif // ELEMENT_H
diff --git a/Project/PowerElement.cpp b/Project/PowerElement.cpp
index c9492f6..2847130 100644
--- a/Project/PowerElement.cpp
+++ b/Project/PowerElement.cpp
@@ -1,10 +1,134 @@
#include "PowerElement.h"
-PowerElement::PowerElement() : Element()
+PowerElement::PowerElement()
+ : Element()
{
}
-PowerElement::~PowerElement()
+PowerElement::~PowerElement() {}
+
+void PowerElement::SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit)
{
}
+wxPoint2DDouble PowerElement::GetSwitchPoint(Element* parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
+{
+ double swLineSize = 25.0;
+ wxPoint2DDouble swPoint = wxPoint2DDouble(parentPoint.m_x, parentPoint.m_y - swLineSize);
+
+ // Rotate the second point (to compare).
+ double angle = parent->GetAngle();
+
+ secondPoint = wxPoint2DDouble(std::cos(wxDegToRad(-angle)) * (secondPoint.m_x - parentPoint.m_x) -
+ std::sin(wxDegToRad(-angle)) * (secondPoint.m_y - parentPoint.m_y) + parentPoint.m_x,
+ std::sin(wxDegToRad(-angle)) * (secondPoint.m_x - parentPoint.m_x) +
+ std::cos(wxDegToRad(-angle)) * (secondPoint.m_y - parentPoint.m_y) + parentPoint.m_y);
+
+ // Rotate
+ if(secondPoint.m_y > parentPoint.m_y) angle -= 180.0;
+ return wxPoint2DDouble(std::cos(wxDegToRad(angle)) * (swPoint.m_x - parentPoint.m_x) -
+ std::sin(wxDegToRad(angle)) * (swPoint.m_y - parentPoint.m_y) + parentPoint.m_x,
+ std::sin(wxDegToRad(angle)) * (swPoint.m_x - parentPoint.m_x) +
+ std::cos(wxDegToRad(angle)) * (swPoint.m_y - parentPoint.m_y) + parentPoint.m_y);
+}
+
+bool PowerElement::SwitchesContains(wxPoint2DDouble position) const
+{
+ for(int i = 0; i < (int)m_switchRect.size(); i++) {
+ if(m_parentList[i]) {
+ if(m_switchRect[i].Contains(position)) return true;
+ }
+ }
+ return false;
+}
+
+void PowerElement::UpdateSwitches()
+{
+ // General method, to one switch only.
+ wxPoint2DDouble swCenter = wxPoint2DDouble(
+ (m_pointList[0].m_x + m_pointList[1].m_x) / 2.0, (m_pointList[0].m_y + m_pointList[1].m_y) / 2.0);
+ m_switchRect[0] = wxRect2DDouble(
+ swCenter.m_x - m_switchSize / 2.0, swCenter.m_y - m_switchSize / 2.0, m_switchSize, m_switchSize);
+}
+
+void PowerElement::DrawSwitches() const
+{
+ int i = 0;
+ for(auto it = m_parentList.begin(); it != m_parentList.end(); it++) {
+ Element* parent = *it;
+ if(parent) {
+ if(m_online) {
+ glColor4dv(m_closedSwitchColour.GetRGBA());
+ } else {
+ glColor4dv(m_openedSwitchColour.GetRGBA());
+ }
+
+ glPushMatrix();
+ glTranslated(m_switchRect[i].GetPosition().m_x + m_switchSize / 2.0,
+ m_switchRect[i].GetPosition().m_y + m_switchSize / 2.0, 0.0);
+ glRotated(parent->GetAngle(), 0.0, 0.0, 1.0);
+ glTranslated(-m_switchRect[i].GetPosition().m_x - m_switchSize / 2.0,
+ -m_switchRect[i].GetPosition().m_y - m_switchSize / 2.0, 0.0);
+
+ DrawRectangle(m_switchRect[i].GetPosition() + wxPoint2DDouble(m_switchSize / 2.0, m_switchSize / 2.0),
+ m_switchSize, m_switchSize);
+
+ glPopMatrix();
+ }
+ i++;
+ }
+}
+
+void PowerElement::CalculatePowerFlowPts(std::vector<wxPoint2DDouble> edges)
+{
+ double arrowRate = 100.0; // One arrow to each "arrowRate" distance in pixels.
+
+ if(edges.size() < 2) return;
+
+ // Clear all power flow points
+ for(int i = 0; i < (int)m_powerFlowArrow.size(); i++) m_powerFlowArrow[i].clear();
+ m_powerFlowArrow.clear();
+
+ for(int i = 1; i < (int)edges.size(); i++) {
+ wxPoint2DDouble pt1 = edges[i - 1];
+ wxPoint2DDouble pt2 = edges[i];
+
+ double angle = std::atan2(pt2.m_y - pt1.m_y, pt2.m_x - pt1.m_x);
+
+ wxPoint2DDouble rotPt2(
+ std::cos(-angle) * (pt2.m_x - pt1.m_x) - std::sin(-angle) * (pt2.m_y - pt1.m_y) + pt1.m_x,
+ std::sin(-angle) * (pt2.m_x - pt1.m_x) + std::cos(-angle) * (pt2.m_y - pt1.m_y) + pt1.m_y);
+
+ int numArrows = std::abs(pt1.m_x - rotPt2.m_x) / arrowRate;
+ if(numArrows == 0) numArrows = 1;
+
+ for(int i = 0; i < numArrows; i++) {
+ wxPoint2DDouble arrowCenter(pt1.m_x + ((rotPt2.m_x - pt1.m_x) / double(numArrows + 1)) * double(i + 1),
+ pt1.m_y + ((rotPt2.m_y - pt1.m_y) / double(numArrows + 1)) * double(i + 1));
+
+ std::vector<wxPoint2DDouble> triPts;
+ triPts.push_back(arrowCenter + wxPoint2DDouble(5.0, 0.0));
+ triPts.push_back(arrowCenter + wxPoint2DDouble(-5.0, 5.0));
+ triPts.push_back(arrowCenter + wxPoint2DDouble(-5.0, -5.0));
+
+ // Rotate back.
+ for(int i = 0; i < 3; i++) {
+ triPts[i] = wxPoint2DDouble(
+ std::cos(angle) * (triPts[i].m_x - pt1.m_x) - std::sin(angle) * (triPts[i].m_y - pt1.m_y) + pt1.m_x,
+ std::sin(angle) * (triPts[i].m_x - pt1.m_x) + std::cos(angle) * (triPts[i].m_y - pt1.m_y) +
+ pt1.m_y);
+ }
+ m_powerFlowArrow.push_back(triPts);
+ }
+ }
+}
+
+void PowerElement::DrawPowerFlowPts() const
+{
+ if(m_online) {
+ glColor4dv(m_powerFlowArrowColour.GetRGBA());
+ for(int i = 0; i < (int)m_powerFlowArrow.size(); i++) {
+ DrawTriangle(m_powerFlowArrow[i]);
+ }
+ }
+}
diff --git a/Project/PowerElement.h b/Project/PowerElement.h
index 6fdc33e..eccaaf5 100644
--- a/Project/PowerElement.h
+++ b/Project/PowerElement.h
@@ -3,12 +3,170 @@
#include "Element.h"
+/**
+ * @enum ElectricalUnit
+ * @brief Electrical units.
+*/
+enum ElectricalUnit {
+ UNIT_PU = 0, /**< Per unit (p.u.) */
+ UNIT_V, /**< Volt */
+ UNIT_kV, /**< Kilovolts */
+ UNIT_A, /**< Ampere */
+ UNIT_kA, /**< Kiloampere */
+ UNIT_W, /**< Watts */
+ UNIT_kW, /**< Kilowatts */
+ UNIT_MW, /**< Megawatts */
+ UNIT_VA, /**< Volt-ampere */
+ UNIT_kVA, /**< Kilovolt-ampere */
+ UNIT_MVA, /**< Megavolt-ampere */
+ UNIT_VAr, /**< Volt-ampere reactive */
+ UNIT_kVAr, /**< Kilovolt-ampere reactive */
+ UNIT_MVAr, /**< Megavolt-ampere reactive */
+ UNIT_OHM, /**< Ohm */
+ UNIT_OHM_km, /**< Ohm/km */
+ UNIT_S, /**< Siemens */
+ UNIT_S_km, /**< Siemens/km */
+ UNIT_DEGREE, /**< Degree */
+ UNIT_RADIAN /**< Radian */
+};
+
+/**
+ * @enum FaultData
+ * @brief Information about fault (type and location).
+*/
+enum FaultData {
+ FAULT_THREEPHASE = 0, /**< Three-phase fault */
+ FAULT_2LINE, /**< Line-to-line fault */
+ FAULT_2LINE_GROUND, /**< Double line-to-ground fault */
+ FAULT_LINE_GROUND, /**< Line-to-ground fault */
+ FAULT_LINE_A, /**< Fault on phase A or phase AB */
+ FAULT_LINE_B, /**< Fault on phase B or phase BC */
+ FAULT_LINE_C /**< Fault on phase C or phase CA */
+};
+
+/**
+ * @enum SwitchingType
+ * @brief Type of switching.
+*/
+enum SwitchingType {
+ SW_INSERT = 0, /**< Insert element */
+ SW_REMOVE /**< Remove element */
+};
+
+/**
+ * @enum PowerFlowDirection
+ * @brief Direction of power flow arrows.
+*/
+enum PowerFlowDirection {
+ PF_NONE = 0, /**< No direction (no arrows printed) */
+ PF_TO_BUS, /**< Element to bus */
+ PF_TO_ELEMENT, /**< Bus to element */
+ PF_BUS1_TO_BUS2, /**< First bus to secont bus (branch elements) */
+ PF_BUS2_TO_BUS1 /**< Second bus to first bus (branch elements) */
+};
+
+/**
+ * @class SwitchingData
+ * @author Thales Lima Oliveira
+ * @date 18/01/2017
+ * @file PowerElement.h
+ * @brief Switching data of power elements.
+ */
+struct SwitchingData {
+ std::vector<SwitchingType> swType; /**< Type of switching */
+ std::vector<double> swTime; /**< Time of switching */
+};
+
+/**
+ * @class PowerElement
+ * @author Thales Lima Oliveira
+ * @date 18/01/2017
+ * @file PowerElement.h
+ * @brief Base class of power elements.
+ */
class PowerElement : public Element
{
public:
+ /**
+ * @brief Constructor
+ */
PowerElement();
+ /**
+ * @brief Destructor.
+ */
~PowerElement();
+ /**
+ * @brief Get the correct switch position.
+ * @param parent Bus with switch.
+ * @param parentPoint Position of node on parent.
+ * @param secondPoint Next point in element.
+ */
+ virtual wxPoint2DDouble
+ GetSwitchPoint(Element* parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const;
+
+ /**
+ * @brief Check if switch contains position.
+ * @param position position to be checked.
+ */
+ virtual bool SwitchesContains(wxPoint2DDouble position) const;
+
+ /**
+ * @brief Update the switch position.
+ */
+ virtual void UpdateSwitches();
+
+ /**
+ * @brief Draw switch.
+ */
+ virtual void DrawSwitches() const;
+
+ /**
+ * @brief Calculate the points of the power flow arrows.
+ * @param edges Points of the element that arrows point.
+ */
+ virtual void CalculatePowerFlowPts(std::vector<wxPoint2DDouble> edges);
+
+ /**
+ * @brief Draw power flow arrows.
+ */
+ virtual void DrawPowerFlowPts() const;
+
+ /**
+ * @brief Set nominal voltage of the element.
+ * @param nominalVoltage Value of the nominal voltage.
+ * @param nominalVoltageUnit Unit of the nominal voltage.
+ */
+ virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit);
+
+ /**
+ * @brief Set the switching data of the element.
+ * @param data Switching data.
+ */
+ virtual void SetSwitchingData(SwitchingData data) { m_swData = data; }
+
+ /**
+ * @brief Returns the switching data of the element.
+ * @return Element switching data.
+ */
+ virtual SwitchingData GetSwitchingData() { return m_swData; }
+
+ /**
+ * @brief Set the direction of the power flow.
+ * @param pfDirection Power flow direction.
+ */
+ virtual void SetPowerFlowDirection(PowerFlowDirection pfDirection) { m_pfDirection = pfDirection; }
+
+ /**
+ * @brief Return the direction of the power flow.
+ * @return Power flow direction.
+ */
+ virtual PowerFlowDirection GetPowerFlowDirection() const { return m_pfDirection; }
+
+protected:
+ SwitchingData m_swData;
+ std::vector<std::vector<wxPoint2DDouble> > m_powerFlowArrow;
+ PowerFlowDirection m_pfDirection = PF_NONE;
};
#endif // POWERELEMENT_H
diff --git a/Project/Project.mk b/Project/Project.mk
index 8c584c6..8c2c0bc 100644
--- a/Project/Project.mk
+++ b/Project/Project.mk
@@ -13,7 +13,7 @@ CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=Thales
-Date :=10/01/2017
+Date :=18/01/2017
CodeLitePath :="C:/Program Files/CodeLite"
LinkerName :=C:/TDM-GCC-64/bin/g++.exe
SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC
diff --git a/Project/SwitchingForm.cpp b/Project/SwitchingForm.cpp
index 2a48783..061b0a5 100644
--- a/Project/SwitchingForm.cpp
+++ b/Project/SwitchingForm.cpp
@@ -1,5 +1,5 @@
#include "SwitchingForm.h"
-#include "Element.h"
+#include "PowerElement.h"
SwitchingForm::SwitchingForm(wxWindow* parent) : SwitchingFormBase(parent)
{
@@ -10,7 +10,7 @@ SwitchingForm::SwitchingForm(wxWindow* parent) : SwitchingFormBase(parent)
Layout();
}
-SwitchingForm::SwitchingForm(wxWindow* parent, Element* element) : SwitchingFormBase(parent)
+SwitchingForm::SwitchingForm(wxWindow* parent, PowerElement* element) : SwitchingFormBase(parent)
{
m_listCtrlSwitchings->AppendColumn(_("Type"));
m_listCtrlSwitchings->AppendColumn(_("Time (s)"));
diff --git a/Project/SwitchingForm.h b/Project/SwitchingForm.h
index 5a4aa51..cf39701 100644
--- a/Project/SwitchingForm.h
+++ b/Project/SwitchingForm.h
@@ -3,13 +3,13 @@
#include "ElementForm.h"
-class Element;
+class PowerElement;
class SwitchingForm : public SwitchingFormBase
{
public:
SwitchingForm(wxWindow* parent);
- SwitchingForm(wxWindow* parent, Element* element);
+ SwitchingForm(wxWindow* parent, PowerElement* element);
virtual ~SwitchingForm();
protected:
virtual void OnDownButtonClick(wxCommandEvent& event);
@@ -23,6 +23,6 @@ protected:
int m_maxID = 0;
- Element* m_element = NULL;
+ PowerElement* m_element = NULL;
};
#endif // SWITCHINGFORM_H
diff --git a/Project/Text.h b/Project/Text.h
index 871af2f..062032c 100644
--- a/Project/Text.h
+++ b/Project/Text.h
@@ -2,6 +2,7 @@
#define TEXT_H
#include "GraphicalElement.h"
+#include "PowerElement.h"
#include "wxGLString.h"
class TextForm;
diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp
index d09efad..d055377 100644
--- a/Project/Workspace.cpp
+++ b/Project/Workspace.cpp
@@ -203,7 +203,7 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event)
} else {
bool clickPickbox = false;
for(auto it = m_elementList.begin(), itEnd = m_elementList.end(); it != itEnd; ++it) {
- Element* element = *it;
+ PowerElement* element = *it;
element->ResetPickboxes(); // Reset pickbox state.
// Set movement initial position (not necessarily will be moved).
@@ -277,7 +277,7 @@ void Workspace::OnLeftDoubleClick(wxMouseEvent& event)
bool redraw = false;
for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) {
- Element* element = *it;
+ PowerElement* element = *it;
// Click in an element.
if(element->Contains(m_camera->ScreenToWorld(event.GetPosition()))) {
@@ -332,7 +332,7 @@ void Workspace::OnLeftDoubleClick(wxMouseEvent& event)
for(auto it = m_textList.begin(); it != m_textList.end(); ++it) {
Text* text = *it;
if(text->Contains(m_camera->ScreenToWorld(event.GetPosition()))) {
- text->ShowForm(this, m_elementList);
+ text->ShowForm(this, GetElementList());
redraw = true;
}
}
@@ -1075,7 +1075,7 @@ void Workspace::Fit()
{
wxPoint2DDouble leftUpCorner(0, 0);
wxPoint2DDouble rightDownCorner(0, 0);
- std::vector<Element*> elementList = m_elementList;
+ std::vector<Element*> elementList = GetElementList();
for(auto it = m_textList.begin(), itEnd = m_textList.end(); it != itEnd; ++it) {
elementList.push_back(*it);
}
@@ -1134,7 +1134,7 @@ void Workspace::ValidateBusesVoltages(Element* initialBus)
void Workspace::ValidateElementsVoltages()
{
for(auto it = m_elementList.begin(); it != m_elementList.end(); it++) {
- Element* child = *it;
+ PowerElement* child = *it;
std::vector<double> nominalVoltage;
std::vector<ElectricalUnit> nominalVoltageUnit;
@@ -1151,7 +1151,7 @@ void Workspace::ValidateElementsVoltages()
bool Workspace::RunPowerFlow()
{
- PowerFlow pf(m_elementList);
+ PowerFlow pf(GetElementList());
bool result = pf.RunGaussSeidel();
if(!result) {
wxMessageDialog msgDialog(this, pf.GetErrorMessage(), _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
@@ -1234,7 +1234,7 @@ bool Workspace::Paste()
if(copy) {
pastedElements.push_back(copy);
pastedBusList.push_back(static_cast<Bus*>(copy));
- m_elementList.push_back(copy);
+ m_elementList.push_back(static_cast<PowerElement*>(copy));
}
}
@@ -1277,7 +1277,7 @@ bool Workspace::Paste()
}
pastedElements.push_back(copy);
- m_elementList.push_back(copy);
+ m_elementList.push_back(static_cast<PowerElement*>(copy));
}
}
}
@@ -1392,7 +1392,8 @@ void Workspace::SetTextList(std::vector<Text*> textList)
void Workspace::SetElementList(std::vector<Element*> elementList)
{
m_elementList.clear();
- for(auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) m_elementList.push_back(*it);
+ for(auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it)
+ m_elementList.push_back(static_cast<PowerElement*>(*it));
}
void Workspace::OnIdle(wxIdleEvent& event)
@@ -1417,7 +1418,7 @@ std::vector<Element*> Workspace::GetAllElements() const
bool Workspace::RunFault()
{
- Fault fault(m_elementList);
+ Fault fault(GetElementList());
bool result = fault.RunFaultCalculation(100e6);
if(!result) {
wxMessageDialog msgDialog(this, fault.GetErrorMessage(), _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
@@ -1429,3 +1430,10 @@ bool Workspace::RunFault()
return result;
}
+
+std::vector<Element*> Workspace::GetElementList() const
+{
+ std::vector<Element*> elementList;
+ for(auto it = m_elementList.begin(), itEnd = m_elementList.end(); it != itEnd; ++it) elementList.push_back(*it);
+ return elementList;
+}
diff --git a/Project/Workspace.h b/Project/Workspace.h
index f138410..2efdbad 100644
--- a/Project/Workspace.h
+++ b/Project/Workspace.h
@@ -68,7 +68,7 @@ public:
~Workspace();
wxString GetName() const { return m_name; }
- std::vector<Element*> GetElementList() const { return m_elementList; }
+ std::vector<Element*> GetElementList() const;
std::vector<Text*> GetTextList() const { return m_textList; }
std::vector<Element*> GetAllElements() const;
WorkspaceMode GetWorkspaceMode() const { return m_mode; }
@@ -132,7 +132,7 @@ protected:
WorkspaceMode m_mode = MODE_EDIT;
- std::vector<Element*> m_elementList;
+ std::vector<PowerElement*> m_elementList;
int m_elementNumber[NUM_ELEMENTS];
std::vector<Text*> m_textList;