ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::visualization::ViewControl Class Reference

View controller for visualizer. More...

#include <ViewControl.h>

Inheritance diagram for cloudViewer::visualization::ViewControl:
Collaboration diagram for cloudViewer::visualization::ViewControl:

Public Types

enum  ProjectionType { Perspective = 0 , Orthogonal = 1 }
 

Public Member Functions

virtual ~ViewControl ()
 
void SetViewMatrices (const Eigen::Matrix4d &model_matrix=Eigen::Matrix4d::Identity())
 
bool ConvertToViewParameters (ViewParameters &status) const
 Function to get equivalent view parameters (support orthogonal) More...
 
bool ConvertFromViewParameters (const ViewParameters &status)
 
void SetZoom (const double zoom)
 
void SetUp (const Eigen::Vector3d &up)
 
void SetFront (const Eigen::Vector3d &front)
 
void SetLookat (const Eigen::Vector3d &lookat)
 
bool ConvertToPinholeCameraParameters (camera::PinholeCameraParameters &parameters)
 
bool ConvertFromPinholeCameraParameters (const camera::PinholeCameraParameters &parameters, bool allow_arbitrary=false)
 
ProjectionType GetProjectionType () const
 
void SetProjectionParameters ()
 
virtual void Reset ()
 
virtual void ChangeFieldOfView (double step)
 
virtual void ChangeWindowSize (int width, int height)
 
virtual void Scale (double scale)
 
virtual void Rotate (double x, double y, double xo=0.0, double yo=0.0)
 Function to process rotation. More...
 
virtual void Translate (double x, double y, double xo=0.0, double yo=0.0)
 Function to process translation. More...
 
virtual void CameraLocalTranslate (double forward, double right, double up)
 
virtual void CameraLocalRotate (double x, double y, double xo=0.0, double yo=0.0)
 
virtual void ResetCameraLocalRotate ()
 
virtual void Roll (double x)
 
const ccBBoxGetBoundingBox () const
 
void ResetBoundingBox ()
 
void FitInGeometry (const ccHObject &geometry)
 
double GetFieldOfView () const
 Function to get field of view. More...
 
gl_util::GLMatrix4f GetMVPMatrix () const
 
gl_util::GLMatrix4f GetProjectionMatrix () const
 
gl_util::GLMatrix4f GetViewMatrix () const
 
gl_util::GLMatrix4f GetModelMatrix () const
 
gl_util::GLVector3f GetEye () const
 
gl_util::GLVector3f GetLookat () const
 
gl_util::GLVector3f GetUp () const
 
gl_util::GLVector3f GetFront () const
 
gl_util::GLVector3f GetRight () const
 
int GetWindowWidth () const
 
int GetWindowHeight () const
 
double GetZNear () const
 
double GetZFar () const
 
void SetConstantZNear (double z_near)
 
void SetConstantZFar (double z_far)
 
void UnsetConstantZNear ()
 
void UnsetConstantZFar ()
 

Static Public Attributes

static const double FIELD_OF_VIEW_MAX = 90.0
 
static const double FIELD_OF_VIEW_MIN = 5.0
 
static const double FIELD_OF_VIEW_DEFAULT = 60.0
 
static const double FIELD_OF_VIEW_STEP = 5.0
 
static const double ZOOM_DEFAULT = 0.7
 
static const double ZOOM_MIN = 0.02
 
static const double ZOOM_MAX = 2.0
 
static const double ZOOM_STEP = 0.02
 
static const double ROTATION_RADIAN_PER_PIXEL = 0.003
 

Protected Attributes

int window_width_ = 0
 
int window_height_ = 0
 
ccBBox bounding_box_
 
Eigen::Vector3d eye_
 
Eigen::Vector3d lookat_
 
Eigen::Vector3d up_
 
Eigen::Vector3d front_
 
Eigen::Vector3d right_
 
double distance_
 
double field_of_view_
 
double zoom_
 
double view_ratio_
 
double aspect_
 
double z_near_
 
double z_far_
 
double constant_z_near_ = -1
 
double constant_z_far_ = -1
 
gl_util::GLMatrix4f projection_matrix_
 
gl_util::GLMatrix4f view_matrix_
 
gl_util::GLMatrix4f model_matrix_
 
gl_util::GLMatrix4f MVP_matrix_
 
Eigen::Vector3d start_local_rotate_up_
 
Eigen::Vector3d start_local_rotate_right_
 
Eigen::Vector3d start_local_rotate_front_
 
