Point Cloud Library (PCL)  1.14.1-dev
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
pcl::visualization::PCLVisualizerInteractorStyle Class Reference

PCLVisualizerInteractorStyle defines an unique, custom VTK based interactory style for PCL Visualizer applications. More...

#include <pcl/visualization/interactor_style.h>

+ Inheritance diagram for pcl::visualization::PCLVisualizerInteractorStyle:
+ Collaboration diagram for pcl::visualization::PCLVisualizerInteractorStyle:

Public Types

using CloudActorMapPtr = pcl::visualization::CloudActorMapPtr
 

Public Member Functions

 PCLVisualizerInteractorStyle ()=default
 Empty constructor. More...
 
 ~PCLVisualizerInteractorStyle () override=default
 Empty destructor. More...
 
 vtkTypeMacro (PCLVisualizerInteractorStyle, vtkInteractorStyleRubberBandPick)
 
virtual void Initialize ()
 Initialization routine. More...
 
void setCloudActorMap (const CloudActorMapPtr &actors)
 Pass a pointer to the cloud actor map. More...
 
void setShapeActorMap (const ShapeActorMapPtr &actors)
 Pass a pointer to the shape actor map. More...
 
CloudActorMapPtr getCloudActorMap ()
 Get the cloud actor map pointer. More...
 
ShapeActorMapPtr getShapeActorMap ()
 Get the cloud actor map pointer. More...
 
void setRendererCollection (vtkSmartPointer< vtkRendererCollection > &rens)
 Pass a set of renderers to the interactor style. More...
 
void setUseVbos (const bool use_vbos)
 Use Vertex Buffer Objects renderers. More...
 
boost::signals2::connection registerMouseCallback (std::function< void(const pcl::visualization::MouseEvent &)> cb)
 Register a callback function for mouse events. More...
 
boost::signals2::connection registerKeyboardCallback (std::function< void(const pcl::visualization::KeyboardEvent &)> cb)
 Register a callback std::function for keyboard events. More...
 
boost::signals2::connection registerPointPickingCallback (std::function< void(const pcl::visualization::PointPickingEvent &)> cb)
 Register a callback function for point picking events. More...
 
boost::signals2::connection registerAreaPickingCallback (std::function< void(const pcl::visualization::AreaPickingEvent &)> cb)
 Register a callback function for area picking events. More...
 
void saveScreenshot (const std::string &file)
 Save the current rendered image to disk, as a PNG screenshot. More...
 
bool saveCameraParameters (const std::string &file)
 Save the camera parameters to disk, as a .cam file. More...
 
void getCameraParameters (Camera &camera, int viewport=0) const
 Get camera parameters of a given viewport (0 means default viewport). More...
 
bool loadCameraParameters (const std::string &file)
 Load camera parameters from a camera parameter file. More...
 
void setCameraParameters (const Eigen::Matrix3f &intrinsics, const Eigen::Matrix4f &extrinsics, int viewport=0)
 Set the camera parameters via an intrinsics and and extrinsics matrix. More...
 
void setCameraParameters (const Camera &camera, int viewport=0)
 Set the camera parameters by given a full camera data structure. More...
 
void setCameraFile (const std::string &file)
 Set camera file for camera parameter saving/restoring. More...
 
std::string getCameraFile () const
 Get camera file for camera parameter saving/restoring. More...
 
void setKeyboardModifier (const InteractorKeyboardModifier &modifier)
 Change the default keyboard modified from ALT to a different special key. More...
 

Static Public Member Functions

static PCLVisualizerInteractorStyleNew ()
 

Protected Member Functions

void OnChar () override
 Interactor style internal method. More...
 
void OnKeyDown () override
 
void OnKeyUp () override
 
void OnMouseMove () override
 
void OnLeftButtonDown () override
 
void OnLeftButtonUp () override
 
void OnMiddleButtonDown () override
 
void OnMiddleButtonUp () override
 
void OnRightButtonDown () override
 
void OnRightButtonUp () override
 
void OnMouseWheelForward () override
 
void OnMouseWheelBackward () override
 
void OnTimer () override
 Interactor style internal method. More...
 
void zoomIn ()
 Interactor style internal method. More...
 
