16 #include "vtkCommand.h" 17 #include <vtkRenderWindowInteractor.h> 19 #include "vtkCamera.h" 20 #include "vtkRenderer.h" 21 #include <vtkSmartPointer.h> 22 #include <vtkTransform.h> 47 if ((dispWidth / widthInMM) < (dispHeight / heightInMM))
49 heightInMM = widthInMM / dispWidth * dispHeight;
52 return heightInMM * 0.5;
55 void mitk::CameraController::AdjustConstrainedCameraPosition(
mitk::Point2D &planePoint)
63 double xMin, xMax, yMin, yMax;
68 if (dispSizeInMM[0] > widthInMM)
70 xMin = widthInMM - 0.5 * dispSizeInMM[0];
71 xMax = 0.5 * dispSizeInMM[0];
75 xMin = 0.5 * dispSizeInMM[0];
76 xMax = widthInMM - 0.5 * dispSizeInMM[0];
79 if (dispSizeInMM[1] > heightInMM)
81 yMin = heightInMM - 0.5 * dispSizeInMM[1];
82 yMax = 0.5 * dispSizeInMM[1];
86 yMin = 0.5 * dispSizeInMM[1];
87 yMax = heightInMM - 0.5 * dispSizeInMM[1];
90 if (planePoint[0] < xMin)
94 if (planePoint[1] < yMin)
98 if (planePoint[0] > xMax)
100 planePoint[0] = xMax;
102 if (planePoint[1] > yMax)
104 planePoint[1] = yMax;
141 if (glRenderer ==
nullptr)
146 mitk::BoundingBox::Pointer bb;
157 vtkRenderer->GetActiveCamera()->SetFocalPoint(middle[0], middle[1], middle[2]);
164 vtkRenderer->GetActiveCamera()->SetViewUp(0, 0, 1);
168 vtkRenderer->GetActiveCamera()->SetViewUp(0, -1, 0);
174 vtkRenderer->GetActiveCamera()->SetPosition(middle[0], -100000, middle[2]);
177 vtkRenderer->GetActiveCamera()->SetPosition(middle[0], +100000, middle[2]);
180 vtkRenderer->GetActiveCamera()->SetPosition(+100000, middle[1], middle[2]);
183 vtkRenderer->GetActiveCamera()->SetPosition(-100000, middle[1], middle[2]);
186 vtkRenderer->GetActiveCamera()->SetPosition(middle[0], middle[1], 100000);
189 vtkRenderer->GetActiveCamera()->SetPosition(middle[0], middle[1], -100000);
192 vtkRenderer->ResetCamera();
194 vtkRenderer->ResetCameraClippingRange();
202 Point2D moveToPoint = planePoint;
220 if (this->
GetRenderer()->GetConstrainZoomingAndPanning() && factor < 1.0)
223 if (maxParallelScale - parallelScale * factor <
227 if (parallelScale > maxParallelScale)
229 parallelScale = maxParallelScale;
245 return CamPosOnPlane;
260 Point2D _planePoint = PlanePoint;
261 if (this->
GetRenderer()->GetConstrainZoomingAndPanning())
265 if (parallelScale > maxParallelScale)
269 AdjustConstrainedCameraPosition(_planePoint);
272 if (planeGeometry !=
nullptr)
280 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
281 vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
294 matrix->SetElement(0, 0, right[0]);
295 matrix->SetElement(1, 0, right[1]);
296 matrix->SetElement(2, 0, right[2]);
297 matrix->SetElement(0, 1, bottom[0]);
298 matrix->SetElement(1, 1, bottom[1]);
299 matrix->SetElement(2, 1, bottom[2]);
300 matrix->SetElement(0, 2, normal[0]);
301 matrix->SetElement(1, 2, normal[1]);
302 matrix->SetElement(2, 2, normal[2]);
303 matrix->SetElement(0, 3, origin[0]);
304 matrix->SetElement(1, 3, origin[1]);
305 matrix->SetElement(2, 3, origin[2]);
306 matrix->SetElement(3, 0, 0.0);
307 matrix->SetElement(3, 1, 0.0);
308 matrix->SetElement(3, 2, 0.0);
309 matrix->SetElement(3, 3, 1.0);
311 trans->SetMatrix(matrix);
ScalarType ComputeMaxParallelScale()
Data management class that handles 'was created by' relations.
Vector3D GetAxisVector(unsigned int direction) const
Get vector along bounding-box in the specified direction in mm.
Baseclass for renderer slice-/camera-control.
vtkRenderer * GetVtkRenderer() const
virtual void SetViewToPosterior()
CameraController()
Default Constructor.
void Zoom(ScalarType factor, const Point2D &zoomPointInMM)
const BaseRenderer * m_Renderer
void DisplayToPlane(const Point2D &displayPoint, Point2D &planePointInMM) const
This method converts a display point to the 2D world index, mapped onto the display plane using the g...
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
virtual void SetViewToAnterior()
void MoveBy(const Vector2D &moveVectorInMM)
~CameraController() override
Default Destructor.
ScalarType GetExtentInMM(int direction) const
Get the extent of the bounding-box in the specified direction in mm.
virtual void SetViewToDexter()
static RenderingManager * GetInstance()
virtual void SetViewToSinister()
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
void SetScaleFactorInMMPerDisplayUnit(ScalarType scale)
Set the desired zoom-level to the absolute value given.
virtual void SetViewToCaudal()
virtual const BaseRenderer * GetRenderer() const
virtual int * GetViewportSize() const
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
Vector3D GetNormal() const
Normal of the plane.
Point2D GetCameraPositionOnPlane()
virtual void SetViewToCranial()
BoundingBox::Pointer ComputeBoundingBox(const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr)
Compute the bounding box of data tree structure it -> an iterator to a data tree structure.
virtual void SetStandardView(StandardView view)
MITKCORE_EXPORT const ScalarType eps
Point2D GetViewportSizeInMM() const
Describes a two-dimensional, rectangular plane.
void MoveCameraToPoint(const Point2D &planePoint)
MoveCameraToPoint Move camera so that the point on the plane is in the view center.
void AdjustCameraToPlane()
AdjustCameraToPlane Moves the camera of a 2D Renderwindow without panning or zooming, eg. only rotate the camera.
void Fit()
Fit Adjust the camera, so that the world bounding box is fully visible.
virtual DataStorage::Pointer GetDataStorage() const
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)