]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 15 Jan 2016 22:09:47 +0000 (17:09 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 15 Jan 2016 22:09:47 +0000 (17:09 -0500)
18 files changed:
lib/cpPipelineEditor/Block.cxx
lib/cpPipelineEditor/Block.h
lib/cpPlugins/Interface/Parameters.cxx
lib/cpPlugins/Interface/Parameters.h
lib/cpPlugins/Interface/Parameters.hxx
lib/cpPlugins/Interface/ParametersQtDialog.cxx
lib/cpPlugins/Interface/ParametersQtDialog.h
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/Workspace.cxx
lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx
lib/cpPlugins/Plugins/IO/ImageReader.cxx
lib/cpPlugins/Plugins/IO/ImageReader.h
lib/cpPlugins/Plugins/IO/ImageWriter.cxx
lib/cpPlugins/Plugins/IO/ImageWriter.h
lib/cpPlugins/Plugins/IO/MeshReader.cxx
lib/cpPlugins/Plugins/IO/MeshReader.h
lib/cpPlugins/Plugins/IO/MeshWriter.cxx
lib/cpPlugins/Plugins/IO/MeshWriter.h

index 6d473efba274ba4f78e6ca396a44aeb3e868e46d..7263cad8f2559343f8b4a85c76672c95889c1c4c 100644 (file)
@@ -2,9 +2,12 @@
 \r
 #include <QPen>\r
 #include <QGraphicsScene>\r
+#include <QGraphicsSceneContextMenuEvent>\r
 #include <QFontMetrics>\r
+#include <QMenu>\r
 #include <QPainter>\r
 #include <QStyleOptionGraphicsItem>\r
+#include <QGraphicsWidget>\r
 \r
 #include "Port.h"\r
 #include "Connection.h"\r
@@ -249,4 +252,22 @@ mouseReleaseEvent( QGraphicsSceneMouseEvent* evt )
   this->Superclass::mouseReleaseEvent( evt );\r
 }\r
 \r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Block::\r
+contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )\r
+{\r
+  QMenu menu;\r
+  QAction* configureAction = menu.addAction( "Configure" );\r
+  QAction* updateAction = menu.addAction( "Update" );\r
+  QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
+\r
+  if( selectedAction == configureAction )\r
+  {\r
+    auto res = this->m_Filter->ExecConfigurationDialog( NULL );\r
+  }\r
+  else if( selectedAction == updateAction )\r
+  {\r
+  } // fi\r
+}\r
+\r
 // eof - $RCSfile$\r
index 81de86fdab932d39c8792396319eb72243b0dd03..763ecda8e13c2c0cbf1aae1c3c1d8778641aa884 100644 (file)
@@ -58,6 +58,7 @@ namespace cpPipelineEditor
     void _configPort( Port* port );\r
 \r
     virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* evt );\r
+    virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* evt );\r
 \r
   private:\r
     int m_HorzMargin;\r
index 1b239725411c8b5cc87e947b3c6ce6db21db0f7f..3423bea68cbea27a735027cbb2d5a633454391f2 100644 (file)
@@ -2,7 +2,13 @@
 #include <cpPlugins/Interface/ProcessObject.h>
 #include <third_party/tinyxml/tinyxml.h>
 
-#include <sstream>
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::Parameters::
+TParameters& cpPlugins::Interface::Parameters::
+GetRawParameters( ) const
+{
+  return( this->m_Parameters );
+}
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::
@@ -44,53 +50,6 @@ Clear( )
   this->Modified( );
 }
 
-// -------------------------------------------------------------------------
-#define cpPlugins_Parameters_Configure( Y )                     \
-  void cpPlugins::Interface::Parameters::                       \
-  ConfigureAs##Y( const TString& name )                         \
-  {                                                             \
-    this->m_Parameters[ name ] = TParameter( Self::Y, "" );     \
-    this->Modified( );                                          \
-  }
-
-cpPlugins_Parameters_Configure( String );
-cpPlugins_Parameters_Configure( Bool );
-cpPlugins_Parameters_Configure( Int );
-cpPlugins_Parameters_Configure( Uint );
-cpPlugins_Parameters_Configure( Real );
-cpPlugins_Parameters_Configure( Index );
-cpPlugins_Parameters_Configure( Point );
-cpPlugins_Parameters_Configure( Vector );
-cpPlugins_Parameters_Configure( StringList );
-cpPlugins_Parameters_Configure( BoolList );
-cpPlugins_Parameters_Configure( IntList );
-cpPlugins_Parameters_Configure( UintList );
-cpPlugins_Parameters_Configure( RealList );
-cpPlugins_Parameters_Configure( IndexList );
-cpPlugins_Parameters_Configure( PointList );
-cpPlugins_Parameters_Configure( VectorList );
-cpPlugins_Parameters_Configure( Choices );
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-ConfigureAsChoices(
-  const TString& name, const std::vector< TString >& choices
-  )
-{
-  // It is invalid not to give choices when configuring
-  if( choices.size( ) == 0 )
-    return;
-
-  std::stringstream str_choices;
-  str_choices << choices[ 0 ];
-  for( unsigned int i = 1; i < choices.size( ); ++i )
-    str_choices << "#" << choices[ i ];
-  str_choices << "@";
-  this->m_Parameters[ name ] =
-    TParameter( Self::Choices, str_choices.str( ) );
-  this->Modified( );
-}
-
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
 GetNames( std::vector< TString >& container ) const
@@ -106,7 +65,7 @@ cpPlugins::Interface::Parameters::
 Type cpPlugins::Interface::Parameters::
 GetType( const TString& name ) const
 {
-  TParameters::const_iterator i = this->m_Parameters.find( name );
+  auto i = this->m_Parameters.find( name );
   if( i != this->m_Parameters.end( ) )
     return( i->second.first );
   else
@@ -114,310 +73,207 @@ GetType( const TString& name ) const
 }
 
 // -------------------------------------------------------------------------
