From 122d124108384bb4579b6d96956b931d7221d3c1 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Thu, 8 Sep 2016 18:54:52 -0300 Subject: Fit implemented --- Project/Line.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Project/Line.cpp') diff --git a/Project/Line.cpp b/Project/Line.cpp index 0ee9cc8..be805a1 100644 --- a/Project/Line.cpp +++ b/Project/Line.cpp @@ -293,3 +293,18 @@ void Line::AddNode(wxPoint2DDouble point) } UpdateSwitchesPosition(); } + +void Line::CalculateBoundaries(wxPoint2DDouble& leftUp, wxPoint2DDouble& rightBottom) const +{ + if(m_pointList.size() > 0) { + // Check points list boundaries. + leftUp = m_pointList[0]; + rightBottom = m_pointList[0]; + for(int i = 1; i < (int)m_pointList.size(); i++) { + if(m_pointList[i].m_x < leftUp.m_x) leftUp.m_x = m_pointList[i].m_x; + if(m_pointList[i].m_y < leftUp.m_y) leftUp.m_y = m_pointList[i].m_y; + if(m_pointList[i].m_x > rightBottom.m_x) rightBottom.m_x = m_pointList[i].m_x; + if(m_pointList[i].m_y > rightBottom.m_y) rightBottom.m_y = m_pointList[i].m_y; + } + } +} -- cgit