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
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 {
82 NumberOfControlPointTypes
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,
127 int &foundComponentType, int &foundComponentIndex, double &closestDistance2);
128
129 virtual int FindClosestPointOnWidget(const int displayPos[2], double worldPos[3], int *idx);
130
131 virtual vtkPointPlacer* GetPointPlacer();
132
135 virtual vtkPolyData* GetControlPointsPolyData(int controlPointType);
138 virtual vtkPolyData* GetLabelControlPointsPolyData(int pipeline);
141 virtual vtkStringArray* GetLabels(int pipeline);
142
144
150
151protected:
154
155 // Convert glyph types from display node enums to 2D glyph source enums
156 static int GetGlyphTypeSourceFromDisplay(int glyphTypeDisplay);
157
159 {
160 public:
163
168 //vtkSmartPointer<vtkPolyData> PointMarkerShape;
169 vtkSmartPointer<vtkMarkupsGlyphSource2D> GlyphSource2D;
170 vtkSmartPointer<vtkSphereSource> GlyphSourceSphere;
171
172 vtkSmartPointer<vtkPolyData> ControlPointsPolyData;
173 vtkSmartPointer<vtkPoints> ControlPoints;
174 vtkSmartPointer<vtkPolyData> LabelControlPointsPolyData;
175 vtkSmartPointer<vtkPoints> LabelControlPoints;
176 vtkSmartPointer<vtkPointSetToLabelHierarchy> PointSetToLabelHierarchyFilter;
177 vtkSmartPointer<vtkStringArray> Labels;
178 vtkSmartPointer<vtkStringArray> LabelsPriority;
179 vtkSmartPointer<vtkTextProperty> TextProperty;
180 };
181
182 // Calculate view size and scale factor
183 virtual void UpdateViewScaleFactor() = 0;
184
185 virtual void UpdateControlPointSize() = 0;
186
188 double ScreenSizePixel; // diagonal size of the screen
189
190 // Control point size, specified in renderer world coordinate system.
191 // For slice views, renderer world coordinate system is the display coordinate system, so it is measured in pixels.
192 // For 3D views, renderer world coordinate system is the Slicer world coordinate system, so it is measured in the
193 // scene length unit (typically millimeters).
195
196 virtual void SetMarkupsNode(vtkMRMLMarkupsNode *markupsNode);
197
198 vtkWeakPointer<vtkMRMLMarkupsDisplayNode> MarkupsDisplayNode;
199 vtkWeakPointer<vtkMRMLMarkupsNode> MarkupsNode;
200
201 vtkSmartPointer<vtkPointPlacer> PointPlacer;
202
203 vtkSmartPointer<vtkTextActor> TextActor;
204
205 vtkTypeBool CurveClosed;
206
209
212
213 // Utility function to build straight lines between control points.
214 // If displayPosition is true then positions will be computed in display coordinate system,
215 // otherwise in world coordinate system.
216 // displayPosition is normally set to true in 2D, and to false in 3D representations.
217 void BuildLine(vtkPolyData* linePolyData, bool displayPosition);
218
220
221 double* GetWidgetColor(int controlPointType) VTK_SIZEHINT(3);
222
223 ControlPointsPipeline* ControlPoints[NumberOfControlPointTypes]; // Unselected, Selected, Active, Project, ProjectBehind
224
225private:
227 void operator=(const vtkSlicerMarkupsWidgetRepresentation&) = delete;
228};
229
230#endif
Abstract Superclass for all specific types of MRML nodes.
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)