]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/Parameters.h
MAC compilation issues solved... Now some tests please
[cpPlugins.git] / lib / cpPlugins / Interface / Parameters.h
index a2cb86105cc1b3c0b1e6267471aa015467be8594..3bf5d0140b8d068e36765a26208599dd0e284e6f 100644 (file)
@@ -70,12 +70,22 @@ class TiXmlElement;
         {                                                               \
           std::stringstream str;                                        \
           str << v;                                                     \
-          i->second.second = str.str( );                                \
+          if( i->second.second != str.str( ) )                          \
+          {                                                             \
+            i->second.second = str.str( );                              \
+            this->Modified( );                                          \
+          }                                                             \
         }                                                               \
         else                                                            \
-          i->second.second =                                            \
-            *( reinterpret_cast< const std::string* >( &v ) );          \
-        this->Modified( );                                              \
+        {                                                               \
+          const std::string* str =                                      \
+            reinterpret_cast< const std::string* >( &v );               \
+          if( i->second.second != *str )                                \
+          {                                                             \
+            i->second.second = *str;                                    \
+            this->Modified( );                                          \
+          }                                                             \
+        }                                                               \
       }                                                                 \
     }                                                                   \
   }
@@ -118,8 +128,11 @@ class TiXmlElement;
       if( i->second.first == Self::Y##List )                            \
       {                                                                 \
         std::stringstream str;                                          \
-        str << i->second.second << "#" << v;                            \
+        if( i->second.second != "" )                                    \
+          str << i->second.second << "#";                               \
+        str << v;                                                       \
         i->second.second = str.str( );                                  \
+        this->Modified( );                                              \
       }                                                                 \
     }                                                                   \
   }                                                                     \
@@ -129,7 +142,13 @@ class TiXmlElement;
     if( i != this->m_Parameters.end( ) )                                \
     {                                                                   \
       if( i->second.first == Self::Y##List )                            \
-        i->second.second = "";                                          \
+      {                                                                 \
+        if( i->second.second != "" )                                    \
+        {                                                               \
+          i->second.second = "";                                        \
+          this->Modified( );                                            \
+        }                                                               \
+      }                                                                 \
     }                                                                   \
   }
 
@@ -139,12 +158,15 @@ namespace cpPlugins
   {
     // Some forward declarations
     class ProcessObject;
+    class ParametersQtDialog;
 
     /**
      */
     class cpPlugins_Interface_EXPORT Parameters
       : public itk::Object
     {
+      friend class ParametersQtDialog;
+
     public:
       typedef Parameters                      Self;
       typedef itk::Object                     Superclass;
@@ -153,14 +175,12 @@ namespace cpPlugins
 
       enum Type
       {
-        String       , Bool         , Int        ,
-        Uint         , Real         , Index      ,
-        Point        , Vector       , FileName   ,
-        PathName     , StringList   , BoolList   ,
-        IntList      , UintList     , RealList   ,
-        IndexList    , PointList    , VectorList ,
-        FileNameList , PathNameList , Choices   ,
-        NoType
+        String       , Bool             , Int              ,
+        Uint         , Real             , OpenFileName     ,
+        SaveFileName , PathName         , StringList       ,
+        BoolList     , IntList          , UintList         ,
+        RealList     , OpenFileNameList , SaveFileNameList ,
+        PathNameList , Choices          , NoType
       };
 
       typedef bool          TBool;
@@ -168,7 +188,8 @@ namespace cpPlugins
       typedef unsigned long TUint;
       typedef double        TReal;
       typedef std::string   TString;
-      typedef std::string   TFileName;
+      typedef std::string   TOpenFileName;
+      typedef std::string   TSaveFileName;
       typedef std::string   TPathName;
 
       typedef std::pair< Self::Type, std::string > TParameter;
@@ -183,20 +204,16 @@ namespace cpPlugins
       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( OpenFileName );
+      cpPlugins_Parameters_Configure( SaveFileName );
       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( OpenFileNameList );
+      cpPlugins_Parameters_Configure( SaveFileNameList );
       cpPlugins_Parameters_Configure( PathNameList );
       cpPlugins_Parameters_Configure( Choices );
 
@@ -204,7 +221,8 @@ namespace cpPlugins
       cpPlugins_Parameters_GetSet( Int );
       cpPlugins_Parameters_GetSet( Uint );
       cpPlugins_Parameters_GetSet( Real );
-      cpPlugins_Parameters_GetSet( FileName );
+      cpPlugins_Parameters_GetSet( OpenFileName );
+      cpPlugins_Parameters_GetSet( SaveFileName );
       cpPlugins_Parameters_GetSet( PathName );
 
       cpPlugins_Parameters_GetSetList( String );
@@ -212,12 +230,12 @@ namespace cpPlugins
       cpPlugins_Parameters_GetSetList( Int );
       cpPlugins_Parameters_GetSetList( Uint );
       cpPlugins_Parameters_GetSetList( Real );
-      cpPlugins_Parameters_GetSetList( FileName );
+      cpPlugins_Parameters_GetSetList( OpenFileName );
+      cpPlugins_Parameters_GetSetList( SaveFileName );
       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 );
@@ -249,62 +267,10 @@ namespace cpPlugins
         const std::string& name, const std::string& choice
         );
 
-      // Some templated methods
-      template< class I >
-        I GetIndex(
-          const std::string& name, const unsigned int& dim
-          ) const;
-      template< class P >
-        P GetPoint(
-          const std::string& name, const unsigned int& dim
-          ) const;
-      template< class V >
-        V GetVector(
-          const std::string& name, const unsigned int& dim
-          ) const;
-
-      template< class I >
-        void SetIndex(
-          const std::string& name, const unsigned int& dim, const I& v
-          );
-      template< class P >
-        void SetPoint(
-          const std::string& name, const unsigned int& dim, const P& v
-          );
-      template< class V >
-        void SetVector(
-          const std::string& name, const unsigned int& dim, const V& 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 >
-        void AddToIndexList(
-          const std::string& name, const unsigned int& dim, const I& v
-          );
-      template< class P >
-        void AddToPointList(
-          const std::string& name, const unsigned int& dim, const P& v
-          );
-      template< class P >
-        void AddToVectorList(
-          const std::string& name, const unsigned int& dim, const P& v
-          );
-
-      void ClearIndexList( const std::string& name );
-      void ClearPointList( const std::string& name );
-      void ClearVectorList( const std::string& name );
+      std::string GetAcceptedFileExtensions( const std::string& name ) const;
+      void SetAcceptedFileExtensions(
+        const std::string& name, const std::string& extensions
+        );
 
       // XML "streaming"
       bool ToXML( TiXmlElement* parent_elem ) const;
@@ -315,22 +281,24 @@ namespace cpPlugins
       virtual ~Parameters( );
       void PrintSelf( std::ostream& os, itk::Indent indent ) const;
 
+      TParameters& GetRawParameters( );
+      const TParameters& GetRawParameters( ) const;
+
     private:
       // Purposely not implemented
       Parameters( const Self& other );
       Self& operator=( const Self& other );
 
     protected:
-      TParameters m_Parameters;
-      ProcessObject* m_Process;
+      TParameters                          m_Parameters;
+      std::map< std::string, std::string > m_AcceptedFileExtensions;
+      ProcessObject*                       m_Process;
     };
 
   } // ecapseman
 
 } // ecapseman
 
-#include <cpPlugins/Interface/Parameters.hxx>
-
 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__H__
 
 // eof - $RCSfile$