-#define cpPlugins_Parameters_Has( Y )                                   \
-  bool cpPlugins::Interface::Parameters::                               \
-  Has##Y( const TString& name ) const                                   \
-  {                                                                     \
-    TParameters::const_iterator i = this->m_Parameters.find( name );    \
-    if( i != this->m_Parameters.end( ) )                                \
-      return( i->second.first == Self::Y );                             \
-    else                                                                \
-      return( false );                                                  \
-  }
-
-cpPlugins_Parameters_Has( String );
-cpPlugins_Parameters_Has( Bool );
-cpPlugins_Parameters_Has( Int );
-cpPlugins_Parameters_Has( Uint );
-cpPlugins_Parameters_Has( Real );
-cpPlugins_Parameters_Has( Index );
-cpPlugins_Parameters_Has( Point );
-cpPlugins_Parameters_Has( Vector );
-cpPlugins_Parameters_Has( StringList );
-cpPlugins_Parameters_Has( BoolList );
-cpPlugins_Parameters_Has( IntList );
-cpPlugins_Parameters_Has( UintList );
-cpPlugins_Parameters_Has( RealList );
-cpPlugins_Parameters_Has( IndexList );
-cpPlugins_Parameters_Has( PointList );
-cpPlugins_Parameters_Has( VectorList );
-cpPlugins_Parameters_Has( Choices );
+#define cpPlugins_Parameters_TypeAsString( Y )  \
+  if( i->second.first == Self::Y )              \
+    return( #Y )
 
-// -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-TString cpPlugins::Interface::Parameters::
-GetString( const TString& name, bool force ) const
+std::string cpPlugins::Interface::Parameters::
+GetTypeAsString( const TString& name ) const
 {
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i != this->m_Parameters.end( ) )
-  {
-    if( i->second.first == Self::String || !force )
-      return( i->second.second );
-
-  } // fi
-  return( "" );
+  auto i = this->m_Parameters.find( name );
+  cpPlugins_Parameters_TypeAsString( String );
+  else cpPlugins_Parameters_TypeAsString( Bool );
+  else cpPlugins_Parameters_TypeAsString( Int );
+  else cpPlugins_Parameters_TypeAsString( Uint );
+  else cpPlugins_Parameters_TypeAsString( Real );
+  else cpPlugins_Parameters_TypeAsString( Index );
+  else cpPlugins_Parameters_TypeAsString( Point );
+  else cpPlugins_Parameters_TypeAsString( Vector );
+  else cpPlugins_Parameters_TypeAsString( FileName );
+  else cpPlugins_Parameters_TypeAsString( PathName );
+  else cpPlugins_Parameters_TypeAsString( StringList );
+  else cpPlugins_Parameters_TypeAsString( BoolList );
+  else cpPlugins_Parameters_TypeAsString( IntList );
+  else cpPlugins_Parameters_TypeAsString( UintList );
+  else cpPlugins_Parameters_TypeAsString( RealList );
+  else cpPlugins_Parameters_TypeAsString( IndexList );
+  else cpPlugins_Parameters_TypeAsString( PointList );
+  else cpPlugins_Parameters_TypeAsString( VectorList );
+  else cpPlugins_Parameters_TypeAsString( FileNameList );
+  else cpPlugins_Parameters_TypeAsString( PathNameList );
+  else cpPlugins_Parameters_TypeAsString( Choices );
+  else return( "NoType" );
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-TBool cpPlugins::Interface::Parameters::
-GetBool( const TString& name ) const
-{
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i != this->m_Parameters.end( ) )
-  {
-    if( i->second.first == Self::Bool )
-      return( std::atoi( i->second.second.c_str( ) ) == 1 );
+#define cpPlugins_Parameters_TypeFromString( Y, str )   \
+  if( str == std::string( #Y ) )                        \
+    return( Self::Y )
 
-  } // fi
-  return( false );
-}
-
-// -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
-TInt cpPlugins::Interface::Parameters::
-GetInt( const TString& name ) const
+Type cpPlugins::Interface::Parameters::
+GetTypeFromString( const std::string& t )
 {
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i != this->m_Parameters.end( ) )
-  {
-    if( i->second.first == Self::Int )
-      return( TInt( std::atoi( i->second.second.c_str( ) ) ) );
-
-  } // fi
-  return( TInt( 0 ) );
+  cpPlugins_Parameters_TypeFromString( String, t );
+  else cpPlugins_Parameters_TypeFromString( Bool, t );
+  else cpPlugins_Parameters_TypeFromString( Int, t );
+  else cpPlugins_Parameters_TypeFromString( Uint, t );
+  else cpPlugins_Parameters_TypeFromString( Real, t );
+  else cpPlugins_Parameters_TypeFromString( Index, t );
+  else cpPlugins_Parameters_TypeFromString( Point, t );
+  else cpPlugins_Parameters_TypeFromString( Vector, t );
+  else cpPlugins_Parameters_TypeFromString( FileName, t );
+  else cpPlugins_Parameters_TypeFromString( PathName, t );
+  else cpPlugins_Parameters_TypeFromString( StringList, t );
+  else cpPlugins_Parameters_TypeFromString( BoolList, t );
+  else cpPlugins_Parameters_TypeFromString( IntList, t );
+  else cpPlugins_Parameters_TypeFromString( UintList, t );
+  else cpPlugins_Parameters_TypeFromString( RealList, t );
+  else cpPlugins_Parameters_TypeFromString( IndexList, t );
+  else cpPlugins_Parameters_TypeFromString( PointList, t );
+  else cpPlugins_Parameters_TypeFromString( VectorList, t );
+  else cpPlugins_Parameters_TypeFromString( FileNameList, t );
+  else cpPlugins_Parameters_TypeFromString( PathNameList, t );
+  else cpPlugins_Parameters_TypeFromString( Choices, t );
+  else return( Self::NoType );
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-TUint cpPlugins::Interface::Parameters::
-GetUint( const TString& name ) const
+std::string cpPlugins::Interface::Parameters::
+GetString( const std::string& name, bool force ) const
 {
-  TParameters::const_iterator i = this->m_Parameters.find( name );
+  auto i = this->m_Parameters.find( name );
   if( i != this->m_Parameters.end( ) )
   {
-    if( i->second.first == Self::Uint )
-      return( TUint( std::atoi( i->second.second.c_str( ) ) ) );
-
-  } // fi
-  return( TUint( 0 ) );
+    if( i->second.first == Self::String || force )
+      return( i->second.second );
+    else
+      return( "" );
+  }
+  else
+    return( "" );
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-TReal cpPlugins::Interface::Parameters::
-GetReal( const TString& name ) const
+void cpPlugins::Interface::Parameters::
+SetString( const std::string& name, const std::string& v, bool force )
 {
-  TParameters::const_iterator i = this->m_Parameters.find( name );
+  auto i = this->m_Parameters.find( name );
   if( i != this->m_Parameters.end( ) )
   {
-    if( i->second.first == Self::Real )
+    if( i->second.first == Self::String || force )
     {
-      std::istringstream tok_str( i->second.second );
-      float v;
-      tok_str >> v;
-      return( TReal( v ) );
+      i->second.second = v;
+      this->Modified( );
 
     } // fi
 
   } // fi
-  return( TReal( 0 ) );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-GetStringList( std::vector< TString >& lst, const TString& name ) const
-{
-  lst.clear( );
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first != Self::StringList )
-    return;
-
-  std::istringstream str( i->second.second );
-  std::string token;
-  while( std::getline( str, token, '#' ) )
-    lst.push_back( token );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-GetBoolList( std::vector< TBool >& lst, const TString& name ) const
-{
-  lst.clear( );
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first != Self::BoolList )
-    return;
-
-  std::istringstream str( i->second.second );
-  std::string token;
-  while( std::getline( str, token, '#' ) )
-    lst.push_back( std::atoi( token.c_str( ) ) == 1 );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-GetIntList( std::vector< TInt >& lst, const TString& name ) const
+ConfigureAsChoices(
+  const std::string& name, const std::vector< std::string >& choices
+  )
 {
-  lst.clear( );
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first != Self::IntList )
+  // It is invalid not to give choices when configuring
+  if( choices.size( ) == 0 )
     return;
 
-  std::istringstream str( i->second.second );
-  std::string token;
-  while( std::getline( str, token, '#' ) )
-    lst.push_back( TInt( std::atoi( token.c_str( ) ) ) );
+  std::stringstream str_choices;
+  str_choices << choices[ 0 ];
+  for( unsigned int i = 1; i < choices.size( ); ++i )
+    str_choices << "#" << choices[ i ];
+  str_choices << "@";
+  this->m_Parameters[ name ] =
+    TParameter( Self::Choices, str_choices.str( ) );
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-GetUintList( std::vector< TUint >& lst, const TString& name ) const
+std::vector< std::string > cpPlugins::Interface::Parameters::
+GetChoices( const TString& name ) const
 {
-  lst.clear( );
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first != Self::UintList )
-    return;
+  std::vector< std::string > choices;
 
-  std::istringstream str( i->second.second );
-  std::string token;
-  while( std::getline( str, token, '#' ) )
-    lst.push_back( TUint( std::atoi( token.c_str( ) ) ) );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-GetRealList( std::vector< TReal >& lst, const TString& name ) const
-{
-  lst.clear( );
   TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first != Self::RealList )
-    return;
-
-  std::istringstream str( i->second.second );
-  std::string token;
-  while( std::getline( str, token, '#' ) )
+  if( i != this->m_Parameters.end( ) )
   {
-    std::istringstream tok_str( token );
-    float v;
-    tok_str >> v;
-    lst.push_back( TReal( v ) );
-
-  } // elihw
-}
+    if( i->second.first == Self::Choices )
+    {
+      std::istringstream str_choices( i->second.second );
+      std::string real_choices;
+      std::getline( str_choices, real_choices, '@' );
+      std::istringstream str( real_choices );
+      std::string token;
+      while( std::getline( str, token, '#' ) )
+        choices.push_back( token );
 
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-GetChoices( std::vector< TString >& choices, const TString& name ) const
-{
-  choices.clear( );
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first != Self::Choices )
-    return;
+    } // fi
 
-  std::istringstream str_choices( i->second.second );
-  std::string real_choices;
-  std::getline( str_choices, real_choices, '@' );
-  std::istringstream str( real_choices );
-  std::string token;
-  while( std::getline( str, token, '#' ) )
-    choices.push_back( token );
+  } // fi
+  return( choices );
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-TString cpPlugins::Interface::Parameters::
-GetSelectedChoice( const TString& name ) const
+std::string cpPlugins::Interface::Parameters::
+GetSelectedChoice( const std::string& name ) const
 {
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return( "" );
-  if( i->second.first != Self::Choices )
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::Choices )
+    {
+      std::istringstream str_choices( i->second.second );
+      std::string real_choice;
+      std::getline( str_choices, real_choice, '@' );
+      std::getline( str_choices, real_choice, '@' );
+      return( real_choice );
+    }
+    else
+      return( "" );
+  }
+  else
     return( "" );
-
-  std::istringstream str_choices( i->second.second );
-  std::string real_choice;
-  std::getline( str_choices, real_choice, '@' );
-  std::getline( str_choices, real_choice, '@' );
-  return( real_choice );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-SetString( const TString& name, const TString& v, bool force )
+bool cpPlugins::Interface::Parameters::
+SetSelectedChoice( const TString& name, const TString& choice )
 {
-  TParameters::iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first != Self::String && force )
-    return;
-  i->second.second = v;
-  this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Parameters_Set( Y )                           \
-  void cpPlugins::Interface::Parameters::                       \
-  Set##Y( const TString& name, const T##Y& v )                  \
-  {                                                             \
-    TParameters::iterator i = this->m_Parameters.find( name );  \
-    if( i == this->m_Parameters.end( ) )                        \
-      return;                                                   \
-    if( i->second.first != Self::Y )                            \
-      return;                                                   \
-    std::stringstream str;                                      \
-    str << v;                                                   \
-    i->second.second = str.str( );                              \
-    this->Modified( );                                          \
-  }
-
-cpPlugins_Parameters_Set( Bool );
-cpPlugins_Parameters_Set( Int );
-cpPlugins_Parameters_Set( Uint );
-cpPlugins_Parameters_Set( Real );
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Parameters_Add( Y )                           \
-  void cpPlugins::Interface::Parameters::                       \
-  AddTo##Y##List( const TString& name, const T##Y& v )          \
-  {                                                             \
-    TParameters::iterator i = this->m_Parameters.find( name );  \
-    if( i == this->m_Parameters.end( ) )                        \
-      return;                                                   \
-    if( i->second.first != Self::Y##List )                      \
-      return;                                                   \
-    std::stringstream str;                                      \
-    if( i->second.second == "" )                                \
-      str << v;                                                 \
-    else                                                        \
-      str << "#" << v;                                          \
-    i->second.second += str.str( );                             \
-    this->Modified( );                                          \
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::Choices )
+    {
+      std::vector< std::string > c = this->GetChoices( name );
+      if( std::find( c.begin( ), c.end( ), choice ) != c.end( ) )
+      {
+        std::istringstream str_choices( i->second.second );
+        std::string choices;
+        std::getline( str_choices, choices, '@' );
+        std::stringstream new_choices;
+        new_choices << choices << "@" << choice;
+        i->second.second = new_choices.str( );
+        return( true );
+      }
+      else
+        return( false );
+    }
+    else
+      return( false );
   }
