ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvViewportParameters Class Reference

Standard parameters for GL displays/viewports. More...

#include <ecvViewportParameters.h>

Inheritance diagram for ecvViewportParameters:
Collaboration diagram for ecvViewportParameters:

Public Member Functions

 ecvViewportParameters ()
 Default constructor. More...
 
 ecvViewportParameters (const ecvViewportParameters &params)
 Copy constructor. More...
 
bool isSerializable () const override
 Returns whether object is serializable of not. More...
 
bool toFile (QFile &out, short dataVersion) const override
 Saves data to binary stream. More...
 
short minimumFileVersion () const override
 Returns the minimum file version required to save this instance. More...
 
bool fromFile (QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
 Loads data from binary stream. More...
 
void setPivotPoint (const CCVector3d &P, bool autoUpdateFocal=true)
 Sets the pivot point (for object-centered view mode) More...
 
const CCVector3dgetPivotPoint () const
 Returns the pivot point (for object-centered view mode) More...
 
void setCameraCenter (const CCVector3d &C, bool autoUpdateFocal=true)
 Sets the camera center. More...
 
const CCVector3dgetCameraCenter () const
 Returns the camera center. More...
 
void setFocalDistance (double distance)
 Sets the 'focal' distance. More...
 
double getFocalDistance () const
 Computes the 'focal' distance. More...
 
ccGLMatrixd computeViewMatrix () const
 Computes the view matrix. More...
 
ccGLMatrixd computeScaleMatrix (const QRect &glViewport) const
 Computes the scale matrix. More...
 
CCVector3d getViewDir () const
 Returns the viewing direction. More...
 
CCVector3d getUpDir () const
 Returns the up direction. More...
 
const CCVector3dgetRotationCenter () const
 Returns the view rotation 'center'. More...
 
double computeDistanceToHalfWidthRatio () const
 Computes the ratio 'distance to half width' (based on the current FOV) More...
 
double computeDistanceToWidthRatio () const
 Computes the ratio 'distance to width' (based on the current FOV) More...
 
double computeWidthAtFocalDist () const
 Computes the object 'width' at the 'focal' distance. More...
 
double computePixelSize (int glWidth) const
 Computes the pixel size at the 'focal' distance. More...
 
- Public Member Functions inherited from ccSerializableObject
virtual ~ccSerializableObject ()=default
 Destructor. More...
 

Static Public Member Functions

static double IncrementToZNearCoef (int i, int iMax)
 
static int ZNearCoefToIncrement (double coef, int iMax)
 
- Static Public Member Functions inherited from ccSerializableObject
static bool WriteError ()
 Sends a custom error message (write error) and returns 'false'. More...
 
static bool ReadError ()
 Sends a custom error message (read error) and returns 'false'. More...
 
static bool MemoryError ()
 Sends a custom error message (not enough memory) and returns 'false'. More...
 
static bool CorruptError ()
 Sends a custom error message (corrupted file) and returns 'false'. More...
 

Public Attributes

ccGLMatrixd viewMat
 Visualization matrix (rotation only) More...
 
float defaultPointSize
 Point size. More...
 
float defaultLineWidth
 Line width. More...
 
float pixelSize
 Current pixel size (in 'current unit'/pixel) More...
 
float zoom
 Current zoom. More...
 
bool perspectiveView
 Perspective view state. More...
 
bool objectCenteredView
 
double zNearCoef
 Theoretical perspective 'zNear' relative position. More...
 
double zNear
 Actual perspective 'zNear' value. More...
 
double zFar
 Actual perspective 'zFar' value. More...
 
CCVector3d focal
 
CCVector3d up
 
float fov_deg
 Camera F.O.V. (field of view) in degrees. More...
 
float cameraAspectRatio
 Camera aspect ratio. More...
 

Protected Attributes

double focalDistance
 Focal distance. More...
 
CCVector3d pivotPoint
 Rotation pivot point (for object-centered view modes) More...
 
CCVector3d cameraCenter
 Camera center. More...
 

Additional Inherited Members

- Public Types inherited from ccSerializableObject
enum  DeserializationFlags { DF_POINT_COORDS_64_BITS , DF_SCALAR_VAL_32_BITS = 2 }
 Deserialization flags (bit-field) More...
 
typedef QMultiMap< unsigned, unsigned > LoadedIDMap
 Map of loaded unique IDs (old ID --> new ID) More...
 

Detailed Description

Standard parameters for GL displays/viewports.

Definition at line 18 of file ecvViewportParameters.h.

Constructor & Destructor Documentation

◆ ecvViewportParameters() [1/2]

ecvViewportParameters::ecvViewportParameters ( )

Default constructor.

Definition at line 16 of file ecvViewportParameters.cpp.

References ccGLMatrixTpl< T >::toIdentity(), and viewMat.

◆ ecvViewportParameters() [2/2]

ecvViewportParameters::ecvViewportParameters ( const ecvViewportParameters params)

Copy constructor.

Definition at line 36 of file ecvViewportParameters.cpp.

Member Function Documentation

◆ computeDistanceToHalfWidthRatio()

double ecvViewportParameters::computeDistanceToHalfWidthRatio ( ) const

Computes the ratio 'distance to half width' (based on the current FOV)

Half width = ratio * distance = tan(fov / 2) * distance

Definition at line 312 of file ecvViewportParameters.cpp.

References cloudViewer::DegreesToRadians(), and fov_deg.

Referenced by computeDistanceToWidthRatio(), define_ccViewPortParameters(), and GamepadInput::update().

◆ computeDistanceToWidthRatio()

double ecvViewportParameters::computeDistanceToWidthRatio ( ) const

Computes the ratio 'distance to width' (based on the current FOV)

Width = ratio * distance = (2 * tan(fov / 2)) * distance

Definition at line 317 of file ecvViewportParameters.cpp.

References computeDistanceToHalfWidthRatio().

Referenced by computeWidthAtFocalDist(), and define_ccViewPortParameters().

◆ computePixelSize()

double ecvViewportParameters::computePixelSize ( int  glWidth) const

Computes the pixel size at the 'focal' distance.

Definition at line 325 of file ecvViewportParameters.cpp.

References computeWidthAtFocalDist().

Referenced by define_ccViewPortParameters().

◆ computeScaleMatrix()

ccGLMatrixd ecvViewportParameters::computeScaleMatrix ( const QRect &  glViewport) const

Computes the scale matrix.

Definition at line 248 of file ecvViewportParameters.cpp.

References cameraAspectRatio, ccGLMatrixTpl< T >::data(), and ccGLMatrixTpl< T >::toIdentity().

◆ computeViewMatrix()

◆ computeWidthAtFocalDist()

double ecvViewportParameters::computeWidthAtFocalDist ( ) const

Computes the object 'width' at the 'focal' distance.

Definition at line 321 of file ecvViewportParameters.cpp.

References computeDistanceToWidthRatio(), and getFocalDistance().

Referenced by Mouse3DInput::Apply(), computePixelSize(), define_ccViewPortParameters(), ccMouseCircle::draw(), and GamepadInput::update().

◆ fromFile()

bool ecvViewportParameters::fromFile ( QFile &  in,
short  dataVersion,
int  flags,
LoadedIDMap oldToNewIDMap 
)
overridevirtual

Loads data from binary stream.

Parameters
ininput file (already opened)
dataVersionfile version (for version-specific deserialization)
flagsdeserialization flags (see ccSerializableObject::DeserializationFlags)
oldToNewIDMapmap to link old IDs with new IDs
Returns
success
Note: When implementing, use dataVersion checks to handle different
versions:
  • if (dataVersion >= X) { read new field } else { use default value } This ensures forward compatibility with older file formats.

Reimplemented from ccSerializableObject.

Definition at line 97 of file ecvViewportParameters.cpp.

◆ getCameraCenter()

const CCVector3d& ecvViewportParameters::getCameraCenter ( ) const
inline

◆ getFocalDistance()

double ecvViewportParameters::getFocalDistance ( ) const
inline

◆ getPivotPoint()

const CCVector3d& ecvViewportParameters::getPivotPoint ( ) const
inline

◆ getRotationCenter()

const CCVector3d & ecvViewportParameters::getRotationCenter ( ) const

Returns the view rotation 'center'.

The rotation center is defined as:

  • the pivot point in object-centered view mode
  • the camera center in viewer-centered view mode

Definition at line 221 of file ecvViewportParameters.cpp.

References cameraCenter, objectCenteredView, and pivotPoint.

Referenced by computeViewMatrix(), and define_ccViewPortParameters().

◆ getUpDir()

CCVector3d ecvViewportParameters::getUpDir ( ) const

Returns the up direction.

This is the vertical direction of the screen (pointing 'upward') in the world coordinate system.

Definition at line 277 of file ecvViewportParameters.cpp.

References ccGLMatrixTpl< T >::data(), Vector3Tpl< Type >::normalize(), and viewMat.

Referenced by define_ccViewPortParameters().

◆ getViewDir()

CCVector3d ecvViewportParameters::getViewDir ( ) const

Returns the viewing direction.

This is the direction normal to the screen (pointing 'forward') in the world coordinate system.

Definition at line 267 of file ecvViewportParameters.cpp.

References ccGLMatrixTpl< T >::data(), Vector3Tpl< Type >::normalize(), and viewMat.

Referenced by define_ccViewPortParameters().

◆ IncrementToZNearCoef()

double ecvViewportParameters::IncrementToZNearCoef ( int  i,
int  iMax 
)
static

Helper: converts an integer (increment) in [0 iMax] to a double (zNear) value in [0.001 1]

Definition at line 203 of file ecvViewportParameters.cpp.

Referenced by QVTKWidgetCustom::wheelEvent().

◆ isSerializable()

bool ecvViewportParameters::isSerializable ( ) const
inlineoverridevirtual

Returns whether object is serializable of not.

Reimplemented from ccSerializableObject.

Definition at line 27 of file ecvViewportParameters.h.

◆ minimumFileVersion()

short ecvViewportParameters::minimumFileVersion ( ) const
overridevirtual

Returns the minimum file version required to save this instance.

To be overridden by subclasses to indicate their minimum required version. This enables the system to determine:

  • Forward compatibility: newer software can read older files (dataVersion check in fromFile)
  • Backward compatibility: determine minimum version needed to save current data
    Returns
    minimum file version required for this object

Implements ccSerializableObject.

Definition at line 92 of file ecvViewportParameters.cpp.

References ccGLMatrixTpl< T >::minimumFileVersion(), and viewMat.

Referenced by cc2DViewportObject::minimumFileVersion_MeOnly().

◆ setCameraCenter()

void ecvViewportParameters::setCameraCenter ( const CCVector3d C,
bool  autoUpdateFocal = true 
)

◆ setFocalDistance()

void ecvViewportParameters::setFocalDistance ( double  distance)

Sets the 'focal' distance.

Warning
changes the camera cener position in object-centered view mode

Definition at line 304 of file ecvViewportParameters.cpp.

References cameraCenter, Utils::distance(), focalDistance, objectCenteredView, pivotPoint, and Tuple3Tpl< Type >::z.

Referenced by Mouse3DInput::Apply(), define_ccViewPortParameters(), cloudViewer::ViewInterpolate::interpolate(), and ViewInterpolate::interpolate().

◆ setPivotPoint()

void ecvViewportParameters::setPivotPoint ( const CCVector3d P,
bool  autoUpdateFocal = true 
)

◆ toFile()

bool ecvViewportParameters::toFile ( QFile &  out,
short  dataVersion 
) const
overridevirtual

Saves data to binary stream.

Parameters
outoutput file (already opened)
dataVersiontarget file version (for forward/backward compatibility)
Returns
success

Reimplemented from ccSerializableObject.

Definition at line 56 of file ecvViewportParameters.cpp.

◆ ZNearCoefToIncrement()

int ecvViewportParameters::ZNearCoefToIncrement ( double  coef,
int  iMax 
)
static

Helper: converts a double (zNear) value in ]0 1] to integer increments in [0 iMax]

