| 94 | } |
| 95 | |
| 96 | bool mitk::PlanarFigure::AddControlPoint(const mitk::Point2D &point, int position) |
| 97 | { |
| 98 | // if we already have the maximum number of control points, do nothing |
| 99 | if (m_NumberOfControlPoints < this->GetMaximumNumberOfControlPoints()) |
| 100 | { |
| 101 | // if position has not been defined or position would be the last control point, just append the new one |
| 102 | // we also append a new point if we click onto the line between the first two control-points if the second |
| 103 | // control-point is selected |
| 104 | // -> special case for PlanarCross |
| 105 | if (position == -1 || position > (int)m_NumberOfControlPoints - 1 || (position == 1 && m_SelectedControlPoint == 2)) |
| 106 | { |
| 107 | if (m_ControlPoints.size() > this->GetMaximumNumberOfControlPoints() - 1) |
| 108 | { |
| 109 | // get rid of deprecated control points in the list. This is necessary |
| 110 | // as ::ResetNumberOfControlPoints() only sets the member, does not resize the list! |
| 111 | m_ControlPoints.resize(this->GetNumberOfControlPoints()); |
| 112 | } |
| 113 | |
| 114 | m_ControlPoints.push_back(this->ApplyControlPointConstraints(m_NumberOfControlPoints, point)); |
| 115 | m_SelectedControlPoint = m_NumberOfControlPoints; |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | // insert the point at the given position and set it as selected point |
| 120 | auto iter = m_ControlPoints.begin() + position; |
| 121 | m_ControlPoints.insert(iter, this->ApplyControlPointConstraints(position, point)); |
| 122 | for (unsigned int i = 0; i < m_ControlPoints.size(); ++i) |
| 123 | { |
| 124 | if (point == m_ControlPoints.at(i)) |
| 125 | { |
| 126 | m_SelectedControlPoint = i; |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | // polylines & helperpolylines need to be repainted |
| 132 | m_PolyLineUpToDate = false; |
| 133 | m_HelperLinesUpToDate = false; |
| 134 | m_FeaturesUpToDate = false; |
| 135 | |
| 136 | // one control point more |
| 137 | ++m_NumberOfControlPoints; |
| 138 | return true; |
| 139 | } |
| 140 | else |
| 141 | { |
| 142 | return false; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | bool mitk::PlanarFigure::SetControlPoint(unsigned int index, const Point2D &point, bool createIfDoesNotExist) |
| 147 | { |