Commit 6f335be5 authored by Jan Möbius's avatar Jan Möbius

Added default lock rotation setting

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11406 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 065f81f1
......@@ -260,8 +260,6 @@ void Core::readApplicationOptions(INIFile& _ini) {
if( _ini.get_entry(draw_modes, "Options", "DefaultDrawModes" + QString::number(i) ) )
OpenFlipper::Options::defaultDrawMode( listToDrawMode(draw_modes), i );
if( _ini.get_entry(mode, "Options", "DefaultViewingDirection" + QString::number(i) ) )
OpenFlipper::Options::defaultViewingDirection( mode, i );
}
//============================================================================
......@@ -463,7 +461,6 @@ void Core::writeApplicationOptions(INIFile& _ini) {
draw_modes = drawModeToList( OpenFlipper::Options::defaultDrawMode(i) );
_ini.add_entry("Options","DefaultDrawModes" + QString::number(i), draw_modes);
_ini.add_entry("Options","DefaultViewingDirection" + QString::number(i), OpenFlipper::Options::defaultViewingDirection(i) );
}
_ini.add_entry("Options","DefaultBaseColor", (uint)OpenFlipper::Options::defaultBaseColor().rgba () );
......
......@@ -489,22 +489,6 @@ void Core::slotFileOpened ( int _id ) {
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
// ================================================================================
// Set defaults for DrawMode, ViewingDirection and Projection if this is the first opened object
// If a plugin changes the drawmode later, this setting will be overridden!
// ================================================================================
if ( PluginFunctions::objectCount() == 1 && OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() )
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ){
PluginFunctions::viewerProperties(i).drawMode( OpenFlipper::Options::defaultDrawMode(i) );
if ( OpenFlipper::Options::defaultPerspectiveProjectionMode(i) )
PluginFunctions::perspectiveProjection(i);
else
PluginFunctions::orthographicProjection(i);
PluginFunctions::setFixedView(OpenFlipper::Options::defaultViewingDirection(i), i );
}
// ================================================================================
// Recompute bounding box and scenegraph info
// Reset scene center here to include new object
......
......@@ -123,9 +123,11 @@ void Core::applyOptions(){
//set viewer properties
for (int i=0; i < PluginFunctions::viewers(); i++){
std::cerr << "ApplyOptions" << std::endl;
// PluginFunctions::setDrawMode( OpenFlipper::Options::defaultDrawMode(i), i );
PluginFunctions::setFixedView(OpenFlipper::Options::defaultViewingDirection(i), i );
PluginFunctions::allowRotation(!OpenFlipper::Options::defaultLockRotation(i),i);
//only switch projection here if an object is opened
//this prevents problems when applying options on app start
......
......@@ -55,6 +55,7 @@
#include <stdlib.h>
#include <iostream>
#include <ACG/Scenegraph/DrawModes.hh>
#include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.hh>
#include <QDir>
#include <QCoreApplication>
......@@ -150,9 +151,6 @@ static bool synchronization_ = false;
/// Store the defaultDrawMode_ mode
static std::vector<ACG::SceneGraph::DrawModes::DrawMode> defaultDrawMode_ = std::vector<ACG::SceneGraph::DrawModes::DrawMode> (4, ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED);
/// Store the defaultViewingDirection_ mode
static std::vector<int> defaultViewingDirection_ = std::vector<int> (4, 0);
/// Store the defaultViewer layout
static int defaultViewerLayout_ = 0;
......@@ -513,13 +511,56 @@ bool defaultPerspectiveProjectionMode(int _viewer){
}
void defaultViewingDirection( int _mode, int _viewer){
defaultViewingDirection_[_viewer] = _mode;
QString entry = "Viewer" + QString::number(_viewer) + "/defaultViewingDirection";
OpenFlipperSettings().setValue(entry,_mode);
}
int defaultViewingDirection(int _viewer){
return defaultViewingDirection_[_viewer];
QString entry = "Viewer" + QString::number(_viewer) + "/defaultViewingDirection";
switch (_viewer) {
case 0:
return OpenFlipperSettings().value(entry,PluginFunctions::VIEW_FREE).toInt();
case 1:
return OpenFlipperSettings().value(entry,PluginFunctions::VIEW_FRONT).toInt();
case 2:
return OpenFlipperSettings().value(entry,PluginFunctions::VIEW_RIGHT).toInt();
case 3:
return OpenFlipperSettings().value(entry,PluginFunctions::VIEW_TOP).toInt();
default:
std::cerr << "defaultViewingDirection: illegal viewer id: " << _viewer << std::endl;
}
return PluginFunctions::VIEW_FREE;
}
void defaultLockRotation( bool _lock, int _viewer ) {
QString entry = "Viewer" + QString::number(_viewer) + "/lockRotation";
OpenFlipperSettings().setValue(entry,_lock);
}
bool defaultLockRotation( int _viewer ) {
QString entry = "Viewer" + QString::number(_viewer) + "/lockRotation";
switch (_viewer) {
case 0:
return OpenFlipperSettings().value(entry,false).toBool();
case 1:
return OpenFlipperSettings().value(entry,true).toBool();
case 2:
return OpenFlipperSettings().value(entry,true).toBool();
case 3:
return OpenFlipperSettings().value(entry,true).toBool();
default:
std::cerr << "defaultViewingDirection: illegal viewer id: " << _viewer << std::endl;
}
return false;
}
void defaultViewerLayout( int _layout ){
defaultViewerLayout_ = _layout;
}
......
......@@ -105,6 +105,8 @@
*
* <b>User Interface Settings for each of the viewers</b>\n
* * Viewer<viewer>/perspectiveProjection Orthogonal = false,Perspective = true (bool)\n
* * Viewer<viewer>/defaultViewingDirection 0:VIEW_FREE; 1:VIEW_TOP; 2:VIEW_BOTTOM; 3:VIEW_LEFT; 4:VIEW_RIGHT; 5:VIEW_FRONT; 6:VIEW_BACK (int)\n
* * Viewer<viewer>/lockRotation true: locked, false: unlocked (bool)\n
*
*
* <b>File Handling</b>\n
......@@ -479,6 +481,14 @@ QString helpDirStr();
DLLEXPORT
int defaultViewingDirection( int _viewer );
/// Store lockrotation setting
DLLEXPORT
void defaultLockRotation( bool _mode, int _viewer );
/// get lockrotation setting
DLLEXPORT
bool defaultLockRotation( int _viewer );
/// Store defaultViewerLayout setting
DLLEXPORT
void defaultViewerLayout( int _layout );
......
......@@ -77,6 +77,7 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
connect( availDrawModes, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(viewerSettingsChanged(QListWidgetItem*)) );
connect( projectionBox, SIGNAL(currentIndexChanged(int)), this, SLOT(viewerSettingsChanged(int)));
connect( directionBox, SIGNAL(currentIndexChanged(int)), this, SLOT(viewerSettingsChanged(int)));
connect( lockRotationBox, SIGNAL(stateChanged(int)), this, SLOT(viewerSettingsChanged(int)));
// Switch stacked widget of stereo settings
connect(stereoOpengl, SIGNAL(clicked()),
......@@ -119,11 +120,13 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
mode = mode<<1;
}
defaultProjectionMode_.resize(4);
defaultViewingDirections_.resize(4);
defaultRotationLocks_.resize(4);
for ( int i=0; i < PluginFunctions::viewers(); i++ ){
viewerList->addItem("Viewer " + QString::number(i+1) );
defaultDrawModes_.push_back( ACG::SceneGraph::DrawModes::DEFAULT );
defaultProjectionMode_.push_back( true );
defaultViewingDirections_.push_back( 0 );
}
pluginOptionsLayout = new QVBoxLayout;
......@@ -184,11 +187,17 @@ void OptionsWidget::viewerSettingsChanged(int /*_index*/){
for (int i=0; i < availDrawModes->count(); i++)
if (availDrawModes->item(i)->checkState() == Qt::Checked)
mode.push_back( availDrawModes->item(i)->text() );
mode.push_back( availDrawModes->item(i)->text() );
defaultDrawModes_[ viewerList->currentRow() ] = descriptionsToDrawMode(mode);
defaultProjectionMode_[ viewerList->currentRow() ] = projectionBox->currentIndex() ;
defaultViewingDirections_[ viewerList->currentRow() ] = directionBox->currentIndex();
defaultRotationLocks_[ viewerList->currentRow() ] = lockRotationBox->isChecked();
if ( lockRotationBox->isChecked() )
std::cerr << "locked" << std::endl;
else
std::cerr << "unlocked" << std::endl;
}
};
......@@ -242,6 +251,8 @@ void OptionsWidget::updateViewerSettings(int _row){
directionBox->setCurrentIndex( defaultViewingDirections_[_row] );
lockRotationBox->setChecked( defaultRotationLocks_[_row] );
updatingViewerSettings_ = false;
}
......@@ -405,6 +416,7 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
defaultDrawModes_[i] = OpenFlipper::Options::defaultDrawMode(i);
defaultProjectionMode_[i] = OpenFlipper::Options::defaultPerspectiveProjectionMode(i);
defaultViewingDirections_[i] = OpenFlipper::Options::defaultViewingDirection(i);
defaultRotationLocks_[i] = OpenFlipper::Options::defaultLockRotation(i);
}
updateViewerSettings(0);
......@@ -690,6 +702,7 @@ void OptionsWidget::slotApply() {
OpenFlipper::Options::defaultDrawMode( defaultDrawModes_[i], i );
OpenFlipper::Options::defaultPerspectiveProjectionMode( defaultProjectionMode_[i], i );
OpenFlipper::Options::defaultViewingDirection( defaultViewingDirections_[i], i );
OpenFlipper::Options::defaultLockRotation( defaultRotationLocks_[i], i );
}
OpenFlipper::Options::defaultViewerLayout( viewerLayout->currentIndex() );
......
......@@ -175,7 +175,8 @@ private:
// remember changes to viewer properties
std::vector< ACG::SceneGraph::DrawModes::DrawMode > defaultDrawModes_;
std::vector< bool > defaultProjectionMode_;
std::vector< int > defaultViewingDirections_;
std::vector< int > defaultViewingDirections_;
std::vector< bool > defaultRotationLocks_;
bool updatingViewerSettings_;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>825</width>
<height>964</height>
<height>926</height>
</rect>
</property>
<property name="windowTitle">
......@@ -23,7 +23,7 @@
<string/>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<property name="usesScrollButtons">
<bool>true</bool>
......@@ -639,7 +639,7 @@
<property name="title">
<string>Viewer Specific Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0" rowspan="2">
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
......@@ -713,8 +713,8 @@ You can select multiple modes at the same time.</string>
</layout>
</item>
<item row="0" column="3">
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="label_15">
......@@ -739,7 +739,7 @@ You can select multiple modes at the same time.</string>
</item>
</layout>
</item>
<item>
<item row="1" column="0">
<layout class="QFormLayout" name="formLayout_3">
<item row="1" column="0">
<widget class="QLabel" name="label_16">
......@@ -789,6 +789,22 @@ You can select multiple modes at the same time.</string>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="lockRotationBox">
<property name="toolTip">
<string>Lock the rotation in the viewer</string>
</property>
<property name="statusTip">
<string>Lock the rotation in the viewer</string>
</property>
<property name="whatsThis">
<string>If this box is checked, the user can not rotate the scene</string>
</property>
<property name="text">
<string>Lock Rotation</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="3">
......
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