diff options
author | Thales1330 <thaleslima.ufu@gmail.com> | 2016-08-29 17:26:50 -0300 |
---|---|---|
committer | Thales1330 <thaleslima.ufu@gmail.com> | 2016-08-29 17:26:50 -0300 |
commit | 06e57f5c75772dcba902e3032c756f79090f3424 (patch) | |
tree | aef78570496dae05d2945e0190bd4591ec799cd0 | |
parent | 8e00906e0517b335a6c33f682334bda3c1eadb69 (diff) | |
download | PSP.git-06e57f5c75772dcba902e3032c756f79090f3424.tar.gz PSP.git-06e57f5c75772dcba902e3032c756f79090f3424.tar.xz PSP.git-06e57f5c75772dcba902e3032c756f79090f3424.zip |
Delete implemented
-rw-r--r-- | .codelite/.tern-port | 2 | ||||
-rw-r--r-- | .codelite/PSP.session | 20 | ||||
-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 -> 531456 bytes | |||
-rw-r--r-- | Project/Bus.cpp | 1 | ||||
-rw-r--r-- | Project/Element.h | 4 | ||||
-rw-r--r-- | Project/Line.cpp | 11 | ||||
-rw-r--r-- | Project/Line.h | 1 | ||||
-rw-r--r-- | Project/Project.mk | 2 | ||||
-rw-r--r-- | Project/Release/Bus.cpp.o | bin | 28972 -> 30860 bytes | |||
-rw-r--r-- | Project/Release/Element.cpp.o | bin | 14070 -> 14638 bytes | |||
-rw-r--r-- | Project/Release/Line.cpp.o | bin | 39241 -> 40746 bytes | |||
-rw-r--r-- | Project/Release/PSP-UFU.exe | bin | 3290651 -> 3294109 bytes | |||
-rw-r--r-- | Project/Release/Workspace.cpp.o | bin | 114623 -> 117977 bytes | |||
-rw-r--r-- | Project/Workspace.cpp | 66 | ||||
-rw-r--r-- | Project/Workspace.h | 1 |
18 files changed, 97 insertions, 19 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port index a40d0e4..980fde0 100644 --- a/.codelite/.tern-port +++ b/.codelite/.tern-port @@ -1 +1 @@ -57419
\ No newline at end of file +50602
\ No newline at end of file diff --git a/.codelite/PSP.session b/.codelite/PSP.session index 6ec6b04..7fdc807 100644 --- a/.codelite/PSP.session +++ b/.codelite/PSP.session @@ -1,26 +1,26 @@ <?xml version="1.0" encoding="UTF-8"?> <Session Name="C:\Users\Thales\Documents\GitHub\PSP\PSP.workspace"> - <int Value="7" 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="238" Name="FirstVisibleLine"/> - <int Value="262" Name="CurrentLine"/> + <int Value="207" Name="FirstVisibleLine"/> + <int Value="219" 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="24" Name="FirstVisibleLine"/> - <int Value="21" Name="CurrentLine"/> + <int Value="38" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Bus.cpp" Name="FileName"/> <int Value="190" Name="FirstVisibleLine"/> - <int Value="97" Name="CurrentLine"/> + <int Value="207" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> @@ -40,22 +40,22 @@ </TabInfo> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Element.h" Name="FileName"/> - <int Value="56" Name="FirstVisibleLine"/> - <int Value="67" Name="CurrentLine"/> + <int Value="0" Name="FirstVisibleLine"/> + <int Value="28" 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="20" Name="CurrentLine"/> + <int Value="19" 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="0" Name="FirstVisibleLine"/> - <int Value="27" Name="CurrentLine"/> + <int Value="269" Name="FirstVisibleLine"/> + <int Value="286" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> diff --git a/.codelite/PSP.tags b/.codelite/PSP.tags Binary files differindex 6c8329c..08ab4a5 100644 --- a/.codelite/PSP.tags +++ b/.codelite/PSP.tags diff --git a/.codelite/compilation.db b/.codelite/compilation.db Binary files differindex 00c5615..a974fb2 100644 --- a/.codelite/compilation.db +++ b/.codelite/compilation.db diff --git a/.codelite/compile_commands.json b/.codelite/compile_commands.json index 6269964..f71231e 100644 --- a/.codelite/compile_commands.json +++ b/.codelite/compile_commands.json @@ -1,9 +1,17 @@ [{ "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" + }, { + "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/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" + }, { + "directory": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project", "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 9e05231..38f07df 100644 --- a/.codelite/refactoring.db +++ b/.codelite/refactoring.db diff --git a/Project/Bus.cpp b/Project/Bus.cpp index 847308d..b2f1ff1 100644 --- a/Project/Bus.cpp +++ b/Project/Bus.cpp @@ -225,5 +225,6 @@ bool Bus::GetContextMenu(wxMenu& menu) { menu.Append(ID_EDIT_BUS, _("Edit bus")); menu.Append(ID_ROTATE, _("Rotate")); + menu.Append(ID_DELETE, _("Delete bus")); return true; } diff --git a/Project/Element.h b/Project/Element.h index bccd993..ec7496a 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -25,7 +25,8 @@ enum ContextMenuID ID_LINE_ADD_NODE, ID_LINE_REMOVE_NODE, - ID_ROTATE + ID_ROTATE, + ID_DELETE }; class Element @@ -71,6 +72,7 @@ class Element virtual bool NodeContains(wxPoint2DDouble position) { return false; } 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, diff --git a/Project/Line.cpp b/Project/Line.cpp index 0cc5d11..6c5457e 100644 --- a/Project/Line.cpp +++ b/Project/Line.cpp @@ -284,6 +284,7 @@ bool Line::GetContextMenu(wxMenu& menu) { menu.Append(ID_LINE_REMOVE_NODE, _("Remove node")); } + menu.Append(ID_DELETE, _("Delete line")); return true; } @@ -419,3 +420,13 @@ void Line::UpdateNodes() } } } + +void Line::RemoveParent(Element* parent) +{ + for(int i=0; i<2; i++) { + if(parent == m_parentList[i]) { + m_parentList[i] = NULL; + UpdateSwitchesPosition(); + } + } +} diff --git a/Project/Line.h b/Project/Line.h index 596b1a4..983293a 100644 --- a/Project/Line.h +++ b/Project/Line.h @@ -17,6 +17,7 @@ class Line : public Element virtual void MoveNode(Element* parent, wxPoint2DDouble position); virtual bool NodeContains(wxPoint2DDouble position); virtual bool SetNodeParent(Element* parent); + virtual void RemoveParent(Element* parent); virtual void UpdateNodes(); virtual wxCursor GetBestPickboxCursor() const { return wxCURSOR_SIZING; } virtual bool AddParent(Element* parent, wxPoint2DDouble position); diff --git a/Project/Project.mk b/Project/Project.mk index 5053587..e221228 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=25/08/2016 +Date :=29/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 b51f1c5..8774df4 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 e306643..9080983 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 8f96b12..80137cf 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 1515590..2790ce1 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 96bf767..2b551da 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp index 22d3858..10e58d3 100644 --- a/Project/Workspace.cpp +++ b/Project/Workspace.cpp @@ -226,14 +226,21 @@ void Workspace::OnRightClickDown(wxMouseEvent& event) menu.Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(Workspace::OnPopupClick), NULL, this); PopupMenu(&menu); + redraw = true; } element->ResetPickboxes(); - redraw = true; + + if(redraw){ + Redraw(); + redraw = false; + } + // If the last element was removed using the menu, we must leave the "search for" to prevent error. + break; } } + } } - if(redraw) Redraw(); } void Workspace::OnLeftClickUp(wxMouseEvent& event) @@ -507,6 +514,28 @@ void Workspace::OnKeyDown(wxKeyEvent& event) } } break; + case WXK_DELETE: // Delete selected elements + { + for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { + Element* element = *it; + + if(element->IsSelected()) { + for(auto itp = m_elementList.begin(); itp != m_elementList.end(); ++itp) { + Element* child = *itp; + // Parent's element being deleted... + for(int i = 0; i < (int)child->GetParentList().size(); i++) { + Element* parent = child->GetParentList()[i]; + if(parent == element) { + child->RemoveParent(parent); + } + } + } + m_elementList.erase(it--); + } + } + Redraw(); + } + break; case 'R': // Rotate the selected elements. { for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { @@ -626,17 +655,42 @@ void Workspace::OnPopupClick(wxCommandEvent& event) { element->Rotate(); for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { - Element* nonEditedElement = *it; + Element* iElement = *it; // Parent's element rotating... - for(int i = 0; i < (int)nonEditedElement->GetParentList().size(); i++) { - Element* parent = nonEditedElement->GetParentList()[i]; + for(int i = 0; i < (int)iElement->GetParentList().size(); i++) { + Element* parent = iElement->GetParentList()[i]; if(parent == element) { - nonEditedElement->RotateNode(parent); + iElement->RotateNode(parent); } } } Redraw(); } break; + case ID_DELETE: + { + for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { + Element* iElement = *it; + + if(element == iElement) { + for(auto itp = m_elementList.begin(); itp != m_elementList.end(); ++itp) { + Element* child = *itp; + // Parent's element being deleted... + for(int i = 0; i < (int)child->GetParentList().size(); i++) { + Element* parent = child->GetParentList()[i]; + if(parent == element) { + child->RemoveParent(parent); + } + } + } + m_elementList.erase(it--); + } + } + Redraw(); + } + break; } + delete menu; } + +void Workspace::DeleteElement(Element* element) {} diff --git a/Project/Workspace.h b/Project/Workspace.h index 3f25130..d6e1803 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -36,6 +36,7 @@ class Workspace : public WorkspaceBase void SetName(wxString name) { m_name = name; } std::vector<Element*> GetElementList() { return m_elementList; } void Redraw() { m_glCanvas->Refresh(); } + void DeleteElement(Element* element); protected: virtual void OnRightClickDown(wxMouseEvent& event); |