]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Parameters.cxx
MAC compilation issues solved... Now some tests please
[cpPlugins.git] / lib / cpPlugins / Interface / Parameters.cxx
index e6db0e3541a6246665dbb91915e69371f723da5a..2e6d36c88b8aba369d36421c22907b47baf296f2 100644 (file)
@@ -22,7 +22,12 @@ GetProcessObject( ) const
 void cpPlugins::Interface::Parameters::
 SetProcessObject( ProcessObject* v )
 {
-  this->m_Process = v;
+  if( this->m_Process != v )
+  {
+    this->m_Process = v;
+    this->Modified( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -147,8 +152,12 @@ SetString( const std::string& name, const std::string& v, bool force )
   {
     if( i->second.first == Self::String || force )
     {
-      i->second.second = v;
-      this->Modified( );
+      if( i->second.second != v )
+      {
+        i->second.second = v;
+        this->Modified( );
+
+      } // fi
 
     } // fi
 
@@ -239,6 +248,7 @@ SetSelectedChoice( const std::string& name, const std::string& choice )
         std::stringstream new_choices;
         new_choices << choices << "@" << choice;
         i->second.second = new_choices.str( );
+        this->Modified( );
         return( true );
       }
       else
@@ -251,6 +261,36 @@ SetSelectedChoice( const std::string& name, const std::string& choice )
     return( false );
 }
 
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Parameters::
+GetAcceptedFileExtensions( const std::string& name ) const
+{
+  auto i = this->m_AcceptedFileExtensions.find( name );
+  if( i != this->m_AcceptedFileExtensions.end( ) )
+    return( i->second );
+  else
+    return( "" );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Parameters::
+SetAcceptedFileExtensions(
+  const std::string& name, const std::string& extensions
+  )
+{
+  auto i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    bool is_valid = ( i->second.first == Self::OpenFileName );
+    is_valid     |= ( i->second.first == Self::SaveFileName );
+    is_valid     |= ( i->second.first == Self::OpenFileNameList );
+    is_valid     |= ( i->second.first == Self::SaveFileNameList );
+    if( is_valid )
+      this->m_AcceptedFileExtensions[ name ] = extensions;
+
+  } // fi
+}
+
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Parameters::
 ToXML( TiXmlElement* parent_elem ) const
@@ -275,8 +315,6 @@ ToXML( TiXmlElement* parent_elem ) const
 bool cpPlugins::Interface::Parameters::
 FromXML( const TiXmlElement* filter_elem )
 {
-  this->m_Parameters.clear( );
-
   const TiXmlElement* param = filter_elem->FirstChildElement( "parameter" );
   bool ret = false;
   while( param != NULL )
@@ -295,6 +333,7 @@ FromXML( const TiXmlElement* filter_elem )
     ret = true;
 
   } // elihw
+  this->Modified( );
   return( ret );
 }