summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.codelite/.tern-port2
-rw-r--r--.codelite/PSP.session24
-rw-r--r--.codelite/PSP.tagsbin80453632 -> 80454656 bytes
-rw-r--r--.codelite/compilation.dbbin24576 -> 24576 bytes
-rw-r--r--.codelite/compile_commands.json8
-rw-r--r--.codelite/refactoring.dbbin465920 -> 465920 bytes
-rw-r--r--Project/Line.cpp43
-rw-r--r--Project/Line.h4
-rw-r--r--Project/Project.mk2
-rw-r--r--Project/Release/Line.cpp.obin29756 -> 35021 bytes
-rw-r--r--Project/Release/PSP-UFU.exebin3277391 -> 3281466 bytes
-rw-r--r--Project/Release/Workspace.cpp.obin110214 -> 110488 bytes
-rw-r--r--Project/Workspace.cpp22
13 files changed, 79 insertions, 26 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port
index 4ff5a54..08eb751 100644
--- a/.codelite/.tern-port
+++ b/.codelite/.tern-port
@@ -1 +1 @@
-61966 \ No newline at end of file
+62299 \ No newline at end of file
diff --git a/.codelite/PSP.session b/.codelite/PSP.session
index 4b8ed91..9f7b334 100644
--- a/.codelite/PSP.session
+++ b/.codelite/PSP.session
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<Session Name="C:\Users\Thales\Documents\GitHub\PSP\PSP.workspace">
- <int Value="0" 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="0" Name="FirstVisibleLine"/>
- <int Value="527" Name="CurrentLine"/>
+ <int Value="532" Name="FirstVisibleLine"/>
+ <int Value="530" 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="15" Name="FirstVisibleLine"/>
- <int Value="36" Name="CurrentLine"/>
+ <int Value="66" Name="FirstVisibleLine"/>
+ <int Value="88" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
@@ -40,28 +40,28 @@
</TabInfo>
<TabInfo>
<wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\Element.h" Name="FileName"/>
- <int Value="0" Name="FirstVisibleLine"/>
- <int Value="27" Name="CurrentLine"/>
+ <int Value="55" Name="FirstVisibleLine"/>
+ <int Value="74" 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="25" Name="CurrentLine"/>
+ <int Value="11" Name="FirstVisibleLine"/>
+ <int Value="31" 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="209" Name="FirstVisibleLine"/>
- <int Value="232" Name="CurrentLine"/>
+ <int Value="242" Name="FirstVisibleLine"/>
+ <int Value="264" 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="153" Name="FirstVisibleLine"/>
+ <int Value="141" Name="FirstVisibleLine"/>
<int Value="177" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
diff --git a/.codelite/PSP.tags b/.codelite/PSP.tags
index 2250a35..933f32f 100644
--- a/.codelite/PSP.tags
+++ b/.codelite/PSP.tags
Binary files differ
diff --git a/.codelite/compilation.db b/.codelite/compilation.db
index df4c5a6..1a9ef43 100644
--- a/.codelite/compilation.db
+++ b/.codelite/compilation.db
Binary files differ
diff --git a/.codelite/compile_commands.json b/.codelite/compile_commands.json
index 747a12e..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/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/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/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/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
index c24b8e5..a9cc56b 100644
--- a/.codelite/refactoring.db
+++ b/.codelite/refactoring.db
Binary files differ
diff --git a/Project/Line.cpp b/Project/Line.cpp
index 54418d4..6710fbe 100644
--- a/Project/Line.cpp
+++ b/Project/Line.cpp
@@ -32,7 +32,7 @@ void Line::Draw(wxPoint2DDouble translation, double scale) const
if(pointList.size() > 0) {
DrawCircle(pointList[0], 5.0 + m_borderSize, 10, GL_POLYGON);
if(m_inserted) {
- DrawCircle(pointList[pointList.size() - 1], 5.0 + +m_borderSize, 10, GL_POLYGON);
+ DrawCircle(pointList[pointList.size() - 1], 5.0 + m_borderSize, 10, GL_POLYGON);
}
}
}
@@ -120,7 +120,7 @@ void Line::MovePickbox(wxPoint2DDouble position)
for(int i = 2; i < (int)m_pointList.size() - 2; i++) {
if(m_activePickboxID == i) {
m_pointList[i] = m_movePts[i] + position - m_moveStartPt;
- UpdateSwitchesPosition();
+ UpdateSwitchesPosition();
}
}
}
@@ -191,7 +191,7 @@ void Line::UpdateSwitchesPosition()
GetSwitchPoint(m_parentList[1], m_pointList[m_pointList.size() - 1], m_pointList[m_pointList.size() - 3]);
}
-double Line::PointToLineDistance(wxPoint2DDouble point) const
+double Line::PointToLineDistance(wxPoint2DDouble point, int* segmentNumber) const
{
//[Ref] http://geomalgorithms.com/a02-_lines.html
double distance = 100.0; // Big initial distance.
@@ -222,7 +222,10 @@ double Line::PointToLineDistance(wxPoint2DDouble point) const
p2.m_y * p1.m_x) /
std::sqrt(std::pow(p2.m_y - p1.m_y, 2) + std::pow(p2.m_x - p1.m_x, 2));
}
- if(d < distance) distance = d;
+ if(d < distance) {
+ distance = d;
+ if(segmentNumber) *segmentNumber = i;
+ }
}
return distance;
@@ -230,6 +233,34 @@ double Line::PointToLineDistance(wxPoint2DDouble point) const
bool Line::GetContextMenu(wxMenu& menu)
{
- menu.Append(ID_EDIT_LINE, _("Edit line"));
- return true;
+ menu.Append(ID_EDIT_LINE, _("Edit line"));
+ if(m_activePickboxID == ID_PB_NONE) {
+ menu.Append(ID_LINE_ADD_NODE, _("Insert node"));
+ }
+ else
+ {
+ menu.Append(ID_LINE_REMOVE_NODE, _("Remove node"));
+ }
+ return true;
+}
+
+void Line::RemoveNode(wxPoint2DDouble point)
+{
+ if(PickboxContains(point)) {
+ for(int i = 2; i < (int)m_pointList.size() - 2; i++) {
+ if(m_activePickboxID == i) {
+ m_pointList.erase(m_pointList.begin() + i);
+ break;
+ }
+ }
+ }
+}
+
+void Line::AddNode(wxPoint2DDouble point)
+{
+ int segmentNumber = 0;
+ PointToLineDistance(point, &segmentNumber);
+ if(segmentNumber > 0 && segmentNumber < (int)m_pointList.size() - 2) {
+ m_pointList.insert(m_pointList.begin() + segmentNumber + 1, point);
+ }
}
diff --git a/Project/Line.h b/Project/Line.h
index 08a2b36..9293baa 100644
--- a/Project/Line.h
+++ b/Project/Line.h
@@ -24,10 +24,12 @@ class Line : public Element
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);
protected:
void UpdateSwitchesPosition();
- double PointToLineDistance(wxPoint2DDouble point) const;
+ double PointToLineDistance(wxPoint2DDouble point, int* segmentNumber = NULL) const;
std::vector<wxPoint2DDouble> m_pointList;
bool m_inserted = false;
std::vector<wxPoint2DDouble> m_movePts;
diff --git a/Project/Project.mk b/Project/Project.mk
index e5e39f0..5c5c3b1 100644
--- a/Project/Project.mk
+++ b/Project/Project.mk
@@ -13,7 +13,7 @@ CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=Thales
-Date :=18/08/2016
+Date :=19/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/Line.cpp.o b/Project/Release/Line.cpp.o
index 587e66d..6717cee 100644
--- a/Project/Release/Line.cpp.o
+++ b/Project/Release/Line.cpp.o
Binary files differ
diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe
index 04fb13d..604327e 100644
--- a/Project/Release/PSP-UFU.exe
+++ b/Project/Release/PSP-UFU.exe
Binary files differ
diff --git a/Project/Release/Workspace.cpp.o b/Project/Release/Workspace.cpp.o
index 9d4cb18..a3a3cfa 100644
--- a/Project/Release/Workspace.cpp.o
+++ b/Project/Release/Workspace.cpp.o
Binary files differ
diff --git a/Project/Workspace.cpp b/Project/Workspace.cpp
index 26c913b..d180b2b 100644
--- a/Project/Workspace.cpp
+++ b/Project/Workspace.cpp
@@ -202,11 +202,13 @@ void Workspace::OnLeftClickDown(wxMouseEvent& event)
void Workspace::OnRightClickDown(wxMouseEvent& event)
{
+ bool redraw = false;
if(m_mode == MODE_EDIT) {
for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) {
Element* element = *it;
if(element->IsSelected()) {
if(element->Contains(m_camera->ScreenToWorld(event.GetPosition()))) {
+ element->ShowPickbox(false);
wxMenu menu;
if(element->GetContextMenu(menu)) {
menu.SetClientData(element);
@@ -214,10 +216,13 @@ void Workspace::OnRightClickDown(wxMouseEvent& event)
wxCommandEventHandler(Workspace::OnPopupClick), NULL, this);
PopupMenu(&menu);
}
+ element->ResetPickboxes();
+ redraw = true;
}
}
}
}
+ if(redraw) Redraw();
}
void Workspace::OnLeftClickUp(wxMouseEvent& event)
@@ -520,9 +525,23 @@ void Workspace::OnPopupClick(wxCommandEvent& event)
wxMessageBox("Edit line!");
}
break;
+ case ID_LINE_ADD_NODE:
+ {
+ Line* line = (Line*)element;
+ line->AddNode(m_camera->GetMousePosition());
+ Redraw();
+ }
+ break;
+ case ID_LINE_REMOVE_NODE:
+ {
+ Line* line = (Line*)element;
+ line->RemoveNode(m_camera->GetMousePosition());
+ Redraw();
+ }
+ break;
case ID_ROTATE:
{
- element->Rotate();
+ element->Rotate();
for(auto it = m_elementList.begin(); it != m_elementList.end(); ++it) {
Element* nonEditedElement = *it;
// Parent's element rotating...
@@ -535,5 +554,6 @@ void Workspace::OnPopupClick(wxCommandEvent& event)
}
Redraw();
}
+ break;
}
}