Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef _MITK_PLANAR_FIGURE_H_
18 #define _MITK_PLANAR_FIGURE_H_
19 
20 #include "mitkBaseData.h"
21 #include "mitkCommon.h"
23 
24 #include <deque>
25 
26 namespace mitk
27 {
28  class PlaneGeometry;
29 
55  {
56  public:
57  mitkClassMacro(PlanarFigure, BaseData) itkCloneMacro(Self)
58 
60 
61  typedef itk::VectorContainer<unsigned long, bool> BoolContainerType;
62 
63  typedef std::deque<Point2D> ControlPointListType;
64  typedef std::vector<PolyLineElement> PolyLineType;
65 
72  virtual void SetPlaneGeometry(mitk::PlaneGeometry *geometry);
73 
75  virtual const PlaneGeometry *GetPlaneGeometry() const;
76 
80  virtual bool IsClosed() const;
81 
84  virtual bool IsPlaced() const { return m_FigurePlaced; };
95  virtual void PlaceFigure(const Point2D &point);
96 
107  virtual bool AddControlPoint(const Point2D &point, int index = -1);
108 
109  virtual bool SetControlPoint(unsigned int index, const Point2D &point, bool createIfDoesNotExist = false);
110 
111  virtual bool SetCurrentControlPoint(const Point2D &point);
112 
114  unsigned int GetNumberOfControlPoints() const;
115 
121  virtual unsigned int GetMinimumNumberOfControlPoints() const = 0;
122 
128  virtual unsigned int GetMaximumNumberOfControlPoints() const = 0;
129 
131  virtual bool SelectControlPoint(unsigned int index);
132 
134  virtual bool DeselectControlPoint();
135 
137  virtual int GetSelectedControlPoint() const { return m_SelectedControlPoint; }
139  Point2D GetControlPoint(unsigned int index) const;
140 
145  virtual int GetControlPointForPolylinePoint(int indexOfPolylinePoint, int polyLineIndex) const;
146 
148  Point3D GetWorldControlPoint(unsigned int index) const;
149 
152  const PolyLineType GetPolyLine(unsigned int index);
153 
156  const PolyLineType GetPolyLine(unsigned int index) const;
157 
160  const PolyLineType GetHelperPolyLine(unsigned int index, double mmPerDisplayUnit, unsigned int displayHeight);
161 
163  void SetPreviewControlPoint(const Point2D &point);
164 
166  void ResetPreviewContolPoint();
167 
169  bool IsPreviewControlPointVisible() const;
170 
172  Point2D GetPreviewControlPoint() const;
173 
176  virtual unsigned int GetNumberOfFeatures() const;
177 
179  const char *GetFeatureName(unsigned int index) const;
180 
182  const char *GetFeatureUnit(unsigned int index) const;
183 
186  double GetQuantity(unsigned int index) const;
187 
191  bool IsFeatureActive(unsigned int index) const;
192 
194  bool IsFeatureVisible(unsigned int index) const;
195 
198  void SetFeatureVisible(unsigned int index, bool visible);
199 
201  virtual void EvaluateFeatures();
202 
204  virtual void UpdateOutputInformation() override;
205 
207  virtual void SetRequestedRegionToLargestPossibleRegion() override;
208 
210  virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
211 
213  virtual bool VerifyRequestedRegion() override;
214 
216  virtual void SetRequestedRegion(const itk::DataObject *data) override;
217 
219  virtual unsigned short GetPolyLinesSize();
220 
222  virtual unsigned short GetHelperPolyLinesSize() const;
223 
225  virtual bool IsHelperToBePainted(unsigned int index) const;
226 
232  virtual bool ResetOnPointSelect();
233  virtual bool ResetOnPointSelectNeeded() const;
234 
236  virtual void RemoveControlPoint(unsigned int index);
237 
239  virtual void RemoveLastControlPoint();
240 
246  virtual Point2D ApplyControlPointConstraints(unsigned int /*index*/, const Point2D &point);
247 
252  virtual bool Equals(const mitk::PlanarFigure &other) const;
253 
254  protected:
255  PlanarFigure();
256 
257  PlanarFigure(const Self &other);
258 
260  void ResetNumberOfControlPoints(int numberOfControlPoints);
261 
265  virtual unsigned int AddFeature(const char *featureName, const char *unitName);
266 
268  void SetFeatureName(unsigned int index, const char *featureName);
269 
271  void SetFeatureUnit(unsigned int index, const char *unitName);
272 
274  void SetQuantity(unsigned int index, double quantity);
275 
277  void ActivateFeature(unsigned int index);
278 
280  void DeactivateFeature(unsigned int index);
281 
284  virtual void GeneratePolyLine() = 0;
285 
288  virtual void GenerateHelperPolyLine(double mmPerDisplayUnit, unsigned int displayHeight) = 0;
289 
292  virtual void EvaluateFeaturesInternal() = 0;
293 
297  virtual void InitializeTimeGeometry(unsigned int timeSteps = 1) override;
298 
300  void SetNumberOfPolyLines(unsigned int numberOfPolyLines);
301 
303  void AppendPointToPolyLine(unsigned int index, PolyLineElement element);
304 
306  void ClearPolyLines();
307 
309  void SetNumberOfHelperPolyLines(unsigned int numberOfHelperPolyLines);
310 
312  void AppendPointToHelperPolyLine(unsigned int index, PolyLineElement element);
313 
315  void ClearHelperPolyLines();
316 
317  virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override;
318 
321 
322  // Currently selected control point; -1 means no point selected
324 
325  std::vector<PolyLineType> m_PolyLines;
326  std::vector<PolyLineType> m_HelperPolyLines;
328 
329  // this point is used to store the coordiantes an additional 'ControlPoint' that is rendered
330  // when the mouse cursor is above the figure (and not a control-point) and when the
331  // property 'planarfigure.isextendable' is set to true
334 
336 
337  private:
338  // not implemented to prevent PlanarFigure::New() calls which would create an itk::Object.
339  static Pointer New();
340 
341  struct Feature
342  {
343  Feature(const char *name, const char *unit) : Name(name), Unit(unit), Quantity(0.0), Active(true), Visible(true)
344  {
345  }
346 
347  std::string Name;
348  std::string Unit;
349  double Quantity;
350  bool Active;
351  bool Visible;
352  };
353 
354  virtual itk::LightObject::Pointer InternalClone() const override = 0;
355 
356  PlaneGeometry *m_PlaneGeometry;
357 
358  bool m_PolyLineUpToDate;
359  bool m_HelperLinesUpToDate;
360  bool m_FeaturesUpToDate;
361 
362  // Vector of features available for this geometric figure
363  typedef std::vector<Feature> FeatureVectorType;
364  FeatureVectorType m_Features;
365 
366  unsigned long m_FeaturesMTime;
367 
368  // this pair is used to store the mmInDisplayUnits (m_DisplaySize.first) and the displayHeight
369  // (m_DisplaySize.second)
370  // that the helperPolyLines have been calculated for.
371  // It's used to determine whether or not GetHelperPolyLine() needs to recalculate the HelperPolyLines.
372  std::pair<double, unsigned int> m_DisplaySize;
373  };
374 
375  MITKPLANARFIGURE_EXPORT bool Equal(const mitk::PlanarFigure &leftHandSide,
376  const mitk::PlanarFigure &rightHandSide,
377  ScalarType eps,
378  bool verbose);
379 
380 } // namespace mitk
381 
382 #endif //_MITK_PLANAR_FIGURE_H_
itk::SmartPointer< Self > Pointer
Base of all data objects.
Definition: mitkBaseData.h:39
double ScalarType
virtual int GetSelectedControlPoint() const
Return currently selected control point.
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
itk::VectorContainer< unsigned long, bool > BoolContainerType
std::deque< Point2D > ControlPointListType
std::vector< PolyLineType > m_HelperPolyLines
ControlPointListType m_ControlPoints
unsigned int m_NumberOfControlPoints
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
#define MITKPLANARFIGURE_EXPORT
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.
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons...
BoolContainerType::Pointer m_HelperPolyLinesToBePainted
MITKCORE_EXPORT const ScalarType eps
std::vector< PolyLineElement > PolyLineType
std::vector< PolyLineType > m_PolyLines
Describes a two-dimensional, rectangular plane.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.