Eigen::Vector3d start_local_rotate_eye_
 
Eigen::Vector3d start_local_rotate_lookat_
 
double local_rotate_up_accum_
 
double local_rotate_right_accum_
 

Detailed Description

View controller for visualizer.

Definition at line 25 of file ViewControl.h.

Member Enumeration Documentation

◆ ProjectionType

Enumerator
Perspective 
Orthogonal 

Definition at line 39 of file ViewControl.h.

Constructor & Destructor Documentation

◆ ~ViewControl()

virtual cloudViewer::visualization::ViewControl::~ViewControl ( )
inlinevirtual

Definition at line 45 of file ViewControl.h.

Member Function Documentation

◆ CameraLocalRotate()

void cloudViewer::visualization::ViewControl::CameraLocalRotate ( double  x,
double  y,
double  xo = 0.0,
double  yo = 0.0 
)
virtual

◆ CameraLocalTranslate()

void cloudViewer::visualization::ViewControl::CameraLocalTranslate ( double  forward,
double  right,
double  up 
)
virtual

◆ ChangeFieldOfView()

◆ ChangeWindowSize()

void cloudViewer::visualization::ViewControl::ChangeWindowSize ( int  width,
int  height 
)
virtual

◆ ConvertFromPinholeCameraParameters()

bool cloudViewer::visualization::ViewControl::ConvertFromPinholeCameraParameters ( const camera::PinholeCameraParameters parameters,
bool  allow_arbitrary = false 
)

Function to get view controller from pinhole camera parameters.

Parameters
parametersThe pinhole camera parameter to convert from.
allow_arbitraryAllow an arbitrary pinhole camera parameters. This can be useful to render images or depthmaps without any restriction in window size, FOV and zoom.

Definition at line 173 of file ViewControl.cpp.

References abs(), bounding_box_, distance_, dot(), cloudViewer::camera::PinholeCameraParameters::extrinsic_, eye_, field_of_view_, FIELD_OF_VIEW_MAX, FIELD_OF_VIEW_MIN, front_, ccBBox::GetCenter(), ccBBox::GetMaxExtent(), GetProjectionType(), cloudViewer::camera::PinholeCameraParameters::intrinsic_, LogWarning, lookat_, M_PI, max(), min(), right_, up_, view_ratio_, window_height_, window_width_, zoom_, ZOOM_MAX, and ZOOM_MIN.

Referenced by cloudViewer::visualization::ViewControlWithCustomAnimation::LoadTrajectoryFromCameraTrajectory(), and cloudViewer::visualization::pybind_viewcontrol().

◆ ConvertFromViewParameters()

◆ ConvertToPinholeCameraParameters()

bool cloudViewer::visualization::ViewControl::ConvertToPinholeCameraParameters ( camera::PinholeCameraParameters parameters)

Function to get equivalent pinhole camera parameters (does not support orthogonal since it is not a real camera view).

Parameters
Thepinhole camera parameter to convert to.

Definition at line 130 of file ViewControl.cpp.

References cloudViewer::camera::PinholeCameraParameters::extrinsic_, eye_, field_of_view_, front_, GetProjectionType(), cloudViewer::camera::PinholeCameraParameters::intrinsic_, LogWarning, M_PI, right_, SetProjectionParameters(), up_, window_height_, and window_width_.

Referenced by cloudViewer::visualization::pybind_viewcontrol().

◆ ConvertToViewParameters()

◆ FitInGeometry()

◆ GetBoundingBox()

const ccBBox& cloudViewer::visualization::ViewControl::GetBoundingBox ( ) const
inline

◆ GetEye()

gl_util::GLVector3f cloudViewer::visualization::ViewControl::GetEye ( ) const
inline

Definition at line 162 of file ViewControl.h.

References eye_.

◆ GetFieldOfView()

double cloudViewer::visualization::ViewControl::GetFieldOfView ( ) const
inline

Function to get field of view.

Definition at line 155 of file ViewControl.h.

References field_of_view_.

Referenced by cloudViewer::visualization::pybind_viewcontrol().

◆ GetFront()

gl_util::GLVector3f cloudViewer::visualization::ViewControl::GetFront ( ) const
inline

Definition at line 165 of file ViewControl.h.

References front_.

◆ GetLookat()

gl_util::GLVector3f cloudViewer::visualization::ViewControl::GetLookat ( ) const
inline

Definition at line 163 of file ViewControl.h.

References lookat_.

◆ GetModelMatrix()

