]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/BaseObjects/Parameters.cxx
..
[cpPlugins.git] / lib / cpPlugins / BaseObjects / Parameters.cxx
index e77c2cc16475cd0d77e68d320544ad8919130e34..cfb5f83b220aaa3b0a8488887932aa2df34c8deb 100644 (file)
@@ -1,10 +1,12 @@
 #include <cpPlugins/BaseObjects/Parameters.h>
-#include <cpExtensions/Utility.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+#include <cpPlugins/Utility.h>
 #include <tinyxml2/tinyxml2.h>
 
 // -------------------------------------------------------------------------
 cpPlugins::BaseObjects::Parameters::
 Parameters( )
+  : m_ProcessObject( NULL )
 {
   this->Clear( );
 }
@@ -15,18 +17,34 @@ cpPlugins::BaseObjects::Parameters::
 {
 }
 
+// -------------------------------------------------------------------------
+cpPlugins::BaseObjects::ProcessObject* cpPlugins::BaseObjects::Parameters::
+GetProcessObject( )
+{
+  return( this->m_ProcessObject );
+}
+
+// -------------------------------------------------------------------------
+const
+cpPlugins::BaseObjects::ProcessObject* cpPlugins::BaseObjects::Parameters::
+GetProcessObject( ) const
+{
+  return( this->m_ProcessObject );
+}
+
 // -------------------------------------------------------------------------
 void cpPlugins::BaseObjects::Parameters::
-Modified( ) const
+SetProcessObject( cpPlugins::BaseObjects::ProcessObject* po )
 {
-  this->m_TimeStamp.Modified( );
+  this->m_ProcessObject = po;
 }
 
 // -------------------------------------------------------------------------
-itk::ModifiedTimeType cpPlugins::BaseObjects::Parameters::
-GetMTime( ) const
+void cpPlugins::BaseObjects::Parameters::
+Modified( ) const
 {
-  return( this->m_TimeStamp.GetMTime( ) );
+  if( this->m_ProcessObject != NULL )
+    this->m_ProcessObject->Modified( );
 }
 
 // -------------------------------------------------------------------------
