]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/IO/MeshReader.cxx
Widget integration (step 3/6). WARNING: IT DOES NOT COMPILE YET
[cpPlugins.git] / lib / cpPlugins / Plugins / IO / MeshReader.cxx
index 67069046163d768395fc55d2e23c5b8a871f6497..e6bba2bd4045ef4e3d2fb2df571ebf7042ae4e5d 100644 (file)
@@ -4,11 +4,49 @@
 #include <vtkPolyData.h>
 #include <vtkPolyDataReader.h>
 
+#ifdef cpPlugins_Interface_QT4
+#include <QFileDialog>
+#endif // cpPlugins_Interface_QT4
+
+// -------------------------------------------------------------------------
+bool cpPlugins::IO::MeshReader::
+ExecConfigurationDialog( QWidget* parent )
+{
+  bool r = false;
+
+#ifdef cpPlugins_Interface_QT4
+
+  // Show dialog and check if it was accepted
+  QFileDialog dialog( parent );
+  dialog.setFileMode( QFileDialog::ExistingFile );
+  dialog.setDirectory( QFileDialog::tr( "." ) );
+  dialog.setNameFilter( QFileDialog::tr( "All files (*)" ) );
+  if( dialog.exec( ) )
+  {
+    this->m_Parameters = this->m_DefaultParameters;
+    QStringList names = dialog.selectedFiles( );
+    this->m_Parameters.AddValueToStringList(
+      "FileNames", names[ 0 ].toStdString( )
+      );
+
+    /* TODO
+       this->m_Parameters.SetValueAsString( "PixelType", "float" );
+       this->m_Parameters.SetValueAsUint( "Dimension", 3 );
+    */
+
+    r = true;
+
+  } // fi
+
+#endif // cpPlugins_Interface_QT4
+
+  return( r );
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::IO::MeshReader::
 MeshReader( )
-  : Superclass( ),
-    m_Reader( NULL )
+  : Superclass( )
 {
   this->m_ClassName = "cpPlugins::IO::MeshReader";
   this->m_ClassCategory = "MeshReader";
@@ -29,8 +67,6 @@ MeshReader( )
 cpPlugins::IO::MeshReader::
 ~MeshReader( )
 {
-  if( this->m_Reader != NULL )
-    this->m_Reader = NULL;
 }
 
 // -------------------------------------------------------------------------
@@ -70,18 +106,14 @@ _GD1( )
   Parameters::TString fname =
     this->m_Parameters.GetValueAsString( "FileName" );
 
-  if( this->m_Reader != NULL )
-    this->m_Reader->Delete( );
-
-  vtkPolyDataReader* pdr = vtkPolyDataReader::New( );
-  this->m_Reader = pdr;
+  vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( );
   pdr->SetFileName( fname.c_str( ) );
   pdr->Update( );
 
   cpPlugins::Interface::Mesh* out =
     this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
   if( out != NULL )
-    out->SetVTKMesh( pdr->GetOutput( ) );
+    out->SetVTK( pdr->GetOutput( ) );
   else
     return( "MeshReader: output not correctly created." );
   return( "" );