Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
mitkPlanarFigure.h
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 #ifndef mitkPlanarFigure_h
14 #define mitkPlanarFigure_h
15 
16 #include "mitkBaseData.h"
17 #include "mitkCommon.h"
19 
20 #include <deque>
21 
22 namespace mitk
23 {
24  class PlaneGeometry;
25 
51  {
52  public:
54  itkCloneMacro(Self);
55 
56  typedef Point2D PolyLineElement;
57 
58  typedef itk::VectorContainer<unsigned long, bool> BoolContainerType;
59 
60  typedef std::deque<Point2D> ControlPointListType;
61  typedef std::vector<PolyLineElement> PolyLineType;
62 
69  virtual void SetPlaneGeometry(mitk::PlaneGeometry *geometry);
70 
72  virtual const PlaneGeometry *GetPlaneGeometry() const;
73 
77  virtual bool IsClosed() const;
78 
81  virtual bool IsPlaced() const { return m_FigurePlaced; };
92  virtual void PlaceFigure(const Point2D &point);
93 
104  virtual bool AddControlPoint(const Point2D &point, int index = -1);
105 
106  virtual bool SetControlPoint(unsigned int index, const Point2D &point, bool createIfDoesNotExist = false);
107 
108  virtual bool SetCurrentControlPoint(const Point2D &point);
109 
111  unsigned int GetNumberOfControlPoints() const;
112 
118  virtual unsigned int GetMinimumNumberOfControlPoints() const = 0;
119 
125  virtual unsigned int GetMaximumNumberOfControlPoints() const = 0;
126 
128  virtual bool SelectControlPoint(unsigned int index);
129 
131  virtual bool DeselectControlPoint();
132 
134  virtual int GetSelectedControlPoint() const { return m_SelectedControlPoint; }
136  Point2D GetControlPoint(unsigned int index) const;
137 
142  virtual int GetControlPointForPolylinePoint(int indexOfPolylinePoint, int polyLineIndex) const;
143 
145  Point3D GetWorldControlPoint(unsigned int index) const;
146 
149  const PolyLineType GetPolyLine(unsigned int index);
150 
153  const PolyLineType GetPolyLine(unsigned int index) const;
154 
157  const PolyLineType GetHelperPolyLine(unsigned int index, double mmPerDisplayUnit, unsigned int displayHeight);
158 
160  void SetPreviewControlPoint(const Point2D &point);
161 
163  void ResetPreviewContolPoint();
164 
166  bool IsPreviewControlPointVisible() const;
167 
169  Point2D GetPreviewControlPoint() const;
170 
173  virtual unsigned int GetNumberOfFeatures() const;
174 
176  const char *GetFeatureName(unsigned int index) const;
177 
179  const char *GetFeatureUnit(unsigned int index) const;
180 
183  double GetQuantity(unsigned int index) const;
184 
188  bool IsFeatureActive(unsigned int index) const;
189 
191  bool IsFeatureVisible(unsigned int index) const;
192 
195  void SetFeatureVisible(unsigned int index, bool visible);
196 
198  virtual void EvaluateFeatures();
199 
201  void UpdateOutputInformation() override;
202 
204  void SetRequestedRegionToLargestPossibleRegion() override;
205 
207  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
208 
210  bool VerifyRequestedRegion() override;
211 
213  void SetRequestedRegion(const itk::DataObject *data) override;
214 
216  virtual unsigned short GetPolyLinesSize();
217 
219  virtual unsigned short GetHelperPolyLinesSize() const;
220 
222  virtual bool IsHelperToBePainted(unsigned int index) const;
223 
229  virtual bool ResetOnPointSelect();
230  virtual bool ResetOnPointSelectNeeded() const;
231 
233  virtual void RemoveControlPoint(unsigned int index);
234 
236  virtual void RemoveLastControlPoint();
237 
243  virtual Point2D ApplyControlPointConstraints(unsigned int /*index*/, const Point2D &point);
244 
249  virtual bool Equals(const mitk::PlanarFigure &other) const;
250 
252  void ResetNumberOfControlPoints(int numberOfControlPoints);
253 
254  protected:
255  PlanarFigure();
256 
257  PlanarFigure(const Self &other);
258 
262  virtual unsigned int AddFeature(const char *featureName, const char *unitName);
263 
265  void SetFeatureName(unsigned int index, const char *featureName);
266 
268  void SetFeatureUnit(unsigned int index, const char *unitName);
269 
271  void SetQuantity(unsigned int index, double quantity);
272 
274  void ActivateFeature(unsigned int index);
275 
277  void DeactivateFeature(unsigned int index);
278 
281  virtual void GeneratePolyLine() = 0;
282 
285  virtual void GenerateHelperPolyLine(double mmPerDisplayUnit, unsigned int displayHeight) = 0;
286 
289  virtual void EvaluateFeaturesInternal() = 0;
290 
294  void InitializeTimeGeometry(unsigned int timeSteps = 1) override;
295 
297  void SetNumberOfPolyLines(unsigned int numberOfPolyLines);
298 
300  void AppendPointToPolyLine(unsigned int index, PolyLineElement element);
301 
303  void ClearPolyLines();
304 
306  void SetNumberOfHelperPolyLines(unsigned int numberOfHelperPolyLines);
307 
309  void AppendPointToHelperPolyLine(unsigned int index, PolyLineElement element);
310 
312  void ClearHelperPolyLines();
313 
314  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
315 
318 
319  // Currently selected control point; -1 means no point selected
321 
322  std::vector<PolyLineType> m_PolyLines;
323  std::vector<PolyLineType> m_HelperPolyLines;
324  BoolContainerType::Pointer m_HelperPolyLinesToBePainted;
325 
326  // this point is used to store the coordinates an additional 'ControlPoint' that is rendered
327  // when the mouse cursor is above the figure (and not a control-point) and when the
328  // property 'planarfigure.isextendable' is set to true
331 
333 
334  private:
335  // not implemented to prevent PlanarFigure::New() calls which would create an itk::Object.
336  static Pointer New();
337 
338  struct Feature
339  {
340  Feature(const char *name, const char *unit) : Name(name), Unit(unit), Quantity(0.0), Active(true), Visible(true)
341  {
342  }
343 
344  std::string Name;
345  std::string Unit;
346  double Quantity;
347  bool Active;
348  bool Visible;
349  };
350 
351  itk::LightObject::Pointer InternalClone() const override = 0;
352 
353  bool m_PolyLineUpToDate;
354  bool m_HelperLinesUpToDate;
355  bool m_FeaturesUpToDate;
356 
357  // Vector of features available for this geometric figure
358  typedef std::vector<Feature> FeatureVectorType;
359  FeatureVectorType m_Features;
360 
361  unsigned long m_FeaturesMTime;
362 
363  // this pair is used to store the mmInDisplayUnits (m_DisplaySize.first) and the displayHeight
364  // (m_DisplaySize.second)
365  // that the helperPolyLines have been calculated for.
366  // It's used to determine whether or not GetHelperPolyLine() needs to recalculate the HelperPolyLines.
367  std::pair<double, unsigned int> m_DisplaySize;
368  };
369 
370  MITKPLANARFIGURE_EXPORT bool Equal(const mitk::PlanarFigure &leftHandSide,
371  const mitk::PlanarFigure &rightHandSide,
372  ScalarType eps,
373  bool verbose);
374 
375 } // namespace mitk
376 
377 #endif
mitk::eps
const MITKCORE_EXPORT ScalarType eps
mitk::PlanarFigure::m_FigurePlaced
bool m_FigurePlaced
Definition: mitkPlanarFigure.h:332
mitk::PlanarFigure::m_PolyLines
std::vector< PolyLineType > m_PolyLines
Definition: mitkPlanarFigure.h:322
mitk::PlanarFigure::m_NumberOfControlPoints
unsigned int m_NumberOfControlPoints
Definition: mitkPlanarFigure.h:317
mitk::PlanarFigure::m_PreviewControlPointVisible
bool m_PreviewControlPointVisible
Definition: mitkPlanarFigure.h:330
MitkPlanarFigureExports.h
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitk::PlanarFigure
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons,...
Definition: mitkPlanarFigure.h:50
mitk::PlanarFigure::PolyLineElement
Point2D PolyLineElement
Definition: mitkPlanarFigure.h:54
MITKPLANARFIGURE_EXPORT
#define MITKPLANARFIGURE_EXPORT
Definition: MitkPlanarFigureExports.h:15
mitk::PlanarFigure::m_HelperPolyLinesToBePainted
BoolContainerType::Pointer m_HelperPolyLinesToBePainted
Definition: mitkPlanarFigure.h:324
mitk::PlanarFigure::m_HelperPolyLines
std::vector< PolyLineType > m_HelperPolyLines
Definition: mitkPlanarFigure.h:323
mitk::Equal
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.
itk::SmartPointer< Self >
mitk::PlanarFigure::m_ControlPoints
ControlPointListType m_ControlPoints
Definition: mitkPlanarFigure.h:316
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::PlanarFigure::GetSelectedControlPoint
virtual int GetSelectedControlPoint() const
Return currently selected control point.
Definition: mitkPlanarFigure.h:134
mitk::PlanarFigure::BoolContainerType
itk::VectorContainer< unsigned long, bool > BoolContainerType
Definition: mitkPlanarFigure.h:58
mitk::Point
Definition: mitkPoint.h:38
mitk::PlanarFigure::m_PreviewControlPoint
Point2D m_PreviewControlPoint
Definition: mitkPlanarFigure.h:329
mitkCommon.h
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
mitk::PlanarFigure::m_SelectedControlPoint
int m_SelectedControlPoint
Definition: mitkPlanarFigure.h:320
mitk::PlanarFigure::PolyLineType
std::vector< PolyLineElement > PolyLineType
Definition: mitkPlanarFigure.h:61
mitkBaseData.h
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::PlanarFigure::IsPlaced
virtual bool IsPlaced() const
True if the planar figure has been placed (and can be displayed/interacted with).
Definition: mitkPlanarFigure.h:81
mitk::ScalarType
double ScalarType
Definition: mitkNumericConstants.h:20
mitk::PlanarFigure::ControlPointListType
std::deque< Point2D > ControlPointListType
Definition: mitkPlanarFigure.h:60