Slicer 5.9
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
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, int& foundComponentType, int& foundComponentIndex, double& closestDistance2) override;
58
61 void CanInteractWithLine(vtkMRMLInteractionEventData* interactionEventData, int& foundComponentType, int& foundComponentIndex, double& closestDistance2);
62
66 void UpdateFromMRMLInternal(vtkMRMLNode* caller, unsigned long event, void* callData = nullptr) override;
67
69 void GetActors(vtkPropCollection*) override;
70 void ReleaseGraphicsResources(vtkWindow*) override;
71 int RenderOverlay(vtkViewport* viewport) override;
72 int RenderOpaqueGeometry(vtkViewport* viewport) override;
73 int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
74 vtkTypeBool HasTranslucentPolygonalGeometry() override;
75
79 int GetNthControlPointDisplayPosition(int n, double pos[2]) override;
80
85
87 virtual void SetNthControlPointSliceVisibility(int n, bool visibility);
88
90 virtual void SetCenterSliceVisibility(bool visibility);
91
92 void GetSliceToWorldCoordinates(const double[2], double[3]);
93 void GetWorldToSliceCoordinates(const double worldPos[3], double slicePos[2]);
94
95protected:
98
101
103
104 void UpdateViewScaleFactor() override;
105 void UpdateControlPointSize() override;
106
107 // Return squared distance of maximum distance for picking a control point,
108 // in pixels.
110
112
114 virtual bool IsControlPointDisplayableOnSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
115
116 // Update colormap based on provided base color (modulated with settings stored in the display node)
117 virtual void UpdateDistanceColorMap(vtkDiscretizableColorTransferFunction* colormap, double color[3]);
118
120 virtual bool IsPointBehindSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
121
123 virtual bool IsPointInFrontSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
124
127
129 void GetWorldToDisplayCoordinates(double r, double a, double s, double* displayCoordinates);
130 void GetWorldToDisplayCoordinates(double* worldCoordinates, double* displayCoordinates);
131
133 bool IsRepresentationIntersectingSlice(vtkPolyData* representation, const char* arrayName);
134
136 {
137 public:
140
141 vtkSmartPointer<vtkActor2D> Actor;
142 vtkSmartPointer<vtkPolyDataMapper2D> Mapper;
143 vtkSmartPointer<vtkGlyph2D> Glypher;
144 vtkSmartPointer<vtkActor2D> LabelsActor;
145 vtkSmartPointer<vtkLabelPlacementMapper> LabelsMapper;
146 // Properties used to control the appearance of selected objects and
147 // the manipulator in general.
148 vtkSmartPointer<vtkProperty2D> Property;
149 };
150
152
153 vtkSmartPointer<vtkIntArray> PointsVisibilityOnSlice;
154 bool CenterVisibilityOnSlice = { false };
155 bool AnyPointVisibilityOnSlice = { false }; // at least one point is visible
156
157 vtkSmartPointer<vtkTransform> WorldToSliceTransform;
158 vtkSmartPointer<vtkPlane> SlicePlane;
159
160 virtual void UpdateAllPointsAndLabelsFromMRML(double labelsOffset);
161
162 double GetWidgetOpacity(int controlPointType);
163
164private:
166 void operator=(const vtkSlicerMarkupsWidgetRepresentation2D&) = delete;
167};
168
169#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