gl_util::GLMatrix4f cloudViewer::visualization::ViewControl::GetModelMatrix ( ) const
inline

Definition at line 161 of file ViewControl.h.

References model_matrix_.

◆ GetMVPMatrix()

gl_util::GLMatrix4f cloudViewer::visualization::ViewControl::GetMVPMatrix ( ) const
inline

◆ GetProjectionMatrix()

gl_util::GLMatrix4f cloudViewer::visualization::ViewControl::GetProjectionMatrix ( ) const
inline

Definition at line 157 of file ViewControl.h.

References projection_matrix_.

◆ GetProjectionType()

◆ GetRight()

gl_util::GLVector3f cloudViewer::visualization::ViewControl::GetRight ( ) const
inline

Definition at line 166 of file ViewControl.h.

References right_.

◆ GetUp()

gl_util::GLVector3f cloudViewer::visualization::ViewControl::GetUp ( ) const
inline

Definition at line 164 of file ViewControl.h.

References up_.

◆ GetViewMatrix()

gl_util::GLMatrix4f cloudViewer::visualization::ViewControl::GetViewMatrix ( ) const
inline

Definition at line 160 of file ViewControl.h.

References view_matrix_.

◆ GetWindowHeight()

int cloudViewer::visualization::ViewControl::GetWindowHeight ( ) const
inline

◆ GetWindowWidth()

int cloudViewer::visualization::ViewControl::GetWindowWidth ( ) const
inline

◆ GetZFar()

double cloudViewer::visualization::ViewControl::GetZFar ( ) const
inline

Definition at line 170 of file ViewControl.h.

References z_far_.

◆ GetZNear()

double cloudViewer::visualization::ViewControl::GetZNear ( ) const
inline

Definition at line 169 of file ViewControl.h.

References z_near_.

◆ Reset()

◆ ResetBoundingBox()

void cloudViewer::visualization::ViewControl::ResetBoundingBox ( )
inline

Definition at line 133 of file ViewControl.h.

References bounding_box_, and cloudViewer::BoundingBoxTpl< T >::clear().

◆ ResetCameraLocalRotate()

◆ Roll()

void cloudViewer::visualization::ViewControl::Roll ( double  x)
virtual
Parameters
xis the distances the mouse cursor has moved. Coordinates are measured in screen coordinates relative to the top-left corner of the window client area.

Definition at line 370 of file ViewControl.cpp.

References front_, ROTATION_RADIAN_PER_PIXEL, SetProjectionParameters(), and up_.

◆ Rotate()

void cloudViewer::visualization::ViewControl::Rotate ( double  x,
double  y,
double  xo = 0.0,
double  yo = 0.0 
)
virtual

Function to process rotation.

Coordinates are measured in screen coordinates relative to the top-left corner of the window client area.

Parameters
xThe distance the mouse cursor has moved in x-axis.
yThe distance the mouse cursor has moved in y-axis.
xoOriginal point coordinate of the mouse in x-axis.
yoOriginal point coordinate of the mouse in y-axis.

Reimplemented in PyViewControl< ViewControlBase >, cloudViewer::visualization::ViewControlWithEditing, and cloudViewer::visualization::ViewControlWithCustomAnimation.

Definition at line 284 of file ViewControl.cpp.

References front_, right_, ROTATION_RADIAN_PER_PIXEL, SetProjectionParameters(), and up_.

Referenced by cloudViewer::visualization::ViewControlWithCustomAnimation::AddSpinKeyFrames(), cloudViewer::visualization::pybind_viewcontrol(), cloudViewer::visualization::ViewControlWithCustomAnimation::Rotate(), and cloudViewer::visualization::ViewControlWithEditing::Rotate().

◆ Scale()

◆ SetConstantZFar()

void cloudViewer::visualization::ViewControl::SetConstantZFar ( double  z_far)
inline

Function to change the far z-plane of the visualizer to a constant value, i.e., independent of zoom and bounding box size.

Parameters
z_farThe depth of the far z-plane of the visualizer.

Definition at line 181 of file ViewControl.h.

References constant_z_far_.

Referenced by cloudViewer::visualization::pybind_viewcontrol().

◆ SetConstantZNear()

void cloudViewer::visualization::ViewControl::SetConstantZNear ( double  z_near)
inline

Function to change the near z-plane of the visualizer to a constant value, i.e., independent of zoom and bounding box size.

Parameters
z_nearThe depth of the near z-plane of the visualizer.

Definition at line 176 of file ViewControl.h.

References constant_z_near_.