Definition at line 209 of file ecvViewportParameters.cpp.

Referenced by QVTKWidgetCustom::wheelEvent().

Member Data Documentation

◆ cameraAspectRatio

◆ cameraCenter

CCVector3d ecvViewportParameters::cameraCenter
protected

◆ defaultLineWidth

float ecvViewportParameters::defaultLineWidth

◆ defaultPointSize

float ecvViewportParameters::defaultPointSize

◆ focal

◆ focalDistance

double ecvViewportParameters::focalDistance
protected

Focal distance.

Definition at line 150 of file ecvViewportParameters.h.

Referenced by setCameraCenter(), setFocalDistance(), and setPivotPoint().

◆ fov_deg

◆ objectCenteredView

bool ecvViewportParameters::objectCenteredView

Whether view is centered on displayed scene (true) or on the user eye (false) Always true for ortho. mode.

Definition at line 130 of file ecvViewportParameters.h.

Referenced by Mouse3DInput::Apply(), define_ccViewPortParameters(), cc2DViewportLabel::drawMeOnly(), getRotationCenter(), QVTKWidgetCustom::mouseMoveEvent(), MainWindow::onItemPicked(), setCameraCenter(), setFocalDistance(), setPivotPoint(), and GamepadInput::update().

◆ perspectiveView