void zoomOut ()
 Interactor style internal method. More...
 
bool getCameraParameters (const std::vector< std::string > &camera)
 Get camera parameters from a string vector. More...
 
void setRenderWindow (const vtkSmartPointer< vtkRenderWindow > &win)
 Set render window. More...
 

Protected Attributes

bool init_ {false}
 Set to true after initialization is complete. More...
 
vtkSmartPointer< vtkRendererCollection > rens_
 Collection of vtkRenderers stored internally. More...
 
CloudActorMapPtr cloud_actors_ {nullptr}
 Cloud actor map stored internally. More...
 
ShapeActorMapPtr shape_actors_ {nullptr}
 Shape map stored internally. More...
 
int win_height_ {0}
 The current window width/height. More...
 
int win_width_ {0}
 
int win_pos_x_ {0}
 The current window position x/y. More...
 
int win_pos_y_ {0}
 
int max_win_height_ {0}
 The maximum resizeable window width/height. More...
 
int max_win_width_ {0}
 
bool use_vbos_ {false}
 Boolean that holds whether or not to use the vtkVertexBufferObjectMapper. More...
 
bool grid_enabled_ {false}
 Set to true if the grid actor is enabled. More...
 
vtkSmartPointer< vtkLegendScaleActor > grid_actor_
 Actor for 2D grid on screen. More...
 
bool lut_enabled_ {false}
 Set to true if the LUT actor is enabled. More...
 
vtkSmartPointer< vtkScalarBarActor > lut_actor_
 Actor for 2D lookup table on screen. More...
 
vtkSmartPointer< vtkPNGWriter > snapshot_writer_
 A PNG writer for screenshot captures. More...
 
vtkSmartPointer< vtkWindowToImageFilter > wif_
 Internal window to image filter. More...
 
vtkSmartPointer< vtkPointPicker > point_picker_
 Stores the point picker when switching to an area picker. More...
 
boost::signals2::signal< void(const pcl::visualization::MouseEvent &)> mouse_signal_
 
boost::signals2::signal< void(const pcl::visualization::KeyboardEvent &)> keyboard_signal_
 
boost::signals2::signal< void(const pcl::visualization::PointPickingEvent &)> point_picking_signal_
 
boost::signals2::signal< void(const pcl::visualization::AreaPickingEvent &)> area_picking_signal_
 
bool stereo_anaglyph_mask_default_ {false}
 True if we're using red-blue colors for anaglyphic stereo, false if magenta-green. More...
 
vtkSmartPointer< PointPickingCallbackmouse_callback_
 A VTK Mouse Callback object, used for point picking. More...
 
InteractorKeyboardModifier modifier_ {}
 The keyboard modifier to use. More...
 
std::string camera_file_
 Camera file for camera parameter saving/restoring. More...
 
Camera camera_
 A pcl::visualization::Camera for camera parameter saving/restoring. More...
 
bool camera_saved_ {false}
 A pcl::visualization::Camera is saved or not. More...
 
vtkSmartPointer< vtkRenderWindow > win_
 The render window. More...
 

Friends

class PointPickingCallback
 
class PCLVisualizer
 

Detailed Description

PCLVisualizerInteractorStyle defines an unique, custom VTK based interactory style for PCL Visualizer applications.

Besides defining the rendering style, we also create a list of custom actions that are triggered on different keys being pressed:

Author
Radu B. Rusu

Definition at line 107 of file interactor_style.h.

Member Typedef Documentation

◆ CloudActorMapPtr

Definition at line 110 of file interactor_style.h.

Constructor & Destructor Documentation

◆ PCLVisualizerInteractorStyle()

pcl::visualization::PCLVisualizerInteractorStyle::PCLVisualizerInteractorStyle ( )
default

Empty constructor.

◆ ~PCLVisualizerInteractorStyle()

pcl::visualization::PCLVisualizerInteractorStyle::~PCLVisualizerInteractorStyle ( )
overridedefault

Empty destructor.

Member Function Documentation

◆ getCameraFile()

std::string pcl::visualization::PCLVisualizerInteractorStyle::getCameraFile ( ) const
inline

Get camera file for camera parameter saving/restoring.

Definition at line 239 of file interactor_style.h.

◆ getCameraParameters() [1/2]