Referenced by cloudViewer::visualization::pybind_viewcontrol().

◆ SetFront()

void cloudViewer::visualization::ViewControl::SetFront ( const Eigen::Vector3d &  front)

◆ SetLookat()

void cloudViewer::visualization::ViewControl::SetLookat ( const Eigen::Vector3d &  lookat)

◆ SetProjectionParameters()

◆ SetUp()

void cloudViewer::visualization::ViewControl::SetUp ( const Eigen::Vector3d &  up)

◆ SetViewMatrices()

void cloudViewer::visualization::ViewControl::SetViewMatrices ( const Eigen::Matrix4d &  model_matrix = Eigen::Matrix4d::Identity())

◆ SetZoom()

void cloudViewer::visualization::ViewControl::SetZoom ( const double  zoom)

◆ Translate()

void cloudViewer::visualization::ViewControl::Translate ( double  x,
double  y,
double  xo = 0.0,
double  yo = 0.0 
)
virtual

Function to process translation.

Coordinates are measured in screen coordinates relative to the top-left corner of the window client area.

Parameters
xDistance the mouse cursor has moved in x-axis.
yDistance the mouse cursor has moved in y-axis.
xoOriginal point coordinate of the mouse in x-axis.
yoOriginal point coordinate of the mouse in y-axis.

Reimplemented in PyViewControl< ViewControlBase >, cloudViewer::visualization::ViewControlWithEditing, and cloudViewer::visualization::ViewControlWithCustomAnimation.

Definition at line 298 of file ViewControl.cpp.

References eye_, lookat_, right_, SetProjectionParameters(), up_, view_ratio_, and window_height_.

Referenced by cloudViewer::visualization::pybind_viewcontrol(), cloudViewer::visualization::ViewControlWithCustomAnimation::Translate(), and cloudViewer::visualization::ViewControlWithEditing::Translate().

◆ UnsetConstantZFar()

void cloudViewer::visualization::ViewControl::UnsetConstantZFar ( )
inline

Function to remove a previously set constant z far value, i.e., far z-plane of the visualizer is dynamically set dependent on zoom and bounding box size.

Definition at line 189 of file ViewControl.h.

References constant_z_far_.

Referenced by cloudViewer::visualization::pybind_viewcontrol().

◆ UnsetConstantZNear()

void cloudViewer::visualization::ViewControl::UnsetConstantZNear ( )
inline

Function to remove a previously set constant z near value, i.e., near z-plane of the visualizer is dynamically set dependent on zoom and bounding box size.

Definition at line 185 of file ViewControl.h.

References constant_z_near_.

Referenced by cloudViewer::visualization::pybind_viewcontrol().

Member Data Documentation

◆ aspect_

double cloudViewer::visualization::ViewControl::aspect_
protected

Definition at line 204 of file ViewControl.h.

Referenced by ChangeWindowSize(), and SetViewMatrices().

◆ bounding_box_

◆ constant_z_far_

double cloudViewer::visualization::ViewControl::constant_z_far_ = -1
protected

Definition at line 208 of file ViewControl.h.

Referenced by SetConstantZFar(), SetViewMatrices(), and UnsetConstantZFar().

◆ constant_z_near_

double cloudViewer::visualization::ViewControl::constant_z_near_ = -1
protected

Definition at line 207 of file ViewControl.h.

Referenced by SetConstantZNear(), SetViewMatrices(), and UnsetConstantZNear().

◆ distance_

double cloudViewer::visualization::ViewControl::distance_
protected

◆ eye_

Eigen::Vector3d cloudViewer::visualization::ViewControl::eye_
protected

◆ field_of_view_

◆ FIELD_OF_VIEW_DEFAULT

const double cloudViewer::visualization::ViewControl::FIELD_OF_VIEW_DEFAULT = 60.0
static

Definition at line 29 of file ViewControl.h.

Referenced by Reset().

◆ FIELD_OF_VIEW_MAX

const double cloudViewer::visualization::ViewControl::FIELD_OF_VIEW_MAX = 90.0
static

Definition at line 27 of file ViewControl.h.

Referenced by ChangeFieldOfView(), and ConvertFromPinholeCameraParameters().

◆ FIELD_OF_VIEW_MIN

◆ FIELD_OF_VIEW_STEP

const double cloudViewer::visualization::ViewControl::FIELD_OF_VIEW_STEP = 5.0
static

Definition at line 30 of file ViewControl.h.

Referenced by ChangeFieldOfView(), and SetProjectionParameters().

◆ front_

