Commit 6eca2eff authored by Mike Kremer's avatar Mike Kremer

Corrected setting of fovy value via options widget to be read directly out of OF settings

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10353 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e5c9b6e1
...@@ -893,31 +893,6 @@ ACG::Vec3d upVector(int _viewer) { ...@@ -893,31 +893,6 @@ ACG::Vec3d upVector(int _viewer) {
return viewerProperties().glState().up(); return viewerProperties().glState().up();
} }
double fovy(int _viewer) {
if ( _viewer == ACTIVE_VIEWER ) {
return viewerProperties(activeExaminer_).glState().fovy();
} else if ( _viewer == ALL_VIEWERS )
std::cerr << "Please select viewer to get fovy!" << std::endl;
else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
return viewerProperties(_viewer).glState().fovy();
else
std::cerr << "Requested illegal viewer for fovy!!" << std::endl;
return viewerProperties().glState().fovy();
}
void fovy(double _fovy, int _viewer) {
if ( _viewer == ACTIVE_VIEWER ) {
examiner_widgets_[activeExaminer_]->setFOVY( _fovy );
} else if ( _viewer == ALL_VIEWERS )
for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
examiner_widgets_[i]->setFOVY( _fovy );
else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
examiner_widgets_[_viewer]->setFOVY( _fovy );
else
std::cerr << "Requested illegal viewer for setFOVY!!" << std::endl;
}
void setViewObjectMarker(ViewObjectMarker * _marker) void setViewObjectMarker(ViewObjectMarker * _marker)
{ {
for ( uint i = 0 ; i < examiner_widgets_.size(); ++i ) for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
......
...@@ -311,25 +311,6 @@ ACG::Vec3d eyePos(int _viewer = ACTIVE_VIEWER); ...@@ -311,25 +311,6 @@ ACG::Vec3d eyePos(int _viewer = ACTIVE_VIEWER);
DLLEXPORT DLLEXPORT
ACG::Vec3d upVector(int _viewer = ACTIVE_VIEWER); ACG::Vec3d upVector(int _viewer = ACTIVE_VIEWER);
/** \brief Get the current fovy value
*
* @param _viewer Id of the viewer to use.
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
double fovy(int _viewer = ACTIVE_VIEWER);
/** \brief Set the fovy value
*
* @param _fovy The new fovy value
* @param _viewer Id of the viewer to use.
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
void fovy(double _fovy, int _viewer = ACTIVE_VIEWER);
/** \brief Switch to orthographic Projection /** \brief Switch to orthographic Projection
* *
* @param _viewer Id of the viewer to use. * @param _viewer Id of the viewer to use.
......
...@@ -167,7 +167,6 @@ glViewer::glViewer( QGraphicsScene* _scene, ...@@ -167,7 +167,6 @@ glViewer::glViewer( QGraphicsScene* _scene,
lookAround_ = false; lookAround_ = false;
near_ = 0.1; near_ = 0.1;
far_ = 100.0; far_ = 100.0;
fovy_ = 45.0;
sceneGraphRoot_ = 0; sceneGraphRoot_ = 0;
...@@ -404,7 +403,10 @@ void glViewer::updateProjectionMatrix() ...@@ -404,7 +403,10 @@ void glViewer::updateProjectionMatrix()
else else
aspect = 1.0; aspect = 1.0;
glstate_->perspective(fovy_, (GLdouble) aspect, // Get fovy
double fovy = OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble();
glstate_->perspective(fovy, (GLdouble) aspect,
near_, far_); near_, far_);
} }
else else
...@@ -495,14 +497,6 @@ void glViewer::lookAt(const ACG::Vec3d& _eye, const ACG::Vec3d& _center, const A ...@@ -495,14 +497,6 @@ void glViewer::lookAt(const ACG::Vec3d& _eye, const ACG::Vec3d& _center, const A
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void glViewer::setFOVY(double _fovy) {
fovy_ = _fovy;
updateProjectionMatrix();
}
//-----------------------------------------------------------------------------
void glViewer::normalsMode(NormalsMode _mode) void glViewer::normalsMode(NormalsMode _mode)
{ {
makeCurrent(); makeCurrent();
......
...@@ -247,9 +247,6 @@ public: ...@@ -247,9 +247,6 @@ public:
/// Set look at transformation directly /// Set look at transformation directly
void lookAt(const ACG::Vec3d& _eye, const ACG::Vec3d& _center, const ACG::Vec3d& _up); void lookAt(const ACG::Vec3d& _eye, const ACG::Vec3d& _center, const ACG::Vec3d& _up);
/// Set the field of view value
void setFOVY(double _fovy);
/// Automatically normalize normals? /// Automatically normalize normals?
enum NormalsMode { enum NormalsMode {
/// use provided normals as is /// use provided normals as is
...@@ -551,7 +548,7 @@ protected: ...@@ -551,7 +548,7 @@ protected:
// projection stuff // projection stuff
GLdouble orthoWidth_; GLdouble orthoWidth_;
GLdouble near_, far_, fovy_; GLdouble near_, far_;
// helper // helper
bool isRotating_; bool isRotating_;
......
...@@ -117,7 +117,8 @@ glViewer::drawScene_glStereo() ...@@ -117,7 +117,8 @@ glViewer::drawScene_glStereo()
h = glHeight(); h = glHeight();
a = w / h; a = w / h;
radians = fovy_ * 0.5 / 180.0 * M_PI; double fovy = OpenFlipperSettings().value("Core/Projection/FOVY").toDouble();
radians = fovy * 0.5 / 180.0 * M_PI;
wd2 = near_ * tan(radians); wd2 = near_ * tan(radians);
zerop = near_ + ((far_ - near_) * OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() ); zerop = near_ + ((far_ - near_) * OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() );
ndfl = near_ / zerop ; ndfl = near_ / zerop ;
...@@ -512,7 +513,8 @@ glViewer::drawScene_anaglyphStereo() ...@@ -512,7 +513,8 @@ glViewer::drawScene_anaglyphStereo()
h = glHeight(); h = glHeight();
a = w / h; a = w / h;
radians = fovy_ * 0.5 / 180.0 * M_PI; double fovy = OpenFlipperSettings().value("Core/Projection/FOVY").toDouble();
radians = fovy * 0.5 / 180.0 * M_PI;
wd2 = near_ * tan(radians); wd2 = near_ * tan(radians);
zerop = near_ + ((far_ - near_) * OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() ); zerop = near_ + ((far_ - near_) * OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() );
ndfl = near_ / zerop ; ndfl = near_ / zerop ;
...@@ -643,7 +645,8 @@ glViewer::drawScene_customAnaglyphStereo() ...@@ -643,7 +645,8 @@ glViewer::drawScene_customAnaglyphStereo()
h = glHeight(); h = glHeight();
a = w / h; a = w / h;
radians = fovy_ * 0.5 / 180.0 * M_PI; double fovy = OpenFlipperSettings().value("Core/Projection/FOVY").toDouble();
radians = fovy * 0.5 / 180.0 * M_PI;
wd2 = near_ * tan(radians); wd2 = near_ * tan(radians);
zerop = near_ + ((far_ - near_) * OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() ); zerop = near_ + ((far_ - near_) * OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() );
ndfl = near_ / zerop ; ndfl = near_ / zerop ;
......
...@@ -379,8 +379,8 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) { ...@@ -379,8 +379,8 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
// Projection settings // Projection settings
// Get field of view in radiant // Get field of view in radiant
double fov = PluginFunctions::fovy() * 180/M_PI; double fovy = OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble();
fieldOfView->setValue(fov); fieldOfView->setValue(fovy);
restrictFPS->setChecked( OpenFlipperSettings().value("Core/Gui/glViewer/restrictFrameRate",false).toBool() ); restrictFPS->setChecked( OpenFlipperSettings().value("Core/Gui/glViewer/restrictFrameRate",false).toBool() );
FPS->setValue( OpenFlipperSettings().value("Core/Gui/glViewer/maxFrameRate",35).toInt() ); FPS->setValue( OpenFlipperSettings().value("Core/Gui/glViewer/maxFrameRate",35).toInt() );
...@@ -613,12 +613,10 @@ void OptionsWidget::slotApply() { ...@@ -613,12 +613,10 @@ void OptionsWidget::slotApply() {
// Projection settings // Projection settings
double fovy = fieldOfView->value(); double fovy = fieldOfView->value();
double old_fovy = OpenFlipperSettings().value("Core/Projection/FOV", 45.0).toDouble(); double old_fovy = OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble();
if(fovy != old_fovy) { if(fovy != old_fovy) {
OpenFlipperSettings().setValue("Core/Projection/FOV", fovy); OpenFlipperSettings().setValue("Core/Projection/FOVY", fovy);
// Reset projection with new fovy
PluginFunctions::fovy(fovy);
} }
OpenFlipperSettings().setValue("Core/Gui/glViewer/showControlWheels", wheelBox->isChecked() ); OpenFlipperSettings().setValue("Core/Gui/glViewer/showControlWheels", wheelBox->isChecked() );
...@@ -983,4 +981,4 @@ void OptionsWidget::slotClearINI() { ...@@ -983,4 +981,4 @@ void OptionsWidget::slotClearINI() {
tr("The changes will take effect after next restart.")); tr("The changes will take effect after next restart."));
OpenFlipper::Options::deleteIniFile(true); OpenFlipper::Options::deleteIniFile(true);
} }
\ No newline at end of file
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