-
-cpPlugins_Parameters_Add( String );
-cpPlugins_Parameters_Add( Bool );
-cpPlugins_Parameters_Add( Int );
-cpPlugins_Parameters_Add( Uint );
-cpPlugins_Parameters_Add( Real );
+  else
+    return( false );
+}
 
 // -------------------------------------------------------------------------
-#define cpPlugins_Parameters_Clear( Y )                         \
+#define cpPlugins_Parameters_ClearList( Y )                     \
   void cpPlugins::Interface::Parameters::                       \
   Clear##Y##List( const TString& name )                         \
   {                                                             \
-    TParameters::iterator i = this->m_Parameters.find( name );  \
+    auto i = this->m_Parameters.find( name );                   \
     if( i == this->m_Parameters.end( ) )                        \
       return;                                                   \
     if( i->second.first != Self::Y##List )                      \
@@ -426,40 +282,9 @@ cpPlugins_Parameters_Add( Real );
     this->Modified( );                                          \
   }
 
-cpPlugins_Parameters_Clear( String );
-cpPlugins_Parameters_Clear( Bool );
-cpPlugins_Parameters_Clear( Int );
-cpPlugins_Parameters_Clear( Uint );
-cpPlugins_Parameters_Clear( Real );
-cpPlugins_Parameters_Clear( Index );
-cpPlugins_Parameters_Clear( Point );
-cpPlugins_Parameters_Clear( Vector );
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-SetSelectedChoice( const TString& name, const TString& choice )
-{
-  TParameters::iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return( false );
-  if( i->second.first != Self::Choices )
-    return( false );
-
-  std::vector< TString > c;
-  this->GetChoices( c, name );
-  if( std::find( c.begin( ), c.end( ), choice ) != c.end( ) )
-  {
-    std::istringstream str_choices( i->second.second );
-    std::string choices;
-    std::getline( str_choices, choices, '@' );
-    std::stringstream new_choices;
-    new_choices << choices << "@" << choice;
-    i->second.second = new_choices.str( );
-    return( true );
-  }
-  else
-    return( false );
-}
+cpPlugins_Parameters_ClearList( Index );
+cpPlugins_Parameters_ClearList( Point );
+cpPlugins_Parameters_ClearList( Vector );
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Parameters::
@@ -474,40 +299,7 @@ ToXML( TiXmlElement* parent_elem ) const
     TiXmlElement* p = new TiXmlElement( "parameter" );
     p->SetAttribute( "name", pIt->first.c_str( ) );
     p->SetAttribute( "value", pIt->second.second.c_str( ) );
-    if( pIt->second.first == Self::String )
-      p->SetAttribute( "type", "String" );
-    else if( pIt->second.first == Self::Bool )
-      p->SetAttribute( "type", "Bool" );
-    else if( pIt->second.first == Self::Int )
-      p->SetAttribute( "type", "Int" );
-    else if( pIt->second.first == Self::Uint )
-      p->SetAttribute( "type", "Uint" );
-    else if( pIt->second.first == Self::Real )
-      p->SetAttribute( "type", "Real" );
-    else if( pIt->second.first == Self::Index )
-      p->SetAttribute( "type", "Index" );
-    else if( pIt->second.first == Self::Point )
-      p->SetAttribute( "type", "Point" );
-    else if( pIt->second.first == Self::Vector )
-      p->SetAttribute( "type", "Vector" );
-    else if( pIt->second.first == Self::StringList )
-      p->SetAttribute( "type", "StringList" );
-    else if( pIt->second.first == Self::BoolList )
-      p->SetAttribute( "type", "BoolList" );
-    else if( pIt->second.first == Self::IntList )
-      p->SetAttribute( "type", "IntList" );
-    else if( pIt->second.first == Self::UintList )
-      p->SetAttribute( "type", "UintList" );
-    else if( pIt->second.first == Self::RealList )
-      p->SetAttribute( "type", "RealList" );
-    else if( pIt->second.first == Self::IndexList )
-      p->SetAttribute( "type", "IndexList" );
-    else if( pIt->second.first == Self::PointList )
-      p->SetAttribute( "type", "PointList" );
-    else if( pIt->second.first == Self::VectorList )
-      p->SetAttribute( "type", "VectorList" );
-    else if( pIt->second.first == Self::Choices )
-      p->SetAttribute( "type", "Choices" );
+    p->SetAttribute( "type", this->GetTypeAsString( pIt->first ).c_str( ) );
     parent_elem->LinkEndChild( p );
 
   } // rof
@@ -530,43 +322,7 @@ FromXML( const TiXmlElement* filter_elem )
     {
       TParameter value;
       value.second = param->Attribute( "value" );
-
-      std::string param_type_str( param_type );
-      if( param_type_str == "Bool" )
-        value.first = Self::Bool;
-      else if( param_type_str == "Int" )
-        value.first = Self::Int;
-      else if( param_type_str == "Uint" )
-        value.first = Self::Uint;
-      else if( param_type_str == "Real" )
-        value.first = Self::Real;
-      else if( param_type_str == "Index" )
-        value.first = Self::Index;
-      else if( param_type_str == "Point" )
-        value.first = Self::Point;
-      else if( param_type_str == "Vector" )
-        value.first = Self::Vector;
-      else if( param_type_str == "StringList" )
-        value.first = Self::StringList;
-      else if( param_type_str == "BoolList" )
-        value.first = Self::BoolList;
-      else if( param_type_str == "IntList" )
-        value.first = Self::IntList;
-      else if( param_type_str == "UintList" )
-        value.first = Self::UintList;
-      else if( param_type_str == "RealList" )
-        value.first = Self::RealList;
-      else if( param_type_str == "IndexList" )
-        value.first = Self::IndexList;
-      else if( param_type_str == "PointList" )
-        value.first = Self::PointList;
-      else if( param_type_str == "VectorList" )
-        value.first = Self::VectorList;
-      else if( param_type_str == "Choices" )
-        value.first = Self::Choices;
-      else
-        value.first = Self::String;
-
+      value.first = Self::GetTypeFromString( param_type );
       this->m_Parameters[ param_name ] = value;
 
     } // fi
index d8a1f578bc9a7a1f532a4857ebae48cd2c6f26be..a2cb86105cc1b3c0b1e6267471aa015467be8594 100644 (file)
 
 #include <map>
 #include <ostream>
+#include <sstream>
 #include <string>
 #include <vector>
 
 #include <itkObject.h>
 #include <itkObjectFactory.h>
 
+// Some forward declarations
 class TiXmlElement;
 
