#include <vtkRenderWindowInteractor.h>
#include <QCheckBox>
-#include <QDialogButtonBox>
#include <QDoubleSpinBox>
+#include <QFileDialog>
#include <QHBoxLayout>
+#include <QInputDialog>
#include <QLineEdit>
#include <QPushButton>
#include <QWidget>
else if( this->Dialog->getParameters( )->HasPoint( this->Name ) )
{
this->Dialog->getParameters( )->SetPoint( this->Name, 3, seed );
- this->Dialog->syncParameters( );
+ this->Dialog->updateParameters( );
auto filter = this->Dialog->getParameters( )->GetProcessObject( );
if( filter != NULL )
{
cpPlugins::Interface::ParametersQtDialog::
ParametersQtDialog( QWidget* parent, Qt::WindowFlags f )
: QDialog( parent, f ),
- m_Parameters( NULL ),
- m_IsModal( false )
+ m_Parameters( NULL )
{
this->m_Title = new QLabel( this );
this->m_Title->setText( "Parameters dialog title" );
delete this->m_MainLayout;
}
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::ParametersQtDialog::
-IsModal( ) const
-{
- return( this->m_IsModal );
-}
-
// -------------------------------------------------------------------------
cpPlugins::Interface::
Parameters* cpPlugins::Interface::ParametersQtDialog::
bool cpPlugins::Interface::ParametersQtDialog::
setParameters( Parameters* parameters )
{
- this->m_IsModal = true;
- this->m_Parameters = parameters;
- if( this->m_Parameters == NULL )
+ if( this->m_Parameters != NULL || parameters == NULL )
return( false );
+ this->m_Parameters = parameters;
// Set dialog title
auto filter = this->m_Parameters->GetProcessObject( );
case 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;
}
case 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;
int v;
tok_str >> v;
QSpinBox* v_uint = new QSpinBox( this );
+ v_uint->setObjectName( pIt->first.c_str( ) );
if( pIt->second.first == Parameters::Uint )
v_uint->setMinimum( 0 );
else
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( ) );
break;
case Parameters::Vector:
break;
- case Parameters::FileName:
+ case 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.c_str( ) );
+ v_button->setObjectName( ( pIt->first + "_=?btn" ).c_str( ) );
v_button->setText( "..." );
v_button->connect(
v_button, SIGNAL( clicked( ) ),
- this, SLOT( _dlg_MultipleFiles( ) )
+ this, SLOT( _dlg_OpenSingleFile( ) )
+ );
+ layout->addWidget( v_string );
+ layout->addWidget( v_button );
+ w_input = frame;
+ }
+ case 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 Parameters::PathName:
- break;
+ {
+ 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 Parameters::StringList:
break;
case Parameters::BoolList:
break;
case Parameters::IntList:
- break;
+ {
+ 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 Parameters::UintList:
- break;
+ {
+ 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 Parameters::RealList:
- break;
+ {
+ 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 Parameters::IndexList:
break;
case Parameters::PointList:
break;
case Parameters::VectorList:
break;
- case Parameters::FileNameList:
+ case 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->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 Parameters::SaveFileNameList:
break;
case Parameters::PathNameList:
break;
break;
} // hctiws
- /* TODO
- else if( pt == Parameters::Real )
- else if(
- pt == Parameters::StringList ||
- pt == Parameters::IntList ||
- pt == Parameters::UintList ||
- pt == Parameters::RealList
- )
- {
- cpPlugins::Interface::ParametersListWidget* l_double =
- new cpPlugins::Interface::ParametersListWidget( *nIt, this );
- w_input = l_double;
- }
- else if( pt == Parameters::Point || pt == Parameters::Index )
- {
- vtkSmartPointer< SingleSeedCommand > command =
- vtkSmartPointer< SingleSeedCommand >::New( );
- command->Dialog = this;
- command->Name = *nIt;
-
- auto iIt = this->m_Interactors.begin( );
- for( ; iIt != this->m_Interactors.end( ); ++iIt )
- {
- TStyle* style =
- dynamic_cast< TStyle* >( ( *iIt )->GetInteractorStyle( ) );
- if( style != NULL )
- {
- style->SeedWidgetOn( );
- style->SetSeedWidgetCommand( command );
-
- } // fi
-
- } // rof
- this->m_IsModal = false;
-
- } // fi
- */
-
// Ok, a representation was created
if( w_input != NULL )
{
- w_input->setObjectName( QString( pIt->first.c_str( ) ) );
-
QHBoxLayout* new_layout = new QHBoxLayout( );
QLabel* label = new QLabel( this );
label->setText( QString( pIt->first.c_str( ) ) );
} // fi
} // rof
- return( this->m_IsModal );
+
+ // 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( )
{
- if( !this->m_IsModal )
- return( 0 );
-
- // Add buttons
- QDialogButtonBox* bb = new QDialogButtonBox(
- QDialogButtonBox::Ok | QDialogButtonBox::Cancel
- );
- QObject::connect( bb, SIGNAL( accepted( ) ), this, SLOT( accept( ) ) );
- QObject::connect( bb, SIGNAL( rejected( ) ), this, SLOT( reject( ) ) );
- this->m_ToolsLayout->addWidget( bb );
-
int ret = this->QDialog::exec( );
if( ret == 1 )
- this->syncParameters( );
+ this->updateParameters( );
+ else
+ this->updateView( );
return( ret );
}
void cpPlugins::Interface::ParametersQtDialog::
show( )
{
- if( this->m_IsModal )
- return;
-
this->QDialog::show( );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::ParametersQtDialog::
-syncParameters( )
+updateParameters( )
{
if( this->m_Parameters == NULL )
return;
- // Get values
- std::vector< std::string > names;
- this->m_Parameters->GetNames( names );
- std::vector< std::string >::const_iterator nIt = names.begin( );
- for( ; nIt != names.end( ); ++nIt )
+ // Put values
+ auto& raw_params = this->m_Parameters->GetRawParameters( );
+ for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt )
{
- Parameters::Type pt = this->m_Parameters->GetType( *nIt );
-
- if( pt == Parameters::String )
+ QString pName = pIt->first.c_str( );
+ switch( pIt->second.first )
{
- QLineEdit* v = this->findChild< QLineEdit* >( nIt->c_str( ) );
- if( v != NULL )
- this->m_Parameters->SetString( *nIt, v->text( ).toStdString( ) );
+ 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";
}
- else if( pt == Parameters::Bool )
+ break;
+ case Parameters::Int:
+ case Parameters::Uint:
{
- QCheckBox* v = this->findChild< QCheckBox* >( nIt->c_str( ) );
- if( v != NULL )
- this->m_Parameters->SetBool( *nIt, v->isChecked( ) );
+ QSpinBox* v_uint = this->findChild< QSpinBox* >( pName );
+ if( v_uint )
+ {
+ std::stringstream str;
+ str << v_uint->value( );
+ pIt->second.second = str.str( );
+
+ } // fi
}
- else if( pt == Parameters::Uint )
+ break;
+ case Parameters::Real:
{
- QSpinBox* v = this->findChild< QSpinBox* >( nIt->c_str( ) );
- if( v != NULL )
- this->m_Parameters->SetUint( *nIt, v->value( ) );
+ QDoubleSpinBox* v_double = this->findChild< QDoubleSpinBox* >( pName );
+ if( v_double )
+ {
+ std::stringstream str;
+ str << v_double->value( );
+ pIt->second.second = str.str( );
+
+ } // fi
}
- else if( pt == Parameters::Int )
+ 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 )
{
- QSpinBox* v = this->findChild< QSpinBox* >( nIt->c_str( ) );
- if( v != NULL )
- this->m_Parameters->SetInt( *nIt, v->value( ) );
+ 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( ) );
}
- else if( pt == Parameters::Real )
+ break;
+ case Parameters::Bool:
{
- QDoubleSpinBox* v = this->findChild< QDoubleSpinBox* >( nIt->c_str( ) );
- if( v != NULL )
- this->m_Parameters->SetReal( *nIt, v->value( ) );
+ QCheckBox* v_bool = this->findChild< QCheckBox* >( pName );
+ if( v_bool != NULL )
+ v_bool->setChecked( pIt->second.second == "1" );
}
- else if(
- pt == Parameters::StringList ||
- pt == Parameters::IntList ||
- pt == Parameters::UintList ||
- pt == Parameters::RealList
- )
- {
- cpPlugins::Interface::ParametersListWidget* lst =
- this->findChild< cpPlugins::Interface::ParametersListWidget* >(
- nIt->c_str( )
- );
- if( lst != NULL )
+ break;
+ case Parameters::Int:
+ case Parameters::Uint:
+ {
+ QSpinBox* v_uint = this->findChild< QSpinBox* >( pName );
+ if( v_uint )
{
- if( pt == Parameters::StringList )
- {
- this->m_Parameters->ClearStringList( *nIt );
- std::vector< std::string > values = lst->GetStringValues( );
- for( int r = 0; r < values.size( ); ++r )
- this->m_Parameters->AddToStringList( *nIt, values[ r ] );
- }
- else if( pt == Parameters::IntList )
- {
- this->m_Parameters->ClearIntList( *nIt );
- std::vector< int > values = lst->GetIntValues( );
- for( int r = 0; r < values.size( ); ++r )
- this->m_Parameters->AddToIntList( *nIt, values[ r ] );
- }
- else if( pt == Parameters::UintList )
- {
- this->m_Parameters->ClearUintList( *nIt );
- std::vector< unsigned int > values = lst->GetUintValues( );
- for( int r = 0; r < values.size( ); ++r )
- this->m_Parameters->AddToUintList( *nIt, values[ r ] );
- }
- else if( pt == Parameters::RealList )
- {
- this->m_Parameters->ClearRealList( *nIt );
- std::vector< double > values = lst->GetDoubleValues( );
- for( int r = 0; r < values.size( ); ++r )
- this->m_Parameters->AddToRealList( *nIt, values[ r ] );
-
- } // fi
+ std::istringstream tok_str( pIt->second.second );
+ int v;
+ tok_str >> v;
+ v_uint->setValue( v );
} // fi
}
- else if( pt == Parameters::Point || pt == Parameters::Index )
+ break;
+ case Parameters::Real:
{
- } // fi
+ 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
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::ParametersQtDialog::
-_dlg_MultipleFiles( )
+_dlg_OpenSingleFile( )
{
- QObject* sender = this->sender( );
- // std::cout << "OK " << sender << " " << sender->objectName( ).toStdString( ) << std::endl;
-}
+ 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
-/* TODO
- enum Type
- {
- Index,
- Point,
- StringList,
- BoolList,
- IntList,
- UintList,
- IndexList,
- PointList,
- Choices,
- NoType
- };
-*/
-/*
- }
- else if(
- pt == Parameters::StringList ||
- pt == Parameters::IntList ||
- pt == Parameters::UintList ||
- pt == Parameters::RealList
- )
- {
- cpPlugins::Interface::ParametersListWidget* lst =
- this->findChild< cpPlugins::Interface::ParametersListWidget* >(
- nIt->c_str( )
- );
- if( lst != NULL )
- {
- if( pt == Parameters::StringList )
- {
- std::vector< std::string > values = lst->GetStringValues( );
- for( int r = 0; r < values.size( ); ++r )
- this->m_Parameters->AddToStringList( *nIt, values[ r ] );
- }
- else if( pt == Parameters::IntList )
+ } // 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::vector< int > values = lst->GetIntValues( );
- for( int r = 0; r < values.size( ); ++r )
- this->m_Parameters->AddToIntList( *nIt, values[ r ] );
- }
- else if( pt == Parameters::UintList )
+ 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 )
{
- std::vector< unsigned int > values = lst->GetUintValues( );
- for( int r = 0; r < values.size( ); ++r )
- this->m_Parameters->AddToUintList( *nIt, values[ r ] );
- }
- else if( pt == Parameters::RealList )
+ std::string param_name = line->objectName( ).toStdString( );
+ if( param_name != "" )
+ {
+ QStringList filters;
+ filters << "Any file (*)";
+
+ // Show dialog and check if it was accepted
+ QFileDialog dialog( this );
+ dialog.setFileMode( QFileDialog::ExistingFiles );
+ dialog.setNameFilters( 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::Interface::ParametersQtDialog::
+_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::vector< double > values = lst->GetDoubleValues( );
- for( int r = 0; r < values.size( ); ++r )
- this->m_Parameters->AddToRealList( *nIt, values[ r ] );
+ 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, -2147483647, 2147483647, 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::Interface::ParametersQtDialog::
+_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, 2147483647, 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::Interface::ParametersQtDialog::
+_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, -2147483647, 2147483647, 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
- } // rof
- return( true );
- }
-*/
+ } // fi
+}
#endif // cpPlugins_Interface_QT4