ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvViewportParameters.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "CV_db.h"
12 #include "ecvGLMatrix.h"
13 #include "ecvSerializableObject.h"
14 
15 class QRect;
16 
19 public: // functions
22 
25 
26  // inherited from ccSerializableObject
27  bool isSerializable() const override { return true; }
28  bool toFile(QFile& out, short dataVersion) const override;
29  short minimumFileVersion() const override;
30  bool fromFile(QFile& in,
31  short dataVersion,
32  int flags,
33  LoadedIDMap& oldToNewIDMap) override;
34 
36  void setPivotPoint(const CCVector3d& P, bool autoUpdateFocal = true);
37 
39  const CCVector3d& getPivotPoint() const { return pivotPoint; }
40 
42  //* _
43  void setCameraCenter(const CCVector3d& C, bool autoUpdateFocal = true);
44 
46  const CCVector3d& getCameraCenter() const { return cameraCenter; }
47 
49 
51  void setFocalDistance(double distance);
52 
54  double getFocalDistance() const { return focalDistance; }
55 
58  static double IncrementToZNearCoef(int i, int iMax);
59 
62  static int ZNearCoefToIncrement(double coef, int iMax);
63 
66 
68  ccGLMatrixd computeScaleMatrix(const QRect& glViewport) const;
69 
71 
75 
77 
81 
83 
87  const CCVector3d& getRotationCenter() const;
88 
90 
93 
95 
98 
100  double computeWidthAtFocalDist() const;
101 
103  double computePixelSize(int glWidth) const;
104 
105 public: // variables
108 
113 
115 
119  float pixelSize;
120 
122  float zoom;
123 
128 
131 
133  double zNearCoef;
135  double zNear;
137  double zFar;
138 
140 
142 
144  float fov_deg;
147 
148 protected:
151 
154 
157 };
#define CV_DB_LIB_API
Definition: CV_db.h:15
cmdLineReadable * params[]
Double version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:56
Serializable object interface.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
Standard parameters for GL displays/viewports.
double zNearCoef
Theoretical perspective 'zNear' relative position.
float defaultLineWidth
Line width.
bool perspectiveView
Perspective view state.
float fov_deg
Camera F.O.V. (field of view) in degrees.
CCVector3d getViewDir() const
Returns the viewing direction.
static int ZNearCoefToIncrement(double coef, int iMax)
float pixelSize
Current pixel size (in 'current unit'/pixel)
CCVector3d cameraCenter
Camera center.
double computeWidthAtFocalDist() const
Computes the object 'width' at the 'focal' distance.
double focalDistance
Focal distance.
bool isSerializable() const override
Returns whether object is serializable of not.
ecvViewportParameters(const ecvViewportParameters &params)
Copy constructor.
double computePixelSize(int glWidth) const
Computes the pixel size at the 'focal' distance.
float cameraAspectRatio
Camera aspect ratio.
double zFar
Actual perspective 'zFar' value.
ecvViewportParameters()
Default constructor.
ccGLMatrixd computeViewMatrix() const
Computes the view matrix.
double getFocalDistance() const
Computes the 'focal' distance.
bool toFile(QFile &out, short dataVersion) const override
Saves data to binary stream.
static double IncrementToZNearCoef(int i, int iMax)
const CCVector3d & getCameraCenter() const
Returns the camera center.
short minimumFileVersion() const override
Returns the minimum file version required to save this instance.
float defaultPointSize
Point size.
void setPivotPoint(const CCVector3d &P, bool autoUpdateFocal=true)
Sets the pivot point (for object-centered view mode)
const CCVector3d & getPivotPoint() const
Returns the pivot point (for object-centered view mode)
double computeDistanceToHalfWidthRatio() const
Computes the ratio 'distance to half width' (based on the current FOV)
ccGLMatrixd viewMat
Visualization matrix (rotation only)
void setCameraCenter(const CCVector3d &C, bool autoUpdateFocal=true)
Sets the camera center.
ccGLMatrixd computeScaleMatrix(const QRect &glViewport) const
Computes the scale matrix.
double computeDistanceToWidthRatio() const
Computes the ratio 'distance to width' (based on the current FOV)
bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads data from binary stream.
CCVector3d pivotPoint
Rotation pivot point (for object-centered view modes)
void setFocalDistance(double distance)
Sets the 'focal' distance.
double zNear
Actual perspective 'zNear' value.
CCVector3d getUpDir() const
Returns the up direction.
const CCVector3d & getRotationCenter() const
Returns the view rotation 'center'.