]> Creatis software - cpPlugins.git/commitdiff
Widget integration (step 5/6): Interactive plugins now supported, widgets updates...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 9 Oct 2015 23:34:23 +0000 (18:34 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 9 Oct 2015 23:34:23 +0000 (18:34 -0500)
27 files changed:
appli/ImageMPR/CMakeLists.txt
appli/ImageMPR/MementoState.cxx
appli/examples/CMakeLists.txt
appli/examples/example_TestParameters.cxx
appli/examples/example_TestQuadSplitter.cxx [new file with mode: 0644]
lib/cpExtensions/CMakeLists.txt
lib/cpExtensions/Config.h.in [new file with mode: 0644]
lib/cpExtensions/QT/QuadSplitter.cxx [new file with mode: 0644]
lib/cpExtensions/QT/QuadSplitter.h [new file with mode: 0644]
lib/cpPlugins/Interface/BaseMPRWindow.cxx [new file with mode: 0644]
lib/cpPlugins/Interface/BaseMPRWindow.h [new file with mode: 0644]
lib/cpPlugins/Interface/BaseMPRWindow.ui [new file with mode: 0644]
lib/cpPlugins/Interface/CMakeLists.txt
lib/cpPlugins/Interface/Config.h.in
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/ProcessObject.h
lib/cpPlugins/Plugins/CMakeLists.txt
lib/cpPlugins/Plugins/IO/ImageReader.cxx
lib/cpPlugins/Plugins/IO/ImageReader.h
lib/cpPlugins/Plugins/IO/ImageWriter.cxx
lib/cpPlugins/Plugins/IO/MeshReader.cxx
lib/cpPlugins/Plugins/IO/MeshWriter.cxx

index 7031e14b5283eb5fd5f0e1c80f4b3c157bec91de..95a7757fc967ec3680e005ca24fd985e8c45d47c 100644 (file)
@@ -10,12 +10,12 @@ IF(USE_QT4)
 
   SET(
     App_QT_SOURCES
-       ImageMPR.cxx
+    ImageMPR.cxx
     )
   SET(
     App_SOURCES
-       MementoState.cxx
-       main.cxx
+    MementoState.cxx
+    main.cxx
     )
   SET(
     App_QT_HEADERS
@@ -23,7 +23,7 @@ IF(USE_QT4)
     )
   SET(
     App_HEADERS
-       MementoState.h
+    MementoState.h
     )
   FILE(GLOB App_QT_UI  "${App_SOURCE_DIR}/*.ui")
   FILE(GLOB App_QT_RES "${App_SOURCE_DIR}/*.qrc")
index d55ceae29c1542c4b7cc5ec360acd149d08e83b9..72bd435bc0cfe38a5bbf0ce6f044d3463b94e2a0 100644 (file)
@@ -13,7 +13,7 @@ MementoState::MementoState()
 // -------------------------------------------------------------------------
 MementoState::MementoState(long id, TPluginImage* _img)
 {
-       char * base = "state";
+       char base[] = "state";
        std::ostringstream oss;
        oss << id;
        std::string str = oss.str();
@@ -33,7 +33,7 @@ MementoState::MementoState(long id, TPluginImage* _img)
 vtkSmartPointer<vtkMetaImageReader>
 MementoState::getMemento(long id)
 {
-       char * base = "state";
+       char base[] = "state";
        std::ostringstream oss;
        oss << id;
        std::string str = oss.str();
@@ -48,22 +48,26 @@ MementoState::getMemento(long id)
 // -------------------------------------------------------------------------
 void MementoState::
 save(const std::string& filename, const std::string& filenameRaw, TPluginImage* img) {
+  /* TODO
        vtkSmartPointer<vtkMetaImageWriter> writer =
                vtkSmartPointer<vtkMetaImageWriter>::New();
        writer->SetInputData(img->GetVTK< vtkImageData >());
        writer->SetFileName(filename.c_str());
        writer->SetRAWFileName(filenameRaw.c_str());
        writer->Write();
+  */
 }
 
 // -------------------------------------------------------------------------
 vtkSmartPointer<vtkMetaImageReader>
 MementoState::load(const std::string& filename) {
+  /* TODO
        vtkSmartPointer<vtkMetaImageReader> reader =
                vtkSmartPointer<vtkMetaImageReader>::New();
        reader->SetFileName(filename.c_str());
        reader->Update();
        return reader;
+  */
 }
 
 // eof - $RCSfile$
index afbe04113da493603eea136ba984915891356b58..2fd980d419444ec1760a211f143f1a3299a2a46d 100644 (file)
@@ -4,9 +4,28 @@
 ## =========================
 
 SET(
-  EXAMPLES_PROGRAMS
+  EXAMPLES_PROGRAMS_ONLY_EXTENSIONS
+  example_TestQuadSplitter
+  )
+
+FOREACH(prog ${EXAMPLES_PROGRAMS_ONLY_EXTENSIONS})
+  ADD_EXECUTABLE(${prog} ${prog}.cxx)
+  TARGET_LINK_LIBRARIES(${prog} cpExtensions)
+ENDFOREACH(prog)
+
+SET(
+  EXAMPLES_PROGRAMS_ONLY_INTERFACE
   example_TestParameters
   example_LoadPlugins
+  )
+
+FOREACH(prog ${EXAMPLES_PROGRAMS_ONLY_INTERFACE}) 
+  ADD_EXECUTABLE(${prog} ${prog}.cxx)
+  TARGET_LINK_LIBRARIES(${prog} cpPlugins_Interface)
+ENDFOREACH(prog)
+
+SET(
+  EXAMPLES_PROGRAMS_WITH_PLUGINS
   example_ReadWriteImage
   example_View2DImage
   ##example_MarchingCubes
index 0c865ea3640939b8736efb2e8cf7f093f39278cc..c728bb246f878037d34ea9269c2dd1600b7ce956 100644 (file)
@@ -24,146 +24,139 @@ int main( int argc, char* argv[] )
   typedef itk::Index< 3 > TIndex;
   typedef itk::Point< float, 3 > TPoint;
 
-  TParameters parameters;
-
-  parameters.Configure( TParameters::String, "StringParam" );
-  parameters.Configure( TParameters::Bool, "BoolParam" );
-  parameters.Configure( TParameters::Int, "IntParam" );
-  parameters.Configure( TParameters::Uint, "UintParam" );
-  parameters.Configure( TParameters::Real, "RealParam" );
-  parameters.Configure( TParameters::Index, "IndexParam" );
-  parameters.Configure( TParameters::Point, "PointParam" );
-  parameters.Configure( TParameters::StringList, "StringListParam" );
-  parameters.Configure( TParameters::BoolList, "BoolListParam" );
-  parameters.Configure( TParameters::IntList, "IntListParam" );
-  parameters.Configure( TParameters::UintList, "UintListParam" );
-  parameters.Configure( TParameters::RealList, "RealListParam" );
-  parameters.Configure( TParameters::IndexList, "IndexListParam" );
-  parameters.Configure( TParameters::PointList, "PointListParam" );
-
-  parameters.SetValueAsString( "StringParam", "test_value" );
-  parameters.SetValueAsBool( "BoolParam", true );
-  parameters.SetValueAsInt( "IntParam", -1234567 );
-  parameters.SetValueAsUint( "UintParam", 1234567 );
-  parameters.SetValueAsReal( "RealParam", 3.14159244444 );
-  parameters.SetValueAsIndex( "IndexParam", 3, 4, -3, 2 );
-  parameters.SetValueAsPoint( "PointParam", 3, 9.4, 8.3, 7.2 );
-
-  parameters.ClearStringList( "StringListParam" );
-  parameters.ClearBoolList( "BoolListParam" );
-  parameters.ClearIntList( "IntListParam" );
-  parameters.ClearUintList( "UintListParam" );
-  parameters.ClearRealList( "RealListParam" );
-  parameters.ClearIndexList( "IndexListParam" );
-  parameters.ClearPointList( "PointListParam" );
-
-  parameters.AddValueToStringList( "StringListParam", "one" );
-  parameters.AddValueToStringList( "StringListParam", "two" );
-  parameters.AddValueToStringList( "StringListParam", "three" );
-  parameters.AddValueToStringList( "StringListParam", "four" );
-
-  parameters.AddValueToBoolList( "BoolListParam", 1 );
-  parameters.AddValueToBoolList( "BoolListParam", 0 );
-  parameters.AddValueToBoolList( "BoolListParam", 0 );
-  parameters.AddValueToBoolList( "BoolListParam", 1 );
-  parameters.AddValueToBoolList( "BoolListParam", 1 );
-
-  parameters.AddValueToIntList( "IntListParam", 1 );
-  parameters.AddValueToIntList( "IntListParam", -2 );
-  parameters.AddValueToIntList( "IntListParam", 3 );
-  parameters.AddValueToIntList( "IntListParam", -4 );
-  parameters.AddValueToIntList( "IntListParam", 5 );
-  parameters.AddValueToIntList( "IntListParam", -6 );
-  parameters.AddValueToIntList( "IntListParam", 7 );
-  parameters.AddValueToIntList( "IntListParam", -8 );
-  parameters.AddValueToIntList( "IntListParam", 9 );
-  parameters.AddValueToIntList( "IntListParam", -10 );
-  parameters.AddValueToIntList( "IntListParam", 11 );
-
-  parameters.AddValueToUintList( "UintListParam", 1 );
-  parameters.AddValueToUintList( "UintListParam", 2 );
-  parameters.AddValueToUintList( "UintListParam", 3 );
-  parameters.AddValueToUintList( "UintListParam", 4 );
-  parameters.AddValueToUintList( "UintListParam", 5 );
-  parameters.AddValueToUintList( "UintListParam", 6 );
-  parameters.AddValueToUintList( "UintListParam", 7 );
-  parameters.AddValueToUintList( "UintListParam", 8 );
-  parameters.AddValueToUintList( "UintListParam", 9 );
-  parameters.AddValueToUintList( "UintListParam", 10 );
-  parameters.AddValueToUintList( "UintListParam", 11 );
-
-  parameters.AddValueToRealList( "RealListParam", 1.9 );
-  parameters.AddValueToRealList( "RealListParam", 2.8 );
-  parameters.AddValueToRealList( "RealListParam", 3.7 );
-  parameters.AddValueToRealList( "RealListParam", 4.6 );
-  parameters.AddValueToRealList( "RealListParam", 5.5 );
-  parameters.AddValueToRealList( "RealListParam", 6.4 );
-  parameters.AddValueToRealList( "RealListParam", 7.3 );
-  parameters.AddValueToRealList( "RealListParam", 8.2 );
-  parameters.AddValueToRealList( "RealListParam", 9.1 );
-  parameters.AddValueToRealList( "RealListParam", 1.0012 );
-  parameters.AddValueToRealList( "RealListParam", 1.131245 );
-
-  parameters.AddValueToIndexList( "IndexListParam", 3, -1, 2, 3 );
-  parameters.AddValueToIndexList( "IndexListParam", 3, 2, -3, 4 );
-  parameters.AddValueToIndexList( "IndexListParam", 3, 3, 4, 7 );
-
-  parameters.AddValueToPointList( "PointListParam", 3, 3.45, 4.67, 7.9 );
-  parameters.AddValueToPointList( "PointListParam", 3, 3.45, 4.67, 3.14 );
-  parameters.AddValueToPointList( "PointListParam", 3, 1.45, 3.67, 2.14 );
-  parameters.AddValueToPointList( "PointListParam", 3, 4.5, 6.7, 4.2 );
-
-  std::vector< TParameters::TString > names = parameters.GetParameters( );
-  std::cout << "Names:" << std::endl;
-  for( unsigned int i = 0; i < names.size( ); ++i )
-    std::cout
-      << "\t... "
-      << names[ i ] << " "
-      << parameters.GetRawValue( names[ i ] ) << "("
-      << parameters.GetParameterType( names[ i ] ) << ")"
-      << std::endl;
-
-  std::cout << std::endl << "Values with type checking" << std::endl;
-  std::cout
-    << "\t... " << "StringParam: "
-    << parameters.GetValueAsString( "StringParam" ) << std::endl
-    << "\t... " << "BoolParam: "
-    << parameters.GetValueAsBool( "BoolParam" ) << std::endl
-    << "\t... " << "IntParam: "
-    << parameters.GetValueAsInt( "IntParam" ) << std::endl
-    << "\t... " << "UintParam: "
-    << parameters.GetValueAsUint( "UintParam" ) << std::endl
-    << "\t... " << "RealParam: "
-    << parameters.GetValueAsReal( "RealParam" ) << std::endl
-    << "\t... " << "IndexParam: "
-    << parameters.GetValueAsIndex< TIndex >( "IndexParam" ) << std::endl
-    << "\t... " << "PointParam: "
-    << parameters.GetValueAsPoint< TPoint >( "PointParam" ) << std::endl;
-
-  std::vector< TParameters::TString > string_lst;
-  std::vector< TParameters::TBool > bool_lst;
-  std::vector< TParameters::TInt > int_lst;
-  std::vector< TParameters::TUint > uint_lst;
-  std::vector< TParameters::TReal > real_lst;
-  std::vector< TIndex > index_lst;
-  std::vector< TPoint > point_lst;
-
-  parameters.GetValueAsStringList( string_lst, "StringListParam" );
-  parameters.GetValueAsBoolList( bool_lst, "BoolListParam" );
-  parameters.GetValueAsIntList( int_lst, "IntListParam" );
-  parameters.GetValueAsUintList( uint_lst, "UintListParam" );
-  parameters.GetValueAsRealList( real_lst, "RealListParam" );
-  parameters.GetValueAsIndexList( index_lst, "IndexListParam" );
-  parameters.GetValueAsPointList( point_lst, "PointListParam" );
-
-  std::cout << "List parameters:" << std::endl;
-  PrintList( string_lst, "StringListParam" );
-  PrintList( bool_lst, "BoolListParam" );
-  PrintList( int_lst, "IntListParam" );
-  PrintList( uint_lst, "UintListParam" );
-  PrintList( real_lst, "RealListParam" );
-  PrintList( index_lst, "IndexListParam" );
-  PrintList( point_lst, "PointListParam" );
+  TParameters::Pointer parameters = TParameters::New( );
+
+  TIndex idx; idx[ 0 ] = 1; idx[ 1 ] = 2; idx[ 2 ] = 3;
+  TPoint pnt; pnt[ 0 ] = 3.1; pnt[ 1 ] = 2.2; pnt[ 2 ] = 1.3;
+
+  parameters->ConfigureAsString( "StringParam", "String_Value" );
+  parameters->ConfigureAsBool( "BoolParam", false );
+  parameters->ConfigureAsInt( "IntParam", -314 );
+  parameters->ConfigureAsUint( "UintParam", 314 );
+  parameters->ConfigureAsReal( "RealParam", 3.14 );
+  parameters->ConfigureAsIndex( "IndexParam", 3, idx );
+  parameters->ConfigureAsPoint( "PointParam", 3, pnt );
+  parameters->ConfigureAsStringList( "StringListParam" );
+  parameters->ConfigureAsBoolList( "BoolListParam" );
+  parameters->ConfigureAsIntList( "IntListParam" );
+  parameters->ConfigureAsUintList( "UintListParam" );
+  parameters->ConfigureAsRealList( "RealListParam" );
+  parameters->ConfigureAsIndexList( "IndexListParam" );
+  parameters->ConfigureAsPointList( "PointListParam" );
+
+  std::vector< std::string > choices;
+  choices.push_back( "bat" );
+  choices.push_back( "deux" );
+  choices.push_back( "drei" );
+  choices.push_back( "cuatro" );
+  choices.push_back( "cinque" );
+  parameters->ConfigureAsChoices( "ChoicesParam", choices );
+
+  std::cout << "---------------------------------------------" << std::endl;
+  parameters->Print( std::cout );
+  std::cout << "---------------------------------------------" << std::endl;
+
+  parameters->SetString( "StringParam", "test_value" );
+  parameters->SetBool( "BoolParam", true );
+  parameters->SetInt( "IntParam", -1234567 );
+  parameters->SetUint( "UintParam", 1234567 );
+  parameters->SetReal( "RealParam", 3.14159244444 );
+
+  idx[ 0 ] = 10; idx[ 1 ] = 20; idx[ 2 ] = 30;
+  pnt[ 0 ] = 30.1; pnt[ 1 ] = 21.2; pnt[ 2 ] = 12.3;
+  parameters->SetIndex( "IndexParam", 3, idx );
+  parameters->SetPoint( "PointParam", 3, pnt );
+
+  std::cout << "---------------------------------------------" << std::endl;
+  parameters->Print( std::cout );
+  std::cout << "---------------------------------------------" << std::endl;
+
+  parameters->ClearStringList( "StringListParam" );
+  parameters->ClearBoolList( "BoolListParam" );
+  parameters->ClearIntList( "IntListParam" );
+  parameters->ClearUintList( "UintListParam" );
+  parameters->ClearRealList( "RealListParam" );
+  parameters->ClearIndexList( "IndexListParam" );
+  parameters->ClearPointList( "PointListParam" );
+
+  parameters->AddToStringList( "StringListParam", "one" );
+  parameters->AddToStringList( "StringListParam", "two" );
+  parameters->AddToStringList( "StringListParam", "three" );
+  parameters->AddToStringList( "StringListParam", "four" );
+
+  parameters->AddToBoolList( "BoolListParam", 1 );
+  parameters->AddToBoolList( "BoolListParam", 0 );
+  parameters->AddToBoolList( "BoolListParam", 0 );
+  parameters->AddToBoolList( "BoolListParam", 1 );
+  parameters->AddToBoolList( "BoolListParam", 1 );
+
+  parameters->AddToIntList( "IntListParam", 1 );
+  parameters->AddToIntList( "IntListParam", -2 );
+  parameters->AddToIntList( "IntListParam", 3 );
+  parameters->AddToIntList( "IntListParam", -4 );
+  parameters->AddToIntList( "IntListParam", 5 );
+  parameters->AddToIntList( "IntListParam", -6 );
+  parameters->AddToIntList( "IntListParam", 7 );
+  parameters->AddToIntList( "IntListParam", -8 );
+  parameters->AddToIntList( "IntListParam", 9 );
+  parameters->AddToIntList( "IntListParam", -10 );
+  parameters->AddToIntList( "IntListParam", 11 );
+
+  parameters->AddToUintList( "UintListParam", 1 );
+  parameters->AddToUintList( "UintListParam", 2 );
+  parameters->AddToUintList( "UintListParam", 3 );
+  parameters->AddToUintList( "UintListParam", 4 );
+  parameters->AddToUintList( "UintListParam", 5 );
+  parameters->AddToUintList( "UintListParam", 6 );
+  parameters->AddToUintList( "UintListParam", 7 );
+  parameters->AddToUintList( "UintListParam", 8 );
+  parameters->AddToUintList( "UintListParam", 9 );
+  parameters->AddToUintList( "UintListParam", 10 );
+  parameters->AddToUintList( "UintListParam", 11 );
+
+  parameters->AddToRealList( "RealListParam", 1.9 );
+  parameters->AddToRealList( "RealListParam", 2.8 );
+  parameters->AddToRealList( "RealListParam", 3.7 );
+  parameters->AddToRealList( "RealListParam", 4.6 );
+  parameters->AddToRealList( "RealListParam", 5.5 );
+  parameters->AddToRealList( "RealListParam", 6.4 );
+  parameters->AddToRealList( "RealListParam", 7.3 );
+  parameters->AddToRealList( "RealListParam", 8.2 );
+  parameters->AddToRealList( "RealListParam", 9.1 );
+  parameters->AddToRealList( "RealListParam", 1.0012 );
+  parameters->AddToRealList( "RealListParam", 1.131245 );
+
+  idx.Fill( 1 );
+  parameters->AddToIndexList( "IndexListParam", 3, idx );
+  idx.Fill( 2 );
+  parameters->AddToIndexList( "IndexListParam", 3, idx );
+  idx.Fill( 3 );
+  parameters->AddToIndexList( "IndexListParam", 3, idx );
+
+  pnt.Fill( 1.2 );
+  parameters->AddToPointList( "PointListParam", 3, pnt );
+  pnt.Fill( 3.14 );
+  parameters->AddToPointList( "PointListParam", 3, pnt );
+  pnt.Fill( 6.28 );
+  parameters->AddToPointList( "PointListParam", 3, pnt );
+  pnt.Fill( 1.63 );
+  parameters->AddToPointList( "PointListParam", 3, pnt );
+
+  std::cout << "---------------------------------------------" << std::endl;
+  parameters->Print( std::cout );
+  std::cout << "---------------------------------------------" << std::endl;
+
+  parameters->SetSelectedChoice( "ChoicesParam", "drei" );
+
+  std::cout << "---------------------------------------------" << std::endl;
+  parameters->Print( std::cout );
+  std::cout << "---------------------------------------------" << std::endl;
+
+  parameters->SetSelectedChoice( "ChoicesParam", "zeven" );
+
+  std::cout << "---------------------------------------------" << std::endl;
+  parameters->Print( std::cout );
+  std::cout << "---------------------------------------------" << std::endl;
 
   return( 0 );
 }
diff --git a/appli/examples/example_TestQuadSplitter.cxx b/appli/examples/example_TestQuadSplitter.cxx
new file mode 100644 (file)
index 0000000..e1c9d1b
--- /dev/null
@@ -0,0 +1,24 @@
+#include <QApplication>
+#include <QTextEdit>
+#include <cpExtensions/QT/QuadSplitter.h>
+
+int main( int argc, char* argv[] )
+{
+  int ret = 0;
+#ifdef cpExtensions_Interface_QT4
+  QApplication app( argc, argv );
+
+  QTextEdit* t1 = new QTextEdit;
+  QTextEdit* t2 = new QTextEdit;
+  QTextEdit* t3 = new QTextEdit;
+  QTextEdit* t4 = new QTextEdit;
+
+  cpExtensions::QT::QuadSplitter quadSplit;
+  quadSplit.addWidgets( t1, t2, t3, t4 );
+  quadSplit.show( );
+  ret = app.exec( );
+#endif // cpExtensions_Interface_QT4
+  return( ret );
+}
+
+// eof - $RCSfile$
index 07b7e420f9eb1dcb1a60121df2846a7803987af0..d977c4692616bcdaf6d12bd8c07bd4488f1f1863 100644 (file)
@@ -1,5 +1,11 @@
 SET(LIBRARY_NAME cpExtensions)
 
+CONFIGURE_FILE(
+  Config.h.in
+  ${PROJECT_BINARY_DIR}/lib/cpExtensions/Config.h
+  @ONLY
+  )
+
 ## ===============
 ## = Source code =
 ## ===============
@@ -51,6 +57,32 @@ FOREACH(dir ${lib_DIRECTORIES})
     )
 ENDFOREACH(dir)
 
+IF(USE_QT4)
+  FILE(GLOB LIB_QT_UI "QT/*.ui")
+  FILE(GLOB LIB_QT_Headers "QT/*.h")
+  FILE(GLOB LIB_QT_Sources "QT/*.cxx")
+  FILE(GLOB LIB_QT_Resources "QT/*.rc")
+
+  QT4_WRAP_UI(LIB_QT_Wrapped_Headers ${LIB_QT_UI})
+  QT4_WRAP_CPP(LIB_QT_Wrapped_MOC_Sources ${LIB_QT_Headers})
+  QT4_ADD_RESOURCES(LIB_QT_Wrapped_Resources_Sources ${LIB_QT_Resources})
+
+  SET(
+    LIB_HEADERS_H
+    ${LIB_HEADERS_H}
+    ${LIB_QT_Wrapped_Headers}
+    )
+  SET(
+    LIB_SOURCES_CXX
+    ${LIB_SOURCES_CXX}
+    ${LIB_QT_Sources}
+    ${LIB_QT_Wrapped_Headers}
+    ${LIB_QT_Wrapped_MOC_Sources}
+    ${LIB_QT_Wrapped_Resources_Sources}
+    )
+ENDIF(USE_QT4)
+
+
 ## =====================
 ## = Compilation rules =
 ## =====================
@@ -71,6 +103,7 @@ GENERATE_EXPORT_HEADER(
   )
 TARGET_LINK_LIBRARIES(
   ${LIBRARY_NAME}
+  ${QT_LIBRARIES}
   ${ITK_LIBRARIES}
   ${VTK_LIBRARIES}
   )
diff --git a/lib/cpExtensions/Config.h.in b/lib/cpExtensions/Config.h.in
new file mode 100644 (file)
index 0000000..4468c5b
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef __CPEXTENSIONS__CONFIG__H__
+#define __CPEXTENSIONS__CONFIG__H__
+
+#define cpExtensions_MAJOR_VERSION   @prj_MAJOR_VERSION@
+#define cpExtensions_MINOR_VERSION   @prj_MINOR_VERSION@
+#define cpExtensions_RELEASE_VERSION @prj_RELEASE_VERSION@
+#define cpExtensions_VERSION         "@prj_VERSION@"
+
+#define cpExtensions_Interface_QT4_USED @QT4_FOUND@
+#if cpExtensions_Interface_QT4_USED == 1
+#  define cpExtensions_Interface_QT4
+#else // cpExtensions_Interface_QT4_USED == 1
+#  undef cpExtensions_Interface_QT4
+#endif // cpExtensions_Interface_QT4_USED == 1
+
+#endif // __CPEXTENSIONS__CONFIG__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpExtensions/QT/QuadSplitter.cxx b/lib/cpExtensions/QT/QuadSplitter.cxx
new file mode 100644 (file)
index 0000000..89fc717
--- /dev/null
@@ -0,0 +1,70 @@
+#include <cpExtensions/QT/QuadSplitter.h>
+
+#include <cpExtensions/Config.h>
+
+#ifdef cpExtensions_Interface_QT4
+
+/**
+ * Inspired by:
+ * https://forum.qt.io/topic/7144/quad-splitter-windows-an-implementation/2
+ */
+
+// -------------------------------------------------------------------------
+cpExtensions::QT::QuadSplitter::
+QuadSplitter( QWidget* parent, Qt::WindowFlags f )
+  : QFrame( parent, f )
+{
+  this->m_Parent.setOrientation(Qt::Vertical);
+  this->m_Parent.addWidget(&this->m_Upper);
+  this->m_Parent.addWidget(&this->m_Bottom);
+
+  QObject::connect(
+    &this->m_Upper, SIGNAL( splitterMoved( int, int ) ),
+    this, SLOT( _SyncBottom( int, int ) )
+    );
+  QObject::connect(
+    &this->m_Bottom, SIGNAL( splitterMoved( int, int ) ),
+    this, SLOT( _SyncUpper( int, int ) )
+    );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::QT::QuadSplitter::
+~QuadSplitter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::QuadSplitter::
+show( )
+{
+  this->m_Parent.show( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::QuadSplitter::
+addWidgets( QWidget* a, QWidget* b, QWidget* c, QWidget* d )
+{
+  this->m_Upper.addWidget( a );
+  this->m_Upper.addWidget( b );
+  this->m_Bottom.addWidget( c );
+  this->m_Bottom.addWidget( d );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::QuadSplitter::
+_SyncBottom( int a, int b )
+{
+  this->m_Bottom.setSizes( m_Upper.sizes( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::QuadSplitter::
+_SyncUpper( int a, int b )
+{
+  this->m_Upper.setSizes( m_Bottom.sizes( ) );
+}
+
+#endif // cpExtensions_Interface_QT4
+
+// eof - $RCSfile$
diff --git a/lib/cpExtensions/QT/QuadSplitter.h b/lib/cpExtensions/QT/QuadSplitter.h
new file mode 100644 (file)
index 0000000..c431dfa
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef __CPEXTENSIONS__QT__QUADSPLITTER__H__
+#define __CPEXTENSIONS__QT__QUADSPLITTER__H__
+
+#include <cpExtensions/Config.h>
+
+#ifdef cpExtensions_Interface_QT4
+
+/**
+ * Inspired by:
+ * https://forum.qt.io/topic/7144/quad-splitter-windows-an-implementation/2
+ */
+
+#include <QFrame>
+#include <QSplitter>
+
+namespace cpExtensions
+{
+  namespace QT
+  {
+    /**
+     */
+    class QuadSplitter
+      : public QFrame
+    {
+      Q_OBJECT;
+
+    public:
+      QuadSplitter( QWidget* parent = 0, Qt::WindowFlags f = 0 );
+      virtual ~QuadSplitter( );
+
+      void show( );
+      void addWidgets( QWidget* a, QWidget* b, QWidget* c, QWidget* d );
+
+
+    private slots:
+      void _SyncBottom( int a, int b );
+      void _SyncUpper( int a, int b );
+
+    protected:
+      QSplitter m_Parent;
+      QSplitter m_Bottom;
+      QSplitter m_Upper;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // cpExtensions_Interface_QT4
+
+#endif // __CPEXTENSIONS__QT__QUADSPLITTER__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Interface/BaseMPRWindow.cxx b/lib/cpPlugins/Interface/BaseMPRWindow.cxx
new file mode 100644 (file)
index 0000000..cc3f9b3
--- /dev/null
@@ -0,0 +1,66 @@
+#include <cpPlugins/Interface/BaseMPRWindow.h>
+
+#ifdef cpPlugins_Interface_QT4
+
+#include <cpPlugins/Interface/ui_BaseMPRWindow.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::BaseMPRWindow::
+BaseMPRWindow( QWidget* parent )
+  : QMainWindow( parent ),
+    m_UI( new Ui::BaseMPRWindow )
+{
+  // Create and associate renderers
+  this->m_MPRObjects = vtkSmartPointer< TMPRObjects >::New( );
+  this->m_MPRObjects->SetRenderWindows(
+    this->m_UI->m_XVTK->GetRenderWindow( ),
+    this->m_UI->m_YVTK->GetRenderWindow( ),
+    this->m_UI->m_ZVTK->GetRenderWindow( ),
+    this->m_UI->m_WVTK->GetRenderWindow( )
+    );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::BaseMPRWindow::
+~BaseMPRWindow( )
+{
+  if( this->m_UI != NULL )
+    delete this->m_UI;
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::BaseMPRWindow::
+_LoadPlugins( const std::string& fname )
+{
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::BaseMPRWindow::
+_LoadImage( const std::string& fname )
+{
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::BaseMPRWindow::
+_LoadMesh( const std::string& fname )
+{
+  return( false );
+}
+
+/*
+  TInterface m_Interface;
+
+  TProcessObject::Pointer m_ImageReader;
+  TProcessObject::Pointer m_ImageWriter;
+  TProcessObject::Pointer m_MeshReader;
+  TProcessObject::Pointer m_MeshWriter;
+
+  TImages m_Images;
+  TMeshes m_Meshes;
+*/
+
+#endif // cpPlugins_Interface_QT4
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Interface/BaseMPRWindow.h b/lib/cpPlugins/Interface/BaseMPRWindow.h
new file mode 100644 (file)
index 0000000..37dd18e
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef __CPPLUGINS__INTERFACE__BASEMPRWINDOW__H__
+#define __CPPLUGINS__INTERFACE__BASEMPRWINDOW__H__
+
+#include <cpPlugins/Interface/Config.h>
+
+#ifdef cpPlugins_Interface_QT4
+
+#include <set>
+
+#include <QMainWindow>
+
+#include <vtkSmartPointer.h>
+
+#include <cpExtensions/Visualization/MPRObjects.h>
+#include <cpPlugins/Interface/Interface.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Interface/Mesh.h>
+
+namespace Ui
+{
+  class BaseMPRWindow;
+}
+
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    /**
+     */
+    class BaseMPRWindow
+      : public QMainWindow
+    {
+      Q_OBJECT;
+
+    public:
+      typedef cpPlugins::Interface::Interface     TInterface;
+      typedef cpPlugins::Interface::ProcessObject TProcessObject;
+      typedef cpPlugins::Interface::DataObject    TDataObject;
+      typedef cpPlugins::Interface::Image         TImage;
+      typedef cpPlugins::Interface::Mesh          TMesh;
+
+      typedef std::set< TImage::Pointer > TImages;
+      typedef std::set< TMesh::Pointer >  TMeshes;
+
+    public:
+      explicit BaseMPRWindow( QWidget* parent = NULL );
+      virtual ~BaseMPRWindow( );
+
+    protected:
+      bool _LoadPlugins( const std::string& fname );
+      bool _LoadImage( const std::string& fname );
+      bool _LoadMesh( const std::string& fname );
+
+    protected:
+      Ui::BaseMPRWindow* m_UI;
+
+      typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
+      vtkSmartPointer< TMPRObjects > m_MPRObjects;
+
+      TInterface m_Interface;
+
+      TProcessObject::Pointer m_ImageReader;
+      TProcessObject::Pointer m_ImageWriter;
+      TProcessObject::Pointer m_MeshReader;
+      TProcessObject::Pointer m_MeshWriter;
+
+      TImages m_Images;
+      TMeshes m_Meshes;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // cpPlugins_Interface_QT4
+
+#endif // __CPPLUGINS__INTERFACE__BASEMPRWINDOW__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Interface/BaseMPRWindow.ui b/lib/cpPlugins/Interface/BaseMPRWindow.ui
new file mode 100644 (file)
index 0000000..ad47ad5
--- /dev/null
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BaseMPRWindow</class>
+ <widget class="QMainWindow" name="BaseMPRWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>718</width>
+    <height>706</height>
+   </rect>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>718</width>
+    <height>706</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Put a fancy title here</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="0" column="0">
+     <widget class="QSplitter" name="splitter_4">
+      <property name="minimumSize">
+       <size>
+        <width>700</width>
+        <height>400</height>
+       </size>
+      </property>
+      <property name="orientation">
+       <enum>Qt::Horizontal</enum>
+      </property>
+      <widget class="QSplitter" name="splitter_3">
+       <property name="orientation">
+        <enum>Qt::Vertical</enum>
+       </property>
+       <widget class="QSplitter" name="splitter">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <widget class="QVTKWidget" name="m_YVTK" native="true">
+         <property name="enabled">
+          <bool>true</bool>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>200</width>
+           <height>200</height>
+          </size>
+         </property>
+        </widget>
+        <widget class="QVTKWidget" name="m_XVTK" native="true">
+         <property name="enabled">
+          <bool>true</bool>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>200</width>
+           <height>200</height>
+          </size>
+         </property>
+        </widget>
+       </widget>
+       <widget class="QSplitter" name="splitter_2">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <widget class="QVTKWidget" name="m_ZVTK" native="true">
+         <property name="enabled">
+          <bool>true</bool>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>200</width>
+           <height>200</height>
+          </size>
+         </property>
+        </widget>
+        <widget class="QVTKWidget" name="m_WVTK" native="true">
+         <property name="enabled">
+          <bool>true</bool>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>200</width>
+           <height>200</height>
+          </size>
+         </property>
+        </widget>
+       </widget>
+      </widget>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>718</width>
+     <height>27</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>&amp;File</string>
+    </property>
+    <addaction name="actionOpenPlugins"/>
+    <addaction name="separator"/>
+    <addaction name="actionOpenInputImage"/>
+    <addaction name="actionOpenSegmentation"/>
+    <addaction name="actionOpenInputPolyData"/>
+    <addaction name="separator"/>
+    <addaction name="actionExit"/>
+   </widget>
+   <widget class="QMenu" name="MenuImageToImage">
+    <property name="title">
+     <string>Image to image</string>
+    </property>
+   </widget>
+   <widget class="QMenu" name="MenuImageToMesh">
+    <property name="title">
+     <string>Image to mesh</string>
+    </property>
+   </widget>
+   <widget class="QMenu" name="menuEdit">
+    <property name="title">
+     <string>Edit</string>
+    </property>
+    <addaction name="actionUndo"/>
+    <addaction name="actionRedo"/>
+   </widget>
+   <addaction name="menuFile"/>
+   <addaction name="menuEdit"/>
+   <addaction name="MenuImageToImage"/>
+   <addaction name="MenuImageToMesh"/>
+  </widget>
+  <action name="actionOpenInputImage">
+   <property name="enabled">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Open image</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+O</string>
+   </property>
+  </action>
+  <action name="actionOpenPlugins">
+   <property name="enabled">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Open plugins</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+P</string>
+   </property>
+  </action>
+  <action name="actionExit">
+   <property name="text">
+    <string>Exit</string>
+   </property>
+  </action>
+  <action name="actionOpenInputPolyData">
+   <property name="text">
+    <string>Open polydata</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+M</string>
+   </property>
+  </action>
+  <action name="actionDasdasd">
+   <property name="text">
+    <string>dasdasd</string>
+   </property>
+  </action>
+  <action name="actionOpenSegmentation">
+   <property name="text">
+    <string>Open segmentation</string>
+   </property>
+  </action>
+  <action name="actionUndo">
+   <property name="text">
+    <string>Undo</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Z</string>
+   </property>
+  </action>
+  <action name="actionRedo">
+   <property name="text">
+    <string>Redo</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Y</string>
+   </property>
+  </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+  <customwidget>
+   <class>QVTKWidget</class>
+   <extends>QWidget</extends>
+   <header>QVTKWidget.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>actionExit</sender>
+   <signal>triggered()</signal>
+   <receiver>BaseMPRWindow</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>378</x>
+     <y>235</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index a607fcad7fe3dd540ba3d786003df446c8a2c2bc..9cd9c5a10a7f45c35c10dbc9c7db1d5e089f9cea 100644 (file)
@@ -21,14 +21,17 @@ IF(USE_QT4)
   SET(
     LIB_QT_UI
     ParametersListWidget.ui
+    BaseMPRWindow.ui
     )
   SET(
     LIB_QT_Headers
     ParametersListWidget.h
+    BaseMPRWindow.h
     )
   SET(
     LIB_QT_Sources
     ParametersListWidget.cxx
+    BaseMPRWindow.cxx
     )
   SET(
     LIB_QT_Resources
@@ -79,6 +82,7 @@ TARGET_LINK_LIBRARIES(
   ${QT_LIBRARIES}
   ${ITK_LIBRARIES}
   ${VTK_LIBRARIES}
+  cpExtensions
   )
 
 ## ========================
index 58a9286393b1c36b6a05e8d044b74abe41d323f5..a076a2b328b7a3e7dd9cc9c0a9be859ae682e63b 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef __CPPLUGINS__INTERFACE__CONFIG__H__
 #define __CPPLUGINS__INTERFACE__CONFIG__H__
 
-
 #define cpPlugins_MAJOR_VERSION   @prj_MAJOR_VERSION@
 #define cpPlugins_MINOR_VERSION   @prj_MINOR_VERSION@
 #define cpPlugins_RELEASE_VERSION @prj_RELEASE_VERSION@
index 38a5f14af0b02729b9298d1290265e586cb20a51..d2ae7f16fec1a041f3fdd33f630614d1cfab60d8 100644 (file)
 #include <cpPlugins/Interface/Parameters.h>
-#include <cstdarg>
-#include <cstdlib>
-#include <sstream>
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_SetMacro( TYPE )                 \
-  void cpPlugins::Interface::Parameters::                               \
-  SetValueAs##TYPE( const TString& name, const T##TYPE& v )             \
-  {                                                                     \
-    TParameters::iterator pIt = this->m_Parameters.find( name );        \
-    if( pIt == this->m_Parameters.end( ) )                              \
-      return;                                                           \
-    if( pIt->second.first != Self::TYPE )                               \
-      return;                                                           \
-    std::stringstream ss;                                               \
-    ss << v;                                                            \
-    pIt->second.second = ss.str( );                                     \
-  }
-
-cpPlugins_Interface_Parameters_SetMacro( String );
-cpPlugins_Interface_Parameters_SetMacro( Bool );
-cpPlugins_Interface_Parameters_SetMacro( Int );
-cpPlugins_Interface_Parameters_SetMacro( Uint );
-cpPlugins_Interface_Parameters_SetMacro( Real );
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_SetArrayMacro( TYPE, ATYPE )     \
-  void cpPlugins::Interface::Parameters::                               \
-  SetValueAs##TYPE( const TString& name, const TUint& n, ... )          \
-  {                                                                     \
-    TParameters::iterator pIt = this->m_Parameters.find( name );        \
-    if( pIt == this->m_Parameters.end( ) )                              \
-      return;                                                           \
-    if( pIt->second.first != Self::TYPE )                               \
-      return;                                                           \
-    va_list v_lst;                                                      \
-    va_start( v_lst, n );                                               \
-    std::stringstream ss;                                               \
-    for( TUint i = 0; i < n; ++i )                                      \
-      ss << va_arg( v_lst, ATYPE ) << ",";                              \
-    va_end( v_lst );                                                    \
-    pIt->second.second = ss.str( );                                     \
-  }
-
-cpPlugins_Interface_Parameters_SetArrayMacro( Index, int );
-cpPlugins_Interface_Parameters_SetArrayMacro( Point, double );
 
-// -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_SetListMacro( TYPE )             \
-  void cpPlugins::Interface::Parameters::                               \
-  AddValueTo##TYPE##List( const TString& name, const T##TYPE& v )       \
-  {                                                                     \
-    TParameters::iterator pIt = this->m_Parameters.find( name );        \
-    if( pIt == this->m_Parameters.end( ) )                              \
-      return;                                                           \
-    if( pIt->second.first != Self::TYPE##List )                         \
-      return;                                                           \
-    std::stringstream ss;                                               \
-    ss << pIt->second.second << v << "#";                               \
-    pIt->second.second = ss.str( );                                     \
-  }
-
-cpPlugins_Interface_Parameters_SetListMacro( String );
-cpPlugins_Interface_Parameters_SetListMacro( Bool );
-cpPlugins_Interface_Parameters_SetListMacro( Int );
-cpPlugins_Interface_Parameters_SetListMacro( Uint );
-cpPlugins_Interface_Parameters_SetListMacro( Real );
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_SetArrayListMacro( TYPE, ATYPE ) \
-  void cpPlugins::Interface::Parameters::                               \
-  AddValueTo##TYPE##List( const TString& name, const TUint& n, ... )    \
-  {                                                                     \
-    TParameters::iterator pIt = this->m_Parameters.find( name );        \
-    if( pIt == this->m_Parameters.end( ) )                              \
-      return;                                                           \
-    if( pIt->second.first != Self::TYPE##List )                         \
-      return;                                                           \
-    va_list v_lst;                                                      \
-    va_start( v_lst, n );                                               \
-    std::stringstream ss;                                               \
-    ss << pIt->second.second;                                           \
-    for( TUint i = 0; i < n; ++i )                                      \
-      ss << va_arg( v_lst, ATYPE ) << ",";                              \
-    va_end( v_lst );                                                    \
-    ss << "#";                                                          \
-    pIt->second.second = ss.str( );                                     \
-  }
-
-cpPlugins_Interface_Parameters_SetArrayListMacro( Index, int );
-cpPlugins_Interface_Parameters_SetArrayListMacro( Point, double );
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_ClearListMacro( TYPE )           \
-  void cpPlugins::Interface::Parameters::                               \
-  Clear##TYPE##List( const TString& name )                              \
-  {                                                                     \
-    TParameters::iterator pIt = this->m_Parameters.find( name );        \
-    if( pIt == this->m_Parameters.end( ) )                              \
-      return;                                                           \
-    if( pIt->second.first != Self::TYPE##List )                         \
-      return;                                                           \
-    pIt->second.second = "";                                            \
-  }
-
-cpPlugins_Interface_Parameters_ClearListMacro( String );
-cpPlugins_Interface_Parameters_ClearListMacro( Bool );
-cpPlugins_Interface_Parameters_ClearListMacro( Int );
-cpPlugins_Interface_Parameters_ClearListMacro( Uint );
-cpPlugins_Interface_Parameters_ClearListMacro( Real );
-cpPlugins_Interface_Parameters_ClearListMacro( Index );
-cpPlugins_Interface_Parameters_ClearListMacro( Point );
+#include <sstream>
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-Parameters( )
+void cpPlugins::Interface::Parameters::
+Clear( )
 {
-  this->Clear( );
+  this->m_Parameters.clear( );
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-Parameters( const Self& other )
+void cpPlugins::Interface::Parameters::
+ConfigureAsString( const TString& name, const TString& v )
 {
-  this->m_Parameters = other.m_Parameters;
+  this->m_Parameters[ name ] = TParameter( Self::String, TValues( v, v ) );
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-~Parameters( )
-{
-  this->Clear( );
-}
+#define cpPlugins_Parameters_Configure( Y )             \
+  void cpPlugins::Interface::Parameters::               \
+  ConfigureAs##Y( const TString& name, const T##Y& v )  \
+  {                                                     \
+    std::stringstream str;                              \
+    str << v;                                           \
+    std::string s = str.str( );                         \
+    this->m_Parameters[ name ] =                        \
+      TParameter( Self::Y, TValues( s, s ) );           \
+    this->Modified( );                                  \
+  }
 
-// -------------------------------------------------------------------------
-cpPlugins::Interface::Parameters::
-Self& cpPlugins::Interface::Parameters::
-operator=( const Self& other )
-{
-  this->m_Parameters = other.m_Parameters;
-  return( *this );
-}
+cpPlugins_Parameters_Configure( Bool );
+cpPlugins_Parameters_Configure( Int );
+cpPlugins_Parameters_Configure( Uint );
+cpPlugins_Parameters_Configure( Real );
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::Parameters::
-Clear( )
-{
-  this->m_Parameters.clear( );
-}
+#define cpPlugins_Parameters_List_Configure( Y )        \
+  void cpPlugins::Interface::Parameters::               \
+  ConfigureAs##Y##List( const TString& name )           \
+  {                                                     \
+    this->m_Parameters[ name ] =                        \
+      TParameter( Self::Y##List, TValues( "", "" ) );   \
+    this->Modified( );                                  \
+  }
+
+cpPlugins_Parameters_List_Configure( String );
+cpPlugins_Parameters_List_Configure( Bool );
+cpPlugins_Parameters_List_Configure( Int );
+cpPlugins_Parameters_List_Configure( Uint );
+cpPlugins_Parameters_List_Configure( Real );
+cpPlugins_Parameters_List_Configure( Index );
+cpPlugins_Parameters_List_Configure( Point );
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-Configure( const Self::Type& type, const TString& name )
+ConfigureAsChoices(
+  const TString& name, const std::vector< TString >& choices
+  )
 {
-  this->m_Parameters[ name ] = TParameter( type, "" );
+  // 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 ];
+  this->m_Parameters[ name ] =
+    TParameter( Self::Choices, TValues( str_choices.str( ), "" ) );
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
-std::vector< cpPlugins::Interface::Parameters::TString >
-cpPlugins::Interface::Parameters::
-GetParameters( ) const
+void cpPlugins::Interface::Parameters::
+GetNames( std::vector< TString >& container ) const
 {
-  std::vector< TString > parameters;
-  TParameters::const_iterator pIt = this->m_Parameters.begin( );
-  for( ; pIt != this->m_Parameters.end( ); ++pIt )
-    parameters.push_back( pIt->first );
-  return( parameters );
+  container.clear( );
+  TParameters::const_iterator i = this->m_Parameters.begin( );
+  for( ; i != this->m_Parameters.end( ); ++i )
+    container.push_back( i->first );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 Type cpPlugins::Interface::Parameters::
-GetParameterType( const TString& name ) const
+GetType( const TString& name ) const
 {
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+    return( i->second.first );
+  else
     return( Self::NoType );
-  return( pIt->second.first );
 }
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Parameters::
-TString& cpPlugins::Interface::Parameters::
-GetRawValue( const TString& name ) const
-{
-  static const TString null_str = "";
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return( null_str );
-  return( pIt->second.second );
-}
+#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( 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( Choices );
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Parameters::
-TString& cpPlugins::Interface::Parameters::
-GetValueAsString( const TString& name ) const
+cpPlugins::Interface::Parameters::
+TString cpPlugins::Interface::Parameters::
+GetString( const TString& name ) const
 {
-  static const TString null_str = "";
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return( null_str );
-  if( pIt->second.first != Self::String )
-    return( null_str );
-
-  return( pIt->second.second );
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::String )
+      return( i->second.second.second );
+
+  } // fi
+  return( "" );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 TBool cpPlugins::Interface::Parameters::
-GetValueAsBool( const TString& name ) const
+GetBool( const TString& name ) const
 {
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return( TBool( false ) );
-  if( pIt->second.first != Self::Bool )
-    return( TBool( false ) );
-  return( TBool( std::atoi( pIt->second.second.c_str( ) ) == 1 ) );
+  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.second.c_str( ) ) == 1 );
+
+  } // fi
+  return( false );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 TInt cpPlugins::Interface::Parameters::
-GetValueAsInt( const TString& name ) const
+GetInt( const TString& name ) const
 {
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return( TInt( 0 ) );
-  if( pIt->second.first != Self::Int )
-    return( TInt( 0 ) );
-  return( TInt( std::atoi( pIt->second.second.c_str( ) ) ) );
+  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.second.c_str( ) ) ) );
+
+  } // fi
+  return( TInt( 0 ) );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 TUint cpPlugins::Interface::Parameters::
-GetValueAsUint( const TString& name ) const
+GetUint( const TString& name ) const
 {
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return( TUint( 0 ) );
-  if( pIt->second.first != Self::Uint )
-    return( TUint( 0 ) );
-  return( TUint( std::atoi( pIt->second.second.c_str( ) ) ) );
+  TParameters::const_iterator 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.second.c_str( ) ) ) );
+
+  } // fi
+  return( TUint( 0 ) );
 }
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::Parameters::
 TReal cpPlugins::Interface::Parameters::
-GetValueAsReal( const TString& name ) const
+GetReal( const TString& name ) const
 {
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
-    return( TReal( 0 ) );
-  if( pIt->second.first != Self::Real )
-    return( TReal( 0 ) );
-  return( TReal( std::atof( pIt->second.second.c_str( ) ) ) );
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::Real )
+      return( TReal( std::atof( i->second.second.second.c_str( ) ) ) );
+
+  } // fi
+  return( TReal( 0 ) );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-GetValueAsStringList(
-  std::vector< TString >& lst, const TString& name
-  ) const
+GetStringList( std::vector< TString >& lst, const TString& name ) const
 {
   lst.clear( );
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
     return;
-  if( pIt->second.first != Self::StringList )
+  if( i->second.first != Self::StringList )
     return;
 
-  std::istringstream ss( pIt->second.second );
+  std::istringstream str( i->second.second.second );
   std::string token;
-  while( std::getline( ss, token, '#' ) )
-    if( token != "" )
-      lst.push_back( token );
+  while( std::getline( str, token, '#' ) )
+    lst.push_back( token );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-GetValueAsBoolList( std::vector< TBool >& lst, const TString& name ) const
+GetBoolList( std::vector< TBool >& lst, const TString& name ) const
 {
   lst.clear( );
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
     return;
-  if( pIt->second.first != Self::BoolList )
+  if( i->second.first != Self::BoolList )
     return;
 
-  std::istringstream ss( pIt->second.second );
+  std::istringstream str( i->second.second.second );
   std::string token;
-  while( std::getline( ss, token, '#' ) )
-    if( token != "" )
-      lst.push_back( TBool( std::atoi( token.c_str( ) ) == 1 ) );
+  while( std::getline( str, token, '#' ) )
+    lst.push_back( std::atoi( token.c_str( ) ) == 1 );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-GetValueAsIntList( std::vector< TInt >& lst, const TString& name ) const
+GetIntList( std::vector< TInt >& lst, const TString& name ) const
 {
   lst.clear( );
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
     return;
-  if( pIt->second.first != Self::IntList )
+  if( i->second.first != Self::IntList )
     return;
 
-  std::istringstream ss( pIt->second.second );
+  std::istringstream str( i->second.second.second );
   std::string token;
-  while( std::getline( ss, token, '#' ) )
-    if( token != "" )
-      lst.push_back( TInt( std::atoi( token.c_str( ) ) ) );
+  while( std::getline( str, token, '#' ) )
+    lst.push_back( TInt( std::atoi( token.c_str( ) ) ) );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-GetValueAsUintList( std::vector< TUint >& lst, const TString& name ) const
+GetUintList( std::vector< TUint >& lst, const TString& name ) const
 {
   lst.clear( );
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
     return;
-  if( pIt->second.first != Self::UintList )
+  if( i->second.first != Self::UintList )
     return;
 
-  std::istringstream ss( pIt->second.second );
+  std::istringstream str( i->second.second.second );
   std::string token;
-  while( std::getline( ss, token, '#' ) )
-    if( token != "" )
-      lst.push_back( TUint( std::atoi( token.c_str( ) ) ) );
+  while( std::getline( str, token, '#' ) )
+    lst.push_back( TUint( std::atoi( token.c_str( ) ) ) );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Parameters::
-GetValueAsRealList( std::vector< TReal >& lst, const TString& name ) const
+GetRealList( std::vector< TReal >& lst, const TString& name ) const
 {
   lst.clear( );
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
     return;
-  if( pIt->second.first != Self::RealList )
+  if( i->second.first != Self::RealList )
     return;
 
-  std::istringstream ss( pIt->second.second );
+  std::istringstream str( i->second.second.second );
   std::string token;
-  while( std::getline( ss, token, '#' ) )
-    if( token != "" )
-      lst.push_back( TReal( std::atof( token.c_str( ) ) ) );
+  while( std::getline( str, token, '#' ) )
+    lst.push_back( TReal( std::atof( token.c_str( ) ) ) );
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasStringValue( const TString& name ) const
-{
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::String );
-  return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasBoolValue( const TString& name ) const
-{
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::Bool );
-  return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasIntValue( const TString& name ) const
-{
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::Int );
-  return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasUintValue( const TString& name ) const
+void cpPlugins::Interface::Parameters::
+GetChoices( std::vector< TString >& choices, const TString& name ) const
 {
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::Uint );
-  return( false );
-}
+  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;
 
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasRealValue( const TString& name ) const
-{
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::Real );
-  return( false );
+  std::istringstream str( i->second.second.first );
+  std::string token;
+  while( std::getline( str, token, '#' ) )
+    choices.push_back( token );
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasIndexValue( const TString& name ) const
+cpPlugins::Interface::Parameters::
+TString cpPlugins::Interface::Parameters::
+GetSelectedChoice( const TString& name ) const
 {
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::Index );
-  return( false );
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
+    return( "" );
+  if( i->second.first != Self::Choices )
+    return( "" );
+  return( i->second.second.second );
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasPointValue( const TString& name ) const
+void cpPlugins::Interface::Parameters::
+SetString( const TString& name, const TString& v )
 {
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::Point );
-  return( false );
-}
+  TParameters::iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
+    return;
+  if( i->second.first != Self::String )
+    return;
+  i->second.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.second = str.str( );                       \
+    this->Modified( );                                          \
+  }
 
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasStringListValue( const TString& name ) const
-{
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::StringList );
-  return( false );
-}
+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.second == "" )                         \
+      str << v;                                                 \
+    else                                                        \
+      str << "#" << v;                                          \
+    i->second.second.second += str.str( );                      \
+    this->Modified( );                                          \
+  }
 
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasBoolListValue( const TString& name ) const
-{
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::BoolList );
-  return( false );
-}
+cpPlugins_Parameters_Add( String );
+cpPlugins_Parameters_Add( Bool );
+cpPlugins_Parameters_Add( Int );
+cpPlugins_Parameters_Add( Uint );
+cpPlugins_Parameters_Add( Real );
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Parameters_Clear( Y )                         \
+  void cpPlugins::Interface::Parameters::                       \
+  Clear##Y##List( const TString& name )                         \
+  {                                                             \
+    TParameters::iterator i = this->m_Parameters.find( name );  \
+    if( i == this->m_Parameters.end( ) )                        \
+      return;                                                   \
+    if( i->second.first != Self::Y )                            \
+      return;                                                   \
+    i->second.second.second = "";                               \
+    this->Modified( );                                          \
+  }
 
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasIntListValue( const TString& name ) const
-{
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::IntList );
-  return( false );
-}
+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 );
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Parameters::
-HasUintListValue( const TString& name ) const
-{
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::UintList );
-  return( false );
+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 );
+  if( i->second.second.first.find( choice ) != std::string::npos )
+  {
+    i->second.second.second = choice;
+    this->Modified( );
+    return( true );
+  }
+  else
+    return( false );
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasRealListValue( const TString& name ) const
+cpPlugins::Interface::Parameters::
+Parameters( )
+  : Superclass( )
 {
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::RealList );
-  return( false );
+  this->Clear( );
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasIndexListValue( const TString& name ) const
+cpPlugins::Interface::Parameters::
+~Parameters( )
 {
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::IndexList );
-  return( false );
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Interface::Parameters::
-HasPointListValue( const TString& name ) const
-{
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt != this->m_Parameters.end( ) )
-    return( pIt->second.first == Self::PointList );
-  return( false );
+void cpPlugins::Interface::Parameters::
+PrintSelf( std::ostream& os, itk::Indent indent ) const
+{
+  TParameters::const_iterator i = this->m_Parameters.begin( );
+  for( ; i != this->m_Parameters.end( ); ++i )
+    os << indent
+       << i->first << ": ("
+       << i->second.first << " | "
+       << i->second.second.first << " | "
+       << i->second.second.second << ")"
+       << std::endl;
 }
 
 // eof - $RCSfile$
index 0e54f0f7fdfae594e9fd9a55cb7042fde4a22a10..abde990d0759714b422a594c28fe9722c938abf8 100644 (file)
@@ -1,11 +1,15 @@
 #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__H__
 #define __CPPLUGINS__INTERFACE__PARAMETERS__H__
 
+#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+
 #include <map>
 #include <ostream>
 #include <string>
 #include <vector>
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+
+#include <itkObject.h>
+#include <itkObjectFactory.h>
 
 namespace cpPlugins
 {
@@ -14,28 +18,13 @@ namespace cpPlugins
     /**
      */
     class cpPlugins_Interface_EXPORT Parameters
+      : public itk::Object
     {
-      // -------------------------------------------------------------------
-      friend std::ostream& operator<<(
-        std::ostream& os, const Parameters& p
-        )
-      {
-        Parameters::TParameters::const_iterator pIt =
-          p.m_Parameters.begin( );
-        for( ; pIt != p.m_Parameters.end( ); ++pIt )
-        {
-          os
-            << pIt->first << ": ("
-            << pIt->second.first << ", "
-            << pIt->second.second << ")"
-            << std::endl;
-
-        } // rof
-        return( os );
-      }
-
     public:
-      typedef Parameters Self;
+      typedef Parameters                      Self;
+      typedef itk::Object                     Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
 
       enum Type
       {
@@ -43,7 +32,8 @@ namespace cpPlugins
         Uint      , Real       , Index    ,
         Point     , StringList , BoolList ,
         IntList   , UintList   , RealList ,
-        IndexList , PointList  , NoType
+        IndexList , PointList  , Choices  ,
+        NoType
       };
 
       typedef bool          TBool;
@@ -52,97 +42,156 @@ namespace cpPlugins
       typedef double        TReal;
       typedef std::string   TString;
 
-      typedef std::pair< Self::Type, TString > TParameter;
+      // NOTE: std::pair< default, value >
+      typedef std::pair< TString, TString >    TValues;
+      typedef std::pair< Self::Type, TValues > TParameter;
       typedef std::map< TString, TParameter >  TParameters;
 
     public:
-      Parameters( );
-      Parameters( const Self& other );
-      virtual ~Parameters( );
-
-      Self& operator=( const Self& other );
+      itkNewMacro( Self );
+      itkTypeMacro( cpPlugins::Interface::Parameters, itk::Object );
 
+    public:
+      // Parameters container configuration
       void Clear( );
-      void Configure( const Self::Type& type, const TString& name );
-      void SetValueAsString( const TString& name, const TString& v );
-      void SetValueAsBool( const TString& name, const TBool& v );
-      void SetValueAsInt( const TString& name, const TInt& v );
-      void SetValueAsUint( const TString& name, const TUint& v );
-      void SetValueAsReal( const TString& name, const TReal& v );
-      void SetValueAsIndex( const TString& name, const TUint& n, ... );
-      void SetValueAsPoint( const TString& name, const TUint& n, ... );
-
-      void AddValueToStringList( const TString& name, const TString& v );
-      void AddValueToBoolList( const TString& name, const TBool& v );
-      void AddValueToIntList( const TString& name, const TInt& v );
-      void AddValueToUintList( const TString& name, const TUint& v );
-      void AddValueToRealList( const TString& name, const TReal& v );
-      void AddValueToIndexList( const TString& name, const TUint& n, ... );
-      void AddValueToPointList( const TString& name, const TUint& n, ... );
 
-      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 );
-      
-      std::vector< TString > GetParameters( ) const;
-      Self::Type GetParameterType( const TString& name ) const;
-      const TString& GetRawValue( const TString& name ) const;
-      const TString& GetValueAsString( const TString& name ) const;
-      TBool GetValueAsBool( const TString& name ) const;
-      TInt GetValueAsInt( const TString& name ) const;
-      TUint GetValueAsUint( const TString& name ) const;
-      TReal GetValueAsReal( const TString& name ) const;
+      void ConfigureAsString( const TString& name, const TString& v );
+      void ConfigureAsBool( const TString& name, const TBool& v );
+      void ConfigureAsInt( const TString& name, const TInt& v );
+      void ConfigureAsUint( const TString& name, const TUint& v );
+      void ConfigureAsReal( const TString& name, const TReal& v );
 
       template< class I >
-      I GetValueAsIndex( const TString& name ) const;
-
+        inline void ConfigureAsIndex(
+          const TString& name, const TUint& dim, const I& v
+          );
       template< class P >
-      P GetValueAsPoint( const TString& name ) const;
-
-      void GetValueAsStringList(
+        inline void ConfigureAsPoint(
+          const TString& name, const TUint& dim, const P& v
+          );
+
+      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 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 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 HasChoices( const TString& name ) const;
+
+      TString GetString( const TString& name ) 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 GetValueAsBoolList(
+      void GetBoolList(
         std::vector< TBool >& lst, const TString& name
         ) const;
-      void GetValueAsIntList(
+      void GetIntList(
         std::vector< TInt >& lst, const TString& name
         ) const;
-      void GetValueAsUintList(
+      void GetUintList(
         std::vector< TUint >& lst, const TString& name
         ) const;
-      void GetValueAsRealList(
+      void GetRealList(
         std::vector< TReal >& lst, const TString& name
         ) const;
 
-      template< class I >
-      void GetValueAsIndexList(
-        std::vector< I >& lst, const TString& name
+      void GetChoices(
+        std::vector< TString >& choices, const TString& name
         ) const;
+      TString GetSelectedChoice( const TString& name ) const;
 
+      template< class I >
+        inline I GetIndex( const TString& name, const TUint& dim ) const;
       template< class P >
-      void GetValueAsPointList(
-        std::vector< P >& lst, const TString& name
-        ) const;
+        inline P GetPoint( const TString& name, const TUint& dim ) const;
+
+      template< class I >
+        inline void GetIndexList(
+          std::vector< I >& lst, const TString& name, const TUint& dim
+          ) const;
+      template< class P >
+        inline void GetPointList(
+          std::vector< P >& lst, const TString& name, const TUint& dim
+          ) const;
+
+      // Set methods
+      void SetString( const TString& name, const TString& v );
+      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
+          );
+      template< class P >
+        inline void SetPoint(
+          const TString& name, const TUint& dim, const P& 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 );
 
-      bool HasStringValue( const TString& name ) const;
-      bool HasBoolValue( const TString& name ) const;
-      bool HasIntValue( const TString& name ) const;
-      bool HasUintValue( const TString& name ) const;
-      bool HasRealValue( const TString& name ) const;
-      bool HasIndexValue( const TString& name ) const;
-      bool HasPointValue( const TString& name ) const;
-      bool HasStringListValue( const TString& name ) const;
-      bool HasBoolListValue( const TString& name ) const;
-      bool HasIntListValue( const TString& name ) const;
-      bool HasUintListValue( const TString& name ) const;
-      bool HasRealListValue( const TString& name ) const;
-      bool HasIndexListValue( const TString& name ) const;
-      bool HasPointListValue( const TString& name ) const;
+      template< class I >
+        inline void AddToIndexList(
+          const TString& name, const TUint& dim, const I& v
+          );
+      template< class P >
+        inline void AddToPointList(
+          const TString& name, const TUint& 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 );
+
+      bool SetSelectedChoice( const TString& name, const TString& choice );
+
+    protected:
+      Parameters( );
+      virtual ~Parameters( );
+      void PrintSelf( std::ostream& os, itk::Indent indent ) const;
+
+    private:
+      // Purposely not implemented
+      Parameters( const Self& other );
+      Self& operator=( const Self& other );
 
     protected:
       TParameters m_Parameters;
index e47b799c7616e2c85ea7148bb4eb4fe2956e22a4..791d526263ad5584ab0b0bfe73010e7403d7ba6a 100644 (file)
 #ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
 #define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
 
-#include <cstdlib>
-#include <iostream>
-#include <sstream>
+// -------------------------------------------------------------------------
+template< class I >
+void cpPlugins::Interface::Parameters::
+ConfigureAsIndex( const TString& name, const TUint& dim, const I& v )
+{
+  std::stringstream str;
+  str << v[ 0 ];
+  for( unsigned int d = 1; d < dim; ++d )
+    str << ";" << v[ d ];
+  std::string s = str.str( );
+  this->m_Parameters[ name ] = TParameter( Self::Index, TValues( s, s ) );
+  this->Modified( );
+}
 
 // -------------------------------------------------------------------------
-#define cpPlugins_Interface_Parameters_SetIndexOrPointMacro( NAME, TYPE ) \
-  template< class T >                                                   \
-  T cpPlugins::Interface::Parameters::                                  \
-  GetValueAs##NAME( const TString& name ) const                         \
-  {                                                                     \
-    T val;                                                              \
-    TParameters::const_iterator pIt = this->m_Parameters.find( name );  \
-    if( pIt != this->m_Parameters.end( ) )                              \
-    {                                                                   \
-      if( pIt->second.first == Self::NAME )                             \
-      {                                                                 \
-        std::istringstream ss( pIt->second.second );                    \
-        std::string token;                                              \
-        unsigned int i = 0;                                             \
-        while( std::getline( ss, token, ',' ) )                         \
-        {                                                               \
-          if( token != "" )                                             \
-            val[ i++ ] = TYPE( std::atof( token.c_str( ) ) );           \
-        }                                                               \
-      }                                                                 \
-    }                                                                   \
-    return( val );                                                      \
-  }
-
-cpPlugins_Interface_Parameters_SetIndexOrPointMacro( Index, long );
-cpPlugins_Interface_Parameters_SetIndexOrPointMacro( Point, double );
+template< class P >
+void cpPlugins::Interface::Parameters::
+ConfigureAsPoint( const TString& name, const TUint& dim, const P& v )
+{
+  std::stringstream str;
+  str << v[ 0 ];
+  for( unsigned int d = 1; d < dim; ++d )
+    str << ";" << v[ d ];
+  std::string s = str.str( );
+  this->m_Parameters[ name ] = TParameter( Self::Point, TValues( s, s ) );
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+I cpPlugins::Interface::Parameters::
+GetIndex( const TString& name, const TUint& dim ) const
+{
+  I v;
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::Index )
+    {
+      std::istringstream str( i->second.second.second );
+      std::string token;
+      unsigned int d = 0;
+      while( std::getline( str, token, ';' ) && d < dim )
+      {
+        v[ d ] = std::atoi( token.c_str( ) );
+        d++;
+
+      } // elihw
+      return( v );
+
+    } // fi
+
+  } // fi
+
+  // If parameter not found
+  for( unsigned int d = 0; d < dim; ++d )
+    v[ d ] = 0;
+  return( v );
+}
+
+// -------------------------------------------------------------------------
+template< class P >
+P cpPlugins::Interface::Parameters::
+GetPoint( const TString& name, const TUint& dim ) const
+{
+  P v;
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i != this->m_Parameters.end( ) )
+  {
+    if( i->second.first == Self::Point )
+    {
+      std::istringstream str( i->second.second.second );
+      std::string token;
+      unsigned int d = 0;
+      while( std::getline( str, token, ';' ) && d < dim )
+      {
+        v[ d ] = std::atof( token.c_str( ) );
+        d++;
+
+      } // elihw
+      return( v );
+
+    } // fi
+
+  } // fi
+
+  // If parameter not found
+  for( unsigned int d = 0; d < dim; ++d )
+    v[ d ] = float( 0 );
+  return( v );
+}
 
 // -------------------------------------------------------------------------
 template< class I >
 void cpPlugins::Interface::Parameters::
-GetValueAsIndexList( std::vector< I >& lst, const TString& name ) const
+GetIndexList(
+  std::vector< I >& lst, const TString& name, const TUint& dim
+  ) const
 {
   lst.clear( );
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
+
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
     return;
-  if( pIt->second.first != Self::IndexList )
+  if( i->second.first == Self::IndexList )
     return;
 
-  std::istringstream ss( pIt->second.second );
+  std::istringstream str( i->second.second.second );
   std::string token;
-  while( std::getline( ss, token, ':' ) )
+  unsigned int d = 0;
+  while( std::getline( str, token, '#' ) )
   {
-    if( token != "" )
+    std::istringstream str2( token );
+    std::string token2;
+    unsigned int d = 0;
+    I v;
+    while( std::getline( str2, token2, ';' ) && d < dim )
     {
-      std::istringstream ts( token );
-      std::string text;
-      unsigned int i = 0;
-      I idx;
-      while( std::getline( ts, text, ',' ) )
-        if( text != "" )
-          idx[ i++ ] = std::atoi( text.c_str( ) );
-      lst.push_back( idx );
+      v[ d ] = std::atoi( token.c_str( ) );
+      d++;
 
-    } // fi
+    } // elihw
+    lst.push_back( v );
 
   } // elihw
 }
@@ -68,35 +131,120 @@ GetValueAsIndexList( std::vector< I >& lst, const TString& name ) const
 // -------------------------------------------------------------------------
 template< class P >
 void cpPlugins::Interface::Parameters::
-GetValueAsPointList( std::vector< P >& lst, const TString& name ) const
+GetPointList(
+  std::vector< P >& lst, const TString& name, const TUint& dim
+  ) const
 {
   lst.clear( );
-  TParameters::const_iterator pIt = this->m_Parameters.find( name );
-  if( pIt == this->m_Parameters.end( ) )
+
+  TParameters::const_iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
     return;
-  if( pIt->second.first != Self::PointList )
+  if( i->second.first == Self::PointList )
     return;
 
-  std::istringstream ss( pIt->second.second );
+  std::istringstream str( i->second.second.second );
   std::string token;
-  while( std::getline( ss, token, ':' ) )
+  unsigned int d = 0;
+  while( std::getline( str, token, '#' ) )
   {
-    if( token != "" )
+    std::istringstream str2( token );
+    std::string token2;
+    unsigned int d = 0;
+    P v;
+    while( std::getline( str2, token2, ';' ) && d < dim )
     {
-      std::istringstream ts( token );
-      std::string text;
-      unsigned int i = 0;
-      P pnt;
-      while( std::getline( ts, text, ',' ) )
-        if( text != "" )
-          pnt[ i++ ] = std::atof( text.c_str( ) );
-      lst.push_back( pnt );
+      v[ d ] = std::atof( token.c_str( ) );
+      d++;
 
-    } // fi
+    } // elihw
+    lst.push_back( v );
 
   } // elihw
 }
 
+// -------------------------------------------------------------------------
+template< class I >
+void cpPlugins::Interface::Parameters::
+SetIndex( const TString& name, const TUint& dim, const I& v )
+{
+  TParameters::iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
+    return;
+  if( i->second.first != Self::Index )
+    return;
+
+  std::stringstream str;
+  str << v[ 0 ];
+  for( unsigned int d = 1; d < dim; ++d )
+    str << ";" << v[ d ];
+  i->second.second.second = str.str( );
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class P >
+void cpPlugins::Interface::Parameters::
+SetPoint( const TString& name, const TUint& dim, const P& v )
+{
+  TParameters::iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
+    return;
+  if( i->second.first != Self::Point )
+    return;
+
+  std::stringstream str;
+  str << v[ 0 ];
+  for( unsigned int d = 1; d < dim; ++d )
+    str << ";" << v[ d ];
+  i->second.second.second = str.str( );
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+void cpPlugins::Interface::Parameters::
+AddToIndexList( const TString& name, const TUint& dim, const I& v )
+{
+  TParameters::iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
+    return;
+  if( i->second.first != Self::IndexList )
+    return;
+
+  std::stringstream str;
+  if( i->second.second.second == "" )
+    str << v[ 0 ];
+  else
+    str << "#" << v[ 0 ];
+  for( unsigned int d = 1; d < dim; ++d )
+    str << ";" << v[ d ];
+  i->second.second.second += str.str( );
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class P >
+void cpPlugins::Interface::Parameters::
+AddToPointList( const TString& name, const TUint& dim, const P& v )
+{
+  TParameters::iterator i = this->m_Parameters.find( name );
+  if( i == this->m_Parameters.end( ) )
+    return;
+  if( i->second.first != Self::PointList )
+    return;
+
+  std::stringstream str;
+  if( i->second.second.second == "" )
+    str << v[ 0 ];
+  else
+    str << "#" << v[ 0 ];
+  for( unsigned int d = 1; d < dim; ++d )
+    str << ";" << v[ d ];
+  i->second.second.second += str.str( );
+  this->Modified( );
+}
+
 #endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
 
 // eof - $RCSfile$
index decfdc0914fcedd30d25cdff3f81a0a5b7756171..9f6aadcdbc910fd960cbcb233ff19cc9b0b64c64 100644 (file)
@@ -18,7 +18,7 @@
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::
 ParametersQtDialog(
-  Parameters& parameters, const std::string& title, QWidget* parent
+  Parameters* parameters, const std::string& title, QWidget* parent
   )
 {
   // Create dialog with a simple layout
@@ -34,11 +34,12 @@ ParametersQtDialog(
   verticalLayout->addWidget( dlg_title );
 
   // Put values
-  std::vector< std::string > names = parameters.GetParameters( );
+  std::vector< std::string > names;
+  parameters->GetNames( names );
   std::vector< std::string >::const_iterator nIt = names.begin( );
   for( ; nIt != names.end( ); ++nIt )
   {
-    Parameters::Type pt = parameters.GetParameterType( *nIt );
+    Parameters::Type pt = parameters->GetType( *nIt );
 
     /* TODO
        enum Type
@@ -66,7 +67,7 @@ ParametersQtDialog(
     {
       QCheckBox* v_bool = new QCheckBox( dlg );
       v_bool->setText( "[ON/OFF]" );
-      v_bool->setChecked( parameters.GetValueAsBool( *nIt ) );
+      v_bool->setChecked( parameters->GetBool( *nIt ) );
       w_input = v_bool;
     }
     else if( pt == Parameters::Uint )
@@ -74,7 +75,7 @@ ParametersQtDialog(
       QSpinBox* v_uint = new QSpinBox( dlg );
       v_uint->setMinimum( 0 );
       v_uint->setMaximum( std::numeric_limits< int >::max( ) );
-      v_uint->setValue( parameters.GetValueAsUint( *nIt ) );
+      v_uint->setValue( parameters->GetUint( *nIt ) );
       w_input = v_uint;
     }
     else if( pt == Parameters::Int )
@@ -82,7 +83,7 @@ ParametersQtDialog(
       QSpinBox* v_int = new QSpinBox( dlg );
       v_int->setMinimum( -std::numeric_limits< int >::max( ) );
       v_int->setMaximum(  std::numeric_limits< int >::max( ) );
-      v_int->setValue( parameters.GetValueAsInt( *nIt ) );
+      v_int->setValue( parameters->GetInt( *nIt ) );
       w_input = v_int;
     }
     else if( pt == Parameters::Real )
@@ -91,7 +92,7 @@ ParametersQtDialog(
       v_double->setDecimals( 3 );
       v_double->setMinimum( -std::numeric_limits< double >::max( ) );
       v_double->setMaximum(  std::numeric_limits< double >::max( ) );
-      v_double->setValue( parameters.GetValueAsReal( *nIt ) );
+      v_double->setValue( parameters->GetReal( *nIt ) );
       w_input = v_double;
     }
     else if(
@@ -141,37 +142,37 @@ ParametersQtDialog(
   nIt = names.begin( );
   for( ; nIt != names.end( ); ++nIt )
   {
-    Parameters::Type pt = parameters.GetParameterType( *nIt );
+    Parameters::Type pt = parameters->GetType( *nIt );
     if( pt == Parameters::String )
     {
       QLineEdit* v_string = dlg->findChild< QLineEdit* >( nIt->c_str( ) );
       if( v_string != NULL )
-        parameters.SetValueAsString( *nIt, v_string->text( ).toStdString( ) );
+        parameters->SetString( *nIt, v_string->text( ).toStdString( ) );
     }
     else if( pt == Parameters::Bool )
     {
       QCheckBox* v_bool = dlg->findChild< QCheckBox* >( nIt->c_str( ) );
       if( v_bool != NULL )
-        parameters.SetValueAsBool( *nIt, v_bool->isChecked( ) );
+        parameters->SetBool( *nIt, v_bool->isChecked( ) );
     }
     else if( pt == Parameters::Uint )
     {
       QSpinBox* v_uint = dlg->findChild< QSpinBox* >( nIt->c_str( ) );
       if( v_uint != NULL )
-        parameters.SetValueAsUint( *nIt, v_uint->value( ) );
+        parameters->SetUint( *nIt, v_uint->value( ) );
     }
     else if( pt == Parameters::Int )
     {
       QSpinBox* v_int = dlg->findChild< QSpinBox* >( nIt->c_str( ) );
       if( v_int != NULL )
-        parameters.SetValueAsInt( *nIt, v_int->value( ) );
+        parameters->SetInt( *nIt, v_int->value( ) );
     }
     else if( pt == Parameters::Real )
     {
       QDoubleSpinBox* v_double =
         dlg->findChild< QDoubleSpinBox* >( nIt->c_str( ) );
       if( v_double != NULL )
-        parameters.SetValueAsReal( *nIt, v_double->value( ) );
+        parameters->SetReal( *nIt, v_double->value( ) );
     }
     else if(
       pt == Parameters::StringList ||
@@ -190,25 +191,25 @@ ParametersQtDialog(
         {
           std::vector< std::string > values = l_double->GetStringValues( );
           for( int r = 0; r < values.size( ); ++r )
-            parameters.AddValueToStringList( *nIt, values[ r ] );
+            parameters->AddToStringList( *nIt, values[ r ] );
         }
         else if( pt == Parameters::IntList )
         {
           std::vector< int > values = l_double->GetIntValues( );
           for( int r = 0; r < values.size( ); ++r )
-            parameters.AddValueToIntList( *nIt, values[ r ] );
+            parameters->AddToIntList( *nIt, values[ r ] );
         }
         else if( pt == Parameters::UintList )
         {
           std::vector< unsigned int > values = l_double->GetUintValues( );
           for( int r = 0; r < values.size( ); ++r )
-            parameters.AddValueToUintList( *nIt, values[ r ] );
+            parameters->AddToUintList( *nIt, values[ r ] );
         }
         else if( pt == Parameters::RealList )
         {
           std::vector< double > values = l_double->GetDoubleValues( );
           for( int r = 0; r < values.size( ); ++r )
-            parameters.AddValueToRealList( *nIt, values[ r ] );
+            parameters->AddToRealList( *nIt, values[ r ] );
 
         } // fi
 
index 6cc8ea4682c0f358a681dcb98fc64e2688cc2f5b..ea9f84de53ebc017dc137c0949b57c1becc04164 100644 (file)
@@ -15,7 +15,7 @@ namespace cpPlugins
   namespace Interface
   {
     bool cpPlugins_Interface_EXPORT ParametersQtDialog(
-      Parameters& parameters,
+      Parameters* parameters,
       const std::string& title,
       QWidget* parent = NULL
       );
index b2b9337d1ea8ccb07ee17bc1a392d7fc12070d9b..f832743feb2d5ce57eb43af8f7e1046e8a2550a4 100644 (file)
@@ -5,19 +5,19 @@
 #endif // cpPlugins_Interface_QT4
 
 // -------------------------------------------------------------------------
-const cpPlugins::Interface::Parameters&
 cpPlugins::Interface::ProcessObject::
-GetDefaultParameters( ) const
+TParameters* cpPlugins::Interface::ProcessObject::
+GetParameters( )
 {
-  return( this->m_DefaultParameters );
+  return( this->m_Parameters.GetPointer( ) );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-SetParameters( const cpPlugins::Interface::Parameters& params )
+const cpPlugins::Interface::ProcessObject::
+TParameters* cpPlugins::Interface::ProcessObject::
+GetParameters( ) const
 {
-  this->m_Parameters = params;
-  this->Modified( );
+  return( this->m_Parameters.GetPointer( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -104,14 +104,15 @@ ExecConfigurationDialog( QWidget* parent )
 
 #ifdef cpPlugins_Interface_QT4
 
-  Parameters parameters = this->m_DefaultParameters;
   r = cpPlugins::Interface::ParametersQtDialog(
-    parameters,
+    this->m_Parameters,
     this->GetClassName( ) + std::string( " basic configuration" ),
     parent
     );
-  if( r )
-    this->m_Parameters = parameters;
+  /*
+    if( r )
+    // TODO: !!! this->m_Parameters = parameters;
+    */
 
 #endif // cpPlugins_Interface_QT4
 
@@ -125,6 +126,7 @@ ProcessObject( )
     m_ITKObject( NULL ),
     m_VTKObject( NULL )
 {
+  this->m_Parameters = TParameters::New( );
 }
 
 // -------------------------------------------------------------------------
index b84ad3ed6dd956fd02b9895f39b66931859e8a71..9cf1924992d2396d4e93f20e97a3ae81270a40b4 100644 (file)
@@ -33,6 +33,8 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >       Pointer;
       typedef itk::SmartPointer< const Self > ConstPointer;
 
+      typedef Parameters TParameters;
+
     public:
       itkTypeMacro( ProcessObject, Object );
       cpPlugins_Id_Macro(
@@ -40,8 +42,8 @@ namespace cpPlugins
         );
 
     public:
-      virtual const Parameters& GetDefaultParameters( ) const;
-      virtual void SetParameters( const Parameters& params );
+      virtual TParameters* GetParameters( );
+      virtual const TParameters* GetParameters( ) const;
 
       virtual unsigned int GetNumberOfInputs( ) const;
       virtual unsigned int GetNumberOfOutputs( ) const;
@@ -104,8 +106,7 @@ namespace cpPlugins
       itk::ProcessObject::Pointer     m_ITKObject;
       vtkSmartPointer< vtkAlgorithm > m_VTKObject;
 
-      Parameters m_DefaultParameters;
-      Parameters m_Parameters;
+      Parameters::Pointer m_Parameters;
 
       std::vector< DataObject::Pointer > m_Inputs;
       std::vector< DataObject::Pointer > m_Outputs;
index 6fe1263cf23ade46b94ff02cf84ef6e6e7d02d09..f0ab717f050ab346063cc3dc765df69879bd56e5 100644 (file)
@@ -1,6 +1,6 @@
 SUBDIRS(
   IO
-  BasicFilters
+  ## BasicFilters
   )
 
 ## eof - $RCSfile$
index 64bec97ee509f757048622affe663c5896f4d9f4..60b33b67998b0961d7c04b934c87f9a725fca907 100644 (file)
@@ -25,14 +25,13 @@ ExecConfigurationDialog( QWidget* parent )
   dialog.setNameFilter( QFileDialog::tr( "All files (*)" ) );
   if( dialog.exec( ) )
   {
-    this->m_Parameters = this->m_DefaultParameters;
     QStringList names = dialog.selectedFiles( );
     QStringList::const_iterator qIt = names.begin( );
     for( ; qIt != names.end( ); ++qIt )
-      this->m_Parameters.AddValueToStringList(
+      this->m_Parameters->AddToStringList(
         "FileNames", qIt->toStdString( )
         );
-    this->m_Parameters.SetValueAsBool( "VectorType", false );
+    this->m_Parameters->SetBool( "VectorType", false );
     r = true;
 
   } // fi
@@ -50,11 +49,8 @@ ImageReader( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::StringList, "FileNames" );
-  this->m_DefaultParameters.Configure( Parameters::Bool, "VectorType" );
-  this->m_DefaultParameters.SetValueAsBool( "VectorType", false );
-  this->m_Parameters = this->m_DefaultParameters;
+  this->m_Parameters->ConfigureAsStringList( "FileNames" );
+  this->m_Parameters->ConfigureAsBool( "VectorType", false );
 }
 
 // -------------------------------------------------------------------------
@@ -69,7 +65,7 @@ _GenerateData( )
 {
   // Get filenames
   TStringList names;
-  this->m_Parameters.GetValueAsStringList( names, "FileNames" );
+  this->m_Parameters->GetStringList( names, "FileNames" );
 
   std::string r = "";
   if( names.size( ) >= 1 )
@@ -344,7 +340,7 @@ template< class P, unsigned int D >
 std::string cpPlugins::IO::ImageReader::
 _GD1( const TStringList& names )
 {
-  if( this->m_Parameters.GetValueAsBool( "VectorType" ) )
+  if( this->m_Parameters->GetBool( "VectorType" ) )
     return( this->_RealGD< itk::VectorImage< P, D > >( names ) );
   else
     return( this->_RealGD< itk::Image< P, D > >( names ) );
index 97937621cee4d7700e0d7b54dbea60fe954f08ce..2f41e10ceb99021c0dd11bd42ee81b519e17d4fb 100644 (file)
@@ -26,9 +26,8 @@ namespace cpPlugins
       typedef itk::SmartPointer< Self >         Pointer;
       typedef itk::SmartPointer< const Self >   ConstPointer;
 
-      typedef
-        std::vector< cpPlugins::Interface::Parameters::TString >
-        TStringList;
+      typedef Superclass::TParameters TParameters;
+      typedef std::vector< TParameters::TString > TStringList;
 
     public:
       itkNewMacro( Self );
index c2b9b8a9795f461d8547968c7d76d63320249d36..7dd131305cc7b202817d7334d5bdcc02d8ac1320 100644 (file)
@@ -10,9 +10,7 @@ ImageWriter( )
 {
   this->SetNumberOfInputs( 1 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
-  this->m_Parameters = this->m_DefaultParameters;
+  this->m_Parameters->ConfigureAsString( "FileName", "" );
 }
 
 // -------------------------------------------------------------------------
@@ -32,14 +30,13 @@ _GenerateData( )
 
   itk::DataObject* itk_image = NULL;
   std::string r = "";
-  /*
   cpPlugins_Image_Demangle_AllTypes( 2, image, itk_image, r, _RealGD );
   else cpPlugins_Image_Demangle_AllTypes( 3, image, itk_image, r, _RealGD );
   else cpPlugins_Image_Demangle_AllTypes( 4, image, itk_image, r, _RealGD );
   else cpPlugins_VectorImage_Demangle_AllTypes( 2, image, itk_image, r, _RealGD );
   else cpPlugins_VectorImage_Demangle_AllTypes( 3, image, itk_image, r, _RealGD );
   else cpPlugins_VectorImage_Demangle_AllTypes( 4, image, itk_image, r, _RealGD );
-  else */r = "ImageWriter: Input image type not supported.";
+  else r = "ImageWriter: Input image type not supported.";
 
   return( r );
 }
@@ -50,7 +47,7 @@ std::string cpPlugins::IO::ImageWriter::
 _RealGD( itk::DataObject* image )
 {
   // Get filename
-  std::string fname = this->m_Parameters.GetValueAsString( "FileName" );
+  std::string fname = this->m_Parameters->GetString( "FileName" );
 
   typedef itk::ImageFileWriter< I > _W;
   _W* writer = this->_CreateITK< _W >( );
index fe61d707532d52b9b91f5ab724f6330d39ac026a..397b644ef10b402d267a5e0fadd98a7571e239fd 100644 (file)
@@ -23,16 +23,10 @@ ExecConfigurationDialog( QWidget* parent )
   dialog.setNameFilter( QFileDialog::tr( "All files (*)" ) );
   if( dialog.exec( ) )
   {
-    this->m_Parameters = this->m_DefaultParameters;
     QStringList names = dialog.selectedFiles( );
-    this->m_Parameters.SetValueAsString(
-      "FileName", names[ 0 ].toStdString( )
-      );
-
-    /* TODO
-       this->m_Parameters.SetValueAsString( "PixelType", "float" );
-       this->m_Parameters.SetValueAsUint( "Dimension", 3 );
-    */
+    this->m_Parameters->SetString( "FileName", names[ 0 ].toStdString( ) );
+    this->m_Parameters->SetSelectedChoice( "PixelType", "float" );
+    this->m_Parameters->SetUint( "Dimension", 3 );
 
     r = true;
 
@@ -51,13 +45,12 @@ MeshReader( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
-  this->m_DefaultParameters.Configure( Parameters::String, "PixelType" );
-  this->m_DefaultParameters.Configure( Parameters::Uint, "Dimension" );
-  this->m_DefaultParameters.SetValueAsString( "PixelType", "float" );
-  this->m_DefaultParameters.SetValueAsUint( "Dimension", 3 );
-  this->m_Parameters = this->m_DefaultParameters;
+  std::vector< TParameters::TString > valid_types;
+  valid_types.push_back( "float" );
+  valid_types.push_back( "double" );
+  this->m_Parameters->ConfigureAsString( "FileName", "" );
+  this->m_Parameters->ConfigureAsChoices( "PixelType", valid_types );
+  this->m_Parameters->ConfigureAsUint( "Dimension", 3 );
 }
 
 // -------------------------------------------------------------------------
@@ -71,7 +64,7 @@ std::string cpPlugins::IO::MeshReader::
 _GenerateData( )
 {
   using namespace cpPlugins::Interface;
-  Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" );
+  Parameters::TUint dim = this->m_Parameters->GetUint( "Dimension" );
   std::string r = "MeshReader: Mesh dimension not supported.";
   if( dim == 2 )
     r = this->_GD0< 2 >( );
@@ -86,7 +79,8 @@ std::string cpPlugins::IO::MeshReader::
 _GD0( )
 {
   using namespace cpPlugins::Interface;
-  Parameters::TString pt = this->m_Parameters.GetValueAsString( "PixelType" );
+  Parameters::TString pt =
+    this->m_Parameters->GetSelectedChoice( "PixelType" );
   std::string r = "MeshReader: Mesh pixel type not supported";
   if( pt == "float" )       r = this->_GD1< float, D >( );
   else if( pt == "double" ) r = this->_GD1< double, D >( );
@@ -99,9 +93,7 @@ std::string cpPlugins::IO::MeshReader::
 _GD1( )
 {
   // Get filename
-  using namespace cpPlugins::Interface;
-  Parameters::TString fname =
-    this->m_Parameters.GetValueAsString( "FileName" );
+  std::string fname = this->m_Parameters->GetString( "FileName" );
 
   vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( );
   pdr->SetFileName( fname.c_str( ) );
index 805ca0ee04b9ef0264bbeb197232654865ba6c13..d865c577b9c64db44723f69d3f44545ea6d47407 100644 (file)
@@ -12,9 +12,7 @@ MeshWriter( )
 {
   this->SetNumberOfInputs( 1 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
-  this->m_Parameters = this->m_DefaultParameters;
+  this->m_Parameters->ConfigureAsString( "FileName", "" );
 }
 
 // -------------------------------------------------------------------------
@@ -34,7 +32,7 @@ _GenerateData( )
   vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
   if( i == NULL )
     return( "MeshWriter: No suitable input." );
-  std::string fname = this->m_Parameters.GetValueAsString( "FileName" );
+  std::string fname = this->m_Parameters->GetString( "FileName" );
 
   vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( );
   pdw->SetInputData( i );