summaryrefslogtreecommitdiffstats
path: root/Project/Line.cpp
diff options
context:
space:
mode:
authorThales1330 <thaleslima.ufu@gmail.com>2016-12-29 19:03:16 -0200
committerThales1330 <thaleslima.ufu@gmail.com>2016-12-29 19:03:16 -0200
commit7aed88dbcf9d37a1f40c8cad115f055c4d69e7a9 (patch)
treef8c67b159a77c61b1a67ffa8ae8f39959cdfbb0f /Project/Line.cpp
parentc5343c718cf80620c2fc7452a4315f7ddb9e5826 (diff)
downloadPSP.git-7aed88dbcf9d37a1f40c8cad115f055c4d69e7a9.tar.gz
PSP.git-7aed88dbcf9d37a1f40c8cad115f055c4d69e7a9.tar.xz
PSP.git-7aed88dbcf9d37a1f40c8cad115f055c4d69e7a9.zip
Parent/child optimization implemented
And others bugfixes.
Diffstat (limited to 'Project/Line.cpp')
-rw-r--r--Project/Line.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/Project/Line.cpp b/Project/Line.cpp
index 3180cf8..4b7f6c4 100644
--- a/Project/Line.cpp
+++ b/Project/Line.cpp
@@ -119,6 +119,7 @@ bool Line::AddParent(Element* parent, wxPoint2DDouble position)
if(m_parentList.size() == 0) {
m_position = position;
m_parentList.push_back(parent);
+ parent->AddChild(this);
wxPoint2DDouble parentPt =
parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position.
parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus.
@@ -149,6 +150,7 @@ bool Line::AddParent(Element* parent, wxPoint2DDouble position)
}
m_parentList.push_back(parent);
+ parent->AddChild(this);
wxPoint2DDouble parentPt =
parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position.
parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus.
@@ -240,14 +242,21 @@ void Line::MoveNode(Element* parent, wxPoint2DDouble position)
}
}
} else {
+ // If parent is setted to NULL for the firts time, remove the parent child
if(m_activeNodeID == 1) {
m_pointList[0] = m_movePts[0] + position - m_moveStartPt;
- m_parentList[0] = NULL;
- m_online = false;
+ if(m_parentList[0]) {
+ m_parentList[0]->RemoveChild(this);
+ m_parentList[0] = NULL;
+ m_online = false;
+ }
} else if(m_activeNodeID == 2) {
m_pointList[m_pointList.size() - 1] = m_movePts[m_pointList.size() - 1] + position - m_moveStartPt;
- m_parentList[1] = NULL;
- m_online = false;
+ if(m_parentList[1]) {
+ m_parentList[1]->RemoveChild(this);
+ m_parentList[1] = NULL;
+ m_online = false;
+ }
}
}