Slicer 5.6
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
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
61 virtual void CanInteractWithHandles(vtkMRMLInteractionEventData* interactionEventData,
62 int& foundComponentType, int& foundComponentIndex, double& closestDistance2);
63
67 int &foundComponentType, int &foundComponentIndex, double &closestDistance2);
68
72 void UpdateFromMRMLInternal(vtkMRMLNode* caller, unsigned long event, void *callData=nullptr) override;
73
75 void GetActors(vtkPropCollection *) override;
76 void ReleaseGraphicsResources(vtkWindow *) override;
77 int RenderOverlay(vtkViewport *viewport) override;
78 int RenderOpaqueGeometry(vtkViewport *viewport) override;
79 int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override;
80 vtkTypeBool HasTranslucentPolygonalGeometry() override;
81
85 int GetNthControlPointDisplayPosition(int n, double pos[2]) override;
86
91
93 virtual void SetNthControlPointSliceVisibility(int n, bool visibility);
94
96 virtual void SetCenterSliceVisibility(bool visibility);
97
98 void GetSliceToWorldCoordinates(const double[2], double[3]);
99 void GetWorldToSliceCoordinates(const double worldPos[3], double slicePos[2]);
100
102
103protected:
106
109
112
114
115 void UpdateViewScaleFactor() override;
116 void UpdateControlPointSize() override;
117
118 // Return squared distance of maximum distance for picking a control point,
119 // in pixels.
121 // Return squared distance of maximum distance for picking an interaction handle,
122 // in pixels.
124
126
128 virtual bool IsControlPointDisplayableOnSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
129
130 // Update colormap based on provided base color (modulated with settings stored in the display node)
131 virtual void UpdateDistanceColorMap(vtkDiscretizableColorTransferFunction* colormap, double color[3]);
132
134 virtual bool IsPointBehindSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
135
137 virtual bool IsPointInFrontSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
138
141
143 void GetWorldToDisplayCoordinates(double r, double a, double s, double * displayCoordinates);
144 void GetWorldToDisplayCoordinates(double * worldCoordinates, double * displayCoordinates);
145
147 bool IsRepresentationIntersectingSlice(vtkPolyData* representation, const char* arrayName);
148
150 {
151 public:
154
155 vtkSmartPointer<vtkActor2D> Actor;
156 vtkSmartPointer<vtkPolyDataMapper2D> Mapper;
157 vtkSmartPointer<vtkGlyph2D> Glypher;
158 vtkSmartPointer<vtkActor2D> LabelsActor;
159 vtkSmartPointer<vtkLabelPlacementMapper> LabelsMapper;
160 // Properties used to control the appearance of selected objects and
161 // the manipulator in general.
162 vtkSmartPointer<vtkProperty2D> Property;
163 };
164
166
167 vtkSmartPointer<vtkIntArray> PointsVisibilityOnSlice;
168 bool CenterVisibilityOnSlice = { false };
169 bool AnyPointVisibilityOnSlice = { false }; // at least one point is visible
170
171 vtkSmartPointer<vtkTransform> WorldToSliceTransform;
172 vtkSmartPointer<vtkPlane> SlicePlane;
173
174 virtual void UpdateAllPointsAndLabelsFromMRML(double labelsOffset);
175
176 double GetWidgetOpacity(int controlPointType);
177
179 {
180 public:
182 ~MarkupsInteractionPipeline2D() override = default;;
183
184 void GetViewPlaneNormal(double viewPlaneNormal[3]) override;
185
186 vtkSmartPointer<vtkTransformPolyDataFilter> WorldToSliceTransformFilter;
187 };
188
189private:
191 void operator=(const vtkSlicerMarkupsWidgetRepresentation2D&) = delete;
192};
193
194#endif
Abstract Superclass for all specific types of MRML nodes.
MRML node for storing a slice through RAS space.
void GetViewPlaneNormal(double viewPlaneNormal[3]) override
Get the view plane normal for the widget in world coordinates.
MarkupsInteractionPipeline2D(vtkSlicerMarkupsWidgetRepresentation *representation)
Default representation for the slicer markups widget.
virtual void CanInteractWithHandles(vtkMRMLInteractionEventData *interactionEventData, int &foundComponentType, int &foundComponentIndex, double &closestDistance2)
Check if interaction with the transformation handles is possible.
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)
void SetupInteractionPipeline() override
Reimplemented for 2D specific mapper/actor settings.
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 UpdateInteractionPipeline() override
Update the interaction pipeline.
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