1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkOrientedPolygonalHandleRepresentation3D.cxx
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 #include "vtkOrientedPolygonalHandleRepresentation3D.h"
16 #include "vtkActor.h"
17 #include "vtkCamera.h"
18 #include "vtkCellPicker.h"
19 #include "vtkFollower.h"
20 #include "vtkObjectFactory.h"
21 #include "vtkPolyDataMapper.h"
22 #include "vtkProperty.h"
23 #include "vtkRenderer.h"
24 #include "vtkTransformPolyDataFilter.h"
25 
26 vtkStandardNewMacro(vtkOrientedPolygonalHandleRepresentation3D);
27 
28 //------------------------------------------------------------------------------
vtkOrientedPolygonalHandleRepresentation3D()29 vtkOrientedPolygonalHandleRepresentation3D ::vtkOrientedPolygonalHandleRepresentation3D()
30 {
31   this->Actor = vtkFollower::New();
32   this->Actor->SetMapper(this->Mapper);
33   this->Actor->SetProperty(this->Property);
34   this->HandlePicker->AddPickList(this->Actor);
35 }
36 
37 //------------------------------------------------------------------------------
38 vtkOrientedPolygonalHandleRepresentation3D ::~vtkOrientedPolygonalHandleRepresentation3D() =
39   default;
40 
41 //------------------------------------------------------------------------------
UpdateHandle()42 void vtkOrientedPolygonalHandleRepresentation3D::UpdateHandle()
43 {
44   this->Superclass::UpdateHandle();
45 
46   // Our handle actor is a follower. It follows the camera set on it.
47   if (this->Renderer)
48   {
49     vtkFollower* follower = vtkFollower::SafeDownCast(this->Actor);
50     if (follower)
51     {
52       follower->SetCamera(this->Renderer->GetActiveCamera());
53     }
54   }
55 
56   // Update the actor position
57   double handlePosition[3];
58   this->GetWorldPosition(handlePosition);
59   this->Actor->SetPosition(handlePosition);
60 }
61 
62 //------------------------------------------------------------------------------
PrintSelf(ostream & os,vtkIndent indent)63 void vtkOrientedPolygonalHandleRepresentation3D::PrintSelf(ostream& os, vtkIndent indent)
64 {
65   this->Superclass::PrintSelf(os, indent);
66 }
67