void pcl::visualization::PCLVisualizerInteractorStyle::getCameraParameters ( Camera camera,
int  viewport = 0 
) const

Get camera parameters of a given viewport (0 means default viewport).

◆ getCameraParameters() [2/2]

bool pcl::visualization::PCLVisualizerInteractorStyle::getCameraParameters ( const std::vector< std::string > &  camera)
protected

Get camera parameters from a string vector.

Parameters
[in]cameraA string vector: Clipping Range, Focal Point, Position, ViewUp, Distance, Field of View Y, Window Size, Window Pos. Values in each string are separated by a ','

◆ getCloudActorMap()

CloudActorMapPtr pcl::visualization::PCLVisualizerInteractorStyle::getCloudActorMap ( )
inline

Get the cloud actor map pointer.

Definition at line 141 of file interactor_style.h.

◆ getShapeActorMap()

ShapeActorMapPtr pcl::visualization::PCLVisualizerInteractorStyle::getShapeActorMap ( )
inline

Get the cloud actor map pointer.

Definition at line 145 of file interactor_style.h.

◆ Initialize()

virtual void pcl::visualization::PCLVisualizerInteractorStyle::Initialize ( )
virtual

Initialization routine.

Must be called before anything else.

◆ loadCameraParameters()

bool pcl::visualization::PCLVisualizerInteractorStyle::loadCameraParameters ( const std::string &  file)

Load camera parameters from a camera parameter file.

Parameters
[in]filethe name of the camera parameter file

◆ New()

static PCLVisualizerInteractorStyle* pcl::visualization::PCLVisualizerInteractorStyle::New ( )
static

◆ OnChar()

void pcl::visualization::PCLVisualizerInteractorStyle::OnChar ( )
overrideprotected

Interactor style internal method.

Gets called whenever a key is pressed.

◆ OnKeyDown()

void pcl::visualization::PCLVisualizerInteractorStyle::OnKeyDown ( )
overrideprotected

◆ OnKeyUp()

void pcl::visualization::PCLVisualizerInteractorStyle::OnKeyUp ( )
overrideprotected

◆ OnLeftButtonDown()

void pcl::visualization::PCLVisualizerInteractorStyle::OnLeftButtonDown ( )
overrideprotected

◆ OnLeftButtonUp()

void pcl::visualization::PCLVisualizerInteractorStyle::OnLeftButtonUp ( )
overrideprotected

◆ OnMiddleButtonDown()

void pcl::visualization::PCLVisualizerInteractorStyle::OnMiddleButtonDown ( )
overrideprotected

◆ OnMiddleButtonUp()

void pcl::visualization::PCLVisualizerInteractorStyle::OnMiddleButtonUp ( )
overrideprotected

◆ OnMouseMove()

void pcl::visualization::PCLVisualizerInteractorStyle::OnMouseMove ( )
overrideprotected

◆ OnMouseWheelBackward()

void pcl::visualization::PCLVisualizerInteractorStyle::OnMouseWheelBackward ( )
overrideprotected

◆ OnMouseWheelForward()

void pcl::visualization::PCLVisualizerInteractorStyle::OnMouseWheelForward ( )
overrideprotected

◆ OnRightButtonDown()

void pcl::visualization::PCLVisualizerInteractorStyle::OnRightButtonDown ( )
overrideprotected

◆ OnRightButtonUp()

void pcl::visualization::PCLVisualizerInteractorStyle::OnRightButtonUp ( )
overrideprotected

◆ OnTimer()

void pcl::visualization::PCLVisualizerInteractorStyle::OnTimer ( )
overrideprotected

Interactor style internal method.

Gets called periodically if a timer is set.

◆ registerAreaPickingCallback()

boost::signals2::connection pcl::visualization::PCLVisualizerInteractorStyle::registerAreaPickingCallback ( std::function< void(const pcl::visualization::AreaPickingEvent &)>  cb)

Register a callback function for area picking events.

Parameters
[in]cba std function that will be registered as a callback for a area picking event
Returns
a connection object that allows to disconnect the callback function.

◆ registerKeyboardCallback()

boost::signals2::connection pcl::visualization::PCLVisualizerInteractorStyle::registerKeyboardCallback ( std::function< void(const pcl::visualization::KeyboardEvent &)>  cb)

