Commit 30306c37 authored by Mike Kremer's avatar Mike Kremer
Browse files

Added scripting function to set FOVY via view control plugin.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10373 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 1c014d3e
......@@ -631,6 +631,19 @@ void orthographicProjection( int _viewer ) {
std::cerr << "Requested illegal viewer for orthographicProjection()!!" << std::endl;
}
void setFOVY( 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 allowRotation(bool _mode, int _viewer ) {
if ( _viewer == ACTIVE_VIEWER ) {
examiner_widgets_[activeExaminer_]->allowRotation(_mode);
......
......@@ -320,6 +320,17 @@ ACG::Vec3d upVector(int _viewer = ACTIVE_VIEWER);
DLLEXPORT
void orthographicProjection( int _viewer = ALL_VIEWERS );
/** \brief Set field of view angle
*
* @param _fovy Field of view (in (1, 180) degrees)
* @param _viewer Id of the viewer to use.
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
void setFOVY( double _fovy, int _viewer = ALL_VIEWERS );
/** \brief Switch to perspective Projection
*
* @param _viewer Id of the viewer to use.
......
......@@ -383,6 +383,17 @@ void glViewer::navigationMode(NavigationMode _n)
emit navigationModeChanged( false );
}
void glViewer::setFOVY(double _fovy) {
if(_fovy <= 0.0 || _fovy >= 180) {
std::cerr << "Error: Minimum or maximum fovy angle exceeded!" << std::endl;
return;
}
OpenFlipperSettings().setValue("Core/Projection/FOVY", _fovy);
updateProjectionMatrix();
}
void glViewer::updateProjectionMatrix()
{
......
......@@ -370,6 +370,9 @@ public slots:
virtual void toggleProjectionMode();
/// toggle navigation mode
virtual void toggleNavigationMode();
/// Set fovy
virtual void setFOVY(double _fovy);
signals:
......
......@@ -1203,6 +1203,12 @@ void ViewControlPlugin::perspectiveProjection(int _viewer) {
PluginFunctions::perspectiveProjection(_viewer);
}
void ViewControlPlugin::setFOVY( double _fovy, int _viewer ) {
PluginFunctions::setFOVY(_fovy, _viewer);
emit updateView();
}
void ViewControlPlugin::setDescriptions() {
emit setSlotDescription("translate(Vector,int)", "Translate Scene",
QString("TranslationVector,Viewer").split(","),
......@@ -1254,6 +1260,12 @@ void ViewControlPlugin::setDescriptions() {
QStringList(), QStringList());
emit setSlotDescription("perspectiveProjection(int)", "Change all Viewers to perspective projection",
QStringList("Viewer"), QStringList("Id of the viewer to change"));
emit setSlotDescription("setFOVY(double,int)", "Set fovy angle of projection for a viewer.",
QString("fovy;viewer").split(";"), QString("FOVY angle;Id of the target viewer").split(";"));
emit setSlotDescription("setFOVY(double)", "Set fovy angle of projection for all viewers.",
QStringList("fovy"), QStringList("FOVY angle"));
}
......
......@@ -280,6 +280,9 @@ class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, Logg
/// Change all Viewers to perspectiveProjection
void perspectiveProjection(int _viewer);
/// Set fovy angle of projection
void setFOVY( double _fovy, int _viewer = PluginFunctions::ALL_VIEWERS );
};
......
Supports Markdown
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