Commit fd4e2463 authored by Mike Kremer's avatar Mike Kremer

Added option handling and new gui elements for stereo mode settings.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7570 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f9d965d3
......@@ -78,16 +78,16 @@ void Core::readApplicationOptions(INIFile& _ini) {
if ( _ini.section_exists("Options") ) {
// TODO: Load View Mode Toolbars and Context Menu Items
// load ViewModes
int viewModeCount;
if (_ini.get_entry(viewModeCount,"Options","ViewModeCount") )
for (int i=0; i < viewModeCount; i++){
QString entryToolbars;
QString entryToolboxes;
QString entryIcon;
QString keyToolbars = "ViewModeToolbars" + QString::number(i);
QString keyToolboxes = "ViewModeToolboxes" + QString::number(i);
QString keyIcon = "ViewModeIcon" + QString::number(i);
......@@ -99,10 +99,10 @@ void Core::readApplicationOptions(INIFile& _ini) {
QStringList toolBars = entryToolbars.split(";");
QStringList toolBoxes = entryToolboxes.split(";");
// Get Mode name ( prepended to all toolbox/toolbar lists
QString mode = toolBoxes.first();
// Remove leading Modes
toolBoxes.removeFirst();
toolBars.removeFirst();
......@@ -112,7 +112,7 @@ void Core::readApplicationOptions(INIFile& _ini) {
for (int i=0; i < viewModes_.size(); i++)
if (viewModes_[i]->name == mode)
found = true;
if (!found){
ViewMode* vm = new ViewMode();
vm->name = mode;
......@@ -196,6 +196,26 @@ void Core::readApplicationOptions(INIFile& _ini) {
if ( _ini.get_entry( val, "Options" , "FocalDistance") )
OpenFlipper::Options::focalDistance(val);
//============================================================================
// Load philips stereo mode settings
//============================================================================
int philipsContent = 0;
if ( _ini.get_entry( philipsContent, "Options" , "PhilipsContent") )
OpenFlipper::Options::stereoPhilipsContent(philipsContent);
int philipsFactor = 0;
if ( _ini.get_entry( philipsFactor, "Options" , "PhilipsFactor") )
OpenFlipper::Options::stereoPhilipsFactor(philipsFactor);
int philipsOffset = 0;
if ( _ini.get_entry( philipsOffset, "Options" , "PhilipsOffset") )
OpenFlipper::Options::stereoPhilipsOffset(philipsOffset);
int philipsSelect = 0;
if ( _ini.get_entry( philipsSelect, "Options" , "PhilipsSelect") )
OpenFlipper::Options::stereoPhilipsSelect(philipsSelect);
//============================================================================
// Load the custom anaglyph stereo mode color matrices
//============================================================================
......@@ -509,7 +529,7 @@ void Core::writeApplicationOptions(INIFile& _ini) {
QVector< QString > toolboxes;
QVector< QString > toolbars;
QVector< QString > icons;
if ( OpenFlipper::Options::gui() )
for (int i=0; i < coreWidget_->viewModes_.size(); i++)
if (coreWidget_->viewModes_[i]->custom){
......@@ -525,15 +545,15 @@ void Core::writeApplicationOptions(INIFile& _ini) {
//store name
QString entryToolbars = coreWidget_->viewModes_[i]->name;
//store widgets
for (int j=0; j < coreWidget_->viewModes_[i]->visibleToolbars.size(); j++)
entryToolbars += ";" + coreWidget_->viewModes_[i]->visibleToolbars[j];
toolbars.push_back(entryToolbars);
icons.push_back(coreWidget_->viewModes_[i]->icon);
}
//save viewmodes to ini
......@@ -671,7 +691,7 @@ void Core::writeApplicationOptions(INIFile& _ini) {
_ini.add_entry("Options","DefaultBackgroundColor", (uint)OpenFlipper::Options::defaultBackgroundColor().rgba () );
_ini.add_entry("Options","DefaultBaseColor", (uint)OpenFlipper::Options::defaultBaseColor().rgba () );
_ini.add_entry("Options","StereoMode",OpenFlipper::Options::stereoMode() );
_ini.add_entry("Options", "StereoMode",OpenFlipper::Options::stereoMode() );
_ini.add_entry("Options" , "EyeDistance", OpenFlipper::Options::eyeDistance());
_ini.add_entry("Options" , "FocalDistance", OpenFlipper::Options::focalDistance());
......@@ -681,6 +701,12 @@ void Core::writeApplicationOptions(INIFile& _ini) {
_ini.add_entry("Options", "StereoMousePick", OpenFlipper::Options::stereoMousePick() );
// Philips stereo mode
_ini.add_entry("Options" , "PhilipsContent", OpenFlipper::Options::stereoPhilipsContent());
_ini.add_entry("Options" , "PhilipsFactor", OpenFlipper::Options::stereoPhilipsFactor());
_ini.add_entry("Options" , "PhilipsOffset", OpenFlipper::Options::stereoPhilipsOffset());
_ini.add_entry("Options" , "PhilipsSelect", OpenFlipper::Options::stereoPhilipsSelect());
_ini.add_entry("Options", "GlMouse", OpenFlipper::Options::glMouse() );
}
......@@ -728,7 +754,7 @@ void Core::openIniFile( QString _filename,
for ( int i = 0 ; i < openFiles.size(); ++i ) {
QString sectionName = openFiles[i];
// Check if the string read is empty (e.g. colon at the end of the line ...)
// So skip trying to read files without a filename.
if ( sectionName.isEmpty() ) {
......@@ -741,7 +767,7 @@ void Core::openIniFile( QString _filename,
emit log(LOGERR,tr("Error parsing ini file. OpenFiles section %1 not found in File!").arg(sectionName));
continue;
}
// Get the path for the file which should be opened
QString path;
if ( !ini.get_entry( path, sectionName , "path" ) ) {
......@@ -751,13 +777,13 @@ void Core::openIniFile( QString _filename,
// Check if path is relative ( The path is considered to be relative if the first character is a ".")
if (path.startsWith( "." + OpenFlipper::Options::dirSeparator() )){
// check if _filename contains a path by testing if it contains a directory separator
if (_filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) != ""){
path.remove(0,1); // remove .
path = _filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) + path;
}
}
int tmpType;
......@@ -817,7 +843,7 @@ void Core::openIniFile( QString _filename,
// As the reading has been completed, tell plugins that we do not read an ini file anymore.
OpenFlipper::Options::loadingSettings(false);
// Reset scenegraph and reset trackball center
// Reset scenegraph and reset trackball center
// This will also recompute the bounding boxes as well as the near and far plane
resetScenegraph(true);
......
......@@ -140,7 +140,7 @@ static std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0);
static bool stereoMousePick_ = true;
/// philips stereo header content type
static int stereoPhilipsContentType_ = 3; // Game
static int stereoPhilipsContent_ = 3; // Game
/// philips stereo header factor
static int stereoPhilipsFactor_ = 64;
......@@ -654,13 +654,13 @@ bool stereoMousePick( ) {
/// Store philips stereo header content type
void stereoPhilipsContent( int _content )
{
stereoPhilipsContentType_ = _content;
stereoPhilipsContent_ = _content;
}
/// get philips stereo header content type
int stereoPhilipsContent( )
{
return stereoPhilipsContentType_;
return stereoPhilipsContent_;
}
/// Store philips stereo header factor
......
......@@ -354,13 +354,11 @@ void CoreWidget::stereoButtonContextMenu(const QPoint& _pos) {
stereoSettingsWidget_->offsetCounter->setNum(OpenFlipper::Options::stereoPhilipsOffset());
stereoSettingsWidget_->headerSelect->setCurrentIndex(OpenFlipper::Options::stereoPhilipsSelect());
// Default values are strange...
/*
std::cerr << "Content type: " << OpenFlipper::Options::stereoPhilipsContent() << std::endl;
std::cerr << "Factor: " << OpenFlipper::Options::stereoPhilipsFactor() << std::endl;
std::cerr << "Offset: " << OpenFlipper::Options::stereoPhilipsOffset() << std::endl;
std::cerr << "Select: " << OpenFlipper::Options::stereoPhilipsSelect() << std::endl;
*/
// // Default values are strange...
// std::cerr << "Content type: " << OpenFlipper::Options::stereoPhilipsContent() << std::endl;
// std::cerr << "Factor: " << OpenFlipper::Options::stereoPhilipsFactor() << std::endl;
// std::cerr << "Offset: " << OpenFlipper::Options::stereoPhilipsOffset() << std::endl;
// std::cerr << "Select: " << OpenFlipper::Options::stereoPhilipsSelect() << std::endl;
// Show right stacked widget
if (stereoSettingsWidget_->stereoPhilips->isChecked()) {
......@@ -394,21 +392,19 @@ void CoreWidget::slotApplyStereoSettings(int /*_tmpParam*/) {
stereoSettingsWidget_->stackedWidget->setCurrentIndex(0);
}
if(stereoSettingsWidget_->stackedWidget->currentIndex() == 0) {
OpenFlipper::Options::eyeDistance(stereoSettingsWidget_->eyeDistance->value());
OpenFlipper::Options::focalDistance(
(float)stereoSettingsWidget_->focalDistance->value() / 1000);
} else {
// Update labels that display the current values
stereoSettingsWidget_->factorCounter->setNum(stereoSettingsWidget_->headerFactor->value());
stereoSettingsWidget_->offsetCounter->setNum(stereoSettingsWidget_->headerOffsetCC->value());
// Set option entries
OpenFlipper::Options::stereoPhilipsContent(stereoSettingsWidget_->headerContentType->currentIndex());
OpenFlipper::Options::stereoPhilipsFactor(stereoSettingsWidget_->headerFactor->value());
OpenFlipper::Options::stereoPhilipsOffset(stereoSettingsWidget_->headerOffsetCC->value());
OpenFlipper::Options::stereoPhilipsSelect(stereoSettingsWidget_->headerSelect->currentIndex());
}
// Save everything
OpenFlipper::Options::eyeDistance(stereoSettingsWidget_->eyeDistance->value());
OpenFlipper::Options::focalDistance((float) stereoSettingsWidget_->focalDistance->value() / 1000);
// Update labels that display the current values
stereoSettingsWidget_->factorCounter->setNum(stereoSettingsWidget_->headerFactor->value());
stereoSettingsWidget_->offsetCounter->setNum(stereoSettingsWidget_->headerOffsetCC->value());
// Set option entries
OpenFlipper::Options::stereoPhilipsContent(stereoSettingsWidget_->headerContentType->currentIndex());
OpenFlipper::Options::stereoPhilipsFactor(stereoSettingsWidget_->headerFactor->value());
OpenFlipper::Options::stereoPhilipsOffset(stereoSettingsWidget_->headerOffsetCC->value());
OpenFlipper::Options::stereoPhilipsSelect(stereoSettingsWidget_->headerSelect->currentIndex());
// Update all views
for (unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i) {
......
......@@ -77,6 +77,16 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
connect( projectionBox, SIGNAL(currentIndexChanged(int)), this, SLOT(viewerSettingsChanged(int)));
connect( directionBox, SIGNAL(currentIndexChanged(int)), this, SLOT(viewerSettingsChanged(int)));
// Switch stacked widget of stereo settings
connect(stereoOpengl, SIGNAL(clicked()),
this, SLOT(switchStackedWidget()));
connect(stereoAnaglyph, SIGNAL(clicked()),
this, SLOT(switchStackedWidget()));
connect(stereoCustomAnaglyph, SIGNAL(clicked()),
this, SLOT(switchStackedWidget()));
connect(stereoPhilips, SIGNAL(clicked()),
this, SLOT(switchStackedWidget()));
uint mode = 2;
for (uint i=1; i < 22; i++) {
std::vector< QString > dm = drawModeToDescriptions( mode );
......@@ -164,6 +174,20 @@ void OptionsWidget::viewerSettingsChanged(int /*_index*/){
}
};
void OptionsWidget::switchStackedWidget() {
// Show right stacked widget of stereo settings
if (stereoCustomAnaglyph->isChecked()) {
stackedWidget->setCurrentIndex(0);
} else if (stereoAnaglyph->isChecked()) {
stackedWidget->setCurrentIndex(0);
} else if (stereoPhilips->isChecked()) {
stackedWidget->setCurrentIndex(1);
} else {
stackedWidget->setCurrentIndex(0);
}
}
void OptionsWidget::updateViewerSettings(int _row){
updatingViewerSettings_ = true;
......@@ -212,6 +236,14 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
eyeDistance->setValue (OpenFlipper::Options::eyeDistance());
focalDistance->setValue (OpenFlipper::Options::focalDistance() * 1000);
// Philips stereo mode part
headerContentType->setCurrentIndex(OpenFlipper::Options::stereoPhilipsContent());
headerFactor->setValue(OpenFlipper::Options::stereoPhilipsFactor());
headerOffsetCC->setValue(OpenFlipper::Options::stereoPhilipsOffset());
factorCounter->setNum(OpenFlipper::Options::stereoPhilipsFactor());
offsetCounter->setNum(OpenFlipper::Options::stereoPhilipsOffset());
headerSelect->setCurrentIndex(OpenFlipper::Options::stereoPhilipsSelect());
std::vector<float> mat = OpenFlipper::Options::anaglyphLeftEyeColorMatrix ();
lcm0->setValue (mat[0]);
lcm1->setValue (mat[1]);
......@@ -287,7 +319,7 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
baseColorButton->setIcon( QIcon(color) );
randomBaseColor->setChecked( OpenFlipper::Options::randomBaseColor() );
viewerList->setCurrentRow(0);
for ( int i=0; i < PluginFunctions::viewers(); i++ ){
......@@ -299,7 +331,7 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
updateViewerSettings(0);
viewerLayout->setCurrentIndex( OpenFlipper::Options::defaultViewerLayout() );
gridVisible->setChecked (OpenFlipper::Options::gridVisible());
if (OpenFlipper::Options::translation() == "en_US")
......@@ -503,7 +535,7 @@ void OptionsWidget::slotApply() {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::AnaglyphRedCyan);
else if (stereoPhilips->isChecked() )
OpenFlipper::Options::stereoMode(OpenFlipper::Options::Philips);
else
else
OpenFlipper::Options::stereoMode(OpenFlipper::Options::OpenGL);
OpenFlipper::Options::eyeDistance(eyeDistance->value ());
......@@ -511,6 +543,12 @@ void OptionsWidget::slotApply() {
OpenFlipper::Options::stereoMousePick(!noMousePick->isChecked ());
// Set option entries for philips stereo mode
OpenFlipper::Options::stereoPhilipsContent(headerContentType->currentIndex());
OpenFlipper::Options::stereoPhilipsFactor(headerFactor->value());
OpenFlipper::Options::stereoPhilipsOffset(headerOffsetCC->value());
OpenFlipper::Options::stereoPhilipsSelect(headerSelect->currentIndex());
std::vector<float> mat (9, 0);
mat[0] = lcm0->value ();
mat[1] = lcm1->value ();
......@@ -537,7 +575,7 @@ void OptionsWidget::slotApply() {
OpenFlipper::Options::anaglyphRightEyeColorMatrix (mat);
OpenFlipper::Options::glMouse(!nativeMouse->isChecked ());
// updates
OpenFlipper::Options::updateUrl( updateURL->text() );
OpenFlipper::Options::updateUsername( updateUser->text() );
......
......@@ -109,6 +109,9 @@ private slots:
void viewerSettingsChanged(QListWidgetItem* _item);
void viewerSettingsChanged(int _index);
/// Switch between the stacked widgets of the stereo settings
void switchStackedWidget();
protected:
void showEvent ( QShowEvent * event );
......
This diff is collapsed.
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