Register a callback std::function for keyboard events.

Parameters
[in]cba std function that will be registered as a callback for a keyboard event
Returns
a connection object that allows to disconnect the callback function.

◆ registerMouseCallback()

boost::signals2::connection pcl::visualization::PCLVisualizerInteractorStyle::registerMouseCallback ( std::function< void(const pcl::visualization::MouseEvent &)>  cb)

Register a callback function for mouse events.

Parameters
[in]cba std function that will be registered as a callback for a mouse event
Returns
a connection object that allows to disconnect the callback function.

◆ registerPointPickingCallback()

boost::signals2::connection pcl::visualization::PCLVisualizerInteractorStyle::registerPointPickingCallback ( std::function< void(const pcl::visualization::PointPickingEvent &)>  cb)

Register a callback function for point picking events.

Parameters
[in]cba std function that will be registered as a callback for a point picking event
Returns
a connection object that allows to disconnect the callback function.

◆ saveCameraParameters()

bool pcl::visualization::PCLVisualizerInteractorStyle::saveCameraParameters ( const std::string &  file)

Save the camera parameters to disk, as a .cam file.

Parameters
[in]filethe name of the .cam file

◆ saveScreenshot()

void pcl::visualization::PCLVisualizerInteractorStyle::saveScreenshot ( const std::string &  file)

Save the current rendered image to disk, as a PNG screenshot.

Parameters
[in]filethe name of the PNG file

◆ setCameraFile()

void pcl::visualization::PCLVisualizerInteractorStyle::setCameraFile ( const std::string &  file)
inline

Set camera file for camera parameter saving/restoring.

Parameters
[in]filethe name of the camera parameter file

Definition at line 232 of file interactor_style.h.

◆ setCameraParameters() [1/2]

void pcl::visualization::PCLVisualizerInteractorStyle::setCameraParameters ( const Camera camera,
int  viewport = 0 
)

Set the camera parameters by given a full camera data structure.

Parameters
[in]cameracamera structure containing all the camera parameters.
[in]viewportthe viewport to modify camera of (0 modifies all cameras)

◆ setCameraParameters() [2/2]

void pcl::visualization::PCLVisualizerInteractorStyle::setCameraParameters ( const Eigen::Matrix3f &  intrinsics,
const Eigen::Matrix4f &  extrinsics,
int  viewport = 0 
)

Set the camera parameters via an intrinsics and and extrinsics matrix.

Note
This assumes that the pixels are square and that the center of the image is at the center of the sensor.
Parameters
[in]intrinsicsthe intrinsics that will be used to compute the VTK camera parameters
[in]extrinsicsthe extrinsics that will be used to compute the VTK camera parameters
[in]viewportthe viewport to modify camera of (0 modifies all cameras)

◆ setCloudActorMap()

void pcl::visualization::PCLVisualizerInteractorStyle::setCloudActorMap ( const CloudActorMapPtr actors)
inline

Pass a pointer to the cloud actor map.

Parameters
[in]actorsthe actor map that will be used with this style

Definition at line 131 of file interactor_style.h.

◆ setKeyboardModifier()

void pcl::visualization::PCLVisualizerInteractorStyle::setKeyboardModifier ( const InteractorKeyboardModifier modifier)
inline

Change the default keyboard modified from ALT to a different special key.

Allowed values are:

  • INTERACTOR_KB_MOD_ALT
  • INTERACTOR_KB_MOD_CTRL
  • INTERACTOR_KB_MOD_SHIFT
    Parameters
    [in]modifierthe new keyboard modifier

Definition at line 252 of file interactor_style.h.

◆ setRendererCollection()

void pcl::visualization::PCLVisualizerInteractorStyle::setRendererCollection ( vtkSmartPointer< vtkRendererCollection > &  rens)
inline

Pass a set of renderers to the interactor style.

Parameters
[in]rensthe vtkRendererCollection to use

Definition at line 151 of file interactor_style.h.

◆ setRenderWindow()

void pcl::visualization::PCLVisualizerInteractorStyle::setRenderWindow ( const vtkSmartPointer< vtkRenderWindow > &  win)
inlineprotected

