33 #include <vtkBoxRepresentation.h> 35 #include <vtkSphereSource.h> 36 #include <vtkPolyDataMapper.h> 37 #include <vtkPolyData.h> 38 #include <vtkCallbackCommand.h> 40 #include <vtkPolyData.h> 41 #include <vtkProperty.h> 42 #include <vtkRenderWindowInteractor.h> 43 #include <vtkRenderer.h> 44 #include <vtkInteractorObserver.h> 46 #include <vtkCellArray.h> 47 #include <vtkCellPicker.h> 48 #include <vtkTransform.h> 49 #include <vtkDoubleArray.h> 51 #include <vtkPlanes.h> 52 #include <vtkCamera.h> 53 #include <vtkAssemblyPath.h> 54 #include <vtkWindow.h> 55 #include <vtkObjectFactory.h> 57 #include "fwRenderVTK/vtk/fwVtkBoxRepresentation.hpp" 62 fwVtkBoxRepresentation::fwVtkBoxRepresentation() : vtkBoxRepresentation()
65 this->TranslationEnabled = 1;
66 this->RotationEnabled = 1;
67 this->ScalingEnabled = 1;
71 void fwVtkBoxRepresentation::WidgetInteraction(
double e[2])
74 vtkCamera* camera = this->Renderer->GetActiveCamera();
79 double focalPoint[4], pickPoint[4], prevPickPoint[4];
81 camera->GetViewPlaneNormal(vpn);
85 if ( this->LastPicker == this->HexPicker )
87 this->HexPicker->GetPickPosition(pos);
91 this->HandlePicker->GetPickPosition(pos);
93 vtkInteractorObserver::ComputeWorldToDisplay(this->Renderer,
94 pos[0], pos[1], pos[2],
97 vtkInteractorObserver::ComputeDisplayToWorld(this->Renderer,this->LastEventPosition[0],
98 this->LastEventPosition[1], z, prevPickPoint);
99 vtkInteractorObserver::ComputeDisplayToWorld(this->Renderer, e[0], e[1], z, pickPoint);
102 if ( this->ScalingEnabled && this->InteractionState == fwVtkBoxRepresentation::MoveF0 )
104 this->MoveMinusXFace(prevPickPoint,pickPoint);
107 else if ( this->ScalingEnabled && this->InteractionState == fwVtkBoxRepresentation::MoveF1 )
109 this->MovePlusXFace(prevPickPoint,pickPoint);
112 else if ( this->ScalingEnabled && this->InteractionState == fwVtkBoxRepresentation::MoveF2 )
114 this->MoveMinusYFace(prevPickPoint,pickPoint);
117 else if ( this->ScalingEnabled && this->InteractionState == fwVtkBoxRepresentation::MoveF3 )
119 this->MovePlusYFace(prevPickPoint,pickPoint);
122 else if ( this->ScalingEnabled && this->InteractionState == fwVtkBoxRepresentation::MoveF4 )
124 this->MoveMinusZFace(prevPickPoint,pickPoint);
127 else if ( this->ScalingEnabled && this->InteractionState == fwVtkBoxRepresentation::MoveF5 )
129 this->MovePlusZFace(prevPickPoint,pickPoint);
132 else if ( this->TranslationEnabled && this->InteractionState == fwVtkBoxRepresentation::Translating )
134 this->Translate(prevPickPoint, pickPoint);
137 else if ( this->ScalingEnabled && this->InteractionState == fwVtkBoxRepresentation::Scaling )
139 this->Scale(prevPickPoint, pickPoint,
140 static_cast<int>(e[0]), static_cast<int>(e[1]));
143 else if ( this->RotationEnabled && this->InteractionState == fwVtkBoxRepresentation::Rotating )
145 this->Rotate(static_cast<int>(e[0]), static_cast<int>(e[1]), prevPickPoint, pickPoint, vpn);
149 this->LastEventPosition[0] = e[0];
150 this->LastEventPosition[1] = e[1];
151 this->LastEventPosition[2] = 0.0;
155 void fwVtkBoxRepresentation::PrintSelf(ostream& os, vtkIndent indent)
157 this->Superclass::PrintSelf(os,indent);
159 os << indent <<
"Translation Enabled: " << (this->TranslationEnabled ?
"On\n" :
"Off\n");
160 os << indent <<
"Scaling Enabled: " << (this->ScalingEnabled ?
"On\n" :
"Off\n");
161 os << indent <<
"Rotation Enabled: " << (this->RotationEnabled ?
"On\n" :
"Off\n");