diff options
author | Thales1330 <thaleslima.ufu@gmail.com> | 2016-09-06 18:32:47 -0300 |
---|---|---|
committer | Thales1330 <thaleslima.ufu@gmail.com> | 2016-09-06 18:32:47 -0300 |
commit | 697baaa3cc92e945d2301238dc9bcabffdb465ef (patch) | |
tree | 01f3de93600a1036c8d693c5c8150434ebf75731 | |
parent | d93ef357da510f2515556ff2cb51688a4e068805 (diff) | |
download | PSP.git-697baaa3cc92e945d2301238dc9bcabffdb465ef.tar.gz PSP.git-697baaa3cc92e945d2301238dc9bcabffdb465ef.tar.xz PSP.git-697baaa3cc92e945d2301238dc9bcabffdb465ef.zip |
Counter clockwise rotation implemented
52 files changed, 164 insertions, 108 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port index cd28455..0a2fd0a 100644 --- a/.codelite/.tern-port +++ b/.codelite/.tern-port @@ -1 +1 @@ -54825
\ No newline at end of file +61316
\ No newline at end of file diff --git a/.codelite/PSP.session b/.codelite/PSP.session index 40a3820..999b9ba 100644 --- a/.codelite/PSP.session +++ b/.codelite/PSP.session @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <Session Name="C:\Users\Thales\Documents\GitHub\PSP\PSP.workspace"> - <int Value="11" Name="m_selectedTab"/> + <int Value="2" 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="217" Name="FirstVisibleLine"/> - <int Value="238" Name="CurrentLine"/> + <int Value="767" Name="FirstVisibleLine"/> + <int Value="797" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> @@ -19,74 +19,46 @@ </TabInfo> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Element.cpp" Name="FileName"/> - <int Value="270" Name="FirstVisibleLine"/> - <int Value="292" Name="CurrentLine"/> + <int Value="274" Name="FirstVisibleLine"/> + <int Value="296" 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="27" Name="FirstVisibleLine"/> - <int Value="53" Name="CurrentLine"/> + <int Value="103" Name="FirstVisibleLine"/> + <int Value="128" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Line.cpp" Name="FileName"/> - <int Value="185" Name="FirstVisibleLine"/> - <int Value="211" Name="CurrentLine"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Capacitor.cpp" Name="FileName"/> + <int Value="90" Name="FirstVisibleLine"/> + <int Value="106" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Line.h" Name="FileName"/> - <int Value="0" Name="FirstVisibleLine"/> - <int Value="23" Name="CurrentLine"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Inductor.cpp" Name="FileName"/> + <int Value="81" Name="FirstVisibleLine"/> + <int Value="98" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Branch.h" Name="FileName"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\SyncMotor.cpp" Name="FileName"/> <int Value="0" Name="FirstVisibleLine"/> - <int Value="30" Name="CurrentLine"/> - <wxArrayString Name="Bookmarks"/> - <IntVector Name="CollapsedFolds"/> - </TabInfo> - <TabInfo> - <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\Transformer.cpp" Name="FileName"/> - <int Value="172" Name="FirstVisibleLine"/> - <int Value="197" Name="CurrentLine"/> + <int Value="26" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <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\Shunt.h" Name="FileName"/> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Machines.h" Name="FileName"/> <int Value="0" Name="FirstVisibleLine"/> <int Value="24" 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="86" Name="FirstVisibleLine"/> - <int Value="113" Name="CurrentLine"/> - <wxArrayString Name="Bookmarks"/> - <IntVector Name="CollapsedFolds"/> - </TabInfo> </TabInfoArray> <SerializedObject Name="m_breakpoints"> <long Value="0" Name="Count"/> diff --git a/.codelite/PSP.tags b/.codelite/PSP.tags Binary files differindex c76ed1f..99f60d5 100644 --- a/.codelite/PSP.tags +++ b/.codelite/PSP.tags diff --git a/.codelite/PSP.workspace.thales b/.codelite/PSP.workspace.thales new file mode 100644 index 0000000..6fcd411 --- /dev/null +++ b/.codelite/PSP.workspace.thales @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Workspace> + <FindInFilesMask> + <![CDATA[*.c;*.cpp;*.cxx;*.cc;*.h;*.hpp;*.inc;*.mm;*.m;*.xrc]]> + </FindInFilesMask> +</Workspace> diff --git a/.codelite/compilation.db b/.codelite/compilation.db Binary files differindex 699d56c..0f7950d 100644 --- a/.codelite/compilation.db +++ b/.codelite/compilation.db diff --git a/.codelite/compile_commands.json b/.codelite/compile_commands.json index 9d177f6..d05a5aa 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/Shunt.cpp.o -MF./Release/Shunt.cpp.o.d -MM Shunt.cpp", - "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Shunt.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/SyncMotor.cpp.o -MF./Release/SyncMotor.cpp.o.d -MM SyncMotor.cpp", + "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\SyncMotor.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/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" + "command": "C:/TDM-GCC-64/bin/g++.exe -c C:/Users/Thales/Documents/GitHub/PSP/Project/SyncMotor.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/SyncMotor.cpp.o -I. -I.", + "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\SyncMotor.cpp" }]
\ No newline at end of file diff --git a/.codelite/refactoring.db b/.codelite/refactoring.db Binary files differindex 8b12a4e..d4410bb 100644 --- a/.codelite/refactoring.db +++ b/.codelite/refactoring.db diff --git a/Project/Branch.cpp b/Project/Branch.cpp index c14c1e1..d0af388 100644 --- a/Project/Branch.cpp +++ b/Project/Branch.cpp @@ -93,7 +93,7 @@ void Branch::RemoveParent(Element* parent) for(int i = 0; i < 2; i++) { if(parent == m_parentList[i]) { m_parentList[i] = NULL; - m_online = false; + m_online = false; UpdateSwitchesPosition(); } } @@ -107,7 +107,7 @@ void Branch::UpdateNodes() if(!m_parentList[0]->Intersects(nodeRect)) { m_parentList[0] = NULL; - m_online = false; + m_online = false; UpdateSwitchesPosition(); } } @@ -118,21 +118,24 @@ void Branch::UpdateNodes() if(!m_parentList[1]->Intersects(nodeRect)) { m_parentList[1] = NULL; - m_online = false; + m_online = false; UpdateSwitchesPosition(); } } } -void Branch::RotateNode(Element* parent) +void Branch::RotateNode(Element* parent, bool clockwise) { + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + if(parent == m_parentList[0]) { - m_pointList[0] = parent->RotateAtPosition(m_pointList[0], m_rotationAngle); + m_pointList[0] = parent->RotateAtPosition(m_pointList[0], rotAngle); } else if(parent == m_parentList[1]) { m_pointList[m_pointList.size() - 1] = - parent->RotateAtPosition(m_pointList[m_pointList.size() - 1], m_rotationAngle); + parent->RotateAtPosition(m_pointList[m_pointList.size() - 1], rotAngle); } UpdateSwitchesPosition(); } diff --git a/Project/Branch.h b/Project/Branch.h index 5032f1f..a39cef6 100644 --- a/Project/Branch.h +++ b/Project/Branch.h @@ -23,8 +23,7 @@ public: virtual bool Intersects(wxRect2DDouble rect) const { return false; } virtual void MovePickbox(wxPoint2DDouble position) {} virtual bool PickboxContains(wxPoint2DDouble position) { return false; } - virtual void Rotate() {} - virtual void RotateNode(Element* parent); + virtual void RotateNode(Element* parent, bool clockwise = true); virtual void AddPoint(wxPoint2DDouble point) {}; virtual bool GetContextMenu(wxMenu& menu) { return false; } virtual void UpdateSwitchesPosition(); diff --git a/Project/Bus.cpp b/Project/Bus.cpp index 9d0775e..927d6c8 100644 --- a/Project/Bus.cpp +++ b/Project/Bus.cpp @@ -77,8 +77,8 @@ bool Bus::Contains(wxPoint2DDouble position) const bool Bus::Intersects(wxRect2DDouble rect) const { if(m_angle == 0.0 || m_angle == 180.0) return m_rect.Intersects(rect); - - return RotatedRectanglesIntersects(m_rect, rect, m_angle, 0.0); + + return RotatedRectanglesIntersects(m_rect, rect, m_angle, 0.0); } bool Bus::PickboxContains(wxPoint2DDouble position) @@ -150,16 +150,20 @@ void Bus::MovePickbox(wxPoint2DDouble position) SetPosition(m_position); } -void Bus::Rotate() +void Bus::Rotate(bool clockwise) { - m_angle += m_rotationAngle; + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + + m_angle += rotAngle; if(m_angle >= 360.0) m_angle = 0.0; } bool Bus::GetContextMenu(wxMenu& menu) { menu.Append(ID_EDIT_BUS, _("Edit bus")); - menu.Append(ID_ROTATE, _("Rotate")); - menu.Append(ID_DELETE, _("Delete")); + menu.Append(ID_ROTATE_CLOCK, _("Rotate clockwise")); + menu.Append(ID_ROTATE_COUNTERCLOCK, _("Rotate counter-clockwise")); + menu.Append(ID_DELETE, _("Delete")); return true; } diff --git a/Project/Bus.h b/Project/Bus.h index a7fa122..190f761 100644 --- a/Project/Bus.h +++ b/Project/Bus.h @@ -13,7 +13,7 @@ class Bus : public Element virtual bool Contains(wxPoint2DDouble position) const; virtual bool Intersects(wxRect2DDouble rect) const; virtual void Draw(wxPoint2DDouble translation, double scale) const; - virtual void Rotate(); + virtual void Rotate(bool clockwise = true); virtual wxCursor GetBestPickboxCursor() const; virtual void MovePickbox(wxPoint2DDouble position); virtual bool PickboxContains(wxPoint2DDouble position); diff --git a/Project/Capacitor.cpp b/Project/Capacitor.cpp index 26e0854..46193f5 100644 --- a/Project/Capacitor.cpp +++ b/Project/Capacitor.cpp @@ -89,18 +89,22 @@ void Capacitor::Draw(wxPoint2DDouble translation, double scale) const } } -void Capacitor::Rotate() +void Capacitor::Rotate(bool clockwise) { - m_angle += m_rotationAngle; - m_pointList[2] = RotateAtPosition(m_pointList[2], m_rotationAngle); - m_pointList[3] = RotateAtPosition(m_pointList[3], m_rotationAngle); + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + + m_angle += rotAngle; + m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle); + m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle); UpdateSwitchesPosition(); } bool Capacitor::GetContextMenu(wxMenu& menu) { menu.Append(ID_EDIT_CAPACITOR, _("Edit Capacitor")); - menu.Append(ID_ROTATE, _("Rotate")); + menu.Append(ID_ROTATE_CLOCK, _("Rotate clockwise")); + menu.Append(ID_ROTATE_COUNTERCLOCK, _("Rotate counter-clockwise")); menu.Append(ID_DELETE, _("Delete")); return true; } diff --git a/Project/Capacitor.h b/Project/Capacitor.h index e407ba8..47eff58 100644 --- a/Project/Capacitor.h +++ b/Project/Capacitor.h @@ -13,7 +13,7 @@ public: virtual void Draw(wxPoint2DDouble translation, double scale) const; virtual bool Contains(wxPoint2DDouble position) const; virtual bool Intersects(wxRect2DDouble rect) const; - virtual void Rotate(); + virtual void Rotate(bool clockwise = true); virtual bool GetContextMenu(wxMenu& menu); }; diff --git a/Project/Element.cpp b/Project/Element.cpp index 9f10ffc..88f764a 100644 --- a/Project/Element.cpp +++ b/Project/Element.cpp @@ -292,3 +292,7 @@ void Element::SetOnline(bool online) } m_online = online; } + +void Element::GeneralMenuItens(wxMenu& menu) +{ +} diff --git a/Project/Element.h b/Project/Element.h index 6c07ec9..688a4e3 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -32,7 +32,8 @@ enum ContextMenuID ID_LINE_ADD_NODE, ID_LINE_REMOVE_NODE, - ID_ROTATE, + ID_ROTATE_CLOCK, + ID_ROTATE_COUNTERCLOCK, ID_DELETE }; @@ -69,7 +70,7 @@ class Element virtual bool Intersects(wxRect2DDouble rect) const = 0; // General methods - virtual void Rotate() {} + virtual void Rotate(bool clockwise = true) {} virtual bool GetContextMenu(wxMenu& menu) { return false; } virtual void AddPoint(wxPoint2DDouble point) {} virtual void StartMove(wxPoint2DDouble position); @@ -79,7 +80,7 @@ class Element virtual void UpdateNodes() {} virtual bool SetNodeParent(Element* parent) { return false; } virtual void RemoveParent(Element* parent) {} - virtual void RotateNode(Element* parent) {} + virtual void RotateNode(Element* parent, bool clockwise = true) {} virtual wxPoint2DDouble GetSwitchPoint(Element* parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const; @@ -124,6 +125,8 @@ class Element virtual std::vector<Element*> GetParentList() const { return m_parentList; } virtual wxPoint2DDouble GetMoveStartPosition() const { return m_moveStartPt; } virtual wxPoint2DDouble GetMovePosition() const { return m_movePos; } + + virtual void GeneralMenuItens(wxMenu& menu); protected: std::vector<Element*> m_parentList; diff --git a/Project/IndMotor.cpp b/Project/IndMotor.cpp index 3d7c243..2880cc1 100644 --- a/Project/IndMotor.cpp +++ b/Project/IndMotor.cpp @@ -22,7 +22,8 @@ void IndMotor::DrawSymbol() const bool IndMotor::GetContextMenu(wxMenu& menu) { menu.Append(ID_EDIT_INDMOTOR, _("Edit induction motor")); - menu.Append(ID_ROTATE, _("Rotate")); + menu.Append(ID_ROTATE_CLOCK, _("Rotate clockwise")); + menu.Append(ID_ROTATE_COUNTERCLOCK, _("Rotate counter-clockwise")); menu.Append(ID_DELETE, _("Delete")); return true; } diff --git a/Project/Inductor.cpp b/Project/Inductor.cpp index 08511e4..03e67ef 100644 --- a/Project/Inductor.cpp +++ b/Project/Inductor.cpp @@ -81,18 +81,22 @@ void Inductor::Draw(wxPoint2DDouble translation, double scale) const } } -void Inductor::Rotate() +void Inductor::Rotate(bool clockwise) { - m_angle += m_rotationAngle; - m_pointList[2] = RotateAtPosition(m_pointList[2], m_rotationAngle); - m_pointList[3] = RotateAtPosition(m_pointList[3], m_rotationAngle); + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + + m_angle += rotAngle; + m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle); + m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle); UpdateSwitchesPosition(); } bool Inductor::GetContextMenu(wxMenu& menu) { menu.Append(ID_EDIT_INDUCTOR, _("Edit Inductor")); - menu.Append(ID_ROTATE, _("Rotate")); + menu.Append(ID_ROTATE_CLOCK, _("Rotate clockwise")); + menu.Append(ID_ROTATE_COUNTERCLOCK, _("Rotate counter-clockwise")); menu.Append(ID_DELETE, _("Delete")); return true; } diff --git a/Project/Inductor.h b/Project/Inductor.h index 830cab5..721d58a 100644 --- a/Project/Inductor.h +++ b/Project/Inductor.h @@ -13,7 +13,7 @@ public: virtual void Draw(wxPoint2DDouble translation, double scale) const; virtual bool Contains(wxPoint2DDouble position) const; virtual bool Intersects(wxRect2DDouble rect) const; - virtual void Rotate(); + virtual void Rotate(bool clockwise = true); virtual bool GetContextMenu(wxMenu& menu); }; diff --git a/Project/Load.cpp b/Project/Load.cpp index b5c5948..92a98d3 100644 --- a/Project/Load.cpp +++ b/Project/Load.cpp @@ -87,18 +87,22 @@ void Load::Draw(wxPoint2DDouble translation, double scale) const } } -void Load::Rotate() +void Load::Rotate(bool clockwise) { - m_angle += m_rotationAngle; - m_pointList[2] = RotateAtPosition(m_pointList[2], m_rotationAngle); - m_pointList[3] = RotateAtPosition(m_pointList[3], m_rotationAngle); + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + + m_angle += rotAngle; + m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle); + m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle); UpdateSwitchesPosition(); } bool Load::GetContextMenu(wxMenu& menu) { menu.Append(ID_EDIT_LOAD, _("Edit Load")); - menu.Append(ID_ROTATE, _("Rotate")); + menu.Append(ID_ROTATE_CLOCK, _("Rotate clockwise")); + menu.Append(ID_ROTATE_COUNTERCLOCK, _("Rotate counter-clockwise")); menu.Append(ID_DELETE, _("Delete")); return true; } diff --git a/Project/Load.h b/Project/Load.h index 393ff7a..fcdaa6b 100644 --- a/Project/Load.h +++ b/Project/Load.h @@ -11,7 +11,7 @@ class Load : public Shunt virtual bool AddParent(Element* parent, wxPoint2DDouble position); virtual void Draw(wxPoint2DDouble translation, double scale) const; - virtual void Rotate(); + virtual void Rotate(bool clockwise = true); virtual bool GetContextMenu(wxMenu& menu); private: diff --git a/Project/Machines.cpp b/Project/Machines.cpp index 29574e6..1b11c68 100644 --- a/Project/Machines.cpp +++ b/Project/Machines.cpp @@ -118,10 +118,13 @@ void Machines::StartMove(wxPoint2DDouble position) m_movePos = m_position; } -void Machines::RotateNode(Element* parent) +void Machines::RotateNode(Element* parent, bool clockwise) { + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + if(parent == m_parentList[0]) { - m_pointList[0] = parent->RotateAtPosition(m_pointList[0], m_rotationAngle); + m_pointList[0] = parent->RotateAtPosition(m_pointList[0], rotAngle); UpdateSwitchesPosition(); } } @@ -190,9 +193,12 @@ void Machines::UpdateNodes() } } -void Machines::Rotate() +void Machines::Rotate(bool clockwise) { - m_pointList[2] = RotateAtPosition(m_pointList[2], m_rotationAngle); - m_pointList[3] = RotateAtPosition(m_pointList[3], m_rotationAngle); + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + + m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle); + m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle); UpdateSwitchesPosition(); } diff --git a/Project/Machines.h b/Project/Machines.h index 737e407..8c60631 100644 --- a/Project/Machines.h +++ b/Project/Machines.h @@ -16,12 +16,12 @@ public: virtual void Move(wxPoint2DDouble position); virtual void MoveNode(Element* element, wxPoint2DDouble position); virtual void StartMove(wxPoint2DDouble position); - virtual void RotateNode(Element* parent); + virtual void RotateNode(Element* parent, bool clockwise = true); virtual void RemoveParent(Element* parent); virtual bool NodeContains(wxPoint2DDouble position); virtual bool SetNodeParent(Element* parent); virtual void UpdateNodes(); - virtual void Rotate(); + virtual void Rotate(bool clockwise = true); virtual void DrawSymbol() const {} protected: diff --git a/Project/Project.mk b/Project/Project.mk index 06384e9..c7b67ad 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=05/09/2016 +Date :=06/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 diff --git a/Project/Release/Branch.cpp.o b/Project/Release/Branch.cpp.o Binary files differindex b1e5b5c..4f4f76a 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 cbfd2b5..c4810a9 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 differindex 8cd89cd..7d205fe 100644 --- a/Project/Release/Capacitor.cpp.o +++ b/Project/Release/Capacitor.cpp.o diff --git a/Project/Release/Element.cpp.o b/Project/Release/Element.cpp.o Binary files differindex c72fc9a..bbfb08e 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 b022ed3..88c6d2f 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 e19d322..f2c67ba 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 3b670d0..305cbd9 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 5105216..a68dcfa 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 7ca5a69..a4b944e 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 a463a04..7c00091 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 4a54691..b9fed50 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 87c8ad9..8d1c4ad 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 8190965..40b26fe 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 3942680..0a064e6 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 e41f7ed..457cf83 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o diff --git a/Project/Release/data/images/cClock.png b/Project/Release/data/images/cClock.png Binary files differnew file mode 100644 index 0000000..543bdf4 --- /dev/null +++ b/Project/Release/data/images/cClock.png diff --git a/Project/Release/data/images/clock.png b/Project/Release/data/images/clock.png Binary files differnew file mode 100644 index 0000000..c09148c --- /dev/null +++ b/Project/Release/data/images/clock.png diff --git a/Project/Release/data/images/menu/delete16.png b/Project/Release/data/images/menu/delete16.png Binary files differnew file mode 100644 index 0000000..8e035b4 --- /dev/null +++ b/Project/Release/data/images/menu/delete16.png diff --git a/Project/Release/data/images/menu/rotateClock16.png b/Project/Release/data/images/menu/rotateClock16.png Binary files differnew file mode 100644 index 0000000..e5965f3 --- /dev/null +++ b/Project/Release/data/images/menu/rotateClock16.png diff --git a/Project/Release/data/images/menu/rotateCounterClock16.png b/Project/Release/data/images/menu/rotateCounterClock16.png Binary files differnew file mode 100644 index 0000000..14cac6a --- /dev/null +++ b/Project/Release/data/images/menu/rotateCounterClock16.png diff --git a/Project/Release/data/images/ribbon/rotateClock32.png b/Project/Release/data/images/ribbon/rotateClock32.png Binary files differnew file mode 100644 index 0000000..9873e13 --- /dev/null +++ b/Project/Release/data/images/ribbon/rotateClock32.png diff --git a/Project/Release/data/images/ribbon/rotateCounterClock32.png b/Project/Release/data/images/ribbon/rotateCounterClock32.png Binary files differnew file mode 100644 index 0000000..3658f93 --- /dev/null +++ b/Project/Release/data/images/ribbon/rotateCounterClock32.png diff --git a/Project/Shunt.cpp b/Project/Shunt.cpp index 81a310d..7df5330 100644 --- a/Project/Shunt.cpp +++ b/Project/Shunt.cpp @@ -124,10 +124,13 @@ void Shunt::UpdateNodes() } } -void Shunt::RotateNode(Element* parent) +void Shunt::RotateNode(Element* parent, bool clockwise) { + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + if(parent == m_parentList[0]) { - m_pointList[0] = parent->RotateAtPosition(m_pointList[0], m_rotationAngle); + m_pointList[0] = parent->RotateAtPosition(m_pointList[0], rotAngle); UpdateSwitchesPosition(); } } diff --git a/Project/Shunt.h b/Project/Shunt.h index 8369516..e44f735 100644 --- a/Project/Shunt.h +++ b/Project/Shunt.h @@ -14,7 +14,7 @@ public: virtual void Move(wxPoint2DDouble position); virtual void MoveNode(Element* element, wxPoint2DDouble position); virtual void StartMove(wxPoint2DDouble position); - virtual void RotateNode(Element* parent); + virtual void RotateNode(Element* parent, bool clockwise = true); virtual void RemoveParent(Element* parent); virtual bool NodeContains(wxPoint2DDouble position); virtual bool SetNodeParent(Element* parent); diff --git a/Project/SyncGenerator.cpp b/Project/SyncGenerator.cpp index dff180d..2433c1f 100644 --- a/Project/SyncGenerator.cpp +++ b/Project/SyncGenerator.cpp @@ -27,7 +27,8 @@ void SyncGenerator::DrawSymbol() const bool SyncGenerator::GetContextMenu(wxMenu& menu) { menu.Append(ID_EDIT_SYNCGENERATOR, _("Edit Generator")); - menu.Append(ID_ROTATE, _("Rotate")); + menu.Append(ID_ROTATE_CLOCK, _("Rotate clockwise")); + menu.Append(ID_ROTATE_COUNTERCLOCK, _("Rotate counter-clockwise")); menu.Append(ID_DELETE, _("Delete")); return true; } diff --git a/Project/SyncMotor.cpp b/Project/SyncMotor.cpp index 08399d2..bdd3abd 100644 --- a/Project/SyncMotor.cpp +++ b/Project/SyncMotor.cpp @@ -16,7 +16,17 @@ void SyncMotor::DrawSymbol() const bool SyncMotor::GetContextMenu(wxMenu& menu) { menu.Append(ID_EDIT_SYNCMOTOR, _("Edit Synchronous Condenser")); - menu.Append(ID_ROTATE, _("Rotate")); - menu.Append(ID_DELETE, _("Delete")); + + wxMenuItem* clockItem = new wxMenuItem(&menu, ID_ROTATE_CLOCK, _("Rotate clockwise")); + clockItem->SetBitmap(wxImage("data\\images\\menu\\rotateClock16.png")); + menu.Append(clockItem); + + wxMenuItem* counterClockItem = new wxMenuItem(&menu, ID_ROTATE_COUNTERCLOCK, _("Rotate counter-clockwise")); + counterClockItem->SetBitmap(wxImage("data\\images\\menu\\rotateCounterClock16.png")); + menu.Append(counterClockItem); + + wxMenuItem* deleteItem = new wxMenuItem(&menu, ID_DELETE, _("Delete")); + deleteItem->SetBitmap(wxImage("data\\images\\menu\\delete16.png")); + menu.Append(deleteItem); return true; } diff --git a/Project/Transformer.cpp b/Project/Transformer.cpp index ce1d12e..0bb32d8 100644 --- a/Project/Transformer.cpp +++ b/Project/Transformer.cpp @@ -147,14 +147,17 @@ bool Transformer::Intersects(wxRect2DDouble rect) const return RotatedRectanglesIntersects(m_rect, rect, m_angle, 0.0); } -void Transformer::Rotate() +void Transformer::Rotate(bool clockwise) { - m_angle += m_rotationAngle; + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + + m_angle += rotAngle; if(m_angle >= 360.0) m_angle = 0.0; // Rotate all the points, except the switches and buses points. for(int i = 2; i < (int)m_pointList.size() - 2; i++) { - m_pointList[i] = RotateAtPosition(m_pointList[i], m_rotationAngle); + m_pointList[i] = RotateAtPosition(m_pointList[i], rotAngle); } } @@ -219,7 +222,8 @@ void Transformer::StartMove(wxPoint2DDouble position) bool Transformer::GetContextMenu(wxMenu& menu) { menu.Append(ID_EDIT_TRANSFORMER, _("Edit tranformer")); - menu.Append(ID_ROTATE, _("Rotate")); + menu.Append(ID_ROTATE_CLOCK, _("Rotate clockwise")); + menu.Append(ID_ROTATE_COUNTERCLOCK, _("Rotate counter-clockwise")); menu.Append(ID_DELETE, _("Delete")); return true; } diff --git a/Project/Transformer.h b/Project/Transformer.h index 413b8d9..4630d33 100644 --- a/Project/Transformer.h +++ b/Project/Transformer.h @@ -13,7 +13,7 @@ public: virtual bool Contains(wxPoint2DDouble position) const; virtual void Draw(wxPoint2DDouble translation, double scale) const; virtual bool Intersects(wxRect2DDouble rect) const; - virtual void Rotate(); + virtual void Rotate(bool clockwise = true); virtual void Move(wxPoint2DDouble position); virtual void MoveNode(Element* parent, wxPoint2DDouble position); virtual void StartMove(wxPoint2DDouble position); diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp index da01c8d..6ac326f 100644 --- a/Project/Workspace.cpp +++ b/Project/Workspace.cpp @@ -575,12 +575,24 @@ void Workspace::OnKeyDown(wxKeyEvent& event) Element* parent = element->GetParentList()[i]; if(parent) { // Check if parent is not null if(parent->IsSelected()) { - element->RotateNode(parent); + if(event.GetModifiers() == wxMOD_SHIFT) { + element->RotateNode(parent, false); + } + else + { + element->RotateNode(parent); + } } } } if(element->IsSelected()) { - element->Rotate(); + if(event.GetModifiers() == wxMOD_SHIFT) { + element->Rotate(false); + } + else + { + element->Rotate(); + } } } Redraw(); @@ -760,7 +772,7 @@ void Workspace::OnPopupClick(wxCommandEvent& event) Redraw(); } break; - case ID_ROTATE: + case ID_ROTATE_CLOCK: { element->Rotate(); for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { @@ -776,6 +788,22 @@ void Workspace::OnPopupClick(wxCommandEvent& event) Redraw(); } break; + case ID_ROTATE_COUNTERCLOCK: + { + element->Rotate(false); + for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { + Element* iElement = *it; + // Parent's element rotating... + for(int i = 0; i < (int)iElement->GetParentList().size(); i++) { + Element* parent = iElement->GetParentList()[i]; + if(parent == element) { + iElement->RotateNode(parent, false); + } + } + } + Redraw(); + } + break; case ID_DELETE: { for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { |