Slicer  5.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkSlicerPlaneRepresentation3D.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4  Queen's University, Kingston, ON, Canada. All Rights Reserved.
5 
6  See COPYRIGHT.txt
7  or http://www.slicer.org/copyright/copyright.txt for details.
8 
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  See the License for the specific language governing permissions and
13  limitations under the License.
14 
15  This file was originally developed by Kyle Sunderland, PerkLab, Queen's University
16  and was supported through CANARIE's Research Software Program, Cancer
17  Care Ontario, OpenAnatomy, and Brigham and Women's Hospital through NIH grant R01MH112748.
18 
19 ==============================================================================*/
20 
32 #ifndef vtkSlicerPlaneRepresentation3D_h
33 #define vtkSlicerPlaneRepresentation3D_h
34 
35 #include "vtkSlicerMarkupsModuleVTKWidgetsExport.h"
37 
38 class vtkActor;
39 class vtkArrayCalculator;
40 class vtkAppendPolyData;
41 class vtkArrowSource;
42 class vtkGlyph3DMapper;
43 class vtkLookupTable;
45 class vtkPlaneSource;
46 class vtkPolyDataMapper;
47 class vtkPolyData;
48 class vtkTransformPolyDataFilter;
49 class vtkTubeFilter;
50 
51 class VTK_SLICER_MARKUPS_MODULE_VTKWIDGETS_EXPORT vtkSlicerPlaneRepresentation3D : public vtkSlicerMarkupsWidgetRepresentation3D
52 {
53 public:
55  static vtkSlicerPlaneRepresentation3D *New();
56 
59  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
64  void UpdateFromMRML(vtkMRMLNode* caller, unsigned long event, void *callData=nullptr) override;
65 
67  void GetActors(vtkPropCollection *) override;
68  void ReleaseGraphicsResources(vtkWindow *) override;
69  int RenderOverlay(vtkViewport *viewport) override;
70  int RenderOpaqueGeometry(vtkViewport *viewport) override;
71  int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override;
72  vtkTypeBool HasTranslucentPolygonalGeometry() override;
73 
75  double *GetBounds() override;
76 
77  bool GetTransformationReferencePoint(double referencePointWorld[3]) override;
78 
79  void CanInteract(vtkMRMLInteractionEventData* interactionEventData,
80  int &foundComponentType, int &foundComponentIndex, double &closestDistance2) override;
81 
82  void CanInteractWithPlane(vtkMRMLInteractionEventData* interactionEventData,
83  int& foundComponentType, int& foundComponentIndex, double& closestDistance2);
84 
85 protected:
88 
89  vtkNew<vtkPlaneSource> PlaneFillFilter;
90  vtkNew<vtkArrowSource> ArrowFilter;
91  vtkNew<vtkGlyph3D> ArrowGlypher;
92  vtkNew<vtkPolyData> PlaneOutlineInputPolyData;
93  vtkNew<vtkTubeFilter> PlaneOutlineFilter;
94  vtkNew<vtkArrayCalculator> ArrowColorFilter;
95  vtkNew<vtkArrayCalculator> PlaneOutlineColorFilter;
96  vtkNew<vtkArrayCalculator> PlaneFillColorFilter;
97  vtkNew<vtkAppendPolyData> Append;
98 
99  vtkNew<vtkActor> PlaneActor;
100  vtkNew<vtkActor> PlaneOccludedActor;
101 
102  vtkNew<vtkPolyDataMapper> PlaneMapper;
103  vtkNew<vtkPolyDataMapper> PlaneOccludedMapper;
104 
105  vtkNew<vtkLookupTable> PlaneColorLUT;
106 
107  std::string LabelFormat;
108 
109  // Setup the pipeline for plane display
110  void BuildPlane();
111 
112 
113  // Initialize interaction handle pipeline
114  void SetupInteractionPipeline() override;
115 
116  // Update visibility of interaction handles for representation
117  void UpdateInteractionPipeline() override;
118 
119  class VTK_SLICER_MARKUPS_MODULE_VTKWIDGETS_EXPORT MarkupsInteractionPipelinePlane : public MarkupsInteractionPipeline
120  {
121  public:
123  ~MarkupsInteractionPipelinePlane() override = default;
124 
125  // Initialize scale handles
126  void CreateScaleHandles() override;
127 
128  HandleInfoList GetHandleInfoList() override;
129 
130  // Update scale handle positions
131  virtual void UpdateScaleHandles();
132 
133  // Update scale handle visibilities
134  void UpdateHandleVisibility() override;
135 
136  void GetHandleColor(int type, int index, double color[4]) override;
137  double GetHandleOpacity(int type, int index) override;
138 
139  void GetInteractionHandleAxisWorld(int type, int index, double axis[3]) override;
140  };
142 
143 private:
145  void operator=(const vtkSlicerPlaneRepresentation3D&) = delete;
146 };
147 
148 #endif
int RenderOpaqueGeometry(vtkViewport *viewport) override
void PrintSelf(ostream &os, vtkIndent indent) override
vtkTypeBool HasTranslucentPolygonalGeometry() override
Default representation for the markups widget in 3D views.
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
vtkNew< vtkArrayCalculator > ArrowColorFilter
Default representation for the plane widget.
void UpdateInteractionPipeline() override
Update the interaction pipeline.
vtkNew< vtkArrayCalculator > PlaneFillColorFilter
vtkNew< vtkPolyDataMapper > PlaneOccludedMapper
std::vector< MarkupsInteractionPipeline::HandleInfo > HandleInfoList
void UpdateFromMRML(vtkMRMLNode *caller, unsigned long event, void *callData=nullptr) override
double * GetBounds() override
Return the bounds of the representation.
int RenderOverlay(vtkViewport *viewport) override
virtual bool GetTransformationReferencePoint(double referencePointWorld[3])
Translation, rotation, scaling will happen around this position.
void CanInteract(vtkMRMLInteractionEventData *interactionEventData, int &foundComponentType, int &foundComponentIndex, double &closestDistance2) override
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
void ReleaseGraphicsResources(vtkWindow *) override
vtkNew< vtkArrayCalculator > PlaneOutlineColorFilter
Default representation for the plane widget.
void GetActors(vtkPropCollection *) override
Methods to make this class behave as a vtkProp.