Commit e5c9b6e1 authored by Mike Kremer's avatar Mike Kremer

Added option to adjust fovy angle in options widget.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10351 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a49ee4ca
......@@ -893,6 +893,31 @@ ACG::Vec3d upVector(int _viewer) {
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)
{
for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
......
......@@ -311,6 +311,25 @@ ACG::Vec3d eyePos(int _viewer = ACTIVE_VIEWER);
DLLEXPORT
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
*
* @param _viewer Id of the viewer to use.
......
......@@ -495,6 +495,13 @@ 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)
{
......
......@@ -246,6 +246,9 @@ public:
/// Set look at transformation directly
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?
enum NormalsMode {
......
......@@ -375,6 +375,12 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
wZoomFactorShift->setValue( OpenFlipperSettings().value("Core/Mouse/Wheel/ZoomFactorShift").toDouble() );
wheelBox->setChecked( OpenFlipperSettings().value("Core/Gui/glViewer/showControlWheels").toBool() );
// Projection settings
// Get field of view in radiant
double fov = PluginFunctions::fovy() * 180/M_PI;
fieldOfView->setValue(fov);
restrictFPS->setChecked( OpenFlipperSettings().value("Core/Gui/glViewer/restrictFrameRate",false).toBool() );
FPS->setValue( OpenFlipperSettings().value("Core/Gui/glViewer/maxFrameRate",35).toInt() );
......@@ -604,6 +610,16 @@ void OptionsWidget::slotApply() {
//viewer
OpenFlipperSettings().setValue("Core/Mouse/Wheel/ZoomFactor", wZoomFactor->text().toDouble());
OpenFlipperSettings().setValue("Core/Mouse/Wheel/ZoomFactorShift", wZoomFactorShift->text().toDouble());
// Projection settings
double fovy = fieldOfView->value();
double old_fovy = OpenFlipperSettings().value("Core/Projection/FOV", 45.0).toDouble();
if(fovy != old_fovy) {
OpenFlipperSettings().setValue("Core/Projection/FOV", fovy);
// Reset projection with new fovy
PluginFunctions::fovy(fovy);
}
OpenFlipperSettings().setValue("Core/Gui/glViewer/showControlWheels", wheelBox->isChecked() );
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>670</width>
<height>917</height>
<width>778</width>
<height>932</height>
</rect>
</property>
<property name="windowTitle">
......@@ -23,7 +23,7 @@
<string/>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<property name="usesScrollButtons">
<bool>true</bool>
......@@ -306,13 +306,6 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>MouseWheel Zoom Sensitivity (shift):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="wZoomFactor">
<property name="maximumSize">
......@@ -332,6 +325,13 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>MouseWheel Zoom Sensitivity (shift):</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="wZoomFactorShift">
<property name="maximumSize">
......@@ -354,6 +354,75 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_12">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="title">
<string>Projection</string>
</property>
<widget class="QWidget" name="formLayoutWidget_2">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>541</width>
<height>61</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_5">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Projection type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="projectionBox">
<item>
<property name="text">
<string>Orthogonal</string>
</property>
</item>
<item>
<property name="text">
<string>Perspective</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Field of View</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="fieldOfView">
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>179.000000000000000</double>
</property>
<property name="value">
<double>45.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
......@@ -619,27 +688,6 @@ You can select multiple modes at the same time.</string>
</item>
<item>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Projection:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="projectionBox">
<item>
<property name="text">
<string>Orthogonal</string>
</property>
</item>
<item>
<property name="text">
<string>Perspective</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
......
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