25 : m_SelectedControlPoint(-1),
26 m_PreviewControlPointVisible(false),
27 m_FigurePlaced(false),
28 m_PlaneGeometry(nullptr),
29 m_PolyLineUpToDate(false),
30 m_HelperLinesUpToDate(false),
31 m_FeaturesUpToDate(false),
36 m_DisplaySize.first = 0.0;
37 m_DisplaySize.second = 0;
47 m_ControlPoints(other.m_ControlPoints),
48 m_NumberOfControlPoints(other.m_NumberOfControlPoints),
49 m_SelectedControlPoint(other.m_SelectedControlPoint),
50 m_PolyLines(other.m_PolyLines),
51 m_HelperPolyLines(other.m_HelperPolyLines),
52 m_PreviewControlPoint(other.m_PreviewControlPoint),
53 m_PreviewControlPointVisible(other.m_PreviewControlPointVisible),
54 m_FigurePlaced(other.m_FigurePlaced),
55 m_PlaneGeometry(other.m_PlaneGeometry),
56 m_PolyLineUpToDate(other.m_PolyLineUpToDate),
57 m_HelperLinesUpToDate(other.m_HelperLinesUpToDate),
58 m_FeaturesUpToDate(other.m_FeaturesUpToDate),
59 m_Features(other.m_Features),
60 m_FeaturesMTime(other.m_FeaturesMTime),
61 m_DisplaySize(other.m_DisplaySize)
64 for (
unsigned long i = 0; i < other.m_HelperPolyLinesToBePainted->Size(); ++i)
72 this->SetGeometry(geometry);
73 m_PlaneGeometry =
dynamic_cast<PlaneGeometry *
>(GetGeometry(0));
78 return m_PlaneGeometry;
84 if (closed !=
nullptr)
93 for (
unsigned int i = 0; i < this->GetNumberOfControlPoints(); ++i)
95 m_ControlPoints.push_back(this->ApplyControlPointConstraints(i, point));
98 m_FigurePlaced =
true;
99 m_SelectedControlPoint = 1;
105 if (m_NumberOfControlPoints < this->GetMaximumNumberOfControlPoints())
111 if (position == -1 || position > (
int)m_NumberOfControlPoints - 1 || (position == 1 && m_SelectedControlPoint == 2))
113 if (m_ControlPoints.size() > this->GetMaximumNumberOfControlPoints() - 1)
117 m_ControlPoints.resize(this->GetNumberOfControlPoints());
120 m_ControlPoints.push_back(this->ApplyControlPointConstraints(m_NumberOfControlPoints, point));
121 m_SelectedControlPoint = m_NumberOfControlPoints;
126 auto iter = m_ControlPoints.begin() + position;
127 m_ControlPoints.insert(iter, this->ApplyControlPointConstraints(position, point));
128 for (
unsigned int i = 0; i < m_ControlPoints.size(); ++i)
130 if (point == m_ControlPoints.at(i))
132 m_SelectedControlPoint = i;
138 m_PolyLineUpToDate =
false;
139 m_HelperLinesUpToDate =
false;
140 m_FeaturesUpToDate =
false;
143 ++m_NumberOfControlPoints;
154 bool controlPointSetCorrectly =
false;
155 if (createIfDoesNotExist)
157 if (m_NumberOfControlPoints <= index)
159 m_ControlPoints.push_back(this->ApplyControlPointConstraints(index, point));
160 m_NumberOfControlPoints++;
164 m_ControlPoints.at(index) = this->ApplyControlPointConstraints(index, point);
166 controlPointSetCorrectly =
true;
168 else if (index < m_NumberOfControlPoints)
170 m_ControlPoints.at(index) = this->ApplyControlPointConstraints(index, point);
171 controlPointSetCorrectly =
true;
178 if (controlPointSetCorrectly)
180 m_PolyLineUpToDate =
false;
181 m_HelperLinesUpToDate =
false;
182 m_FeaturesUpToDate =
false;
185 return controlPointSetCorrectly;
190 if ((m_SelectedControlPoint < 0) || (m_SelectedControlPoint >= (
int)m_NumberOfControlPoints))
195 return this->SetControlPoint(m_SelectedControlPoint, point,
false);
200 return m_NumberOfControlPoints;
205 if (index < this->GetNumberOfControlPoints())
207 m_SelectedControlPoint = index;
218 bool wasSelected = (m_SelectedControlPoint != -1);
220 m_SelectedControlPoint = -1;
227 m_PreviewControlPoint = point;
228 m_PreviewControlPointVisible =
true;
233 m_PreviewControlPointVisible =
false;
238 return m_PreviewControlPoint;
243 return m_PreviewControlPointVisible;
248 if (index < m_NumberOfControlPoints)
250 return m_ControlPoints.at(index);
253 itkExceptionMacro(<<
"GetControlPoint(): Invalid index!");
259 if ((m_PlaneGeometry !=
nullptr) && (index < m_NumberOfControlPoints))
261 m_PlaneGeometry->Map(m_ControlPoints.at(index), point3D);
265 itkExceptionMacro(<<
"GetWorldControlPoint(): Invalid index!");
271 if (index > m_PolyLines.size() || !m_PolyLineUpToDate)
273 this->GeneratePolyLine();
274 m_PolyLineUpToDate =
true;
277 return m_PolyLines.at(index);
282 return m_PolyLines.at(index);
287 for (std::vector<PolyLineType>::size_type i = 0; i < m_PolyLines.size(); i++)
289 m_PolyLines.at(i).clear();
291 m_PolyLineUpToDate =
false;
295 double mmPerDisplayUnit,
296 unsigned int displayHeight)
299 if (index < m_HelperPolyLines.size())
303 if (!m_HelperLinesUpToDate || m_DisplaySize.first != mmPerDisplayUnit || m_DisplaySize.second != displayHeight)
305 this->GenerateHelperPolyLine(mmPerDisplayUnit, displayHeight);
306 m_HelperLinesUpToDate =
true;
309 m_DisplaySize.first = mmPerDisplayUnit;
310 m_DisplaySize.second = displayHeight;
313 helperPolyLine = m_HelperPolyLines.at(index);
316 return helperPolyLine;
321 for (std::vector<PolyLineType>::size_type i = 0; i < m_HelperPolyLines.size(); i++)
323 m_HelperPolyLines.at(i).clear();
325 m_HelperLinesUpToDate =
false;
332 return m_Features.size();
337 return indexOfPolylinePoint;
342 if (index < m_Features.size())
344 return m_Features[index].Name.c_str();
354 if (index < m_Features.size())
356 return m_Features[index].Unit.c_str();
366 if (index < m_Features.size())
368 return m_Features[index].Quantity;
378 if (index < m_Features.size())
380 return m_Features[index].Active;
390 if (index < m_Features.size())
392 return m_Features[index].Visible;
402 if (index < m_Features.size())
404 m_Features[index].Visible = visible;
410 if (!m_FeaturesUpToDate || !m_PolyLineUpToDate)
412 if (!m_PolyLineUpToDate)
414 this->GeneratePolyLine();
417 this->EvaluateFeaturesInternal();
419 m_FeaturesUpToDate =
true;
427 Superclass::UpdateOutputInformation();
428 this->GetTimeGeometry()->Update();
452 m_NumberOfControlPoints = numberOfControlPoints;
457 if (m_PlaneGeometry ==
nullptr)
463 m_PlaneGeometry->WorldToIndex(point, indexPoint);
466 if (indexPoint[0] < bounds[0])
468 indexPoint[0] = bounds[0];
470 if (indexPoint[0] > bounds[1])
472 indexPoint[0] = bounds[1];
474 if (indexPoint[1] < bounds[2])
476 indexPoint[1] = bounds[2];
478 if (indexPoint[1] > bounds[3])
480 indexPoint[1] = bounds[3];
484 m_PlaneGeometry->IndexToWorld(indexPoint, constrainedPoint);
486 return constrainedPoint;
491 unsigned int index = m_Features.size();
493 Feature newFeature(featureName, unitName);
494 m_Features.push_back(newFeature);
501 if (index < m_Features.size())
503 m_Features[index].Name = featureName;
509 if (index < m_Features.size())
511 m_Features[index].Unit = unitName;
517 if (index < m_Features.size())
519 m_Features[index].Quantity = quantity;
525 if (index < m_Features.size())
527 m_Features[index].Active =
true;
533 if (index < m_Features.size())
535 m_Features[index].Active =
false;
542 geometry2D->Initialize();
547 timeGeometry->Initialize(geometry2D, timeSteps);
548 SetTimeGeometry(timeGeometry);
553 Superclass::PrintSelf(os, indent);
554 os << indent << this->GetNameOfClass() <<
":\n";
556 if (this->IsClosed())
557 os << indent <<
"This figure is closed\n";
559 os << indent <<
"This figure is not closed\n";
560 os << indent <<
"Minimum number of control points: " << this->GetMinimumNumberOfControlPoints() << std::endl;
561 os << indent <<
"Maximum number of control points: " << this->GetMaximumNumberOfControlPoints() << std::endl;
562 os << indent <<
"Current number of control points: " << this->GetNumberOfControlPoints() << std::endl;
563 os << indent <<
"Control points:" << std::endl;
565 for (
unsigned int i = 0; i < this->GetNumberOfControlPoints(); ++i)
568 os << indent.GetNextIndent() << i <<
": " << m_ControlPoints.at(i) << std::endl;
570 os << indent <<
"Geometry:\n";
571 this->GetPlaneGeometry()->Print(os, indent.GetNextIndent());
576 if (!m_PolyLineUpToDate)
578 this->GeneratePolyLine();
579 m_PolyLineUpToDate =
true;
581 return m_PolyLines.size();
586 return m_HelperPolyLines.size();
591 return m_HelperPolyLinesToBePainted->GetElement(index);
606 if (index > m_ControlPoints.size())
609 if ((m_ControlPoints.size() - 1) < this->GetMinimumNumberOfControlPoints())
612 ControlPointListType::iterator iter;
613 iter = m_ControlPoints.begin() + index;
615 m_ControlPoints.erase(iter);
617 m_PolyLineUpToDate =
false;
618 m_HelperLinesUpToDate =
false;
619 m_FeaturesUpToDate =
false;
621 --m_NumberOfControlPoints;
626 RemoveControlPoint(m_ControlPoints.size() - 1);
631 m_PolyLines.resize(numberOfPolyLines);
636 m_HelperPolyLines.resize(numberOfHerlperPolyLines);
641 if (index < m_PolyLines.size())
643 m_PolyLines[index].push_back(element);
644 m_PolyLineUpToDate =
false;
648 MITK_ERROR <<
"Tried to add point to PolyLine " << index + 1 <<
", although only " << m_PolyLines.size()
655 if (index < m_HelperPolyLines.size())
657 m_HelperPolyLines[index].push_back(element);
658 m_HelperLinesUpToDate =
false;
662 MITK_ERROR <<
"Tried to add point to HelperPolyLine " << index + 1 <<
", although only " << m_HelperPolyLines.size()
691 if (this->IsClosed() != other.
IsClosed())
698 if (this->m_PolyLines.size() != other.
m_PolyLines.size())
704 auto itThis = this->m_PolyLines.begin();
705 auto itEnd = this->m_PolyLines.end();
708 while (itThis != itEnd)
710 if (itThis->size() != itOther->size())
714 auto itLineThis = itThis->begin();
715 auto itLineEnd = itThis->end();
716 auto itLineOther = itOther->begin();
718 while (itLineThis != itLineEnd)
722 ScalarType delta = fabs(p1[0] - p2[0]) + fabs(p1[1] - p2[1]);
742 MITK_ERROR <<
"Number of Features is Different";
747 auto itThis = m_Features.begin();
748 auto itEnd = m_Features.end();
749 auto itOther = other.m_Features.begin();
751 while (itThis != itEnd)
753 if ((itThis->Quantity - itOther->Quantity) > .001)
755 MITK_ERROR <<
"Quantity is Different" << itThis->Quantity <<
"/" << itOther->Quantity;
758 if (itThis->Unit.compare(itOther->Unit) != 0)
760 MITK_ERROR <<
"Unit is Different" << itThis->Unit <<
"/" << itOther->Unit;
763 if (itThis->Name.compare(itOther->Name) != 0)
765 MITK_ERROR <<
"Name of Measure is Different " << itThis->Name <<
"/ " << itOther->Name;
784 return leftHandSide.
Equals(rightHandSide);
Base of all data objects.
void SetProperty(const char *propertyKey, BaseProperty *property)
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
MITKCORE_EXPORT const ScalarType eps
Describes a two-dimensional, rectangular plane.
BoundingBoxType::BoundsArrayType BoundsArrayType
virtual T GetValue() const
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.