Set render window.

Definition at line 357 of file interactor_style.h.

◆ setShapeActorMap()

void pcl::visualization::PCLVisualizerInteractorStyle::setShapeActorMap ( const ShapeActorMapPtr actors)
inline

Pass a pointer to the shape actor map.

Parameters
[in]actorsthe actor map that will be used with this style

Definition at line 137 of file interactor_style.h.

◆ setUseVbos()

void pcl::visualization::PCLVisualizerInteractorStyle::setUseVbos ( const bool  use_vbos)
inline

Use Vertex Buffer Objects renderers.

This is an optimization for the obsolete OpenGL backend. Modern OpenGL2 backend (VTK ≥ 6.3) uses vertex buffer objects by default, transparently for the user.

Parameters
[in]use_vbosset to true to use VBOs
Deprecated:
Scheduled for removal in version 1 . 18 : "this function has no effect"

Definition at line 160 of file interactor_style.h.

◆ vtkTypeMacro()

pcl::visualization::PCLVisualizerInteractorStyle::vtkTypeMacro ( PCLVisualizerInteractorStyle  ,
vtkInteractorStyleRubberBandPick   
)

◆ zoomIn()

void pcl::visualization::PCLVisualizerInteractorStyle::zoomIn ( )
protected

Interactor style internal method.

Zoom in.

◆ zoomOut()

void pcl::visualization::PCLVisualizerInteractorStyle::zoomOut ( )
protected

Interactor style internal method.

Zoom out.

Friends And Related Function Documentation

◆ PCLVisualizer

friend class PCLVisualizer
friend

Definition at line 383 of file interactor_style.h.

◆ PointPickingCallback

friend class PointPickingCallback
friend

Definition at line 382 of file interactor_style.h.

Member Data Documentation

◆ area_picking_signal_

boost::signals2::signal<void (const pcl::visualization::AreaPickingEvent&)> pcl::visualization::PCLVisualizerInteractorStyle::area_picking_signal_
protected

Definition at line 302 of file interactor_style.h.

◆ camera_

Camera pcl::visualization::PCLVisualizerInteractorStyle::camera_
protected

A pcl::visualization::Camera for camera parameter saving/restoring.

Definition at line 374 of file interactor_style.h.

◆ camera_file_

std::string pcl::visualization::PCLVisualizerInteractorStyle::camera_file_
protected

Camera file for camera parameter saving/restoring.

Definition at line 372 of file interactor_style.h.

◆ camera_saved_

bool pcl::visualization::PCLVisualizerInteractorStyle::camera_saved_ {false}
protected

A pcl::visualization::Camera is saved or not.

Definition at line 376 of file interactor_style.h.

◆ cloud_actors_

CloudActorMapPtr pcl::visualization::PCLVisualizerInteractorStyle::cloud_actors_ {nullptr}
protected

Cloud actor map stored internally.

Definition at line 265 of file interactor_style.h.

◆ grid_actor_

vtkSmartPointer<vtkLegendScaleActor> pcl::visualization::PCLVisualizerInteractorStyle::grid_actor_
protected

Actor for 2D grid on screen.

Definition at line 285 of file interactor_style.h.

◆ grid_enabled_

bool pcl::visualization::PCLVisualizerInteractorStyle::grid_enabled_ {false}
protected

Set to true if the grid actor is enabled.

Definition at line 283 of file interactor_style.h.

◆ init_

bool pcl::visualization::PCLVisualizerInteractorStyle::init_ {false}
protected

Set to true after initialization is complete.

Definition at line 259 of file interactor_style.h.

◆ keyboard_signal_

boost::signals2::signal<void (const pcl::visualization::KeyboardEvent&)> pcl::visualization::PCLVisualizerInteractorStyle::keyboard_signal_
protected

Definition at line 300 of file interactor_style.h.

◆ lut_actor_

vtkSmartPointer<vtkScalarBarActor> pcl::visualization::PCLVisualizerInteractorStyle::lut_actor_
protected

Actor for 2D lookup table on screen.

Definition at line 290 of file interactor_style.h.

◆ lut_enabled_

bool pcl::visualization::PCLVisualizerInteractorStyle::lut_enabled_ {false}
protected

