Commit a8d7afa7 authored by Mike Kremer's avatar Mike Kremer
Browse files

Added context menu to stereo mode button in toolbar.

TODO: Update the current viewports after having changed the settings.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7564 383ad7c9-94d9-4d36-a494-682f7c89f535
parent cad47166
......@@ -115,6 +115,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
snapshotCounter_(0),
stackMenu_(0),
helpWidget_(0),
stereoSettingsWidget_(0),
aboutWidget_(0),
optionsWidget_(0),
plugins_(_plugins),
......@@ -432,13 +433,17 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
stereoButton_->setMaximumSize( 32, 32 );
stereoButton_->setCheckable( true );
stereoButton_->setToolTip(tr( "Toggle stereo viewing"));
// We want a custom context menu
stereoButton_->setContextMenuPolicy(Qt::CustomContextMenu);
stereoButton_->setWhatsThis(tr(
"Toggle stereo mode<br><br>"
"Use this button to switch between stereo "
"and mono view. To use this feature you need "
"a stereo capable graphics card and a stereo "
"display/projection system."));
connect( stereoButton_,SIGNAL( clicked() ), this , SLOT( slotToggleStereoMode() ) );
connect( stereoButton_, SIGNAL( clicked() ), this , SLOT( slotToggleStereoMode() ) );
// Custom context menu
connect( stereoButton_, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(stereoButtonContextMenu(const QPoint &)));
viewerToolbar_->addWidget( stereoButton_ )->setText( tr("Stereo"));
}
......@@ -517,6 +522,13 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
// Create stereo settings widget
stereoSettingsWidget_ = new StereoSettingsWidget(this);
// Make it look like a dialog
stereoSettingsWidget_->setWindowFlags(Qt::Popup);
// Connect Ok button to local slot
connect(stereoSettingsWidget_->confirmButton, SIGNAL(pressed()),
this, SLOT(slotApplyStereoSettings()));
}
......
......@@ -89,6 +89,7 @@
#include <OpenFlipper/widgets/loggerWidget/loggerWidget.hh>
#include <OpenFlipper/widgets/optionsWidget/optionsWidget.hh>
#include <OpenFlipper/widgets/helpWidget/helpWidget.hh>
#include <OpenFlipper/widgets/stereoSettingsWidget/stereoSettingsWidget.hh>
#include <OpenFlipper/Core/PluginInfo.hh>
......@@ -800,6 +801,25 @@ public:
/** @} */
//===========================================================================
/** @name Stereo View Mode
* @{ */
//===========================================================================
public slots:
/// Creates custom context menu for stereo viewer settings
void stereoButtonContextMenu(const QPoint& _pos);
/// Is called if the user has changed stereo settings
void slotApplyStereoSettings();
private:
/// Widget to change stereo settings
StereoSettingsWidget* stereoSettingsWidget_;
/** @} */
//===========================================================================
/** @name About System
* @{ */
......
......@@ -335,3 +335,42 @@ void CoreWidget::slotChangeView(QString _mode, QStringList _toolboxWidgets, QStr
}
void CoreWidget::stereoButtonContextMenu(const QPoint& _pos) {
// Set values:
stereoSettingsWidget_->stereoOpengl->setChecked(OpenFlipper::Options::stereoMode() == OpenFlipper::Options::OpenGL);
stereoSettingsWidget_->stereoAnaglyph->setChecked(OpenFlipper::Options::stereoMode() == OpenFlipper::Options::AnaglyphRedCyan);
stereoSettingsWidget_->stereoCustomAnaglyph->setChecked(OpenFlipper::Options::stereoMode() == OpenFlipper::Options::AnaglyphCustom);
stereoSettingsWidget_->stereoPhilips->setChecked(OpenFlipper::Options::stereoMode() == OpenFlipper::Options::Philips);
stereoSettingsWidget_->eyeDistance->setValue(OpenFlipper::Options::eyeDistance());
stereoSettingsWidget_->focalDistance->setValue(OpenFlipper::Options::focalDistance() * 1000);
// Move widget to the position of the cursor
stereoSettingsWidget_->move(stereoButton_->mapToGlobal(_pos));
// Show widget
stereoSettingsWidget_->show();
}
void CoreWidget::slotApplyStereoSettings() {
// Hide widget
stereoSettingsWidget_->hide();
// Update values
if (stereoSettingsWidget_->stereoCustomAnaglyph->isChecked()) {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::AnaglyphCustom);
} else if (stereoSettingsWidget_->stereoAnaglyph->isChecked()) {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::AnaglyphRedCyan);
} else if (stereoSettingsWidget_->stereoPhilips->isChecked()) {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::Philips);
} else {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::OpenGL);
}
OpenFlipper::Options::eyeDistance(stereoSettingsWidget_->eyeDistance->value());
OpenFlipper::Options::focalDistance(
(float)stereoSettingsWidget_->focalDistance->value() / 1000);
// TODO: We should force an update of the viewports here
}
#include "stereoSettingsWidget.hh"
#include <OpenFlipper/common/GlobalOptions.hh>
StereoSettingsWidget::StereoSettingsWidget(QWidget* _parent) : QWidget(_parent) {
setupUi(this);
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 83 $ *
* $Author: kremer $ *
* $Date: 2009-02-27 17:31:45 +0100 (Fr, 27. Feb 2009) $ *
* *
\*===========================================================================*/
/*
* stereoSettingsWidget.hh
*
* Created on: Nov 9, 2009
* Author: kremer
*/
#include "ui_stereoSettingsWidget.hh"
#include <QtGui>
class StereoSettingsWidget : public QWidget, public Ui::StereoSettingsWidget
{
Q_OBJECT
public:
StereoSettingsWidget(QWidget *parent = 0);
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StereoSettingsWidget</class>
<widget class="QWidget" name="StereoSettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>496</width>
<height>304</height>
</rect>
</property>
<property name="windowTitle">
<string>Stereo Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Stereo Mode</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QRadioButton" name="stereoOpengl">
<property name="text">
<string>OpenGL stereo buffers</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="stereoAnaglyph">
<property name="text">
<string>Red/Cyan Anaglyph</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="stereoCustomAnaglyph">
<property name="text">
<string>Custom Anaglyph</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="stereoPhilips">
<property name="text">
<string>Philips Stereo Mode (For 3D autostereoskopic displays)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>View properties</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Eye distance:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Focal distance:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_20">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QDoubleSpinBox" name="eyeDistance">
<property name="decimals">
<number>4</number>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QLabel" name="label_13">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Near</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="focalDistance">
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="pageStep">
<number>100</number>
</property>
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_14">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Far</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="confirmButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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