Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkVtkOverlay2D.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,
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 #include "mitkVtkOverlay2D.h"
18 #include <vtkActor2D.h>
19 #include <vtkCoordinate.h>
20 #include <vtkProperty2D.h>
21 
23 {
24 }
25 
27 {
28 }
29 
31 {
32  mitk::Overlay::Bounds bounds;
33  vtkSmartPointer<vtkActor2D> actor = GetVtkActor2D(renderer);
34  bounds.Position = actor->GetPosition();
35  bounds.Size = actor->GetPosition2();
36  return bounds;
37 }
38 
40 {
41  vtkSmartPointer<vtkActor2D> actor = GetVtkActor2D(renderer);
42  actor->SetDisplayPosition(bounds.Position[0], bounds.Position[1]);
43  actor->SetWidth(bounds.Size[0]);
44  actor->SetHeight(bounds.Size[1]);
45 }
46 
48 {
49  vtkActor2D *prop = GetVtkActor2D(renderer);
50  float color[3] = {1, 1, 1};
51  float opacity = 1.0;
52  GetColor(color, renderer);
53  GetOpacity(opacity, renderer);
54  prop->GetProperty()->SetColor(color[0], color[1], color[2]);
55  prop->GetProperty()->SetOpacity(opacity);
56  UpdateVtkOverlay2D(renderer);
57 }
58 
60 {
61  mitk::Point2dProperty::Pointer position2dProperty = mitk::Point2dProperty::New(position2D);
62  SetProperty("VtkOverlay2D.Position2D", position2dProperty.GetPointer(), renderer);
63 }
64 
66 {
67  mitk::Point2D position2D;
68  position2D.Fill(0);
69  GetPropertyValue<mitk::Point2D>("VtkOverlay2D.Position2D", position2D, renderer);
70  return position2D;
71 }
72 
74 {
75  mitk::Point2dProperty::Pointer OffsetVectorProperty = mitk::Point2dProperty::New(OffsetVector);
76  SetProperty("VtkOverlay2D.OffsetVector", OffsetVectorProperty.GetPointer(), renderer);
77 }
78 
80 {
81  mitk::Point2D OffsetVector;
82  OffsetVector.Fill(0);
83  GetPropertyValue<mitk::Point2D>("VtkOverlay2D.OffsetVector", OffsetVector, renderer);
84  return OffsetVector;
85 }
86 
88 {
89  return GetVtkActor2D(renderer);
90 }
Point2D GetPosition2D(mitk::BaseRenderer *renderer=NULL) const
itk::Point< double, 2 > Size
Definition: mitkOverlay.h:43
Organizes the rendering process.
itk::Point< double, 2 > Position
Definition: mitkOverlay.h:42
void SetOffsetVector(const Point2D &OffsetVector, BaseRenderer *renderer=NULL)
virtual ~VtkOverlay2D()
virtual destructor in order to derive from this class
static Pointer New()
virtual void UpdateVtkOverlay(BaseRenderer *renderer) override
virtual vtkProp * GetVtkProp(BaseRenderer *renderer) const override
This method is implemented by the specific VTKOverlays in order to create the element as a vtkProp...
virtual void SetBoundsOnDisplay(BaseRenderer *renderer, const Bounds &bounds) override
Sets position and size of the overlay on the display.
virtual Overlay::Bounds GetBoundsOnDisplay(BaseRenderer *renderer) const override
Returns position and size of the overlay on the display.
void SetPosition2D(const Point2D &position2D, mitk::BaseRenderer *renderer=NULL)
VtkOverlay2D()
explicit constructor which disallows implicit conversions
Point2D GetOffsetVector(mitk::BaseRenderer *renderer=NULL) const
Container for position and size on the display.
Definition: mitkOverlay.h:40