Set to true if the LUT actor is enabled.

Definition at line 288 of file interactor_style.h.

◆ max_win_height_

int pcl::visualization::PCLVisualizerInteractorStyle::max_win_height_ {0}
protected

The maximum resizeable window width/height.

Definition at line 277 of file interactor_style.h.

◆ max_win_width_

int pcl::visualization::PCLVisualizerInteractorStyle::max_win_width_ {0}
protected

Definition at line 277 of file interactor_style.h.

◆ modifier_

InteractorKeyboardModifier pcl::visualization::PCLVisualizerInteractorStyle::modifier_ {}
protected

The keyboard modifier to use.

Default: Alt.

Definition at line 369 of file interactor_style.h.

◆ mouse_callback_

vtkSmartPointer<PointPickingCallback> pcl::visualization::PCLVisualizerInteractorStyle::mouse_callback_
protected

A VTK Mouse Callback object, used for point picking.

Definition at line 366 of file interactor_style.h.

◆ mouse_signal_

boost::signals2::signal<void (const pcl::visualization::MouseEvent&)> pcl::visualization::PCLVisualizerInteractorStyle::mouse_signal_
protected

Definition at line 299 of file interactor_style.h.

◆ point_picker_

vtkSmartPointer<vtkPointPicker> pcl::visualization::PCLVisualizerInteractorStyle::point_picker_
protected

Stores the point picker when switching to an area picker.

Definition at line 297 of file interactor_style.h.

◆ point_picking_signal_

boost::signals2::signal<void (const pcl::visualization::PointPickingEvent&)> pcl::visualization::PCLVisualizerInteractorStyle::point_picking_signal_
protected

Definition at line 301 of file interactor_style.h.

◆ rens_

vtkSmartPointer<vtkRendererCollection> pcl::visualization::PCLVisualizerInteractorStyle::rens_
protected

Collection of vtkRenderers stored internally.

Definition at line 262 of file interactor_style.h.

◆ shape_actors_

ShapeActorMapPtr pcl::visualization::PCLVisualizerInteractorStyle::shape_actors_ {nullptr}
protected

Shape map stored internally.

Definition at line 268 of file interactor_style.h.

◆ snapshot_writer_

vtkSmartPointer<vtkPNGWriter> pcl::visualization::PCLVisualizerInteractorStyle::snapshot_writer_
protected

A PNG writer for screenshot captures.

Definition at line 293 of file interactor_style.h.

◆ stereo_anaglyph_mask_default_

bool pcl::visualization::PCLVisualizerInteractorStyle::stereo_anaglyph_mask_default_ {false}
protected

True if we're using red-blue colors for anaglyphic stereo, false if magenta-green.

Definition at line 363 of file interactor_style.h.

◆ use_vbos_

bool pcl::visualization::PCLVisualizerInteractorStyle::use_vbos_ {false}
protected

Boolean that holds whether or not to use the vtkVertexBufferObjectMapper.

Definition at line 280 of file interactor_style.h.

◆ wif_

vtkSmartPointer<vtkWindowToImageFilter> pcl::visualization::PCLVisualizerInteractorStyle::wif_
protected

Internal window to image filter.

Needed by snapshot_writer_.

Definition at line 295 of file interactor_style.h.

◆ win_

vtkSmartPointer<vtkRenderWindow> pcl::visualization::PCLVisualizerInteractorStyle::win_
protected

The render window.

Only used when interactor maybe not available

Definition at line 380 of file interactor_style.h.

◆ win_height_

int pcl::visualization::PCLVisualizerInteractorStyle::win_height_ {0}
protected

The current window width/height.

Definition at line 271 of file interactor_style.h.

◆ win_pos_x_

int pcl::visualization::PCLVisualizerInteractorStyle::win_pos_x_ {0}
protected

The current window position x/y.

Definition at line 274 of file interactor_style.h.

◆ win_pos_y_

int pcl::visualization::PCLVisualizerInteractorStyle::win_pos_y_ {0}
protected

Definition at line 274 of file interactor_style.h.

◆ win_width_

int pcl::visualization::PCLVisualizerInteractorStyle::win_width_ {0}
protected

Definition at line 271 of file interactor_style.h.


The documentation for this class was generated from the following file: