Commit 2b582282 authored by Dirk Wilden's avatar Dirk Wilden

set fixed view directions via context menu or options

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6694 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b8bb0db3
......@@ -249,6 +249,49 @@ void setBackColor( OpenMesh::Vec4f _color) {
PluginFunctions::viewerProperties(i).backgroundColor(_color);
}
void setFixedView(int _mode, int _viewer ) {
if ( (_viewer != ACTIVE_VIEWER ) && ( ( _viewer < 0 ) || _viewer >= (int)examiner_widgets_.size()) ){
std::cerr << "Unable to set fixed view. Wrong viewer id (" << _viewer << ")" << std::endl;
return;
}
switch ( _mode ){
case VIEW_TOP : //TOP
PluginFunctions::viewingDirection( ACG::Vec3d(0.0, -1.0, 0.0), ACG::Vec3d(0.0, 0.0, -1.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
case VIEW_BOTTOM : //BOTTOM
PluginFunctions::viewingDirection( ACG::Vec3d(0.0, 1.0, 0.0), ACG::Vec3d(0.0, 0.0, -1.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
case VIEW_LEFT : //LEFT
PluginFunctions::viewingDirection( ACG::Vec3d(1.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
case VIEW_RIGHT : //RIGHT
PluginFunctions::viewingDirection( ACG::Vec3d(-1.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
case VIEW_FRONT : //FRONT
PluginFunctions::viewingDirection( ACG::Vec3d(0.0, 0.0, -1.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
case VIEW_BACK : //BACK
PluginFunctions::viewingDirection( ACG::Vec3d(0.0, 0.0, 1.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
PluginFunctions::allowRotation(false, _viewer);
break;
default : //Free View
PluginFunctions::allowRotation(true, _viewer);
break;
}
if ( _viewer == ACTIVE_VIEWER )
viewerProperties(activeExaminer()).currentViewingDirection( _mode );
else
viewerProperties( _viewer ).currentViewingDirection( _mode );
}
QPoint mapToGlobal(const QPoint _point ) {
return examiner_widgets_[activeExaminer_]->glMapToGlobal(_point);
}
......@@ -413,8 +456,27 @@ void orthographicProjection( int _viewer ) {
std::cerr << "Requested illegal viewer for orthographicProjection()!!" << std::endl;
}
void allowRotation(bool _mode) {
examiner_widget_->allowRotation(_mode);
void allowRotation(bool _mode, int _viewer ) {
if ( _viewer == ACTIVE_VIEWER ) {
examiner_widgets_[activeExaminer_]->allowRotation(_mode);
} else if ( _viewer == ALL_VIEWERS )
for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
examiner_widgets_[i]->allowRotation(_mode);
else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
examiner_widgets_[_viewer]->allowRotation(_mode);
else
std::cerr << "Requested illegal viewer for allowRotation!!" << std::endl;
}
bool allowRotation( int _viewer ) {
if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
return examiner_widgets_[_viewer]->allowRotation();
else {
std::cerr << "Requested illegal viewer for isRotationAllowed!!" << std::endl;
return false;
}
}
void setMainGLContext() {
......@@ -563,6 +625,21 @@ ACG::Vec3d viewingDirection(int _viewer) {
return viewerProperties().glState().viewing_direction();
}
bool isProjectionOrthographic( int _viewer ) {
if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() ){
if ( examiner_widgets_[_viewer]->projectionMode() == 0) //ORTHOGRAPHIC_PROJECTION
return true;
else
return false;
} else
std::cerr << "Requested illegal viewer for isProjectionOrthographic!!" << std::endl;
return false;
}
ACG::Vec3d eyePos(int _viewer) {
if ( _viewer == ACTIVE_VIEWER ) {
return viewerProperties(activeExaminer_).glState().eye();
......
......@@ -60,6 +60,14 @@ namespace PluginFunctions {
const int ALL_VIEWERS = -2;
const int ACTIVE_VIEWER = -1;
const int VIEW_FREE = 0;
const int VIEW_TOP = 1;
const int VIEW_BOTTOM = 2;
const int VIEW_LEFT = 3;
const int VIEW_RIGHT = 4;
const int VIEW_FRONT = 5;
const int VIEW_BACK = 6;
//=======================================
// Get/set status of viewers
/** @name Viewer Status and properties
......@@ -86,9 +94,23 @@ Viewer::ViewerProperties& viewerProperties(int _id = -1);
/** Lock scene rotation via mouse
*
* @param _mode allow or disallow rotation
* @param _viewer Id of the viewer to use.
* ALL_VIEWERS will set all viewers (Default)
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
void allowRotation(bool _mode);
void allowRotation(bool _mode, int _viewer = ACTIVE_VIEWER);
/** is scene rotation locked
*
* @param _viewer Id of the viewer to use.
* ALL_VIEWERS will set all viewers (Default)
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
bool allowRotation(int _viewer = ACTIVE_VIEWER);
/** \brief Set current GL Context to main context
*/
......@@ -203,6 +225,15 @@ void viewAll(int _viewer = ALL_VIEWERS);
DLLEXPORT
ACG::Vec3d viewingDirection(int _viewer = ALL_VIEWERS);
/** \brief Check if the projection is orthographic
* @param _viewer Id of the viewer to use.
* ALL_VIEWERS will set all viewers (Default)
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
bool isProjectionOrthographic( int _viewer = ACTIVE_VIEWER );
/** \brief Get the current viewer position
*
* @param _viewer Id of the viewer to use.
......@@ -268,6 +299,18 @@ unsigned int drawMode( int _viewer = ACTIVE_VIEWER );
DLLEXPORT
void setBackColor( OpenMesh::Vec4f _color);
/** \brief Set a fixed View for a viewer
*
*
* @param _mode id for the mode
* @param _viewer Id of the viewer to use.
* ACTIVE_VIEWER active viewer
* 0..3 Choose viewer explicitly
*/
DLLEXPORT
void setFixedView(int _mode, int _viewer = ACTIVE_VIEWER );
/** @} */
......
......@@ -236,11 +236,22 @@ void Core::readApplicationOptions(INIFile& _ini) {
OpenFlipper::Options::defaultToolboxMode(toolboxMode);
//============================================================================
// Load the drawmodes
// Load the viewer settings
//============================================================================
std::vector< QString > draw_modes;
if( _ini.get_entry(draw_modes, "Options", "StandardDrawModes") )
OpenFlipper::Options::standardDrawMode( ListToDrawMode(draw_modes) );
int mode;
for (int i=0; i < 4/*PluginFunctions::viewers()*/; i++ ){
if( _ini.get_entry(draw_modes, "Options", "DefaultDrawModes" + QString::number(i) ) )
OpenFlipper::Options::defaultDrawMode( ListToDrawMode(draw_modes), i );
if( _ini.get_entry(mode, "Options", "DefaultProjectionMode" + QString::number(i) ) )
OpenFlipper::Options::defaultProjectionMode( mode, i );
if( _ini.get_entry(mode, "Options", "DefaultViewingDirection" + QString::number(i) ) )
OpenFlipper::Options::defaultViewingDirection( mode, i );
}
//============================================================================
// Load logFile status
......@@ -547,11 +558,20 @@ void Core::writeApplicationOptions(INIFile& _ini) {
(uint)PluginFunctions::viewerProperties(i).backgroundColorRgb() );
}
//============================================================================
// Save the current draw modes
// Save the current viewer properties
//============================================================================
std::vector< QString > draw_modes;
draw_modes = drawModeToList( OpenFlipper::Options::standardDrawMode() );
_ini.add_entry("Options","StandardDrawModes",draw_modes);
int mode;
for (int i=0; i < PluginFunctions::viewers(); i++ ){
draw_modes = drawModeToList( OpenFlipper::Options::defaultDrawMode(i) );
_ini.add_entry("Options","DefaultDrawModes" + QString::number(i), draw_modes);
_ini.add_entry("Options","DefaultProjectionMode" + QString::number(i), OpenFlipper::Options::defaultProjectionMode(i) );
_ini.add_entry("Options","DefaultViewingDirection" + QString::number(i), OpenFlipper::Options::defaultViewingDirection(i) );
}
_ini.add_entry("Options","LoggerState", OpenFlipper::Options::loggerState() );
_ini.add_entry("Options","HideToolbox", OpenFlipper::Options::hideToolbox() );
......@@ -679,7 +699,7 @@ void Core::openIniFile( QString _filename,
if ( OpenFlipper::Options::gui() ){
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
PluginFunctions::viewerProperties(i).drawMode( OpenFlipper::Options::standardDrawMode() );
PluginFunctions::viewerProperties(i).drawMode( OpenFlipper::Options::defaultDrawMode(i) );
coreWidget_->examiner_widgets_[i]->viewAll();
}
......
......@@ -318,12 +318,20 @@ void Core::slotObjectOpened ( int _id ) {
object->setBaseColor( colorV );
// ================================================================================
// Set standard draw mode if this is the first opened 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::standardDrawMode() );
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ){
PluginFunctions::viewerProperties(i).drawMode( OpenFlipper::Options::defaultDrawMode(i) );
if ( OpenFlipper::Options::defaultProjectionMode(i) == 0 )
PluginFunctions::orthographicProjection(i);
else
PluginFunctions::perspectiveProjection(i);
PluginFunctions::setFixedView(OpenFlipper::Options::defaultViewingDirection(i), i );
}
// ================================================================================
// Recompute bounding box and scenegraph info
......
......@@ -89,6 +89,18 @@ void Core::applyOptions(){
target = ACG::SceneGraph::PICK_ANYTHING;
}
//set viewer properties
for (int i=0; i < PluginFunctions::viewers(); i++){
PluginFunctions::setDrawMode( OpenFlipper::Options::defaultDrawMode(i), i );
PluginFunctions::setFixedView(OpenFlipper::Options::defaultViewingDirection(i), i );
if ( OpenFlipper::Options::defaultProjectionMode(i) == 0 )
PluginFunctions::orthographicProjection(i);
else
PluginFunctions::perspectiveProjection(i);
}
//set defaultBackgroundColor
QColor c = OpenFlipper::Options::defaultBackgroundColor() ;
......
......@@ -119,8 +119,8 @@ static float eyeDistance_ = 0.07f;
static float focalDistance_ = 0.5;
/// vectroy containing left/right color matrices for custom anaglyph mode
std::vector<float> anaglyphLeftEyeColors_ = std::vector<float> (9, 0.0);
std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0);
static std::vector<float> anaglyphLeftEyeColors_ = std::vector<float> (9, 0.0);
static std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0);
/// Store the synchronization mode
static bool synchronization_ = false;
......@@ -140,8 +140,14 @@ static bool showWheelsAtStartup_ = false;
/// Store the maxFrameRate_ mode
static int maxFrameRate_ = 35;
/// Store the standardDrawMode_ mode
static uint standardDrawMode_ = ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED;
/// Store the defaultDrawMode_ mode
static std::vector<uint> defaultDrawMode_ = std::vector<uint> (4, ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED);
/// Store the defaultProjectionMode_ mode
static std::vector<int> defaultProjectionMode_ = std::vector<int> (4, 0);
/// Store the defaultViewingDirection_ mode
static std::vector<int> defaultViewingDirection_ = std::vector<int> (4, 0);
/// Store the disableRedraw_ mode
static int redrawDisabled_ = 0;
......@@ -629,12 +635,28 @@ int maxFrameRate(){
return maxFrameRate_;
}
void standardDrawMode( uint _mode ){
standardDrawMode_ = _mode;
void defaultDrawMode( uint _mode, int _viewer){
defaultDrawMode_[_viewer] = _mode;
}
uint defaultDrawMode(int _viewer){
return defaultDrawMode_[_viewer];
}
void defaultProjectionMode( int _mode, int _viewer){
defaultProjectionMode_[_viewer] = _mode;
}
int defaultProjectionMode(int _viewer){
return defaultProjectionMode_[_viewer];
}
void defaultViewingDirection( int _mode, int _viewer){
defaultViewingDirection_[_viewer] = _mode;
}
uint standardDrawMode(){
return standardDrawMode_;
int defaultViewingDirection(int _viewer){
return defaultViewingDirection_[_viewer];
}
void redrawDisabled( bool disable ){
......
......@@ -500,13 +500,29 @@ bool dataDir(QString _dir);
DLLEXPORT
int maxFrameRate( );
/// Store standardDrawMode setting
/// Store defaultDrawMode setting
DLLEXPORT
void standardDrawMode( uint _mode );
void defaultDrawMode( uint _mode, int _viewer );
/// get standardDrawMode setting
/// get defaultDrawMode setting
DLLEXPORT
uint standardDrawMode( );
uint defaultDrawMode( int _viewer );
/// Store defaultProjectionMode setting
DLLEXPORT
void defaultProjectionMode( int _mode, int _viewer );
/// get defaultProjectionMode setting
DLLEXPORT
int defaultProjectionMode( int _viewer );
/// Store defaultViewingDirection setting
DLLEXPORT
void defaultViewingDirection( int _mode, int _viewer );
/// get defaultViewingDirection setting
DLLEXPORT
int defaultViewingDirection( int _viewer );
/// Store disableRedraw setting
DLLEXPORT
......
......@@ -99,5 +99,13 @@ namespace Viewer {
emit setActionMode(_am);
}
int ViewerProperties::currentViewingDirection(){
return currentViewingDirection_;
}
void ViewerProperties::currentViewingDirection(int _dir){
currentViewingDirection_ = _dir;
}
}
......@@ -352,6 +352,15 @@ namespace Viewer {
private:
ViewObjectMarker *objectMarker_;
//===========================================================================
public:
int currentViewingDirection();
void currentViewingDirection(int _dir);
private:
int currentViewingDirection_;
//===========================================================================
......
......@@ -46,6 +46,7 @@
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include "../../common/GlobalOptions.hh"
//== IMPLEMENTATION ==========================================================
......@@ -176,6 +177,78 @@ void CoreWidget::updatePopupMenuCoordsysNode(QMenu* _menu , const int /*_part*/
multisampling->setChecked( PluginFunctions::viewerProperties().multisampling() );
connect(multisampling, SIGNAL(triggered(bool)), this , SLOT( slotLocalChangeMultisampling(bool) ) );
//============================================================================================================
// Viewing Direction Menu
//============================================================================================================
QMenu* viewingDirectionMenu = new QMenu( tr("Viewing Direction"), _menu);
// viewingDirectionMenu->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"renderingOptions.png"));
_menu->addMenu(viewingDirectionMenu);
QActionGroup* dirGroup = new QActionGroup(this);
QAction* viewAction;
// freeView
viewAction = new QAction( tr("Free View"), viewingDirectionMenu );
// viewAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"orthogonal.png") );
viewAction->setCheckable( true );
viewAction->setData( PluginFunctions::VIEW_FREE );
viewAction->setChecked( PluginFunctions::viewerProperties().currentViewingDirection() == PluginFunctions::VIEW_FREE );
viewingDirectionMenu->addAction( viewAction );
dirGroup->addAction(viewAction);
viewingDirectionMenu->addSeparator();
// TOP
viewAction = new QAction( tr("Top View"), viewingDirectionMenu );
// viewAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"orthogonal.png") );
viewAction->setCheckable( true );
viewAction->setData( PluginFunctions::VIEW_TOP );
viewAction->setChecked( PluginFunctions::viewerProperties().currentViewingDirection() == PluginFunctions::VIEW_TOP );
viewingDirectionMenu->addAction( viewAction );
dirGroup->addAction(viewAction);
// BOTTOM
viewAction = new QAction( tr("Bottom View"), viewingDirectionMenu );
// viewAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"orthogonal.png") );
viewAction->setCheckable( true );
viewAction->setData( PluginFunctions::VIEW_BOTTOM );
viewAction->setChecked( PluginFunctions::viewerProperties().currentViewingDirection() == PluginFunctions::VIEW_BOTTOM );
viewingDirectionMenu->addAction( viewAction );
dirGroup->addAction(viewAction);
// LEFT
viewAction = new QAction( tr("Left View"), viewingDirectionMenu );
// viewAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"orthogonal.png") );
viewAction->setCheckable( true );
viewAction->setData( PluginFunctions::VIEW_LEFT );
viewAction->setChecked( PluginFunctions::viewerProperties().currentViewingDirection() == PluginFunctions::VIEW_LEFT );
viewingDirectionMenu->addAction( viewAction );
dirGroup->addAction(viewAction);
// RIGHT
viewAction = new QAction( tr("Right View"), viewingDirectionMenu );
// viewAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"orthogonal.png") );
viewAction->setCheckable( true );
viewAction->setData( PluginFunctions::VIEW_RIGHT );
viewAction->setChecked( PluginFunctions::viewerProperties().currentViewingDirection() == PluginFunctions::VIEW_RIGHT );
viewingDirectionMenu->addAction( viewAction );
dirGroup->addAction(viewAction);
// FRONT
viewAction = new QAction( tr("Front View"), viewingDirectionMenu );
// viewAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"orthogonal.png") );
viewAction->setCheckable( true );
viewAction->setData( PluginFunctions::VIEW_FRONT );
viewAction->setChecked( PluginFunctions::viewerProperties().currentViewingDirection() == PluginFunctions::VIEW_FRONT );
viewingDirectionMenu->addAction( viewAction );
dirGroup->addAction(viewAction);
// BACK
viewAction = new QAction( tr("Back View"), viewingDirectionMenu );
// viewAction->setIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"orthogonal.png") );
viewAction->setCheckable( true );
viewAction->setData( PluginFunctions::VIEW_BACK );
viewAction->setChecked( PluginFunctions::viewerProperties().currentViewingDirection() == PluginFunctions::VIEW_BACK );
viewingDirectionMenu->addAction( viewAction );
dirGroup->addAction(viewAction);
connect( dirGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotSetViewingDirection(QAction*) ) );
//====================================================================================================
// Other Toplevel Action
//====================================================================================================
......
......@@ -741,7 +741,13 @@ CoreWidget::updateRecent()
QVector< OpenFlipper::Options::RecentFile > recentFiles = OpenFlipper::Options::recentFiles();
for (int i = 0 ; i < recentFiles.size() ; ++i ) {
QString path = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
path += typeIcon( recentFiles[i].type );
QFileInfo fi(recentFiles[i].filename);
if (fi.suffix() == "ini")
path += "Settings-Icon.png";
else
path += typeIcon( recentFiles[i].type );
recentFilesMenu_->addAction(QIcon(path), recentFiles[i].filename);
}
......
......@@ -885,6 +885,9 @@ public:
void slotGlobalOrthographicProjection();
/// Change the Viewing direction from context-menu
void slotSetViewingDirection(QAction* _action);
/// Set the animation Mode for all viewers
void slotGlobalChangeAnimation(bool _animation);
......
......@@ -582,5 +582,9 @@ if (_visible)
}
void CoreWidget::slotSetViewingDirection(QAction* _action) {
PluginFunctions::setFixedView( _action->data().toInt() );
}
//=============================================================================
......@@ -1727,7 +1727,7 @@ glViewer::viewMouseEvent(QMouseEvent* _event)
}
// move in x,y direction
else if (_event->buttons() & Qt::MidButton)
else if ( (_event->buttons() & Qt::MidButton) || (!allowRotation_ && (_event->buttons() & Qt::LeftButton)))
{
value_x = scene_radius_ * ((newPoint2D.x() - lastPoint2D_.x())) * 2.0 / (double) glWidth();
value_y = scene_radius_ * ((newPoint2D.y() - lastPoint2D_.y())) * 2.0 / (double) glHeight();
......
......@@ -769,7 +769,7 @@ private:
/// Lock scene rotation
void allowRotation( bool _mode ) { allowRotation_ = _mode; };
bool allowRotation() { return allowRotation_; };
private slots:
......
......@@ -67,6 +67,7 @@ bool glViewer::pick( ACG::SceneGraph::PickTarget _pickTarget,
// QTime time;
// time.start ();
int rv = pickColor (_pickTarget, _mousePos, _nodeIdx, _targetIdx, _hitPointPtr);
std::cerr << "ColorPicking: " << rv << std::endl;
// printf ("ColorPicking took %d msec\n",time.restart ());
// rv = -1;
// node = _nodeIdx;
......
......@@ -112,7 +112,7 @@ void SimpleViewer::initialize (const QGLFormat & _format, QGLWidget *_shareWidge
mainWidget_->sceneGraph (PluginFunctions::getSceneGraphRootNode (), true);
props_.drawMode (OpenFlipper::Options::standardDrawMode());
props_.drawMode (OpenFlipper::Options::defaultDrawMode(0));
}
void SimpleViewer::setActionMode(const Viewer::ActionMode _am)
......
......@@ -38,8 +38,10 @@
#include <ACG/Scenegraph/DrawModes.hh>
#include <OpenFlipper/ACGHelper/DrawModeConverter.hh>
#include <OpenFlipper/INIFile/INIFile.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <QColorDialog>
#include <QMessageBox>
OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, InverseKeyMap& _invKeys, QWidget *parent)
: QWidget(parent),
......@@ -56,7 +58,14 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
connect(checkUpdateButton,SIGNAL(clicked()),this,SLOT(slotCheckUpdates()));
connect(updateButton,SIGNAL(clicked()),this,SLOT(slotGetUpdates()));
updateButton->setEnabled(false);
// Viewer Settings
connect( restrictFPS, SIGNAL(toggled(bool)), FPS, SLOT(setEnabled(bool)) );
connect( viewerList, SIGNAL(currentRowChanged(int)), this, SLOT(updateViewerSettings(int)) );
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)));
uint mode = 2;
for (uint i=1; i < 22; i++) {
std::vector< QString > dm = drawModeToDescriptions( mode );
......@@ -66,16 +75,19 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
// if (OpenFlipper::Options::standardDrawMode() )
// item->setCheckState(Qt::Checked);
// else
item->setCheckState(Qt::Unchecked);
item->setCheckState(Qt::Unchecked);
availDrawModes->addItem( item );
}
mode = mode<<1;
}
for ( int i=0; i < PluginFunctions::viewers(); i++ ){
viewerList->addItem("Viewer " + QString::number(i+1) );
defaultDrawModes_.push_back( 0 );
defaultProjectionMode_.push_back( 0 );
defaultViewingDirections_.push_back( 0 );
}
pluginOptionsLayout = new QVBoxLayout;
......@@ -121,6 +133,50 @@ void OptionsWidget::getBaseColor(){
baseColorButton->setIcon( QIcon(color) );
}
void OptionsWidget::viewerSettingsChanged(QListWidgetItem* /*_item*/){
viewerSettingsChanged(0);
};
void OptionsWidget::viewerSettingsChanged(int /*_index*/){
if ( !updatingViewerSettings_ ){
//viewer defaults
std::vector< QString > mode;
for (int i=0; i < availDrawModes->count(); i++)
if (availDrawModes->item(i)->checkState() == Qt::Checked)
mode.push_back( availDrawModes->item(i)->text() );
defaultDrawModes_[ viewerList->currentRow() ] = descriptionsToDrawMode(mode);
defaultProjectionMode_[ viewerList->currentRow() ] = projectionBox->currentIndex();
defaultViewingDirections_[ viewerList->currentRow() ] = directionBox->currentIndex();
}
};
void OptionsWidget::updateViewerSettings(int _row){
updatingViewerSettings_ = true;
for (int i = 0 ; i < availDrawModes->count(); ++i )
availDrawModes->item( i )->setCheckState(Qt::Unchecked) ;
//Check the drawModes from StandardDrawMode
std::vector< QString > dm = drawModeToDescriptions( defaultDrawModes_[_row] );
for (uint i=0; i < dm.size(); i++){
if ( !dm.empty() ) {
QList< QListWidgetItem* > found = availDrawModes->findItems(dm[i],Qt::MatchExactly);
for(int k=0; k < found.count(); k++)
(found[k])->setCheckState(Qt::Checked);
}
}
projectionBox->setCurrentIndex( defaultProjectionMode_[_row] );
directionBox->setCurrentIndex( defaultViewingDirections_[_row] );
updatingViewerSettings_ = false;
}
void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
//general
......@@ -136,23 +192,6 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
//paths
logFile->setText( OpenFlipper::Options::logFile() );
//viewer
wZoomFactor->setText( QString::number(OpenFlipper::Options::wheelZoomFactor(), 'f') );
wZoomFactorShift->setText( QString::number(OpenFlipper::Options::wheelZoomFactorShift(), 'f') );
wheelBox->setChecked( OpenFlipper::Options::showWheelsAtStartup() );
restrictFPS->setChecked( OpenFlipper::Options::restrictFrameRate() );
FPS->setValue( OpenFlipper::Options::maxFrameRate() );
QPixmap color(16,16);
color.fill( OpenFlipper::Options::defaultBackgroundColor() );
backgroundButton->setIcon( QIcon(color) );
color.fill( OpenFlipper::Options::defaultBaseColor() );
baseColorButton->setIcon( QIcon(color) );
randomBaseColor->setChecked( OpenFlipper::Options::randomBaseColor() );
//stereo
stereoOpengl->setChecked (OpenFlipper::Options::stereoMode() == OpenFlipper::Options::OpenGL);
stereoAnaglyph->setChecked (OpenFlipper::Options::stereoMode() == OpenFlipper::Options::AnaglyphRedCyan);
......@@ -214,20 +253,35 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
connect(shortcutButton, SIGNAL(keyChanged()), this, SLOT(updateShortcut()) );
connect(presetsButton, SIGNAL(clicked()), this, SLOT(restoreKeyPresets()) );
for (int i = 0 ; i < availDrawModes->count(); ++i )
availDrawModes->item( i )->setCheckState(Qt::Unchecked) ;
//Check the drawModes from StandardDrawMode
std::vector< QString > dm = drawModeToDescriptions( OpenFlipper::Options::standardDrawMode() );
//Init Viewer Settings
wZoomFactor->setText( QString::number(OpenFlipper::Options::wheelZoomFactor(), 'f') );
wZoomFactorShift->setText( QString::number(OpenFlipper::Options::wheelZoomFactorShift(), 'f') );
for (uint i=0; i < dm.size(); i++){
if ( !dm.empty() ) {
QList< QListWidgetItem* > found = availDrawModes-&g