Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkSlicerMarkupsWidgetRepresentation3D.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 
27 #ifndef vtkSlicerMarkupsWidgetRepresentation3D_h
28 #define vtkSlicerMarkupsWidgetRepresentation3D_h
29 
30 #include "vtkSlicerMarkupsModuleVTKWidgetsExport.h"
32 
33 class vtkActor;
34 class vtkActor2D;
35 class vtkCellPicker;
36 class vtkGlyph3D;
37 class vtkLabelPlacementMapper;
38 class vtkPolyDataMapper;
39 class vtkProperty;
40 class vtkSelectVisiblePoints;
41 
43 
44 class VTK_SLICER_MARKUPS_MODULE_VTKWIDGETS_EXPORT vtkSlicerMarkupsWidgetRepresentation3D : public vtkSlicerMarkupsWidgetRepresentation
45 {
46 public:
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
51  void SetRenderer(vtkRenderer *ren) override;
52 
56  void UpdateFromMRML(vtkMRMLNode* caller, unsigned long event, void *callData = nullptr) override;
57 
59  void GetActors(vtkPropCollection *) override;
60  void ReleaseGraphicsResources(vtkWindow *) override;
61  int RenderOverlay(vtkViewport *viewport) override;
62  int RenderOpaqueGeometry(vtkViewport *viewport) override;
63  int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override;
64  vtkTypeBool HasTranslucentPolygonalGeometry() override;
65 
67  double *GetBounds() override;
68 
69  void CanInteract(vtkMRMLInteractionEventData* interactionEventData,
70  int &foundComponentType, int &foundComponentIndex, double &closestDistance2) override;
71 
73  virtual void CanInteractWithHandles(vtkMRMLInteractionEventData* interactionEventData,
74  int& foundComponentType, int& foundComponentIndex, double& closestDistance2);
75 
78  void CanInteractWithLine(vtkMRMLInteractionEventData* interactionEventData,
79  int &foundComponentType, int &foundComponentIndex, double &closestDistance2);
80 
81  bool AccuratePick(int x, int y, double pickPoint[3]);
82 
86  bool GetNthControlPointViewVisibility(int n);
87 
92  vtkSetMacro(OccludedRelativeOffset, double);
93  vtkGetMacro(OccludedRelativeOffset, double);
94 
95 protected:
98 
99  double GetViewScaleFactorAtPosition(double positionWorld[3]);
100 
101  void UpdateViewScaleFactor() override;
102 
103  void UpdateControlPointSize() override;
104 
105  void UpdateInteractionPipeline() override;
106 
107  class ControlPointsPipeline3D : public ControlPointsPipeline
108  {
109  public:
111  ~ControlPointsPipeline3D() override;
112 
113  vtkSmartPointer<vtkGlyph3D> Glypher;
114 
115  // Properties used to control the appearance of selected objects and
116  // the manipulator in general.
117  vtkSmartPointer<vtkProperty> Property;
118  vtkSmartPointer<vtkProperty> OccludedProperty;
119  vtkSmartPointer<vtkTextProperty> OccludedTextProperty;
120 
121  vtkSmartPointer<vtkSelectVisiblePoints> SelectVisiblePoints;
122  vtkSmartPointer<vtkIdTypeArray> ControlPointIndices; // store original ID to determine which control point is actually visible
123  vtkSmartPointer<vtkPointSetToLabelHierarchy> OccludedPointSetToLabelHierarchyFilter;
124 
125  vtkSmartPointer<vtkPolyDataMapper> Mapper;
126  vtkSmartPointer<vtkPolyDataMapper> OccludedMapper;
127  vtkSmartPointer<vtkLabelPlacementMapper> LabelsMapper;
128  vtkSmartPointer<vtkLabelPlacementMapper> LabelsOccludedMapper;
129 
130  vtkSmartPointer<vtkActor> Actor;
131  vtkSmartPointer<vtkActor> OccludedActor;
132  vtkSmartPointer<vtkActor2D> LabelsActor;
133  vtkSmartPointer<vtkActor2D> LabelsOccludedActor;
134  };
135 
136  ControlPointsPipeline3D* GetControlPointsPipeline(int controlPointType);
137 
138  virtual void UpdateNthPointAndLabelFromMRML(int n);
139 
140  virtual void UpdateAllPointsAndLabelsFromMRML();
141 
148  void UpdateRelativeCoincidentTopologyOffsets(vtkMapper* mapper, vtkMapper* occludedMapper);
150 
151  vtkSmartPointer<vtkCellPicker> AccuratePicker;
152 
153  double TextActorPositionWorld[3];
157 
158 private:
160  void operator=(const vtkSlicerMarkupsWidgetRepresentation3D&) = delete;
161 };
162 
163 #endif
virtual void CanInteract(vtkMRMLInteractionEventData *interactionEventData, int &foundComponentType, int &foundComponentIndex, double &closestDistance2)
Default representation for the markups widget in 3D views.
virtual void UpdateInteractionPipeline()
Update the interaction pipeline.
void UpdateFromMRML(vtkMRMLNode *caller, unsigned long event, void *callData=nullptr) override
Update the representation from markups node.
int RenderOverlay(vtkViewport *viewport) override
vtkTypeBool HasTranslucentPolygonalGeometry() override
int RenderOpaqueGeometry(vtkViewport *viewport) override
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
void ReleaseGraphicsResources(vtkWindow *) override
void PrintSelf(ostream &os, vtkIndent indent) override
void GetActors(vtkPropCollection *) override
Methods to make this class behave as a vtkProp.
virtual void UpdateRelativeCoincidentTopologyOffsets(vtkMapper *mapper)
virtual void SetRenderer(vtkRenderer *ren)
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167