◆ local_rotate_right_accum_

double cloudViewer::visualization::ViewControl::local_rotate_right_accum_
protected

Definition at line 220 of file ViewControl.h.

Referenced by CameraLocalRotate(), and ResetCameraLocalRotate().

◆ local_rotate_up_accum_

double cloudViewer::visualization::ViewControl::local_rotate_up_accum_
protected

Definition at line 219 of file ViewControl.h.

Referenced by CameraLocalRotate(), and ResetCameraLocalRotate().

◆ lookat_

◆ model_matrix_

gl_util::GLMatrix4f cloudViewer::visualization::ViewControl::model_matrix_
protected

Definition at line 211 of file ViewControl.h.

Referenced by GetModelMatrix(), and SetViewMatrices().

◆ MVP_matrix_

gl_util::GLMatrix4f cloudViewer::visualization::ViewControl::MVP_matrix_
protected

Definition at line 212 of file ViewControl.h.

Referenced by GetMVPMatrix(), and SetViewMatrices().

◆ projection_matrix_

gl_util::GLMatrix4f cloudViewer::visualization::ViewControl::projection_matrix_
protected

Definition at line 209 of file ViewControl.h.

Referenced by GetProjectionMatrix(), and SetViewMatrices().

◆ right_

◆ ROTATION_RADIAN_PER_PIXEL

const double cloudViewer::visualization::ViewControl::ROTATION_RADIAN_PER_PIXEL = 0.003
static

◆ start_local_rotate_eye_

Eigen::Vector3d cloudViewer::visualization::ViewControl::start_local_rotate_eye_
protected

Definition at line 217 of file ViewControl.h.

Referenced by CameraLocalRotate(), and ResetCameraLocalRotate().

◆ start_local_rotate_front_

Eigen::Vector3d cloudViewer::visualization::ViewControl::start_local_rotate_front_
protected

Definition at line 216 of file ViewControl.h.

Referenced by CameraLocalRotate(), and ResetCameraLocalRotate().

◆ start_local_rotate_lookat_

Eigen::Vector3d cloudViewer::visualization::ViewControl::start_local_rotate_lookat_
protected

Definition at line 218 of file ViewControl.h.

Referenced by CameraLocalRotate(), and ResetCameraLocalRotate().

◆ start_local_rotate_right_

Eigen::Vector3d cloudViewer::visualization::ViewControl::start_local_rotate_right_
protected

Definition at line 215 of file ViewControl.h.

Referenced by CameraLocalRotate(), and ResetCameraLocalRotate().

◆ start_local_rotate_up_

Eigen::Vector3d cloudViewer::visualization::ViewControl::start_local_rotate_up_
protected

Definition at line 214 of file ViewControl.h.

Referenced by CameraLocalRotate(), and ResetCameraLocalRotate().

◆ up_

◆ view_matrix_

gl_util::GLMatrix4f cloudViewer::visualization::ViewControl::view_matrix_
protected

Definition at line 210 of file ViewControl.h.

Referenced by GetViewMatrix(), and SetViewMatrices().

◆ view_ratio_

double cloudViewer::visualization::ViewControl::view_ratio_
protected

◆ window_height_

◆ window_width_

int cloudViewer::visualization::ViewControl::window_width_ = 0
protected

◆ z_far_

double cloudViewer::visualization::ViewControl::z_far_
protected

Definition at line 206 of file ViewControl.h.

Referenced by GetZFar(), and SetViewMatrices().

◆ z_near_

double cloudViewer::visualization::ViewControl::z_near_
protected

Definition at line 205 of file ViewControl.h.

Referenced by GetZNear(), and SetViewMatrices().

◆ zoom_

◆ ZOOM_DEFAULT

const double cloudViewer::visualization::ViewControl::ZOOM_DEFAULT = 0.7
static

◆ ZOOM_MAX

const double cloudViewer::visualization::ViewControl::ZOOM_MAX = 2.0
static

Definition at line 34 of file ViewControl.h.

Referenced by ConvertFromPinholeCameraParameters(), and Scale().

◆ ZOOM_MIN

const double cloudViewer::visualization::ViewControl::ZOOM_MIN = 0.02
static

Definition at line 33 of file ViewControl.h.

Referenced by ConvertFromPinholeCameraParameters(), and Scale().

◆ ZOOM_STEP

const double cloudViewer::visualization::ViewControl::ZOOM_STEP = 0.02
static

Definition at line 35 of file ViewControl.h.

Referenced by Scale().


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