17 : defaultPointSize(1),
21 perspectiveView(false),
22 objectCenteredView(true),
29 cameraAspectRatio(1.0f),
32 cameraCenter(0, 0, focalDistance) {
38 : viewMat(params.viewMat),
39 defaultPointSize(params.defaultPointSize),
40 defaultLineWidth(params.defaultLineWidth),
41 pixelSize(params.pixelSize),
43 perspectiveView(params.perspectiveView),
44 objectCenteredView(params.objectCenteredView),
45 zNearCoef(params.zNearCoef),
50 fov_deg(params.fov_deg),
51 cameraAspectRatio(params.cameraAspectRatio),
52 focalDistance(params.focalDistance),
53 pivotPoint(params.pivotPoint),
54 cameraCenter(params.cameraCenter) {}
57 if (dataVersion < 20) {
66 QDataStream outStream(&out);
102 if (dataVersion >= 36)
109 if (!_viewMat.
fromFile(in, dataVersion, flags, oldToNewIDMap))
115 QDataStream inStream(&in);
119 if (dataVersion < 25)
128 if (dataVersion >= 36)
148 if (dataVersion >= 25)
163 if (dataVersion < 25)
167 inStream >> screenPan[0];
168 inStream >> screenPan[1];
176 if (dataVersion >= 30 && dataVersion < 48) {
178 float orthoAspectRatio = 0.0f;
179 inStream >> orthoAspectRatio;
184 if (dataVersion < 48 &&
zoom != 1.0f) {
196 "[ecvViewportParameters] Approximate focal distance (sorry, "
197 "the parameters of viewport objects have changed!)");
204 assert(i >= 0 && i <= iMax);
205 return pow(10, -
static_cast<double>((iMax - i) * 3) /
210 assert(coef >= 0 && coef <= 1.0);
211 double id = -(iMax / 3.0) * log10(coef);
212 int i =
static_cast<int>(id);
214 if (std::abs(
id - i) > std::abs(
id - (i + 1))) {
217 assert(i >= 0 && i <= iMax);
249 const QRect& glViewport)
const {
254 if (glViewport.height() != 0) {
255 double ar =
static_cast<double>(
259 scaleMatd.
data()[0] = ar;
260 scaleMatd.
data()[5] = ar;
287 bool autoUpdateFocal) {
296 bool autoUpdateFocal) {
constexpr float ZERO_TOLERANCE_F
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
void normalize()
Sets vector norm to unity.
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
Vector3Tpl< T > getTranslationAsVec3D() const
Returns a copy of the translation as a CCVector3.
bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads data from binary stream.
T * data()
Returns a pointer to internal data.
bool toFile(QFile &out, short dataVersion) const override
Saves data to binary stream.
void setTranslation(const Vector3Tpl< float > &Tr)
Sets translation (float version)
short minimumFileVersion() const override
Returns the minimum file version required to save this instance.
virtual void toIdentity()
Sets matrix to identity.
Float version of ccGLMatrixTpl.
Double version of ccGLMatrixTpl.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
static void CoordsFromDataStream(QDataStream &stream, int flags, PointCoordinateType *out, unsigned count=1)
Standard parameters for GL displays/viewports.
static int ZNearCoefToIncrement(double coef, int iMax)
float defaultLineWidth
Line width.
const CCVector3d & getRotationCenter() const
Returns the view rotation 'center'.
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 double IncrementToZNearCoef(int i, 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.
double computePixelSize(int glWidth) const
Computes the pixel size at the 'focal' distance.
float cameraAspectRatio
Camera aspect ratio.
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.
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)
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.
CCVector3d getUpDir() const
Returns the up direction.
static double distance(T *pot1, T *pot2)
float DegreesToRadians(int degrees)
Convert degrees to radians.