◆ pivotPoint

CCVector3d ecvViewportParameters::pivotPoint
protected

Rotation pivot point (for object-centered view modes)

Definition at line 153 of file ecvViewportParameters.h.

Referenced by getRotationCenter(), setCameraCenter(), setFocalDistance(), and setPivotPoint().

◆ pixelSize

float ecvViewportParameters::pixelSize

Current pixel size (in 'current unit'/pixel)

This scale is valid eveywhere in ortho. mode or at the focal distance in perspective mode. Warning: doesn't take current zoom into account!

Definition at line 119 of file ecvViewportParameters.h.

Referenced by cc2DViewportLabel::drawMeOnly(), ccSphere::drawNameIn3D(), ecvDisplayTools::onWheelEvent(), cc2Point5DimEditor::update2DDisplayZoom(), and DistanceMapGenerationDlg::updateZoom().

◆ up

◆ viewMat

◆ zFar

◆ zNear

◆ zNearCoef

double ecvViewportParameters::zNearCoef

Theoretical perspective 'zNear' relative position.

Definition at line 133 of file ecvViewportParameters.h.

Referenced by define_ccViewPortParameters(), cloudViewer::ViewInterpolate::interpolate(), ViewInterpolate::interpolate(), and QVTKWidgetCustom::wheelEvent().

◆ zoom


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