+ 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::StringList:
+ break;
+ case Parameters::BoolList:
+ break;
+ case Parameters::SaveFileNameList:
+ break;
+ case Parameters::PathNameList:
+ break;
+ case 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::Interface::ParametersQtDialog::
+_dlg_OpenSingleFile( )
+{
+ 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 =
+ this->m_Parameters->GetOpenFileName( param_name );
+ if( param_value == "" )
+ param_value = ".";
+ QStringList filters;
+ 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( filters );
+ dialog.setAcceptMode( QFileDialog::AcceptOpen );
+ if( dialog.exec( ) )
+ line->setText( *( dialog.selectedFiles( ).begin( ) ) );
+
+ } // fi
+
+ } // fi
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+_dlg_SaveSingleFile( )
+{
+ 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 =
+ this->m_Parameters->GetSaveFileName( param_name );
+ if( param_value == "" )
+ param_value = ".";
+ QStringList filters;
+ 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( filters );
+ dialog.setAcceptMode( QFileDialog::AcceptSave );
+ if( dialog.exec( ) )
+ line->setText( *( dialog.selectedFiles( ).begin( ) ) );
+
+ } // fi
+
+ } // fi
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+_dlg_OpenSinglePath( )
+{
+ 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 =
+ this->m_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::Interface::ParametersQtDialog::
+_dlg_OpenMultipleFiles( )
+{
+ 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 )