19 #include <vtkActor2D.h>
20 #include <vtkIntArray.h>
21 #include <vtkLabelPlacementMapper.h>
22 #include <vtkPointData.h>
23 #include <vtkPointSetToLabelHierarchy.h>
24 #include <vtkPolyData.h>
25 #include <vtkPolyDataMapper.h>
26 #include <vtkProperty2D.h>
27 #include <vtkStringArray.h>
28 #include <vtkTextProperty.h>
36 if (m_LabelCoordinates.IsNotNull())
37 m_LabelCoordinates->RemoveObserver(m_PointSetModifiedObserverTag);
50 m_Labels->SetNumberOfValues(0);
51 m_Labels->SetName(
"labels");
55 m_Sizes->SetNumberOfValues(0);
56 m_Sizes->SetName(
"sizes");
58 m_Points->GetPointData()->AddArray(m_Sizes);
59 m_Points->GetPointData()->AddArray(m_Labels);
62 m_PointSetToLabelHierarchyFilter->SetInputData(m_Points);
63 m_PointSetToLabelHierarchyFilter->SetLabelArrayName(
"labels");
64 m_PointSetToLabelHierarchyFilter->SetPriorityArrayName(
"sizes");
65 m_PointSetToLabelHierarchyFilter->Update();
68 m_LabelMapper->SetInputConnection(m_PointSetToLabelHierarchyFilter->GetOutputPort());
71 m_LabelsActor->SetMapper(m_LabelMapper);
76 if (m_LabelCoordinates.IsNull())
78 MITK_WARN <<
"No pointset defined to print labels!";
81 LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer);
87 size_t pointsetsize = (size_t)m_LabelCoordinates->GetSize();
88 ls->
m_Labels->SetNumberOfValues(pointsetsize);
89 ls->
m_Sizes->SetNumberOfValues(pointsetsize);
91 for (
size_t i = 0; i < pointsetsize; i++)
94 points->InsertNextPoint(coordinate[0] + GetOffsetVector(renderer)[0],
95 coordinate[1] + GetOffsetVector(renderer)[1],
96 coordinate[2] + GetOffsetVector(renderer)[2]);
97 if (m_LabelVector.size() > i)
98 ls->
m_Labels->SetValue(i, m_LabelVector[i]);
102 if (m_PriorityVector.size() > i)
103 ls->
m_Sizes->SetValue(i, m_PriorityVector[i]);
112 float color[3] = {1, 1, 1};
114 GetColor(color, renderer);
115 GetOpacity(opacity, renderer);
116 ls->
m_LabelsActor->GetProperty()->SetColor(color[0], color[1], color[2]);
124 LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer);
130 m_LabelVector = LabelVector;
136 m_PriorityVector = PriorityVector;
142 if (m_LabelCoordinates.IsNotNull())
144 m_LabelCoordinates->RemoveObserver(m_PointSetModifiedObserverTag);
145 m_PointSetModifiedObserverTag = 0;
146 m_LabelCoordinates = NULL;
148 if (LabelCoordinates.IsNull())
152 m_LabelCoordinates = LabelCoordinates;
156 m_PointSetModifiedObserverTag = m_LabelCoordinates->AddObserver(itk::ModifiedEvent(), _PropertyListModifiedCommand);
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 ~LabelOverlay3D()
virtual destructor in order to derive from this class
~LocalStorage()
Default deconstructor of the local storage.
itk::SmartPointer< Self > Pointer
LocalStorage()
Default constructor of the local storage.
void SetLabelVector(const std::vector< std::string > &LabelVector)
Set the vector of labels that are shown to each corresponding point3D. The size has to be equal to th...
vtkSmartPointer< vtkPolyData > m_Points
Organizes the rendering process.
void UpdateVtkOverlay(mitk::BaseRenderer *renderer) override
vtkSmartPointer< vtkPointSetToLabelHierarchy > m_PointSetToLabelHierarchyFilter
vtkSmartPointer< vtkActor2D > m_LabelsActor
void SetLabelCoordinates(itk::SmartPointer< PointSet > LabelCoordinates)
Coordinates of the labels.
vtkSmartPointer< vtkStringArray > m_Labels
Internal class holding the vtkActor, etc. for each of the render windows.
void SetPriorityVector(const std::vector< int > &PriorityVector)
Optional: Provide a vector of priorities. The labels with higher priorities will be visible in lower ...
void UpdateGenerateDataTime()
bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Overlay *overlay)
vtkSmartPointer< vtkLabelPlacementMapper > m_LabelMapper
LabelOverlay3D()
explicit constructor which disallows implicit conversions
vtkSmartPointer< vtkIntArray > m_Sizes
void PointSetModified(const itk::Object *, const itk::EventObject &)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.