Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkSlicerMarkupsWidgetRepresentation.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Copyright (c) ProxSim ltd., Kwun Tong, Hong Kong. All Rights Reserved.
4
5 See COPYRIGHT.txt
6 or http://www.slicer.org/copyright/copyright.txt for details.
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
13
14 This file was originally developed by Davide Punzo, punzodavide@hotmail.it,
15 and development was supported by ProxSim ltd.
16
17=========================================================================*/
18
40
41#ifndef vtkSlicerMarkupsWidgetRepresentation_h
42#define vtkSlicerMarkupsWidgetRepresentation_h
43
44#include "vtkSlicerMarkupsModuleVTKWidgetsExport.h"
45
48#include "vtkMRMLMarkupsNode.h"
49
50#include "vtkActor2D.h"
51#include "vtkAppendPolyData.h"
52#include "vtkArcSource.h"
53#include "vtkArrowSource.h"
54#include "vtkGlyph3D.h"
55#include "vtkLookupTable.h"
57#include "vtkPointPlacer.h"
58#include "vtkPointSetToLabelHierarchy.h"
59#include "vtkPolyDataMapper2D.h"
60#include "vtkProperty2D.h"
61#include "vtkSmartPointer.h"
62#include "vtkSphereSource.h"
63#include "vtkTextActor.h"
64#include "vtkTextProperty.h"
65#include "vtkTensorGlyph.h"
66#include "vtkTransform.h"
67#include "vtkTransformPolyDataFilter.h"
68#include "vtkTubeFilter.h"
69
71
72class VTK_SLICER_MARKUPS_MODULE_VTKWIDGETS_EXPORT vtkSlicerMarkupsWidgetRepresentation : public vtkMRMLAbstractWidgetRepresentation
73{
74public:
75 enum
76 {
83 };
84
87 void PrintSelf(ostream& os, vtkIndent indent) override;
88
90 void UpdateFromMRML(vtkMRMLNode* caller, unsigned long event, void* callData = nullptr) override;
91 virtual void UpdateFromMRMLInternal(vtkMRMLNode* caller, unsigned long event, void* callData = nullptr);
92
94 void GetActors(vtkPropCollection*) override;
95 void ReleaseGraphicsResources(vtkWindow*) override;
96 int RenderOverlay(vtkViewport* viewport) override;
97 int RenderOpaqueGeometry(vtkViewport* viewport) override;
98 int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
99 vtkTypeBool HasTranslucentPolygonalGeometry() override;
100
103
107 virtual int GetNthControlPointDisplayPosition(int n, double pos[2]);
108
111
113 virtual void SetMarkupsDisplayNode(vtkMRMLMarkupsDisplayNode* markupsDisplayNode);
116
119
121 virtual bool GetTransformationReferencePoint(double referencePointWorld[3]);
122
126 virtual void CanInteract(vtkMRMLInteractionEventData* interactionEventData, int& foundComponentType, int& foundComponentIndex, double& closestDistance2);
127
128 virtual int FindClosestPointOnWidget(const int displayPos[2], double worldPos[3], int* idx);
129
130 virtual vtkPointPlacer* GetPointPlacer();
131
134 virtual vtkPolyData* GetControlPointsPolyData(int controlPointType);
137 virtual vtkPolyData* GetLabelControlPointsPolyData(int pipeline);
140 virtual vtkStringArray* GetLabels(int pipeline);
141
143
149
150protected:
153
154 // Convert glyph types from display node enums to 2D glyph source enums
155 static int GetGlyphTypeSourceFromDisplay(int glyphTypeDisplay);
156
158 {
159 public:
162
167 // vtkSmartPointer<vtkPolyData> PointMarkerShape;
168 vtkSmartPointer<vtkMarkupsGlyphSource2D> GlyphSource2D;
169 vtkSmartPointer<vtkSphereSource> GlyphSourceSphere;
170
171 vtkSmartPointer<vtkPolyData> ControlPointsPolyData;
172 vtkSmartPointer<vtkPoints> ControlPoints;
173 vtkSmartPointer<vtkPolyData> LabelControlPointsPolyData;
174 vtkSmartPointer<vtkPoints> LabelControlPoints;
175 vtkSmartPointer<vtkPointSetToLabelHierarchy> PointSetToLabelHierarchyFilter;
176 vtkSmartPointer<vtkStringArray> Labels;
177 vtkSmartPointer<vtkStringArray> LabelsPriority;
178 vtkSmartPointer<vtkTextProperty> TextProperty;
179 };
180
181 // Calculate view size and scale factor
182 virtual void UpdateViewScaleFactor() = 0;
183
184 virtual void UpdateControlPointSize() = 0;
185
187 double ScreenSizePixel; // diagonal size of the screen
188
189 // Control point size, specified in renderer world coordinate system.
190 // For slice views, renderer world coordinate system is the display coordinate system, so it is measured in pixels.
191 // For 3D views, renderer world coordinate system is the Slicer world coordinate system, so it is measured in the
192 // scene length unit (typically millimeters).
194
195 virtual void SetMarkupsNode(vtkMRMLMarkupsNode* markupsNode);
196
197 vtkWeakPointer<vtkMRMLMarkupsDisplayNode> MarkupsDisplayNode;
198 vtkWeakPointer<vtkMRMLMarkupsNode> MarkupsNode;
199
200 vtkSmartPointer<vtkPointPlacer> PointPlacer;
201
202 vtkSmartPointer<vtkTextActor> TextActor;
203
204 vtkTypeBool CurveClosed;
205
208
211
212 // Utility function to build straight lines between control points.
213 // If displayPosition is true then positions will be computed in display coordinate system,
214 // otherwise in world coordinate system.
215 // displayPosition is normally set to true in 2D, and to false in 3D representations.
216 void BuildLine(vtkPolyData* linePolyData, bool displayPosition);
217
219
220 double* GetWidgetColor(int controlPointType) VTK_SIZEHINT(3);
221
222 ControlPointsPipeline* ControlPoints[NumberOfControlPointTypes]; // Unselected, Selected, Active, Project, ProjectBehind
223
224private:
226 void operator=(const vtkSlicerMarkupsWidgetRepresentation&) = delete;
227};
228
229#endif
Abstract Superclass for all specific types of MRML nodes.
ControlPointsPipeline * ControlPoints[NumberOfControlPointTypes]
void GetActors(vtkPropCollection *) override
Methods to make this class behave as a vtkProp.
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
vtkTypeBool HasTranslucentPolygonalGeometry() override
virtual void UpdateFromMRMLInternal(vtkMRMLNode *caller, unsigned long event, void *callData=nullptr)
int RenderOverlay(vtkViewport *viewport) override
virtual int FindClosestPointOnWidget(const int displayPos[2], double worldPos[3], int *idx)
void BuildLine(vtkPolyData *linePolyData, bool displayPosition)
virtual void SetMarkupsDisplayNode(vtkMRMLMarkupsDisplayNode *markupsDisplayNode)
Set/Get the vtkMRMLMarkupsNode connected with this representation.
virtual vtkMRMLMarkupsNode::ControlPoint * GetNthControlPoint(int n)
Get the nth control point.
vtkWeakPointer< vtkMRMLMarkupsDisplayNode > MarkupsDisplayNode
void UpdateFromMRML(vtkMRMLNode *caller, unsigned long event, void *callData=nullptr) override
Update the representation from markups node.
virtual int GetNthControlPointDisplayPosition(int n, double pos[2])
double * GetWidgetColor(int controlPointType) VTK_SIZEHINT(3)
virtual vtkPointPlacer * GetPointPlacer()
void PrintSelf(ostream &os, vtkIndent indent) override
virtual vtkPolyData * GetLabelControlPointsPolyData(int pipeline)
int RenderOpaqueGeometry(vtkViewport *viewport) override
virtual vtkStringArray * GetLabels(int pipeline)
bool GetAllControlPointsSelected()
Convenience method.
virtual bool GetTransformationReferencePoint(double referencePointWorld[3])
Translation, rotation, scaling will happen around this position.
static int GetGlyphTypeSourceFromDisplay(int glyphTypeDisplay)
virtual vtkPolyData * GetControlPointsPolyData(int controlPointType)
virtual void UpdateCenterOfRotation()
Compute the center of rotation and update it in the Markups node.
virtual vtkMRMLMarkupsNode * GetMarkupsNode()
virtual vtkMRMLMarkupsDisplayNode * GetMarkupsDisplayNode()
void ReleaseGraphicsResources(vtkWindow *) override
virtual void SetMarkupsNode(vtkMRMLMarkupsNode *markupsNode)
virtual bool GetAllControlPointsVisible()
Convenience method.
virtual int GetNumberOfControlPoints()
Get number of control points.
virtual void CanInteract(vtkMRMLInteractionEventData *interactionEventData, int &foundComponentType, int &foundComponentIndex, double &closestDistance2)