diff options
-rw-r--r-- | .codelite/.tern-port | 2 | ||||
-rw-r--r-- | .codelite/.tern-project | 2 | ||||
-rw-r--r-- | .codelite/PSP.session | 24 | ||||
-rw-r--r-- | .codelite/PSP.tags | bin | 80395264 -> 80401408 bytes | |||
-rw-r--r-- | .codelite/compilation.db | bin | 21504 -> 21504 bytes | |||
-rw-r--r-- | .codelite/compile_commands.json | 8 | ||||
-rw-r--r-- | .codelite/refactoring.db | bin | 350208 -> 378880 bytes | |||
-rw-r--r-- | Project/Bus.cpp | 60 | ||||
-rw-r--r-- | Project/Bus.h | 4 | ||||
-rw-r--r-- | Project/Element.h | 17 | ||||
-rw-r--r-- | Project/Project.mk | 5 | ||||
-rw-r--r-- | Project/Release/Bus.cpp.o | bin | 12812 -> 13972 bytes | |||
-rw-r--r-- | Project/Release/Element.cpp.o | bin | 4511 -> 4511 bytes | |||
-rw-r--r-- | Project/Release/PSP-UFU.exe | bin | 3235524 -> 3238405 bytes | |||
-rw-r--r-- | Project/Release/Workspace.cpp.o | bin | 80040 -> 86265 bytes | |||
-rw-r--r-- | Project/Workspace.cpp | 38 | ||||
-rw-r--r-- | Project/Workspace.h | 1 |
17 files changed, 129 insertions, 32 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port index a262d80..013f236 100644 --- a/.codelite/.tern-port +++ b/.codelite/.tern-port @@ -1 +1 @@ -54635
\ No newline at end of file +60393
\ No newline at end of file diff --git a/.codelite/.tern-project b/.codelite/.tern-project index 09b6465..d5969c6 100644 --- a/.codelite/.tern-project +++ b/.codelite/.tern-project @@ -8,6 +8,8 @@ "node_resolve": { }, "node": { + }, + "complete_strings": { } } }
\ No newline at end of file diff --git a/.codelite/PSP.session b/.codelite/PSP.session index 931aa54..8811242 100644 --- a/.codelite/PSP.session +++ b/.codelite/PSP.session @@ -1,6 +1,6 @@ <?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="4" Name="m_selectedTab"/> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\PSP.workspace" Name="m_workspaceName"/> <TabInfoArray Name="TabInfoArray"> <TabInfo> @@ -19,43 +19,43 @@ </TabInfo> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Workspace.cpp" Name="FileName"/> - <int Value="106" Name="FirstVisibleLine"/> - <int Value="127" Name="CurrentLine"/> + <int Value="215" Name="FirstVisibleLine"/> + <int Value="240" 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="21" Name="FirstVisibleLine"/> - <int Value="25" Name="CurrentLine"/> + <int Value="18" Name="FirstVisibleLine"/> + <int Value="17" 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="33" Name="FirstVisibleLine"/> - <int Value="61" Name="CurrentLine"/> + <int Value="102" Name="FirstVisibleLine"/> + <int Value="131" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Bus.h" Name="FileName"/> <int Value="0" Name="FirstVisibleLine"/> - <int Value="12" Name="CurrentLine"/> + <int Value="3" 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="23" Name="FirstVisibleLine"/> - <int Value="53" Name="CurrentLine"/> + <int Value="0" Name="FirstVisibleLine"/> + <int Value="4" 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="21" Name="FirstVisibleLine"/> - <int Value="47" Name="CurrentLine"/> + <int Value="34" Name="FirstVisibleLine"/> + <int Value="73" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> diff --git a/.codelite/PSP.tags b/.codelite/PSP.tags Binary files differindex e94278f..2907d31 100644 --- a/.codelite/PSP.tags +++ b/.codelite/PSP.tags diff --git a/.codelite/compilation.db b/.codelite/compilation.db Binary files differindex 18b7af8..f17b297 100644 --- a/.codelite/compilation.db +++ b/.codelite/compilation.db diff --git a/.codelite/compile_commands.json b/.codelite/compile_commands.json index 747a12e..c4e61b3 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/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 -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/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" }]
\ No newline at end of file diff --git a/.codelite/refactoring.db b/.codelite/refactoring.db Binary files differindex 980be8d..7f41429 100644 --- a/.codelite/refactoring.db +++ b/.codelite/refactoring.db diff --git a/Project/Bus.cpp b/Project/Bus.cpp index c188beb..fe12c5b 100644 --- a/Project/Bus.cpp +++ b/Project/Bus.cpp @@ -6,10 +6,12 @@ Bus::Bus(wxPoint2DDouble position) : Element() m_height = 5.0; SetPosition(position); } + Bus::~Bus() {} + void Bus::Draw(wxPoint2DDouble translation, double scale) const { - // Draw selection (behind) + // Draw selection (layer 1) if(m_selected) { // If the object is selected, the matrix is reset to remove scale effects applied to it, thus keeping the // edges with fixed sizes for all zoom levels. @@ -34,7 +36,7 @@ void Bus::Draw(wxPoint2DDouble translation, double scale) const DrawRectangle(pts); glPopMatrix(); } - // Draw element (middle) + // Draw element (layer 2) // Push the current matrix on stack. glPushMatrix(); // Rotate the matrix around the object position. @@ -47,7 +49,7 @@ void Bus::Draw(wxPoint2DDouble translation, double scale) const // Pop the old matrix back. glPopMatrix(); - // Draw pickbox (above) + // Draw pickbox (layer 3) if(m_showPickbox) { glPushMatrix(); glLoadIdentity(); @@ -65,12 +67,35 @@ void Bus::Draw(wxPoint2DDouble translation, double scale) const glPopMatrix(); } } + bool Bus::Contains(wxPoint2DDouble position) const { wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle); return m_rect.Contains(ptR); } -int Bus::PickboxContains(wxPoint2DDouble position) const { return 0; } + +bool Bus::PickboxContains(wxPoint2DDouble position) +{ + wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle); + + wxPoint2DDouble center(m_position.m_x + m_width / 2.0, m_position.m_y); + wxRect2DDouble rectRight(center.m_x - 5.0, center.m_y - 5.0, 10.0, 10.0); + + center = wxPoint2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y); + wxRect2DDouble rectLeft(center.m_x - 5.0, center.m_y - 5.0, 10.0, 10.0); + + if(rectRight.Contains(ptR)){ + m_activePickboxID = ID_PB_RIGHT; + return true; + } + else if(rectLeft.Contains(ptR)){ + m_activePickboxID = ID_PB_LEFT; + return true; + } + + return false; +} + wxCursor Bus::GetBestPickboxCursor() const { double angle = m_angle; @@ -87,7 +112,32 @@ wxCursor Bus::GetBestPickboxCursor() const return wxCursor(wxCURSOR_ARROW); } -void Bus::MovePickbox(wxPoint2DDouble position, int pickboxID) {} + +void Bus::MovePickbox(wxPoint2DDouble position) +{ + wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle); + + double dx = 0.0; + if(m_activePickboxID == ID_PB_RIGHT) + dx = ptR.m_x - m_position.m_x - m_width / 2.0; + else if(m_activePickboxID == ID_PB_LEFT) + dx = m_position.m_x - m_width / 2.0 - ptR.m_x ; + + if(m_width + dx < 20.0) return; + + if(m_activePickboxID == ID_PB_RIGHT) { + m_position.m_x += (dx / 2.0) * std::cos(wxDegToRad(m_angle)); + m_position.m_y += (dx / 2.0) * std::sin(wxDegToRad(m_angle)); + } + else if(m_activePickboxID == ID_PB_LEFT) { + m_position.m_x -= (dx / 2.0) * std::cos(wxDegToRad(m_angle)); + m_position.m_y -= (dx / 2.0) * std::sin(wxDegToRad(m_angle)); + } + m_width += dx; + + SetPosition(m_position); +} + void Bus::Rotate() { m_angle += 45.0; diff --git a/Project/Bus.h b/Project/Bus.h index 80bb206..6725fd7 100644 --- a/Project/Bus.h +++ b/Project/Bus.h @@ -12,8 +12,8 @@ class Bus : public Element virtual void Draw(wxPoint2DDouble translation, double scale) const; virtual void Rotate(); virtual wxCursor GetBestPickboxCursor() const; - virtual void MovePickbox(wxPoint2DDouble position, int pickboxID); - virtual int PickboxContains(wxPoint2DDouble position) const; + virtual void MovePickbox(wxPoint2DDouble position); + virtual bool PickboxContains(wxPoint2DDouble position); }; #endif // BUS_H diff --git a/Project/Element.h b/Project/Element.h index 7023704..bb74910 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -5,6 +5,17 @@ #include <wx/cursor.h> #include <GL/gl.h> +enum PickboxID +{ + ID_PB_NONE = 0, + ID_PB_RIGHT, + ID_PB_LEFT, + ID_PB_RIGHT_BOTTOM, + ID_PB_RIGHT_TOP, + ID_PB_LEFT_BOTTOM, + ID_PB_LEFT_TOP +}; + class Element { public: @@ -33,8 +44,8 @@ class Element virtual void Draw(wxPoint2DDouble translation, double scale) const = 0; virtual void Rotate() = 0; virtual bool Contains(wxPoint2DDouble position) const = 0; - virtual int PickboxContains(wxPoint2DDouble position) const = 0; - virtual void MovePickbox(wxPoint2DDouble position, int pickboxID) = 0; + virtual bool PickboxContains(wxPoint2DDouble position) = 0; + virtual void MovePickbox(wxPoint2DDouble position) = 0; virtual wxCursor GetBestPickboxCursor() const = 0; // General methods @@ -59,6 +70,8 @@ class Element bool m_selected = false; bool m_dragging = false; bool m_showPickbox = false; + + PickboxID m_activePickboxID = ID_PB_NONE; }; #endif // ELEMENT_H diff --git a/Project/Project.mk b/Project/Project.mk index 21f4153..5862e1b 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -14,7 +14,7 @@ CurrentFilePath := CurrentFileFullPath := User :=Thales Date :=02/08/2016 -CodeLitePath :="C:/Program Files/CodeLite" +CodeLitePath :="C:/Program Files (x86)/CodeLite" LinkerName :=C:/TDM-GCC-64/bin/g++.exe SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC ObjectSuffix :=.o @@ -61,7 +61,8 @@ AS := C:/TDM-GCC-64/bin/as.exe ## ## User defined environment variables ## -CodeLiteDir:=C:\Program Files\CodeLite +CodeLiteDir:=C:\Program Files (x86)\CodeLite +UNIT_TEST_PP_SRC_DIR:=C:\UnitTest++-1.3 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)/Bus.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) \ diff --git a/Project/Release/Bus.cpp.o b/Project/Release/Bus.cpp.o Binary files differindex 8ed6829..8458037 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 860759e..44786c5 100644 --- a/Project/Release/Element.cpp.o +++ b/Project/Release/Element.cpp.o diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe Binary files differindex 7ddd459..319dd3e 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 093cc4f..f9aaf30 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp index e1e5fb2..bae40e6 100644 --- a/Project/Workspace.cpp +++ b/Project/Workspace.cpp @@ -124,7 +124,7 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event) Element* element = *it; if(element->Contains(m_camera->ScreenToWorld(event.GetPosition()))) { element->SetSelected(); - element->ShowPickbox(); + element->ShowPickbox(); } else if(!event.ControlDown()) { @@ -138,7 +138,13 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event) event.Skip(); } -void Workspace::OnLeftClickUp(wxMouseEvent& event) {} +void Workspace::OnLeftClickUp(wxMouseEvent& event) +{ + if(m_mode == MODE_EDIT_ELEMENT) { + m_mode = MODE_EDIT; + } +} + void Workspace::OnKeyDown(wxKeyEvent& event) { char key = event.GetUnicodeKey(); @@ -207,18 +213,41 @@ void Workspace::OnMouseMotion(wxMouseEvent& event) } break; + case MODE_EDIT_ELEMENT: case MODE_EDIT: { + bool foundPickbox = false; std::vector<Element*>::iterator it = m_elementList.begin(); while(it != m_elementList.end()) { Element* element = *it; if(element->IsSelected()) { - if(element->Contains(m_camera->ScreenToWorld(event.GetPosition()))) { + // MODE_EDIT_ELEMENT is a flag which indicates that a pickbox is being dragged. He + // will work like a shortcut to method Element::MovePickbox until a mouse button is + // released. + if(element->Contains(m_camera->ScreenToWorld(event.GetPosition())) || + m_mode == MODE_EDIT_ELEMENT) + { element->ShowPickbox(); + if(element->PickboxContains(m_camera->ScreenToWorld(event.GetPosition())) || + m_mode == MODE_EDIT_ELEMENT) + { + foundPickbox = true; + SetCursor(element->GetBestPickboxCursor()); + if(event.Dragging()) { + m_mode = MODE_EDIT_ELEMENT; + element->MovePickbox( + m_camera->ScreenToWorld(event.GetPosition())); + } + } + else if(!foundPickbox) + { + SetCursor(wxCURSOR_ARROW); + } } - else + else if(!foundPickbox) { element->ShowPickbox(false); + SetCursor(wxCURSOR_ARROW); } } it++; @@ -275,6 +304,7 @@ void Workspace::UpdateStatusBar() } break; + case MODE_EDIT_ELEMENT: case MODE_EDIT: { m_statusBar->SetStatusText(wxT("")); diff --git a/Project/Workspace.h b/Project/Workspace.h index e093105..3c847a3 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -15,6 +15,7 @@ class Element; enum WorkspaceMode { MODE_EDIT = 0, + MODE_EDIT_ELEMENT, MODE_DRAG, MODE_INSERT }; |