diff options
author | Thales1330 <thaleslima.ufu@gmail.com> | 2016-08-25 18:09:39 -0300 |
---|---|---|
committer | Thales1330 <thaleslima.ufu@gmail.com> | 2016-08-25 18:09:39 -0300 |
commit | 8e00906e0517b335a6c33f682334bda3c1eadb69 (patch) | |
tree | 73a05e149d2fe0bc55cfd81cef9048d51a61f251 | |
parent | c36a96b8a152b98e406c352462435070b46f2dcd (diff) | |
download | PSP.git-8e00906e0517b335a6c33f682334bda3c1eadb69.tar.gz PSP.git-8e00906e0517b335a6c33f682334bda3c1eadb69.tar.xz PSP.git-8e00906e0517b335a6c33f682334bda3c1eadb69.zip |
Line finally done
-rw-r--r-- | .codelite/.tern-port | 2 | ||||
-rw-r--r-- | .codelite/PSP.session | 18 | ||||
-rw-r--r-- | .codelite/PSP.tags | bin | 80476160 -> 80476160 bytes | |||
-rw-r--r-- | .codelite/compilation.db | bin | 24576 -> 24576 bytes | |||
-rw-r--r-- | .codelite/compile_commands.json | 8 | ||||
-rw-r--r-- | .codelite/refactoring.db | bin | 520192 -> 520192 bytes | |||
-rw-r--r-- | Project/Element.h | 7 | ||||
-rw-r--r-- | Project/Line.cpp | 74 | ||||
-rw-r--r-- | Project/Line.h | 27 | ||||
-rw-r--r-- | Project/Project.mk | 2 | ||||
-rw-r--r-- | Project/Release/Bus.cpp.o | bin | 28409 -> 28972 bytes | |||
-rw-r--r-- | Project/Release/Element.cpp.o | bin | 13507 -> 14070 bytes | |||
-rw-r--r-- | Project/Release/Line.cpp.o | bin | 37471 -> 39241 bytes | |||
-rw-r--r-- | Project/Release/PSP-UFU.exe | bin | 3287771 -> 3290651 bytes | |||
-rw-r--r-- | Project/Release/Workspace.cpp.o | bin | 113675 -> 114623 bytes | |||
-rw-r--r-- | Project/Workspace.cpp | 34 |
16 files changed, 126 insertions, 46 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port index 8fe3316..a40d0e4 100644 --- a/.codelite/.tern-port +++ b/.codelite/.tern-port @@ -1 +1 @@ -55053
\ No newline at end of file +57419
\ No newline at end of file diff --git a/.codelite/PSP.session b/.codelite/PSP.session index b3371e9..6ec6b04 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="2" Name="m_selectedTab"/> + <int Value="7" 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="493" Name="FirstVisibleLine"/> - <int Value="494" Name="CurrentLine"/> + <int Value="238" Name="FirstVisibleLine"/> + <int Value="262" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> @@ -19,8 +19,8 @@ </TabInfo> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Bus.cpp" Name="FileName"/> - <int Value="72" Name="FirstVisibleLine"/> - <int Value="106" Name="CurrentLine"/> + <int Value="190" Name="FirstVisibleLine"/> + <int Value="97" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> @@ -41,21 +41,21 @@ <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Element.h" Name="FileName"/> <int Value="56" Name="FirstVisibleLine"/> - <int Value="68" Name="CurrentLine"/> + <int Value="67" 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="3" Name="FirstVisibleLine"/> - <int Value="18" Name="CurrentLine"/> + <int Value="20" 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="304" Name="FirstVisibleLine"/> - <int Value="334" Name="CurrentLine"/> + <int Value="0" Name="FirstVisibleLine"/> + <int Value="27" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> diff --git a/.codelite/PSP.tags b/.codelite/PSP.tags Binary files differindex e60cc61..6c8329c 100644 --- a/.codelite/PSP.tags +++ b/.codelite/PSP.tags diff --git a/.codelite/compilation.db b/.codelite/compilation.db Binary files differindex 0b0e4e5..00c5615 100644 --- a/.codelite/compilation.db +++ b/.codelite/compilation.db diff --git a/.codelite/compile_commands.json b/.codelite/compile_commands.json index c4e61b3..6269964 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/Bus.cpp.o -MF./Release/Bus.cpp.o.d -MM Bus.cpp", - "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Bus.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/Line.cpp.o -MF./Release/Line.cpp.o.d -MM Line.cpp", + "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Line.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/Bus.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/Bus.cpp.o -I. -I.", - "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Bus.cpp" + "command": "C:/TDM-GCC-64/bin/g++.exe -c C:/Users/Thales/Documents/GitHub/PSP/Project/Line.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/Line.cpp.o -I. -I.", + "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Line.cpp" }]
\ No newline at end of file diff --git a/.codelite/refactoring.db b/.codelite/refactoring.db Binary files differindex e55b6d9..9e05231 100644 --- a/.codelite/refactoring.db +++ b/.codelite/refactoring.db diff --git a/Project/Element.h b/Project/Element.h index 0b2d4be..bccd993 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -67,9 +67,10 @@ class Element virtual void AddPoint(wxPoint2DDouble point) {} virtual void StartMove(wxPoint2DDouble position); virtual void Move(wxPoint2DDouble position); - virtual void MoveNode(Element* parent, wxPoint2DDouble position){}; - virtual bool NodeContains(wxPoint2DDouble position) { return false; }; - virtual bool SetNodeParent(Element* parent) { return false; }; + 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 RotateNode(Element* parent) {} virtual wxPoint2DDouble GetSwitchPoint(Element* parent, wxPoint2DDouble parentPoint, diff --git a/Project/Line.cpp b/Project/Line.cpp index 8b17ade..0cc5d11 100644 --- a/Project/Line.cpp +++ b/Project/Line.cpp @@ -64,7 +64,24 @@ void Line::Draw(wxPoint2DDouble translation, double scale) const } } -wxCursor Line::GetBestPickboxCursor() const { return wxCURSOR_SIZING; } +void Line::Move(wxPoint2DDouble position) +{ + if(!m_parentList[0]) { + m_pointList[0] = m_movePts[0] + position - m_moveStartPt; + UpdateSwitchesPosition(); + } + if(!m_parentList[1]) { + m_pointList[m_pointList.size() - 1] = m_movePts[m_pointList.size() - 1] + position - m_moveStartPt; + UpdateSwitchesPosition(); + } + + if(!m_parentList[0] && !m_parentList[1]) { + for(int i = 2; i < (int)m_pointList.size() - 2; i++) { + m_pointList[i] = m_movePts[i] + position - m_moveStartPt; + } + } +} + bool Line::AddParent(Element* parent, wxPoint2DDouble position) { if(parent) { @@ -334,22 +351,38 @@ bool Line::SetNodeParent(Element* parent) if(parent->Intersects(nodeRect)) { if(m_activeNodeID == 1) { - // if(m_parentList[1] == parent){ - // m_activeNodeID = 0; - // return false; - //} + // Check if the user is trying to connect the same bus. + if(m_parentList[1] == parent) { + m_activeNodeID = 0; + return false; + } m_parentList[0] = parent; + + // Centralize the node on bus. + wxPoint2DDouble parentPt = parent->RotateAtPosition( + m_pointList[0], -parent->GetAngle()); // Rotate click to horizontal position. + parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. + parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); + m_pointList[0] = parentPt; + UpdateSwitchesPosition(); return true; } if(m_activeNodeID == 2) { - // if(m_parentList[0] == parent) { - // m_activeNodeID = 0; - // return false; - //} + if(m_parentList[0] == parent) { + m_activeNodeID = 0; + return false; + } m_parentList[1] = parent; + + wxPoint2DDouble parentPt = + parent->RotateAtPosition(m_pointList[m_pointList.size() - 1], -parent->GetAngle()); + parentPt.m_y = parent->GetPosition().m_y; + parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); + m_pointList[m_pointList.size() - 1] = parentPt; + UpdateSwitchesPosition(); return true; } @@ -363,3 +396,26 @@ bool Line::SetNodeParent(Element* parent) // m_activeNodeID = 0; return false; } + +void Line::UpdateNodes() +{ + 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; + UpdateSwitchesPosition(); + } + } + if(m_parentList[1]) { + wxRect2DDouble nodeRect = wxRect2DDouble(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, 10 + 2.0 * m_borderSize); + + if(!m_parentList[1]->Intersects(nodeRect)) { + m_parentList[1] = NULL; + UpdateSwitchesPosition(); + } + } +} diff --git a/Project/Line.h b/Project/Line.h index 7374e29..596b1a4 100644 --- a/Project/Line.h +++ b/Project/Line.h @@ -12,29 +12,30 @@ class Line : public Element ~Line(); virtual bool Contains(wxPoint2DDouble position) const; virtual void Draw(wxPoint2DDouble translation, double scale) const; - virtual void Move(wxPoint2DDouble position) {} - virtual void StartMove(wxPoint2DDouble position); + virtual void Move(wxPoint2DDouble position); + virtual void StartMove(wxPoint2DDouble position); virtual void MoveNode(Element* parent, wxPoint2DDouble position); - virtual bool NodeContains(wxPoint2DDouble position); - virtual bool SetNodeParent(Element* parent); - virtual wxCursor GetBestPickboxCursor() const; + virtual bool NodeContains(wxPoint2DDouble position); + virtual bool SetNodeParent(Element* parent); + virtual void UpdateNodes(); + virtual wxCursor GetBestPickboxCursor() const { return wxCURSOR_SIZING; } 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 Rotate() {} - virtual void RotateNode(Element* parent); + virtual void RotateNode(Element* parent); virtual void AddPoint(wxPoint2DDouble point); - virtual bool GetContextMenu(wxMenu& menu); - virtual void RemoveNode(wxPoint2DDouble point); - virtual void AddNode(wxPoint2DDouble point); + virtual bool GetContextMenu(wxMenu& menu); + virtual void RemoveNode(wxPoint2DDouble point); + virtual void AddNode(wxPoint2DDouble point); -protected: - void UpdateSwitchesPosition(); - double PointToLineDistance(wxPoint2DDouble point, int* segmentNumber = NULL) const; + protected: + void UpdateSwitchesPosition(); + double PointToLineDistance(wxPoint2DDouble point, int* segmentNumber = NULL) const; std::vector<wxPoint2DDouble> m_pointList; bool m_inserted = false; - std::vector<wxPoint2DDouble> m_movePts; + std::vector<wxPoint2DDouble> m_movePts; }; #endif // LINE_H diff --git a/Project/Project.mk b/Project/Project.mk index 7bc77fb..5053587 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=24/08/2016 +Date :=25/08/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/Bus.cpp.o b/Project/Release/Bus.cpp.o Binary files differindex 0f40d0a..b51f1c5 100644 --- a/Project/Release/Bus.cpp.o +++ b/Project/Release/Bus.cpp.o diff --git a/Project/Release/Element.cpp.o b/Project/Release/Element.cpp.o Binary files differindex 5c4b04c..e306643 100644 --- a/Project/Release/Element.cpp.o +++ b/Project/Release/Element.cpp.o diff --git a/Project/Release/Line.cpp.o b/Project/Release/Line.cpp.o Binary files differindex 327c980..8f96b12 100644 --- a/Project/Release/Line.cpp.o +++ b/Project/Release/Line.cpp.o diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe Binary files differindex 64a92de..1515590 100644 --- a/Project/Release/PSP-UFU.exe +++ b/Project/Release/PSP-UFU.exe diff --git a/Project/Release/Workspace.cpp.o b/Project/Release/Workspace.cpp.o Binary files differindex 99752d1..96bf767 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp index 68e8464..22d3858 100644 --- a/Project/Workspace.cpp +++ b/Project/Workspace.cpp @@ -247,6 +247,27 @@ void Workspace::OnLeftClickUp(wxMouseEvent& event) for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { Element* element = *it; + // The user was moving a pickbox. + if(m_mode == MODE_MOVE_PICKBOX) { + // Catch only the element that have the pickbox shown. + if(element->IsPickboxShown()) { + // If the element is a bus, check if a node is outside. + if(typeid(*element) == typeid(Bus)) { + // Get all the bus children. + for(int i = 0; i < (int)m_elementList.size(); i++) { + Element* child = m_elementList[i]; + for(int j = 0; j < (int)child->GetParentList().size(); j++) { + Element* parent = child->GetParentList()[j]; + // The child have a parent that is the element. + if(parent == element) { + child->UpdateNodes(); + } + } + } + } + } + } + if(m_mode == MODE_SELECTION_RECT) { if(element->Intersects(m_selectionRect)) { element->SetSelected(); @@ -393,9 +414,10 @@ void Workspace::OnMouseMotion(wxMouseEvent& event) // Parent's element moving... for(int i = 0; i < (int)element->GetParentList().size(); i++) { Element* parent = element->GetParentList()[i]; - if(parent) { - if(parent->IsSelected()) { - element->MoveNode(parent, m_camera->ScreenToWorld(event.GetPosition())); + if(parent) { + if(parent->IsSelected()) { + element->MoveNode(parent, + m_camera->ScreenToWorld(event.GetPosition())); } } } @@ -492,9 +514,9 @@ void Workspace::OnKeyDown(wxKeyEvent& event) // Parent's element rotating... for(int i = 0; i < (int)element->GetParentList().size(); i++) { Element* parent = element->GetParentList()[i]; - if(parent) { // Check if parent is not null - if(parent->IsSelected()) { - element->RotateNode(parent); + if(parent) { // Check if parent is not null + if(parent->IsSelected()) { + element->RotateNode(parent); } } } |