From 5f6b88b34ce2a6c5073cb1fcc9dd17402a9645ae Mon Sep 17 00:00:00 2001 From: djairoh Date: Mon, 6 May 2024 11:19:13 +0200 Subject: [PATCH] documentation --- vtk/src/commands/CameraMoveCallback.cpp | 1 + vtk/src/commands/CameraMoveCallback.h | 28 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/vtk/src/commands/CameraMoveCallback.cpp b/vtk/src/commands/CameraMoveCallback.cpp index f48b087..a462376 100644 --- a/vtk/src/commands/CameraMoveCallback.cpp +++ b/vtk/src/commands/CameraMoveCallback.cpp @@ -74,6 +74,7 @@ void CameraMoveCallback::zoom(const bool in) { clampCamera(this->cam->GetPosition()); } +// we use the interactor's getKeySym instead of getKeyCode because getKeyCode is platform-dependent. void CameraMoveCallback::pan(const string dir) { double pos[3]; this->cam->GetPosition(pos); diff --git a/vtk/src/commands/CameraMoveCallback.h b/vtk/src/commands/CameraMoveCallback.h index d85b9bb..13e0553 100644 --- a/vtk/src/commands/CameraMoveCallback.h +++ b/vtk/src/commands/CameraMoveCallback.h @@ -10,17 +10,45 @@ class CameraMoveCallback : public vtkCallbackCommand { public: + /** Create new instance using the vtk New template. + */ static CameraMoveCallback *New(vtkCamera *cam); + + /** Constructor. + */ CameraMoveCallback(); + /** Sets the camera to operate on. + */ void setCam(const vtkSmartPointer &cam); private: + /** The camera to operate on. + */ vtkSmartPointer cam; + /** Event callback. Should be subscribed to keyPressEvent and MouseWheelForward/MouseWheelBackward events. + */ void Execute(vtkObject *caller, unsigned long evId, void *callData) override; + + /** Zooms the camera in or out. + * @param in : whether to zoom in or out. + */ void zoom(const bool in); + + /** Pans the camera in a direction, determined by the parameter. + * 'h' and 'left' : pan left + * 'j' and 'up' : pan up + * 'k' and 'down' : pan down + * 'l' and 'right' : pan right + * @param dir : string of the pressed keycode. + */ void pan(const std::string dir); + + /** Edits the camera such that it only ever renders within the [-1,1] normalised coordinate field. + * Does so by making sure that the position of the camera (on the x,y axes), combined with the parallel scale, is never > 1. + * @param pos : pointer to new desired camera position. This will be changed if it would cause points outside [-1,1] to be displayed. + */ void clampCamera(double *pos); };