Slicer 5.11
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
38#include <memory>
39
40class vtkActor2D;
41class vtkAlgorithmOutput;
42class vtkDoubleArray;
43class vtkDiscretizableColorTransferFunction;
44class vtkFloatArray;
45class vtkGlyph2D;
46class vtkLabelPlacementMapper;
48class vtkPlane;
49class vtkPoints;
50class vtkPolyData;
51class vtkPolyDataMapper2D;
52class vtkProperty2D;
53class vtkScalarsToColors;
54
56
57class VTK_SLICER_MARKUPS_MODULE_VTKWIDGETS_EXPORT vtkSlicerMarkupsWidgetRepresentation2D : public vtkSlicerMarkupsWidgetRepresentation
58{
59public:
62 void PrintSelf(ostream& os, vtkIndent indent) override;
63
65 void CanInteract(vtkMRMLInteractionEventData* interactionEventData, int& foundComponentType, int& foundComponentIndex, double& closestDistance2) override;
66
69 void CanInteractWithLine(vtkMRMLInteractionEventData* interactionEventData, int& foundComponentType, int& foundComponentIndex, double& closestDistance2);
70
74 void UpdateFromMRMLInternal(vtkMRMLNode* caller, unsigned long event, void* callData = nullptr) override;
75
77 void GetActors(vtkPropCollection*) override;
78 void ReleaseGraphicsResources(vtkWindow*) override;
79 int RenderOverlay(vtkViewport* viewport) override;
80 int RenderOpaqueGeometry(vtkViewport* viewport) override;
81 int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
82 vtkTypeBool HasTranslucentPolygonalGeometry() override;
83
87 int GetNthControlPointDisplayPosition(int n, double pos[2]) override;
88
93
95 virtual void SetNthControlPointSliceVisibility(int n, bool visibility);
96
98 virtual void SetCenterSliceVisibility(bool visibility);
99
100 void GetSliceToWorldCoordinates(const double[2], double[3]);
101 void GetWorldToSliceCoordinates(const double worldPos[3], double slicePos[2]);
102
103protected:
106
109
111
112 void UpdateViewScaleFactor() override;
113 void UpdateControlPointSize() override;
114
115 // Return squared distance of maximum distance for picking a control point,
116 // in pixels.
118
120
122 virtual bool IsControlPointDisplayableOnSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
123
124 // Update colormap based on provided base color (modulated with settings stored in the display node)
125 virtual void UpdateDistanceColorMap(vtkDiscretizableColorTransferFunction* colormap, double color[3]);
126
128 virtual bool IsPointBehindSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
129
131 virtual bool IsPointInFrontSlice(vtkMRMLMarkupsNode* node, int pointIndex = 0);
132
135
137 void GetWorldToDisplayCoordinates(double r, double a, double s, double* displayCoordinates);
138 void GetWorldToDisplayCoordinates(double* worldCoordinates, double* displayCoordinates);
139
141 bool IsRepresentationIntersectingSlice(vtkPolyData* representation, const char* arrayName);
142
153 virtual void ComputeIntersectionFadingScalars(vtkPolyData* worldPolyData,
154 vtkPlane* slicePlane,
155 vtkPolyData* outputPolyData,
156 vtkFloatArray* distanceArray = nullptr,
157 vtkPoints* intersectionPoints = nullptr);
158
161 virtual void UpdateSliceIntersectionPointDisplay(double glyphSize, vtkScalarsToColors* colorMap);
162
164 {
165 public:
168
169 vtkSmartPointer<vtkActor2D> Actor;
170 vtkSmartPointer<vtkPolyDataMapper2D> Mapper;
171 vtkSmartPointer<vtkGlyph2D> Glypher;
172 vtkSmartPointer<vtkActor2D> LabelsActor;
173 vtkSmartPointer<vtkLabelPlacementMapper> LabelsMapper;
174 // Properties used to control the appearance of selected objects and
175 // the manipulator in general.
176 vtkSmartPointer<vtkProperty2D> Property;
177 };
178
180
181 vtkSmartPointer<vtkIntArray> PointsVisibilityOnSlice;
182 bool CenterVisibilityOnSlice = { false };
183 bool AnyPointVisibilityOnSlice = { false }; // at least one point is visible
184
185 vtkSmartPointer<vtkTransform> WorldToSliceTransform;
186 vtkSmartPointer<vtkPlane> SlicePlane;
187
192 {
193 public:
194 LineIntersectionPointsPipeline2D(vtkAlgorithmOutput* glyphSourcePort, vtkProperty2D* property);
196
197 vtkSmartPointer<vtkPoints> DisplayPoints;
198 vtkSmartPointer<vtkPolyData> PointsPoly;
199 vtkSmartPointer<vtkGlyph2D> Glypher;
200 vtkSmartPointer<vtkPolyDataMapper2D> Mapper;
201 vtkSmartPointer<vtkProperty2D> Property;
202 vtkSmartPointer<vtkActor2D> Actor;
203 };
204
211 {
212 public:
215
216 vtkSmartPointer<vtkPoints> Points;
217 vtkSmartPointer<vtkDoubleArray> Normals;
218 vtkSmartPointer<vtkFloatArray> SliceDistances;
219 vtkSmartPointer<vtkPolyData> PointsPoly;
220 vtkSmartPointer<vtkGlyph2D> Glypher;
221 vtkSmartPointer<vtkPolyDataMapper2D> Mapper;
222 vtkSmartPointer<vtkActor2D> Actor;
223 };
224
226 std::unique_ptr<LineDirectionArrowPipeline2D> LineDirectionArrowPipeline;
227
230 vtkSmartPointer<vtkPoints> LineDirectionMarkerCachedWorldPositions;
231 vtkSmartPointer<vtkDoubleArray> LineDirectionMarkerCachedWorldTangents;
237
238 // Line slice intersection point glyph pipelines (2D).
239 // Mark the exact positions where a curve/line crosses the slice plane.
240 // Entering (CircledCross) and exiting (CircledPoint) are driven by
241 // SliceIntersectionApproachingSigns.
242 vtkSmartPointer<vtkPoints> LineSliceIntersectionWorldPoints;
243 vtkSmartPointer<vtkFloatArray> LineSliceIntersectionApproachingSigns;
244 vtkSmartPointer<vtkProperty2D> LineSliceIntersectionProperty;
245 std::unique_ptr<LineIntersectionPointsPipeline2D> LineSliceIntersectionEnteringPipeline;
246 std::unique_ptr<LineIntersectionPointsPipeline2D> LineSliceIntersectionExitingPipeline;
247
254
255 virtual void UpdateAllPointsAndLabelsFromMRML(double labelsOffset);
256
257 double GetWidgetOpacity(int controlPointType);
258
259private:
261 void operator=(const vtkSlicerMarkupsWidgetRepresentation2D&) = delete;
262};
263
264#endif
Abstract Superclass for all specific types of MRML nodes.
MRML node for storing a slice through RAS space.
vtkSmartPointer< vtkFloatArray > SliceDistances
signed distance to slice per marker, drives opacity fading
LineIntersectionPointsPipeline2D(vtkAlgorithmOutput *glyphSourcePort, vtkProperty2D *property)
vtkSmartPointer< vtkFloatArray > LineSliceIntersectionApproachingSigns
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
virtual void UpdateSliceIntersectionPointDisplay(double glyphSize, vtkScalarsToColors *colorMap)
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
std::unique_ptr< LineIntersectionPointsPipeline2D > LineSliceIntersectionExitingPipeline
virtual void ComputeIntersectionFadingScalars(vtkPolyData *worldPolyData, vtkPlane *slicePlane, vtkPolyData *outputPolyData, vtkFloatArray *distanceArray=nullptr, vtkPoints *intersectionPoints=nullptr)
bool IsRepresentationIntersectingSlice(vtkPolyData *representation, const char *arrayName)
Check if the representation polydata intersects the slice.
std::unique_ptr< LineDirectionArrowPipeline2D > LineDirectionArrowPipeline
Direction arrow glyph pipeline (2D).
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.
std::unique_ptr< LineIntersectionPointsPipeline2D > LineSliceIntersectionEnteringPipeline
vtkSmartPointer< vtkDoubleArray > LineDirectionMarkerCachedWorldTangents
int RenderOpaqueGeometry(vtkViewport *viewport) override