diff options
author | Thales1330 <thaleslima.ufu@gmail.com> | 2016-09-08 18:54:52 -0300 |
---|---|---|
committer | Thales1330 <thaleslima.ufu@gmail.com> | 2016-09-08 18:54:52 -0300 |
commit | 122d124108384bb4579b6d96956b931d7221d3c1 (patch) | |
tree | 72a94cb2d317d37665dac1905d3d3660c48100fb | |
parent | fb8a409d7e35735afc9d28bfc0d7b49974f0d3a2 (diff) | |
download | PSP.git-122d124108384bb4579b6d96956b931d7221d3c1.tar.gz PSP.git-122d124108384bb4579b6d96956b931d7221d3c1.tar.xz PSP.git-122d124108384bb4579b6d96956b931d7221d3c1.zip |
Fit implemented
-rw-r--r-- | .codelite/.tern-port | 2 | ||||
-rw-r--r-- | .codelite/.tern-project | 2 | ||||
-rw-r--r-- | .codelite/PSP.session | 44 | ||||
-rw-r--r-- | .codelite/PSP.tags | bin | 80629760 -> 80641024 bytes | |||
-rw-r--r-- | .codelite/compilation.db | bin | 40960 -> 40960 bytes | |||
-rw-r--r-- | .codelite/compile_commands.json | 8 | ||||
-rw-r--r-- | .codelite/refactoring.db | bin | 743424 -> 784384 bytes | |||
-rw-r--r-- | Project/Element.cpp | 49 | ||||
-rw-r--r-- | Project/Element.h | 2 | ||||
-rw-r--r-- | Project/Line.cpp | 15 | ||||
-rw-r--r-- | Project/Line.h | 3 | ||||
-rw-r--r-- | Project/MainFrame.cpp | 58 | ||||
-rw-r--r-- | Project/Project.mk | 7 | ||||
-rw-r--r-- | Project/Release/Branch.cpp.o | bin | 25477 -> 25561 bytes | |||
-rw-r--r-- | Project/Release/Bus.cpp.o | bin | 27468 -> 27568 bytes | |||
-rw-r--r-- | Project/Release/Capacitor.cpp.o | bin | 31047 -> 31147 bytes | |||
-rw-r--r-- | Project/Release/Element.cpp.o | bin | 38751 -> 39429 bytes | |||
-rw-r--r-- | Project/Release/IndMotor.cpp.o | bin | 25364 -> 25448 bytes | |||
-rw-r--r-- | Project/Release/Inductor.cpp.o | bin | 30963 -> 31063 bytes | |||
-rw-r--r-- | Project/Release/Line.cpp.o | bin | 39879 -> 40230 bytes | |||
-rw-r--r-- | Project/Release/Line.cpp.o.d | 8 | ||||
-rw-r--r-- | Project/Release/Load.cpp.o | bin | 31792 -> 31892 bytes | |||
-rw-r--r-- | Project/Release/Machines.cpp.o | bin | 31354 -> 31438 bytes | |||
-rw-r--r-- | Project/Release/MainFrame.cpp.o | bin | 131736 -> 132672 bytes | |||
-rw-r--r-- | Project/Release/PSP-UFU.exe | bin | 3389590 -> 3395427 bytes | |||
-rw-r--r-- | Project/Release/Shunt.cpp.o | bin | 26146 -> 26246 bytes | |||
-rw-r--r-- | Project/Release/SyncGenerator.cpp.o | bin | 25796 -> 25880 bytes | |||
-rw-r--r-- | Project/Release/SyncMotor.cpp.o | bin | 22193 -> 22277 bytes | |||
-rw-r--r-- | Project/Release/Transformer.cpp.o | bin | 34264 -> 34348 bytes | |||
-rw-r--r-- | Project/Release/Workspace.cpp.o | bin | 125606 -> 129162 bytes | |||
-rw-r--r-- | Project/Workspace.cpp | 112 | ||||
-rw-r--r-- | Project/Workspace.h | 10 |
32 files changed, 246 insertions, 74 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port index 3b51bed..1517c3b 100644 --- a/.codelite/.tern-port +++ b/.codelite/.tern-port @@ -1 +1 @@ -51228
\ No newline at end of file +63593
\ 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 cef6f1c..550e910 100644 --- a/.codelite/PSP.session +++ b/.codelite/PSP.session @@ -5,29 +5,36 @@ <TabInfoArray Name="TabInfoArray"> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Workspace.cpp" Name="FileName"/> - <int Value="551" Name="FirstVisibleLine"/> - <int Value="572" Name="CurrentLine"/> + <int Value="671" Name="FirstVisibleLine"/> + <int Value="688" 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="28" Name="FirstVisibleLine"/> - <int Value="51" Name="CurrentLine"/> + <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\MainFrame.cpp" Name="FileName"/> + <int Value="139" Name="FirstVisibleLine"/> + <int Value="163" 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="83" Name="FirstVisibleLine"/> - <int Value="0" Name="CurrentLine"/> + <int Value="302" Name="FirstVisibleLine"/> + <int Value="330" 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="120" Name="FirstVisibleLine"/> - <int Value="128" Name="CurrentLine"/> + <int Value="0" Name="FirstVisibleLine"/> + <int Value="6" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> @@ -39,13 +46,6 @@ <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> - <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\MainFrame.cpp" Name="FileName"/> - <int Value="254" Name="FirstVisibleLine"/> - <int Value="276" 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="35" Name="FirstVisibleLine"/> <int Value="58" Name="CurrentLine"/> @@ -59,6 +59,20 @@ <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> + <TabInfo> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Line.cpp" Name="FileName"/> + <int Value="278" Name="FirstVisibleLine"/> + <int Value="300" 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="5" 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 5add8fa..23a06a2 100644 --- a/.codelite/PSP.tags +++ b/.codelite/PSP.tags diff --git a/.codelite/compilation.db b/.codelite/compilation.db Binary files differindex 5a74966..d4c2464 100644 --- a/.codelite/compilation.db +++ b/.codelite/compilation.db diff --git a/.codelite/compile_commands.json b/.codelite/compile_commands.json index ba59d01..747a12e 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/MainFrame.cpp.o -MF./Release/MainFrame.cpp.o.d -MM MainFrame.cpp", - "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\MainFrame.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/Workspace.cpp.o -MF./Release/Workspace.cpp.o.d -MM Workspace.cpp", + "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\Workspace.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/MainFrame.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/MainFrame.cpp.o -I. -I.", - "file": "C:\\Users\\Thales\\Documents\\GitHub\\PSP\\Project\\MainFrame.cpp" + "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" }]
\ No newline at end of file diff --git a/.codelite/refactoring.db b/.codelite/refactoring.db Binary files differindex 21d7829..e842e90 100644 --- a/.codelite/refactoring.db +++ b/.codelite/refactoring.db diff --git a/Project/Element.cpp b/Project/Element.cpp index bd04944..170be4a 100644 --- a/Project/Element.cpp +++ b/Project/Element.cpp @@ -295,15 +295,44 @@ void Element::SetOnline(bool online) void Element::GeneralMenuItens(wxMenu& menu) { - 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* 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); + deleteItem->SetBitmap(wxImage("data\\images\\menu\\delete16.png")); + menu.Append(deleteItem); +} + +void Element::CalculateBoundaries(wxPoint2DDouble& leftUp, wxPoint2DDouble& rightBottom) const +{ + // Check rect corners boundaries. + + // Get rectangle corners + wxPoint2DDouble rectCorner[4] = {m_rect.GetLeftTop(), m_rect.GetLeftBottom(), m_rect.GetRightBottom(), + m_rect.GetRightTop()}; + // Rotate corners. + for(int i = 0; i < 4; ++i) { + rectCorner[i] = RotateAtPosition(rectCorner[i], m_angle); + } + leftUp = rectCorner[0]; + rightBottom = rectCorner[0]; + for(int i = 1; i < 4; ++i) { + if(rectCorner[i].m_x < leftUp.m_x) leftUp.m_x = rectCorner[i].m_x; + if(rectCorner[i].m_y < leftUp.m_y) leftUp.m_y = rectCorner[i].m_y; + if(rectCorner[i].m_x > rightBottom.m_x) rightBottom.m_x = rectCorner[i].m_x; + if(rectCorner[i].m_y > rightBottom.m_y) rightBottom.m_y = rectCorner[i].m_y; + } + + // Check points list boundaries. + for(int i = 0; i < (int)m_pointList.size(); i++) { + if(m_pointList[i].m_x < leftUp.m_x) leftUp.m_x = m_pointList[i].m_x; + if(m_pointList[i].m_y < leftUp.m_y) leftUp.m_y = m_pointList[i].m_y; + if(m_pointList[i].m_x > rightBottom.m_x) rightBottom.m_x = m_pointList[i].m_x; + if(m_pointList[i].m_y > rightBottom.m_y) rightBottom.m_y = m_pointList[i].m_y; + } } diff --git a/Project/Element.h b/Project/Element.h index 688a4e3..4033b20 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -126,6 +126,8 @@ class Element virtual wxPoint2DDouble GetMoveStartPosition() const { return m_moveStartPt; } virtual wxPoint2DDouble GetMovePosition() const { return m_movePos; } + virtual void CalculateBoundaries(wxPoint2DDouble& leftUp, wxPoint2DDouble& rightBottom) const; + virtual void GeneralMenuItens(wxMenu& menu); protected: std::vector<Element*> m_parentList; diff --git a/Project/Line.cpp b/Project/Line.cpp index 0ee9cc8..be805a1 100644 --- a/Project/Line.cpp +++ b/Project/Line.cpp @@ -293,3 +293,18 @@ void Line::AddNode(wxPoint2DDouble point) } UpdateSwitchesPosition(); } + +void Line::CalculateBoundaries(wxPoint2DDouble& leftUp, wxPoint2DDouble& rightBottom) const +{ + if(m_pointList.size() > 0) { + // Check points list boundaries. + leftUp = m_pointList[0]; + rightBottom = m_pointList[0]; + for(int i = 1; i < (int)m_pointList.size(); i++) { + if(m_pointList[i].m_x < leftUp.m_x) leftUp.m_x = m_pointList[i].m_x; + if(m_pointList[i].m_y < leftUp.m_y) leftUp.m_y = m_pointList[i].m_y; + if(m_pointList[i].m_x > rightBottom.m_x) rightBottom.m_x = m_pointList[i].m_x; + if(m_pointList[i].m_y > rightBottom.m_y) rightBottom.m_y = m_pointList[i].m_y; + } + } +} diff --git a/Project/Line.h b/Project/Line.h index d2b3547..edf4d07 100644 --- a/Project/Line.h +++ b/Project/Line.h @@ -3,6 +3,8 @@ #include "Branch.h" +#include <wx/log.h> + class Line : public Branch { public: @@ -22,6 +24,7 @@ class Line : public Branch virtual bool GetContextMenu(wxMenu& menu); virtual void RemoveNode(wxPoint2DDouble point); virtual void AddNode(wxPoint2DDouble point); + virtual void CalculateBoundaries(wxPoint2DDouble& leftUp, wxPoint2DDouble& rightBottom) const; protected: double PointToLineDistance(wxPoint2DDouble point, int* segmentNumber = NULL) const; diff --git a/Project/MainFrame.cpp b/Project/MainFrame.cpp index d7eb329..b02869f 100644 --- a/Project/MainFrame.cpp +++ b/Project/MainFrame.cpp @@ -134,7 +134,13 @@ void MainFrame::OnChartsClick(wxRibbonButtonBarEvent& event) {} void MainFrame::OnCloseClick(wxRibbonButtonBarEvent& event) {} void MainFrame::OnCopyClick(wxRibbonButtonBarEvent& event) {} void MainFrame::OnDataReportClick(wxRibbonButtonBarEvent& event) {} -void MainFrame::OnDeleteClick(wxRibbonButtonBarEvent& event) {} +void MainFrame::OnDeleteClick(wxRibbonButtonBarEvent& event) +{ + Workspace* workspace = (Workspace*)m_auiNotebook->GetCurrentPage(); + if(workspace) { + workspace->DeleteSelectedElements(); + } +} void MainFrame::OnDisableSolutionClick(wxRibbonButtonBarEvent& event) { m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true); @@ -150,8 +156,40 @@ void MainFrame::OnEnableSolutionClick(wxRibbonButtonBarEvent& event) void MainFrame::OnExpImpClick(wxRibbonButtonBarEvent& event) {} void MainFrame::OnFaultClick(wxRibbonButtonBarEvent& event) {} -void MainFrame::OnFitClick(wxRibbonButtonBarEvent& event) {} -void MainFrame::OnMoveClick(wxRibbonButtonBarEvent& event) {} +void MainFrame::OnFitClick(wxRibbonButtonBarEvent& event) +{ + Workspace* workspace = (Workspace*)m_auiNotebook->GetCurrentPage(); + if(workspace) { + workspace->Fit(); + } +} +void MainFrame::OnMoveClick(wxRibbonButtonBarEvent& event) +{ + Workspace* workspace = (Workspace*)m_auiNotebook->GetCurrentPage(); + if(workspace) { + auto elementList = workspace->GetElementList(); + // Calculate the average position of selected elements. + wxPoint2DDouble averagePos(0, 0); + int numSelElements = 0; + for(auto it = elementList.begin(); it != elementList.end(); it++) { + Element* element = *it; + if(element->IsSelected()) { + averagePos += element->GetPosition(); + numSelElements++; + } + } + averagePos = + wxPoint2DDouble(averagePos.m_x / double(numSelElements), averagePos.m_y / double(numSelElements)); + // Set the move position to the average of selected elements. + for(auto it = elementList.begin(); it != elementList.end(); it++) { + Element* element = *it; + if(element->IsSelected()) { + element->StartMove(averagePos); + } + } + workspace->SetWorkspaceMode(MODE_MOVE_ELEMENT); + } +} void MainFrame::OnOpenClick(wxRibbonButtonBarEvent& event) {} void MainFrame::OnPSPGuideClick(wxRibbonButtonBarEvent& event) {} void MainFrame::OnPasteClick(wxRibbonButtonBarEvent& event) {} @@ -270,7 +308,7 @@ void MainFrame::NotebookPageClosing(wxAuiNotebookEvent& event) auto it = m_workspaceList.begin(); while(it != m_workspaceList.end()) { if(*it == m_auiNotebook->GetCurrentPage()) { - //delete *it; //Memory leak? + // delete *it; //Memory leak? m_workspaceList.erase(it); break; } @@ -280,15 +318,15 @@ void MainFrame::NotebookPageClosing(wxAuiNotebookEvent& event) } void MainFrame::OnRotClockClick(wxRibbonButtonBarEvent& event) { - Workspace* workspace = (Workspace*)m_auiNotebook->GetCurrentPage(); - if(workspace) { - workspace->RotateSelectedElements(); + Workspace* workspace = (Workspace*)m_auiNotebook->GetCurrentPage(); + if(workspace) { + workspace->RotateSelectedElements(); } } void MainFrame::OnRotCounterClockClick(wxRibbonButtonBarEvent& event) { - Workspace* workspace = (Workspace*)m_auiNotebook->GetCurrentPage(); - if(workspace) { - workspace->RotateSelectedElements(false); + Workspace* workspace = (Workspace*)m_auiNotebook->GetCurrentPage(); + if(workspace) { + workspace->RotateSelectedElements(false); } } diff --git a/Project/Project.mk b/Project/Project.mk index e7aa817..ea6903d 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,8 +13,8 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=07/09/2016 -CodeLitePath :="C:/Program Files (x86)/CodeLite" +Date :=08/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,8 +61,7 @@ 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) \ diff --git a/Project/Release/Branch.cpp.o b/Project/Release/Branch.cpp.o Binary files differindex 7b22814..ac261ea 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 c661451..cba2571 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 aca015c..4140a76 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 c8c256d..c47e811 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 5fb49e0..3b19ad8 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 66fde49..93ef042 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 a26221e..01b4296 100644 --- a/Project/Release/Line.cpp.o +++ b/Project/Release/Line.cpp.o diff --git a/Project/Release/Line.cpp.o.d b/Project/Release/Line.cpp.o.d index 613ca05..7770ea4 100644 --- a/Project/Release/Line.cpp.o.d +++ b/Project/Release/Line.cpp.o.d @@ -108,7 +108,9 @@ Release/Line.cpp.o: Line.cpp Line.h Branch.h Element.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 + C:/wxWidgets-3.1.0/include/wx/msw/menu.h \ + C:/wxWidgets-3.1.0/include/wx/log.h \ + C:/wxWidgets-3.1.0/include/wx/generic/logg.h Line.h: @@ -337,3 +339,7 @@ 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: + +C:/wxWidgets-3.1.0/include/wx/log.h: + +C:/wxWidgets-3.1.0/include/wx/generic/logg.h: diff --git a/Project/Release/Load.cpp.o b/Project/Release/Load.cpp.o Binary files differindex 4b47c7c..a556d7c 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 f479d24..b396ef0 100644 --- a/Project/Release/Machines.cpp.o +++ b/Project/Release/Machines.cpp.o diff --git a/Project/Release/MainFrame.cpp.o b/Project/Release/MainFrame.cpp.o Binary files differindex fb5123f..8293d99 100644 --- a/Project/Release/MainFrame.cpp.o +++ b/Project/Release/MainFrame.cpp.o diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe Binary files differindex e71ee5b..8507810 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 afdb286..beb8986 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 2344e49..ddb1f01 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 6d1912d..9f0e8b4 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 670b60f..dfdac78 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 44c689c..856db1b 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp index 541e4d0..59bd4e0 100644 --- a/Project/Workspace.cpp +++ b/Project/Workspace.cpp @@ -37,8 +37,8 @@ void Camera::SetScale(wxPoint2DDouble screenPoint, double delta) m_scale += delta; // Limits: 5% - 300% - if(m_scale < 0.05) m_scale = 0.05; - if(m_scale > 3.0) m_scale = 3.0; + if(m_scale < m_zoomMin) m_scale = m_zoomMin; + if(m_scale > m_zoomMax) m_scale = m_zoomMax; m_translation += screenPoint * (1.0 - m_scale) / m_scale; } @@ -140,7 +140,7 @@ void Workspace::SetViewport() void Workspace::OnLeftClickDown(wxMouseEvent& event) { bool foundElement = false; - if(m_mode == MODE_INSERT) { + if(m_mode == MODE_INSERT || m_mode == MODE_DRAG_INSERT) { // Get the last element inserted on the list. Element* newElement = *(m_elementList.end() - 1); for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) { @@ -381,6 +381,7 @@ void Workspace::OnMouseMotion(wxMouseEvent& event) break; case MODE_DRAG: + case MODE_DRAG_INSERT: { m_camera->SetTranslation(event.GetPosition()); redraw = true; @@ -505,19 +506,26 @@ void Workspace::OnMouseMotion(wxMouseEvent& event) void Workspace::OnMiddleDown(wxMouseEvent& event) { - if(m_mode != MODE_INSERT) { - // Set to drag mode. + // Set to drag mode. + if(m_mode != MODE_INSERT && m_mode != MODE_DRAG_INSERT) { m_mode = MODE_DRAG; - m_camera->StartTranslation(m_camera->ScreenToWorld(event.GetPosition())); } + else + { + m_mode = MODE_DRAG_INSERT; + } + m_camera->StartTranslation(m_camera->ScreenToWorld(event.GetPosition())); UpdateStatusBar(); } void Workspace::OnMiddleUp(wxMouseEvent& event) { - if(m_mode != MODE_INSERT) { + if(m_mode != MODE_INSERT && m_mode != MODE_DRAG_INSERT) { // Set to edit mode back. m_mode = MODE_EDIT; } + else if(m_mode == MODE_DRAG_INSERT) { + m_mode = MODE_INSERT; + } UpdateStatusBar(); } void Workspace::OnScroll(wxMouseEvent& event) @@ -548,29 +556,19 @@ 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--); - } + DeleteSelectedElements(); + } + break; + case 'F': + { + if(event.GetModifiers() == wxMOD_SHIFT) { + Fit(); } - Redraw(); } break; case 'R': // Rotate the selected elements. { - RotateSelectedElements(event.GetModifiers() != wxMOD_SHIFT); + RotateSelectedElements(event.GetModifiers() != wxMOD_SHIFT); } break; case 'B': // Insert a bus. @@ -594,8 +592,8 @@ void Workspace::OnKeyDown(wxKeyEvent& event) m_statusBar->SetStatusText( _("Insert Load: Click on a buses, ESC to cancel.")); } - else - { // Insert a power line. + else // Insert a power line. + { Line* newLine = new Line(); m_elementList.push_back(newLine); m_mode = MODE_INSERT; @@ -697,6 +695,7 @@ void Workspace::UpdateStatusBar() break; case MODE_INSERT: + case MODE_DRAG_INSERT: { m_statusBar->SetStatusText(_("MODE: INSERT"), 1); } @@ -834,3 +833,62 @@ void Workspace::RotateSelectedElements(bool clockwise) } Redraw(); } + +void Workspace::DeleteSelectedElements() +{ + 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(); +} + +void Workspace::Fit() +{ + if(m_elementList.size() > 0) { + wxPoint2DDouble leftUpCorner(0, 0); + wxPoint2DDouble rightDownCorner(0, 0); + m_elementList[0]->CalculateBoundaries(leftUpCorner, rightDownCorner); + + for(auto it = m_elementList.begin() + 1; it != m_elementList.end(); it++) { + Element* element = *it; + wxPoint2DDouble leftUp; + wxPoint2DDouble rightDown; + element->CalculateBoundaries(leftUp, rightDown); + if(leftUp.m_x < leftUpCorner.m_x) leftUpCorner.m_x = leftUp.m_x; + if(leftUp.m_y < leftUpCorner.m_y) leftUpCorner.m_y = leftUp.m_y; + if(rightDown.m_x > rightDownCorner.m_x) rightDownCorner.m_x = rightDown.m_x; + if(rightDown.m_y > rightDownCorner.m_y) rightDownCorner.m_y = rightDown.m_y; + } + + int width = 0.0; + int height = 0.0; + GetSize(&width, &height); + + double scaleX = double(width) / (rightDownCorner.m_x - leftUpCorner.m_x); + double scaleY = double(height) / (rightDownCorner.m_y - leftUpCorner.m_y); + + double scale = scaleX < scaleY ? scaleX : scaleY; + if(scale > m_camera->GetZoomMax()) scale = m_camera->GetZoomMax(); + if(scale < m_camera->GetZoomMin()) scale = m_camera->GetZoomMin(); + + m_camera->SetScale(scale); + + m_camera->StartTranslation(leftUpCorner); + m_camera->SetTranslation(wxPoint2DDouble(0, 0)); + Redraw(); + } +} diff --git a/Project/Workspace.h b/Project/Workspace.h index d673976..5bea745 100644 --- a/Project/Workspace.h +++ b/Project/Workspace.h @@ -28,6 +28,7 @@ enum WorkspaceMode MODE_MOVE_PICKBOX, MODE_MOVE_NODE, MODE_DRAG, + MODE_DRAG_INSERT, MODE_INSERT, MODE_SELECTION_RECT }; @@ -42,6 +43,7 @@ class Workspace : public WorkspaceBase wxString GetName() const { return m_name; } std::vector<Element*> GetElementList() const { return m_elementList; } WorkspaceMode GetWorkspaceMode() const { return m_mode; } + Camera* GetCamera() const { return m_camera; } void SetName(wxString name) { m_name = name; } void SetElementList(std::vector<Element*> elementList) { m_elementList = elementList; } @@ -50,6 +52,8 @@ class Workspace : public WorkspaceBase void Redraw() { m_glCanvas->Refresh(); } void RotateSelectedElements(bool clockwise = true); + void DeleteSelectedElements(); + void Fit(); protected: virtual void OnLeftDoubleClick(wxMouseEvent& event); @@ -89,6 +93,7 @@ class Camera ~Camera(); void SetScale(wxPoint2DDouble screenPoint, double delta); + void SetScale(double scale) { m_scale = scale; } void SetTranslation(wxPoint2DDouble screenPoint); void StartTranslation(wxPoint2DDouble startPoint) { this->m_translationStartPt = startPoint; } void UpdateMousePosition(wxPoint2DDouble mousePosition) { this->m_mousePosition = mousePosition; } @@ -96,6 +101,8 @@ class Camera wxPoint2DDouble GetTranslation() const { return m_translation; } wxPoint2DDouble GetMousePosition(bool worldCoords = true) const; wxPoint2DDouble ScreenToWorld(wxPoint2DDouble screenCoords) const; + double GetZoomMin() const { return m_zoomMin; } + double GetZoomMax() const { return m_zoomMax; } protected: wxPoint2DDouble m_translation; @@ -103,6 +110,9 @@ class Camera double m_scale; wxPoint2DDouble m_mousePosition; + + double m_zoomMin = 0.05; + double m_zoomMax = 3.0; }; #endif // WORKSPACE_H |