Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkVtkAnnotation2D.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 "mitkVtkAnnotation2D.h"
14 #include <vtkActor2D.h>
15 #include <vtkCoordinate.h>
16 #include <vtkProperty2D.h>
17 
19 {
20 }
21 
23 {
24 }
25 
27 {
29  vtkSmartPointer<vtkActor2D> actor = GetVtkActor2D(renderer);
30  bounds.Position = actor->GetPosition();
31  bounds.Size = actor->GetPosition2();
32  return bounds;
33 }
34 
36 {
37  vtkSmartPointer<vtkActor2D> actor = GetVtkActor2D(renderer);
38  actor->SetDisplayPosition(bounds.Position[0], bounds.Position[1]);
39  actor->SetWidth(bounds.Size[0]);
40  actor->SetHeight(bounds.Size[1]);
41 }
42 
44 {
45  vtkActor2D *prop = GetVtkActor2D(renderer);
46  float color[3] = {1, 1, 1};
47  float opacity = 1.0;
48  GetColor(color);
49  GetOpacity(opacity);
50  prop->GetProperty()->SetColor(color[0], color[1], color[2]);
51  prop->GetProperty()->SetOpacity(opacity);
52  UpdateVtkAnnotation2D(renderer);
53 }
54 
56 {
57  mitk::Point2dProperty::Pointer position2dProperty = mitk::Point2dProperty::New(position2D);
58  SetProperty("VtkAnnotation2D.Position2D", position2dProperty.GetPointer());
59 }
60 
62 {
63  mitk::Point2D position2D;
64  position2D.Fill(0);
65  GetPropertyValue<mitk::Point2D>("VtkAnnotation2D.Position2D", position2D);
66  return position2D;
67 }
68 
70 {
71  mitk::Point2dProperty::Pointer OffsetVectorProperty = mitk::Point2dProperty::New(OffsetVector);
72  SetProperty("VtkAnnotation2D.OffsetVector", OffsetVectorProperty.GetPointer());
73 }
74 
76 {
77  mitk::Point2D OffsetVector;
78  OffsetVector.Fill(0);
79  GetPropertyValue<mitk::Point2D>("VtkAnnotation2D.OffsetVector", OffsetVector);
80  return OffsetVector;
81 }
82 
84 {
85  return GetVtkActor2D(renderer);
86 }
VtkAnnotation2D()
explicit constructor which disallows implicit conversions
void SetProperty(const std::string &propertyKey, const BaseProperty::Pointer &property)
Set the property (instance of BaseProperty) with key propertyKey in the PropertyList of the renderer ...
virtual void UpdateVtkAnnotation2D(BaseRenderer *renderer)=0
void SetPosition2D(const Point2D &position2D)
vtkProp * GetVtkProp(BaseRenderer *renderer) const override
This method is implemented by the specific VTKAnnotation in order to create the element as a vtkProp...
Point2D GetOffsetVector() const
virtual vtkActor2D * GetVtkActor2D(BaseRenderer *renderer) const =0
Container for position and size on the display.
itk::Point< double, 2 > Size
Organizes the rendering process.
static Pointer New()
itk::Point< double, 2 > Position
Annotation::Bounds GetBoundsOnDisplay(BaseRenderer *renderer) const override
Returns position and size of the Annotation on the display.
bool GetColor(float rgb[], const std::string &propertyKey="color") const
Convenience access method for color properties (instances of ColorProperty)
~VtkAnnotation2D() override
virtual destructor in order to derive from this class
bool GetOpacity(float &opacity, const std::string &propertyKey="opacity") const
Convenience access method for opacity properties (instances of FloatProperty)
void SetBoundsOnDisplay(BaseRenderer *renderer, const Bounds &bounds) override
Sets position and size of the Annotation on the display.
void UpdateVtkAnnotation(BaseRenderer *renderer) override
void SetOffsetVector(const Point2D &OffsetVector)