@@ -174,6 +192,50 @@ ConfigureAsChoices(
   this->Modified( );
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::BaseObjects::Parameters::
+ConfigureAsRealTypesChoices( const std::string& name )
+{
+  std::vector< std::string > choices;
+  choices.push_back( "float" );
+  choices.push_back( "double" );
+  this->ConfigureAsChoices( name, choices );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseObjects::Parameters::
+ConfigureAsIntTypesChoices( const std::string& name )
+{
+  std::vector< std::string > choices;
+  choices.push_back( "char" );
+  choices.push_back( "uchar" );
+  choices.push_back( "short" );
+  choices.push_back( "ushort" );
+  choices.push_back( "int" );
+  choices.push_back( "uint" );
+  choices.push_back( "long" );
+  choices.push_back( "ulong" );
+  this->ConfigureAsChoices( name, choices );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseObjects::Parameters::
+ConfigureAsScalarTypesChoices( const std::string& name )
+{
+  std::vector< std::string > choices;
+  choices.push_back( "char" );
+  choices.push_back( "uchar" );
+  choices.push_back( "short" );
+  choices.push_back( "ushort" );
+  choices.push_back( "int" );
+  choices.push_back( "uint" );
+  choices.push_back( "long" );
+  choices.push_back( "ulong" );
+  choices.push_back( "float" );
+  choices.push_back( "double" );
+  this->ConfigureAsChoices( name, choices );
+}
+
 // -------------------------------------------------------------------------
 std::vector< std::string > cpPlugins::BaseObjects::Parameters::
 GetChoices( const std::string& name ) const
@@ -349,12 +411,24 @@ GetRawParameters( ) const
 // -------------------------------------------------------------------------
 #define cpPlugins_BaseObjects_Parameters_Configure_Code( Y )            \
   void cpPlugins::BaseObjects::Parameters::                             \
-  ConfigureAs##Y( const std::string& name )                             \
-  { this->_Configure< Y >( name ); }                                    \
+  ConfigureAs##Y( const std::string& name, const T##Y& init )           \
+  {                                                                     \
+    this->_Configure< Y >( name );                                      \
+    this->Set##Y( name, init );                                         \
+  }                                                                     \
   bool cpPlugins::BaseObjects::Parameters::                             \
   Has##Y( const std::string& name ) const                               \
   { return( this->_Has< Y >( name ) ); }
 
+// -------------------------------------------------------------------------
+#define cpPlugins_BaseObjects_Parameters_ConfigureList_Code( Y )        \
+  void cpPlugins::BaseObjects::Parameters::                             \
+  ConfigureAs##Y##List( const std::string& name )                       \
+  { this->_Configure< Y##List >( name ); }                              \
+  bool cpPlugins::BaseObjects::Parameters::                             \
+  Has##Y##List( const std::string& name ) const                         \
+  { return( this->_Has< Y##List >( name ) ); }
+
 // -------------------------------------------------------------------------
 #define cpPlugins_BaseObjects_Parameters_GetSet_Code( Y )               \
   cpPlugins::BaseObjects::Parameters::T##Y                              \
@@ -390,15 +464,16 @@ cpPlugins_BaseObjects_Parameters_Configure_Code( Real );
 cpPlugins_BaseObjects_Parameters_Configure_Code( OpenFileName );
 cpPlugins_BaseObjects_Parameters_Configure_Code( SaveFileName );
 cpPlugins_BaseObjects_Parameters_Configure_Code( PathName );
-cpPlugins_BaseObjects_Parameters_Configure_Code( StringList );
-cpPlugins_BaseObjects_Parameters_Configure_Code( BoolList );
-cpPlugins_BaseObjects_Parameters_Configure_Code( IntList );
-cpPlugins_BaseObjects_Parameters_Configure_Code( UintList );
-cpPlugins_BaseObjects_Parameters_Configure_Code( RealList );
-cpPlugins_BaseObjects_Parameters_Configure_Code( OpenFileNameList );
-cpPlugins_BaseObjects_Parameters_Configure_Code( SaveFileNameList );
-cpPlugins_BaseObjects_Parameters_Configure_Code( PathNameList );
-cpPlugins_BaseObjects_Parameters_Configure_Code( Choices );
+
+cpPlugins_BaseObjects_Parameters_ConfigureList_Code( String );
+cpPlugins_BaseObjects_Parameters_ConfigureList_Code( Bool );
+cpPlugins_BaseObjects_Parameters_ConfigureList_Code( Int );
+cpPlugins_BaseObjects_Parameters_ConfigureList_Code( Uint );
+cpPlugins_BaseObjects_Parameters_ConfigureList_Code( Real );
+cpPlugins_BaseObjects_Parameters_ConfigureList_Code( OpenFileName );
+cpPlugins_BaseObjects_Parameters_ConfigureList_Code( SaveFileName );
+cpPlugins_BaseObjects_Parameters_ConfigureList_Code( PathName );
+
 cpPlugins_BaseObjects_Parameters_GetSet_Code( Bool );
 cpPlugins_BaseObjects_Parameters_GetSet_Code( Int );
 cpPlugins_BaseObjects_Parameters_GetSet_Code( Uint );
@@ -406,15 +481,92 @@ cpPlugins_BaseObjects_Parameters_GetSet_Code( Real );
 cpPlugins_BaseObjects_Parameters_GetSet_Code( OpenFileName );
 cpPlugins_BaseObjects_Parameters_GetSet_Code( SaveFileName );
 cpPlugins_BaseObjects_Parameters_GetSet_Code( PathName );
+
 cpPlugins_BaseObjects_Parameters_GetSetList_Code( String );
 cpPlugins_BaseObjects_Parameters_GetSetList_Code( Bool );
 cpPlugins_BaseObjects_Parameters_GetSetList_Code( Int );
 cpPlugins_BaseObjects_Parameters_GetSetList_Code( Uint );
 cpPlugins_BaseObjects_Parameters_GetSetList_Code( Real );
-cpPlugins_BaseObjects_Parameters_GetSetList_Code( OpenFileName );
-cpPlugins_BaseObjects_Parameters_GetSetList_Code( SaveFileName );
 cpPlugins_BaseObjects_Parameters_GetSetList_Code( PathName );
 
+// -------------------------------------------------------------------------
+std::vector< cpPlugins::BaseObjects::Parameters::TOpenFileName >
+cpPlugins::BaseObjects::Parameters::
+GetOpenFileNameList( const std::string& name ) const
+{
+  return( this->_GetList< TOpenFileName, OpenFileNameList >( name ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseObjects::Parameters::
+AddToOpenFileNameList(
+  const std::string& name,
+  const cpPlugins::BaseObjects::Parameters::TOpenFileName& v
+  )
+{
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == OpenFileNameList )
+    {
+      auto pos = v.find_last_of( "/\\" );
+      if( i->second.second == "" )
+        i->second.second = v.substr( 0, pos );
+      i->second.second += std::string( "#" );
+      i->second.second += v.substr( pos + 1 );
+      this->Modified( );
+
+    } // fi
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseObjects::Parameters::
+ClearOpenFileNameList( const std::string& name )
+{
+  this->_ClearList< OpenFileNameList >( name );
+}
+
+// -------------------------------------------------------------------------
+std::vector< cpPlugins::BaseObjects::Parameters::TSaveFileName >
+cpPlugins::BaseObjects::Parameters::
+GetSaveFileNameList( const std::string& name ) const
+{
+  return( this->_GetList< TSaveFileName, SaveFileNameList >( name ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseObjects::Parameters::
+AddToSaveFileNameList(
+  const std::string& name,
+  const cpPlugins::BaseObjects::Parameters::TSaveFileName& v
+  )
+{
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == SaveFileNameList )
+    {
+      auto pos = v.find_last_of( "/\\" );
+      if( i->second.second == "" )
+        i->second.second = v.substr( 0, pos );
+      i->second.second += std::string( "#" );
+      i->second.second += v.substr( pos + 1 );
+      this->Modified( );
+
+    } // fi
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseObjects::Parameters::
+ClearSaveFileNameList( const std::string& name )
+{
+  this->_ClearList< SaveFileNameList >( name );
+}
+
 // -------------------------------------------------------------------------
 template< unsigned int _Enum >
 void cpPlugins::BaseObjects::Parameters::
@@ -520,7 +672,7 @@ _GetList( const std::string& name ) const
     if( i->second.first == ( Self::Type )( _Enum ) )
     {
       std::vector< std::string > tokens;
-      cpExtensions::Tokenize( tokens, i->second.second, "#" );
+      cpPlugins::Tokenize( tokens, i->second.second, "#" );
       for( auto t = tokens.begin( ); t != tokens.end( ); ++t )
       {
         if( typeid( _Type ) != typeid( std::string ) )