From 7aed88dbcf9d37a1f40c8cad115f055c4d69e7a9 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Thu, 29 Dec 2016 19:03:16 -0200 Subject: Parent/child optimization implemented And others bugfixes. --- Project/Line.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'Project/Line.cpp') 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; + } } } -- cgit