Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
vtkSlicerMarkupsWidgetRepresentation2D.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
29
30#ifndef vtkSlicerMarkupsWidgetRepresentation2D_h
31#define vtkSlicerMarkupsWidgetRepresentation2D_h
32
33#include "vtkSlicerMarkupsModuleVTKWidgetsExport.h"
35
36#include "vtkMRMLSliceNode.h"
37
38class vtkActor2D;
39class vtkDiscretizableColorTransferFunction;
40class vtkGlyph2D;
41class vtkLabelPlacementMapper;
43class vtkPlane;
44class vtkPolyDataMapper2D;
45class vtkProperty2D;
46
48
49class VTK_SLICER_MARKUPS_MODULE_VTKWIDGETS_EXPORT vtkSlicerMarkupsWidgetRepresentation2D : public vtkSlicerMarkupsWidgetRepresentation
50{
51public:
54 void PrintSelf(ostream& os, vtkIndent indent) override;
55
57 void CanInteract(vtkMRMLInteractionEventData* interactionEventData,
58 int &foundComponentType, int &foundComponentIndex, double &closestDistance2) override;
59
63 int &foundComponentType, int &foundComponentIndex, double &closestDistance2);
64
68 void UpdateFromMRMLInternal(vtkMRMLNode* caller, unsigned long event, void *callData=nullptr) override;
69
71 void GetActors(vtkPropCollection *) override;
72 void ReleaseGraphicsResources(vtkWindow *) override;
73 int RenderOverlay(vtkViewport *viewport) override;
74 int RenderOpaqueGeometry(vtkViewport *viewport) override;
75 int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override;
76 vtkTypeBool HasTranslucentPolygonalGeometry() override;
77
81 int GetNthControlPointDisplayPosition(int n, double pos[2]) override;
82
87
89 virtual void SetNthControlPointSliceVisibility(int n, bool visibility);
90
92 virtual void SetCenterSliceVisibility(bool visibility);
93
94 void GetSliceToWorldCoordinates(const double[2], double[3]);
95 void GetWorldToSliceCoordinates(const double worldPos[3], double slicePos[2]);
96
97protected:
100
103
105
106 void UpdateViewScaleFactor() override;
107 void UpdateControlPointSize() override;
108
109 // Return squared distance of maximum distance for picking a control point,
110 // in pixels.
112
114
116 virtual bool IsControlPointDisplayableOnSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
117
118 // Update colormap based on provided base color (modulated with settings stored in the display node)
119 virtual void UpdateDistanceColorMap(vtkDiscretizableColorTransferFunction* colormap, double color[3]);
120
122 virtual bool IsPointBehindSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
123
125 virtual bool IsPointInFrontSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
126
129
131 void GetWorldToDisplayCoordinates(double r, double a, double s, double * displayCoordinates);
132 void GetWorldToDisplayCoordinates(double * worldCoordinates, double * displayCoordinates);
133
135 bool IsRepresentationIntersectingSlice(vtkPolyData* representation, const char* arrayName);
136
138 {
139 public:
142
143 vtkSmartPointer<vtkActor2D> Actor;
144 vtkSmartPointer<vtkPolyDataMapper2D> Mapper;
145 vtkSmartPointer<vtkGlyph2D> Glypher;
146 vtkSmartPointer<vtkActor2D> LabelsActor;
147 vtkSmartPointer<vtkLabelPlacementMapper> LabelsMapper;
148 // Properties used to control the appearance of selected objects and
149 // the manipulator in general.
150 vtkSmartPointer<vtkProperty2D> Property;
151 };
152
154
155 vtkSmartPointer<vtkIntArray> PointsVisibilityOnSlice;
156 bool CenterVisibilityOnSlice = { false };
157 bool AnyPointVisibilityOnSlice = { false }; // at least one point is visible
158
159 vtkSmartPointer<vtkTransform> WorldToSliceTransform;
160 vtkSmartPointer<vtkPlane> SlicePlane;
161
162 virtual void UpdateAllPointsAndLabelsFromMRML(double labelsOffset);
163
164 double GetWidgetOpacity(int controlPointType);
165
166private:
168 void operator=(const vtkSlicerMarkupsWidgetRepresentation2D&) = delete;
169};
170
171#endif
Abstract Superclass for all specific types of MRML nodes.
MRML node for storing a slice through RAS space.
virtual bool IsCenterDisplayableOnSlice(vtkMRMLMarkupsNode *node)
Check, if the point is displayable in the current slice geometry.
void UpdateFromMRMLInternal(vtkMRMLNode *caller, unsigned long event, void *callData=nullptr) override
virtual void SetNthControlPointSliceVisibility(int n, bool visibility)
Set the Nth node slice visibility (i.e. if it is on the slice).
vtkTypeBool HasTranslucentPolygonalGeometry() override
virtual bool IsControlPointDisplayableOnSlice(vtkMRMLMarkupsNode *node, int pointIndex=0)
Check, if the point is displayable in the current slice geometry.
int GetNthControlPointDisplayPosition(int n, double pos[2]) override
void CanInteractWithLine(vtkMRMLInteractionEventData *interactionEventData, int &foundComponentType, int &foundComponentIndex, double &closestDistance2)
void GetActors(vtkPropCollection *) override
Methods to make this class behave as a vtkProp.
void GetWorldToSliceCoordinates(const double worldPos[3], double slicePos[2])
void GetSliceToWorldCoordinates(const double[2], double[3])
void ReleaseGraphicsResources(vtkWindow *) override
virtual void SetCenterSliceVisibility(bool visibility)
Set the center slice visibility (i.e. if it is on the slice).
virtual bool IsPointInFrontSlice(vtkMRMLMarkupsNode *node, int pointIndex=0)
Check, if the point is in front in the current slice geometry.
double GetWidgetOpacity(int controlPointType)
ControlPointsPipeline2D * GetControlPointsPipeline(int controlPointType)
virtual void UpdateDistanceColorMap(vtkDiscretizableColorTransferFunction *colormap, double color[3])
vtkMRMLSliceNode * GetSliceNode()
Get MRML view node as slice view node.
virtual bool GetNthControlPointViewVisibility(int n)
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
virtual bool IsPointBehindSlice(vtkMRMLMarkupsNode *node, int pointIndex=0)
Check, if the point is behind in the current slice geometry.
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void UpdateAllPointsAndLabelsFromMRML(double labelsOffset)
int RenderOverlay(vtkViewport *viewport) override
bool IsRepresentationIntersectingSlice(vtkPolyData *representation, const char *arrayName)
Check if the representation polydata intersects the slice.
void GetWorldToDisplayCoordinates(double *worldCoordinates, double *displayCoordinates)
void GetWorldToDisplayCoordinates(double r, double a, double s, double *displayCoordinates)
Convert display to world coordinates.
bool GetAllControlPointsVisible() override
Convenience method.
void CanInteract(vtkMRMLInteractionEventData *interactionEventData, int &foundComponentType, int &foundComponentIndex, double &closestDistance2) override
Position is displayed (slice) position.
int RenderOpaqueGeometry(vtkViewport *viewport) override