diff options
author | Thales1330 <thaleslima.ufu@gmail.com> | 2016-12-29 19:03:16 -0200 |
---|---|---|
committer | Thales1330 <thaleslima.ufu@gmail.com> | 2016-12-29 19:03:16 -0200 |
commit | 7aed88dbcf9d37a1f40c8cad115f055c4d69e7a9 (patch) | |
tree | f8c67b159a77c61b1a67ffa8ae8f39959cdfbb0f /Project/Transformer.cpp | |
parent | c5343c718cf80620c2fc7452a4315f7ddb9e5826 (diff) | |
download | PSP.git-7aed88dbcf9d37a1f40c8cad115f055c4d69e7a9.tar.gz PSP.git-7aed88dbcf9d37a1f40c8cad115f055c4d69e7a9.tar.xz PSP.git-7aed88dbcf9d37a1f40c8cad115f055c4d69e7a9.zip |
Parent/child optimization implemented
And others bugfixes.
Diffstat (limited to 'Project/Transformer.cpp')
-rw-r--r-- | Project/Transformer.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Project/Transformer.cpp b/Project/Transformer.cpp index 2ba6850..4dfa7f4 100644 --- a/Project/Transformer.cpp +++ b/Project/Transformer.cpp @@ -28,6 +28,7 @@ bool Transformer::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. @@ -43,6 +44,7 @@ bool Transformer::AddParent(Element* parent, wxPoint2DDouble position) // Second bus. else if(parent != m_parentList[0]) { 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. @@ -220,12 +222,18 @@ void Transformer::MoveNode(Element* parent, 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; + } } 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; + } } } |