]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/IO/MeshReader.cxx
Widget integration (step 5/6): Interactive plugins now supported, widgets updates...
[cpPlugins.git] / lib / cpPlugins / Plugins / IO / MeshReader.cxx
index fe61d707532d52b9b91f5ab724f6330d39ac026a..397b644ef10b402d267a5e0fadd98a7571e239fd 100644 (file)
@@ -23,16 +23,10 @@ ExecConfigurationDialog( QWidget* parent )
   dialog.setNameFilter( QFileDialog::tr( "All files (*)" ) );
   if( dialog.exec( ) )
   {
-    this->m_Parameters = this->m_DefaultParameters;
     QStringList names = dialog.selectedFiles( );
-    this->m_Parameters.SetValueAsString(
-      "FileName", names[ 0 ].toStdString( )
-      );
-
-    /* TODO
-       this->m_Parameters.SetValueAsString( "PixelType", "float" );
-       this->m_Parameters.SetValueAsUint( "Dimension", 3 );
-    */
+    this->m_Parameters->SetString( "FileName", names[ 0 ].toStdString( ) );
+    this->m_Parameters->SetSelectedChoice( "PixelType", "float" );
+    this->m_Parameters->SetUint( "Dimension", 3 );
 
     r = true;
 
@@ -51,13 +45,12 @@ MeshReader( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
-  this->m_DefaultParameters.Configure( Parameters::String, "PixelType" );
-  this->m_DefaultParameters.Configure( Parameters::Uint, "Dimension" );
-  this->m_DefaultParameters.SetValueAsString( "PixelType", "float" );
-  this->m_DefaultParameters.SetValueAsUint( "Dimension", 3 );
-  this->m_Parameters = this->m_DefaultParameters;
+  std::vector< TParameters::TString > valid_types;
+  valid_types.push_back( "float" );
+  valid_types.push_back( "double" );
+  this->m_Parameters->ConfigureAsString( "FileName", "" );
+  this->m_Parameters->ConfigureAsChoices( "PixelType", valid_types );
+  this->m_Parameters->ConfigureAsUint( "Dimension", 3 );
 }
 
 // -------------------------------------------------------------------------
@@ -71,7 +64,7 @@ std::string cpPlugins::IO::MeshReader::
 _GenerateData( )
 {
   using namespace cpPlugins::Interface;
-  Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" );
+  Parameters::TUint dim = this->m_Parameters->GetUint( "Dimension" );
   std::string r = "MeshReader: Mesh dimension not supported.";
   if( dim == 2 )
     r = this->_GD0< 2 >( );
@@ -86,7 +79,8 @@ std::string cpPlugins::IO::MeshReader::
 _GD0( )
 {
   using namespace cpPlugins::Interface;
-  Parameters::TString pt = this->m_Parameters.GetValueAsString( "PixelType" );
+  Parameters::TString pt =
+    this->m_Parameters->GetSelectedChoice( "PixelType" );
   std::string r = "MeshReader: Mesh pixel type not supported";
   if( pt == "float" )       r = this->_GD1< float, D >( );
   else if( pt == "double" ) r = this->_GD1< double, D >( );
@@ -99,9 +93,7 @@ std::string cpPlugins::IO::MeshReader::
 _GD1( )
 {
   // Get filename
-  using namespace cpPlugins::Interface;
-  Parameters::TString fname =
-    this->m_Parameters.GetValueAsString( "FileName" );
+  std::string fname = this->m_Parameters->GetString( "FileName" );
 
   vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( );
   pdr->SetFileName( fname.c_str( ) );