Medical Imaging Interaction Toolkit  2018.4.99-b7f3afaa
Medical Imaging Interaction Toolkit
mitkPlanarFigure.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkPlanarFigure.h"
14 #include "mitkPlaneGeometry.h"
15 #include <mitkProperties.h>
17 
18 #include <algorithm>
19 
21  : m_SelectedControlPoint(-1),
22  m_PreviewControlPointVisible(false),
23  m_FigurePlaced(false),
24  m_PlaneGeometry(nullptr),
25  m_PolyLineUpToDate(false),
26  m_HelperLinesUpToDate(false),
27  m_FeaturesUpToDate(false),
28  m_FeaturesMTime(0)
29 {
30  m_HelperPolyLinesToBePainted = BoolContainerType::New();
31 
32  m_DisplaySize.first = 0.0;
33  m_DisplaySize.second = 0;
34 
35  this->SetProperty("closed", mitk::BoolProperty::New(false));
36 
37  // Currently only single-time-step geometries are supported
38  this->InitializeTimeGeometry(1);
39 }
40 
42  : BaseData(other),
46  m_PolyLines(other.m_PolyLines),
51  m_PlaneGeometry(other.m_PlaneGeometry), // do not clone since SetPlaneGeometry() doesn't clone either
52  m_PolyLineUpToDate(other.m_PolyLineUpToDate),
53  m_HelperLinesUpToDate(other.m_HelperLinesUpToDate),
54  m_FeaturesUpToDate(other.m_FeaturesUpToDate),
55  m_Features(other.m_Features),
56  m_FeaturesMTime(other.m_FeaturesMTime),
57  m_DisplaySize(other.m_DisplaySize)
58 {
59  m_HelperPolyLinesToBePainted = BoolContainerType::New();
60  for (unsigned long i = 0; i < other.m_HelperPolyLinesToBePainted->Size(); ++i)
61  {
62  m_HelperPolyLinesToBePainted->InsertElement(i, other.m_HelperPolyLinesToBePainted->GetElement(i));
63  }
64 }
65 
67 {
68  this->SetGeometry(geometry);
69  m_PlaneGeometry = dynamic_cast<PlaneGeometry *>(GetGeometry(0)); // geometry;
70 }
71 
73 {
74  return m_PlaneGeometry;
75 }
76 
78 {
79  mitk::BoolProperty *closed = dynamic_cast<mitk::BoolProperty *>(this->GetProperty("closed").GetPointer());
80  if (closed != nullptr)
81  {
82  return closed->GetValue();
83  }
84  return false;
85 }
86 
88 {
89  for (unsigned int i = 0; i < this->GetNumberOfControlPoints(); ++i)
90  {
91  m_ControlPoints.push_back(this->ApplyControlPointConstraints(i, point));
92  }
93 
94  m_FigurePlaced = true;
96 }
97 
98 bool mitk::PlanarFigure::AddControlPoint(const mitk::Point2D &point, int position)
99 {
100  // if we already have the maximum number of control points, do nothing
101  if (m_NumberOfControlPoints < this->GetMaximumNumberOfControlPoints())
102  {
103  // if position has not been defined or position would be the last control point, just append the new one
104  // we also append a new point if we click onto the line between the first two control-points if the second
105  // control-point is selected
106  // -> special case for PlanarCross
107  if (position == -1 || position > (int)m_NumberOfControlPoints - 1 || (position == 1 && m_SelectedControlPoint == 2))
108  {
109  if (m_ControlPoints.size() > this->GetMaximumNumberOfControlPoints() - 1)
110  {
111  // get rid of deprecated control points in the list. This is necessary
112  // as ::ResetNumberOfControlPoints() only sets the member, does not resize the list!
114  }
115 
118  }
119  else
120  {
121  // insert the point at the given position and set it as selected point
122  auto iter = m_ControlPoints.begin() + position;
123  m_ControlPoints.insert(iter, this->ApplyControlPointConstraints(position, point));
124  for (unsigned int i = 0; i < m_ControlPoints.size(); ++i)
125  {
126  if (point == m_ControlPoints.at(i))
127  {
129  }
130  }
131  }
132 
133  // polylines & helperpolylines need to be repainted
134  m_PolyLineUpToDate = false;
135  m_HelperLinesUpToDate = false;
136  m_FeaturesUpToDate = false;
137 
138  // one control point more
140  return true;
141  }
142  else
143  {
144  return false;
145  }
146 }
147 
148 bool mitk::PlanarFigure::SetControlPoint(unsigned int index, const Point2D &point, bool createIfDoesNotExist)
149 {
150  bool controlPointSetCorrectly = false;
151  if (createIfDoesNotExist)
152  {
153  if (m_NumberOfControlPoints <= index)
154  {
155  m_ControlPoints.push_back(this->ApplyControlPointConstraints(index, point));
157  }
158  else
159  {
160  m_ControlPoints.at(index) = this->ApplyControlPointConstraints(index, point);
161  }
162  controlPointSetCorrectly = true;
163  }
164  else if (index < m_NumberOfControlPoints)
165  {
166  m_ControlPoints.at(index) = this->ApplyControlPointConstraints(index, point);
167  controlPointSetCorrectly = true;
168  }
169  else
170  {
171  return false;
172  }
173 
174  if (controlPointSetCorrectly)
175  {
176  m_PolyLineUpToDate = false;
177  m_HelperLinesUpToDate = false;
178  m_FeaturesUpToDate = false;
179  }
180 
181  return controlPointSetCorrectly;
182 }
183 
185 {
187  {
188  return false;
189  }
190 
191  return this->SetControlPoint(m_SelectedControlPoint, point, false);
192 }
193 
195 {
197 }
198 
200 {
201  if (index < this->GetNumberOfControlPoints())
202  {
203  m_SelectedControlPoint = index;
204  return true;
205  }
206  else
207  {
208  return false;
209  }
210 }
211 
213 {
214  bool wasSelected = (m_SelectedControlPoint != -1);
215 
217 
218  return wasSelected;
219 }
220 
222 {
223  m_PreviewControlPoint = point;
225 }
226 
228 {
230 }
231 
233 {
234  return m_PreviewControlPoint;
235 }
236 
238 {
240 }
241 
243 {
244  if (index < m_NumberOfControlPoints)
245  {
246  return m_ControlPoints.at(index);
247  }
248 
249  itkExceptionMacro(<< "GetControlPoint(): Invalid index!");
250 }
251 
253 {
254  Point3D point3D;
255  if ((m_PlaneGeometry != nullptr) && (index < m_NumberOfControlPoints))
256  {
257  m_PlaneGeometry->Map(m_ControlPoints.at(index), point3D);
258  return point3D;
259  }
260 
261  itkExceptionMacro(<< "GetWorldControlPoint(): Invalid index!");
262 }
263 
265 {
267  if (index > m_PolyLines.size() || !m_PolyLineUpToDate)
268  {
269  this->GeneratePolyLine();
270  m_PolyLineUpToDate = true;
271  }
272 
273  return m_PolyLines.at(index);
274 }
275 
277 {
278  return m_PolyLines.at(index);
279 }
280 
282 {
283  for (std::vector<PolyLineType>::size_type i = 0; i < m_PolyLines.size(); i++)
284  {
285  m_PolyLines.at(i).clear();
286  }
287  m_PolyLineUpToDate = false;
288 }
289 
291  double mmPerDisplayUnit,
292  unsigned int displayHeight)
293 {
294  mitk::PlanarFigure::PolyLineType helperPolyLine;
295  if (index < m_HelperPolyLines.size())
296  {
297  // m_HelperLinesUpToDate does not cover changes in zoom-level, so we have to check previous values of the
298  // two parameters as well
299  if (!m_HelperLinesUpToDate || m_DisplaySize.first != mmPerDisplayUnit || m_DisplaySize.second != displayHeight)
300  {
301  this->GenerateHelperPolyLine(mmPerDisplayUnit, displayHeight);
302  m_HelperLinesUpToDate = true;
303 
304  // store these parameters to be able to check next time if somebody zoomed in or out
305  m_DisplaySize.first = mmPerDisplayUnit;
306  m_DisplaySize.second = displayHeight;
307  }
308 
309  helperPolyLine = m_HelperPolyLines.at(index);
310  }
311 
312  return helperPolyLine;
313 }
314 
316 {
317  for (std::vector<PolyLineType>::size_type i = 0; i < m_HelperPolyLines.size(); i++)
318  {
319  m_HelperPolyLines.at(i).clear();
320  }
321  m_HelperLinesUpToDate = false;
322 }
323 
327 {
328  return m_Features.size();
329 }
330 
331 int mitk::PlanarFigure::GetControlPointForPolylinePoint(int indexOfPolylinePoint, int /*polyLineIndex*/) const
332 {
333  return indexOfPolylinePoint;
334 }
335 
336 const char *mitk::PlanarFigure::GetFeatureName(unsigned int index) const
337 {
338  if (index < m_Features.size())
339  {
340  return m_Features[index].Name.c_str();
341  }
342  else
343  {
344  return nullptr;
345  }
346 }
347 
348 const char *mitk::PlanarFigure::GetFeatureUnit(unsigned int index) const
349 {
350  if (index < m_Features.size())
351  {
352  return m_Features[index].Unit.c_str();
353  }
354  else
355  {
356  return nullptr;
357  }
358 }
359 
360 double mitk::PlanarFigure::GetQuantity(unsigned int index) const
361 {
362  if (index < m_Features.size())
363  {
364  return m_Features[index].Quantity;
365  }
366  else
367  {
368  return 0.0;
369  }
370 }
371 
372 bool mitk::PlanarFigure::IsFeatureActive(unsigned int index) const
373 {
374  if (index < m_Features.size())
375  {
376  return m_Features[index].Active;
377  }
378  else
379  {
380  return false;
381  }
382 }
383 
384 bool mitk::PlanarFigure::IsFeatureVisible(unsigned int index) const
385 {
386  if (index < m_Features.size())
387  {
388  return m_Features[index].Visible;
389  }
390  else
391  {
392  return false;
393  }
394 }
395 
396 void mitk::PlanarFigure::SetFeatureVisible(unsigned int index, bool visible)
397 {
398  if (index < m_Features.size())
399  {
400  m_Features[index].Visible = visible;
401  }
402 }
403 
405 {
406  if (!m_FeaturesUpToDate || !m_PolyLineUpToDate)
407  {
408  if (!m_PolyLineUpToDate)
409  {
410  this->GeneratePolyLine();
411  }
412 
413  this->EvaluateFeaturesInternal();
414 
415  m_FeaturesUpToDate = true;
416  }
417 }
418 
420 {
421  // Bounds are NOT calculated here, since the PlaneGeometry defines a fixed
422  // frame (= bounds) for the planar figure.
423  Superclass::UpdateOutputInformation();
424  this->GetTimeGeometry()->Update();
425 }
426 
428 {
429 }
430 
432 {
433  return false;
434 }
435 
437 {
438  return true;
439 }
440 
441 void mitk::PlanarFigure::SetRequestedRegion(const itk::DataObject * /*data*/)
442 {
443 }
444 
445 void mitk::PlanarFigure::ResetNumberOfControlPoints(int numberOfControlPoints)
446 {
447  // DO NOT resize the list here, will cause crash!!
448  m_NumberOfControlPoints = numberOfControlPoints;
449 }
450 
452 {
453  if (m_PlaneGeometry == nullptr)
454  {
455  return point;
456  }
457 
458  Point2D indexPoint;
459  m_PlaneGeometry->WorldToIndex(point, indexPoint);
460 
461  BoundingBox::BoundsArrayType bounds = m_PlaneGeometry->GetBounds();
462  if (indexPoint[0] < bounds[0])
463  {
464  indexPoint[0] = bounds[0];
465  }
466  if (indexPoint[0] > bounds[1])
467  {
468  indexPoint[0] = bounds[1];
469  }
470  if (indexPoint[1] < bounds[2])
471  {
472  indexPoint[1] = bounds[2];
473  }
474  if (indexPoint[1] > bounds[3])
475  {
476  indexPoint[1] = bounds[3];
477  }
478 
479  Point2D constrainedPoint;
480  m_PlaneGeometry->IndexToWorld(indexPoint, constrainedPoint);
481 
482  return constrainedPoint;
483 }
484 
485 unsigned int mitk::PlanarFigure::AddFeature(const char *featureName, const char *unitName)
486 {
487  unsigned int index = m_Features.size();
488 
489  Feature newFeature(featureName, unitName);
490  m_Features.push_back(newFeature);
491 
492  return index;
493 }
494 
495 void mitk::PlanarFigure::SetFeatureName(unsigned int index, const char *featureName)
496 {
497  if (index < m_Features.size())
498  {
499  m_Features[index].Name = featureName;
500  }
501 }
502 
503 void mitk::PlanarFigure::SetFeatureUnit(unsigned int index, const char *unitName)
504 {
505  if (index < m_Features.size())
506  {
507  m_Features[index].Unit = unitName;
508  }
509 }
510 
511 void mitk::PlanarFigure::SetQuantity(unsigned int index, double quantity)
512 {
513  if (index < m_Features.size())
514  {
515  m_Features[index].Quantity = quantity;
516  }
517 }
518 
519 void mitk::PlanarFigure::ActivateFeature(unsigned int index)
520 {
521  if (index < m_Features.size())
522  {
523  m_Features[index].Active = true;
524  }
525 }
526 
528 {
529  if (index < m_Features.size())
530  {
531  m_Features[index].Active = false;
532  }
533 }
534 
535 void mitk::PlanarFigure::InitializeTimeGeometry(unsigned int timeSteps)
536 {
538  geometry2D->Initialize();
539 
540  // The geometry is propagated automatically to all time steps,
541  // if EvenlyTimed is true...
543  timeGeometry->Initialize(geometry2D, timeSteps);
544  SetTimeGeometry(timeGeometry);
545 }
546 
547 void mitk::PlanarFigure::PrintSelf(std::ostream &os, itk::Indent indent) const
548 {
549  Superclass::PrintSelf(os, indent);
550  os << indent << this->GetNameOfClass() << ":\n";
551 
552  if (this->IsClosed())
553  os << indent << "This figure is closed\n";
554  else
555  os << indent << "This figure is not closed\n";
556  os << indent << "Minimum number of control points: " << this->GetMinimumNumberOfControlPoints() << std::endl;
557  os << indent << "Maximum number of control points: " << this->GetMaximumNumberOfControlPoints() << std::endl;
558  os << indent << "Current number of control points: " << this->GetNumberOfControlPoints() << std::endl;
559  os << indent << "Control points:" << std::endl;
560 
561  for (unsigned int i = 0; i < this->GetNumberOfControlPoints(); ++i)
562  {
563  // os << indent.GetNextIndent() << i << ": " << m_ControlPoints->ElementAt( i ) << std::endl;
564  os << indent.GetNextIndent() << i << ": " << m_ControlPoints.at(i) << std::endl;
565  }
566  os << indent << "Geometry:\n";
567  this->GetPlaneGeometry()->Print(os, indent.GetNextIndent());
568 }
569 
571 {
572  if (!m_PolyLineUpToDate)
573  {
574  this->GeneratePolyLine();
575  m_PolyLineUpToDate = true;
576  }
577  return m_PolyLines.size();
578 }
579 
581 {
582  return m_HelperPolyLines.size();
583 }
584 
585 bool mitk::PlanarFigure::IsHelperToBePainted(unsigned int index) const
586 {
587  return m_HelperPolyLinesToBePainted->GetElement(index);
588 }
589 
591 {
592  return false;
593 }
594 
596 {
597  return false;
598 }
599 
601 {
602  if (index > m_ControlPoints.size())
603  return;
604 
605  if ((m_ControlPoints.size() - 1) < this->GetMinimumNumberOfControlPoints())
606  return;
607 
608  ControlPointListType::iterator iter;
609  iter = m_ControlPoints.begin() + index;
610 
611  m_ControlPoints.erase(iter);
612 
613  m_PolyLineUpToDate = false;
614  m_HelperLinesUpToDate = false;
615  m_FeaturesUpToDate = false;
616 
618 }
619 
621 {
623 }
624 
625 void mitk::PlanarFigure::SetNumberOfPolyLines(unsigned int numberOfPolyLines)
626 {
627  m_PolyLines.resize(numberOfPolyLines);
628 }
629 
630 void mitk::PlanarFigure::SetNumberOfHelperPolyLines(unsigned int numberOfHerlperPolyLines)
631 {
632  m_HelperPolyLines.resize(numberOfHerlperPolyLines);
633 }
634 
636 {
637  if (index < m_PolyLines.size())
638  {
639  m_PolyLines[index].push_back(element);
640  m_PolyLineUpToDate = false;
641  }
642  else
643  {
644  MITK_ERROR << "Tried to add point to PolyLine " << index + 1 << ", although only " << m_PolyLines.size()
645  << " exists";
646  }
647 }
648 
650 {
651  if (index < m_HelperPolyLines.size())
652  {
653  m_HelperPolyLines[index].push_back(element);
654  m_HelperLinesUpToDate = false;
655  }
656  else
657  {
658  MITK_ERROR << "Tried to add point to HelperPolyLine " << index + 1 << ", although only " << m_HelperPolyLines.size()
659  << " exists";
660  }
661 }
662 
664 {
665  // check geometries
666  if (this->GetPlaneGeometry() && other.GetPlaneGeometry())
667  {
668  if (!Equal(*(this->GetPlaneGeometry()), *(other.GetPlaneGeometry()), mitk::eps, true))
669  {
670  return false;
671  }
672  }
673  else
674  {
675  MITK_ERROR << "Geometry is not equal";
676  return false;
677  }
678 
679  // check isPlaced member
680  if (this->m_FigurePlaced != other.m_FigurePlaced)
681  {
682  MITK_ERROR << "Is_Placed is not equal";
683  return false;
684  }
685 
686  // check closed property
687  if (this->IsClosed() != other.IsClosed())
688  {
689  MITK_ERROR << "Is_closed is not equal";
690  return false;
691  }
692 
693  // check poly lines
694  if (this->m_PolyLines.size() != other.m_PolyLines.size())
695  {
696  return false;
697  }
698  else
699  {
700  auto itThis = this->m_PolyLines.begin();
701  auto itEnd = this->m_PolyLines.end();
702  auto itOther = other.m_PolyLines.begin();
703 
704  while (itThis != itEnd)
705  {
706  if (itThis->size() != itOther->size())
707  return false;
708  else
709  {
710  auto itLineThis = itThis->begin();
711  auto itLineEnd = itThis->end();
712  auto itLineOther = itOther->begin();
713 
714  while (itLineThis != itLineEnd)
715  {
716  Point2D p1 = *itLineThis;
717  Point2D p2 = *itLineOther;
718  ScalarType delta = fabs(p1[0] - p2[0]) + fabs(p1[1] - p2[1]);
719  if (delta > .001)
720  {
721  MITK_ERROR << "Poly line is not equal";
722  MITK_ERROR << p1 << "/" << p2;
723  return false;
724  }
725 
726  ++itLineThis;
727  ++itLineOther;
728  }
729  }
730  ++itThis;
731  ++itOther;
732  }
733  }
734 
735  // check features
736  if (this->GetNumberOfFeatures() != other.GetNumberOfFeatures())
737  {
738  MITK_ERROR << "Number of Features is Different";
739  return false;
740  }
741  else
742  {
743  auto itThis = m_Features.begin();
744  auto itEnd = m_Features.end();
745  auto itOther = other.m_Features.begin();
746 
747  while (itThis != itEnd)
748  {
749  if ((itThis->Quantity - itOther->Quantity) > .001)
750  {
751  MITK_ERROR << "Quantity is Different" << itThis->Quantity << "/" << itOther->Quantity;
752  return false;
753  }
754  if (itThis->Unit.compare(itOther->Unit) != 0)
755  {
756  MITK_ERROR << "Unit is Different" << itThis->Unit << "/" << itOther->Unit;
757  return false;
758  }
759  if (itThis->Name.compare(itOther->Name) != 0)
760  {
761  MITK_ERROR << "Name of Measure is Different " << itThis->Name << "/ " << itOther->Name;
762  ;
763  return false;
764  }
765 
766  ++itThis;
767  ++itOther;
768  }
769  }
770 
771  return true;
772 }
773 
774 bool mitk::Equal(const mitk::PlanarFigure &leftHandSide,
775  const mitk::PlanarFigure &rightHandSide,
776  ScalarType /*eps*/,
777  bool /*verbose*/)
778 {
779  // FIXME: use eps and verbose
780  return leftHandSide.Equals(rightHandSide);
781 }
virtual bool Equals(const mitk::PlanarFigure &other) const
Compare two PlanarFigure objects Note: all subclasses have to implement the method on their own...
void DeactivateFeature(unsigned int index)
Point2D GetPreviewControlPoint() const
Returns the coordinates of the PreviewControlPoint.
Point2D GetControlPoint(unsigned int index) const
Returns specified control point in 2D world coordinates.
void PrintSelf(std::ostream &os, itk::Indent indent) const override
virtual unsigned int GetMaximumNumberOfControlPoints() const =0
Returns the maximum number of control points allowed for this figure (e.g. 3 for triangles).
virtual const PlaneGeometry * GetPlaneGeometry() const
Returns (previously set) 2D geometry of this figure.
Base of all data objects.
Definition: mitkBaseData.h:37
virtual unsigned int AddFeature(const char *featureName, const char *unitName)
virtual void RemoveLastControlPoint()
Removes last control point.
#define MITK_ERROR
Definition: mitkLogMacros.h:20
Point3D GetWorldControlPoint(unsigned int index) const
Returns specified control point in world coordinates.
double ScalarType
bool IsFeatureActive(unsigned int index) const
Returns true if the feature with the specified index exists and is active (an inactive feature may e...
virtual void SetGeometry(BaseGeometry *aGeometry3D)
Set the BaseGeometry of the data, which will be referenced (not copied!). Assumes the data object has...
virtual unsigned int GetMinimumNumberOfControlPoints() const =0
Returns the minimum number of control points needed to represent this figure.
virtual void SetTimeGeometry(TimeGeometry *geometry)
Set the TimeGeometry of the data, which will be referenced (not copied!).
void ResetNumberOfControlPoints(int numberOfControlPoints)
Set the initial number of control points of the planar figure.
virtual unsigned short GetHelperPolyLinesSize() const
Returns the current number of helperpolylines.
virtual bool ResetOnPointSelectNeeded() const
double GetQuantity(unsigned int index) const
bool VerifyRequestedRegion() override
Intherited from parent.
virtual bool Map(const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const
Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 2D point in mm (pt2d_m...
const PolyLineType GetPolyLine(unsigned int index)
Returns the polyline representing the planar figure (for rendering, measurements, etc...
void SetRequestedRegion(const itk::DataObject *data) override
Intherited from parent.
bool IsFeatureVisible(unsigned int index) const
Returns true if the feature with the specified index exists and is set visible.
virtual void IndexToWorld(const Point2D &pt_units, Point2D &pt_mm) const
void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Add new or change existent property.
virtual bool IsClosed() const
True if the planar figure is closed.
virtual T GetValue() const
unsigned int GetNumberOfControlPoints() const
Returns the current number of 2D control points defining this figure.
static Pointer New()
virtual void EvaluateFeatures()
Calculates quantities of all features of this planar figure.
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:61
void SetQuantity(unsigned int index, double quantity)
void SetFeatureVisible(unsigned int index, bool visible)
Defines if the feature with the specified index will be shown as an Annotation in the RenderWindow...
std::vector< PolyLineType > m_HelperPolyLines
ControlPointListType m_ControlPoints
void ResetPreviewContolPoint()
Marks the PreviewControlPoint as invisible.
virtual void WorldToIndex(const Point2D &pt_mm, Point2D &pt_units) const
unsigned int m_NumberOfControlPoints
virtual bool ResetOnPointSelect()
Returns true if the planar figure is reset to "add points" mode when a point is selected.
void UpdateOutputInformation() override
Intherited from parent.
void SetNumberOfHelperPolyLines(unsigned int numberOfHelperPolyLines)
defines the number of HelperPolyLines that will be available
virtual void PlaceFigure(const Point2D &point)
Place figure at the given point (in 2D index coordinates) onto the given 2D geometry.
virtual Point2D ApplyControlPointConstraints(unsigned int, const Point2D &point)
Allow sub-classes to apply constraints on control points.
void ActivateFeature(unsigned int index)
virtual unsigned short GetPolyLinesSize()
Returns the current number of polylines.
virtual bool SetCurrentControlPoint(const Point2D &point)
virtual void EvaluateFeaturesInternal()=0
Calculates quantities of all features of this planar figure. Must be implemented in sub-classes...
const PolyLineType GetHelperPolyLine(unsigned int index, double mmPerDisplayUnit, unsigned int displayHeight)
Returns the polyline that should be drawn the same size at every scale (for text, angles...
virtual unsigned int GetNumberOfFeatures() const
Returns the number of features available for this PlanarFigure (such as, radius, area, ...).
void AppendPointToPolyLine(unsigned int index, PolyLineElement element)
Append a point to the PolyLine # index.
virtual void GeneratePolyLine()=0
Generates the poly-line representation of the planar figure. Must be implemented in sub-classes...
mitk::BaseProperty::Pointer GetProperty(const char *propertyKey) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList, and set it to this, respectively;.
void SetNumberOfPolyLines(unsigned int numberOfPolyLines)
defines the number of PolyLines that will be available
virtual bool DeselectControlPoint()
Deselect control point; no control point active.
void SetFeatureName(unsigned int index, const char *featureName)
virtual void SetPlaneGeometry(mitk::PlaneGeometry *geometry)
Sets the 2D geometry on which this figure will be placed.
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.
virtual bool SetControlPoint(unsigned int index, const Point2D &point, bool createIfDoesNotExist=false)
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons...
void AppendPointToHelperPolyLine(unsigned int index, PolyLineElement element)
Append a point to the HelperPolyLine # index.
void ClearHelperPolyLines()
clears the list of HelperPolyLines. Call before re-calculating a new HelperPolyline.
BoolContainerType::Pointer m_HelperPolyLinesToBePainted
virtual bool IsHelperToBePainted(unsigned int index) const
Returns whether a helper polyline should be painted or not.
static Pointer New()
virtual void GenerateHelperPolyLine(double mmPerDisplayUnit, unsigned int displayHeight)=0
Generates the poly-lines that should be drawn the same size regardless of zoom. Must be implemented i...
MITKCORE_EXPORT const ScalarType eps
virtual void RemoveControlPoint(unsigned int index)
removes the point with the given index from the list of controlpoints.
std::vector< PolyLineElement > PolyLineType
std::vector< PolyLineType > m_PolyLines
virtual bool SelectControlPoint(unsigned int index)
Selects currently active control points.
const char * GetFeatureName(unsigned int index) const
Returns the name (identifier) of the specified features.
const char * GetFeatureUnit(unsigned int index) const
Returns the physical unit of the specified features.
Describes a two-dimensional, rectangular plane.
void SetPreviewControlPoint(const Point2D &point)
Sets the position of the PreviewControlPoint. Automatically sets it visible.
void InitializeTimeGeometry(unsigned int timeSteps=1) override
Initializes the TimeGeometry describing the (time-resolved) geometry of this figure. Note that each time step holds one PlaneGeometry.
void Update()
Updates the geometry.
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:138
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
Intherited from parent.
virtual int GetControlPointForPolylinePoint(int indexOfPolylinePoint, int polyLineIndex) const
Returns the id of the control-point that corresponds to the given polyline-point. ...
virtual bool AddControlPoint(const Point2D &point, int index=-1)
Adds / inserts new control-points.
const BoundsArrayType GetBounds() const
void SetRequestedRegionToLargestPossibleRegion() override
Intherited from parent.
void ClearPolyLines()
clears the list of PolyLines. Call before re-calculating a new Polyline.
BoundingBoxType::BoundsArrayType BoundsArrayType
bool IsPreviewControlPointVisible() const
Returns whether or not the PreviewControlPoint is visible.
void SetFeatureUnit(unsigned int index, const char *unitName)