X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FParameters.cxx;h=2e6d36c88b8aba369d36421c22907b47baf296f2;hb=6ffc11d77924d6ab7e94db95d41105982ac73e00;hp=e6db0e3541a6246665dbb91915e69371f723da5a;hpb=273699a71c538630c162de031f0c95014319311d;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/Parameters.cxx b/lib/cpPlugins/Interface/Parameters.cxx index e6db0e3..2e6d36c 100644 --- a/lib/cpPlugins/Interface/Parameters.cxx +++ b/lib/cpPlugins/Interface/Parameters.cxx @@ -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 ); }