summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.codelite/.tern-port2
-rw-r--r--.codelite/PSP.session35
-rw-r--r--.codelite/PSP.tagsbin79142912 -> 79306752 bytes
-rw-r--r--.codelite/compilation.dbbin65536 -> 65536 bytes
-rw-r--r--.codelite/refactoring.dbbin2988032 -> 2988032 bytes
-rw-r--r--Buglist.txt4
-rw-r--r--Project/Bus.cpp155
-rw-r--r--Project/Bus.h3
-rw-r--r--Project/Capacitor.cpp32
-rw-r--r--Project/Capacitor.h11
-rw-r--r--Project/Element.h3
-rw-r--r--Project/IndMotor.cpp66
-rw-r--r--Project/IndMotor.h1
-rw-r--r--Project/Inductor.cpp32
-rw-r--r--Project/Inductor.h1
-rw-r--r--Project/Line.cpp37
-rw-r--r--Project/Line.h13
-rw-r--r--Project/Load.cpp94
-rw-r--r--Project/Load.h3
-rw-r--r--Project/Project.mk2
-rw-r--r--Project/Project.project2
-rw-r--r--Project/Release/Branch.cpp.obin38491 -> 39468 bytes
-rw-r--r--Project/Release/Bus.cpp.obin53553 -> 75164 bytes
-rw-r--r--Project/Release/BusForm.cpp.obin119004 -> 119004 bytes
-rw-r--r--Project/Release/Capacitor.cpp.obin53887 -> 61089 bytes
-rw-r--r--Project/Release/Capacitor.cpp.o.d6
-rw-r--r--Project/Release/ElectricCalculation.cpp.obin74659 -> 74659 bytes
-rw-r--r--Project/Release/Element.cpp.obin165690 -> 166365 bytes
-rw-r--r--Project/Release/FileHanding.cpp.obin197260 -> 197260 bytes
-rw-r--r--Project/Release/GeneratorStabForm.cpp.obin104202 -> 104202 bytes
-rw-r--r--Project/Release/IndMotor.cpp.obin46722 -> 56226 bytes
-rw-r--r--Project/Release/IndMotorForm.cpp.obin87116 -> 87116 bytes
-rw-r--r--Project/Release/Inductor.cpp.obin53771 -> 60972 bytes
-rw-r--r--Project/Release/Inductor.cpp.o.d6
-rw-r--r--Project/Release/Line.cpp.obin172448 -> 188898 bytes
-rw-r--r--Project/Release/LineForm.cpp.obin101112 -> 101112 bytes
-rw-r--r--Project/Release/Load.cpp.obin52598 -> 64001 bytes
-rw-r--r--Project/Release/Load.cpp.o.d6
-rw-r--r--Project/Release/Machines.cpp.obin43306 -> 44283 bytes
-rw-r--r--Project/Release/MainFrame.cpp.obin155536 -> 155536 bytes
-rw-r--r--Project/Release/PSP-UFU.exebin4458510 -> 4537648 bytes
-rw-r--r--Project/Release/PowerFlow.cpp.obin31904 -> 31904 bytes
-rw-r--r--Project/Release/ReactiveShuntElementForm.cpp.obin93115 -> 93115 bytes
-rw-r--r--Project/Release/Shunt.cpp.obin39028 -> 40619 bytes
-rw-r--r--Project/Release/SwitchingForm.cpp.obin107046 -> 107046 bytes
-rw-r--r--Project/Release/SyncGenerator.cpp.obin52372 -> 61898 bytes
-rw-r--r--Project/Release/SyncMachineForm.cpp.obin123729 -> 123729 bytes
-rw-r--r--Project/Release/SyncMotor.cpp.obin49547 -> 59068 bytes
-rw-r--r--Project/Release/Text.cpp.obin112553 -> 113244 bytes
-rw-r--r--Project/Release/TextForm.cpp.obin165833 -> 165833 bytes
-rw-r--r--Project/Release/Transformer.cpp.obin59897 -> 81590 bytes
-rw-r--r--Project/Release/TransformerForm.cpp.obin108670 -> 108670 bytes
-rw-r--r--Project/Release/Workspace.cpp.obin228913 -> 230568 bytes
-rw-r--r--Project/Release/Workspace.cpp.o.d29
-rw-r--r--Project/Release/WorkspaceBase.cpp.obin98406 -> 99844 bytes
-rw-r--r--Project/Release/WorkspaceBase.cpp.o.d9
-rw-r--r--Project/Shunt.h1
-rw-r--r--Project/SyncGenerator.cpp42
-rw-r--r--Project/SyncGenerator.h1
-rw-r--r--Project/SyncMotor.cpp73
-rw-r--r--Project/SyncMotor.h1
-rw-r--r--Project/Transformer.cpp61
-rw-r--r--Project/Transformer.h1
-rw-r--r--Project/Workspace.cpp29
-rw-r--r--Project/Workspace.h6
-rw-r--r--Project/Workspace.wxcp36
-rw-r--r--Project/WorkspaceBase.cpp8
-rw-r--r--Project/WorkspaceBase.h8
68 files changed, 640 insertions, 179 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port
index 7d990b9..be1c15f 100644
--- a/.codelite/.tern-port
+++ b/.codelite/.tern-port
@@ -1 +1 @@
-55500 \ No newline at end of file
+63064 \ No newline at end of file
diff --git a/.codelite/PSP.session b/.codelite/PSP.session
index 867ce55..3f9437f 100644
--- a/.codelite/PSP.session
+++ b/.codelite/PSP.session
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<Session Name="C:\Users\Thales\Documents\GitHub\PSP\PSP.workspace">
- <int Value="6" Name="m_selectedTab"/>
+ <int Value="0" Name="m_selectedTab"/>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\PSP.workspace" Name="m_workspaceName"/>
<TabInfoArray Name="TabInfoArray">
<TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Workspace.cpp" Name="FileName"/>
- <int Value="27" Name="FirstVisibleLine"/>
- <int Value="45" Name="CurrentLine"/>
+ <int Value="356" Name="FirstVisibleLine"/>
+ <int Value="373" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Workspace.h" Name="FileName"/>
- <int Value="136" Name="FirstVisibleLine"/>
- <int Value="151" Name="CurrentLine"/>
+ <int Value="105" Name="FirstVisibleLine"/>
+ <int Value="123" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
@@ -33,29 +33,8 @@
</TabInfo>
<TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Element.h" Name="FileName"/>
- <int Value="126" Name="FirstVisibleLine"/>
- <int Value="143" Name="CurrentLine"/>
- <wxArrayString Name="Bookmarks"/>
- <IntVector Name="CollapsedFolds"/>
- </TabInfo>
- <TabInfo>
- <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\PowerFlow.cpp" Name="FileName"/>
- <int Value="0" Name="FirstVisibleLine"/>
- <int Value="20" Name="CurrentLine"/>
- <wxArrayString Name="Bookmarks"/>
- <IntVector Name="CollapsedFolds"/>
- </TabInfo>
- <TabInfo>
- <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\ElectricCalculation.cpp" Name="FileName"/>
- <int Value="148" Name="FirstVisibleLine"/>
- <int Value="166" Name="CurrentLine"/>
- <wxArrayString Name="Bookmarks"/>
- <IntVector Name="CollapsedFolds"/>
- </TabInfo>
- <TabInfo>
- <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\ElectricCalculation.h" Name="FileName"/>
- <int Value="15" Name="FirstVisibleLine"/>
- <int Value="30" Name="CurrentLine"/>
+ <int Value="120" Name="FirstVisibleLine"/>
+ <int Value="137" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
diff --git a/.codelite/PSP.tags b/.codelite/PSP.tags
index 56bcbbd..e0f5734 100644
--- a/.codelite/PSP.tags
+++ b/.codelite/PSP.tags
Binary files differ
diff --git a/.codelite/compilation.db b/.codelite/compilation.db
index 98a3256..2ae1465 100644
--- a/.codelite/compilation.db
+++ b/.codelite/compilation.db
Binary files differ
diff --git a/.codelite/refactoring.db b/.codelite/refactoring.db
index a2492ff..2263d68 100644
--- a/.codelite/refactoring.db
+++ b/.codelite/refactoring.db
Binary files differ
diff --git a/Buglist.txt b/Buglist.txt
index c05ac90..154f739 100644
--- a/Buglist.txt
+++ b/Buglist.txt
@@ -5,7 +5,6 @@ PRIORIDADE 1:
PRIORIDADE 2:
-> Atualizar a posição dos disjuntores quando um circuito for colado;
--> Implementar uma visão rápida da solução (usar wxPopupTransientWindow ou wxPopupWindow);
-> Abrir formulário pelo menu de contexto;
-> Abrir o formulário do elemento após inserir o mesmo;
-> Erro ao tentar inserir texto do tipo nome para elementos de ramo;
@@ -18,10 +17,11 @@ PRIORIDADE 2:
-> Setas de fluxo de carga de linhas e transformadores não são atualizadas quando uma barra conectada é removida;
-> Setas do fluxo de carga das máquinas elétricas não são atualizadas quando a barra conectada é rotacionada;
-> Criar segurança caso um aquivo não possa ser escrito ou aberto;
--> Linhas dos transformadores desalinhadas quando abertos de um arquivo salvo;
+-> Linhas dos transformadores desalinhadas quando movidos;
-> Remover a ferramenta Exportar/Importar.
PRIORIDADE 3:
+-> Fluxo de potência dos elementos de ramo na unidade da potência base do sistema;
-> Inserir texto com nome da barra juntamente com barra;
-> Implementar dados em relação à base de potência do elemento (e não somente do sistema);
-> Implementar fluxo de carga pelo método numérico de Newton-Raphson;
diff --git a/Project/Bus.cpp b/Project/Bus.cpp
index dffe8fc..63123c3 100644
--- a/Project/Bus.cpp
+++ b/Project/Bus.cpp
@@ -1,7 +1,11 @@
#include "Bus.h"
-Bus::Bus() : Element() {}
-Bus::Bus(wxPoint2DDouble position) : Element()
+Bus::Bus()
+ : Element()
+{
+}
+Bus::Bus(wxPoint2DDouble position)
+ : Element()
{
m_width = 100.0;
m_height = 5.0;
@@ -22,29 +26,29 @@ void Bus::Draw(wxPoint2DDouble translation, double scale) const
{
// Draw selection (layer 1)
if(m_selected) {
- // If the object is selected, the matrix is reset to remove scale effects applied to it, thus keeping the
- // edges with fixed sizes for all zoom levels.
- glPushMatrix();
- glLoadIdentity();
- // The matrix was reset, so we must use screen coordinates (WorldToScreen).
- wxPoint2DDouble screenPt = WorldToScreen(translation, scale);
- glTranslated(screenPt.m_x, screenPt.m_y, 0.0);
- glRotated(m_angle, 0.0, 0.0, 1.0);
- glTranslated(-screenPt.m_x, -screenPt.m_y, 0.0);
-
- glColor4d(0.0, 0.5, 1.0, 0.5);
-
- wxPoint2DDouble pts[4] = {WorldToScreen(translation, scale, -(m_width / 2.0), -(m_height / 2.0)) -
- wxPoint2DDouble(m_borderSize, m_borderSize),
- WorldToScreen(translation, scale, -(m_width / 2.0), (m_height / 2.0)) -
- wxPoint2DDouble(m_borderSize, -m_borderSize),
- WorldToScreen(translation, scale, (m_width / 2.0), (m_height / 2.0)) -
- wxPoint2DDouble(-m_borderSize, -m_borderSize),
- WorldToScreen(translation, scale, (m_width / 2.0), -(m_height / 2.0)) -
- wxPoint2DDouble(-m_borderSize, m_borderSize)};
- DrawRectangle(pts);
- glPopMatrix();
- }
+ // If the object is selected, the matrix is reset to remove scale effects applied to it, thus keeping the
+ // edges with fixed sizes for all zoom levels.
+ glPushMatrix();
+ glLoadIdentity();
+ // The matrix was reset, so we must use screen coordinates (WorldToScreen).
+ wxPoint2DDouble screenPt = WorldToScreen(translation, scale);
+ glTranslated(screenPt.m_x, screenPt.m_y, 0.0);
+ glRotated(m_angle, 0.0, 0.0, 1.0);
+ glTranslated(-screenPt.m_x, -screenPt.m_y, 0.0);
+
+ glColor4d(0.0, 0.5, 1.0, 0.5);
+
+ wxPoint2DDouble pts[4] = { WorldToScreen(translation, scale, -(m_width / 2.0), -(m_height / 2.0)) -
+ wxPoint2DDouble(m_borderSize, m_borderSize),
+ WorldToScreen(translation, scale, -(m_width / 2.0), (m_height / 2.0)) -
+ wxPoint2DDouble(m_borderSize, -m_borderSize),
+ WorldToScreen(translation, scale, (m_width / 2.0), (m_height / 2.0)) -
+ wxPoint2DDouble(-m_borderSize, -m_borderSize),
+ WorldToScreen(translation, scale, (m_width / 2.0), -(m_height / 2.0)) -
+ wxPoint2DDouble(-m_borderSize, m_borderSize) };
+ DrawRectangle(pts);
+ glPopMatrix();
+ }
// Draw bus (layer 2)
// Push the current matrix on stack.
glPushMatrix();
@@ -60,21 +64,21 @@ void Bus::Draw(wxPoint2DDouble translation, double scale) const
// Draw pickbox (layer 3)
if(m_showPickbox) {
- glPushMatrix();
- glLoadIdentity();
+ glPushMatrix();
+ glLoadIdentity();
- wxPoint2DDouble screenPt = WorldToScreen(translation, scale);
- glTranslated(screenPt.m_x, screenPt.m_y, 0.0);
- glRotated(m_angle, 0.0, 0.0, 1.0);
- glTranslated(-screenPt.m_x, -screenPt.m_y, 0.0);
+ wxPoint2DDouble screenPt = WorldToScreen(translation, scale);
+ glTranslated(screenPt.m_x, screenPt.m_y, 0.0);
+ glRotated(m_angle, 0.0, 0.0, 1.0);
+ glTranslated(-screenPt.m_x, -screenPt.m_y, 0.0);
- wxPoint2DDouble pbPosition[2] = {WorldToScreen(translation, scale, m_width / 2.0),
- WorldToScreen(translation, scale, -m_width / 2.0)};
- DrawPickbox(pbPosition[0]);
- DrawPickbox(pbPosition[1]);
+ wxPoint2DDouble pbPosition[2] = { WorldToScreen(translation, scale, m_width / 2.0),
+ WorldToScreen(translation, scale, -m_width / 2.0) };
+ DrawPickbox(pbPosition[0]);
+ DrawPickbox(pbPosition[1]);
- glPopMatrix();
- }
+ glPopMatrix();
+ }
}
bool Bus::Contains(wxPoint2DDouble position) const
@@ -103,13 +107,13 @@ bool Bus::PickboxContains(wxPoint2DDouble position)
wxRect2DDouble rectLeft(center.m_x - 5.0, center.m_y - 5.0, 10.0, 10.0);
if(rectRight.Contains(ptR)) {
- m_activePickboxID = ID_PB_RIGHT;
- return true;
- }
+ m_activePickboxID = ID_PB_RIGHT;
+ return true;
+ }
if(rectLeft.Contains(ptR)) {
- m_activePickboxID = ID_PB_LEFT;
- return true;
- }
+ m_activePickboxID = ID_PB_LEFT;
+ return true;
+ }
return false;
}
@@ -120,13 +124,13 @@ wxCursor Bus::GetBestPickboxCursor() const
while(angle >= 157.5) angle -= 180.0;
if(angle >= -22.5 && angle < 22.5)
- return wxCursor(wxCURSOR_SIZEWE);
+ return wxCursor(wxCURSOR_SIZEWE);
else if(angle >= 22.5 && angle < 67.5)
- return wxCursor(wxCURSOR_SIZENWSE);
+ return wxCursor(wxCURSOR_SIZENWSE);
else if(angle >= 67.5 && angle < 112.5)
- return wxCursor(wxCURSOR_SIZENS);
+ return wxCursor(wxCURSOR_SIZENS);
else if(angle >= 112.5 && angle < 157.5)
- return wxCursor(wxCURSOR_SIZENESW);
+ return wxCursor(wxCURSOR_SIZENESW);
return wxCursor(wxCURSOR_ARROW);
}
@@ -139,21 +143,19 @@ void Bus::MovePickbox(wxPoint2DDouble position)
double dx = 0.0;
if(m_activePickboxID == ID_PB_RIGHT)
- dx = ptR.m_x - m_position.m_x - m_width / 2.0;
+ dx = ptR.m_x - m_position.m_x - m_width / 2.0;
else if(m_activePickboxID == ID_PB_LEFT)
- dx = m_position.m_x - m_width / 2.0 - ptR.m_x;
+ dx = m_position.m_x - m_width / 2.0 - ptR.m_x;
if(m_width + dx < 20.0) return;
if(m_activePickboxID == ID_PB_RIGHT) {
- m_position.m_x += (dx / 2.0) * std::cos(wxDegToRad(m_angle));
- m_position.m_y += (dx / 2.0) * std::sin(wxDegToRad(m_angle));
- }
- else if(m_activePickboxID == ID_PB_LEFT)
- {
- m_position.m_x -= (dx / 2.0) * std::cos(wxDegToRad(m_angle));
- m_position.m_y -= (dx / 2.0) * std::sin(wxDegToRad(m_angle));
- }
+ m_position.m_x += (dx / 2.0) * std::cos(wxDegToRad(m_angle));
+ m_position.m_y += (dx / 2.0) * std::sin(wxDegToRad(m_angle));
+ } else if(m_activePickboxID == ID_PB_LEFT) {
+ m_position.m_x -= (dx / 2.0) * std::cos(wxDegToRad(m_angle));
+ m_position.m_y -= (dx / 2.0) * std::sin(wxDegToRad(m_angle));
+ }
m_width += dx;
SetPosition(m_position);
@@ -179,9 +181,9 @@ bool Bus::ShowForm(wxWindow* parent, Element* element)
{
BusForm* busForm = new BusForm(parent, this);
if(busForm->ShowModal() == wxID_OK) {
- busForm->Destroy();
- return true;
- }
+ busForm->Destroy();
+ return true;
+ }
busForm->Destroy();
return false;
@@ -189,7 +191,34 @@ bool Bus::ShowForm(wxWindow* parent, Element* element)
Element* Bus::GetCopy()
{
- Bus* copy = new Bus();
- *copy = *this;
- return copy;
+ Bus* copy = new Bus();
+ *copy = *this;
+ return copy;
+}
+wxString Bus::GetTipText() const
+{
+ wxString tipText = m_electricalData.name;
+ tipText += wxString::Format(" (%d)", m_electricalData.number + 1);
+ tipText += "\n";
+ tipText += StringFromDouble(m_electricalData.nominalVoltage, 1) +
+ (m_electricalData.nominalVoltageUnit == UNIT_V ? _(" V") : _(" kV"));
+ tipText += "\n";
+ tipText += _("\nV = ") + wxString::FromDouble(std::abs(m_electricalData.voltage), 5) + _(" p.u.");
+ tipText += "\n";
+ tipText += wxString(L'\u03B8') + " = " + wxString::FromDouble(wxRadToDeg(std::arg(m_electricalData.voltage)), 5) +
+ " " + wxString(L'\u00B0');
+
+ tipText += _("\n\nFault info:");
+ tipText += _("\nVa = ") + wxString::FromDouble(std::abs(m_electricalData.faultVoltage[0]), 5) + _(" p.u.");
+ tipText += _("\nVb = ") + wxString::FromDouble(std::abs(m_electricalData.faultVoltage[1]), 5) + _(" p.u.");
+ tipText += _("\nVc = ") + wxString::FromDouble(std::abs(m_electricalData.faultVoltage[2]), 5) + _(" p.u.");
+ if(m_electricalData.hasFault) {
+ tipText += _("\nIa = ") + wxString::FromDouble(std::abs(m_electricalData.faultCurrent[0]), 5) + _(" p.u.");
+ tipText += _("\nIb = ") + wxString::FromDouble(std::abs(m_electricalData.faultCurrent[1]), 5) + _(" p.u.");
+ tipText += _("\nIc = ") + wxString::FromDouble(std::abs(m_electricalData.faultCurrent[2]), 5) + _(" p.u.");
+ }
+
+ tipText += _("\n\nSsc = ") + wxString::FromDouble(std::abs(m_electricalData.scPower), 5) + _(" p.u.");
+
+ return tipText;
}
diff --git a/Project/Bus.h b/Project/Bus.h
index acf22ab..c7f66ef 100644
--- a/Project/Bus.h
+++ b/Project/Bus.h
@@ -46,7 +46,7 @@ public:
Bus(wxPoint2DDouble position);
Bus(wxPoint2DDouble position, wxString name);
~Bus();
- virtual Element* GetCopy();
+ virtual Element* GetCopy();
virtual bool AddParent(Element* parent, wxPoint2DDouble position) { return true; }
virtual bool Contains(wxPoint2DDouble position) const;
virtual bool Intersects(wxRect2DDouble rect) const;
@@ -56,6 +56,7 @@ public:
virtual void MovePickbox(wxPoint2DDouble position);
virtual bool PickboxContains(wxPoint2DDouble position);
virtual bool GetContextMenu(wxMenu& menu);
+ virtual wxString GetTipText() const;
virtual BusElectricalData GetEletricalData() const { return m_electricalData; }
virtual void SetElectricalData(BusElectricalData electricalData) { m_electricalData = electricalData; }
virtual bool ShowForm(wxWindow* parent, Element* element);
diff --git a/Project/Capacitor.cpp b/Project/Capacitor.cpp
index 7545135..1ec17fc 100644
--- a/Project/Capacitor.cpp
+++ b/Project/Capacitor.cpp
@@ -170,3 +170,35 @@ Element* Capacitor::GetCopy()
*copy = *this;
return copy;
}
+
+wxString Capacitor::GetTipText() const
+{
+ wxString tipText = m_electricalData.name;
+
+ // TODO: Avoid reactive power calculation.
+ double reactivePower = m_electricalData.reactivePower;
+ if(m_online) {
+ std::complex<double> v = ((Bus*)m_parentList[0])->GetEletricalData().voltage;
+ reactivePower *= std::pow(std::abs(v), 2);
+ }
+ tipText += "\n";
+ tipText += _("\nQ = ") + wxString::FromDouble(reactivePower, 5);
+ switch(m_electricalData.reactivePowerUnit) {
+ case UNIT_PU: {
+ tipText += _(" p.u.");
+ } break;
+ case UNIT_VAr: {
+ tipText += _(" VAr");
+ } break;
+ case UNIT_kVAr: {
+ tipText += _(" kVAr");
+ } break;
+ case UNIT_MVAr: {
+ tipText += _(" MVAr");
+ } break;
+ default:
+ break;
+ }
+
+ return tipText;
+}
diff --git a/Project/Capacitor.h b/Project/Capacitor.h
index fdacb42..c124396 100644
--- a/Project/Capacitor.h
+++ b/Project/Capacitor.h
@@ -13,24 +13,25 @@ struct CapacitorElectricalData {
class Capacitor : public Shunt
{
- public:
+public:
Capacitor();
Capacitor(wxString name);
~Capacitor();
-
- virtual Element* GetCopy();
+
+ virtual Element* GetCopy();
virtual bool AddParent(Element* parent, wxPoint2DDouble position);
virtual void Draw(wxPoint2DDouble translation, double scale) const;
virtual bool Contains(wxPoint2DDouble position) const;
virtual bool Intersects(wxRect2DDouble rect) const;
virtual void Rotate(bool clockwise = true);
virtual bool GetContextMenu(wxMenu& menu);
+ virtual wxString GetTipText() const;
virtual bool ShowForm(wxWindow* parent, Element* element);
virtual CapacitorElectricalData GetElectricalData() { return m_electricalData; }
virtual CapacitorElectricalData GetPUElectricalData(double systemPowerBase);
virtual void SetElectricalData(CapacitorElectricalData electricalData) { m_electricalData = electricalData; }
- protected:
+protected:
CapacitorElectricalData m_electricalData;
};
-#endif // CAPACITOR_H
+#endif // CAPACITOR_H
diff --git a/Project/Element.h b/Project/Element.h
index c5aa030..996d066 100644
--- a/Project/Element.h
+++ b/Project/Element.h
@@ -135,7 +135,8 @@ public:
virtual void AddChild(Element* child);
virtual void RemoveChild(Element* child);
virtual void ReplaceChild(Element* oldChild, Element* newChild);
- virtual void Draw(wxPoint2DDouble translation, double scale) const {};
+ virtual wxString GetTipText() const { return wxEmptyString; }
+ virtual void Draw(wxPoint2DDouble translation, double scale) const {}
virtual void Rotate(bool clockwise = true) {}
virtual bool GetContextMenu(wxMenu& menu) { return false; }
virtual void AddPoint(wxPoint2DDouble point) {}
diff --git a/Project/IndMotor.cpp b/Project/IndMotor.cpp
index fc30f12..b129d63 100644
--- a/Project/IndMotor.cpp
+++ b/Project/IndMotor.cpp
@@ -1,8 +1,12 @@
#include "IndMotorForm.h"
#include "IndMotor.h"
-IndMotor::IndMotor() : Machines() { }
-IndMotor::IndMotor(wxString name) : Machines()
+IndMotor::IndMotor()
+ : Machines()
+{
+}
+IndMotor::IndMotor(wxString name)
+ : Machines()
{
m_electricalData.name = name;
}
@@ -38,9 +42,9 @@ bool IndMotor::ShowForm(wxWindow* parent, Element* element)
IndMotorElectricalData IndMotor::GetPUElectricalData(double systemPowerBase)
{
- IndMotorElectricalData data = m_electricalData;
-
- switch(data.activePowerUnit) {
+ IndMotorElectricalData data = m_electricalData;
+
+ switch(data.activePowerUnit) {
case UNIT_W: {
data.activePower = data.activePower / systemPowerBase;
data.activePowerUnit = UNIT_PU;
@@ -72,13 +76,55 @@ IndMotorElectricalData IndMotor::GetPUElectricalData(double systemPowerBase)
default:
break;
}
-
- return data;
+
+ return data;
}
Element* IndMotor::GetCopy()
{
- IndMotor* copy = new IndMotor();
- *copy = *this;
- return copy;
+ IndMotor* copy = new IndMotor();
+ *copy = *this;
+ return copy;
+}
+
+wxString IndMotor::GetTipText() const
+{
+ wxString tipText = m_electricalData.name;
+ tipText += "\n";
+ tipText += _("\nP = ") + wxString::FromDouble(m_electricalData.activePower, 5);
+ switch(m_electricalData.activePowerUnit) {
+ case UNIT_PU: {
+ tipText += _(" p.u.");
+ } break;
+ case UNIT_W: {
+ tipText += _(" W");
+ } break;
+ case UNIT_kW: {
+ tipText += _(" kW");
+ } break;
+ case UNIT_MW: {
+ tipText += _(" MW");
+ } break;
+ default:
+ break;
+ }
+ tipText += _("\nQ = ") + wxString::FromDouble(m_electricalData.reactivePower, 5);
+ switch(m_electricalData.reactivePowerUnit) {
+ case UNIT_PU: {
+ tipText += _(" p.u.");
+ } break;
+ case UNIT_VAr: {
+ tipText += _(" VAr");
+ } break;
+ case UNIT_kVAr: {
+ tipText += _(" kVAr");
+ } break;
+ case UNIT_MVAr: {
+ tipText += _(" MVAr");
+ } break;
+ default:
+ break;
+ }
+
+ return tipText;
}
diff --git a/Project/IndMotor.h b/Project/IndMotor.h
index 03c64d7..1a40511 100644
--- a/Project/IndMotor.h
+++ b/Project/IndMotor.h
@@ -24,6 +24,7 @@ class IndMotor : public Machines
virtual Element* GetCopy();
virtual void DrawSymbol() const;
virtual bool GetContextMenu(wxMenu& menu);
+ virtual wxString GetTipText() const;
virtual bool ShowForm(wxWindow* parent, Element* element);
virtual IndMotorElectricalData GetElectricalData() { return m_electricalData; }
virtual IndMotorElectricalData GetPUElectricalData(double systemPowerBase);
diff --git a/Project/Inductor.cpp b/Project/Inductor.cpp
index 0a272c1..6856ff4 100644
--- a/Project/Inductor.cpp
+++ b/Project/Inductor.cpp
@@ -164,3 +164,35 @@ Element* Inductor::GetCopy()
*copy = *this;
return copy;
}
+
+wxString Inductor::GetTipText() const
+{
+ wxString tipText = m_electricalData.name;
+
+ // TODO: Avoid reactive power calculation.
+ double reactivePower = m_electricalData.reactivePower;
+ if(m_online) {
+ std::complex<double> v = ((Bus*)m_parentList[0])->GetEletricalData().voltage;
+ reactivePower *= std::pow(std::abs(v), 2);
+ }
+ tipText += "\n";
+ tipText += _("\nQ = ") + wxString::FromDouble(reactivePower, 5);
+ switch(m_electricalData.reactivePowerUnit) {
+ case UNIT_PU: {
+ tipText += _(" p.u.");
+ } break;
+ case UNIT_VAr: {
+ tipText += _(" VAr");
+ } break;
+ case UNIT_kVAr: {
+ tipText += _(" kVAr");
+ } break;
+ case UNIT_MVAr: {
+ tipText += _(" MVAr");
+ } break;
+ default:
+ break;
+ }
+
+ return tipText;
+}
diff --git a/Project/Inductor.h b/Project/Inductor.h
index 84acc18..64e6889 100644
--- a/Project/Inductor.h
+++ b/Project/Inductor.h
@@ -25,6 +25,7 @@ class Inductor : public Shunt
virtual bool Intersects(wxRect2DDouble rect) const;
virtual void Rotate(bool clockwise = true);
virtual bool GetContextMenu(wxMenu& menu);
+ virtual wxString GetTipText() const;
virtual bool ShowForm(wxWindow* parent, Element* element);
virtual InductorElectricalData GetElectricalData() { return m_electricalData; }
virtual InductorElectricalData GetPUElectricalData(double systemPowerBase);
diff --git a/Project/Line.cpp b/Project/Line.cpp
index 4b7f6c4..32f4aa8 100644
--- a/Project/Line.cpp
+++ b/Project/Line.cpp
@@ -32,9 +32,11 @@ bool Line::Contains(wxPoint2DDouble position) const
void Line::Draw(wxPoint2DDouble translation, double scale) const
{
OpenGLColour elementColour;
- if(m_online) elementColour = m_onlineElementColour;
- else elementColour = m_offlineElementColour;
-
+ if(m_online)
+ elementColour = m_onlineElementColour;
+ else
+ elementColour = m_offlineElementColour;
+
std::vector<wxPoint2DDouble> pointList = m_pointList;
if(!m_inserted && pointList.size() > 0) {
wxPoint2DDouble secondPoint = m_position;
@@ -503,7 +505,30 @@ void Line::SetPointList(std::vector<wxPoint2DDouble> pointList)
Element* Line::GetCopy()
{
- Line* copy = new Line();
- *copy = *this;
- return copy;
+ Line* copy = new Line();
+ *copy = *this;
+ return copy;
+}
+
+wxString Line::GetTipText() const
+{
+ wxString tipText = m_electricaData.name;
+
+ if(m_online) {
+ tipText += "\n";
+ int busNumber[2];
+ busNumber[0] = ((Bus*)m_parentList[0])->GetEletricalData().number + 1;
+ busNumber[1] = ((Bus*)m_parentList[1])->GetEletricalData().number + 1;
+
+ tipText += _("\nP") + wxString::Format("(%d-%d) = ", busNumber[0], busNumber[1]) +
+ wxString::FromDouble(m_electricaData.powerFlow[0].real(), 5) + _(" p.u.");
+ tipText += _("\nQ") + wxString::Format("(%d-%d) = ", busNumber[0], busNumber[1]) +
+ wxString::FromDouble(m_electricaData.powerFlow[0].imag(), 5) + _(" p.u.");
+ tipText += _("\nP") + wxString::Format("(%d-%d) = ", busNumber[1], busNumber[0]) +
+ wxString::FromDouble(m_electricaData.powerFlow[1].real(), 5) + _(" p.u.");
+ tipText += _("\nQ") + wxString::Format("(%d-%d) = ", busNumber[1], busNumber[0]) +
+ wxString::FromDouble(m_electricaData.powerFlow[1].imag(), 5) + _(" p.u.");
+ }
+
+ return tipText;
}
diff --git a/Project/Line.h b/Project/Line.h
index 7000701..1ff1102 100644
--- a/Project/Line.h
+++ b/Project/Line.h
@@ -21,8 +21,8 @@ struct LineElectricalData {
bool useLinePower = false;
// Power flow (p.u.)
- std::complex<double> current[2] = {std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0)};
- std::complex<double> powerFlow[2] = {std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0)};
+ std::complex<double> current[2] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0) };
+ std::complex<double> powerFlow[2] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0) };
// Fault
double zeroResistance = 0.0;
@@ -34,7 +34,7 @@ struct LineElectricalData {
class Line : public Branch
{
- public:
+public:
Line();
Line(wxString name);
~Line();
@@ -45,13 +45,14 @@ class Line : public Branch
virtual void MoveNode(Element* parent, wxPoint2DDouble position);
virtual bool SetNodeParent(Element* parent);
virtual wxCursor GetBestPickboxCursor() const { return wxCURSOR_SIZING; }
- virtual Element* GetCopy();
+ virtual Element* GetCopy();
virtual bool AddParent(Element* parent, wxPoint2DDouble position);
virtual bool Intersects(wxRect2DDouble rect) const;
virtual void MovePickbox(wxPoint2DDouble position);
virtual bool PickboxContains(wxPoint2DDouble position);
virtual void AddPoint(wxPoint2DDouble point);
virtual bool GetContextMenu(wxMenu& menu);
+ virtual wxString GetTipText() const;
virtual void RemoveNode(wxPoint2DDouble point);
virtual void AddNode(wxPoint2DDouble point);
virtual void RotateNode(Element* parent, bool clockwise = true);
@@ -63,10 +64,10 @@ class Line : public Branch
virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit);
virtual void SetPointList(std::vector<wxPoint2DDouble> pointList);
- protected:
+protected:
double PointToLineDistance(wxPoint2DDouble point, int* segmentNumber = NULL) const;
void UpdatePowerFlowArrowsPosition();
LineElectricalData m_electricaData;
};
-#endif // LINE_H
+#endif // LINE_H
diff --git a/Project/Load.cpp b/Project/Load.cpp
index be5d1bb..e1b9b82 100644
--- a/Project/Load.cpp
+++ b/Project/Load.cpp
@@ -1,7 +1,14 @@
#include "Load.h"
-Load::Load() : Shunt() {}
-Load::Load(wxString name) : Shunt() { m_electricalData.name = name; }
+Load::Load()
+ : Shunt()
+{
+}
+Load::Load(wxString name)
+ : Shunt()
+{
+ m_electricalData.name = name;
+}
Load::~Load() {}
bool Load::AddParent(Element* parent, wxPoint2DDouble position)
{
@@ -9,11 +16,11 @@ bool Load::AddParent(Element* parent, wxPoint2DDouble position)
m_parentList.push_back(parent);
parent->AddChild(this);
wxPoint2DDouble parentPt =
- parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position.
- parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus.
- parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back.
+ parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position.
+ parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus.
+ parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back.
- m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
+ m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
m_width = m_height = 20.0;
m_rect = wxRect2DDouble(m_position.m_x - 10.0, m_position.m_y - 10.0, m_width, m_height);
@@ -29,7 +36,7 @@ bool Load::AddParent(Element* parent, wxPoint2DDouble position)
m_inserted = true;
wxRect2DDouble genRect(0, 0, 0, 0);
- m_switchRect.push_back(genRect); // Push a general rectangle.
+ m_switchRect.push_back(genRect); // Push a general rectangle.
UpdateSwitches();
m_pfDirection = PF_TO_ELEMENT;
UpdatePowerFlowArrowsPosition();
@@ -42,19 +49,21 @@ bool Load::AddParent(Element* parent, wxPoint2DDouble position)
void Load::Draw(wxPoint2DDouble translation, double scale) const
{
OpenGLColour elementColour;
- if(m_online) elementColour = m_onlineElementColour;
- else elementColour = m_offlineElementColour;
-
+ if(m_online)
+ elementColour = m_onlineElementColour;
+ else
+ elementColour = m_offlineElementColour;
+
if(m_inserted) {
// Draw Selection (layer 1).
if(m_selected) {
glLineWidth(1.5 + m_borderSize * 2.0);
glColor4dv(m_selectionColour.GetRGBA());
std::vector<wxPoint2DDouble> selTriangPts;
- selTriangPts.push_back(m_triangPts[0] + m_position +
- wxPoint2DDouble(-m_borderSize / scale, -m_borderSize / scale));
- selTriangPts.push_back(m_triangPts[1] + m_position +
- wxPoint2DDouble(m_borderSize / scale, -m_borderSize / scale));
+ selTriangPts.push_back(
+ m_triangPts[0] + m_position + wxPoint2DDouble(-m_borderSize / scale, -m_borderSize / scale));
+ selTriangPts.push_back(
+ m_triangPts[1] + m_position + wxPoint2DDouble(m_borderSize / scale, -m_borderSize / scale));
selTriangPts.push_back(m_triangPts[2] + m_position + wxPoint2DDouble(0.0, m_borderSize / scale));
glPushMatrix();
@@ -168,7 +177,58 @@ LoadElectricalData Load::GetPUElectricalData(double systemPowerBase)
Element* Load::GetCopy()
{
- Load* copy = new Load();
- *copy = *this;
- return copy;
+ Load* copy = new Load();
+ *copy = *this;
+ return copy;
+}
+
+wxString Load::GetTipText() const
+{
+ wxString tipText = m_electricalData.name;
+
+ // TODO: Avoid power calculation.
+ double activePower = m_electricalData.activePower;
+ double reactivePower = m_electricalData.reactivePower;
+ if(m_online && m_electricalData.loadType == CONST_IMPEDANCE) {
+ std::complex<double> v = ((Bus*)m_parentList[0])->GetEletricalData().voltage;
+ reactivePower *= std::pow(std::abs(v), 2);
+ activePower *= std::pow(std::abs(v), 2);
+ }
+ tipText += "\n";
+ tipText += _("\nP = ") + wxString::FromDouble(activePower, 5);
+ switch(m_electricalData.activePowerUnit) {
+ case UNIT_PU: {
+ tipText += _(" p.u.");
+ } break;
+ case UNIT_W: {
+ tipText += _(" W");
+ } break;
+ case UNIT_kW: {
+ tipText += _(" kW");
+ } break;
+ case UNIT_MW: {
+ tipText += _(" MW");
+ } break;
+ default:
+ break;
+ }
+ tipText += _("\nQ = ") + wxString::FromDouble(reactivePower, 5);
+ switch(m_electricalData.reactivePowerUnit) {
+ case UNIT_PU: {
+ tipText += _(" p.u.");
+ } break;
+ case UNIT_VAr: {
+ tipText += _(" VAr");
+ } break;
+ case UNIT_kVAr: {
+ tipText += _(" kVAr");
+ } break;
+ case UNIT_MVAr: {
+ tipText += _(" MVAr");
+ } break;
+ default:
+ break;
+ }
+
+ return tipText;
}
diff --git a/Project/Load.h b/Project/Load.h
index 88bedaa..ce71e5f 100644
--- a/Project/Load.h
+++ b/Project/Load.h
@@ -32,12 +32,13 @@ class Load : public Shunt
virtual void Draw(wxPoint2DDouble translation, double scale) const;
virtual void Rotate(bool clockwise = true);
virtual bool GetContextMenu(wxMenu& menu);
+ virtual wxString GetTipText() const;
virtual bool ShowForm(wxWindow* parent, Element* element);
LoadElectricalData GetElectricalData() { return m_electricalData; }
LoadElectricalData GetPUElectricalData(double systemPowerBase);
void SetElectricalData(LoadElectricalData electricalData) { m_electricalData = electricalData; }
- private:
+ protected:
std::vector<wxPoint2DDouble> m_triangPts;
LoadElectricalData m_electricalData;
};
diff --git a/Project/Project.mk b/Project/Project.mk
index 6d4aebd..7db3855 100644
--- a/Project/Project.mk
+++ b/Project/Project.mk
@@ -13,7 +13,7 @@ CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=Thales
-Date :=29/12/2016
+Date :=02/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/Project.project b/Project/Project.project
index b04dc78..06bb41e 100644
--- a/Project/Project.project
+++ b/Project/Project.project
@@ -185,7 +185,7 @@
</Compiler>
<Linker Options="$(shell wx-config --libs gl);-mwindows" Required="yes"/>
<ResourceCompiler Options="$(shell wx-config --rcflags)" Required="no"/>
- <General OutputFile="$(IntermediateDirectory)/PSP-UFU" IntermediateDirectory="./Release" Command="./PSP-UFU" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="no" IsGUIProgram="no" IsEnabled="yes"/>
+ <General OutputFile="$(IntermediateDirectory)/PSP-UFU" IntermediateDirectory="./Release" Command="./PSP-UFU" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="no" IsGUIProgram="yes" IsEnabled="yes"/>
<BuildSystem Name="Default"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[]]>
diff --git a/Project/Release/Branch.cpp.o b/Project/Release/Branch.cpp.o
index 650804e..8e86561 100644
--- a/Project/Release/Branch.cpp.o
+++ b/Project/Release/Branch.cpp.o
Binary files differ
diff --git a/Project/Release/Bus.cpp.o b/Project/Release/Bus.cpp.o
index 1340ef8..ca4bc6c 100644
--- a/Project/Release/Bus.cpp.o
+++ b/Project/Release/Bus.cpp.o
Binary files differ
diff --git a/Project/Release/BusForm.cpp.o b/Project/Release/BusForm.cpp.o
index 8951fc6..8bea3b5 100644
--- a/Project/Release/BusForm.cpp.o
+++ b/Project/Release/BusForm.cpp.o
Binary files differ
diff --git a/Project/Release/Capacitor.cpp.o b/Project/Release/Capacitor.cpp.o
index 5d66a63..a6cb286 100644
--- a/Project/Release/Capacitor.cpp.o
+++ b/Project/Release/Capacitor.cpp.o
Binary files differ
diff --git a/Project/Release/Capacitor.cpp.o.d b/Project/Release/Capacitor.cpp.o.d
index 83c44d8..ad88897 100644
--- a/Project/Release/Capacitor.cpp.o.d
+++ b/Project/Release/Capacitor.cpp.o.d
@@ -225,7 +225,7 @@ Release/Capacitor.cpp.o: Capacitor.cpp ReactiveShuntElementForm.h \
C:/wxWidgets-3.1.0/include/wx/msw/menuitem.h \
C:/wxWidgets-3.1.0/include/wx/ownerdrw.h \
C:/wxWidgets-3.1.0/include/wx/msw/ownerdrw.h \
- C:/wxWidgets-3.1.0/include/wx/msw/menu.h
+ C:/wxWidgets-3.1.0/include/wx/msw/menu.h Bus.h BusForm.h
ReactiveShuntElementForm.h:
@@ -694,3 +694,7 @@ C:/wxWidgets-3.1.0/include/wx/ownerdrw.h:
C:/wxWidgets-3.1.0/include/wx/msw/ownerdrw.h:
C:/wxWidgets-3.1.0/include/wx/msw/menu.h:
+
+Bus.h:
+
+BusForm.h:
diff --git a/Project/Release/ElectricCalculation.cpp.o b/Project/Release/ElectricCalculation.cpp.o
index 2dfcbc1..b91eaf0 100644
--- a/Project/Release/ElectricCalculation.cpp.o
+++ b/Project/Release/ElectricCalculation.cpp.o
Binary files differ
diff --git a/Project/Release/Element.cpp.o b/Project/Release/Element.cpp.o
index fde7b9d..432ace6 100644
--- a/Project/Release/Element.cpp.o
+++ b/Project/Release/Element.cpp.o
Binary files differ
diff --git a/Project/Release/FileHanding.cpp.o b/Project/Release/FileHanding.cpp.o
index 710256c..e1c3dde 100644
--- a/Project/Release/FileHanding.cpp.o
+++ b/Project/Release/FileHanding.cpp.o
Binary files differ
diff --git a/Project/Release/GeneratorStabForm.cpp.o b/Project/Release/GeneratorStabForm.cpp.o
index c79ab0f..542233d 100644
--- a/Project/Release/GeneratorStabForm.cpp.o
+++ b/Project/Release/GeneratorStabForm.cpp.o
Binary files differ
diff --git a/Project/Release/IndMotor.cpp.o b/Project/Release/IndMotor.cpp.o
index c977c83..fb7b130 100644
--- a/Project/Release/IndMotor.cpp.o
+++ b/Project/Release/IndMotor.cpp.o
Binary files differ
diff --git a/Project/Release/IndMotorForm.cpp.o b/Project/Release/IndMotorForm.cpp.o
index bc4d845..1655663 100644
--- a/Project/Release/IndMotorForm.cpp.o
+++ b/Project/Release/IndMotorForm.cpp.o
Binary files differ
diff --git a/Project/Release/Inductor.cpp.o b/Project/Release/Inductor.cpp.o
index 9162679..278fe7a 100644
--- a/Project/Release/Inductor.cpp.o
+++ b/Project/Release/Inductor.cpp.o
Binary files differ
diff --git a/Project/Release/Inductor.cpp.o.d b/Project/Release/Inductor.cpp.o.d
index 4d36a8e..32c4b5f 100644
--- a/Project/Release/Inductor.cpp.o.d
+++ b/Project/Release/Inductor.cpp.o.d
@@ -225,7 +225,7 @@ Release/Inductor.cpp.o: Inductor.cpp ReactiveShuntElementForm.h \
C:/wxWidgets-3.1.0/include/wx/msw/menuitem.h \
C:/wxWidgets-3.1.0/include/wx/ownerdrw.h \
C:/wxWidgets-3.1.0/include/wx/msw/ownerdrw.h \
- C:/wxWidgets-3.1.0/include/wx/msw/menu.h
+ C:/wxWidgets-3.1.0/include/wx/msw/menu.h Bus.h BusForm.h
ReactiveShuntElementForm.h:
@@ -694,3 +694,7 @@ C:/wxWidgets-3.1.0/include/wx/ownerdrw.h:
C:/wxWidgets-3.1.0/include/wx/msw/ownerdrw.h:
C:/wxWidgets-3.1.0/include/wx/msw/menu.h:
+
+Bus.h:
+
+BusForm.h:
diff --git a/Project/Release/Line.cpp.o b/Project/Release/Line.cpp.o
index ebc38b3..6011e10 100644
--- a/Project/Release/Line.cpp.o
+++ b/Project/Release/Line.cpp.o
Binary files differ
diff --git a/Project/Release/LineForm.cpp.o b/Project/Release/LineForm.cpp.o
index 0c481b7..ae904d1 100644
--- a/Project/Release/LineForm.cpp.o
+++ b/Project/Release/LineForm.cpp.o
Binary files differ
diff --git a/Project/Release/Load.cpp.o b/Project/Release/Load.cpp.o
index 4cf5b30..1a819eb 100644
--- a/Project/Release/Load.cpp.o
+++ b/Project/Release/Load.cpp.o
Binary files differ
diff --git a/Project/Release/Load.cpp.o.d b/Project/Release/Load.cpp.o.d
index a0f11b6..5050c3a 100644
--- a/Project/Release/Load.cpp.o.d
+++ b/Project/Release/Load.cpp.o.d
@@ -225,7 +225,7 @@ Release/Load.cpp.o: Load.cpp Load.h LoadForm.h ElementForm.h \
C:/wxWidgets-3.1.0/include/wx/msw/ownerdrw.h \
C:/wxWidgets-3.1.0/include/wx/msw/menu.h \
C:/wxWidgets-3.1.0/include/wx/log.h \
- C:/wxWidgets-3.1.0/include/wx/generic/logg.h
+ C:/wxWidgets-3.1.0/include/wx/generic/logg.h Bus.h BusForm.h
Load.h:
@@ -694,3 +694,7 @@ C:/wxWidgets-3.1.0/include/wx/msw/menu.h:
C:/wxWidgets-3.1.0/include/wx/log.h:
C:/wxWidgets-3.1.0/include/wx/generic/logg.h:
+
+Bus.h:
+
+BusForm.h:
diff --git a/Project/Release/Machines.cpp.o b/Project/Release/Machines.cpp.o
index 77bb073..98cf0de 100644
--- a/Project/Release/Machines.cpp.o
+++ b/Project/Release/Machines.cpp.o
Binary files differ
diff --git a/Project/Release/MainFrame.cpp.o b/Project/Release/MainFrame.cpp.o
index 4b8b802..c8e7d49 100644
--- a/Project/Release/MainFrame.cpp.o
+++ b/Project/Release/MainFrame.cpp.o
Binary files differ
diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe
index ef49ff3..4259c0bb 100644
--- a/Project/Release/PSP-UFU.exe
+++ b/Project/Release/PSP-UFU.exe
Binary files differ
diff --git a/Project/Release/PowerFlow.cpp.o b/Project/Release/PowerFlow.cpp.o
index 6cb09be..9de4bb9 100644
--- a/Project/Release/PowerFlow.cpp.o
+++ b/Project/Release/PowerFlow.cpp.o
Binary files differ
diff --git a/Project/Release/ReactiveShuntElementForm.cpp.o b/Project/Release/ReactiveShuntElementForm.cpp.o
index 363e8c9..2a46617 100644
--- a/Project/Release/ReactiveShuntElementForm.cpp.o
+++ b/Project/Release/ReactiveShuntElementForm.cpp.o
Binary files differ
diff --git a/Project/Release/Shunt.cpp.o b/Project/Release/Shunt.cpp.o
index 5476fab..c15cc27 100644
--- a/Project/Release/Shunt.cpp.o
+++ b/Project/Release/Shunt.cpp.o
Binary files differ
diff --git a/Project/Release/SwitchingForm.cpp.o b/Project/Release/SwitchingForm.cpp.o
index 8e3123b..8bfe3b3 100644
--- a/Project/Release/SwitchingForm.cpp.o
+++ b/Project/Release/SwitchingForm.cpp.o
Binary files differ
diff --git a/Project/Release/SyncGenerator.cpp.o b/Project/Release/SyncGenerator.cpp.o
index 5d23073..01d1a97 100644
--- a/Project/Release/SyncGenerator.cpp.o
+++ b/Project/Release/SyncGenerator.cpp.o
Binary files differ
diff --git a/Project/Release/SyncMachineForm.cpp.o b/Project/Release/SyncMachineForm.cpp.o
index bddf083..00941a6 100644
--- a/Project/Release/SyncMachineForm.cpp.o
+++ b/Project/Release/SyncMachineForm.cpp.o
Binary files differ
diff --git a/Project/Release/SyncMotor.cpp.o b/Project/Release/SyncMotor.cpp.o
index 5adf1ba..91822cf 100644
--- a/Project/Release/SyncMotor.cpp.o
+++ b/Project/Release/SyncMotor.cpp.o
Binary files differ
diff --git a/Project/Release/Text.cpp.o b/Project/Release/Text.cpp.o
index d690ed4..c2bfb7d 100644
--- a/Project/Release/Text.cpp.o
+++ b/Project/Release/Text.cpp.o
Binary files differ
diff --git a/Project/Release/TextForm.cpp.o b/Project/Release/TextForm.cpp.o
index 0ae59b4..5343efd 100644
--- a/Project/Release/TextForm.cpp.o
+++ b/Project/Release/TextForm.cpp.o
Binary files differ
diff --git a/Project/Release/Transformer.cpp.o b/Project/Release/Transformer.cpp.o
index 41c0cea..3996ec8 100644
--- a/Project/Release/Transformer.cpp.o
+++ b/Project/Release/Transformer.cpp.o
Binary files differ
diff --git a/Project/Release/TransformerForm.cpp.o b/Project/Release/TransformerForm.cpp.o
index f7be3ea..bc30990 100644
--- a/Project/Release/TransformerForm.cpp.o
+++ b/Project/Release/TransformerForm.cpp.o
Binary files differ
diff --git a/Project/Release/Workspace.cpp.o b/Project/Release/Workspace.cpp.o
index 2c08502..16e19dd 100644
--- a/Project/Release/Workspace.cpp.o
+++ b/Project/Release/Workspace.cpp.o
Binary files differ
diff --git a/Project/Release/Workspace.cpp.o.d b/Project/Release/Workspace.cpp.o.d
index f67b8e6..71f7c3e 100644
--- a/Project/Release/Workspace.cpp.o.d
+++ b/Project/Release/Workspace.cpp.o.d
@@ -144,7 +144,10 @@ Release/Workspace.cpp.o: Workspace.cpp Workspace.h \
C:/wxWidgets-3.1.0/include/wx/msw/ole/dataform.h \
C:/wxWidgets-3.1.0/include/wx/msw/ole/dataobj.h \
C:/wxWidgets-3.1.0/include/wx/msw/ole/dataobj2.h \
- C:/wxWidgets-3.1.0/include/wx/msw/clipbrd.h WorkspaceBase.h \
+ C:/wxWidgets-3.1.0/include/wx/msw/clipbrd.h \
+ C:/wxWidgets-3.1.0/include/wx/tipwin.h \
+ C:/wxWidgets-3.1.0/include/wx/popupwin.h \
+ C:/wxWidgets-3.1.0/include/wx/msw/popupwin.h WorkspaceBase.h \
C:/wxWidgets-3.1.0/include/wx/xrc/xmlres.h \
C:/wxWidgets-3.1.0/include/wx/filesys.h \
C:/wxWidgets-3.1.0/include/wx/filename.h \
@@ -167,6 +170,9 @@ Release/Workspace.cpp.o: Workspace.cpp Workspace.h \
C:/wxWidgets-3.1.0/include/wx/generic/logg.h \
C:/wxWidgets-3.1.0/include/wx/msw/app.h \
C:/wxWidgets-3.1.0/include/wx/msw/glcanvas.h \
+ C:/wxWidgets-3.1.0/include/wx/timer.h \
+ C:/wxWidgets-3.1.0/include/wx/stopwatch.h \
+ C:/wxWidgets-3.1.0/include/wx/time.h \
C:/wxWidgets-3.1.0/include/wx/persist.h \
C:/wxWidgets-3.1.0/include/wx/confbase.h \
C:/wxWidgets-3.1.0/include/wx/base64.h \
@@ -213,7 +219,6 @@ Release/Workspace.cpp.o: Workspace.cpp Workspace.h \
C:/wxWidgets-3.1.0/include/wx/scrolwin.h \
C:/wxWidgets-3.1.0/include/wx/generic/scrolwin.h \
C:/wxWidgets-3.1.0/include/wx/recguard.h \
- C:/wxWidgets-3.1.0/include/wx/time.h \
C:/wxWidgets-3.1.0/include/wx/propgrid/property.h \
C:/wxWidgets-3.1.0/include/wx/propgrid/propgriddefs.h \
C:/wxWidgets-3.1.0/include/wx/hashset.h \
@@ -248,8 +253,6 @@ Release/Workspace.cpp.o: Workspace.cpp Workspace.h \
LoadForm.h Shunt.h Inductor.h Capacitor.h ElementDataObject.h Text.h \
wxGLString.h C:/wxWidgets-3.1.0/include/wx/wx.h \
C:/wxWidgets-3.1.0/include/wx/hash.h \
- C:/wxWidgets-3.1.0/include/wx/stopwatch.h \
- C:/wxWidgets-3.1.0/include/wx/timer.h \
C:/wxWidgets-3.1.0/include/wx/module.h \
C:/wxWidgets-3.1.0/include/wx/wxcrtvararg.h \
C:/wxWidgets-3.1.0/include/wx/frame.h \
@@ -584,6 +587,12 @@ C:/wxWidgets-3.1.0/include/wx/msw/ole/dataobj2.h:
C:/wxWidgets-3.1.0/include/wx/msw/clipbrd.h:
+C:/wxWidgets-3.1.0/include/wx/tipwin.h:
+
+C:/wxWidgets-3.1.0/include/wx/popupwin.h:
+
+C:/wxWidgets-3.1.0/include/wx/msw/popupwin.h:
+
WorkspaceBase.h:
C:/wxWidgets-3.1.0/include/wx/xrc/xmlres.h:
@@ -630,6 +639,12 @@ C:/wxWidgets-3.1.0/include/wx/msw/app.h:
C:/wxWidgets-3.1.0/include/wx/msw/glcanvas.h:
+C:/wxWidgets-3.1.0/include/wx/timer.h:
+
+C:/wxWidgets-3.1.0/include/wx/stopwatch.h:
+
+C:/wxWidgets-3.1.0/include/wx/time.h:
+
C:/wxWidgets-3.1.0/include/wx/persist.h:
C:/wxWidgets-3.1.0/include/wx/confbase.h:
@@ -728,8 +743,6 @@ C:/wxWidgets-3.1.0/include/wx/generic/scrolwin.h:
C:/wxWidgets-3.1.0/include/wx/recguard.h:
-C:/wxWidgets-3.1.0/include/wx/time.h:
-
C:/wxWidgets-3.1.0/include/wx/propgrid/property.h:
C:/wxWidgets-3.1.0/include/wx/propgrid/propgriddefs.h:
@@ -828,10 +841,6 @@ C:/wxWidgets-3.1.0/include/wx/wx.h:
C:/wxWidgets-3.1.0/include/wx/hash.h:
-C:/wxWidgets-3.1.0/include/wx/stopwatch.h:
-
-C:/wxWidgets-3.1.0/include/wx/timer.h:
-
C:/wxWidgets-3.1.0/include/wx/module.h:
C:/wxWidgets-3.1.0/include/wx/wxcrtvararg.h:
diff --git a/Project/Release/WorkspaceBase.cpp.o b/Project/Release/WorkspaceBase.cpp.o
index 8829c58..35849ec 100644
--- a/Project/Release/WorkspaceBase.cpp.o
+++ b/Project/Release/WorkspaceBase.cpp.o
Binary files differ
diff --git a/Project/Release/WorkspaceBase.cpp.o.d b/Project/Release/WorkspaceBase.cpp.o.d
index 6e24e93..8d6c0d0 100644
--- a/Project/Release/WorkspaceBase.cpp.o.d
+++ b/Project/Release/WorkspaceBase.cpp.o.d
@@ -132,6 +132,9 @@ Release/WorkspaceBase.cpp.o: WorkspaceBase.cpp WorkspaceBase.h \
C:/wxWidgets-3.1.0/include/wx/generic/logg.h \
C:/wxWidgets-3.1.0/include/wx/msw/app.h \
C:/wxWidgets-3.1.0/include/wx/msw/glcanvas.h \
+ C:/wxWidgets-3.1.0/include/wx/timer.h \
+ C:/wxWidgets-3.1.0/include/wx/stopwatch.h \
+ C:/wxWidgets-3.1.0/include/wx/time.h \
C:/wxWidgets-3.1.0/include/wx/persist.h \
C:/wxWidgets-3.1.0/include/wx/confbase.h \
C:/wxWidgets-3.1.0/include/wx/base64.h \
@@ -435,6 +438,12 @@ C:/wxWidgets-3.1.0/include/wx/msw/app.h:
C:/wxWidgets-3.1.0/include/wx/msw/glcanvas.h:
+C:/wxWidgets-3.1.0/include/wx/timer.h:
+
+C:/wxWidgets-3.1.0/include/wx/stopwatch.h:
+
+C:/wxWidgets-3.1.0/include/wx/time.h:
+
C:/wxWidgets-3.1.0/include/wx/persist.h:
C:/wxWidgets-3.1.0/include/wx/confbase.h:
diff --git a/Project/Shunt.h b/Project/Shunt.h
index cf1681d..f68df4b 100644
--- a/Project/Shunt.h
+++ b/Project/Shunt.h
@@ -2,6 +2,7 @@
#define SHUNT_H
#include "Element.h"
+#include "Bus.h"
class Shunt : public Element
{
diff --git a/Project/SyncGenerator.cpp b/Project/SyncGenerator.cpp
index c20bff1..655f447 100644
--- a/Project/SyncGenerator.cpp
+++ b/Project/SyncGenerator.cpp
@@ -142,3 +142,45 @@ Element* SyncGenerator::GetCopy()
*copy = *this;
return copy;
}
+
+wxString SyncGenerator::GetTipText() const
+{
+ wxString tipText = m_electricalData.name;
+ tipText += "\n";
+ tipText += _("\nP = ") + wxString::FromDouble(m_electricalData.activePower, 5);
+ switch(m_electricalData.activePowerUnit) {
+ case UNIT_PU: {
+ tipText += _(" p.u.");
+ } break;
+ case UNIT_W: {
+ tipText += _(" W");
+ } break;
+ case UNIT_kW: {
+ tipText += _(" kW");
+ } break;
+ case UNIT_MW: {
+ tipText += _(" MW");
+ } break;
+ default:
+ break;
+ }
+ tipText += _("\nQ = ") + wxString::FromDouble(m_electricalData.reactivePower, 5);
+ switch(m_electricalData.reactivePowerUnit) {
+ case UNIT_PU: {
+ tipText += _(" p.u.");
+ } break;
+ case UNIT_VAr: {
+ tipText += _(" VAr");
+ } break;
+ case UNIT_kVAr: {
+ tipText += _(" kVAr");
+ } break;
+ case UNIT_MVAr: {
+ tipText += _(" MVAr");
+ } break;
+ default:
+ break;
+ }
+
+ return tipText;
+}
diff --git a/Project/SyncGenerator.h b/Project/SyncGenerator.h
index 3fe5a3b..a672a4f 100644
--- a/Project/SyncGenerator.h
+++ b/Project/SyncGenerator.h
@@ -73,6 +73,7 @@ public:
virtual void DrawSymbol() const;
virtual bool GetContextMenu(wxMenu& menu);
virtual bool ShowForm(wxWindow* parent, Element* element);
+ virtual wxString GetTipText() const;
virtual SyncGeneratorElectricalData GetElectricalData() { return m_electricalData; }
virtual SyncGeneratorElectricalData GetPUElectricalData(double systemPowerBase);
virtual void SetElectricalData(SyncGeneratorElectricalData electricalData) { m_electricalData = electricalData; }
diff --git a/Project/SyncMotor.cpp b/Project/SyncMotor.cpp
index 13ea5e4..18252c1 100644
--- a/Project/SyncMotor.cpp
+++ b/Project/SyncMotor.cpp
@@ -1,8 +1,15 @@
#include "SyncMachineForm.h"
#include "SyncMotor.h"
-SyncMotor::SyncMotor() : Machines() {}
-SyncMotor::SyncMotor(wxString name) : Machines() { m_electricalData.name = name; }
+SyncMotor::SyncMotor()
+ : Machines()
+{
+}
+SyncMotor::SyncMotor(wxString name)
+ : Machines()
+{
+ m_electricalData.name = name;
+}
SyncMotor::~SyncMotor() {}
void SyncMotor::DrawSymbol() const { DrawArc(m_position, 12, 30, 330, 10, GL_LINE_STRIP); }
bool SyncMotor::GetContextMenu(wxMenu& menu)
@@ -28,9 +35,9 @@ bool SyncMotor::ShowForm(wxWindow* parent, Element* element)
SyncMotorElectricalData SyncMotor::GetPUElectricalData(double systemPowerBase)
{
- SyncMotorElectricalData data = m_electricalData;
-
- switch(data.activePowerUnit) {
+ SyncMotorElectricalData data = m_electricalData;
+
+ switch(data.activePowerUnit) {
case UNIT_W: {
data.activePower = data.activePower / systemPowerBase;
data.activePowerUnit = UNIT_PU;
@@ -62,7 +69,7 @@ SyncMotorElectricalData SyncMotor::GetPUElectricalData(double systemPowerBase)
default:
break;
}
- switch(data.maxReactiveUnit) {
+ switch(data.maxReactiveUnit) {
case UNIT_VAr: {
data.maxReactive = data.maxReactive / systemPowerBase;
data.maxReactiveUnit = UNIT_PU;
@@ -78,7 +85,7 @@ SyncMotorElectricalData SyncMotor::GetPUElectricalData(double systemPowerBase)
default:
break;
}
- switch(data.minReactiveUnit) {
+ switch(data.minReactiveUnit) {
case UNIT_VAr: {
data.minReactive = data.minReactive / systemPowerBase;
data.minReactiveUnit = UNIT_PU;
@@ -94,13 +101,55 @@ SyncMotorElectricalData SyncMotor::GetPUElectricalData(double systemPowerBase)
default:
break;
}
-
- return data;
+
+ return data;
}
Element* SyncMotor::GetCopy()
{
- SyncMotor* copy = new SyncMotor();
- *copy = *this;
- return copy;
+ SyncMotor* copy = new SyncMotor();
+ *copy = *this;
+ return copy;
+}
+
+wxString SyncMotor::GetTipText() const
+{
+ wxString tipText = m_electricalData.name;
+ tipText += "\n";
+ tipText += _("\nP = ") + wxString::FromDouble(m_electricalData.activePower, 5);
+ switch(m_electricalData.activePowerUnit) {
+ case UNIT_PU: {
+ tipText += _(" p.u.");
+ } break;
+ case UNIT_W: {
+ tipText += _(" W");
+ } break;
+ case UNIT_kW: {
+ tipText += _(" kW");
+ } break;
+ case UNIT_MW: {
+ tipText += _(" MW");
+ } break;
+ default:
+ break;
+ }
+ tipText += _("\nQ = ") + wxString::FromDouble(m_electricalData.reactivePower, 5);
+ switch(m_electricalData.reactivePowerUnit) {
+ case UNIT_PU: {
+ tipText += _(" p.u.");
+ } break;
+ case UNIT_VAr: {
+ tipText += _(" VAr");
+ } break;
+ case UNIT_kVAr: {
+ tipText += _(" kVAr");
+ } break;
+ case UNIT_MVAr: {
+ tipText += _(" MVAr");
+ } break;
+ default:
+ break;
+ }
+
+ return tipText;
}
diff --git a/Project/SyncMotor.h b/Project/SyncMotor.h
index a7eecd8..d6e9bf1 100644
--- a/Project/SyncMotor.h
+++ b/Project/SyncMotor.h
@@ -66,6 +66,7 @@ class SyncMotor : public Machines
virtual Element* GetCopy();
virtual void DrawSymbol() const;
virtual bool GetContextMenu(wxMenu& menu);
+ virtual wxString GetTipText() const;
virtual SyncMotorElectricalData GetElectricalData() { return m_electricalData; }
virtual SyncMotorElectricalData GetPUElectricalData(double systemPowerBase);
virtual void SetElectricalData(SyncMotorElectricalData electricalData) { m_electricalData = electricalData; }
diff --git a/Project/Transformer.cpp b/Project/Transformer.cpp
index 4dfa7f4..959686a 100644
--- a/Project/Transformer.cpp
+++ b/Project/Transformer.cpp
@@ -95,9 +95,11 @@ bool Transformer::Contains(wxPoint2DDouble position) const
void Transformer::Draw(wxPoint2DDouble translation, double scale) const
{
OpenGLColour elementColour;
- if(m_online) elementColour = m_onlineElementColour;
- else elementColour = m_offlineElementColour;
-
+ if(m_online)
+ elementColour = m_onlineElementColour;
+ else
+ elementColour = m_offlineElementColour;
+
if(m_inserted) {
// Draw selection (layer 1).
if(m_selected) {
@@ -389,7 +391,54 @@ void Transformer::SetPowerFlowDirection(PowerFlowDirection pfDirection)
Element* Transformer::GetCopy()
{
- Transformer* copy = new Transformer();
- *copy = *this;
- return copy;
+ Transformer* copy = new Transformer();
+ *copy = *this;
+ return copy;
+}
+
+wxString Transformer::GetTipText() const
+{
+ wxString tipText = m_electricalData.name;
+ wxString primVoltage = StringFromDouble(m_electricalData.primaryNominalVoltage);
+ switch(m_electricalData.primaryNominalVoltageUnit) {
+ case UNIT_V: {
+ primVoltage += _(" V");
+ } break;
+ case UNIT_kV: {
+ primVoltage += _(" kV");
+ } break;
+ default:
+ break;
+ }
+ wxString secVoltage = StringFromDouble(m_electricalData.secondaryNominalVoltage);
+ switch(m_electricalData.secondaryNominalVoltageUnit) {
+ case UNIT_V: {
+ secVoltage += _(" V");
+ } break;
+ case UNIT_kV: {
+ secVoltage += _(" kV");
+ } break;
+ default:
+ break;
+ }
+
+ tipText += "\n" + primVoltage + " / " + secVoltage;
+
+ if(m_online) {
+ tipText += "\n";
+ int busNumber[2];
+ busNumber[0] = ((Bus*)m_parentList[0])->GetEletricalData().number + 1;
+ busNumber[1] = ((Bus*)m_parentList[1])->GetEletricalData().number + 1;
+
+ tipText += _("\nP") + wxString::Format("(%d-%d) = ", busNumber[0], busNumber[1]) +
+ wxString::FromDouble(m_electricalData.powerFlow[0].real(), 5) + _(" p.u.");
+ tipText += _("\nQ") + wxString::Format("(%d-%d) = ", busNumber[0], busNumber[1]) +
+ wxString::FromDouble(m_electricalData.powerFlow[0].imag(), 5) + _(" p.u.");
+ tipText += _("\nP") + wxString::Format("(%d-%d) = ", busNumber[1], busNumber[0]) +
+ wxString::FromDouble(m_electricalData.powerFlow[1].real(), 5) + _(" p.u.");
+ tipText += _("\nQ") + wxString::Format("(%d-%d) = ", busNumber[1], busNumber[0]) +
+ wxString::FromDouble(m_electricalData.powerFlow[1].imag(), 5) + _(" p.u.");
+ }
+
+ return tipText;
}
diff --git a/Project/Transformer.h b/Project/Transformer.h
index 5020fbd..d557cda 100644
--- a/Project/Transformer.h
+++ b/Project/Transformer.h
@@ -68,6 +68,7 @@ class Transformer : public Branch
virtual void MoveNode(Element* parent, wxPoint2DDouble position);
virtual void StartMove(wxPoint2DDouble position);
virtual bool GetContextMenu(wxMenu& menu);
+ virtual wxString GetTipText() const;
virtual void RotateNode(Element* parent, bool clockwise);
virtual bool SetNodeParent(Element* parent);
virtual void SetPowerFlowDirection(PowerFlowDirection pfDirection);
diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp
index c045408..21f8669 100644
--- a/Project/Workspace.cpp
+++ b/Project/Workspace.cpp
@@ -62,6 +62,7 @@ Workspace::Workspace()
Workspace::Workspace(wxWindow* parent, wxString name, wxStatusBar* statusBar)
: WorkspaceBase(parent)
{
+ m_timer->Start();
m_name = name;
m_statusBar = statusBar;
m_glContext = new wxGLContext(m_glCanvas);
@@ -271,6 +272,7 @@ void Workspace::OnLeftDoubleClick(wxMouseEvent& event)
elementIsBus = true;
oldBus = *(Bus*)element;
}
+ m_timer->Stop();
element->ShowForm(this, element);
elementEdited = true;
redraw = true;
@@ -321,6 +323,7 @@ void Workspace::OnLeftDoubleClick(wxMouseEvent& event)
}
if(elementEdited) UpdateTextElements();
if(redraw) Redraw();
+ m_timer->Start();
}
void Workspace::OnRightClickDown(wxMouseEvent& event)
@@ -335,6 +338,7 @@ void Workspace::OnRightClickDown(wxMouseEvent& event)
element->ShowPickbox(false);
wxMenu menu;
if(element->GetContextMenu(menu)) {
+ m_timer->Stop();
menu.SetClientData(element);
menu.Connect(
wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(Workspace::OnPopupClick), NULL, this);
@@ -354,6 +358,7 @@ void Workspace::OnRightClickDown(wxMouseEvent& event)
}
}
}
+ m_timer->Start();
}
void Workspace::OnLeftClickUp(wxMouseEvent& event)
@@ -586,6 +591,7 @@ void Workspace::OnMouseMotion(wxMouseEvent& event)
if(redraw) Redraw();
m_camera->UpdateMousePosition(event.GetPosition());
UpdateStatusBar();
+ m_timer->Start(); // Restart the timer.
event.Skip();
}
@@ -1280,3 +1286,26 @@ void Workspace::UpdateElementsID()
id++;
}
}
+void Workspace::OnTimer(wxTimerEvent& event)
+{
+ if(m_tipWindow) {
+ m_tipWindow->Close();
+ m_tipWindow = NULL;
+ }
+ if(m_mode == MODE_EDIT) {
+ for(auto it = m_elementList.begin(), itEnd = m_elementList.end(); it != itEnd; ++it) {
+ Element* element = *it;
+ if(element->Contains(m_camera->GetMousePosition())) {
+ wxString tipText = element->GetTipText();
+ if(!tipText.IsEmpty()) {
+ m_tipWindow = new wxTipWindow(this, tipText, 10000, &m_tipWindow);
+ // Creates a very tiny bounding rect to remove the tip on any mouse movement.
+ m_tipWindow->SetBoundingRect(wxRect(wxGetMousePosition(), wxSize(1, 1)));
+ break;
+ }
+ }
+ }
+ }
+
+ m_timer->Stop();
+}
diff --git a/Project/Workspace.h b/Project/Workspace.h
index fe2a25f..e900604 100644
--- a/Project/Workspace.h
+++ b/Project/Workspace.h
@@ -7,6 +7,7 @@
#include <wx/msgdlg.h>
#include <wx/statusbr.h>
#include <wx/clipbrd.h>
+#include <wx/tipwin.h>
#include "WorkspaceBase.h"
#include "Bus.h"
@@ -101,6 +102,7 @@ public:
bool RunPowerFlow();
protected:
+ virtual void OnTimer(wxTimerEvent& event);
virtual void OnLeftDoubleClick(wxMouseEvent& event);
virtual void OnRightClickDown(wxMouseEvent& event);
virtual void OnLeftClickUp(wxMouseEvent& event);
@@ -119,6 +121,7 @@ protected:
wxGLContext* m_glContext;
wxStatusBar* m_statusBar;
Camera* m_camera;
+ wxTipWindow* m_tipWindow = NULL;
wxString m_name;
WorkspaceMode m_mode = MODE_EDIT;
@@ -129,8 +132,7 @@ protected:
std::vector<Text*> m_textList;
wxFileName m_savedPath;
-
-private:
+
wxRect2DDouble m_selectionRect;
wxPoint2DDouble m_startSelRect;
};
diff --git a/Project/Workspace.wxcp b/Project/Workspace.wxcp
index bae4b9f..f5e0149 100644
--- a/Project/Workspace.wxcp
+++ b/Project/Workspace.wxcp
@@ -1,7 +1,7 @@
{
"metadata": {
"m_generatedFilesDir": ".",
- "m_objCounter": 4,
+ "m_objCounter": 6,
"m_includeFiles": [],
"m_bitmapFunction": "wxC52C4InitBitmapResources",
"m_bitmapsFile": "WorkspaceBitmaps.cpp",
@@ -337,6 +337,40 @@
}],
"m_children": []
}]
+ }, {
+ "m_type": 4483,
+ "proportion": 0,
+ "border": 5,
+ "gbSpan": "1,1",
+ "gbPosition": "0,0",
+ "m_styles": [],
+ "m_sizerFlags": [],
+ "m_properties": [{
+ "type": "string",
+ "m_label": "Name:",
+ "m_value": "m_timer"
+ }, {
+ "type": "integer",
+ "m_label": "Interval",
+ "m_value": 1500
+ }, {
+ "type": "bool",
+ "m_label": "Start the timer",
+ "m_value": true
+ }, {
+ "type": "bool",
+ "m_label": "One Shot Timer",
+ "m_value": false
+ }],
+ "m_events": [{
+ "m_eventName": "wxEVT_TIMER",
+ "m_eventClass": "wxTimerEvent",
+ "m_eventHandler": "wxTimerEventHandler",
+ "m_functionNameAndSignature": "OnTimer(wxTimerEvent& event)",
+ "m_description": "Process a timer event",
+ "m_noBody": false
+ }],
+ "m_children": []
}]
}]
} \ No newline at end of file
diff --git a/Project/WorkspaceBase.cpp b/Project/WorkspaceBase.cpp
index f4973d6..8c98633 100644
--- a/Project/WorkspaceBase.cpp
+++ b/Project/WorkspaceBase.cpp
@@ -37,6 +37,9 @@ WorkspaceBase::WorkspaceBase(wxWindow* parent, wxWindowID id, const wxPoint& pos
boxSizer_lvl_1_1->Add(m_glCanvas, 1, wxEXPAND, WXC_FROM_DIP(5));
+ m_timer = new wxTimer;
+ m_timer->Start(1500, false);
+
SetName(wxT("WorkspaceBase"));
SetSize(500,300);
if (GetSizer()) {
@@ -53,6 +56,7 @@ WorkspaceBase::WorkspaceBase(wxWindow* parent, wxWindowID id, const wxPoint& pos
m_glCanvas->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(WorkspaceBase::OnScroll), NULL, this);
m_glCanvas->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(WorkspaceBase::OnRightClickDown), NULL, this);
m_glCanvas->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(WorkspaceBase::OnLeftDoubleClick), NULL, this);
+ m_timer->Connect(wxEVT_TIMER, wxTimerEventHandler(WorkspaceBase::OnTimer), NULL, this);
}
@@ -68,5 +72,9 @@ WorkspaceBase::~WorkspaceBase()
m_glCanvas->Disconnect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(WorkspaceBase::OnScroll), NULL, this);
m_glCanvas->Disconnect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(WorkspaceBase::OnRightClickDown), NULL, this);
m_glCanvas->Disconnect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(WorkspaceBase::OnLeftDoubleClick), NULL, this);
+ m_timer->Disconnect(wxEVT_TIMER, wxTimerEventHandler(WorkspaceBase::OnTimer), NULL, this);
+ m_timer->Stop();
+ wxDELETE( m_timer );
+
}
diff --git a/Project/WorkspaceBase.h b/Project/WorkspaceBase.h
index fb7d0b9..ef88d11 100644
--- a/Project/WorkspaceBase.h
+++ b/Project/WorkspaceBase.h
@@ -4,8 +4,8 @@
// Do not modify this file by hand!
//////////////////////////////////////////////////////////////////////
-#ifndef PSP_PROJECT_WORKSPACE_BASE_CLASSES_H
-#define PSP_PROJECT_WORKSPACE_BASE_CLASSES_H
+#ifndef _PSP_PROJECT_WORKSPACE_BASE_CLASSES_H
+#define _PSP_PROJECT_WORKSPACE_BASE_CLASSES_H
#include <wx/settings.h>
#include <wx/xrc/xmlres.h>
@@ -14,6 +14,7 @@
#include <wx/artprov.h>
#include <wx/sizer.h>
#include <wx/glcanvas.h>
+#include <wx/timer.h>
#if wxVERSION_NUMBER >= 2900
#include <wx/persist.h>
#include <wx/persist/toplevel.h>
@@ -35,6 +36,7 @@ class WorkspaceBase : public wxPanel
{
protected:
wxGLCanvas* m_glCanvas;
+ wxTimer* m_timer;
protected:
virtual void OnPaint(wxPaintEvent& event) { event.Skip(); }
@@ -47,9 +49,11 @@ protected:
virtual void OnScroll(wxMouseEvent& event) { event.Skip(); }
virtual void OnRightClickDown(wxMouseEvent& event) { event.Skip(); }
virtual void OnLeftDoubleClick(wxMouseEvent& event) { event.Skip(); }
+ virtual void OnTimer(wxTimerEvent& event) { event.Skip(); }
public:
wxGLCanvas* GetGlCanvas() { return m_glCanvas; }
+ wxTimer* GetTimer() { return m_timer; }
WorkspaceBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(500,300), long style = wxTAB_TRAVERSAL);
virtual ~WorkspaceBase();
};