+// -------------------------------------------------------------------------
+#define cpPlugins_Parameters_Configure( Y )                     \
+  void ConfigureAs##Y( const std::string& name )                \
+  {                                                             \
+    this->m_Parameters[ name ] = TParameter( Self::Y, "" );     \
+    this->Modified( );                                          \
+  }                                                             \
+  bool Has##Y( const std::string& name ) const                  \
+  {                                                             \
+    auto i = this->m_Parameters.find( name );                   \
+    if( i != this->m_Parameters.end( ) )                        \
+      return( i->second.first == Self::Y );                     \
+    else                                                        \
+      return( false );                                          \
+  }
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Parameters_GetSet( Y )                                \
+  T##Y Get##Y( const std::string& name ) const                          \
+  {                                                                     \
+    auto i = this->m_Parameters.find( name );                           \
+    if( i != this->m_Parameters.end( ) )                                \
+    {                                                                   \
+      if( i->second.first == Self::Y )                                  \
+      {                                                                 \
+        if( typeid( T##Y ) != typeid( std::string ) )                   \
+        {                                                               \
+          std::istringstream tok_str( i->second.second );               \
+          T##Y v;                                                       \
+          tok_str >> v;                                                 \
+          return( v );                                                  \
+        }                                                               \
+        else                                                            \
+        {                                                               \
+          const T##Y* ptr =                                             \
+            reinterpret_cast< const T##Y* >(                            \
+              &( i->second.second )                                     \
+              );                                                        \
+          return( *ptr );                                               \
+        }                                                               \
+      }                                                                 \
+    }                                                                   \
+    return( T##Y( 0 ) );                                                \
+  }                                                                     \
+  void Set##Y( const std::string& name, const T##Y& v )                 \
+  {                                                                     \
+    auto i = this->m_Parameters.find( name );                           \
+    if( i != this->m_Parameters.end( ) )                                \
+    {                                                                   \
+      if( i->second.first == Self::Y )                                  \
+      {                                                                 \
+        if( typeid( T##Y ) != typeid( std::string ) )                   \
+        {                                                               \
+          std::stringstream str;                                        \
+          str << v;                                                     \
+          i->second.second = str.str( );                                \
+        }                                                               \
+        else                                                            \
+          i->second.second =                                            \
+            *( reinterpret_cast< const std::string* >( &v ) );          \
+        this->Modified( );                                              \
+      }                                                                 \
+    }                                                                   \
+  }
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Parameters_GetSetList( Y )                            \
+  std::vector< T##Y > Get##Y##List( const std::string& name ) const     \
+  {                                                                     \
+    std::vector< T##Y > lst;                                            \
+    std::vector< std::string >* slst =                                  \
+      reinterpret_cast< std::vector< std::string >* >( &lst );          \
+    auto i = this->m_Parameters.find( name );                           \
+    if( i != this->m_Parameters.end( ) )                                \
+    {                                                                   \
+      if( i->second.first == Self::Y##List )                            \
+      {                                                                 \
+        std::istringstream str( i->second.second );                     \
+        std::string token;                                              \
+        while( std::getline( str, token, '#' ) )                        \
+        {                                                               \
+          if( typeid( T##Y ) != typeid( std::string ) )                 \
+          {                                                             \
+            std::istringstream tok_str( token );                        \
+            T##Y v;                                                     \
+            tok_str >> v;                                               \
+            lst.push_back( v );                                         \
+          }                                                             \
+          else                                                          \
+            slst->push_back( token );                                   \
+        }                                                               \
+      }                                                                 \
+    }                                                                   \
+    return( lst );                                                      \
+  }                                                                     \
+  void AddTo##Y##List( const std::string& name, const T##Y& v )         \
+  {                                                                     \
+    auto i = this->m_Parameters.find( name );                           \
+    if( i != this->m_Parameters.end( ) )                                \
+    {                                                                   \
+      if( i->second.first == Self::Y##List )                            \
+      {                                                                 \
+        std::stringstream str;                                          \
+        str << i->second.second << "#" << v;                            \
+        i->second.second = str.str( );                                  \
+      }                                                                 \
+    }                                                                   \
+  }                                                                     \
+  void Clear##Y##List( const std::string& name )                        \
+  {                                                                     \
+    auto i = this->m_Parameters.find( name );                           \
+    if( i != this->m_Parameters.end( ) )                                \
+    {                                                                   \
+      if( i->second.first == Self::Y##List )                            \
+        i->second.second = "";                                          \
+    }                                                                   \
+  }
+
 namespace cpPlugins
 {
   namespace Interface
@@ -33,12 +153,14 @@ namespace cpPlugins
 
       enum Type
       {
-        String     , Bool       , Int        ,
-        Uint       , Real       , Index      ,
-        Point      , Vector     , StringList ,
-        BoolList   , IntList    , UintList   ,
-        RealList   , IndexList  , PointList  ,
-        VectorList , Choices    , NoType
+        String       , Bool         , Int        ,
+        Uint         , Real         , Index      ,
+        Point        , Vector       , FileName   ,
+        PathName     , StringList   , BoolList   ,
+        IntList      , UintList     , RealList   ,
+        IndexList    , PointList    , VectorList ,
+        FileNameList , PathNameList , Choices   ,
+        NoType
       };
 
       typedef bool          TBool;
@@ -46,16 +168,56 @@ namespace cpPlugins
       typedef unsigned long TUint;
       typedef double        TReal;
       typedef std::string   TString;
+      typedef std::string   TFileName;
+      typedef std::string   TPathName;
 
-      typedef std::pair< Self::Type, TString > TParameter;
-      typedef std::map< TString, TParameter >  TParameters;
+      typedef std::pair< Self::Type, std::string > TParameter;
+      typedef std::map< std::string, TParameter >  TParameters;
 
     public:
       itkNewMacro( Self );
       itkTypeMacro( cpPlugins::Interface::Parameters, itk::Object );
 
+      cpPlugins_Parameters_Configure( String );
+      cpPlugins_Parameters_Configure( Bool );
+      cpPlugins_Parameters_Configure( Int );
+      cpPlugins_Parameters_Configure( Uint );
+      cpPlugins_Parameters_Configure( Real );
+      cpPlugins_Parameters_Configure( Index );
+      cpPlugins_Parameters_Configure( Point );
+      cpPlugins_Parameters_Configure( Vector );
+      cpPlugins_Parameters_Configure( FileName );
+      cpPlugins_Parameters_Configure( PathName );
+      cpPlugins_Parameters_Configure( StringList );
+      cpPlugins_Parameters_Configure( BoolList );
+      cpPlugins_Parameters_Configure( IntList );
+      cpPlugins_Parameters_Configure( UintList );
+      cpPlugins_Parameters_Configure( RealList );
+      cpPlugins_Parameters_Configure( IndexList );
+      cpPlugins_Parameters_Configure( PointList );
+      cpPlugins_Parameters_Configure( VectorList );
+      cpPlugins_Parameters_Configure( FileNameList );
+      cpPlugins_Parameters_Configure( PathNameList );
+      cpPlugins_Parameters_Configure( Choices );
+
+      cpPlugins_Parameters_GetSet( Bool );
+      cpPlugins_Parameters_GetSet( Int );
+      cpPlugins_Parameters_GetSet( Uint );
+      cpPlugins_Parameters_GetSet( Real );
+      cpPlugins_Parameters_GetSet( FileName );
+      cpPlugins_Parameters_GetSet( PathName );
+
+      cpPlugins_Parameters_GetSetList( String );
+      cpPlugins_Parameters_GetSetList( Bool );
+      cpPlugins_Parameters_GetSetList( Int );
+      cpPlugins_Parameters_GetSetList( Uint );
+      cpPlugins_Parameters_GetSetList( Real );
+      cpPlugins_Parameters_GetSetList( FileName );
+      cpPlugins_Parameters_GetSetList( PathName );
+
     public:
       // To impact pipeline
+      const TParameters& GetRawParameters( ) const;
       virtual ProcessObject* GetProcessObject( );
       virtual const ProcessObject* GetProcessObject( ) const;
       virtual void SetProcessObject( ProcessObject* v );
@@ -64,148 +226,87 @@ namespace cpPlugins
       // Parameters container configuration
       void Clear( );
 
-      void ConfigureAsString( const TString& name );
-      void ConfigureAsBool( const TString& name );
-      void ConfigureAsInt( const TString& name );
-      void ConfigureAsUint( const TString& name );
-      void ConfigureAsReal( const TString& name );
-      void ConfigureAsIndex( const TString& name );
-      void ConfigureAsPoint( const TString& name );
-      void ConfigureAsVector( const TString& name );
-      void ConfigureAsStringList( const TString& name );
-      void ConfigureAsBoolList( const TString& name );
-      void ConfigureAsIntList( const TString& name );
-      void ConfigureAsUintList( const TString& name );
-      void ConfigureAsRealList( const TString& name );
-      void ConfigureAsIndexList( const TString& name );
-      void ConfigureAsPointList( const TString& name );
-      void ConfigureAsVectorList( const TString& name );
-      void ConfigureAsChoices( const TString& name );
-      void ConfigureAsChoices(
-        const TString& name, const std::vector< TString >& choices
-        );
-
       // Get methods
-      void GetNames( std::vector< TString >& container ) const;
-      Type GetType( const TString& name ) const;
-
-      bool HasString( const TString& name ) const;
-      bool HasBool( const TString& name ) const;
-      bool HasInt( const TString& name ) const;
-      bool HasUint( const TString& name ) const;
-      bool HasReal( const TString& name ) const;
-      bool HasIndex( const TString& name ) const;
-      bool HasPoint( const TString& name ) const;
-      bool HasVector( const TString& name ) const;
-      bool HasStringList( const TString& name ) const;
-      bool HasBoolList( const TString& name ) const;
-      bool HasIntList( const TString& name ) const;
-      bool HasUintList( const TString& name ) const;
-      bool HasRealList( const TString& name ) const;
-      bool HasIndexList( const TString& name ) const;
-      bool HasPointList( const TString& name ) const;
-      bool HasVectorList( const TString& name ) const;
-      bool HasChoices( const TString& name ) const;
-
-      TString GetString( const TString& name, bool force = true ) const;
-      TBool GetBool( const TString& name ) const;
-      TInt GetInt( const TString& name ) const;
-      TUint GetUint( const TString& name ) const;
-      TReal GetReal( const TString& name ) const;
-
-      void GetStringList(
-        std::vector< TString >& lst, const TString& name
-        ) const;
-      void GetBoolList(
-        std::vector< TBool >& lst, const TString& name
-        ) const;
-      void GetIntList(
-        std::vector< TInt >& lst, const TString& name
-        ) const;
-      void GetUintList(
-        std::vector< TUint >& lst, const TString& name
+      void GetNames( std::vector< std::string >& container ) const;
+      Type GetType( const std::string& name ) const;
+      std::string GetTypeAsString( const std::string& name ) const;
+      static Type GetTypeFromString( const std::string& t );
+
+      // Base string methods
+      std::string GetString(
+        const std::string& name, bool force = true
         ) const;
-      void GetRealList(
-        std::vector< TReal >& lst, const TString& name
-        ) const;
-
-      void GetChoices(
-        std::vector< TString >& choices, const TString& name
-        ) const;
-      TString GetSelectedChoice( const TString& name ) const;
+      void SetString(
+        const std::string& name, const std::string& v, bool force = true
+        );
 
-      template< class I >
-        inline I GetIndex( const TString& name, const TUint& dim ) const;
-      template< class P >
-        inline P GetPoint( const TString& name, const TUint& dim ) const;
-      template< class V >
-        inline V GetVector( const TString& name, const TUint& dim ) const;
+      void ConfigureAsChoices(
+        const std::string& name, const std::vector< std::string >& choices
+        );
+      std::vector< std::string > GetChoices( const std::string& name ) const;
+      std::string GetSelectedChoice( const std::string& name ) const;
+      bool SetSelectedChoice(
+        const std::string& name, const std::string& choice
+        );
 
+      // Some templated methods
       template< class I >
-        inline void GetIndexList(
-          std::vector< I >& lst, const TString& name, const TUint& dim
+        I GetIndex(
+          const std::string& name, const unsigned int& dim
           ) const;
       template< class P >
-        inline void GetPointList(
-          std::vector< P >& lst, const TString& name, const TUint& dim
+        P GetPoint(
+          const std::string& name, const unsigned int& dim
           ) const;
       template< class V >
-        inline void GetVectorList(
-          std::vector< V >& lst, const TString& name, const TUint& dim
+        V GetVector(
+          const std::string& name, const unsigned int& dim
           ) const;
 
-      // Set methods
-      void SetString(
-        const TString& name, const TString& v, bool force = true
-        );
-      void SetBool( const TString& name, const TBool& v );
-      void SetInt( const TString& name, const TInt& v );
-      void SetUint( const TString& name, const TUint& v );
-      void SetReal( const TString& name, const TReal& v );
-
       template< class I >
-        inline void SetIndex(
-          const TString& name, const TUint& dim, const I& v
+        void SetIndex(
+          const std::string& name, const unsigned int& dim, const I& v
           );
       template< class P >
-        inline void SetPoint(
-          const TString& name, const TUint& dim, const P& v
+        void SetPoint(
+          const std::string& name, const unsigned int& dim, const P& v
           );
       template< class V >
-        inline void SetVector(
-          const TString& name, const TUint& dim, const V& v
+        void SetVector(
+          const std::string& name, const unsigned int& dim, const V& v
           );
 
-      void AddToStringList( const TString& name, const TString& v );
-      void AddToBoolList( const TString& name, const TBool& v );
-      void AddToIntList( const TString& name, const TInt& v );
-      void AddToUintList( const TString& name, const TUint& v );
-      void AddToRealList( const TString& name, const TReal& v );
+      template< class I >
+        std::vector< I > GetIndexList(
+          const std::string& name, const unsigned int& dim
+          ) const;
+      template< class P >
+        std::vector< P > GetPointList(
+          const std::string& name, const unsigned int& dim
+          ) const;
+      template< class V >
+        std::vector< V > GetVectorList(
+          const std::string& name, const unsigned int& dim
+          ) const;
 
       template< class I >
-        inline void AddToIndexList(
-          const TString& name, const TUint& dim, const I& v
+        void AddToIndexList(
+          const std::string& name, const unsigned int& dim, const I& v
           );
       template< class P >
-        inline void AddToPointList(
-          const TString& name, const TUint& dim, const P& v
+        void AddToPointList(
+          const std::string& name, const unsigned int& dim, const P& v
           );
       template< class P >
-        inline void AddToVectorList(
-          const TString& name, const TUint& dim, const P& v
+        void AddToVectorList(
+          const std::string& name, const unsigned int& dim, const P& v
           );
 
-      void ClearStringList( const TString& name );
-      void ClearBoolList( const TString& name );
-      void ClearIntList( const TString& name );
-      void ClearUintList( const TString& name );
-      void ClearRealList( const TString& name );
-      void ClearIndexList( const TString& name );
-      void ClearPointList( const TString& name );
-      void ClearVectorList( const TString& name );
-
-      bool SetSelectedChoice( const TString& name, const TString& choice );
+      void ClearIndexList( const std::string& name );
+      void ClearPointList( const std::string& name );
+      void ClearVectorList( const std::string& name );
 
+      // XML "streaming"
       bool ToXML( TiXmlElement* parent_elem ) const;
       bool FromXML( const TiXmlElement* filter_elem );
 
index d0fb9c27b1e2cb055286e8d1efb24dddfc329c99..eecb2b6b08ebb74d201324a7cd79ec6039e685a1 100644 (file)
@@ -4,10 +4,10 @@
 // -------------------------------------------------------------------------
 template< class I >
 I cpPlugins::Interface::Parameters::
-GetIndex( const TString& name, const TUint& dim ) const
+GetIndex( const std::string& name, const unsigned int& dim ) const
 {
   I v;
-  TParameters::const_iterator i = this->m_Parameters.find( name );
+  auto i = this->m_Parameters.find( name );
   if( i != this->m_Parameters.end( ) )
   {
     if( i->second.first == Self::Index )
@@ -36,10 +36,10 @@ GetIndex( const TString& name, const TUint& dim ) const
 // -------------------------------------------------------------------------
 template< class P >
 P cpPlugins::Interface::Parameters::
-GetPoint( const TString& name, const TUint& dim ) const
+GetPoint( const std::string& name, const unsigned int& dim ) const
 {
   P v;
-  TParameters::const_iterator i = this->m_Parameters.find( name );
+  auto i = this->m_Parameters.find( name );
   if( i != this->m_Parameters.end( ) )
   {
     if( i->second.first == Self::Point )
@@ -69,10 +69,10 @@ GetPoint( const TString& name, const TUint& dim ) const
 // -------------------------------------------------------------------------
 template< class V >
 V cpPlugins::Interface::Parameters::
-GetVector( const TString& name, const TUint& dim ) const
+GetVector( const std::string& name, const unsigned int& dim ) const
 {
   V v;
-  TParameters::const_iterator i = this->m_Parameters.find( name );
+  auto i = this->m_Parameters.find( name );
   if( i != this->m_Parameters.end( ) )
   {
     if( i->second.first == Self::Vector )
@@ -102,114 +102,7 @@ GetVector( const TString& name, const TUint& dim ) const
 // -------------------------------------------------------------------------
 template< class I >
 void cpPlugins::Interface::Parameters::
-GetIndexList(
-  std::vector< I >& lst, const TString& name, const TUint& dim
-  ) const
-{
-  lst.clear( );
-
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first == Self::IndexList )
-    return;
-
-  std::istringstream str( i->second.second );
-  std::string token;
-  unsigned int d = 0;
-  while( std::getline( str, token, '#' ) )
-  {
-    std::istringstream str2( token );
-    std::string token2;
-    unsigned int d = 0;
-    I v;
-    while( std::getline( str2, token2, ';' ) && d < dim )
-    {
-      v[ d ] = std::atoi( token.c_str( ) );
-      d++;
-
-    } // elihw
-    lst.push_back( v );
-
-  } // elihw
-}
-
-// -------------------------------------------------------------------------
-template< class P >
-void cpPlugins::Interface::Parameters::
-GetPointList(
-  std::vector< P >& lst, const TString& name, const TUint& dim
-  ) const
-{
-  lst.clear( );
-
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first == Self::PointList )
-    return;
-
-  std::istringstream str( i->second.second );
-  std::string token;
-  unsigned int d = 0;
-  while( std::getline( str, token, '#' ) )
-  {
-    std::istringstream str2( token );
-    std::string token2;
-    unsigned int d = 0;
-    P v;
-    while( std::getline( str2, token2, ';' ) && d < dim )
-    {
-      std::istringstream tok_str( token );
-      tok_str >> v[ d ];
-      d++;
-
-    } // elihw
-    lst.push_back( v );
-
-  } // elihw
-}
-
-// -------------------------------------------------------------------------
-template< class V >
-void cpPlugins::Interface::Parameters::
-GetVectorList(
-  std::vector< V >& lst, const TString& name, const TUint& dim
-  ) const
-{
-  lst.clear( );
-
-  TParameters::const_iterator i = this->m_Parameters.find( name );
-  if( i == this->m_Parameters.end( ) )
-    return;
-  if( i->second.first == Self::VectorList )
-    return;
-
-  std::istringstream str( i->second.second );
-  std::string token;
-  unsigned int d = 0;
-  while( std::getline( str, token, '#' ) )
-  {
-    std::istringstream str2( token );
-    std::string token2;
-    unsigned int d = 0;
-    V v;
-    while( std::getline( str2, token2, ';' ) && d < dim )
-    {
-      std::istringstream tok_str( token );
-      tok_str >> v[ d ];
-      d++;
-
-    } // elihw
-    lst.push_back( v );
-
-  } // elihw
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-SetIndex( const TString& name, const TUint& dim, const I& v )
+SetIndex( const std::string& name, const unsigned int& dim, const I& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -228,7 +121,7 @@ SetIndex( const TString& name, const TUint& dim, const I& v )
 // -------------------------------------------------------------------------
 template< class P >
 void cpPlugins::Interface::Parameters::
-SetPoint( const TString& name, const TUint& dim, const P& v )
+SetPoint( const std::string& name, const unsigned int& dim, const P& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -247,7 +140,7 @@ SetPoint( const TString& name, const TUint& dim, const P& v )
 // -------------------------------------------------------------------------
 template< class V >
 void cpPlugins::Interface::Parameters::
-SetVector( const TString& name, const TUint& dim, const V& v )
+SetVector( const std::string& name, const unsigned int& dim, const V& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -263,10 +156,122 @@ SetVector( const TString& name, const TUint& dim, const V& v )
   this->Modified( );
 }
 
+// -------------------------------------------------------------------------
+template< class I >
+std::vector< I > cpPlugins::Interface::Parameters::
+GetIndexList( const std::string& name, const unsigned int& dim ) const
+{
+  std::vector< I > lst;
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::IndexList )
+    {
+      std::istringstream str( i->second.second );
+      std::string token;
+      unsigned int d = 0;
+      while( std::getline( str, token, '#' ) )
+      {
+        std::istringstream str2( token );
+        std::string token2;
+        unsigned int d = 0;
+        I v;
+        while( std::getline( str2, token2, ';' ) && d < dim )
+        {
+          v[ d ] = std::atoi( token.c_str( ) );
+          d++;
+
+        } // elihw
+        lst.push_back( v );
+
+      } // elihw
+
+    } // fi
+
+  } // fi
+  return( lst );
+}
+
+// -------------------------------------------------------------------------
+template< class P >
+std::vector< P > cpPlugins::Interface::Parameters::
+GetPointList( const std::string& name, const unsigned int& dim ) const
+{
+  std::vector< P > lst;
+
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::PointList )
+    {
+      std::istringstream str( i->second.second );
+      std::string token;
+      unsigned int d = 0;
+      while( std::getline( str, token, '#' ) )
+      {
+        std::istringstream str2( token );
+        std::string token2;
+        unsigned int d = 0;
+        P v;
+        while( std::getline( str2, token2, ';' ) && d < dim )
+        {
+          std::istringstream tok_str( token );
+          tok_str >> v[ d ];
+          d++;
+
+        } // elihw
+        lst.push_back( v );
+
+      } // elihw
+
+    } // fi
+
+  } // fi
+  return( lst );
+}
+
+// -------------------------------------------------------------------------
+template< class V >
+std::vector< V > cpPlugins::Interface::Parameters::
+GetVectorList( const std::string& name, const unsigned int& dim ) const
+{
+  std::vector< V > lst;
+
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::VectorList )
+    {
+      std::istringstream str( i->second.second );
+      std::string token;
+      unsigned int d = 0;
+      while( std::getline( str, token, '#' ) )
+      {
+        std::istringstream str2( token );
+        std::string token2;
+        unsigned int d = 0;
+        V v;
+        while( std::getline( str2, token2, ';' ) && d < dim )
+        {
+          std::istringstream tok_str( token );
+          tok_str >> v[ d ];
+          d++;
+
+        } // elihw
+        lst.push_back( v );
+
+      } // elihw
+
+    } // fi
+
+  } // fi
+  return( lst );
+}
+
 // -------------------------------------------------------------------------
 template< class I >
 void cpPlugins::Interface::Parameters::
-AddToIndexList( const TString& name, const TUint& dim, const I& v )
+AddToIndexList( const std::string& name, const unsigned int& dim, const I& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -288,7 +293,7 @@ AddToIndexList( const TString& name, const TUint& dim, const I& v )
 // -------------------------------------------------------------------------
 template< class P >
 void cpPlugins::Interface::Parameters::
-AddToPointList( const TString& name, const TUint& dim, const P& v )
+AddToPointList( const std::string& name, const unsigned int& dim, const P& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
@@ -310,7 +315,7 @@ AddToPointList( const TString& name, const TUint& dim, const P& v )
 // -------------------------------------------------------------------------
 template< class V >
 void cpPlugins::Interface::Parameters::
-AddToVectorList( const TString& name, const TUint& dim, const V& v )
+AddToVectorList( const std::string& name, const unsigned int& dim, const V& v )
 {
   TParameters::iterator i = this->m_Parameters.find( name );
   if( i == this->m_Parameters.end( ) )
index 90393ffc9150fe4e3daebfc167b8374d123a9fb4..431ddfe9ab66ec023e40177779a4975534b0c4de 100644 (file)
@@ -14,6 +14,7 @@
 #include <QDoubleSpinBox>
 #include <QHBoxLayout>
 #include <QLineEdit>
+#include <QPushButton>
 #include <QWidget>
 
 // -------------------------------------------------------------------------
@@ -157,96 +158,163 @@ setParameters( Parameters* parameters )
   if( this->m_Parameters == NULL )
     return( false );
 
+  // Set dialog title
+  auto filter = this->m_Parameters->GetProcessObject( );
+  std::stringstream title;
+  title << "Parameters for \"" << filter->GetName( ) << "\"";
+  this->m_Title->setText( title.str( ).c_str( ) );
+
   // Put 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 )
+  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 );
-
     QWidget* w_input = NULL;
-    if( pt == Parameters::String )
+    switch( pIt->second.first )
+    {
+    case Parameters::String:
     {
       QLineEdit* v_string = new QLineEdit( this );
-      v_string->setText( "Enter some text!!!" );
+      v_string->setText( pIt->second.second.c_str( ) );
       w_input = v_string;
     }
-    else if( pt == Parameters::Bool )
+    break;
+    case Parameters::Bool:
     {
       QCheckBox* v_bool = new QCheckBox( this );
       v_bool->setText( "[ON/OFF]" );
-      v_bool->setChecked( this->m_Parameters->GetBool( *nIt ) );
+      v_bool->setChecked( pIt->second.second == "1" );
       w_input = v_bool;
     }
-    else if( pt == Parameters::Uint )
+    break;
+    case Parameters::Int:
+    case Parameters::Uint:
     {
+      std::istringstream tok_str( pIt->second.second );
+      int v;
+      tok_str >> v;
       QSpinBox* v_uint = new QSpinBox( this );
-      v_uint->setMinimum( 0 );
+      if( pIt->second.first == 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( this->m_Parameters->GetUint( *nIt ) );
+      v_uint->setValue( v );
       w_input = v_uint;
     }
-    else if( pt == Parameters::Int )
-    {
-      QSpinBox* v_int = new QSpinBox( this );
-      v_int->setMinimum( -std::numeric_limits< int >::max( ) );
-      v_int->setMaximum(  std::numeric_limits< int >::max( ) );
-      v_int->setValue( this->m_Parameters->GetInt( *nIt ) );
-      w_input = v_int;
-    }
-    else if( pt == Parameters::Real )
+    break;
+    case Parameters::Real:
     {
+      std::istringstream tok_str( pIt->second.second );
+      double v;
+      tok_str >> v;
       QDoubleSpinBox* v_double = new QDoubleSpinBox( this );
       v_double->setDecimals( 3 );
       v_double->setMinimum( -std::numeric_limits< double >::max( ) );
       v_double->setMaximum(  std::numeric_limits< double >::max( ) );
-      v_double->setValue( this->m_Parameters->GetReal( *nIt ) );
+      v_double->setValue( v );
       w_input = v_double;
     }
-    else if(
-      pt == Parameters::StringList ||
-      pt == Parameters::IntList ||
-      pt == Parameters::UintList ||
-      pt == Parameters::RealList
-      )
+    break;
+    case Parameters::Index:
+      break;
+    case Parameters::Point:
+      break;
+    case Parameters::Vector:
+      break;
+    case Parameters::FileName:
     {
-      cpPlugins::Interface::ParametersListWidget* l_double =
-        new cpPlugins::Interface::ParametersListWidget( *nIt, this );
-      w_input = l_double;
+      QFrame* frame = new QFrame( this );
+      QHBoxLayout* layout = new QHBoxLayout( frame );
+      QLineEdit* v_string = new QLineEdit( frame );
+      v_string->setText( pIt->second.second.c_str( ) );
+      QPushButton* v_button = new QPushButton( frame );
+      v_button->setObjectName( pIt->first.c_str( ) );
+      v_button->setText( "..." );
+      v_button->connect(
+        v_button, SIGNAL( clicked( ) ),
+        this, SLOT( _dlg_MultipleFiles( ) )
+        );
+
+      layout->addWidget( v_string );
+      layout->addWidget( v_button );
+      w_input = frame;
     }
-    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
+    break;
+    case Parameters::PathName:
+      break;
+    case Parameters::StringList:
+      break;
+    case Parameters::BoolList:
+      break;
+    case Parameters::IntList:
+      break;
+    case Parameters::UintList:
+      break;
+    case Parameters::RealList:
+      break;
+    case Parameters::IndexList:
+      break;
+    case Parameters::PointList:
+      break;
+    case Parameters::VectorList:
+      break;
+    case Parameters::FileNameList:
+      break;
+    case Parameters::PathNameList:
+      break;
+    case Parameters::Choices:
+      break;
+    default:
+      w_input = NULL;
+      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( nIt->c_str( ) ) );
+      w_input->setObjectName( QString( pIt->first.c_str( ) ) );
 
       QHBoxLayout* new_layout = new QHBoxLayout( );
       QLabel* label = new QLabel( this );
-      label->setText( QString( nIt->c_str( ) ) );
+      label->setText( QString( pIt->first.c_str( ) ) );
       new_layout->addWidget( label );
       new_layout->addWidget( w_input );
       this->m_ToolsLayout->addLayout( new_layout );
@@ -257,13 +325,6 @@ setParameters( Parameters* parameters )
   return( this->m_IsModal );
 }
 
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ParametersQtDialog::
-setTitle( const std::string& title )
-{
-  this->m_Title->setText( title.c_str( ) );
-}
-
 // -------------------------------------------------------------------------
 int cpPlugins::Interface::ParametersQtDialog::
 exec( )
@@ -392,7 +453,13 @@ syncParameters( )
   } // rof
 }
 
-
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+_dlg_MultipleFiles( )
+{
+  QObject* sender = this->sender( );
+  // std::cout << "OK " << sender << " " << sender->objectName( ).toStdString( ) << std::endl;
+}
 
 
 
index d19d31450323814a4ceec7f3ae11cd8d12110784..ee5c238fbcf74be29523faa0757c273410bd065c 100644 (file)
@@ -44,12 +44,14 @@ namespace cpPlugins
       TInteractors& getInteractors( );
       const TInteractors& getInteractors( ) const;
       bool setParameters( Parameters* parameters );
-      void setTitle( const std::string& title );
 
       virtual int exec( );
       virtual void show( );
       void syncParameters( );
 
+    protected slots:
+      void _dlg_MultipleFiles( );
+
     protected:
       Parameters* m_Parameters;
       QLabel* m_Title;
index 266b0ea1c7a94d97eed7cf8eacab9ca52e9a8b8d..fc010b81fac56ee6579e88beb9c4b838261eed36 100644 (file)
@@ -156,9 +156,11 @@ ExecConfigurationDialog( QWidget* parent )
   {
     if( this->m_ParametersDialog == NULL )
       this->m_ParametersDialog = new ParametersQtDialog( );
-    this->m_ParametersDialog->setTitle(
-      this->GetClassName( ) + std::string( " basic configuration" )
-      );
+    /* TODO
+       this->m_ParametersDialog->setTitle(
+       this->GetClassName( ) + std::string( " basic configuration" )
+       );
+    */
 
     this->m_ParametersDialog->setParent( NULL );
     this->m_ParametersDialog->setParameters( this->m_Parameters );
index 022f9faa0babc181feed2ff42cce0468cb5cbcd2..67eaf0a677b3937809c3f5431fc9023a68aea909 100644 (file)
@@ -292,58 +292,6 @@ GetExposedOutputPorts( ) const
   return( this->m_ExposedOutputPorts );
 }
 
-// -------------------------------------------------------------------------
-/* TODO
-cpPlugins::Interface::Workspace::
-TData* cpPlugins::Interface::Workspace::
-GetOutput( const std::string& name )
-{
-  auto port = this->m_ExposedOutputPorts.find( name );
-  if( port != this->m_ExposedOutputPorts.end( ) )
-  {
-    TFilter* f = this->GetFilter( port->second.first );
-    if( f != NULL )
-      return( f->GetOutput< TData >( port->second.second ) );
-    else
-      return( NULL );
-  }
-  else
-    return( NULL );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::Workspace::
-TData* cpPlugins::Interface::Workspace::
-GetOutput( const std::string& name ) const
-{
-  auto port = this->m_ExposedOutputPorts.find( name );
-  if( port != this->m_ExposedOutputPorts.end( ) )
-  {
-    const TFilter* f = this->GetFilter( port->second.first );
-    if( f != NULL )
-      return( f->GetOutput< TData >( port->second.second ) );
-    else
-      return( NULL );
-  }
-  else
-    return( NULL );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-ClearInputPorts( )
-{
-  this->m_ExposedInputPorts.clear( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Workspace::
-ClearOutputPorts( )
-{
-  this->m_ExposedOutputPorts.clear( );
-}
-*/
-
 // -------------------------------------------------------------------------
 std::string cpPlugins::Interface::Workspace::
 Execute( QWidget* p )
index 625838c08f6d8d353e139069e713a9b230d98586..51bc93708e844324918be8f7e5906b8696224e1d 100644 (file)
@@ -36,8 +36,8 @@ _GenerateData( )
   if( vtk_image == NULL )
     return( "MarchingCubes: Input does not have a valid VTK conversion." );
 
-  std::vector< double > values;
-  this->m_Parameters->GetRealList( values, "Thresholds" );
+  std::vector< double > values =
+    this->m_Parameters->GetRealList( "Thresholds" );
   vtkPolyData* pd = NULL;
   if( vtk_image->GetDataDimension( ) == 2 )
   {
index 17744fa4e38a48c5a1007c54800476b785a1f02d..e18c98709f58f2654e9b6f431a91b07c94941512 100644 (file)
@@ -4,51 +4,52 @@
 #include <itkImageFileReader.h>
 #include <itkImageSeriesReader.h>
 
-#ifdef cpPlugins_Interface_QT4
-#include <QFileDialog>
-#endif // cpPlugins_Interface_QT4
+/* TODO
+   #ifdef cpPlugins_Interface_QT4
+   #include <QFileDialog>
+   #endif // cpPlugins_Interface_QT4
 
-// -------------------------------------------------------------------------
-cpPlugins::IO::ImageReader::
-DialogResult cpPlugins::IO::ImageReader::
-ExecConfigurationDialog( QWidget* parent )
-{
-  DialogResult r = Self::DialogResult_Cancel;
+   // -------------------------------------------------------------------------
+   cpPlugins::IO::ImageReader::
+   DialogResult cpPlugins::IO::ImageReader::
+   ExecConfigurationDialog( QWidget* parent )
+   {
+   DialogResult r = Self::DialogResult_Cancel;
 
-#ifdef cpPlugins_Interface_QT4
+   #ifdef cpPlugins_Interface_QT4
 
-  QStringList filters;
-  filters
-    << "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)"
-    << "Any files (*)";
+   QStringList filters;
+   filters
+   << "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)"
+   << "Any files (*)";
 
-  std::vector< std::string > names;
-  this->m_Parameters->GetStringList( names, "FileNames" );
-  std::string name = ( names.size( ) > 0 )? names[ 0 ]: ".";
+   TStringList names = this->m_Parameters->GetFileNameList( "FileNames" );
+   std::string name = ( names.size( ) > 0 )? names[ 0 ]: ".";
 
-  // Show dialog and check if it was accepted
-  QFileDialog dialog( parent );
-  dialog.setFileMode( QFileDialog::ExistingFiles );
-  dialog.setDirectory( QFileDialog::tr( name.c_str( ) ) );
-  dialog.setNameFilters( filters );
-  dialog.setAcceptMode( QFileDialog::AcceptOpen );
-  if( dialog.exec( ) )
-  {
-    QStringList names = dialog.selectedFiles( );
-    QStringList::const_iterator qIt = names.begin( );
-    for( ; qIt != names.end( ); ++qIt )
-      this->m_Parameters->AddToStringList(
-        "FileNames", qIt->toStdString( )
-        );
-    this->m_Parameters->SetBool( "VectorType", false );
-    r = Self::DialogResult_NoModal;
+   // Show dialog and check if it was accepted
+   QFileDialog dialog( parent );
+   dialog.setFileMode( QFileDialog::ExistingFiles );
+   dialog.setDirectory( QFileDialog::tr( name.c_str( ) ) );
+   dialog.setNameFilters( filters );
+   dialog.setAcceptMode( QFileDialog::AcceptOpen );
+   if( dialog.exec( ) )
+   {
+   QStringList names = dialog.selectedFiles( );
+   QStringList::const_iterator qIt = names.begin( );
+   for( ; qIt != names.end( ); ++qIt )
+   this->m_Parameters->AddToStringList(
+   "FileNames", qIt->toStdString( )
+   );
+   this->m_Parameters->SetBool( "VectorType", false );
+   r = Self::DialogResult_NoModal;
 
-  } // fi
+   } // fi
 
-#endif // cpPlugins_Interface_QT4
+   #endif // cpPlugins_Interface_QT4
 
-  return( r );
-}
+   return( r );
+   }
+*/
 
 // -------------------------------------------------------------------------
 cpPlugins::IO::ImageReader::
@@ -57,7 +58,7 @@ ImageReader( )
 {
   this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
 
-  this->m_Parameters->ConfigureAsStringList( "FileNames" );
+  this->m_Parameters->ConfigureAsFileNameList( "FileNames" );
   this->m_Parameters->ConfigureAsBool( "VectorType" );
   this->m_Parameters->SetBool( "VectorType", false );
 }
@@ -73,8 +74,7 @@ std::string cpPlugins::IO::ImageReader::
 _GenerateData( )
 {
   // Get filenames
-  TStringList names;
-  this->m_Parameters->GetStringList( names, "FileNames" );
+  TStringList names = this->m_Parameters->GetFileNameList( "FileNames" );
 
   std::string r = "";
   if( names.size( ) >= 1 )
index 520ab940340cbd601e12b075aa894ad817924714..340c5dbcf51220fae6acce76041689ff5387e61a 100644 (file)
@@ -26,17 +26,14 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >         Pointer;
       typedef itk::SmartPointer< const Self >   ConstPointer;
 
-      typedef Superclass::TParameters TParameters;
-      typedef std::vector< TParameters::TString > TStringList;
+      typedef Superclass::TParameters    TParameters;
+      typedef std::vector< std::string > TStringList;
 
     public:
       itkNewMacro( Self );
       itkTypeMacro( ImageReader, cpPluginsInterfaceImageSource );
       cpPlugins_Id_Macro( cpPlugins::IO::ImageReader, IO );
 
-    public:
-      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
-
     protected:
       ImageReader( );
       virtual ~ImageReader( );
index 67b13905630c4ce567aef1d43d084789922ebc50..76ffd845a4c53d23151406bd44740a3b87dc1c80 100644 (file)
@@ -3,43 +3,45 @@
 
 #include <itkImageFileWriter.h>
 
-#ifdef cpPlugins_Interface_QT4
-#include <QFileDialog>
-#endif // cpPlugins_Interface_QT4
-
-// -------------------------------------------------------------------------
-cpPlugins::IO::ImageWriter::
-DialogResult cpPlugins::IO::ImageWriter::
-ExecConfigurationDialog( QWidget* parent )
-{
-  DialogResult r = Self::DialogResult_Cancel;
-
-#ifdef cpPlugins_Interface_QT4
-
-  std::string name = this->m_Parameters->GetString( "FileName" );
-  if( name == "" )
-    name = "save.mhd";
-
-  // Show dialog and check if it was accepted
-  QString qname =
-    QFileDialog::getSaveFileName(
-      parent,
-      QFileDialog::tr( "Save File" ),
-      QFileDialog::tr( name.c_str( ) ),
-      QFileDialog::tr( "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff);;Any file (*)")
-      );
-  name = qname.toStdString( );
-  if( name != "" )
-  {
-    this->m_Parameters->SetString( "FileName", name );
-    r = Self::DialogResult_NoModal;
-
-  } // fi
-
-#endif // cpPlugins_Interface_QT4
-
-  return( r );
-}
+/* TODO
+   #ifdef cpPlugins_Interface_QT4
+   #include <QFileDialog>
+   #endif // cpPlugins_Interface_QT4
+
+   // -------------------------------------------------------------------------
+   cpPlugins::IO::ImageWriter::
+   DialogResult cpPlugins::IO::ImageWriter::
+   ExecConfigurationDialog( QWidget* parent )
+   {
+   DialogResult r = Self::DialogResult_Cancel;
+
+   #ifdef cpPlugins_Interface_QT4
+
+   std::string name = this->m_Parameters->GetString( "FileName" );
+   if( name == "" )
+   name = "save.mhd";
+
+   // Show dialog and check if it was accepted
+   QString qname =
+   QFileDialog::getSaveFileName(
+   parent,
+   QFileDialog::tr( "Save File" ),
+   QFileDialog::tr( name.c_str( ) ),
+   QFileDialog::tr( "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff);;Any file (*)")
+   );
+   name = qname.toStdString( );
+   if( name != "" )
+   {
+   this->m_Parameters->SetString( "FileName", name );
+   r = Self::DialogResult_NoModal;
+
+   } // fi
+
+   #endif // cpPlugins_Interface_QT4
+
+   return( r );
+   }
+*/
 
 // -------------------------------------------------------------------------
 cpPlugins::IO::ImageWriter::
@@ -47,7 +49,7 @@ ImageWriter( )
   : Superclass( )
 {
   this->_AddInput( "Input" );
-  this->m_Parameters->ConfigureAsString( "FileName" );
+  this->m_Parameters->ConfigureAsFileName( "FileName" );
 }
 
 // -------------------------------------------------------------------------
@@ -112,7 +114,7 @@ std::string cpPlugins::IO::ImageWriter::
 _RealGD( itk::DataObject* image )
 {
   // Get filename
-  std::string fname = this->m_Parameters->GetString( "FileName" );
+  std::string fname = this->m_Parameters->GetFileName( "FileName" );
 
   typedef itk::ImageFileWriter< I > _W;
   _W* writer = this->_CreateITK< _W >( );
index 0dd3a2532dfbb3b6ef36efd0bfd35fedf8863a22..bfde61b5c40904363e5f423c9cc84dfb8dd4ec4a 100644 (file)
@@ -24,9 +24,6 @@ namespace cpPlugins
       itkTypeMacro( ImageWriter, cpPluginsInterfaceImageSink );
       cpPlugins_Id_Macro( cpPlugins::IO::ImageWriter, IO );
 
-    public:
-      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
-
     protected:
       ImageWriter( );
       virtual ~ImageWriter( );
@@ -34,7 +31,7 @@ namespace cpPlugins
       virtual std::string _GenerateData( );
 
       /*
-       * These two methods are Microsort courtesy: inner loop error !
+       * These two methods are Micro$oft courtesy: inner loop error !
        */
       template< unsigned int D >
         inline std::string _GD0_Image( );
index 35b95d4cc81909ddb0e603e05e712380ba67c377..cfcd51240f5dcd452838a3021147fba7721e8405 100644 (file)
@@ -4,6 +4,7 @@
 #include <vtkPolyData.h>
 #include <vtkPolyDataReader.h>
 
+/* TODO
 #ifdef cpPlugins_Interface_QT4
 #include <QFileDialog>
 #endif // cpPlugins_Interface_QT4
@@ -37,6 +38,7 @@ ExecConfigurationDialog( QWidget* parent )
 
   return( r );
 }
+*/
 
 // -------------------------------------------------------------------------
 cpPlugins::IO::MeshReader::
@@ -48,7 +50,7 @@ MeshReader( )
   std::vector< TParameters::TString > valid_types;
   valid_types.push_back( "float" );
   valid_types.push_back( "double" );
-  this->m_Parameters->ConfigureAsString( "FileName" );
+  this->m_Parameters->ConfigureAsFileName( "FileName" );
   this->m_Parameters->ConfigureAsChoices( "PixelType", valid_types );
   this->m_Parameters->ConfigureAsUint( "Dimension" );
 
@@ -95,7 +97,7 @@ std::string cpPlugins::IO::MeshReader::
 _GD1( )
 {
   // Get filename
-  std::string fname = this->m_Parameters->GetString( "FileName" );
+  std::string fname = this->m_Parameters->GetFileName( "FileName" );
 
   vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( );
   pdr->SetFileName( fname.c_str( ) );
index c26c3ae64764ec7dd26c23ad7a50134debebd564..48c116413ec03142e9c015dfb811a342e8a3a281 100644 (file)
@@ -26,9 +26,6 @@ namespace cpPlugins
       itkTypeMacro( MeshReader, cpPluginsInterfaceMeshSource );
       cpPlugins_Id_Macro( cpPlugins::IO::MeshReader, IO );
 
-    public:
-      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
-
     protected:
       MeshReader( );
       virtual ~MeshReader( );
index e3408b25d6b75d68a706f698c4f51f565316e35b..e45367d79676e80209f6527dfb928296ae6a1b35 100644 (file)
@@ -5,43 +5,45 @@
 #include <vtkPolyData.h>
 #include <vtkPolyDataWriter.h>
 
-#ifdef cpPlugins_Interface_QT4
-#include <QFileDialog>
-#endif // cpPlugins_Interface_QT4
+/* TODO
+   #ifdef cpPlugins_Interface_QT4
+   #include <QFileDialog>
+   #endif // cpPlugins_Interface_QT4
 
-// -------------------------------------------------------------------------
-cpPlugins::IO::MeshWriter::
-DialogResult cpPlugins::IO::MeshWriter::
-ExecConfigurationDialog( QWidget* parent )
-{
-  DialogResult r = Self::DialogResult_Cancel;
-
-#ifdef cpPlugins_Interface_QT4
+   // -------------------------------------------------------------------------
+   cpPlugins::IO::MeshWriter::
+   DialogResult cpPlugins::IO::MeshWriter::
+   ExecConfigurationDialog( QWidget* parent )
+   {
+   DialogResult r = Self::DialogResult_Cancel;
 
-  std::string name = this->m_Parameters->GetString( "FileName" );
-  if( name == "" )
-    name = "save.vtk";
+   #ifdef cpPlugins_Interface_QT4
 
-  // Show dialog and check if it was accepted
-  QString qname =
-    QFileDialog::getSaveFileName(
-      parent,
-      QFileDialog::tr( "Save File" ),
-      QFileDialog::tr( name.c_str( ) ),
-      QFileDialog::tr( "Mesh files (*.vtk *.stl *.obj);;Any file (*)")
-      );
-  name = qname.toStdString( );
-  if( name != "" )
-  {
-    this->m_Parameters->SetString( "FileName", name );
-    r = Self::DialogResult_NoModal;
-
-  } // fi
-
-#endif // cpPlugins_Interface_QT4
-
-  return( r );
-}
+   std::string name = this->m_Parameters->GetString( "FileName" );
+   if( name == "" )
+   name = "save.vtk";
+   
+   // Show dialog and check if it was accepted
+   QString qname =
+   QFileDialog::getSaveFileName(
+   parent,
+   QFileDialog::tr( "Save File" ),
+   QFileDialog::tr( name.c_str( ) ),
+   QFileDialog::tr( "Mesh files (*.vtk *.stl *.obj);;Any file (*)")
+   );
+   name = qname.toStdString( );
+   if( name != "" )
+   {
+   this->m_Parameters->SetString( "FileName", name );
+   r = Self::DialogResult_NoModal;
+   
+   } // fi
+   
+   #endif // cpPlugins_Interface_QT4
+   
+   return( r );
+   }
+*/
 
 // -------------------------------------------------------------------------
 cpPlugins::IO::MeshWriter::
@@ -49,7 +51,7 @@ MeshWriter( )
   : Superclass( )
 {
   this->_AddInput( "Input" );
-  this->m_Parameters->ConfigureAsString( "FileName" );
+  this->m_Parameters->ConfigureAsFileName( "FileName" );
 }
 
 // -------------------------------------------------------------------------
@@ -69,7 +71,7 @@ _GenerateData( )
   vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
   if( i == NULL )
     return( "MeshWriter: No suitable input." );
-  std::string fname = this->m_Parameters->GetString( "FileName" );
+  std::string fname = this->m_Parameters->GetFileName( "FileName" );
 
   vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( );
   pdw->SetInputData( i );
index 2dc64a64413d8eabec0af8653a6930312b5700ff..c1f4a7e598bae7af3bcafcb42a00c061610063da 100644 (file)
@@ -26,9 +26,6 @@ namespace cpPlugins
       itkTypeMacro( MeshWriter, cpPluginsInterfaceMeshSink );
       cpPlugins_Id_Macro( cpPlugins::IO::MeshWriter, IO );
 
-    public:
-      virtual DialogResult ExecConfigurationDialog( QWidget* parent );
-
     protected:
       MeshWriter( );
       virtual ~MeshWriter( );