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 
65  ccGLMatrixd computeViewMatrix() const;
66 
68  ccGLMatrixd computeScaleMatrix(const QRect& glViewport) const;
69 
71 
74  CCVector3d getViewDir() const;
75 
77 
80  CCVector3d getUpDir() const;
81 
83 
87  const CCVector3d& getRotationCenter() const;
88 
90 
92  double computeDistanceToHalfWidthRatio() const;
93 
95 
97  double computeDistanceToWidthRatio() const;
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
Double version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:56
Serializable object interface.
virtual short minimumFileVersion() const =0
Returns the minimum file version required to save this instance.
virtual bool toFile(QFile &out, short dataVersion) const
Saves data to binary stream.
virtual bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap)
Loads data from binary stream.
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.
float pixelSize
Current pixel size (in 'current unit'/pixel)
CCVector3d cameraCenter
Camera center.
double focalDistance
Focal distance.
bool isSerializable() const override
Returns whether object is serializable of not.
float cameraAspectRatio
Camera aspect ratio.
double zFar
Actual perspective 'zFar' value.
double getFocalDistance() const
Computes the 'focal' distance.
const CCVector3d & getCameraCenter() const
Returns the camera center.
float defaultPointSize
Point size.
const CCVector3d & getPivotPoint() const
Returns the pivot point (for object-centered view mode)
ccGLMatrixd viewMat
Visualization matrix (rotation only)
CCVector3d pivotPoint
Rotation pivot point (for object-centered view modes)
double zNear
Actual perspective 'zNear' value.
static double distance(T *pot1, T *pot2)
Definition: utils.h:111