#include #include #include #include #include #include #include #include #include #include #include #include // ------------------------------------------------------------------------- cpPlugins::QT::ParametersDialog:: ParametersDialog( QWidget* parent, Qt::WindowFlags f, bool manual ) : QDialog( parent, f ), m_ProcessObject( NULL ), m_WidgetsUpdated( false ), m_Manual( manual ) { if( !this->m_Manual ) { this->m_Title = new QLabel( this ); this->m_Title->setText( "Parameters dialog title" ); this->m_MainLayout = new QGridLayout( this ); this->m_ToolsLayout = new QVBoxLayout( ); this->m_ToolsLayout->addWidget( this->m_Title ); this->m_MainLayout->addLayout( this->m_ToolsLayout, 0, 0, 1, 1 ); } // fi this->connect( this, SIGNAL( accepted( ) ), this, SLOT( _dlg_Accepted( ) ) ); } // ------------------------------------------------------------------------- cpPlugins::QT::ParametersDialog:: ~ParametersDialog( ) { if( !this->m_Manual ) { delete this->m_Title; delete this->m_ToolsLayout; delete this->m_MainLayout; } // fi } // ------------------------------------------------------------------------- cpPlugins::Pipeline::ProcessObject* cpPlugins::QT::ParametersDialog:: getProcessObject( ) const { return( this->m_ProcessObject ); } // ------------------------------------------------------------------------- bool cpPlugins::QT::ParametersDialog:: setProcessObject( cpPlugins::Pipeline::ProcessObject* obj ) { if( this->m_ProcessObject != NULL || obj == NULL ) return( false ); this->m_ProcessObject = obj; this->m_WidgetsUpdated = false; this->_updateWidgets( ); this->updateView( ); return( true ); } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: updateParameters( ) { if( this->m_ProcessObject == NULL ) return; if( this->m_Manual ) return; // Check if an explicit re-execution button is needed QCheckBox* v_bool = this->findChild< QCheckBox* >( "___ExplicitExecution___" ); if( v_bool != NULL ) this->m_ProcessObject->SetExplicitExecution( v_bool->isChecked( ) ); // Put values auto parameters = this->m_ProcessObject->GetParameters( ); auto& raw_params = parameters->GetRawParameters( ); for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt ) { QString pName = pIt->first.c_str( ); switch( pIt->second.first ) { case cpPlugins::Pipeline::Parameters::String: case cpPlugins::Pipeline::Parameters::OpenFileName: case cpPlugins::Pipeline::Parameters::SaveFileName: case cpPlugins::Pipeline::Parameters::PathName: case cpPlugins::Pipeline::Parameters::IntList: case cpPlugins::Pipeline::Parameters::UintList: case cpPlugins::Pipeline::Parameters::RealList: case cpPlugins::Pipeline::Parameters::OpenFileNameList: { QLineEdit* v_string = this->findChild< QLineEdit* >( pName ); if( v_string != NULL ) pIt->second.second = v_string->text( ).toStdString( ); } break; case cpPlugins::Pipeline::Parameters::Bool: { QCheckBox* v_bool = this->findChild< QCheckBox* >( pName ); if( v_bool != NULL ) pIt->second.second = ( v_bool->isChecked( ) )? "1": "0"; } break; case cpPlugins::Pipeline::Parameters::Int: case cpPlugins::Pipeline::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 cpPlugins::Pipeline::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 cpPlugins::Pipeline::Parameters::StringList: break; case cpPlugins::Pipeline::Parameters::BoolList: break; case cpPlugins::Pipeline::Parameters::SaveFileNameList: break; case cpPlugins::Pipeline::Parameters::PathNameList: break; case cpPlugins::Pipeline::Parameters::Choices: { QComboBox* v_choices = this->findChild< QComboBox* >( pName ); if( v_choices != NULL ) { std::istringstream str_choices( pIt->second.second ); std::string real_choices; std::getline( str_choices, real_choices, '@' ); pIt->second.second = real_choices + "@" + v_choices->currentText( ).toStdString( ); } // fi } break; default: break; } // hctiws } // rof this->m_ProcessObject->Modified( ); } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: updateView( ) { if( this->m_ProcessObject == NULL ) return; if( this->m_Manual ) return; // Check if an explicit re-execution button is needed QCheckBox* v_bool = this->findChild< QCheckBox* >( "___ExplicitExecution___" ); if( v_bool != NULL ) v_bool->setChecked( this->m_ProcessObject->GetExplicitExecution( ) ); // Put values auto parameters = this->m_ProcessObject->GetParameters( ); auto& raw_params = parameters->GetRawParameters( ); for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt ) { QString pName = pIt->first.c_str( ); switch( pIt->second.first ) { case cpPlugins::Pipeline::Parameters::String: case cpPlugins::Pipeline::Parameters::OpenFileName: case cpPlugins::Pipeline::Parameters::SaveFileName: case cpPlugins::Pipeline::Parameters::PathName: case cpPlugins::Pipeline::Parameters::IntList: case cpPlugins::Pipeline::Parameters::UintList: case cpPlugins::Pipeline::Parameters::RealList: case cpPlugins::Pipeline::Parameters::OpenFileNameList: { QLineEdit* v_string = this->findChild< QLineEdit* >( pName ); if( v_string != NULL ) v_string->setText( pIt->second.second.c_str( ) ); } break; case cpPlugins::Pipeline::Parameters::Bool: { QCheckBox* v_bool = this->findChild< QCheckBox* >( pName ); if( v_bool != NULL ) v_bool->setChecked( pIt->second.second == "1" ); } break; case cpPlugins::Pipeline::Parameters::Int: case cpPlugins::Pipeline::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 cpPlugins::Pipeline::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 cpPlugins::Pipeline::Parameters::StringList: break; case cpPlugins::Pipeline::Parameters::BoolList: break; case cpPlugins::Pipeline::Parameters::SaveFileNameList: break; case cpPlugins::Pipeline::Parameters::PathNameList: break; case cpPlugins::Pipeline::Parameters::Choices: { QComboBox* v_choices = this->findChild< QComboBox* >( pName ); if( v_choices != NULL ) { std::istringstream str_choices( pIt->second.second ); std::string choices, real_choice; std::getline( str_choices, choices, '@' ); std::getline( str_choices, real_choice, '@' ); std::istringstream str( choices ); std::string token; int id = -1, cont = 0; while( std::getline( str, token, '#' ) ) { if( token == real_choice ) id = cont; cont++; } // elihw if( id > -1 ) v_choices->setCurrentIndex( id ); } // fi } break; default: break; } // hctiws } // rof } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: _addButtons( ) { if( this->m_Manual ) return; // 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 ); this->updateView( ); this->m_WidgetsUpdated = true; } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: _updateWidgets( ) { if( this->m_WidgetsUpdated || this->m_ProcessObject == NULL ) return; if( this->m_Manual ) return; // Set dialog title std::stringstream title; title << "Parameters for an object of class \"" << this->m_ProcessObject->GetClassName( ) << "\""; this->m_Title->setText( title.str( ).c_str( ) ); // Check if an explicit re-execution button is needed QCheckBox* v_bool = new QCheckBox( this ); v_bool->setObjectName( "___ExplicitExecution___" ); v_bool->setText( "Explicit re-execution" ); v_bool->setChecked( this->m_ProcessObject->GetExplicitExecution( ) ); QHBoxLayout* new_layout = new QHBoxLayout( ); new_layout->addWidget( v_bool ); this->m_ToolsLayout->addLayout( new_layout ); // Put values auto parameters = this->m_ProcessObject->GetParameters( ); auto& raw_params = parameters->GetRawParameters( ); for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt ) { QWidget* w_input = NULL; switch( pIt->second.first ) { case cpPlugins::Pipeline::Parameters::String: { QLineEdit* v_string = new QLineEdit( this ); v_string->setObjectName( pIt->first.c_str( ) ); v_string->setText( pIt->second.second.c_str( ) ); w_input = v_string; } break; case cpPlugins::Pipeline::Parameters::Bool: { QCheckBox* v_bool = new QCheckBox( this ); v_bool->setObjectName( pIt->first.c_str( ) ); v_bool->setText( "[ON/OFF]" ); v_bool->setChecked( pIt->second.second == "1" ); w_input = v_bool; } break; case cpPlugins::Pipeline::Parameters::Int: case cpPlugins::Pipeline::Parameters::Uint: { std::istringstream tok_str( pIt->second.second ); int v; tok_str >> v; QSpinBox* v_uint = new QSpinBox( this ); v_uint->setObjectName( pIt->first.c_str( ) ); if( pIt->second.first == cpPlugins::Pipeline::Parameters::Uint ) v_uint->setMinimum( 0 ); else v_uint->setMinimum( -std::numeric_limits< int >::max( ) ); v_uint->setMaximum( std::numeric_limits< int >::max( ) ); v_uint->setValue( v ); w_input = v_uint; } break; case cpPlugins::Pipeline::Parameters::Real: { std::istringstream tok_str( pIt->second.second ); double v; tok_str >> v; QDoubleSpinBox* v_double = new QDoubleSpinBox( this ); v_double->setObjectName( pIt->first.c_str( ) ); v_double->setDecimals( 3 ); v_double->setMinimum( -std::numeric_limits< double >::max( ) ); v_double->setMaximum( std::numeric_limits< double >::max( ) ); v_double->setValue( v ); w_input = v_double; } break; case cpPlugins::Pipeline::Parameters::OpenFileName: { QFrame* frame = new QFrame( this ); QHBoxLayout* layout = new QHBoxLayout( frame ); QLineEdit* v_string = new QLineEdit( frame ); v_string->setObjectName( pIt->first.c_str( ) ); v_string->setText( pIt->second.second.c_str( ) ); QPushButton* v_button = new QPushButton( frame ); v_button->setObjectName( ( pIt->first + "_=?btn" ).c_str( ) ); v_button->setText( "..." ); v_button->connect( v_button, SIGNAL( clicked( ) ), this, SLOT( _dlg_OpenSingleFile( ) ) ); layout->addWidget( v_string ); layout->addWidget( v_button ); w_input = frame; } case cpPlugins::Pipeline::Parameters::SaveFileName: { QFrame* frame = new QFrame( this ); QHBoxLayout* layout = new QHBoxLayout( frame ); QLineEdit* v_string = new QLineEdit( frame ); v_string->setObjectName( pIt->first.c_str( ) ); v_string->setText( pIt->second.second.c_str( ) ); QPushButton* v_button = new QPushButton( frame ); v_button->setObjectName( ( pIt->first + "_=?btn" ).c_str( ) ); v_button->setText( "..." ); v_button->connect( v_button, SIGNAL( clicked( ) ), this, SLOT( _dlg_SaveSingleFile( ) ) ); layout->addWidget( v_string ); layout->addWidget( v_button ); w_input = frame; } break; case cpPlugins::Pipeline::Parameters::PathName: { QFrame* frame = new QFrame( this ); QHBoxLayout* layout = new QHBoxLayout( frame ); QLineEdit* v_string = new QLineEdit( frame ); v_string->setObjectName( pIt->first.c_str( ) ); v_string->setText( pIt->second.second.c_str( ) ); QPushButton* v_button = new QPushButton( frame ); v_button->setObjectName( ( pIt->first + "_=?btn" ).c_str( ) ); v_button->setText( "..." ); v_button->connect( v_button, SIGNAL( clicked( ) ), this, SLOT( _dlg_OpenSinglePath( ) ) ); layout->addWidget( v_string ); layout->addWidget( v_button ); w_input = frame; } break; case cpPlugins::Pipeline::Parameters::StringList: break; case cpPlugins::Pipeline::Parameters::BoolList: break; case cpPlugins::Pipeline::Parameters::IntList: { QFrame* frame = new QFrame( this ); QHBoxLayout* layout = new QHBoxLayout( frame ); QLineEdit* v_string = new QLineEdit( frame ); v_string->setObjectName( pIt->first.c_str( ) ); v_string->setText( pIt->second.second.c_str( ) ); QPushButton* v_button = new QPushButton( frame ); v_button->setObjectName( ( pIt->first + "_=?btn" ).c_str( ) ); v_button->setText( "+" ); v_button->connect( v_button, SIGNAL( clicked( ) ), this, SLOT( _dlg_AddInt( ) ) ); layout->addWidget( v_string ); layout->addWidget( v_button ); w_input = frame; } break; case cpPlugins::Pipeline::Parameters::UintList: { QFrame* frame = new QFrame( this ); QHBoxLayout* layout = new QHBoxLayout( frame ); QLineEdit* v_string = new QLineEdit( frame ); v_string->setObjectName( pIt->first.c_str( ) ); v_string->setText( pIt->second.second.c_str( ) ); QPushButton* v_button = new QPushButton( frame ); v_button->setObjectName( ( pIt->first + "_=?btn" ).c_str( ) ); v_button->setText( "+" ); v_button->connect( v_button, SIGNAL( clicked( ) ), this, SLOT( _dlg_AddUint( ) ) ); layout->addWidget( v_string ); layout->addWidget( v_button ); w_input = frame; } break; case cpPlugins::Pipeline::Parameters::RealList: { QFrame* frame = new QFrame( this ); QHBoxLayout* layout = new QHBoxLayout( frame ); QLineEdit* v_string = new QLineEdit( frame ); v_string->setObjectName( pIt->first.c_str( ) ); v_string->setText( pIt->second.second.c_str( ) ); QPushButton* v_button = new QPushButton( frame ); v_button->setObjectName( ( pIt->first + "_=?btn" ).c_str( ) ); v_button->setText( "+" ); v_button->connect( v_button, SIGNAL( clicked( ) ), this, SLOT( _dlg_AddReal( ) ) ); layout->addWidget( v_string ); layout->addWidget( v_button ); w_input = frame; } break; case cpPlugins::Pipeline::Parameters::OpenFileNameList: { QFrame* frame = new QFrame( this ); QHBoxLayout* layout = new QHBoxLayout( frame ); QLineEdit* v_string = new QLineEdit( frame ); v_string->setObjectName( pIt->first.c_str( ) ); v_string->setMaxLength( std::numeric_limits< int >::max( ) ); v_string->setText( pIt->second.second.c_str( ) ); QPushButton* v_button = new QPushButton( frame ); v_button->setObjectName( ( pIt->first + "_=?btn" ).c_str( ) ); v_button->setText( "..." ); v_button->connect( v_button, SIGNAL( clicked( ) ), this, SLOT( _dlg_OpenMultipleFiles( ) ) ); layout->addWidget( v_string ); layout->addWidget( v_button ); w_input = frame; } break; case cpPlugins::Pipeline::Parameters::SaveFileNameList: break; case cpPlugins::Pipeline::Parameters::PathNameList: break; case cpPlugins::Pipeline::Parameters::Choices: { QComboBox* v_choices = new QComboBox( this ); v_choices->setObjectName( pIt->first.c_str( ) ); std::istringstream str0( pIt->second.second ); std::string choices; std::getline( str0, choices, '@' ); std::istringstream str1( choices ); std::string token; int id = 0; while( std::getline( str1, token, '#' ) ) v_choices->insertItem( id++, token.c_str( ) ); w_input = v_choices; } break; default: w_input = NULL; break; } // hctiws // Ok, a representation was created if( w_input != NULL ) { QHBoxLayout* new_layout = new QHBoxLayout( ); QLabel* label = new QLabel( this ); label->setText( QString( pIt->first.c_str( ) ) ); new_layout->addWidget( label ); new_layout->addWidget( w_input ); this->m_ToolsLayout->addLayout( new_layout ); } // fi } // rof // Update values this->_addButtons( ); } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: _dlg_Accepted( ) { this->updateParameters( ); } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: _dlg_OpenSingleFile( ) { auto parameters = this->m_ProcessObject->GetParameters( ); QPushButton* btn = dynamic_cast< QPushButton* >( this->sender( ) ); if( btn != NULL ) { std::string bName = btn->objectName( ).toStdString( ); std::string line_name = bName.substr( 0, bName.find( "_=?btn" ) ); QLineEdit* line = this->findChild< QLineEdit* >( line_name.c_str( ) ); if( line != NULL ) { std::string param_name = line->objectName( ).toStdString( ); if( param_name != "" ) { std::string param_value = parameters->GetOpenFileName( param_name ); if( param_value == "" ) param_value = "."; QStringList dialog_filters; std::string extensions = parameters->GetAcceptedFileExtensions( param_name ); if( extensions != "" ) dialog_filters << extensions.c_str( ); dialog_filters << "Any file (*)"; // Show dialog and check if it was accepted QFileDialog dialog( this ); dialog.setFileMode( QFileDialog::ExistingFile ); dialog.setDirectory( QFileDialog::tr( param_value.c_str( ) ) ); dialog.setNameFilters( dialog_filters ); dialog.setAcceptMode( QFileDialog::AcceptOpen ); if( dialog.exec( ) ) line->setText( *( dialog.selectedFiles( ).begin( ) ) ); } // fi } // fi } // fi } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: _dlg_SaveSingleFile( ) { auto parameters = this->m_ProcessObject->GetParameters( ); QPushButton* btn = dynamic_cast< QPushButton* >( this->sender( ) ); if( btn != NULL ) { std::string bName = btn->objectName( ).toStdString( ); std::string line_name = bName.substr( 0, bName.find( "_=?btn" ) ); QLineEdit* line = this->findChild< QLineEdit* >( line_name.c_str( ) ); if( line != NULL ) { std::string param_name = line->objectName( ).toStdString( ); if( param_name != "" ) { std::string param_value = parameters->GetSaveFileName( param_name ); if( param_value == "" ) param_value = "."; QStringList dialog_filters; std::string extensions = parameters->GetAcceptedFileExtensions( param_name ); if( extensions != "" ) dialog_filters << extensions.c_str( ); dialog_filters << "Any file (*)"; // Show dialog and check if it was accepted QFileDialog dialog( this ); dialog.setFileMode( QFileDialog::AnyFile ); dialog.setDirectory( QFileDialog::tr( param_value.c_str( ) ) ); dialog.setNameFilters( dialog_filters ); dialog.setAcceptMode( QFileDialog::AcceptSave ); if( dialog.exec( ) ) line->setText( *( dialog.selectedFiles( ).begin( ) ) ); } // fi } // fi } // fi } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: _dlg_OpenSinglePath( ) { auto parameters = this->m_ProcessObject->GetParameters( ); QPushButton* btn = dynamic_cast< QPushButton* >( this->sender( ) ); if( btn != NULL ) { std::string bName = btn->objectName( ).toStdString( ); std::string line_name = bName.substr( 0, bName.find( "_=?btn" ) ); QLineEdit* line = this->findChild< QLineEdit* >( line_name.c_str( ) ); if( line != NULL ) { std::string param_name = line->objectName( ).toStdString( ); if( param_name != "" ) { std::string param_value = parameters->GetPathName( param_name ); if( param_value == "" ) param_value = "."; // Show dialog and check if it was accepted QFileDialog dialog( this ); dialog.setFileMode( QFileDialog::Directory ); dialog.setDirectory( QFileDialog::tr( param_value.c_str( ) ) ); dialog.setAcceptMode( QFileDialog::AcceptOpen ); if( dialog.exec( ) ) line->setText( *( dialog.selectedFiles( ).begin( ) ) ); } // fi } // fi } // fi } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: _dlg_OpenMultipleFiles( ) { auto parameters = this->m_ProcessObject->GetParameters( ); QPushButton* btn = dynamic_cast< QPushButton* >( this->sender( ) ); if( btn != NULL ) { std::string bName = btn->objectName( ).toStdString( ); std::string line_name = bName.substr( 0, bName.find( "_=?btn" ) ); QLineEdit* line = this->findChild< QLineEdit* >( line_name.c_str( ) ); if( line != NULL ) { std::string param_name = line->objectName( ).toStdString( ); if( param_name != "" ) { QStringList dialog_filters; std::string extensions = parameters->GetAcceptedFileExtensions( param_name ); if( extensions != "" ) dialog_filters << extensions.c_str( ); dialog_filters << "Any file (*)"; // Show dialog and check if it was accepted QFileDialog dialog( this ); dialog.setFileMode( QFileDialog::ExistingFiles ); dialog.setNameFilters( dialog_filters ); dialog.setAcceptMode( QFileDialog::AcceptOpen ); if( dialog.exec( ) ) { if( dialog.selectedFiles( ).size( ) > 0 ) { std::stringstream str; auto files = dialog.selectedFiles( ); auto fIt = files.begin( ); str << fIt->toStdString( ); ++fIt; for( ; fIt != files.end( ); ++fIt ) str << "#" << fIt->toStdString( ); line->setText( str.str( ).c_str( ) ); } // fi } // fi } // fi } // fi } // fi } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: _dlg_AddInt( ) { QPushButton* btn = dynamic_cast< QPushButton* >( this->sender( ) ); if( btn != NULL ) { std::string bName = btn->objectName( ).toStdString( ); std::string line_name = bName.substr( 0, bName.find( "_=?btn" ) ); QLineEdit* line = this->findChild< QLineEdit* >( line_name.c_str( ) ); if( line != NULL ) { std::string param_name = line->objectName( ).toStdString( ); if( param_name != "" ) { bool ok; int value = QInputDialog::getInt( this, ( std::string( "Add new value to \"" ) + param_name + std::string( "\"" ) ).c_str( ), "Value:", 0, -std::numeric_limits< int >::max( ), std::numeric_limits< int >::max( ), 1, &ok ); if( ok ) { std::string values = line->text( ).toStdString( ); if( values != "" ) values += "#"; std::stringstream str; str << values << value; line->setText( str.str( ).c_str( ) ); } // fi } // fi } // fi } // fi } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: _dlg_AddUint( ) { QPushButton* btn = dynamic_cast< QPushButton* >( this->sender( ) ); if( btn != NULL ) { std::string bName = btn->objectName( ).toStdString( ); std::string line_name = bName.substr( 0, bName.find( "_=?btn" ) ); QLineEdit* line = this->findChild< QLineEdit* >( line_name.c_str( ) ); if( line != NULL ) { std::string param_name = line->objectName( ).toStdString( ); if( param_name != "" ) { bool ok; int value = QInputDialog::getInt( this, ( std::string( "Add new value to \"" ) + param_name + std::string( "\"" ) ).c_str( ), "Value:", 0, 0, std::numeric_limits< int >::max( ), 1, &ok ); if( ok ) { std::string values = line->text( ).toStdString( ); if( values != "" ) values += "#"; std::stringstream str; str << values << value; line->setText( str.str( ).c_str( ) ); } // fi } // fi } // fi } // fi } // ------------------------------------------------------------------------- void cpPlugins::QT::ParametersDialog:: _dlg_AddReal( ) { QPushButton* btn = dynamic_cast< QPushButton* >( this->sender( ) ); if( btn != NULL ) { std::string bName = btn->objectName( ).toStdString( ); std::string line_name = bName.substr( 0, bName.find( "_=?btn" ) ); QLineEdit* line = this->findChild< QLineEdit* >( line_name.c_str( ) ); if( line != NULL ) { std::string param_name = line->objectName( ).toStdString( ); if( param_name != "" ) { bool ok; double value = QInputDialog::getDouble( this, ( std::string( "Add new value to \"" ) + param_name + std::string( "\"" ) ).c_str( ), "Value:", 0, -std::numeric_limits< double >::max( ), std::numeric_limits< double >::max( ), 1, &ok ); if( ok ) { std::string values = line->text( ).toStdString( ); if( values != "" ) values += "#"; std::stringstream str; str << values << value; line->setText( str.str( ).c_str( ) ); } // fi } // fi } // fi } // fi } // eof - $RCSfile$