- // Add buttons
- this->m_Buttons = new QDialogButtonBox(
- QDialogButtonBox::Ok | QDialogButtonBox::Cancel
- );
- this->connect(
- this->m_Buttons, SIGNAL( accepted( ) ), this, SLOT( accept( ) )
- );
- this->connect(
- this->m_Buttons, SIGNAL( rejected( ) ), this, SLOT( reject( ) )
- );
- this->m_ToolsLayout->addWidget( this->m_Buttons );
-
- return( true );
-}
-
-// -------------------------------------------------------------------------
-int cpPlugins::Interface::ParametersQtDialog::
-exec( )
-{
- int ret = this->QDialog::exec( );
- if( ret == 1 )
- this->updateParameters( );
- else
- this->updateView( );
- return( ret );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ParametersQtDialog::
-show( )
-{
- this->QDialog::show( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ParametersQtDialog::
-updateParameters( )
-{
- if( this->m_Parameters == NULL )
- return;
-
- // Put values
- auto& raw_params = this->m_Parameters->GetRawParameters( );
- for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt )
- {
- QString pName = pIt->first.c_str( );
- switch( pIt->second.first )
- {
- case Parameters::String:
- case Parameters::OpenFileName:
- case Parameters::SaveFileName:
- case Parameters::PathName:
- case Parameters::IntList:
- case Parameters::UintList:
- case Parameters::RealList:
- case Parameters::OpenFileNameList:
- {
- QLineEdit* v_string = this->findChild< QLineEdit* >( pName );
- if( v_string != NULL )
- pIt->second.second = v_string->text( ).toStdString( );
- }
- break;
- case Parameters::Bool:
- {
- QCheckBox* v_bool = this->findChild< QCheckBox* >( pName );
- if( v_bool != NULL )
- pIt->second.second = ( v_bool->isChecked( ) )? "1": "0";
- }
- break;
- case Parameters::Int:
- case Parameters::Uint:
- {
- QSpinBox* v_uint = this->findChild< QSpinBox* >( pName );
- if( v_uint )
- {
- std::stringstream str;
- str << v_uint->value( );
- pIt->second.second = str.str( );
-
- } // fi
- }
- break;
- case Parameters::Real:
- {
- QDoubleSpinBox* v_double = this->findChild< QDoubleSpinBox* >( pName );
- if( v_double )
- {
- std::stringstream str;
- str << v_double->value( );
- pIt->second.second = str.str( );
-
- } // fi
- }
- break;
- case Parameters::Index:
- break;
- case Parameters::Point:
- break;
- case Parameters::Vector:
- break;
- case Parameters::StringList:
- break;
- case Parameters::BoolList:
- break;
- case Parameters::IndexList:
- break;
- case Parameters::PointList:
- break;
- case Parameters::VectorList:
- break;
- case Parameters::SaveFileNameList:
- break;
- case Parameters::PathNameList:
- break;
- case Parameters::Choices:
- break;
- default:
- break;
- } // hctiws
-
- } // rof
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ParametersQtDialog::
-updateView( )
-{
- if( this->m_Parameters == NULL )
- return;
-
- // Put values
- auto& raw_params = this->m_Parameters->GetRawParameters( );
- for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt )
- {
- QString pName = pIt->first.c_str( );
- switch( pIt->second.first )
- {
- case Parameters::String:
- case Parameters::OpenFileName:
- case Parameters::SaveFileName:
- case Parameters::PathName:
- case Parameters::IntList:
- case Parameters::UintList:
- case Parameters::RealList:
- case Parameters::OpenFileNameList:
- {
- QLineEdit* v_string = this->findChild< QLineEdit* >( pName );
- if( v_string != NULL )
- v_string->setText( pIt->second.second.c_str( ) );
- }
- break;
- case Parameters::Bool:
- {
- QCheckBox* v_bool = this->findChild< QCheckBox* >( pName );
- if( v_bool != NULL )
- v_bool->setChecked( pIt->second.second == "1" );
- }
- break;
- case Parameters::Int:
- case Parameters::Uint:
- {
- QSpinBox* v_uint = this->findChild< QSpinBox* >( pName );
- if( v_uint )
- {
- std::istringstream tok_str( pIt->second.second );
- int v;
- tok_str >> v;
- v_uint->setValue( v );
-
- } // fi
- }
- break;
- case Parameters::Real:
- {
- QDoubleSpinBox* v_double = this->findChild< QDoubleSpinBox* >( pName );
- if( v_double )
- {
- std::istringstream tok_str( pIt->second.second );
- double v;
- tok_str >> v;
- v_double->setValue( v );
-
- } // fi
- }
- break;
- case Parameters::Index:
- break;
- case Parameters::Point:
- break;
- case Parameters::Vector:
- break;
- case Parameters::StringList:
- break;
- case Parameters::BoolList:
- break;
- case Parameters::IndexList:
- break;
- case Parameters::PointList:
- break;
- case Parameters::VectorList:
- break;
- case Parameters::SaveFileNameList:
- break;
- case Parameters::PathNameList:
- break;
- case Parameters::Choices:
- break;
- default:
- break;
- } // hctiws
-
- } // rof