Commit 0613284b authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Cleaned up QtBaseViewer code a bit.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@18265 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 124502f8
......@@ -409,7 +409,6 @@ void glViewer::setFOVY(double _fovy) {
updateProjectionMatrix();
}
void glViewer::updateProjectionMatrix()
{
if( projectionUpdateLocked_ )
......@@ -419,34 +418,23 @@ void glViewer::updateProjectionMatrix()
glstate_->reset_projection();
const double aspect = this->aspect_ratio();
// In stereo mode we have to use a perspective matrix
if ( projectionMode_ == PERSPECTIVE_PROJECTION)
{
double aspect;
if (isVisible() && glWidth() && glHeight())
aspect = (double) glWidth() / (double) glHeight();
else
aspect = 1.0;
// Get fovy
double fovy = OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble() + fovyModifier_;
const double fovy = this->field_of_view_vertical();
glstate_->perspective(fovy, (GLdouble) aspect,
properties_.nearPlane(), properties_.farPlane());
near_plane(), far_plane());
}
else
{
double aspect;
if (isVisible() && glWidth() && glHeight())
aspect = (double) glWidth() / (double) glHeight();
else
aspect = 1.0;
glstate_->ortho( -properties_.orthoWidth(), properties_.orthoWidth(),
-properties_.orthoWidth()/aspect, properties_.orthoWidth()/aspect,
properties_.nearPlane(), properties_.farPlane() );
glstate_->ortho( -ortho_width(), ortho_width(),
-ortho_width() / aspect, ortho_width() / aspect,
near_plane(), far_plane() );
}
}
......@@ -1378,6 +1366,12 @@ QPoint glViewer::glMapToGlobal( const QPoint& _pos ) const {
return scene()->views().front()->mapToGlobal(p);
}
double glViewer::field_of_view_vertical() const {
return OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble()
+ fovyModifier_;
}
//-----------------------------------------------------------------------------
......
......@@ -277,6 +277,31 @@ public:
/// map glarea coords to global coords
QPoint glMapToGlobal( const QPoint& _pos ) const;
double field_of_view_vertical() const;
/// Returns the viewer's aspect ratio.
double aspect_ratio() const {
if (isVisible() && glWidth() && glHeight())
return (double) glWidth() / (double) glHeight();
else
return 1.0;
}
/// Returns a chili cheese burger.
double near_plane() const {
return properties_.nearPlane();
}
/// Returns a peanut butter sandwich.
double far_plane() const {
return properties_.farPlane();
}
/// Get width of the gl scene in orthogonal projection mode
double ortho_width() const {
return properties_.orthoWidth();
}
/** convert current view to text representation
if saved, the old window size will be written into _windowSize
\note QSize(0,0) indicates that the window is maximized.
......@@ -920,7 +945,8 @@ private:
public:
/// Returns a pointer to the Viewer Status
Viewer::ViewerProperties* properties(){ return &properties_; };
Viewer::ViewerProperties* properties() { return &properties_; };
const Viewer::ViewerProperties* properties() const { return &properties_; };
private:
/// All properties for this viewer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment