diff options
Diffstat (limited to 'Project')
-rw-r--r-- | Project/Element.cpp | 44 | ||||
-rw-r--r-- | Project/Element.h | 6 | ||||
-rw-r--r-- | Project/Line.h | 13 | ||||
-rw-r--r-- | Project/Machines.cpp | 7 | ||||
-rw-r--r-- | Project/Project.mk | 2 | ||||
-rw-r--r-- | Project/Release/Branch.cpp.o | bin | 31620 -> 31796 bytes | |||
-rw-r--r-- | Project/Release/Bus.cpp.o | bin | 39223 -> 39399 bytes | |||
-rw-r--r-- | Project/Release/BusForm.cpp.o | bin | 112442 -> 112442 bytes | |||
-rw-r--r-- | Project/Release/Capacitor.cpp.o | bin | 41253 -> 41429 bytes | |||
-rw-r--r-- | Project/Release/Element.cpp.o | bin | 146598 -> 153721 bytes | |||
-rw-r--r-- | Project/Release/GeneratorStabForm.cpp.o | bin | 103823 -> 103823 bytes | |||
-rw-r--r-- | Project/Release/IndMotor.cpp.o | bin | 34703 -> 34879 bytes | |||
-rw-r--r-- | Project/Release/IndMotorForm.cpp.o | bin | 87201 -> 87201 bytes | |||
-rw-r--r-- | Project/Release/Inductor.cpp.o | bin | 41159 -> 41335 bytes | |||
-rw-r--r-- | Project/Release/Line.cpp.o | bin | 157420 -> 157876 bytes | |||
-rw-r--r-- | Project/Release/LineForm.cpp.o | bin | 100045 -> 100269 bytes | |||
-rw-r--r-- | Project/Release/Load.cpp.o | bin | 38631 -> 38807 bytes | |||
-rw-r--r-- | Project/Release/LoadForm.cpp.o | bin | 86826 -> 86826 bytes | |||
-rw-r--r-- | Project/Release/Machines.cpp.o | bin | 36776 -> 37516 bytes | |||
-rw-r--r-- | Project/Release/MainFrame.cpp.o | bin | 141166 -> 141166 bytes | |||
-rw-r--r-- | Project/Release/PSP-UFU.exe | bin | 3980519 -> 3987450 bytes | |||
-rw-r--r-- | Project/Release/ReactiveShuntElementForm.cpp.o | bin | 93200 -> 93200 bytes | |||
-rw-r--r-- | Project/Release/Shunt.cpp.o | bin | 31584 -> 31760 bytes | |||
-rw-r--r-- | Project/Release/SwitchingForm.cpp.o | bin | 107131 -> 107131 bytes | |||
-rw-r--r-- | Project/Release/SyncGenerator.cpp.o | bin | 39224 -> 39400 bytes | |||
-rw-r--r-- | Project/Release/SyncMachineForm.cpp.o | bin | 123326 -> 123326 bytes | |||
-rw-r--r-- | Project/Release/SyncMotor.cpp.o | bin | 35364 -> 35540 bytes | |||
-rw-r--r-- | Project/Release/Transformer.cpp.o | bin | 44949 -> 45125 bytes | |||
-rw-r--r-- | Project/Release/TransformerForm.cpp.o | bin | 108025 -> 108025 bytes | |||
-rw-r--r-- | Project/Release/Workspace.cpp.o | bin | 154829 -> 156051 bytes |
30 files changed, 66 insertions, 6 deletions
diff --git a/Project/Element.cpp b/Project/Element.cpp index 7c69e18..3f6e111 100644 --- a/Project/Element.cpp +++ b/Project/Element.cpp @@ -387,3 +387,47 @@ wxString Element::StringFromDouble(double value, int minDecimal) return formatedStr; } + +void Element::CalculatePowerFlowPts(std::vector<wxPoint2DDouble> edges) +{ + 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); + + //wxLogMessage(wxString::Format("(%f, %f) (%f, %f)"), pt1.m_x, pt1.m_y, pt2.m_x, pt2.m_y); + + 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); + + wxPoint2DDouble mid((rotPt2.m_x + pt1.m_x) / 2.0, (rotPt2.m_y + pt1.m_y) / 2.0); // test + std::vector<wxPoint2DDouble> triPts; + triPts.push_back(mid + wxPoint2DDouble(5.0, 0.0)); + triPts.push_back(mid + wxPoint2DDouble(-5.0, 5.0)); + triPts.push_back(mid + 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 +{ + glColor4d(1.0, 0.55, 0.0, 1.0); + for(int i = 0; i < (int)m_powerFlowArrow.size(); i++) { + DrawTriangle(m_powerFlowArrow[i]); + } +} diff --git a/Project/Element.h b/Project/Element.h index 51cb588..ec18ccd 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -7,6 +7,8 @@ #include <wx/menu.h> #include <GL/gl.h> +#include <complex> + #include <wx/log.h> enum PickboxID @@ -135,6 +137,9 @@ class Element 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) {} @@ -204,6 +209,7 @@ class Element double m_switchSize = 10.0; std::vector<wxRect2DDouble> m_switchRect; + std::vector< std::vector<wxPoint2DDouble> > m_powerFlowArrow; bool m_selected = false; bool m_dragging = false; diff --git a/Project/Line.h b/Project/Line.h index 3e5a5a6..afabb17 100644 --- a/Project/Line.h +++ b/Project/Line.h @@ -4,8 +4,7 @@ #include "LineForm.h" #include "Branch.h" -struct LineElectricalData -{ +struct LineElectricalData { // General wxString name = ""; double nominalVoltage = 138.0; @@ -21,6 +20,9 @@ struct LineElectricalData double lineSize = 100.0; bool useLinePower = false; + // Power flow + std::complex<double> powerFlow[2] = {std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0)}; + // Fault double zeroResistance = 0.0; double zeroIndReactance = 1.0; @@ -31,14 +33,14 @@ class Line : public Branch { public: Line(); - Line(wxString name); + Line(wxString name); ~Line(); virtual bool Contains(wxPoint2DDouble position) const; virtual void Draw(wxPoint2DDouble translation, double scale) const; virtual void Move(wxPoint2DDouble position); virtual void StartMove(wxPoint2DDouble position); virtual void MoveNode(Element* parent, wxPoint2DDouble position); - virtual bool SetNodeParent(Element* parent); + virtual bool SetNodeParent(Element* parent); virtual wxCursor GetBestPickboxCursor() const { return wxCURSOR_SIZING; } virtual bool AddParent(Element* parent, wxPoint2DDouble position); virtual bool Intersects(wxRect2DDouble rect) const; @@ -52,7 +54,8 @@ class Line : public Branch virtual bool ShowForm(wxWindow* parent, Element* element); virtual LineElectricalData GetElectricalData() const { return m_electricaData; } virtual void SetElectricalData(LineElectricalData electricalData) { m_electricaData = electricalData; } - virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit); + virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit); + protected: double PointToLineDistance(wxPoint2DDouble point, int* segmentNumber = NULL) const; LineElectricalData m_electricaData; diff --git a/Project/Machines.cpp b/Project/Machines.cpp index 1b11c68..c86f7b7 100644 --- a/Project/Machines.cpp +++ b/Project/Machines.cpp @@ -54,6 +54,7 @@ void Machines::Draw(wxPoint2DDouble translation, double scale) const DrawLine(m_pointList); DrawSwitches(); + DrawPowerFlowPts(); glColor4d(1.0, 1.0, 1.0, 1.0); DrawCircle(m_position, 25.0, 20, GL_POLYGON); @@ -89,6 +90,12 @@ void Machines::Move(wxPoint2DDouble position) m_pointList[0] = m_movePts[0] + position - m_moveStartPt; } UpdateSwitchesPosition(); + + //Power flow arrows + std::vector<wxPoint2DDouble> edges; + edges.push_back(m_pointList[1]); + edges.push_back(m_pointList[2]); + CalculatePowerFlowPts(edges); } void Machines::MoveNode(Element* element, wxPoint2DDouble position) diff --git a/Project/Project.mk b/Project/Project.mk index ab401cd..b53fbf5 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=27/10/2016 +Date :=28/10/2016 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/Release/Branch.cpp.o b/Project/Release/Branch.cpp.o Binary files differindex a790b76..9d35f07 100644 --- a/Project/Release/Branch.cpp.o +++ b/Project/Release/Branch.cpp.o diff --git a/Project/Release/Bus.cpp.o b/Project/Release/Bus.cpp.o Binary files differindex 3313bf2..050e9af 100644 --- a/Project/Release/Bus.cpp.o +++ b/Project/Release/Bus.cpp.o diff --git a/Project/Release/BusForm.cpp.o b/Project/Release/BusForm.cpp.o Binary files differindex a003729..8e2aa6b 100644 --- a/Project/Release/BusForm.cpp.o +++ b/Project/Release/BusForm.cpp.o diff --git a/Project/Release/Capacitor.cpp.o b/Project/Release/Capacitor.cpp.o Binary files differindex a743548..b7b887a 100644 --- a/Project/Release/Capacitor.cpp.o +++ b/Project/Release/Capacitor.cpp.o diff --git a/Project/Release/Element.cpp.o b/Project/Release/Element.cpp.o Binary files differindex 4b4f63d..54cb60c 100644 --- a/Project/Release/Element.cpp.o +++ b/Project/Release/Element.cpp.o diff --git a/Project/Release/GeneratorStabForm.cpp.o b/Project/Release/GeneratorStabForm.cpp.o Binary files differindex 5dd2b53..c0ee1ba 100644 --- a/Project/Release/GeneratorStabForm.cpp.o +++ b/Project/Release/GeneratorStabForm.cpp.o diff --git a/Project/Release/IndMotor.cpp.o b/Project/Release/IndMotor.cpp.o Binary files differindex 407305a..bd75e9a 100644 --- a/Project/Release/IndMotor.cpp.o +++ b/Project/Release/IndMotor.cpp.o diff --git a/Project/Release/IndMotorForm.cpp.o b/Project/Release/IndMotorForm.cpp.o Binary files differindex 4e427d4..aa7071b 100644 --- a/Project/Release/IndMotorForm.cpp.o +++ b/Project/Release/IndMotorForm.cpp.o diff --git a/Project/Release/Inductor.cpp.o b/Project/Release/Inductor.cpp.o Binary files differindex 2592076..b666ec7 100644 --- a/Project/Release/Inductor.cpp.o +++ b/Project/Release/Inductor.cpp.o diff --git a/Project/Release/Line.cpp.o b/Project/Release/Line.cpp.o Binary files differindex 9cec445..dd750f9 100644 --- a/Project/Release/Line.cpp.o +++ b/Project/Release/Line.cpp.o diff --git a/Project/Release/LineForm.cpp.o b/Project/Release/LineForm.cpp.o Binary files differindex ebf71f9..b0762e5 100644 --- a/Project/Release/LineForm.cpp.o +++ b/Project/Release/LineForm.cpp.o diff --git a/Project/Release/Load.cpp.o b/Project/Release/Load.cpp.o Binary files differindex 36f05eb..18e6d63 100644 --- a/Project/Release/Load.cpp.o +++ b/Project/Release/Load.cpp.o diff --git a/Project/Release/LoadForm.cpp.o b/Project/Release/LoadForm.cpp.o Binary files differindex edbc5cd..4bda98b 100644 --- a/Project/Release/LoadForm.cpp.o +++ b/Project/Release/LoadForm.cpp.o diff --git a/Project/Release/Machines.cpp.o b/Project/Release/Machines.cpp.o Binary files differindex a7269bf..9db50de 100644 --- a/Project/Release/Machines.cpp.o +++ b/Project/Release/Machines.cpp.o diff --git a/Project/Release/MainFrame.cpp.o b/Project/Release/MainFrame.cpp.o Binary files differindex 963d460..51effa4 100644 --- a/Project/Release/MainFrame.cpp.o +++ b/Project/Release/MainFrame.cpp.o diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe Binary files differindex ebc1db3..775cb72 100644 --- a/Project/Release/PSP-UFU.exe +++ b/Project/Release/PSP-UFU.exe diff --git a/Project/Release/ReactiveShuntElementForm.cpp.o b/Project/Release/ReactiveShuntElementForm.cpp.o Binary files differindex 0a45712..dd57691 100644 --- a/Project/Release/ReactiveShuntElementForm.cpp.o +++ b/Project/Release/ReactiveShuntElementForm.cpp.o diff --git a/Project/Release/Shunt.cpp.o b/Project/Release/Shunt.cpp.o Binary files differindex 9f09e7e..a0985c1 100644 --- a/Project/Release/Shunt.cpp.o +++ b/Project/Release/Shunt.cpp.o diff --git a/Project/Release/SwitchingForm.cpp.o b/Project/Release/SwitchingForm.cpp.o Binary files differindex b7f81f0..38b5227 100644 --- a/Project/Release/SwitchingForm.cpp.o +++ b/Project/Release/SwitchingForm.cpp.o diff --git a/Project/Release/SyncGenerator.cpp.o b/Project/Release/SyncGenerator.cpp.o Binary files differindex 8b9d321..1e5282d 100644 --- a/Project/Release/SyncGenerator.cpp.o +++ b/Project/Release/SyncGenerator.cpp.o diff --git a/Project/Release/SyncMachineForm.cpp.o b/Project/Release/SyncMachineForm.cpp.o Binary files differindex b90dfda..00e1157 100644 --- a/Project/Release/SyncMachineForm.cpp.o +++ b/Project/Release/SyncMachineForm.cpp.o diff --git a/Project/Release/SyncMotor.cpp.o b/Project/Release/SyncMotor.cpp.o Binary files differindex 878ebbe..ecb3f5c 100644 --- a/Project/Release/SyncMotor.cpp.o +++ b/Project/Release/SyncMotor.cpp.o diff --git a/Project/Release/Transformer.cpp.o b/Project/Release/Transformer.cpp.o Binary files differindex 4f2b47b..52e3555 100644 --- a/Project/Release/Transformer.cpp.o +++ b/Project/Release/Transformer.cpp.o diff --git a/Project/Release/TransformerForm.cpp.o b/Project/Release/TransformerForm.cpp.o Binary files differindex 15c729d..0388483 100644 --- a/Project/Release/TransformerForm.cpp.o +++ b/Project/Release/TransformerForm.cpp.o diff --git a/Project/Release/Workspace.cpp.o b/Project/Release/Workspace.cpp.o Binary files differindex 065631f..b04b8ca 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o |