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/Machines.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Project/Machines.cpp') diff --git a/Project/Machines.cpp b/Project/Machines.cpp index bda8a7a..6377f08 100644 --- a/Project/Machines.cpp +++ b/Project/Machines.cpp @@ -9,6 +9,7 @@ bool Machines::AddParent(Element* parent, wxPoint2DDouble position) { if(parent) { 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. @@ -107,8 +108,11 @@ void Machines::MoveNode(Element* element, wxPoint2DDouble position) } else { 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; + } } } @@ -192,6 +196,7 @@ void Machines::UpdateNodes() 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); if(!m_parentList[0]->Intersects(nodeRect)) { + m_parentList[0]->RemoveChild(this); m_parentList[0] = NULL; m_online = false; UpdateSwitchesPosition(); -- cgit