diff options
46 files changed, 746 insertions, 108 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port index fa62293..cd28455 100644 --- a/.codelite/.tern-port +++ b/.codelite/.tern-port @@ -1 +1 @@ -62933
\ No newline at end of file +54825
\ No newline at end of file diff --git a/.codelite/.tern-project b/.codelite/.tern-project index d5969c6..09b6465 100644 --- a/.codelite/.tern-project +++ b/.codelite/.tern-project @@ -8,8 +8,6 @@ "node_resolve": { }, "node": { - }, - "complete_strings": { } } }
\ No newline at end of file diff --git a/.codelite/PSP.session b/.codelite/PSP.session index 82433ca..40a3820 100644 --- a/.codelite/PSP.session +++ b/.codelite/PSP.session @@ -5,85 +5,85 @@ <TabInfoArray Name="TabInfoArray"> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Workspace.cpp" Name="FileName"/> - <int Value="610" Name="FirstVisibleLine"/> - <int Value="646" Name="CurrentLine"/> + <int Value="217" Name="FirstVisibleLine"/> + <int Value="238" 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="0" Name="FirstVisibleLine"/> - <int Value="20" Name="CurrentLine"/> + <int Value="0" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Element.cpp" Name="FileName"/> - <int Value="187" Name="FirstVisibleLine"/> - <int Value="77" Name="CurrentLine"/> + <int Value="270" Name="FirstVisibleLine"/> + <int Value="292" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Element.h" Name="FileName"/> - <int Value="0" Name="FirstVisibleLine"/> - <int Value="24" Name="CurrentLine"/> + <int Value="27" Name="FirstVisibleLine"/> + <int Value="53" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Inductor.h" Name="FileName"/> - <int Value="0" Name="FirstVisibleLine"/> - <int Value="14" Name="CurrentLine"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Line.cpp" Name="FileName"/> + <int Value="185" Name="FirstVisibleLine"/> + <int Value="211" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Inductor.cpp" Name="FileName"/> - <int Value="58" Name="FirstVisibleLine"/> - <int Value="85" Name="CurrentLine"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Line.h" Name="FileName"/> + <int Value="0" Name="FirstVisibleLine"/> + <int Value="23" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Load.h" Name="FileName"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Branch.h" Name="FileName"/> <int Value="0" Name="FirstVisibleLine"/> - <int Value="11" Name="CurrentLine"/> + <int Value="30" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Load.cpp" Name="FileName"/> - <int Value="0" Name="FirstVisibleLine"/> - <int Value="6" Name="CurrentLine"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Branch.cpp" Name="FileName"/> + <int Value="71" Name="FirstVisibleLine"/> + <int Value="82" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Shunt.h" Name="FileName"/> - <int Value="0" Name="FirstVisibleLine"/> - <int Value="24" Name="CurrentLine"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Transformer.cpp" Name="FileName"/> + <int Value="172" Name="FirstVisibleLine"/> + <int Value="197" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Shunt.cpp" Name="FileName"/> - <int Value="101" Name="FirstVisibleLine"/> - <int Value="141" Name="CurrentLine"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Machines.cpp" Name="FileName"/> + <int Value="112" Name="FirstVisibleLine"/> + <int Value="131" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Capacitor.h" Name="FileName"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Shunt.h" Name="FileName"/> <int Value="0" Name="FirstVisibleLine"/> - <int Value="19" Name="CurrentLine"/> + <int Value="24" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Capacitor.cpp" Name="FileName"/> - <int Value="0" Name="FirstVisibleLine"/> - <int Value="11" Name="CurrentLine"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Shunt.cpp" Name="FileName"/> + <int Value="86" Name="FirstVisibleLine"/> + <int Value="113" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> diff --git a/.codelite/PSP.tags b/.codelite/PSP.tags Binary files differindex e220bc5..c76ed1f 100644 --- a/.codelite/PSP.tags +++ b/.codelite/PSP.tags diff --git a/.codelite/compilation.db b/.codelite/compilation.db Binary files differindex 1eece92..699d56c 100644 --- a/.codelite/compilation.db +++ b/.codelite/compilation.db diff --git a/.codelite/compile_commands.json b/.codelite/compile_commands.json index 747a12e..9d177f6 100644 --- a/.codelite/compile_commands.json +++ b/.codelite/compile_commands.json @@ -1,9 +1,9 @@ [{ "directory": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project", - "command": "C:/TDM-GCC-64/bin/g++.exe -O2 -Wall -mthreads -DHAVE_W32API_H -D__WXMSW__ -DNDEBUG -D_UNICODE -IC:/wxWidgets-3.1.0/lib/gcc_dll/mswu -IC:/wxWidgets-3.1.0/include -DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -fno-keep-inline-dllexport -std=c++11 -DNDEBUG -DUNICODE -I. -I. -MG -MP -MT./Release/Workspace.cpp.o -MF./Release/Workspace.cpp.o.d -MM Workspace.cpp", - "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Workspace.cpp" + "command": "C:/TDM-GCC-64/bin/g++.exe -O2 -Wall -mthreads -DHAVE_W32API_H -D__WXMSW__ -DNDEBUG -D_UNICODE -IC:/wxWidgets-3.1.0/lib/gcc_dll/mswu -IC:/wxWidgets-3.1.0/include -DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -fno-keep-inline-dllexport -std=c++11 -DNDEBUG -DUNICODE -I. -I. -MG -MP -MT./Release/Shunt.cpp.o -MF./Release/Shunt.cpp.o.d -MM Shunt.cpp", + "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Shunt.cpp" }, { "directory": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project", - "command": "C:/TDM-GCC-64/bin/g++.exe -c C:/Users/Thales/Documents/GitHub/PSP/Project/Workspace.cpp -O2 -Wall -mthreads -DHAVE_W32API_H -D__WXMSW__ -DNDEBUG -D_UNICODE -IC:/wxWidgets-3.1.0/lib/gcc_dll/mswu -IC:/wxWidgets-3.1.0/include -DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -fno-keep-inline-dllexport -std=c++11 -DNDEBUG -DUNICODE -o ./Release/Workspace.cpp.o -I. -I.", - "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Workspace.cpp" + "command": "C:/TDM-GCC-64/bin/g++.exe -c C:/Users/Thales/Documents/GitHub/PSP/Project/Shunt.cpp -O2 -Wall -mthreads -DHAVE_W32API_H -D__WXMSW__ -DNDEBUG -D_UNICODE -IC:/wxWidgets-3.1.0/lib/gcc_dll/mswu -IC:/wxWidgets-3.1.0/include -DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -fno-keep-inline-dllexport -std=c++11 -DNDEBUG -DUNICODE -o ./Release/Shunt.cpp.o -I. -I.", + "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Shunt.cpp" }]
\ No newline at end of file diff --git a/.codelite/refactoring.db b/.codelite/refactoring.db Binary files differindex 7fc2440..8b12a4e 100644 --- a/.codelite/refactoring.db +++ b/.codelite/refactoring.db diff --git a/Project/Branch.cpp b/Project/Branch.cpp index 14ca4ea..c14c1e1 100644 --- a/Project/Branch.cpp +++ b/Project/Branch.cpp @@ -1,16 +1,10 @@ #include "Branch.h" -Branch::Branch() : Element() -{ -} - -Branch::~Branch() -{ -} - +Branch::Branch() : Element() {} +Branch::~Branch() {} bool Branch::NodeContains(wxPoint2DDouble position) { - wxRect2DDouble nodeRect1(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, + wxRect2DDouble nodeRect1(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); wxRect2DDouble nodeRect2(m_pointList[m_pointList.size() - 1].m_x - 5.0 - m_borderSize, m_pointList[m_pointList.size() - 1].m_y - 5.0 - m_borderSize, 10 + 2.0 * m_borderSize, @@ -31,7 +25,7 @@ bool Branch::NodeContains(wxPoint2DDouble position) bool Branch::SetNodeParent(Element* parent) { - if(m_activeNodeID == 1 && parent == m_parentList[0]) return false; + if(m_activeNodeID == 1 && parent == m_parentList[0]) return false; if(m_activeNodeID == 2 && parent == m_parentList[1]) return false; if(parent && m_activeNodeID != 0) { @@ -96,9 +90,10 @@ bool Branch::SetNodeParent(Element* parent) void Branch::RemoveParent(Element* parent) { - for(int i = 0; i < 2; i++) { + for(int i = 0; i < 2; i++) { if(parent == m_parentList[i]) { m_parentList[i] = NULL; + m_online = false; UpdateSwitchesPosition(); } } @@ -106,12 +101,13 @@ void Branch::RemoveParent(Element* parent) void Branch::UpdateNodes() { - if(m_parentList[0]) { + if(m_parentList[0]) { wxRect2DDouble nodeRect(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); if(!m_parentList[0]->Intersects(nodeRect)) { m_parentList[0] = NULL; + m_online = false; UpdateSwitchesPosition(); } } @@ -122,6 +118,7 @@ void Branch::UpdateNodes() if(!m_parentList[1]->Intersects(nodeRect)) { m_parentList[1] = NULL; + m_online = false; UpdateSwitchesPosition(); } } @@ -129,7 +126,7 @@ void Branch::UpdateNodes() void Branch::RotateNode(Element* parent) { - if(parent == m_parentList[0]) { + if(parent == m_parentList[0]) { m_pointList[0] = parent->RotateAtPosition(m_pointList[0], m_rotationAngle); } else if(parent == m_parentList[1]) @@ -142,7 +139,7 @@ void Branch::RotateNode(Element* parent) void Branch::UpdateSwitchesPosition() { - if(m_parentList[0]) { + if(m_parentList[0]) { m_pointList[1] = GetSwitchPoint(m_parentList[0], m_pointList[0], m_pointList[2]); } else @@ -157,4 +154,21 @@ void Branch::UpdateSwitchesPosition() { m_pointList[m_pointList.size() - 2] = m_pointList[m_pointList.size() - 1]; } + UpdateSwitches(); +} + +void Branch::UpdateSwitches() +{ + 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); + + if(m_switchRect.size() > 1) { + swCenter = wxPoint2DDouble( + (m_pointList[m_pointList.size() - 1].m_x + m_pointList[m_pointList.size() - 2].m_x) / 2.0, + (m_pointList[m_pointList.size() - 1].m_y + m_pointList[m_pointList.size() - 2].m_y) / 2.0); + m_switchRect[1] = wxRect2DDouble(swCenter.m_x - m_switchSize / 2.0, swCenter.m_y - m_switchSize / 2.0, + m_switchSize, m_switchSize); + } } diff --git a/Project/Branch.h b/Project/Branch.h index 309419a..5032f1f 100644 --- a/Project/Branch.h +++ b/Project/Branch.h @@ -28,11 +28,10 @@ public: virtual void AddPoint(wxPoint2DDouble point) {}; virtual bool GetContextMenu(wxMenu& menu) { return false; } virtual void UpdateSwitchesPosition(); + virtual void UpdateSwitches(); protected: bool m_inserted = false; - std::vector<wxPoint2DDouble> m_pointList; - std::vector<wxPoint2DDouble> m_movePts; }; #endif // BRANCH_H diff --git a/Project/Capacitor.cpp b/Project/Capacitor.cpp index 698d6a4..26e0854 100644 --- a/Project/Capacitor.cpp +++ b/Project/Capacitor.cpp @@ -10,16 +10,108 @@ Capacitor::~Capacitor() bool Capacitor::AddParent(Element* parent, wxPoint2DDouble position) { + if(parent) { + m_parentList.push_back(parent); + 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. + + m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus. + m_width = 40; + m_height = 30; + m_rect = wxRect2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y - m_height / 2.0, m_width, m_height); + + m_pointList.push_back(parentPt); + m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position)); + m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -m_height / 2.0 - 10.0)); + m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -m_height / 2.0)); + + m_inserted = true; + + wxRect2DDouble genRect(0,0,0,0); + m_switchRect.push_back(genRect); // Push a general rectangle. + UpdateSwitches(); + + return true; + } + return false; } void Capacitor::Draw(wxPoint2DDouble translation, double scale) const { + if(m_inserted) { + std::vector<wxPoint2DDouble> capPts; + capPts.push_back(wxPoint2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y - m_height / 2.0)); + capPts.push_back(wxPoint2DDouble(m_position.m_x + m_width / 2.0, m_position.m_y - m_height / 2.0)); + capPts.push_back(wxPoint2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y - m_height / 2.0 + 10.0)); + capPts.push_back(wxPoint2DDouble(m_position.m_x + m_width / 2.0, m_position.m_y - m_height / 2.0 + 10.0)); + + if(m_selected) { + glLineWidth(1.5 + m_borderSize * 2.0); + glColor4d(0.0, 0.5, 1.0, 0.5); + + DrawLine(m_pointList); + + glPushMatrix(); + glTranslated(m_position.m_x, m_position.m_y, 0.0); + glRotated(m_angle, 0.0, 0.0, 1.0); + glTranslated(-m_position.m_x, -m_position.m_y, 0.0); + + DrawLine(capPts, GL_LINES); + + DrawGround(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 10.0)); + + glPopMatrix(); + + // Draw node selection. + DrawCircle(m_pointList[0], 5.0 + m_borderSize / scale, 10, GL_POLYGON); + } + // Draw Capacitor (layer 2). + glLineWidth(1.5); + glColor4d(0.2, 0.2, 0.2, 1.0); + DrawCircle(m_pointList[0], 5.0, 10, GL_POLYGON); + DrawLine(m_pointList); + + DrawSwitches(); + + glPushMatrix(); + glTranslated(m_position.m_x, m_position.m_y, 0.0); + glRotated(m_angle, 0.0, 0.0, 1.0); + glTranslated(-m_position.m_x, -m_position.m_y, 0.0); + + glColor4d(0.2, 0.2, 0.2, 1.0); + DrawLine(capPts, GL_LINES); + + DrawGround(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 10.0)); + + glPopMatrix(); + } } void Capacitor::Rotate() { + m_angle += m_rotationAngle; + m_pointList[2] = RotateAtPosition(m_pointList[2], m_rotationAngle); + m_pointList[3] = RotateAtPosition(m_pointList[3], m_rotationAngle); + UpdateSwitchesPosition(); } bool Capacitor::GetContextMenu(wxMenu& menu) { + menu.Append(ID_EDIT_CAPACITOR, _("Edit Capacitor")); + menu.Append(ID_ROTATE, _("Rotate")); + menu.Append(ID_DELETE, _("Delete")); + return true; +} + +bool Capacitor::Contains(wxPoint2DDouble position) const +{ + wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle); + return m_rect.Contains(ptR); +} + +bool Capacitor::Intersects(wxRect2DDouble rect) const +{ + return RotatedRectanglesIntersects(m_rect, rect, m_angle, 0.0); } diff --git a/Project/Capacitor.h b/Project/Capacitor.h index fe7c267..e407ba8 100644 --- a/Project/Capacitor.h +++ b/Project/Capacitor.h @@ -3,7 +3,7 @@ #include "Shunt.h" -class Capacitor : Shunt +class Capacitor : public Shunt { public: Capacitor(); @@ -11,6 +11,8 @@ public: 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(); virtual bool GetContextMenu(wxMenu& menu); diff --git a/Project/Element.cpp b/Project/Element.cpp index ff7d246..9f10ffc 100644 --- a/Project/Element.cpp +++ b/Project/Element.cpp @@ -20,11 +20,16 @@ void Element::DrawCircle(wxPoint2DDouble position, double radius, int numSegment glEnd(); } -void Element::DrawArc(wxPoint2DDouble position, double radius, double initAngle, double finalAngle, int numSegments, GLenum mode) const +void Element::DrawArc(wxPoint2DDouble position, + double radius, + double initAngle, + double finalAngle, + int numSegments, + GLenum mode) const { - double initAngRad = wxDegToRad(initAngle); - double finalAngRad = wxDegToRad(finalAngle); - glBegin(mode); + double initAngRad = wxDegToRad(initAngle); + double finalAngRad = wxDegToRad(finalAngle); + glBegin(mode); for(int i = 0; i <= numSegments; i++) { double theta = initAngRad + (finalAngRad - initAngRad) * double(i) / double(numSegments); glVertex2f(radius * std::cos(theta) + position.m_x, radius * std::sin(theta) + position.m_y); @@ -34,11 +39,11 @@ void Element::DrawArc(wxPoint2DDouble position, double radius, double initAngle, void Element::DrawTriangle(std::vector<wxPoint2DDouble> points, GLenum mode) const { - glBegin(mode); - for(int i=0; i<3; i++) { - glVertex2d(points[i].m_x, points[i].m_y); + glBegin(mode); + for(int i = 0; i < 3; i++) { + glVertex2d(points[i].m_x, points[i].m_y); } - glEnd(); + glEnd(); } void Element::DrawRectangle(wxPoint2DDouble position, double width, double height, GLenum mode) const @@ -228,3 +233,62 @@ 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) { + glColor4d(0.0, 0.4, 0.0, 1.0); // green + } + else + { + glColor4d(1.0, 0.1, 0.1, 1.0); // red + } + + 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. + for(auto it = m_parentList.begin(); it != m_parentList.end(); it++) { + if(!(*it)) return; + } + m_online = online; +} diff --git a/Project/Element.h b/Project/Element.h index 1a6b73e..6c07ec9 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -21,18 +21,19 @@ enum ContextMenuID { ID_EDIT_BUS = 0, ID_EDIT_LINE, - ID_EDIT_TRANSFORMER, - ID_EDIT_SYNCGENERATOR, - ID_EDIT_INDMOTOR, - ID_EDIT_SYNCMOTOR, - ID_EDIT_LOAD, - ID_EDIT_INDUCTOR, + ID_EDIT_TRANSFORMER, + ID_EDIT_SYNCGENERATOR, + ID_EDIT_INDMOTOR, + ID_EDIT_SYNCMOTOR, + ID_EDIT_LOAD, + ID_EDIT_INDUCTOR, + ID_EDIT_CAPACITOR, ID_LINE_ADD_NODE, ID_LINE_REMOVE_NODE, ID_ROTATE, - ID_DELETE + ID_DELETE }; class Element @@ -50,6 +51,7 @@ class Element void SetAngle(double angle) { this->m_angle = angle; } void ShowPickbox(bool showPickbox = true) { this->m_showPickbox = showPickbox; } void SetBorderSize(double borderSize) { this->m_borderSize = borderSize; } + void SetOnline(bool online = true); // Getters wxRect2DDouble GetRect() const { return m_rect; } wxPoint2DDouble GetPosition() const { return m_position; } @@ -59,6 +61,7 @@ class Element double GetWidth() const { return m_width; } double GetAngle() const { return m_angle; } bool IsPickboxShown() const { return m_showPickbox; } + bool IsOnline() const { return m_online; } // Pure-virtuals methods virtual bool AddParent(Element* parent, wxPoint2DDouble position) = 0; virtual void Draw(wxPoint2DDouble translation, double scale) const = 0; @@ -66,25 +69,29 @@ class Element virtual bool Intersects(wxRect2DDouble rect) const = 0; // General methods - virtual void Rotate() {} + virtual void Rotate() {} virtual bool GetContextMenu(wxMenu& menu) { return false; } virtual void AddPoint(wxPoint2DDouble point) {} virtual void StartMove(wxPoint2DDouble position); virtual void Move(wxPoint2DDouble position); - virtual void MoveNode(Element* parent, wxPoint2DDouble position){} + virtual void MoveNode(Element* parent, wxPoint2DDouble position) {} virtual bool NodeContains(wxPoint2DDouble position) { return false; } - virtual void UpdateNodes() {} - virtual bool SetNodeParent(Element* parent) { return false; } - virtual void RemoveParent(Element* parent) {} + virtual void UpdateNodes() {} + virtual bool SetNodeParent(Element* parent) { return false; } + virtual void RemoveParent(Element* parent) {} virtual void RotateNode(Element* parent) {} virtual wxPoint2DDouble GetSwitchPoint(Element* parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const; - virtual bool PickboxContains(wxPoint2DDouble position) { return false;} + virtual bool SwitchesContains(wxPoint2DDouble position) const; + virtual void UpdateSwitches(); + virtual void DrawSwitches() const; + + virtual bool PickboxContains(wxPoint2DDouble position) { return false; } virtual void MovePickbox(wxPoint2DDouble position) {} - virtual wxCursor GetBestPickboxCursor() const {return wxCURSOR_ARROW;} + virtual wxCursor GetBestPickboxCursor() const { return wxCURSOR_ARROW; } virtual void ResetPickboxes() { m_activePickboxID = ID_PB_NONE; } - virtual void ResetNodes() { m_activeNodeID= 0; } + virtual void ResetNodes() { m_activeNodeID = 0; } virtual wxPoint2DDouble WorldToScreen(wxPoint2DDouble translation, double scale, double offsetX = 0.0, @@ -94,13 +101,22 @@ class Element double scale, double offsetX = 0.0, double offsetY = 0.0) const; - virtual bool RotatedRectanglesIntersects(wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const; + virtual bool RotatedRectanglesIntersects(wxRect2DDouble rect1, + wxRect2DDouble rect2, + double angle1, + double angle2) const; + virtual void DrawCircle(wxPoint2DDouble position, double radius, int numSegments, GLenum mode = GL_LINE_LOOP) const; - virtual void DrawArc(wxPoint2DDouble position, double radius, double initAngle, double finalAngle, int numSegments, GLenum mode = GL_LINE_LOOP) const; + virtual void DrawArc(wxPoint2DDouble position, + double radius, + double initAngle, + double finalAngle, + int numSegments, + GLenum mode = GL_LINE_LOOP) const; virtual void DrawRectangle(wxPoint2DDouble position, double width, double height, GLenum mode = GL_QUADS) const; virtual void DrawRectangle(wxPoint2DDouble* points, GLenum mode = GL_QUADS) const; - virtual void DrawTriangle(std::vector<wxPoint2DDouble> points, GLenum mode = GL_TRIANGLES) const; - virtual void DrawPoint(wxPoint2DDouble position, double size) const; + virtual void DrawTriangle(std::vector<wxPoint2DDouble> points, GLenum mode = GL_TRIANGLES) const; + virtual void DrawPoint(wxPoint2DDouble position, double size) const; virtual void DrawLine(std::vector<wxPoint2DDouble> points, GLenum mode = GL_LINE_STRIP) const; virtual void DrawPickbox(wxPoint2DDouble position) const; virtual wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees = true) const; @@ -118,6 +134,9 @@ class Element double m_angle = 0.0; double m_borderSize = 2.0; double m_rotationAngle = 45.0; + double m_switchSize = 10.0; + + std::vector<wxRect2DDouble> m_switchRect; bool m_selected = false; bool m_dragging = false; @@ -126,8 +145,13 @@ class Element int m_activePickboxID = ID_PB_NONE; int m_activeNodeID = 0; + std::vector<wxPoint2DDouble> m_pointList; + std::vector<wxPoint2DDouble> m_movePts; + wxPoint2DDouble m_moveStartPt; wxPoint2DDouble m_movePos; + + bool m_online = true; }; #endif // ELEMENT_H diff --git a/Project/Inductor.cpp b/Project/Inductor.cpp index 0ed8ba5..08511e4 100644 --- a/Project/Inductor.cpp +++ b/Project/Inductor.cpp @@ -22,6 +22,11 @@ bool Inductor::AddParent(Element* parent, wxPoint2DDouble position) m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -m_height / 2.0)); m_inserted = true; + + wxRect2DDouble genRect(0,0,0,0); + m_switchRect.push_back(genRect); // Push a general rectangle. + UpdateSwitches(); + return true; } return false; @@ -57,12 +62,15 @@ void Inductor::Draw(wxPoint2DDouble translation, double scale) const glColor4d(0.2, 0.2, 0.2, 1.0); DrawCircle(m_pointList[0], 5.0, 10, GL_POLYGON); DrawLine(m_pointList); + + DrawSwitches(); glPushMatrix(); glTranslated(m_position.m_x, m_position.m_y, 0.0); glRotated(m_angle, 0.0, 0.0, 1.0); glTranslated(-m_position.m_x, -m_position.m_y, 0.0); - + + glColor4d(0.2, 0.2, 0.2, 1.0); DrawArc(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 10.0), 10, 45, 270, 10, GL_LINE_STRIP); DrawArc(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 25.0), 10, 45, 315, 10, GL_LINE_STRIP); DrawArc(m_position + wxPoint2DDouble(0, -m_height / 2.0 + 40.0), 10, 90, 315, 10, GL_LINE_STRIP); diff --git a/Project/Line.cpp b/Project/Line.cpp index 5fd6c86..0ee9cc8 100644 --- a/Project/Line.cpp +++ b/Project/Line.cpp @@ -41,6 +41,8 @@ void Line::Draw(wxPoint2DDouble translation, double scale) const glLineWidth(1.5); glColor4d(0.2, 0.2, 0.2, 1.0); DrawLine(pointList); + + DrawSwitches(); // Draw nodes. if(pointList.size() > 0) { @@ -95,6 +97,11 @@ bool Line::AddParent(Element* parent, wxPoint2DDouble position) parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. m_pointList.push_back(parentPt); // First point m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position)); + + wxRect2DDouble genRect(0,0,0,0); + m_switchRect.push_back(genRect); + UpdateSwitches(); + return false; } // Second bus. @@ -117,6 +124,11 @@ bool Line::AddParent(Element* parent, wxPoint2DDouble position) m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_pointList[m_pointList.size() - 1])); m_pointList.push_back(parentPt); // Last point. + + wxRect2DDouble genRect(0,0,0,0); + m_switchRect.push_back(genRect); + UpdateSwitches(); + m_inserted = true; return true; } @@ -191,11 +203,13 @@ void Line::MoveNode(Element* parent, wxPoint2DDouble position) if(m_activeNodeID == 1) { m_pointList[0] = m_movePts[0] + position - m_moveStartPt; m_parentList[0] = NULL; + m_online = false; } else if(m_activeNodeID == 2) { m_pointList[m_pointList.size() - 1] = m_movePts[m_pointList.size() - 1] + position - m_moveStartPt; m_parentList[1] = NULL; + m_online = false; } } @@ -209,7 +223,7 @@ double Line::PointToLineDistance(wxPoint2DDouble point, int* segmentNumber) cons double distance = 100.0; // Big initial distance. wxPoint2DDouble p0 = point; - for(int i = 0; i < (int)m_pointList.size() - 1; i++) { + for(int i = 1; i < (int)m_pointList.size() - 2; i++) { double d = 0.0; wxPoint2DDouble p1 = m_pointList[i]; diff --git a/Project/Load.cpp b/Project/Load.cpp index a932c64..b5c5948 100644 --- a/Project/Load.cpp +++ b/Project/Load.cpp @@ -25,6 +25,11 @@ bool Load::AddParent(Element* parent, wxPoint2DDouble position) m_triangPts.push_back(wxPoint2DDouble(0.0, m_height / 2.0)); m_inserted = true; + + wxRect2DDouble genRect(0,0,0,0); + m_switchRect.push_back(genRect); // Push a general rectangle. + UpdateSwitches(); + return true; } return false; @@ -65,7 +70,9 @@ void Load::Draw(wxPoint2DDouble translation, double scale) const DrawCircle(m_pointList[0], 5.0, 10, GL_POLYGON); DrawLine(m_pointList); - + + DrawSwitches(); + std::vector<wxPoint2DDouble> triangPts; for(int i = 0; i < 3; i++) { triangPts.push_back(m_triangPts[i] + m_position); @@ -74,6 +81,7 @@ void Load::Draw(wxPoint2DDouble translation, double scale) const glTranslated(m_position.m_x, m_position.m_y, 0.0); glRotated(m_angle, 0.0, 0.0, 1.0); glTranslated(-m_position.m_x, -m_position.m_y, 0.0); + glColor4d(0.2, 0.2, 0.2, 1.0); DrawTriangle(triangPts); glPopMatrix(); } diff --git a/Project/Machines.cpp b/Project/Machines.cpp index bde4af8..29574e6 100644 --- a/Project/Machines.cpp +++ b/Project/Machines.cpp @@ -1,13 +1,7 @@ #include "Machines.h" -Machines::Machines() : Element() -{ -} - -Machines::~Machines() -{ -} - +Machines::Machines() : Element() {} +Machines::~Machines() {} bool Machines::AddParent(Element* parent, wxPoint2DDouble position) { if(parent) { @@ -26,6 +20,10 @@ bool Machines::AddParent(Element* parent, wxPoint2DDouble position) m_pointList.push_back(m_position + wxPoint2DDouble(35.0, 0.0)); m_pointList.push_back(m_position + wxPoint2DDouble(25.0, 0.0)); m_inserted = true; + + wxRect2DDouble genRect(0,0,0,0); + m_switchRect.push_back(genRect); // Push a general rectangle. + UpdateSwitches(); return true; } return false; @@ -34,6 +32,7 @@ bool Machines::AddParent(Element* parent, wxPoint2DDouble position) void Machines::Draw(wxPoint2DDouble translation, double scale) const { if(m_inserted) { + // Draw Selection (layer 1). if(m_selected) { glLineWidth(1.5 + m_borderSize * 2.0); @@ -53,6 +52,8 @@ void Machines::Draw(wxPoint2DDouble translation, double scale) const DrawCircle(m_pointList[0], 5.0, 10, GL_POLYGON); DrawLine(m_pointList); + + DrawSwitches(); glColor4d(1.0, 1.0, 1.0, 1.0); DrawCircle(m_position, 25.0, 20, GL_POLYGON); @@ -61,7 +62,7 @@ void Machines::Draw(wxPoint2DDouble translation, double scale) const DrawCircle(m_position, 25.0, 20); // Draw machine symbol. - glLineWidth(2.0); + glLineWidth(2.0); DrawSymbol(); } } @@ -75,6 +76,7 @@ void Machines::UpdateSwitchesPosition() { m_pointList[1] = m_pointList[0]; } + UpdateSwitches(); } void Machines::Move(wxPoint2DDouble position) @@ -83,8 +85,8 @@ void Machines::Move(wxPoint2DDouble position) for(int i = 2; i < (int)m_pointList.size(); i++) { m_pointList[i] = m_movePts[i] + position - m_moveStartPt; } - if(!m_parentList[0]) { - m_pointList[0] = m_movePts[0] + position - m_moveStartPt; + if(!m_parentList[0]) { + m_pointList[0] = m_movePts[0] + position - m_moveStartPt; } UpdateSwitchesPosition(); } @@ -101,6 +103,7 @@ void Machines::MoveNode(Element* element, wxPoint2DDouble position) if(m_activeNodeID == 1) { m_pointList[0] = m_movePts[0] + position - m_moveStartPt; m_parentList[0] = NULL; + m_online = false; } } @@ -167,6 +170,7 @@ bool Machines::SetNodeParent(Element* parent) else { m_parentList[0] = NULL; + m_online = false; } } return false; @@ -180,6 +184,7 @@ void Machines::UpdateNodes() if(!m_parentList[0]->Intersects(nodeRect)) { m_parentList[0] = NULL; + m_online = false; UpdateSwitchesPosition(); } } diff --git a/Project/Machines.h b/Project/Machines.h index e7758af..737e407 100644 --- a/Project/Machines.h +++ b/Project/Machines.h @@ -27,8 +27,6 @@ public: protected: void UpdateSwitchesPosition(); bool m_inserted = false; - std::vector<wxPoint2DDouble> m_pointList; - std::vector<wxPoint2DDouble> m_movePts; }; diff --git a/Project/Project.mk b/Project/Project.mk index 958115b..06384e9 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,8 +13,8 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=04/09/2016 -CodeLitePath :="C:/Program Files (x86)/CodeLite" +Date :=05/09/2016 +CodeLitePath :="C:/Program Files/CodeLite" LinkerName :=C:/TDM-GCC-64/bin/g++.exe SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC ObjectSuffix :=.o @@ -61,13 +61,12 @@ AS := C:/TDM-GCC-64/bin/as.exe ## ## User defined environment variables ## -CodeLiteDir:=C:\Program Files (x86)\CodeLite -UNIT_TEST_PP_SRC_DIR:=C:\UnitTest++-1.3 +CodeLiteDir:=C:\Program Files\CodeLite WXWIN:=C:\wxWidgets-3.1.0 WXCFG:=gcc_dll\mswu Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IntermediateDirectory)/win_resources.rc$(ObjectSuffix) $(IntermediateDirectory)/Element.cpp$(ObjectSuffix) $(IntermediateDirectory)/ArtMetro.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrame.cpp$(ObjectSuffix) $(IntermediateDirectory)/Workspace.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrameBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/WorkspaceBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrameBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/WorkspaceBase.cpp$(ObjectSuffix) \ $(IntermediateDirectory)/Bus.cpp$(ObjectSuffix) $(IntermediateDirectory)/Line.cpp$(ObjectSuffix) $(IntermediateDirectory)/Transformer.cpp$(ObjectSuffix) $(IntermediateDirectory)/Machines.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncGenerator.cpp$(ObjectSuffix) $(IntermediateDirectory)/IndMotor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Branch.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncMotor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Shunt.cpp$(ObjectSuffix) $(IntermediateDirectory)/Load.cpp$(ObjectSuffix) \ - $(IntermediateDirectory)/Inductor.cpp$(ObjectSuffix) + $(IntermediateDirectory)/Inductor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Capacitor.cpp$(ObjectSuffix) @@ -260,6 +259,14 @@ $(IntermediateDirectory)/Inductor.cpp$(DependSuffix): Inductor.cpp $(IntermediateDirectory)/Inductor.cpp$(PreprocessSuffix): Inductor.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/Inductor.cpp$(PreprocessSuffix)Inductor.cpp +$(IntermediateDirectory)/Capacitor.cpp$(ObjectSuffix): Capacitor.cpp $(IntermediateDirectory)/Capacitor.cpp$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/Thales/Documents/GitHub/PSP/Project/Capacitor.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/Capacitor.cpp$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/Capacitor.cpp$(DependSuffix): Capacitor.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/Capacitor.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/Capacitor.cpp$(DependSuffix) -MM Capacitor.cpp + +$(IntermediateDirectory)/Capacitor.cpp$(PreprocessSuffix): Capacitor.cpp + $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/Capacitor.cpp$(PreprocessSuffix)Capacitor.cpp + -include $(IntermediateDirectory)/*$(DependSuffix) ## diff --git a/Project/Project.txt b/Project/Project.txt index 4e7ae1c..fb71673 100644 --- a/Project/Project.txt +++ b/Project/Project.txt @@ -1 +1 @@ -./Release/main.cpp.o ./Release/win_resources.rc.o ./Release/Element.cpp.o ./Release/ArtMetro.cpp.o ./Release/MainFrame.cpp.o ./Release/Workspace.cpp.o ./Release/MainFrameBitmaps.cpp.o ./Release/WorkspaceBitmaps.cpp.o ./Release/MainFrameBase.cpp.o ./Release/WorkspaceBase.cpp.o ./Release/Bus.cpp.o ./Release/Line.cpp.o ./Release/Transformer.cpp.o ./Release/Machines.cpp.o ./Release/SyncGenerator.cpp.o ./Release/IndMotor.cpp.o ./Release/Branch.cpp.o ./Release/SyncMotor.cpp.o ./Release/Shunt.cpp.o ./Release/Load.cpp.o ./Release/Inductor.cpp.o +./Release/main.cpp.o ./Release/win_resources.rc.o ./Release/Element.cpp.o ./Release/ArtMetro.cpp.o ./Release/MainFrame.cpp.o ./Release/Workspace.cpp.o ./Release/MainFrameBitmaps.cpp.o ./Release/WorkspaceBitmaps.cpp.o ./Release/MainFrameBase.cpp.o ./Release/WorkspaceBase.cpp.o ./Release/Bus.cpp.o ./Release/Line.cpp.o ./Release/Transformer.cpp.o ./Release/Machines.cpp.o ./Release/SyncGenerator.cpp.o ./Release/IndMotor.cpp.o ./Release/Branch.cpp.o ./Release/SyncMotor.cpp.o ./Release/Shunt.cpp.o ./Release/Load.cpp.o ./Release/Inductor.cpp.o ./Release/Capacitor.cpp.o diff --git a/Project/Release/Branch.cpp.o b/Project/Release/Branch.cpp.o Binary files differindex debc6f6..b1e5b5c 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 618edb2..cbfd2b5 100644 --- a/Project/Release/Bus.cpp.o +++ b/Project/Release/Bus.cpp.o diff --git a/Project/Release/Capacitor.cpp.o b/Project/Release/Capacitor.cpp.o Binary files differnew file mode 100644 index 0000000..8cd89cd --- /dev/null +++ b/Project/Release/Capacitor.cpp.o diff --git a/Project/Release/Capacitor.cpp.o.d b/Project/Release/Capacitor.cpp.o.d new file mode 100644 index 0000000..2680d76 --- /dev/null +++ b/Project/Release/Capacitor.cpp.o.d @@ -0,0 +1,339 @@ +Release/Capacitor.cpp.o: Capacitor.cpp Capacitor.h Shunt.h Element.h \ + C:/wxWidgets-3.1.0/include/wx/geometry.h \ + C:/wxWidgets-3.1.0/include/wx/defs.h \ + C:/wxWidgets-3.1.0/include/wx/platform.h \ + C:/wxWidgets-3.1.0/include/wx/compiler.h \ + C:/wxWidgets-3.1.0/lib/gcc_dll/mswu/wx/setup.h \ + C:/wxWidgets-3.1.0/include/wx/msw/libraries.h \ + C:/wxWidgets-3.1.0/include/wx/msw/gccpriv.h \ + C:/wxWidgets-3.1.0/include/wx/chkconf.h \ + C:/wxWidgets-3.1.0/include/wx/msw/chkconf.h \ + C:/wxWidgets-3.1.0/include/wx/version.h \ + C:/wxWidgets-3.1.0/include/wx/cpp.h \ + C:/wxWidgets-3.1.0/include/wx/dlimpexp.h \ + C:/wxWidgets-3.1.0/include/wx/debug.h \ + C:/wxWidgets-3.1.0/include/wx/chartype.h \ + C:/wxWidgets-3.1.0/include/wx/windowid.h \ + C:/wxWidgets-3.1.0/include/wx/msw/winundef.h \ + C:/wxWidgets-3.1.0/include/wx/features.h \ + C:/wxWidgets-3.1.0/include/wx/utils.h \ + C:/wxWidgets-3.1.0/include/wx/object.h \ + C:/wxWidgets-3.1.0/include/wx/memory.h \ + C:/wxWidgets-3.1.0/include/wx/string.h \ + C:/wxWidgets-3.1.0/include/wx/wxcrtbase.h \ + C:/wxWidgets-3.1.0/include/wx/strvararg.h \ + C:/wxWidgets-3.1.0/include/wx/strconv.h \ + C:/wxWidgets-3.1.0/include/wx/buffer.h \ + C:/wxWidgets-3.1.0/include/wx/fontenc.h \ + C:/wxWidgets-3.1.0/include/wx/unichar.h \ + C:/wxWidgets-3.1.0/include/wx/stringimpl.h \ + C:/wxWidgets-3.1.0/include/wx/beforestd.h \ + C:/wxWidgets-3.1.0/include/wx/afterstd.h \ + C:/wxWidgets-3.1.0/include/wx/stringops.h \ + C:/wxWidgets-3.1.0/include/wx/iosfwrap.h \ + C:/wxWidgets-3.1.0/include/wx/msgout.h \ + C:/wxWidgets-3.1.0/include/wx/xti.h C:/wxWidgets-3.1.0/include/wx/rtti.h \ + C:/wxWidgets-3.1.0/include/wx/flags.h \ + C:/wxWidgets-3.1.0/include/wx/xti2.h \ + C:/wxWidgets-3.1.0/include/wx/list.h \ + C:/wxWidgets-3.1.0/include/wx/vector.h \ + C:/wxWidgets-3.1.0/include/wx/scopeguard.h \ + C:/wxWidgets-3.1.0/include/wx/except.h \ + C:/wxWidgets-3.1.0/include/wx/meta/movable.h \ + C:/wxWidgets-3.1.0/include/wx/meta/pod.h \ + C:/wxWidgets-3.1.0/include/wx/meta/if.h \ + C:/wxWidgets-3.1.0/include/wx/filefn.h \ + C:/wxWidgets-3.1.0/include/wx/arrstr.h \ + C:/wxWidgets-3.1.0/include/wx/hashmap.h \ + C:/wxWidgets-3.1.0/include/wx/wxcrt.h \ + C:/wxWidgets-3.1.0/include/wx/versioninfo.h \ + C:/wxWidgets-3.1.0/include/wx/meta/implicitconversion.h \ + C:/wxWidgets-3.1.0/include/wx/gdicmn.h \ + C:/wxWidgets-3.1.0/include/wx/math.h \ + C:/wxWidgets-3.1.0/include/wx/mousestate.h \ + C:/wxWidgets-3.1.0/include/wx/kbdstate.h \ + C:/wxWidgets-3.1.0/include/wx/longlong.h \ + C:/wxWidgets-3.1.0/include/wx/platinfo.h \ + C:/wxWidgets-3.1.0/include/wx/cursor.h \ + C:/wxWidgets-3.1.0/include/wx/gdiobj.h \ + C:/wxWidgets-3.1.0/include/wx/msw/gdiimage.h \ + C:/wxWidgets-3.1.0/include/wx/msw/cursor.h \ + C:/wxWidgets-3.1.0/include/wx/menu.h \ + C:/wxWidgets-3.1.0/include/wx/window.h \ + C:/wxWidgets-3.1.0/include/wx/event.h \ + C:/wxWidgets-3.1.0/include/wx/clntdata.h \ + C:/wxWidgets-3.1.0/include/wx/dynarray.h \ + C:/wxWidgets-3.1.0/include/wx/thread.h \ + C:/wxWidgets-3.1.0/include/wx/tracker.h \ + C:/wxWidgets-3.1.0/include/wx/typeinfo.h \ + C:/wxWidgets-3.1.0/include/wx/any.h \ + C:/wxWidgets-3.1.0/include/wx/datetime.h \ + C:/wxWidgets-3.1.0/include/wx/anystr.h \ + C:/wxWidgets-3.1.0/include/wx/variant.h \ + C:/wxWidgets-3.1.0/include/wx/meta/convertible.h \ + C:/wxWidgets-3.1.0/include/wx/meta/removeref.h \ + C:/wxWidgets-3.1.0/include/wx/font.h \ + C:/wxWidgets-3.1.0/include/wx/msw/font.h \ + C:/wxWidgets-3.1.0/include/wx/colour.h \ + C:/wxWidgets-3.1.0/include/wx/msw/colour.h \ + C:/wxWidgets-3.1.0/include/wx/region.h \ + C:/wxWidgets-3.1.0/include/wx/msw/region.h \ + C:/wxWidgets-3.1.0/include/wx/intl.h \ + C:/wxWidgets-3.1.0/include/wx/translation.h \ + C:/wxWidgets-3.1.0/include/wx/language.h \ + C:/wxWidgets-3.1.0/include/wx/scopedptr.h \ + C:/wxWidgets-3.1.0/include/wx/checkeddelete.h \ + C:/wxWidgets-3.1.0/include/wx/validate.h \ + C:/wxWidgets-3.1.0/include/wx/palette.h \ + C:/wxWidgets-3.1.0/include/wx/msw/palette.h \ + C:/wxWidgets-3.1.0/include/wx/accel.h \ + C:/wxWidgets-3.1.0/include/wx/msw/accel.h \ + C:/wxWidgets-3.1.0/include/wx/msw/window.h \ + C:/wxWidgets-3.1.0/include/wx/settings.h \ + C:/wxWidgets-3.1.0/include/wx/menuitem.h \ + C:/wxWidgets-3.1.0/include/wx/msw/menuitem.h \ + C:/wxWidgets-3.1.0/include/wx/bitmap.h \ + C:/wxWidgets-3.1.0/include/wx/image.h \ + C:/wxWidgets-3.1.0/include/wx/stream.h \ + C:/wxWidgets-3.1.0/include/wx/imagbmp.h \ + C:/wxWidgets-3.1.0/include/wx/imagpng.h \ + C:/wxWidgets-3.1.0/include/wx/imaggif.h \ + C:/wxWidgets-3.1.0/include/wx/imagpcx.h \ + C:/wxWidgets-3.1.0/include/wx/imagjpeg.h \ + C:/wxWidgets-3.1.0/include/wx/imagtga.h \ + C:/wxWidgets-3.1.0/include/wx/imagtiff.h \ + C:/wxWidgets-3.1.0/include/wx/imagpnm.h \ + C:/wxWidgets-3.1.0/include/wx/imagxpm.h \ + C:/wxWidgets-3.1.0/include/wx/imagiff.h \ + C:/wxWidgets-3.1.0/include/wx/msw/bitmap.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 + +Capacitor.h: + +Shunt.h: + +Element.h: + +C:/wxWidgets-3.1.0/include/wx/geometry.h: + +C:/wxWidgets-3.1.0/include/wx/defs.h: + +C:/wxWidgets-3.1.0/include/wx/platform.h: + +C:/wxWidgets-3.1.0/include/wx/compiler.h: + +C:/wxWidgets-3.1.0/lib/gcc_dll/mswu/wx/setup.h: + +C:/wxWidgets-3.1.0/include/wx/msw/libraries.h: + +C:/wxWidgets-3.1.0/include/wx/msw/gccpriv.h: + +C:/wxWidgets-3.1.0/include/wx/chkconf.h: + +C:/wxWidgets-3.1.0/include/wx/msw/chkconf.h: + +C:/wxWidgets-3.1.0/include/wx/version.h: + +C:/wxWidgets-3.1.0/include/wx/cpp.h: + +C:/wxWidgets-3.1.0/include/wx/dlimpexp.h: + +C:/wxWidgets-3.1.0/include/wx/debug.h: + +C:/wxWidgets-3.1.0/include/wx/chartype.h: + +C:/wxWidgets-3.1.0/include/wx/windowid.h: + +C:/wxWidgets-3.1.0/include/wx/msw/winundef.h: + +C:/wxWidgets-3.1.0/include/wx/features.h: + +C:/wxWidgets-3.1.0/include/wx/utils.h: + +C:/wxWidgets-3.1.0/include/wx/object.h: + +C:/wxWidgets-3.1.0/include/wx/memory.h: + +C:/wxWidgets-3.1.0/include/wx/string.h: + +C:/wxWidgets-3.1.0/include/wx/wxcrtbase.h: + +C:/wxWidgets-3.1.0/include/wx/strvararg.h: + +C:/wxWidgets-3.1.0/include/wx/strconv.h: + +C:/wxWidgets-3.1.0/include/wx/buffer.h: + +C:/wxWidgets-3.1.0/include/wx/fontenc.h: + +C:/wxWidgets-3.1.0/include/wx/unichar.h: + +C:/wxWidgets-3.1.0/include/wx/stringimpl.h: + +C:/wxWidgets-3.1.0/include/wx/beforestd.h: + +C:/wxWidgets-3.1.0/include/wx/afterstd.h: + +C:/wxWidgets-3.1.0/include/wx/stringops.h: + +C:/wxWidgets-3.1.0/include/wx/iosfwrap.h: + +C:/wxWidgets-3.1.0/include/wx/msgout.h: + +C:/wxWidgets-3.1.0/include/wx/xti.h: + +C:/wxWidgets-3.1.0/include/wx/rtti.h: + +C:/wxWidgets-3.1.0/include/wx/flags.h: + +C:/wxWidgets-3.1.0/include/wx/xti2.h: + +C:/wxWidgets-3.1.0/include/wx/list.h: + +C:/wxWidgets-3.1.0/include/wx/vector.h: + +C:/wxWidgets-3.1.0/include/wx/scopeguard.h: + +C:/wxWidgets-3.1.0/include/wx/except.h: + +C:/wxWidgets-3.1.0/include/wx/meta/movable.h: + +C:/wxWidgets-3.1.0/include/wx/meta/pod.h: + +C:/wxWidgets-3.1.0/include/wx/meta/if.h: + +C:/wxWidgets-3.1.0/include/wx/filefn.h: + +C:/wxWidgets-3.1.0/include/wx/arrstr.h: + +C:/wxWidgets-3.1.0/include/wx/hashmap.h: + +C:/wxWidgets-3.1.0/include/wx/wxcrt.h: + +C:/wxWidgets-3.1.0/include/wx/versioninfo.h: + +C:/wxWidgets-3.1.0/include/wx/meta/implicitconversion.h: + +C:/wxWidgets-3.1.0/include/wx/gdicmn.h: + +C:/wxWidgets-3.1.0/include/wx/math.h: + +C:/wxWidgets-3.1.0/include/wx/mousestate.h: + +C:/wxWidgets-3.1.0/include/wx/kbdstate.h: + +C:/wxWidgets-3.1.0/include/wx/longlong.h: + +C:/wxWidgets-3.1.0/include/wx/platinfo.h: + +C:/wxWidgets-3.1.0/include/wx/cursor.h: + +C:/wxWidgets-3.1.0/include/wx/gdiobj.h: + +C:/wxWidgets-3.1.0/include/wx/msw/gdiimage.h: + +C:/wxWidgets-3.1.0/include/wx/msw/cursor.h: + +C:/wxWidgets-3.1.0/include/wx/menu.h: + +C:/wxWidgets-3.1.0/include/wx/window.h: + +C:/wxWidgets-3.1.0/include/wx/event.h: + +C:/wxWidgets-3.1.0/include/wx/clntdata.h: + +C:/wxWidgets-3.1.0/include/wx/dynarray.h: + +C:/wxWidgets-3.1.0/include/wx/thread.h: + +C:/wxWidgets-3.1.0/include/wx/tracker.h: + +C:/wxWidgets-3.1.0/include/wx/typeinfo.h: + +C:/wxWidgets-3.1.0/include/wx/any.h: + +C:/wxWidgets-3.1.0/include/wx/datetime.h: + +C:/wxWidgets-3.1.0/include/wx/anystr.h: + +C:/wxWidgets-3.1.0/include/wx/variant.h: + +C:/wxWidgets-3.1.0/include/wx/meta/convertible.h: + +C:/wxWidgets-3.1.0/include/wx/meta/removeref.h: + +C:/wxWidgets-3.1.0/include/wx/font.h: + +C:/wxWidgets-3.1.0/include/wx/msw/font.h: + +C:/wxWidgets-3.1.0/include/wx/colour.h: + +C:/wxWidgets-3.1.0/include/wx/msw/colour.h: + +C:/wxWidgets-3.1.0/include/wx/region.h: + +C:/wxWidgets-3.1.0/include/wx/msw/region.h: + +C:/wxWidgets-3.1.0/include/wx/intl.h: + +C:/wxWidgets-3.1.0/include/wx/translation.h: + +C:/wxWidgets-3.1.0/include/wx/language.h: + +C:/wxWidgets-3.1.0/include/wx/scopedptr.h: + +C:/wxWidgets-3.1.0/include/wx/checkeddelete.h: + +C:/wxWidgets-3.1.0/include/wx/validate.h: + +C:/wxWidgets-3.1.0/include/wx/palette.h: + +C:/wxWidgets-3.1.0/include/wx/msw/palette.h: + +C:/wxWidgets-3.1.0/include/wx/accel.h: + +C:/wxWidgets-3.1.0/include/wx/msw/accel.h: + +C:/wxWidgets-3.1.0/include/wx/msw/window.h: + +C:/wxWidgets-3.1.0/include/wx/settings.h: + +C:/wxWidgets-3.1.0/include/wx/menuitem.h: + +C:/wxWidgets-3.1.0/include/wx/msw/menuitem.h: + +C:/wxWidgets-3.1.0/include/wx/bitmap.h: + +C:/wxWidgets-3.1.0/include/wx/image.h: + +C:/wxWidgets-3.1.0/include/wx/stream.h: + +C:/wxWidgets-3.1.0/include/wx/imagbmp.h: + +C:/wxWidgets-3.1.0/include/wx/imagpng.h: + +C:/wxWidgets-3.1.0/include/wx/imaggif.h: + +C:/wxWidgets-3.1.0/include/wx/imagpcx.h: + +C:/wxWidgets-3.1.0/include/wx/imagjpeg.h: + +C:/wxWidgets-3.1.0/include/wx/imagtga.h: + +C:/wxWidgets-3.1.0/include/wx/imagtiff.h: + +C:/wxWidgets-3.1.0/include/wx/imagpnm.h: + +C:/wxWidgets-3.1.0/include/wx/imagxpm.h: + +C:/wxWidgets-3.1.0/include/wx/imagiff.h: + +C:/wxWidgets-3.1.0/include/wx/msw/bitmap.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: diff --git a/Project/Release/Element.cpp.o b/Project/Release/Element.cpp.o Binary files differindex 8a82cdc..c72fc9a 100644 --- a/Project/Release/Element.cpp.o +++ b/Project/Release/Element.cpp.o diff --git a/Project/Release/IndMotor.cpp.o b/Project/Release/IndMotor.cpp.o Binary files differindex 27c098d..b022ed3 100644 --- a/Project/Release/IndMotor.cpp.o +++ b/Project/Release/IndMotor.cpp.o diff --git a/Project/Release/Inductor.cpp.o b/Project/Release/Inductor.cpp.o Binary files differindex c8331a3..e19d322 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 53db765..3b670d0 100644 --- a/Project/Release/Line.cpp.o +++ b/Project/Release/Line.cpp.o diff --git a/Project/Release/Load.cpp.o b/Project/Release/Load.cpp.o Binary files differindex 24f2ed1..5105216 100644 --- a/Project/Release/Load.cpp.o +++ b/Project/Release/Load.cpp.o diff --git a/Project/Release/Machines.cpp.o b/Project/Release/Machines.cpp.o Binary files differindex 71b8009..7ca5a69 100644 --- a/Project/Release/Machines.cpp.o +++ b/Project/Release/Machines.cpp.o diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe Binary files differindex 9e65316..a463a04 100644 --- a/Project/Release/PSP-UFU.exe +++ b/Project/Release/PSP-UFU.exe diff --git a/Project/Release/Shunt.cpp.o b/Project/Release/Shunt.cpp.o Binary files differindex 1b06520..4a54691 100644 --- a/Project/Release/Shunt.cpp.o +++ b/Project/Release/Shunt.cpp.o diff --git a/Project/Release/SyncGenerator.cpp.o b/Project/Release/SyncGenerator.cpp.o Binary files differindex 982a88b..87c8ad9 100644 --- a/Project/Release/SyncGenerator.cpp.o +++ b/Project/Release/SyncGenerator.cpp.o diff --git a/Project/Release/SyncMotor.cpp.o b/Project/Release/SyncMotor.cpp.o Binary files differindex 78e1caf..8190965 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 23b6f1a..3942680 100644 --- a/Project/Release/Transformer.cpp.o +++ b/Project/Release/Transformer.cpp.o diff --git a/Project/Release/Workspace.cpp.o b/Project/Release/Workspace.cpp.o Binary files differindex f0e577a..e41f7ed 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o diff --git a/Project/Release/Workspace.cpp.o.d b/Project/Release/Workspace.cpp.o.d index fd74f92..29bdf87 100644 --- a/Project/Release/Workspace.cpp.o.d +++ b/Project/Release/Workspace.cpp.o.d @@ -192,7 +192,7 @@ Release/Workspace.cpp.o: Workspace.cpp Workspace.h \ C:/wxWidgets-3.1.0/include/wx/msw/ownerdrw.h \ C:/wxWidgets-3.1.0/include/wx/msw/menu.h Bus.h Line.h Branch.h \ Transformer.h SyncGenerator.h Machines.h IndMotor.h SyncMotor.h Load.h \ - Shunt.h Inductor.h + Shunt.h Inductor.h Capacitor.h Workspace.h: @@ -607,3 +607,5 @@ Load.h: Shunt.h: Inductor.h: + +Capacitor.h: diff --git a/Project/Release/WorkspaceBase.cpp.o b/Project/Release/WorkspaceBase.cpp.o Binary files differindex 8ec190c..8829c58 100644 --- a/Project/Release/WorkspaceBase.cpp.o +++ b/Project/Release/WorkspaceBase.cpp.o diff --git a/Project/Shunt.cpp b/Project/Shunt.cpp index 34e4068..81a310d 100644 --- a/Project/Shunt.cpp +++ b/Project/Shunt.cpp @@ -17,6 +17,7 @@ void Shunt::UpdateSwitchesPosition() { m_pointList[1] = m_pointList[0]; } + UpdateSwitches(); } void Shunt::Move(wxPoint2DDouble position) @@ -43,6 +44,7 @@ void Shunt::MoveNode(Element* element, wxPoint2DDouble position) if(m_activeNodeID == 1) { m_pointList[0] = m_movePts[0] + position - m_moveStartPt; m_parentList[0] = NULL; + m_online = false; } } @@ -61,6 +63,7 @@ void Shunt::RemoveParent(Element* parent) { if(parent == m_parentList[0]) { m_parentList[0] = NULL; + m_online = false; UpdateSwitchesPosition(); } } @@ -101,6 +104,7 @@ bool Shunt::SetNodeParent(Element* parent) else { m_parentList[0] = NULL; + m_online = false; } } return false; @@ -114,6 +118,7 @@ void Shunt::UpdateNodes() if(!m_parentList[0]->Intersects(nodeRect)) { m_parentList[0] = NULL; + m_online = false; UpdateSwitchesPosition(); } } diff --git a/Project/Shunt.h b/Project/Shunt.h index 9f5064a..8369516 100644 --- a/Project/Shunt.h +++ b/Project/Shunt.h @@ -24,8 +24,6 @@ public: void UpdateSwitchesPosition(); void DrawGround(wxPoint2DDouble position) const; bool m_inserted = false; - std::vector<wxPoint2DDouble> m_pointList; - std::vector<wxPoint2DDouble> m_movePts; }; diff --git a/Project/Transformer.cpp b/Project/Transformer.cpp index cb18d2f..ce1d12e 100644 --- a/Project/Transformer.cpp +++ b/Project/Transformer.cpp @@ -15,6 +15,10 @@ bool Transformer::AddParent(Element* parent, wxPoint2DDouble position) parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. m_pointList.push_back(parentPt); // First point m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position)); + + wxRect2DDouble genRect(0,0,0,0); + m_switchRect.push_back(genRect); + return false; } // Second bus. @@ -51,6 +55,11 @@ bool Transformer::AddParent(Element* parent, wxPoint2DDouble position) m_pointList.push_back(parentPt); // Last point. m_inserted = true; + + wxRect2DDouble genRect(0,0,0,0); + m_switchRect.push_back(genRect); + UpdateSwitches(); + return true; } } @@ -78,7 +87,6 @@ void Transformer::Draw(wxPoint2DDouble translation, double scale) const glRotated(m_angle, 0.0, 0.0, 1.0); glTranslated(-m_position.m_x, -m_position.m_y, 0.0); - // glColor4d(0.0, 0.5, 1.0, 0.5); DrawCircle(m_rect.GetPosition() + wxPoint2DDouble(20.0, 20.0), 20 + (m_borderSize + 1.5) / scale, 20, GL_POLYGON); DrawCircle(m_rect.GetPosition() + wxPoint2DDouble(50.0, 20.0), 20 + (m_borderSize + 1.5) / scale, @@ -109,7 +117,9 @@ void Transformer::Draw(wxPoint2DDouble translation, double scale) const DrawCircle(m_pointList[m_pointList.size() - 1], 5.0, 10, GL_POLYGON); } } - + + DrawSwitches(); + // Push the current matrix on stack. glPushMatrix(); // Rotate the matrix around the object position. @@ -185,11 +195,13 @@ void Transformer::MoveNode(Element* parent, wxPoint2DDouble position) if(m_activeNodeID == 1) { m_pointList[0] = m_movePts[0] + position - m_moveStartPt; m_parentList[0] = NULL; + m_online = false; } else if(m_activeNodeID == 2) { m_pointList[m_pointList.size() - 1] = m_movePts[m_pointList.size() - 1] + position - m_moveStartPt; m_parentList[1] = NULL; + m_online = false; } } diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp index 79bb61c..da01c8d 100644 --- a/Project/Workspace.cpp +++ b/Project/Workspace.cpp @@ -9,6 +9,7 @@ #include "SyncMotor.h" #include "Load.h" #include "Inductor.h" +#include "Capacitor.h" // Camera Camera::Camera() @@ -184,7 +185,7 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event) foundElement = true; } - // Click in an element + // Click in an element. else if(element->Contains(m_camera->ScreenToWorld(event.GetPosition()))) { if(!foundElement) { @@ -203,6 +204,11 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event) m_mode = MODE_MOVE_ELEMENT; } } + + // Click in a switch. + else if(element->SwitchesContains(m_camera->ScreenToWorld(event.GetPosition()))) { + element->SetOnline(element->IsOnline() ? false : true); + } } } @@ -216,6 +222,24 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event) event.Skip(); } +void Workspace::OnLeftDoubleClick(wxMouseEvent& event) +{ + for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { + Element* element = *it; + + // Click in an element. + if(element->Contains(m_camera->ScreenToWorld(event.GetPosition()))) + { + //Open the form. + } + + // Click in a switch. + else if(element->SwitchesContains(m_camera->ScreenToWorld(event.GetPosition()))) { + element->SetOnline(element->IsOnline() ? false : true); + } + } +} + void Workspace::OnRightClickDown(wxMouseEvent& event) { bool redraw = false; @@ -645,6 +669,19 @@ void Workspace::OnKeyDown(wxKeyEvent& event) } } break; + case 'C': + { + if(m_mode != MODE_INSERT) { + if(event.GetModifiers() == wxMOD_SHIFT) { // Insert a capacitor. + Capacitor* newCapacitor = new Capacitor(); + m_elementList.push_back(newCapacitor); + m_mode = MODE_INSERT; + m_statusBar->SetStatusText(_("Insert Capacitor: Click on a buses, ESC to cancel.")); + Redraw(); + } + } + } + break; default: break; } diff --git a/Project/Workspace.h b/Project/Workspace.h index b506189..7df1190 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -19,6 +19,7 @@ class IndMotor; class SyncMotor; class Load; class Inductor; +class Capacitor; enum WorkspaceMode { @@ -44,6 +45,7 @@ class Workspace : public WorkspaceBase void Redraw() { m_glCanvas->Refresh(); } protected: + virtual void OnLeftDoubleClick(wxMouseEvent& event); virtual void OnRightClickDown(wxMouseEvent& event); virtual void OnLeftClickUp(wxMouseEvent& event); virtual void OnScroll(wxMouseEvent& event); diff --git a/Project/Workspace.wxcp b/Project/Workspace.wxcp index 0153fd3..bae4b9f 100644 --- a/Project/Workspace.wxcp +++ b/Project/Workspace.wxcp @@ -327,6 +327,13 @@ "m_functionNameAndSignature": "OnRightClickDown(wxMouseEvent& event)", "m_description": "Process a wxEVT_RIGHT_DOWN event", "m_noBody": false + }, { + "m_eventName": "wxEVT_LEFT_DCLICK", + "m_eventClass": "wxMouseEvent", + "m_eventHandler": "wxMouseEventHandler", + "m_functionNameAndSignature": "OnLeftDoubleClick(wxMouseEvent& event)", + "m_description": "Process a wxEVT_LEFT_DCLICK event.", + "m_noBody": false }], "m_children": [] }] diff --git a/Project/WorkspaceBase.cpp b/Project/WorkspaceBase.cpp index 65a1071..f4973d6 100644 --- a/Project/WorkspaceBase.cpp +++ b/Project/WorkspaceBase.cpp @@ -52,6 +52,7 @@ WorkspaceBase::WorkspaceBase(wxWindow* parent, wxWindowID id, const wxPoint& pos m_glCanvas->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(WorkspaceBase::OnLeftClickUp), NULL, this); 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); } @@ -66,5 +67,6 @@ WorkspaceBase::~WorkspaceBase() m_glCanvas->Disconnect(wxEVT_LEFT_UP, wxMouseEventHandler(WorkspaceBase::OnLeftClickUp), NULL, this); 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); } diff --git a/Project/WorkspaceBase.h b/Project/WorkspaceBase.h index 30bfdc3..fb7d0b9 100644 --- a/Project/WorkspaceBase.h +++ b/Project/WorkspaceBase.h @@ -46,6 +46,7 @@ protected: virtual void OnLeftClickUp(wxMouseEvent& event) { event.Skip(); } virtual void OnScroll(wxMouseEvent& event) { event.Skip(); } virtual void OnRightClickDown(wxMouseEvent& event) { event.Skip(); } + virtual void OnLeftDoubleClick(wxMouseEvent& event) { event.Skip(); } public: wxGLCanvas* GetGlCanvas() { return m_glCanvas; } |