Slicer  5.0
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<vtkTubeFilter> PlaneOutlineFilter;
93  vtkNew<vtkArrayCalculator> ArrowColorFilter;
94  vtkNew<vtkArrayCalculator> PlaneOutlineColorFilter;
95  vtkNew<vtkArrayCalculator> PlaneFillColorFilter;
96  vtkNew<vtkAppendPolyData> Append;
97 
98  vtkNew<vtkActor> PlaneActor;
99  vtkNew<vtkActor> PlaneOccludedActor;
100 
101  vtkNew<vtkPolyDataMapper> PlaneMapper;
102  vtkNew<vtkPolyDataMapper> PlaneOccludedMapper;
103 
104  vtkNew<vtkLookupTable> PlaneColorLUT;
105 
106  std::string LabelFormat;
107 
108  // Setup the pipeline for plane display
109  void BuildPlane();
110 
111 
112  // Initialize interaction handle pipeline
113  void SetupInteractionPipeline() override;
114 
115  // Update visibility of interaction handles for representation
116  void UpdateInteractionPipeline() override;
117 
118  class VTK_SLICER_MARKUPS_MODULE_VTKWIDGETS_EXPORT MarkupsInteractionPipelinePlane : public MarkupsInteractionPipeline
119  {
120  public:
122  ~MarkupsInteractionPipelinePlane() override = default;
123 
124  // Initialize scale handles
125  void CreateScaleHandles() override;
126 
127  HandleInfoList GetHandleInfoList() override;
128 
129  // Update scale handle positions
130  virtual void UpdateScaleHandles();
131 
132  // Update scale handle visibilities
133  void UpdateHandleVisibility() override;
134 
135  void GetHandleColor(int type, int index, double color[4]) override;
136  double GetHandleOpacity(int type, int index) override;
137 
138  void GetInteractionHandleAxisWorld(int type, int index, double axis[3]) override;
139  };
141 
142 private:
144  void operator=(const vtkSlicerPlaneRepresentation3D&) = delete;
145 };
146 
147 #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.