]> Creatis software - cpPlugins.git/commitdiff
Parameters are now part of the pipeline update process
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 13 Oct 2015 23:13:04 +0000 (18:13 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 13 Oct 2015 23:13:04 +0000 (18:13 -0500)
44 files changed:
CMakeLists.txt
COMPILATION
README
appli/ImageMPR/CMakeLists.txt
appli/ImageMPR/ImageMPR.cxx
appli/ImageMPR/ImageMPR.h
appli/ImageMPR/ImageMPR.ui
appli/ImageMPR/MementoState.cxx
appli/ImageMPR/Plugins.cfg.in [new file with mode: 0644]
lib/cpExtensions/QT/QuadSplitter.cxx
lib/cpExtensions/QT/QuadSplitter.h
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpExtensions/Visualization/ImageSliceActors.h
lib/cpExtensions/Visualization/MPRActors.cxx
lib/cpExtensions/Visualization/MPRActors.h
lib/cpExtensions/Visualization/MPRObjects.cxx
lib/cpExtensions/Visualization/MPRObjects.h
lib/cpPlugins/Interface/BaseMPRWindow.cxx
lib/cpPlugins/Interface/BaseMPRWindow.h
lib/cpPlugins/Interface/BaseMPRWindow.ui [deleted file]
lib/cpPlugins/Interface/CMakeLists.txt
lib/cpPlugins/Interface/Instances_itkMesh.cxx
lib/cpPlugins/Interface/Instances_itkVectorImage.cxx
lib/cpPlugins/Interface/Interface.cxx
lib/cpPlugins/Interface/Parameters.cxx
lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h
lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx
lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/FloodFillImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx
lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx
lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx
lib/cpPlugins/Plugins/CMakeLists.txt
lib/cpPlugins/Plugins/IO/ImageReader.cxx
lib/cpPlugins/Plugins/IO/ImageWriter.cxx
lib/cpPlugins/Plugins/IO/ImageWriter.h
lib/third_party/Pluma/DLibrary.cpp
lib/third_party/Pluma/Dir.cpp
lib/third_party/Pluma/Host.cpp
lib/third_party/Pluma/PluginManager.cpp

index 76b21ce10d7efb99d67b0bb61fddbc09a66cd609..fd4ebea50ad78735129b0ce6751b1a68d9a7f147 100644 (file)
@@ -47,19 +47,20 @@ ENDIF(BUILD_SHARED_LIBRARIES)
 ## = Packages and options =
 ## ========================
 
-# it seems that by default on Visual Studio Compiler supports c++11, so it only need to be test on other O.S.
-       if(NOT MSVC)
-       INCLUDE(CheckCXXCompilerFlag)
-       CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
-       CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
-       IF(COMPILER_SUPPORTS_CXX11)
-         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-       ELSEIF(COMPILER_SUPPORTS_CXX0X)
-         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-       ELSE()
-         MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
-       ENDIF()
-endif(NOT MSVC)
+# NOTE: It seems that by default on Visual Studio Compiler supports c++11,
+# so it only need to be test on other O.S.
+IF(NOT MSVC)
+  INCLUDE(CheckCXXCompilerFlag)
+  CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+  IF(COMPILER_SUPPORTS_CXX11)
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+  ELSEIF(COMPILER_SUPPORTS_CXX0X)
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+  ELSE()
+    MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
+  ENDIF()
+ENDIF(NOT MSVC)
 
 # Prepare header to build shared libs (windows)
 INCLUDE(GenerateExportHeader)
index b92c2ce29bfa90cddc7a4dd8c723c23ba7488481..de796b54af9667354ca426d2cf3cc1f7b2b5893f 100644 (file)
 
 @prerequisites
 
+  0. A decent compiler for your system:
+    Linux: g++ with c++11 support
+    Mac: Xcode
+    Windows: any Visual Studio >= 2010
+
   1. CMake (>=2.8.12.2)
+    Just use your favorite repository or get the installer from http://www.cmake.org.
 
-  2. Visualization Toolkit -VTK- (>=6.1.0)
-    2.1 Steps
-      Open CMake
-      Select the soruce and the binary folder
-      Select the desired version of generator to compile (Visual Studio 12 2013) and click on configure and wait until the options are enabled, and the make sure
-    2.2 Required cmake flags:
-      BUILD_EXAMPLES OFF
-      BUILD_SHARED_LIBS ON
-      BUILD_TESTING OFF
-      Module_VtkGUISupportQt ON
-      Module_VtkGUISupportQtOpenGL ON
-      Module_VtkGUISupportQtSql OFF
-      Module_VtkGUISupportQtWebkit OFF
+  2. [Optional] Qt (=4.8)
+    On linux just install the corresponding package. On Mac and Windows, download
+    the source code and compile it with your favorite compiler. Please be aware that:
+      - Both release and debug configs are needed.
+      - Compile Qt with only SHARED support.
+      - Compile Qt without Webkit support.
 
+  3. Visualization Toolkit -VTK- (>=6.1.0)
+    1. Download VTK source code from http://www.vtk.org, copy the downloaded
+       zip/tar.gz file to your work directory (say ~/sources), uncompress the
+       source file and create an empty folder (say ~/sources/vtk-build)
+    2. Execute cmake taking care to put two directories: the source dir (where
+       the VTK source code is after decompression) and the build dir (the new
+       empty folder you just created).
+    3. On linux/mac, it is easier to execute from a command line console:
+      $ cd ~/sources/vtk-build
+      *** WARNING: IF YOU INSTALLED QT ***
+      $ cmake -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
+              -DBUILD_DOCUMENTATION:BOOL=OFF \
+              -DBUILD_EXAMPLES:BOOL=OFF \
+              -DBUILD_SHARED_LIBS:BOOL=ON \
+              -DBUILD_TESTING:BOOL=OFF \
+              -DCMAKE_BUILD_TYPE:STRING=MinSizeRel \
+              -DModule_vtkGUISupportQt:BOOL=ON \
+              -DModule_vtkGUISupportQtOpenGL:BOOL=ON \
+              -DModule_vtkGUISupportQtSQL:BOOL=OFF \
+              -DModule_vtkGUISupportQtWebkit:BOOL=OFF \
+              -DCMAKE_INSTALL_PREFIX:PATH=~/local \
+              ~/source/the_folder_where_vtk_was_decompressed
+      *** WARNING: IF YOU DIDN'T INSTALLED QT ***
+      $ cmake -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
+              -DBUILD_DOCUMENTATION:BOOL=OFF \
+              -DBUILD_EXAMPLES:BOOL=OFF \
+              -DBUILD_SHARED_LIBS:BOOL=ON \
+              -DBUILD_TESTING:BOOL=OFF \
+              -DCMAKE_BUILD_TYPE:STRING=MinSizeRel \
+              -DModule_vtkGUISupportQt:BOOL=OFF \
+              -DModule_vtkGUISupportQtOpenGL:BOOL=OFF \
+              -DModule_vtkGUISupportQtSQL:BOOL=OFF \
+              -DModule_vtkGUISupportQtWebkit:BOOL=OFF \
+              -DCMAKE_INSTALL_PREFIX:PATH=~/local \
+              ~/source/the_folder_where_vtk_was_decompressed
+      $ make
+      ... WAIT A FEW MINUTES ...
+      $ make install
+    4. On windows, make sure that the following cmake variables are configured as:
+         BUILD_DOCUMENTATION:BOOL=OFF
+         BUILD_EXAMPLES:BOOL=OFF
+         BUILD_SHARED_LIBS:BOOL=ON
+         BUILD_TESTING:BOOL=OFF
+         CMAKE_BUILD_TYPE:STRING=MinSizeRel
+         Module_vtkGUISupportQt:BOOL=[OFF/ON] ** "ON", IF YOU INSTALLED Qt
+         Module_vtkGUISupportQtOpenGL:BOOL=[OFF/ON] ** "ON", IF YOU INSTALLED Qt
+         Module_vtkGUISupportQtSQL:BOOL=OFF \
+         Module_vtkGUISupportQtWebkit:BOOL=OFF \
+       NOTE: Normally, windows compilers already support c++11.
 
   3. Insight Toolkit -ITK- (>=4.6.0)
-    3.1 Required cmake flags:
-      BUILD_SHARED_LIBS:BOOL=ON
-      Module_ITKVtkGlue:BOOL=ON
+    1. Download ITK source code from http://www.itk.org, copy the downloaded
+       zip/tar.gz file to your work directory (say ~/sources), uncompress the
+       source file and create an empty folder (say ~/sources/itk-build)
+    2. Execute cmake taking care to put two directories: the source dir (where
+       the ITK source code is after decompression) and the build dir (the new
+       empty folder you just created).
+    3. On linux/mac, it is easier to execute from a command line console:
+      $ cd ~/sources/itk-build
+      $ cmake -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
+              -DBUILD_DOCUMENTATION:BOOL=OFF \
+              -DBUILD_EXAMPLES:BOOL=OFF \
+              -DBUILD_SHARED_LIBS:BOOL=ON \
+              -DBUILD_TESTING:BOOL=OFF \
+              -DCMAKE_BUILD_TYPE:STRING=MinSizeRel \
+              -DModule_ITKReview:BOOL=ON \
+              -DModule_ITKVtkGlue:BOOL=OFF \
+              -DCMAKE_INSTALL_PREFIX:PATH=~/local \
+              ~/source/the_folder_where_itk_was_decompressed
+      $ make
+      ... WAIT A FEW MINUTES ...
+      $ make install
+    4. On windows, make sure that the following cmake variables are configured as:
+         BUILD_DOCUMENTATION:BOOL=OFF
+         BUILD_EXAMPLES:BOOL=OFF
+         BUILD_SHARED_LIBS:BOOL=ON
+         BUILD_TESTING:BOOL=OFF
+         CMAKE_BUILD_TYPE:STRING=MinSizeRel
+         Module_ITKReview:BOOL=ON
+         Module_ITKVtkGlue:BOOL=OFF
+       NOTE: Normally, windows compilers already support c++11.
 
   4. WARNING: Notes on compilation on MS-Windows
-     As the time being (circa dec 2014), I've been using MSVC-2013
-     (compiler version 12). As expected, weird behavior is related to
-     this config. Please take into account the following in order to
-     have a successful compilation:
+     As the time being (circa dec 2014), I've been using MSVC-2013 (compiler
+     version 12). As expected, weird behavior is related to this config. Please
+     take into account the following in order to have a successful compilation:
      4.1 If you want to build the Qt-based code, please be sure that
          it was compiled with EXACTLY the same compiler you are using.
      4.2 Since the dll load-unload procedure in MSWin is kind of magic,
-         VTK should be compiled as shared libraries and ITK should be
-         compiled as static libraries. This allows a correct
-         execution of the SmartPointer's thus preventing anoying crashes.
+         VTK and ITK should be compiled as shared libraries. This allows a
+         correct execution of the SmartPointer's thus preventing anoying crashes.
      4.3 If you found more problems in any MSWin config, please let us know at
          florez-l@javeriana.edu.co
-  
-
-@cmake_flags
-  BUILD_DEMOS:BOOL
-    Build example applications? (most of them are command line)
-  CMAKE_BUILD_TYPE:STRING
-    Debug/Release?
-  CMAKE_INSTALL_PREFIX:STRING
-    Where to put installation products? (in windows this option has no use)
+
+@compilation
+  The project uses CMake as project manager. You can use the CMake GUI to configure
+  it on your box. Please take into account the following variables:
+    USE_QT4:BOOL           -> It allows you to compile the Qt support
+    BUILD_EXAMPLES:BOOL    -> Do you want to compile the examples?
+    BUILD_SHARED_LIBRARIES -> Put this allways "ON". "OFF" is still experimental
+    CMAKE_BUILD_TYPE       -> Compilation type. Possible values: Debug, Release,
+                              MinSizeRel, RelWithDebInfo, None
+    ITK_DIR                -> Where ITK was intalled. If you followed this list,
+                              it should be on: ~/local/lib/cmake/ITK-X.Y (X and Y are
+                              the version numbers)
+    VTK_DIR                -> Where VTK was intalled. If you followed this list,
+                              it should be on: ~/local/lib/cmake/vtk-X.Y (X and Y are
+                              the version numbers)
 
 ## eof - $RCSfile$
diff --git a/README b/README
index 667addaeefcd49d6b04e5fe2e7706f6eb16e647a..46efa014205c759e430e23d1aa424634cc6f6549 100644 (file)
--- a/README
+++ b/README
@@ -7,8 +7,9 @@
   0.0.1 (2014-12-31)
 
 @authors
+  Leonardo FLÓREZ-VALENCIA (florez-l@javeriana.edu.co)
   Maciej ORKISZ (maciej.orkisz@creatis.insa-lyon.fr)
-  Leonardo FLOREZ-VALENCIA (florez-l@javeriana.edu.co)
+  José Luis GUZMÁN-RODRÍGUEZ (cycopepe@gmail.com)
   <Who else?>
 
 @description
index 95a7757fc967ec3680e005ca24fd985e8c45d47c..2359c70bd29ac43958734fb47738f8369c44fd48 100644 (file)
@@ -1,5 +1,11 @@
 IF(USE_QT4)
 
+  CONFIGURE_FILE(
+    Plugins.cfg.in
+    ${PROJECT_BINARY_DIR}/Plugins.cfg
+    @ONLY
+    )
+
   ## ====================================================
   ## = Source code, user interafaces and resources here =
   ## ====================================================
index 402baff2c1b1c4a074f6da2af00f34b50fe3692b..ada90eaa9ac06e67c5694d300146987a99c7a394 100644 (file)
@@ -1,7 +1,173 @@
 #include "ImageMPR.h"
-#include "MementoState.h"
 #include "ui_ImageMPR.h"
 
+// -------------------------------------------------------------------------
+#define ImageMPR_ConnectAction( ACTION )                \
+  QObject::connect(                                     \
+    this->m_UI->a##ACTION, SIGNAL( triggered( ) ),      \
+    this, SLOT( _a##ACTION( ) )                         \
+    )
+
+// -------------------------------------------------------------------------
+ImageMPR::
+ImageMPR( QWidget* parent )
+  : QMainWindow( parent ),
+    m_UI( new Ui::ImageMPR ),
+    m_ImageLoaded( false )
+{
+  this->m_UI->setupUi( this );
+
+  // Connect actions
+  ImageMPR_ConnectAction( OpenImage );
+  ImageMPR_ConnectAction( OpenSegmentation );
+  ImageMPR_ConnectAction( OpenPolyData );
+  ImageMPR_ConnectAction( SaveImage );
+  ImageMPR_ConnectAction( SaveSegmentation );
+  ImageMPR_ConnectAction( SavePolyData );
+  ImageMPR_ConnectAction( Undo );
+  ImageMPR_ConnectAction( Redo );
+  ImageMPR_ConnectAction( LoadPlugins );
+  ImageMPR_ConnectAction( ShowPlugins );
+
+  // Try to load default plugins
+  this->m_UI->MPR->LoadPlugins( );
+  this->m_UI->MPR->AssociatePluginsToMenu(
+    this->m_UI->MenuFilters, this, SLOT( _execPlugin( ) )
+    );
+}
+
+// -------------------------------------------------------------------------
+ImageMPR::
+~ImageMPR( )
+{
+  delete this->m_UI;
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_aOpenImage( )
+{
+  if( this->m_ImageLoaded )
+    this->m_UI->MPR->ClearAll( );
+  this->m_ImageLoaded = this->m_UI->MPR->LoadImage( );
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_aOpenSegmentation( )
+{
+  if( this->m_ImageLoaded )
+    this->m_ImageLoaded = this->m_UI->MPR->LoadImage( );
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_aOpenPolyData( )
+{
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_aSaveImage( )
+{
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_aSaveSegmentation( )
+{
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_aSavePolyData( )
+{
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_aUndo( )
+{
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_aRedo( )
+{
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_aLoadPlugins( )
+{
+  this->m_UI->MPR->DialogLoadPlugins( );
+  this->m_UI->MPR->AssociatePluginsToMenu(
+    this->m_UI->MenuFilters, this, SLOT( _execPlugin( ) )
+    );
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_aShowPlugins( )
+{
+}
+
+// -------------------------------------------------------------------------
+void ImageMPR::
+_execPlugin( )
+{
+  // Get filter name
+  QAction* action = dynamic_cast< QAction* >( this->sender( ) );
+  if( action == NULL )
+    return;
+  std::string name = action->text( ).toStdString( );
+  this->m_UI->MPR->ExecuteFilter( name, 0 );
+
+  // Configure filter
+  /*
+    TPluginFilter::Pointer filter =
+    this->m_Plugins.CreateProcessObject( name );
+    bool dlg_ok = filter->ExecConfigurationDialog( NULL );
+    if( !dlg_ok )
+    return;
+
+    // Execute filter
+    QApplication::setOverrideCursor( Qt::WaitCursor );
+    this->setEnabled( false );
+    filter->SetInput( 0, this->m_Image );
+    std::string err = filter->Update( );
+    QApplication::restoreOverrideCursor( );
+    this->setEnabled( true );
+
+    // Update image
+    if( err == "" )
+    {
+    TPluginImage* result = filter->GetOutput< TPluginImage >( 0 );
+    result->DisconnectPipeline( );
+    this->m_Image = result;
+    if( this->m_Image.IsNotNull( ) )
+    this->m_MPRObjects->SetImage(
+    this->m_Image->GetVTK< vtkImageData >( )
+    );
+    MementoState(this->m_state, this->m_Image);
+    this->m_state++;
+    if (this->m_state > this->m_max_state)
+    {
+    this->m_max_state = this->m_state;
+    }
+    }
+    else
+    QMessageBox::critical(
+    this,
+    tr( "Error executing filter" ),
+    tr( err.c_str( ) )
+    );
+  */
+}
+
+/*
+#include "MementoState.h"
+
 #include <vtkProperty.h>
 #include <vtkRenderWindow.h>
 #include <vtkMetaImageReader.h>
@@ -546,5 +712,6 @@ _triggered_actionRedo()
        
 }
        
+*/
 
 // eof - $RCSfile$
index c864bfe471dc04c05d7cc2bfb2879f00f31895cb..1cc16c9cb368ed1fa33d75f6112992e7d7ddf573 100644 (file)
@@ -120,63 +120,76 @@ class ImageMPR
 
 public:
   // Plugins types
-  typedef cpPlugins::Interface::Interface        TPluginsInterface;
-  typedef cpPlugins::Interface::Object           TPluginObject;
-  typedef cpPlugins::Interface::DataObject       TPluginData;
-  typedef cpPlugins::Interface::Image            TPluginImage;
-  typedef cpPlugins::Interface::ImplicitFunction TPluginImplicitFunction;
-  typedef cpPlugins::Interface::Mesh             TPluginMesh;
-  typedef cpPlugins::Interface::ProcessObject    TPluginFilter;
-  typedef cpPlugins::Interface::Parameters       TParameters;
-
-  typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
+  /*
+    typedef cpPlugins::Interface::Interface        TPluginsInterface;
+    typedef cpPlugins::Interface::Object           TPluginObject;
+    typedef cpPlugins::Interface::DataObject       TPluginData;
+    typedef cpPlugins::Interface::Image            TPluginImage;
+    typedef cpPlugins::Interface::ImplicitFunction TPluginImplicitFunction;
+    typedef cpPlugins::Interface::Mesh             TPluginMesh;
+    typedef cpPlugins::Interface::ProcessObject    TPluginFilter;
+    typedef cpPlugins::Interface::Parameters       TParameters;
+    typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
+  */
 
 public:
   explicit ImageMPR( QWidget* parent = 0 );
   virtual ~ImageMPR( );
 
-protected:
-  bool _LoadPlugins( const std::string& filename );
-  std::string _LoadImage( TPluginImage::Pointer& image );
-  std::string _ConfigureMeshActors( );
+  /*
+    protected:
+    bool _LoadPlugins( const std::string& filename );
+    std::string _LoadImage( TPluginImage::Pointer& image );
+    std::string _ConfigureMeshActors( );
+  */
 
 private slots:
-  void _triggered_actionOpenPlugins( );
-  void _triggered_actionOpenInputImage( );
-  void _triggered_actionOpenSegmentation( );
-  void _triggered_actionOpenInputPolyData( );
-  void _triggered_actionImageToImage( );
-  void _triggered_actionImageToMesh( );
-  void _triggered_actionUndo();
-  void _triggered_actionRedo();
+  void _aOpenImage( );
+  void _aOpenSegmentation( );
+  void _aOpenPolyData( );
+  void _aSaveImage( );
+  void _aSaveSegmentation( );
+  void _aSavePolyData( );
+  void _aUndo( );
+  void _aRedo( );
+  void _aLoadPlugins( );
+  void _aShowPlugins( );
+
+  void _execPlugin( );
+
 private:
   Ui::ImageMPR* m_UI;
 
+  // Some state flags
+  bool m_ImageLoaded;
+
   // Plugins objects
-  TPluginsInterface m_Plugins;
-
-  // Needed object from plugins
-  std::string m_ImageReaderClass;
-  std::string m_ImageWriterClass;
-  std::string m_MeshReaderClass;
-  std::string m_MeshWriterClass;
-  std::string m_MeshCutterClass;
-
-  // Real data
-  TPluginImage::Pointer m_Image;
-  TPluginImage::Pointer m_Segmentation;
-  TPluginMesh::Pointer  m_Mesh;
-
-  // Cutters
-  TPluginFilter::Pointer m_Cutters[ 3 ];
-  TPluginImplicitFunction::Pointer m_Planes[ 3 ];
-
-  // Visualization stuff
-  vtkSmartPointer< TMPRObjects > m_MPRObjects;
-
-  // Memento stuff
-  unsigned long m_state;
-  unsigned long m_max_state;
+  /*
+    TPluginsInterface m_Plugins;
+
+    // Needed object from plugins
+    std::string m_ImageReaderClass;
+    std::string m_ImageWriterClass;
+    std::string m_MeshReaderClass;
+    std::string m_MeshWriterClass;
+    std::string m_MeshCutterClass;
+
+    // Real data
+    TPluginImage::Pointer m_Image;
+    TPluginImage::Pointer m_Segmentation;
+    TPluginMesh::Pointer  m_Mesh;
+
+    // Cutters
+    TPluginFilter::Pointer m_Cutters[ 3 ];
+    TPluginImplicitFunction::Pointer m_Planes[ 3 ];
+
+    // Visualization stuff
+    vtkSmartPointer< TMPRObjects > m_MPRObjects;
+
+    // Memento stuff
+    unsigned long m_state;
+    unsigned long m_max_state;
+  */
 
   /* TODO
      vtkSmartPointer< vtkOrientationMarkerWidget > m_3DOrientationWidget;
index 8fd0d129dbe85921f0f4d6ed047187e6988737d5..7a292a252f49f314a45b1aa2698fca71013a9cb5 100644 (file)
    </size>
   </property>
   <property name="windowTitle">
-   <string>Interactive deformable mesh segmentation (v0.1)</string>
+   <string>ImageMPR (v0.1)</string>
   </property>
-  <widget class="QWidget" name="centralWidget">
+  <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_YPlaneVTK" 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_XPlaneVTK" 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_ZPlaneVTK" 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_3DVTK" 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>
+     <widget class="cpPlugins::Interface::BaseMPRWindow" name="MPR"/>
     </item>
    </layout>
   </widget>
-  <widget class="QMenuBar" name="menuBar">
+  <widget class="QMenuBar" name="MenuBar">
    <property name="geometry">
     <rect>
      <x>0</x>
      <y>0</y>
      <width>718</width>
-     <height>21</height>
+     <height>25</height>
     </rect>
    </property>
-   <widget class="QMenu" name="menuFile">
+   <widget class="QMenu" name="MenuOptionFile">
     <property name="title">
      <string>&amp;File</string>
     </property>
-    <addaction name="actionOpenPlugins"/>
+    <addaction name="aOpenImage"/>
+    <addaction name="aOpenSegmentation"/>
+    <addaction name="aOpenPolyData"/>
     <addaction name="separator"/>
-    <addaction name="actionOpenInputImage"/>
-    <addaction name="actionOpenSegmentation"/>
-    <addaction name="actionOpenInputPolyData"/>
+    <addaction name="aSaveImage"/>
+    <addaction name="aSaveSegmentation"/>
+    <addaction name="aSavePolyData"/>
     <addaction name="separator"/>
-    <addaction name="actionExit"/>
+    <addaction name="aExit"/>
    </widget>
-   <widget class="QMenu" name="MenuImageToImage">
+   <widget class="QMenu" name="MenuOptionEdit">
     <property name="title">
-     <string>Image to image</string>
+     <string>&amp;Edit</string>
     </property>
+    <widget class="QMenu" name="MenuOptionPlugins">
+     <property name="title">
+      <string>&amp;Plugins</string>
+     </property>
+     <addaction name="aLoadPlugins"/>
+     <addaction name="aShowPlugins"/>
+    </widget>
+    <addaction name="aUndo"/>
+    <addaction name="aRedo"/>
+    <addaction name="separator"/>
+    <addaction name="MenuOptionPlugins"/>
    </widget>
-   <widget class="QMenu" name="MenuImageToMesh">
+   <widget class="QMenu" name="MenuOptionHelp">
     <property name="title">
-     <string>Image to mesh</string>
+     <string>&amp;Help</string>
     </property>
    </widget>
-   <widget class="QMenu" name="menuEdit">
+   <widget class="QMenu" name="MenuFilters">
     <property name="title">
-     <string>Edit</string>
+     <string>&amp;Filters</string>
     </property>
-    <addaction name="actionUndo"/>
-    <addaction name="actionRedo"/>
    </widget>
-   <addaction name="menuFile"/>
-   <addaction name="menuEdit"/>
-   <addaction name="MenuImageToImage"/>
-   <addaction name="MenuImageToMesh"/>
+   <addaction name="MenuOptionFile"/>
+   <addaction name="MenuOptionEdit"/>
+   <addaction name="MenuFilters"/>
+   <addaction name="MenuOptionHelp"/>
   </widget>
-  <action name="actionOpenInputImage">
+  <widget class="QStatusBar" name="StatusBar"/>
+  <action name="aOpenImage">
    <property name="enabled">
     <bool>true</bool>
    </property>
     <string>Ctrl+O</string>
    </property>
   </action>
-  <action name="actionOpenPlugins">
-   <property name="enabled">
-    <bool>true</bool>
+  <action name="aExit">
+   <property name="text">
+    <string>Exit</string>
    </property>
+  </action>
+  <action name="aOpenPolyData">
    <property name="text">
-    <string>Open plugins</string>
+    <string>Open polydata</string>
    </property>
    <property name="shortcut">
-    <string>Ctrl+P</string>
+    <string>Ctrl+M</string>
    </property>
   </action>
-  <action name="actionExit">
+  <action name="aOpenSegmentation">
    <property name="text">
-    <string>Exit</string>
+    <string>Open segmentation</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+S</string>
    </property>
   </action>
-  <action name="actionOpenInputPolyData">
+  <action name="aUndo">
    <property name="text">
-    <string>Open polydata</string>
+    <string>&amp;Undo</string>
    </property>
    <property name="shortcut">
-    <string>Ctrl+M</string>
+    <string>Ctrl+Z</string>
    </property>
   </action>
-  <action name="actionDasdasd">
+  <action name="aRedo">
    <property name="text">
-    <string>dasdasd</string>
+    <string>&amp;Redo</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Y</string>
    </property>
   </action>
-  <action name="actionOpenSegmentation">
+  <action name="aLoadPlugins">
    <property name="text">
-    <string>Open segmentation</string>
+    <string>Load plugins</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+P</string>
    </property>
   </action>
-  <action name="actionUndo">
+  <action name="aShowPlugins">
    <property name="text">
-    <string>Undo</string>
+    <string>Show plugins</string>
    </property>
    <property name="shortcut">
-    <string>Ctrl+Z</string>
+    <string>Ctrl+H</string>
    </property>
   </action>
-  <action name="actionRedo">
+  <action name="aSaveImage">
    <property name="text">
-    <string>Redo</string>
+    <string>Save image</string>
    </property>
    <property name="shortcut">
-    <string>Ctrl+Y</string>
+    <string>Ctrl+Shift+I</string>
+   </property>
+  </action>
+  <action name="aSaveSegmentation">
+   <property name="text">
+    <string>Save segmentation</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Shift+S</string>
+   </property>
+  </action>
+  <action name="aSavePolyData">
+   <property name="text">
+    <string>Save polydata</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Shift+M</string>
    </property>
   </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>
   <customwidget>
-   <class>QVTKWidget</class>
-   <extends>QWidget</extends>
-   <header>QVTKWidget.h</header>
+   <class>cpPlugins::Interface::BaseMPRWindow</class>
+   <extends>QFrame</extends>
+   <header location="global">cpPlugins/Interface/BaseMPRWindow.h</header>
+   <container>1</container>
   </customwidget>
  </customwidgets>
  <resources/>
  <connections>
   <connection>
-   <sender>actionExit</sender>
+   <sender>aExit</sender>
    <signal>triggered()</signal>
    <receiver>ImageMPR</receiver>
    <slot>close()</slot>
index 72bd435bc0cfe38a5bbf0ce6f044d3463b94e2a0..cfc9b7ca1849485699a5bd0796842c9cdd2b4283 100644 (file)
@@ -68,6 +68,7 @@ MementoState::load(const std::string& filename) {
        reader->Update();
        return reader;
   */
+return( NULL );
 }
 
 // eof - $RCSfile$
diff --git a/appli/ImageMPR/Plugins.cfg.in b/appli/ImageMPR/Plugins.cfg.in
new file mode 100644 (file)
index 0000000..09b8bed
--- /dev/null
@@ -0,0 +1,2 @@
+@CMAKE_SHARED_LIBRARY_PREFIX@cpPluginsIO@CMAKE_SHARED_LIBRARY_SUFFIX@
+@CMAKE_SHARED_LIBRARY_PREFIX@cpPluginsBasicFilters@CMAKE_SHARED_LIBRARY_SUFFIX@
index 89fc7177310637a52bb2f29129c2a42cc85bf7ee..6713180cbbaa858e487e39e3f3c98b60ecb1a5b9 100644 (file)
 
 // -------------------------------------------------------------------------
 cpExtensions::QT::QuadSplitter::
-QuadSplitter( QWidget* parent, Qt::WindowFlags f )
-  : QFrame( parent, f )
+QuadSplitter( QWidget* parent )
+  : QSplitter( parent )
 {
-  this->m_Parent.setOrientation(Qt::Vertical);
-  this->m_Parent.addWidget(&this->m_Upper);
-  this->m_Parent.addWidget(&this->m_Bottom);
+  this->setOrientation( Qt::Vertical );
+  this->addWidget( &this->m_Upper );
+  this->addWidget( &this->m_Bottom );
 
   QObject::connect(
-    &this->m_Upper, SIGNAL( splitterMoved( int, int ) ),
+    &( this->m_Upper ), SIGNAL( splitterMoved( int, int ) ),
     this, SLOT( _SyncBottom( int, int ) )
     );
   QObject::connect(
-    &this->m_Bottom, SIGNAL( splitterMoved( int, int ) ),
+    &( this->m_Bottom ), SIGNAL( splitterMoved( int, int ) ),
     this, SLOT( _SyncUpper( int, int ) )
     );
 }
@@ -34,13 +34,6 @@ cpExtensions::QT::QuadSplitter::
 {
 }
 
-// -------------------------------------------------------------------------
-void cpExtensions::QT::QuadSplitter::
-show( )
-{
-  this->m_Parent.show( );
-}
-
 // -------------------------------------------------------------------------
 void cpExtensions::QT::QuadSplitter::
 addWidgets( QWidget* a, QWidget* b, QWidget* c, QWidget* d )
@@ -55,14 +48,14 @@ addWidgets( QWidget* a, QWidget* b, QWidget* c, QWidget* d )
 void cpExtensions::QT::QuadSplitter::
 _SyncBottom( int a, int b )
 {
-  this->m_Bottom.setSizes( m_Upper.sizes( ) );
+  this->m_Bottom.setSizes( this->m_Upper.sizes( ) );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::QuadSplitter::
 _SyncUpper( int a, int b )
 {
-  this->m_Upper.setSizes( m_Bottom.sizes( ) );
+  this->m_Upper.setSizes( this->m_Bottom.sizes( ) );
 }
 
 #endif // cpExtensions_Interface_QT4
index c431dfaeb90439a20105e348273e9e3f59a43500..7c275095eb1767911b6c3d70ec037d166837a4fe 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __CPEXTENSIONS__QT__QUADSPLITTER__H__
 #define __CPEXTENSIONS__QT__QUADSPLITTER__H__
 
+#include <cpExtensions/cpExtensions_Export.h>
 #include <cpExtensions/Config.h>
 
 #ifdef cpExtensions_Interface_QT4
@@ -10,7 +11,6 @@
  * https://forum.qt.io/topic/7144/quad-splitter-windows-an-implementation/2
  */
 
-#include <QFrame>
 #include <QSplitter>
 
 namespace cpExtensions
@@ -19,25 +19,22 @@ namespace cpExtensions
   {
     /**
      */
-    class QuadSplitter
-      : public QFrame
+    class cpExtensions_EXPORT QuadSplitter
+      : public QSplitter
     {
       Q_OBJECT;
 
     public:
-      QuadSplitter( QWidget* parent = 0, Qt::WindowFlags f = 0 );
+      QuadSplitter( QWidget* parent = 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;
     };
index 558fed75946f826b64e4d84f472022cf68a5ac0e..250c2ed5547e08f2a2bb969f7832b97306a54139 100644 (file)
@@ -29,7 +29,7 @@ New( )
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-AddInputConnection( vtkAlgorithmOutput* aout, int axis, LUTType lut )
+AddInputConnection( vtkAlgorithmOutput* aout, int axis )
 {
   vtkImageData* data = dynamic_cast< vtkImageData* >(
     aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
@@ -42,7 +42,7 @@ AddInputConnection( vtkAlgorithmOutput* aout, int axis, LUTType lut )
   if( new_map == NULL )
   {
     // Configure LUT
-    this->_ConfigureNewLUT( data, lut );
+    this->_ConfigureNewLUT( data );
     new_map = *( this->ImageMaps.rbegin( ) );
     if( new_map != NULL )
     {
@@ -67,10 +67,10 @@ AddInputConnection( vtkAlgorithmOutput* aout, int axis, LUTType lut )
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-AddInputData( vtkImageData* data, int axis, LUTType lut )
+AddInputData( vtkImageData* data, int axis )
 {
   // Configure LUT
-  this->_ConfigureNewLUT( data, lut );
+  this->_ConfigureNewLUT( data );
   vtkImageMapToColors* new_map = *( this->ImageMaps.rbegin( ) );
   if( new_map != NULL )
   {
@@ -109,7 +109,7 @@ Clear( )
   this->CursorMapper  = vtkSmartPointer< vtkPolyDataMapper >::New( );
   this->CursorActor   = vtkSmartPointer< vtkActor >::New( );
   this->PlaneFunction = vtkSmartPointer< vtkPlane >::New( );
-  this->PlaneSource   = vtkSmartPointer< vtkPolyData >::New( );
+  this->Plane         = vtkSmartPointer< vtkPolyData >::New( );
   this->PlaneMapper   = vtkSmartPointer< vtkPolyDataMapper >::New( );
   this->TextActor     = vtkSmartPointer< vtkTextActor >::New( );
   this->PlaneActor    = vtkSmartPointer< vtkActor >::New( );
@@ -160,10 +160,10 @@ Clear( )
   plane_lines->InsertCellPoint( 2 );
   plane_lines->InsertCellPoint( 3 );
   plane_lines->InsertCellPoint( 0 );
-  this->PlaneSource->SetPoints( plane_points );
-  this->PlaneSource->SetLines( plane_lines );
+  this->Plane->SetPoints( plane_points );
+  this->Plane->SetLines( plane_lines );
 
-  this->PlaneMapper->SetInputData( this->PlaneSource );
+  this->PlaneMapper->SetInputData( this->Plane );
   this->PlaneActor->SetMapper( this->PlaneMapper );
 
   this->TextActor->SetTextScaleModeToNone( );
@@ -517,16 +517,21 @@ GetImageMap( unsigned int id ) const
 
 // -------------------------------------------------------------------------
 double cpExtensions::Visualization::ImageSliceActors::
-GetWindow( unsigned int id ) const
+GetWindow( ) const
 {
-  if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+  if( this->ImageMaps.size( ) > 0 )
   {
-    vtkWindowLevelLookupTable* lut =
-      dynamic_cast< vtkWindowLevelLookupTable* >(
-        this->ImageMaps[ id ]->GetLookupTable( )
-        );
-    if( lut != NULL )
-      return( lut->GetWindow( ) );
+    if( this->ImageMaps[ 0 ].GetPointer( ) != NULL )
+    {
+      vtkWindowLevelLookupTable* lut =
+        dynamic_cast< vtkWindowLevelLookupTable* >(
+          this->ImageMaps[ 0 ]->GetLookupTable( )
+          );
+      if( lut != NULL )
+        return( lut->GetWindow( ) );
+      else
+        return( double( 0 ) );
+    }
     else
       return( double( 0 ) );
   }
@@ -536,16 +541,21 @@ GetWindow( unsigned int id ) const
 
 // -------------------------------------------------------------------------
 double cpExtensions::Visualization::ImageSliceActors::
-GetLevel( unsigned int id ) const
+GetLevel( ) const
 {
-  if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+  if( this->ImageMaps.size( ) > 0 )
   {
-    vtkWindowLevelLookupTable* lut =
-      dynamic_cast< vtkWindowLevelLookupTable* >(
-        this->ImageMaps[ id ]->GetLookupTable( )
-        );
-    if( lut != NULL )
-      return( lut->GetLevel( ) );
+    if( this->ImageMaps[ 0 ].GetPointer( ) != NULL )
+    {
+      vtkWindowLevelLookupTable* lut =
+        dynamic_cast< vtkWindowLevelLookupTable* >(
+          this->ImageMaps[ 0 ]->GetLookupTable( )
+          );
+      if( lut != NULL )
+        return( lut->GetLevel( ) );
+      else
+        return( double( 0 ) );
+    }
     else
       return( double( 0 ) );
   }
@@ -555,20 +565,30 @@ GetLevel( unsigned int id ) const
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-SetWindow( unsigned int id, double w )
+SetWindow( double w )
 {
-  if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+  if( this->ImageMaps.size( ) > 0 )
   {
-    vtkWindowLevelLookupTable* lut =
-      dynamic_cast< vtkWindowLevelLookupTable* >(
-        this->ImageMaps[ id ]->GetLookupTable( )
-        );
-    if( lut != NULL )
+    if( this->ImageMaps[ 0 ].GetPointer( ) != NULL )
     {
-      lut->SetWindow( w );
-      lut->Build( );
-      this->ImageMaps[ id ]->Modified( );
-      this->Modified( );
+      vtkWindowLevelLookupTable* lut =
+        dynamic_cast< vtkWindowLevelLookupTable* >(
+          this->ImageMaps[ 0 ]->GetLookupTable( )
+          );
+      if( lut != NULL )
+      {
+        /* TODO: Min and Max values are assigned 0!!!
+           if( w < this->MinWindow )
+           w = this->MinWindow;
+           if( w > this->MaxWindow )
+           w = this->MaxWindow;
+        */
+        lut->SetWindow( w );
+        lut->Build( );
+        this->ImageMaps[ 0 ]->Modified( );
+        this->Modified( );
+
+      } // fi
 
     } // fi
 
@@ -577,20 +597,30 @@ SetWindow( unsigned int id, double w )
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-SetLevel( unsigned int id, double l )
+SetLevel( double l )
 {
-  if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+  if( this->ImageMaps.size( ) > 0 )
   {
-    vtkWindowLevelLookupTable* lut =
-      dynamic_cast< vtkWindowLevelLookupTable* >(
-        this->ImageMaps[ id ]->GetLookupTable( )
-        );
-    if( lut != NULL )
+    if( this->ImageMaps[ 0 ].GetPointer( ) != NULL )
     {
-      lut->SetLevel( l );
-      lut->Build( );
-      this->ImageMaps[ id ]->Modified( );
-      this->Modified( );
+      vtkWindowLevelLookupTable* lut =
+        dynamic_cast< vtkWindowLevelLookupTable* >(
+          this->ImageMaps[ 0 ]->GetLookupTable( )
+          );
+      if( lut != NULL )
+      {
+        /* TODO: Min and Max values are assigned 0!!!
+           if( l < this->MinLevel )
+           l = this->MinLevel;
+           if( l > this->MaxLevel )
+           l = this->MaxLevel;
+        */
+        lut->SetLevel( l );
+        lut->Build( );
+        this->ImageMaps[ 0 ]->Modified( );
+        this->Modified( );
+
+      } // fi
 
     } // fi
 
@@ -599,21 +629,65 @@ SetLevel( unsigned int id, double l )
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-SetWindowLevel( unsigned int id, double w, double l )
+SetWindowLevel( double w, double l )
 {
-  if( this->ImageMaps[ id ].GetPointer( ) != NULL )
+  if( this->ImageMaps.size( ) > 0 )
   {
-    vtkWindowLevelLookupTable* lut =
-      dynamic_cast< vtkWindowLevelLookupTable* >(
-        this->ImageMaps[ id ]->GetLookupTable( )
-        );
-    if( lut != NULL )
+    if( this->ImageMaps[ 0 ].GetPointer( ) != NULL )
+    {
+      vtkWindowLevelLookupTable* lut =
+        dynamic_cast< vtkWindowLevelLookupTable* >(
+          this->ImageMaps[ 0 ]->GetLookupTable( )
+          );
+      if( lut != NULL )
+      {
+        /* TODO: Min and Max values are assigned 0!!!
+           std::cout << this->MinWindow << " " << this->MaxWindow << std::endl;
+           std::cout << this->MinLevel << " " << this->MaxLevel << std::endl;
+           std::cout << w << " " << l << " <-> " << std::ends;
+           if( w < this->MinWindow )
+           w = this->MinWindow;
+           if( w > this->MaxWindow )
+           w = this->MaxWindow;
+           if( l < this->MinLevel )
+           l = this->MinLevel;
+           if( l > this->MaxLevel )
+           l = this->MaxLevel;
+           std::cout << w << " " << l << std::endl;
+        */
+        lut->SetWindow( w );
+        lut->SetLevel( l );
+        lut->Build( );
+        this->ImageMaps[ 0 ]->Modified( );
+        this->Modified( );
+
+      } // fi
+
+    } // fi
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+ResetWindowLevel( )
+{
+  this->SetWindowLevel(
+    this->MaxWindow,
+    ( this->MaxLevel + this->MinLevel ) / double( 2 )
+    );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+SetLookupTable( unsigned int id, vtkLookupTable* lut )
+{
+  if( id < this->ImageMaps.size( ) && id > 0 )
+  {
+    if( this->ImageMaps[ id ].GetPointer( ) != NULL )
     {
-      lut->SetWindow( w );
-      lut->SetLevel( l );
-      lut->Build( );
+      this->ImageMaps[ id ]->SetLookupTable( lut );
       this->ImageMaps[ id ]->Modified( );
-      this->UpdateText( w, l );
       this->Modified( );
 
     } // fi
@@ -623,8 +697,58 @@ SetWindowLevel( unsigned int id, double w, double l )
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-ResetWindowLevel( unsigned int id )
+SetLookupTableAsColor( unsigned int id, double r, double g, double b )
 {
+  static const double _0 = double( 0 );
+  static const double _2 = double( 2 );
+  static const double _4 = double( 4 );
+  static const double _6 = double( 6 );
+  static const double _OPACITY = double( 0.6 );
+
+  // Check ID consistency
+  if( id == 0 || id >= this->ImageMaps.size( ) )
+    return;
+
+  // Get image scalar range
+  vtkAlgorithmOutput* aout = this->ImageMaps[ id ]->GetOutputPort( );
+  vtkImageData* image = dynamic_cast< vtkImageData* >(
+    aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
+    );
+  double range[ 2 ];
+  image->GetScalarRange( range );
+
+  // Get HSV from display color
+  double cmax = ( r > g )? r: g; cmax = ( b > cmax )? b: cmax;
+  double cmin = ( r < g )? r: g; cmin = ( b < cmin )? b: cmin;
+  double d = cmax - cmin;
+
+  double saturation = ( std::fabs( cmax ) > _0 )? d / cmax: _0;
+  double value = cmax;
+  double hue = _0;
+  if( d > _0 )
+  {
+    if( r == cmax )
+      hue = std::fmod( ( g - b ) / d, _6 );
+    else if( g == cmax )
+      hue = ( ( b - r ) / d ) + _2;
+    else if( b == cmax )
+      hue = ( ( r - g ) / d ) + _4;
+    hue /= _6;
+
+  } // fi
+
+  // Define new lookup table
+  vtkSmartPointer< vtkLookupTable > lut =
+    vtkSmartPointer< vtkLookupTable >::New( );
+  lut->SetScaleToLinear( );
+  lut->SetNanColor( _0, _0, _0, _0 );
+  lut->SetTableRange( range[ 0 ], range[ 1 ] );
+  lut->SetAlphaRange( _0, _OPACITY );
+  lut->SetHueRange( _0, hue );
+  lut->SetSaturationRange( _0, saturation );
+  lut->SetValueRange( _0, value );
+  lut->Build( );
+  this->SetLookupTable( id, lut );
 }
 
 // -------------------------------------------------------------------------
@@ -741,7 +865,7 @@ SetSliceNumber( const int& slice )
   int axis = this->SliceMappers[ 0 ]->GetOrientation( );
   this->PlaneActor->GetProperty( )->SetRepresentationToWireframe( );
   this->PlaneActor->GetProperty( )->SetLineWidth( 2 );
-  vtkPoints* plane_points = this->PlaneSource->GetPoints( );
+  vtkPoints* plane_points = this->Plane->GetPoints( );
   if( axis == 0 ) // YZ, x-normal
   {
     this->PlaneFunction->SetNormal( 1, 0, 0 );
@@ -771,7 +895,7 @@ SetSliceNumber( const int& slice )
 
   } // fi
   this->PlaneFunction->Modified( );
-  this->PlaneSource->Modified( );
+  this->Plane->Modified( );
   this->PlaneMapper->Modified( );
   this->PlaneActor->Modified( );
 
@@ -825,14 +949,6 @@ SetSlice( double* pos )
   this->SetSliceNumber( ijk[ this->GetAxis( ) ] );
 }
 
-// -------------------------------------------------------------------------
-/* TODO
-   void cpExtensions::Visualization::ImageSliceActors::
-   SetSlices( double pos[ 3 ] )
-   {
-   }
-*/
-
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 UpdateText( )
@@ -906,7 +1022,7 @@ UpdateText( double pos[ 3 ] )
             );
       str << ")";
       std::sprintf(
-        this->TextBuffer, "Axis: %c (%d) | Pixel %s",
+        this->TextBuffer, "Axis: %c (%d)\nPixel %s",
         axis, slice, str.str( ).c_str( )
         );
 
@@ -932,7 +1048,7 @@ UpdateText( const double& w, const double& l )
     else if( axId == 2 ) axis = 'Z';
 
     std::sprintf(
-      this->TextBuffer, "Axis: %c (%d) | W/L (%.2f/%.2f)",
+      this->TextBuffer, "Axis: %c (%d)\nW/L (%.2f/%.2f)",
       axis, this->SliceMappers[ 0 ]->GetSliceNumber( ), w, l
       );
   }
@@ -971,76 +1087,41 @@ cpExtensions::Visualization::ImageSliceActors::
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-_ConfigureNewLUT( vtkImageData* data, LUTType lut_t )
+_ConfigureNewLUT( vtkImageData* data )
 {
-  static const double _0 = double( 0 );
-  static const double _1 = double( 1 );
-  static const double _2 = double( 2 );
-  static const double _4 = double( 4 );
-  static const double _6 = double( 6 );
-  static const double _OPACITY = double( 0.6 );
+  // Does the new LUT is a window-level one?
+  unsigned int nImgs = this->ImageMaps.size( );
+  unsigned int nCmps = data->GetNumberOfScalarComponents( );
 
-  // Configure LUT
-  vtkSmartPointer< vtkImageMapToColors > new_map( NULL );
-  if( data->GetNumberOfScalarComponents( ) == 1 )
+  if( nCmps > 1 )
   {
-    double range[ 2 ];
-    data->GetScalarRange( range );
-    if( lut_t == Self::LUTType_WindowLevel )
-    {
-      vtkSmartPointer< vtkWindowLevelLookupTable > lut =
-        vtkSmartPointer< vtkWindowLevelLookupTable >::New( );
-      lut->SetScaleToLinear( );
-      lut->SetTableRange( range );
-      lut->SetWindow( range[ 1 ] - range[ 0 ] );
-      lut->SetLevel( ( range[ 1 ] + range[ 0 ] ) / double( 2 ) );
-      lut->Build( );
-
-      new_map = vtkSmartPointer< vtkImageMapToColors >::New( );
-      new_map->SetLookupTable( lut );
-    }
-    else if( lut_t == LUTType_Colors )
-    {
-      // Get HSV from display color
-      double r = 1, g = 0, b = 0;
-      double cmax = ( r > g )? r: g; cmax = ( b > cmax )? b: cmax;
-      double cmin = ( r < g )? r: g; cmin = ( b < cmin )? b: cmin;
-      double d = cmax - cmin;
-
-      double saturation = ( std::fabs( cmax ) > _0 )? d / cmax: _0;
-      double value = cmax;
-      double hue = _0;
-      if( d > _0 )
-      {
-        if( r == cmax )
-          hue = std::fmod( ( g - b ) / d, _6 );
-        else if( g == cmax )
-          hue = ( ( b - r ) / d ) + _2;
-        else if( b == cmax )
-          hue = ( ( r - g ) / d ) + _4;
-        hue *= _1 / _6;
-
-      } // fi
-
-      // Define new lookup table
-      vtkSmartPointer< vtkLookupTable > lut =
-        vtkSmartPointer< vtkLookupTable >::New( );
-      lut->SetScaleToLinear( );
-      lut->SetNanColor( _0, _0, _0, _0 );
-      lut->SetTableRange( range[ 0 ], range[ 1 ] );
-      lut->SetAlphaRange( _0, _OPACITY );
-      lut->SetHueRange( _0, hue );
-      lut->SetSaturationRange( _0, saturation );
-      lut->SetValueRange( _0, value );
-      lut->Build( );
-
-      new_map = vtkSmartPointer< vtkImageMapToColors >::New( );
-      new_map->SetLookupTable( lut );
-
-    } // fi
+    this->ImageMaps.push_back( NULL );
+    return;
 
   } // fi
-  this->ImageMaps.push_back( new_map );
+
+  // Create LUT filter
+  this->ImageMaps.push_back( vtkSmartPointer< vtkImageMapToColors >::New( ) );
+  if( nImgs == 0 )
+  {
+    double range[ 2 ];
+    data->GetScalarRange( range );
+    vtkSmartPointer< vtkWindowLevelLookupTable > lut =
+      vtkSmartPointer< vtkWindowLevelLookupTable >::New( );
+    lut->SetScaleToLinear( );
+    lut->SetTableRange( range );
+    lut->SetWindow( range[ 1 ] - range[ 0 ] );
+    lut->SetLevel( ( range[ 1 ] + range[ 0 ] ) / double( 2 ) );
+    lut->Build( );
+    this->ImageMaps[ 0 ]->SetLookupTable( lut );
+
+    this->MinWindow = double( 0 );
+    this->MaxWindow = range[ 1 ] - range[ 0 ];
+    this->MinLevel = range[ 0 ];
+    this->MaxLevel = range[ 1 ];
+  }
+  else
+    this->SetLookupTableAsColor( nImgs, 1, 0, 0 );
 }
 
 // -------------------------------------------------------------------------
@@ -1122,7 +1203,6 @@ _MouseMoveCommand(
       dx *= actors->StartWindowLevel[ 0 ];
       dy *= actors->StartWindowLevel[ 1 ];
       actors->SetWindowLevel(
-        0,
         actors->StartWindowLevel[ 0 ] + dx,
         actors->StartWindowLevel[ 1 ] + dy
         );
@@ -1147,8 +1227,8 @@ _MouseClickCommand(
   actors->StartWindowLevelPos[ 0 ] = pos[ 0 ];
   actors->StartWindowLevelPos[ 1 ] = pos[ 1 ];
   actors->StartWindowLevelPos[ 2 ] = pos[ 2 ];
-  actors->StartWindowLevel[ 0 ] = actors->GetWindow( );
-  actors->StartWindowLevel[ 1 ] = actors->GetLevel( );
+  actors->StartWindowLevel[ 0 ] = actors->GetWindow( );
+  actors->StartWindowLevel[ 1 ] = actors->GetLevel( );
 }
 
 // -------------------------------------------------------------------------
index 962c8f2b0cf0b2388981f949b1be19f85d768236..22bfe6a7f39ee551158ffbe80cfa67066676c559 100644 (file)
@@ -22,6 +22,7 @@
 // -------------------------------------------------------------------------
 class vtkAlgorithmOutput;
 class vtkImageData;
+class vtkLookupTable;
 
 // -------------------------------------------------------------------------
 namespace cpExtensions
@@ -41,26 +42,17 @@ namespace cpExtensions
     public:
       vtkTypeMacro( ImageSliceActors, vtkPropCollection );
 
-      enum LUTType
-      {
-        LUTType_None = 0,
-        LUTType_WindowLevel,
-        LUTType_Colors
-      };
+      vtkGetMacro( MinWindow, double );
+      vtkGetMacro( MaxWindow, double );
+      vtkGetMacro( MinLevel, double );
+      vtkGetMacro( MaxLevel, double );
 
     public:
       // Creation
       static ImageSliceActors* New( );
 
-      void AddInputConnection(
-        vtkAlgorithmOutput* aout,
-        int axis = 2,
-        LUTType lut = Self::LUTType_None
-        );
-      void AddInputData(
-        vtkImageData* data,
-        int axis = 2,
-        LUTType lut = Self::LUTType_None );
+      void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
+      void AddInputData( vtkImageData* data, int axis = 2 );
       void Clear( );
 
       void AssociateSlice( Self* other );
@@ -97,12 +89,17 @@ namespace cpExtensions
       vtkImageMapToColors* GetImageMap( unsigned int id );
       const vtkImageMapToColors* GetImageMap( unsigned int id ) const;
 
-      double GetWindow( unsigned int id ) const;
-      double GetLevel( unsigned int id ) const;
-      void SetWindow( unsigned int id, double w );
-      void SetLevel( unsigned int id, double l );
-      void SetWindowLevel( unsigned int id, double w, double l );
-      void ResetWindowLevel( unsigned int id );
+      double GetWindow( ) const;
+      double GetLevel( ) const;
+      void SetWindow( double w );
+      void SetLevel( double l );
+      void SetWindowLevel( double w, double l );
+      void ResetWindowLevel( );
+
+      void SetLookupTable( unsigned int id, vtkLookupTable* lut );
+      void SetLookupTableAsColor(
+        unsigned int id, double r, double g, double b
+        );
 
       int GetAxis( ) const;
       int GetSliceNumber( ) const;
@@ -118,7 +115,7 @@ namespace cpExtensions
       ImageSliceActors( );
       virtual ~ImageSliceActors( );
 
-      void _ConfigureNewLUT( vtkImageData* data, LUTType lut_t );
+      void _ConfigureNewLUT( vtkImageData* data );
       void _ConfigureNewInput( int axis );
 
       // Events
@@ -160,6 +157,10 @@ namespace cpExtensions
       std::vector< vtkSmartPointer< vtkImageActor > >       ImageActors;
       bool Interpolate;
 
+      // Window-Level values
+      double MinWindow, MaxWindow;
+      double MinLevel, MaxLevel;
+
       // Other associated slices
       std::vector< vtkSmartPointer< Self > > AssociatedSlices;
       TCursorCommand SlicesCommand;
@@ -175,7 +176,7 @@ namespace cpExtensions
       vtkSmartPointer< vtkPolyDataMapper > CursorMapper;
       vtkSmartPointer< vtkActor >          CursorActor;
       vtkSmartPointer< vtkPlane >          PlaneFunction;
-      vtkSmartPointer< vtkPolyData >       PlaneSource;
+      vtkSmartPointer< vtkPolyData >       Plane;
       vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
       char                                 TextBuffer[ 1024 ];
       vtkSmartPointer< vtkTextActor >      TextActor;
index 4498a2ba8120d5c18a23db065e75d488bc672028..55f271c44c7026cc30f710b1ba0537f7fa1ea759 100644 (file)
@@ -1,5 +1,6 @@
 #include <cpExtensions/Visualization/MPRActors.h>
 
+#include <vtkAlgorithmOutput.h>
 #include <vtkImageData.h>
 #include <vtkRenderer.h>
 #include <vtkRendererCollection.h>
@@ -26,55 +27,61 @@ GetSliceActors( const int& i ) const
 
 // -------------------------------------------------------------------------
 int cpExtensions::Visualization::MPRActors::
-AddInputConnection(
-  vtkAlgorithmOutput* aout, ImageSliceActors::LUTType lut
-  )
+AddInputConnection( vtkAlgorithmOutput* aout )
 {
   int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( );
   if( N == 0 )
   {
-    this->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0, lut );
+    this->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0 );
     vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( 0 );
     for( unsigned int i = 0; i < 2; ++i )
       for( unsigned int j = 0; j < 3; ++j )
         if( i != 0 || j != 0 )
           this->Slices[ i ][ j ]->AddInputConnection(
-            ( ( imap != NULL )? imap->GetOutputPort( ): aout ), j,
-            ImageSliceActors::LUTType_None
+            ( ( imap != NULL )? imap->GetOutputPort( ): aout ), j
             );
   }
   else
   {
-    /*
     // Check if the image share the same space
-    vtkImageData* ref_image = this->_Image( 0 );
-    vtkImageData* new_image =
-      vtkImageData::SafeDownCast(
-        aout->GetProducer( )->GetOutputInformation( 0 )->
-        Get( vtkDataObject::DATA_OBJECT( ) )
-        );
-    int ref_ext[ 6 ], new_ext[ 6 ];
-    ref_image->GetExtent( ref_ext );
-    new_image->GetExtent( new_ext );
-    if(
-      ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
-      ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
-      ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
-      )
+    vtkImageData* new_image = dynamic_cast< vtkImageData* >(
+      aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
+      );
+    if( new_image != NULL )
     {
-      this->ImageMaps.push_back(
-        vtkSmartPointer< vtkImageMapToColors >::New( )
+      vtkAlgorithmOutput* ref_aout =
+        this->Slices[ 0 ][ 0 ]->GetImageMap( 0 )->GetOutputPort( );
+      vtkImageData* ref_image = dynamic_cast< vtkImageData* >(
+        ref_aout->GetProducer( )->GetOutputDataObject( ref_aout->GetIndex( ) )
         );
-      this->ImageMaps[ N ]->SetInputConnection( aout );
-      this->SetLookupTableToColor(
-        N, double( 1 ), double( 0 ), double( 0 )
-        );
-      this->_Update( N );
-      return( N );
+      if( ref_image != NULL )
+      {
+        int ref_ext[ 6 ], new_ext[ 6 ];
+        ref_image->GetExtent( ref_ext );
+        new_image->GetExtent( new_ext );
+        if(
+          ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
+          ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
+          ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
+          )
+        {
+          this->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0 );
+          vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( N );
+          for( unsigned int i = 0; i < 2; ++i )
+            for( unsigned int j = 0; j < 3; ++j )
+              if( i != 0 || j != 0 )
+                this->Slices[ i ][ j ]->AddInputConnection(
+                  ( ( imap != NULL )? imap->GetOutputPort( ): aout ), j
+                  );
+        }
+        else
+          N = -1;
+      }
+      else
+        N = -1;
     }
     else
-    N = -1;
-  */
+      N = -1;
 
   } // fi
   return( N );
@@ -82,12 +89,12 @@ AddInputConnection(
 
 // -------------------------------------------------------------------------
 int cpExtensions::Visualization::MPRActors::
-AddInputData( vtkImageData* image, ImageSliceActors::LUTType lut )
+AddInputData( vtkImageData* new_image )
 {
   int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( );
   if( N == 0 )
   {
-    this->Slices[ 0 ][ 0 ]->AddInputData( image, 0, lut );
+    this->Slices[ 0 ][ 0 ]->AddInputData( new_image, 0 );
     vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( 0 );
     for( unsigned int i = 0; i < 2; ++i )
       for( unsigned int j = 0; j < 3; ++j )
@@ -95,62 +102,62 @@ AddInputData( vtkImageData* image, ImageSliceActors::LUTType lut )
         {
           if( imap != NULL )
             this->Slices[ i ][ j ]->AddInputConnection(
-              imap->GetOutputPort( ), j,
-              ImageSliceActors::LUTType_None
+              imap->GetOutputPort( ), j
               );
           else
-            this->Slices[ i ][ j ]->AddInputData(
-              image, j,
-              ImageSliceActors::LUTType_None
-              );
+            this->Slices[ i ][ j ]->AddInputData( new_image, j );
+
         } // fi
   }
   else
-  {
-  } // fi
-  return( N );
-  /*
-  int N = this->ImageMaps.size( );
-  if( N == 0 )
-  {
-    this->ImageMaps.push_back(
-      vtkSmartPointer< vtkImageMapToColors >::New( )
-      );
-    this->ImageMaps[ 0 ]->SetInputData( image );
-    this->SetLookupTableToWindowLevel( 0 );
-    this->_Update( 0 );
-    this->ResetWindowLevel( 0 );
-    return( 0 );
-  }
-  else
   {
     // Check if the image share the same space
-    vtkImageData* ref_image = this->_Image( 0 );
-    vtkImageData* new_image = image;
-    int ref_ext[ 6 ], new_ext[ 6 ];
-    ref_image->GetExtent( ref_ext );
-    new_image->GetExtent( new_ext );
-    if(
-      ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
-      ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
-      ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
-      )
+    vtkAlgorithmOutput* ref_aout =
+      this->Slices[ 0 ][ 0 ]->GetImageMap( 0 )->GetOutputPort( );
+    vtkImageData* ref_image = dynamic_cast< vtkImageData* >(
+      ref_aout->GetProducer( )->GetOutputDataObject( ref_aout->GetIndex( ) )
+      );
+    if( ref_image != NULL )
     {
-      this->ImageMaps.push_back(
-        vtkSmartPointer< vtkImageMapToColors >::New( )
-        );
-      this->ImageMaps[ N ]->SetInputData( image );
-      this->SetLookupTableToColor(
-        N, double( 1 ), double( 0 ), double( 0 )
-        );
-      this->_Update( N );
-      return( N );
+      int ref_ext[ 6 ], new_ext[ 6 ];
+      ref_image->GetExtent( ref_ext );
+      new_image->GetExtent( new_ext );
+      if(
+        ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
+        ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
+        ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
+        )
+      {
+        this->Slices[ 0 ][ 0 ]->AddInputData( new_image, 0 );
+        vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( N );
+        for( unsigned int i = 0; i < 2; ++i )
+          for( unsigned int j = 0; j < 3; ++j )
+            if( i != 0 || j != 0 )
+            {
+              if( imap != NULL )
+                this->Slices[ i ][ j ]->AddInputConnection(
+                  imap->GetOutputPort( ), j
+                  );
+              else
+                this->Slices[ i ][ j ]->AddInputData( new_image, j );
+
+            } // fi
+      }
+      else
+        N = -1;
     }
     else
-      return( -1 );
+      N = -1;
 
   } // fi
-  */
+  return( N );
+}
+
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::MPRActors::
+GetNumberOfImages( ) const
+{
+  return( this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -211,330 +218,64 @@ PushActorsInto(
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
-PopDataFrom(
-  vtkRenderer* x,
-  vtkRenderer* y,
-  vtkRenderer* z,
-  vtkRenderer* w
+PopActorsFrom(
+  vtkRenderWindow* x, vtkRenderWindow* y, vtkRenderWindow* z,
+  vtkRenderWindow* w
   )
 {
-  /*
-  vtkRenderer* rends[] = { x, y, z };
+  this->Slices[ 0 ][ 0 ]->PopActorsFrom( x );
+  this->Slices[ 0 ][ 1 ]->PopActorsFrom( y );
+  this->Slices[ 0 ][ 2 ]->PopActorsFrom( z );
+
+  vtkRenderer* wren =
+    ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
+  vtkRenderer* rends[ ] =
+    {
+      ( x != NULL )? x->GetRenderers( )->GetFirstRenderer( ): NULL,
+      ( y != NULL )? y->GetRenderers( )->GetFirstRenderer( ): NULL,
+      ( z != NULL )? z->GetRenderers( )->GetFirstRenderer( ): NULL
+    };
   for( int i = 0; i < 3; ++i )
   {
     if( rends[ i ] != NULL )
-    {
-      for(
-        unsigned int k = 0;
-        k < this->Slices[ 0 ][ i ]->GetNumberOfImageActors( );
-        ++k
-        )
-        rends[ i ]->RemoveActor( this->Slices[ 0 ][ i ]->GetImageActor( k ) );
-      rends[ i ]->RemoveActor( this->Slices[ 0 ][ i ]->GetTextActor( ) );
       for( int j = 0; j < 3; ++j )
-        rends[ i ]->RemoveActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
-
-    } // fi
-    if( w != NULL )
+        if( i != j )
+          rends[ i ]->RemoveActor( this->Slices[ 0 ][ j ]->GetPlaneActor( ) );
+    if( wren != NULL )
     {
       for(
         unsigned int k = 0;
         k < this->Slices[ 1 ][ i ]->GetNumberOfImageActors( );
         ++k
         )
-        w->RemoveActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
-      w->RemoveActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
+        wren->RemoveActor( this->Slices[ 1 ][ i ]->GetImageActor( k ) );
+      wren->RemoveActor( this->Slices[ 1 ][ i ]->GetPlaneActor( ) );
 
     } // fi
 
   } // rof
-  if( w != NULL )
-    w->RemoveActor( this->ImageOutlineActor );
-  */
-}
-
-// -------------------------------------------------------------------------
-  /*
-void cpExtensions::Visualization::MPRActors::
-LinkInteractors( )
-{
-  this->_Update( 0 );
-  this->_Update( 1 );
-  this->_Update( 2 );
-}
-  */
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-SetLookupTable( unsigned int i, vtkScalarsToColors* lut )
-{
-  /*
-  if( i < this->ImageMaps.size( ) )
-  {
-    this->ImageMaps[ i ]->SetLookupTable( lut );
-    this->ImageMaps[ i ]->Update( );
-    this->Modified( );
-
-  } // fi
-  */
-}
-
-// -------------------------------------------------------------------------
-vtkScalarsToColors* cpExtensions::Visualization::MPRActors::
-GetLookupTable( unsigned int i ) const
-{
-  /*
-  if( i < this->ImageMaps.size( ) )
-    return( this->ImageMaps[ i ]->GetLookupTable( ) );
-  else
-    return( NULL );
-    */
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-SetLookupTableToWindowLevel( unsigned int i )
-{
-  /*
-  // Check if the input has been configured
-  vtkImageData* image = this->_Image( i );
-  if( image == NULL )
-    return;
-
-  double r[ 2 ];
-  image->GetScalarRange( r );
-
-  vtkSmartPointer< vtkWindowLevelLookupTable > lut =
-    vtkSmartPointer< vtkWindowLevelLookupTable >::New( );
-  lut->SetScaleToLinear( );
-  lut->SetTableRange( r );
-  lut->Build( );
-
-  this->SetLookupTable( i, lut );
-  */
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::MPRActors::
-GetMinWindow( unsigned int i ) const
-{
-  return( 0 );
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::MPRActors::
-GetMaxWindow( unsigned int i ) const
-{
-  /*
-  // Check if the input has been configured
-  vtkImageData* image = this->_Image( i );
-  if( image == NULL )
-    return( double( 0 ) );
-
-  double r[ 2 ];
-  image->GetScalarRange( r );
-  return( r[ 1 ] - r[ 0 ] );
-  */
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::MPRActors::
-GetMinLevel( unsigned int i ) const
-{
-  /*
-  // Check if the input has been configured
-  vtkImageData* image = this->_Image( i );
-  if( image == NULL )
-    return( double( 0 ) );
-
-  double r[ 2 ];
-  image->GetScalarRange( r );
-  return( r[ 0 ] );
-  */
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::MPRActors::
-GetMaxLevel( unsigned int i ) const
-{
-  /*
-  // Check if the input has been configured
-  vtkImageData* image = this->_Image( i );
-  if( image == NULL )
-    return( double( 0 ) );
-
-  double r[ 2 ];
-  image->GetScalarRange( r );
-  return( r[ 1 ] );
-  */
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::MPRActors::
-GetWindow( unsigned int i ) const
-{
-  /*
-  vtkWindowLevelLookupTable* lut =
-    dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
-  if( lut != NULL )
-    return( lut->GetWindow( ) );
-  else
-    return( double( 0 ) );
-  */
-}
-
-// -------------------------------------------------------------------------
-double cpExtensions::Visualization::MPRActors::
-GetLevel( unsigned int i ) const
-{
-  /*
-  vtkWindowLevelLookupTable* lut =
-    dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
-  if( lut != NULL )
-    return( lut->GetLevel( ) );
-  else
-    return( double( 0 ) );
-  */
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-SetWindow( unsigned int i, const double& w )
-{
-  /*
-  vtkWindowLevelLookupTable* lut =
-    dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
-  if( lut != NULL )
-  {
-    lut->SetWindow( w );
-    lut->Build( );
-    this->ImageMaps[ i ]->Modified( );
-    this->Modified( );
-
-  } // fi
-  */
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-SetLevel( unsigned int i, const double& l )
-{
-  /*
-  vtkWindowLevelLookupTable* lut =
-    dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
-  if( lut != NULL )
-  {
-    lut->SetLevel( l );
-    lut->Build( );
-    this->ImageMaps[ i ]->Modified( );
-    this->Modified( );
-
-  } // fi
-  */
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-SetWindowLevel( unsigned int i, const double& w, const double& l )
-{
-  /*
-  vtkWindowLevelLookupTable* lut =
-    dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
-  if( lut != NULL )
-  {
-    lut->SetWindow( w );
-    lut->SetLevel( l );
-    lut->Build( );
-    this->ImageMaps[ i ]->Modified( );
-
-    for( unsigned int j = 0; j < 3; ++j )
-      this->Slices[ 0 ][ j ]->UpdateText( w, l );
-
-    this->Modified( );
-
-  } // fi
-  */
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-ResetWindowLevel( unsigned int i )
-{
-  /*
-  vtkImageData* image = this->_Image( i );
-  vtkWindowLevelLookupTable* lut =
-    dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( i ) );
-  if( image != NULL && lut != NULL )
-  {
-    double r[ 2 ];
-    image->GetScalarRange( r );
-    lut->SetTableRange( r );
-    lut->SetWindow( r[ 1 ] - r[ 0 ] );
-    lut->SetLevel( ( r[ 1 ] + r[ 0 ] ) / double( 2 ) );
-    lut->Build( );
-    this->ImageMaps[ i ]->Modified( );
-    this->Modified( );
+  if( wren != NULL )
+    wren->RemoveActor( this->ImageOutlineActor );
 
-  } // fi
-  */
+  this->Slices[ 0 ][ 0 ]->Clear( );
+  this->Slices[ 0 ][ 1 ]->Clear( );
+  this->Slices[ 0 ][ 2 ]->Clear( );
+  this->Slices[ 1 ][ 0 ]->Clear( );
+  this->Slices[ 1 ][ 1 ]->Clear( );
+  this->Slices[ 1 ][ 2 ]->Clear( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
-SetLookupTableToColor(
-  unsigned int i, const double& r, const double& g, const double& b
-  )
-{
-  /*
-  static const double _0 = double( 0 );
-  static const double _1 = double( 1 );
-  static const double _2 = double( 2 );
-  static const double _4 = double( 4 );
-  static const double _6 = double( 6 );
-  static const double _OPACITY = double( 0.6 );
-
-  // Check if the input has been configured
-  vtkImageData* image = this->_Image( i );
-  if( image == NULL )
-    return;
-
-  double range[ 2 ];
-  image->GetScalarRange( range );
-
-  // Get HSV from display color
-  double cmax = ( r > g )? r: g; cmax = ( b > cmax )? b: cmax;
-  double cmin = ( r < g )? r: g; cmin = ( b < cmin )? b: cmin;
-  double d = cmax - cmin;
-
-  double saturation = ( std::fabs( cmax ) > _0 )? d / cmax: _0;
-  double value = cmax;
-  double hue = _0;
-  if( d > _0 )
-  {
-    if( r == cmax )
-      hue = std::fmod( ( g - b ) / d, _6 );
-    else if( g == cmax )
-      hue = ( ( b - r ) / d ) + _2;
-    else if( b == cmax )
-      hue = ( ( r - g ) / d ) + _4;
-    hue *= _1 / _6;
-
-  } // fi
-
-  // Define new lookup table
-  vtkSmartPointer< vtkLookupTable > lut =
-    vtkSmartPointer< vtkLookupTable >::New( );
-  lut->SetScaleToLinear( );
-  lut->SetNanColor( _0, _0, _0, _0 );
-  lut->SetTableRange( range[ 0 ], range[ 1 ] );
-  lut->SetAlphaRange( _0, _OPACITY );
-  lut->SetHueRange( _0, hue );
-  lut->SetSaturationRange( _0, saturation );
-  lut->SetValueRange( _0, value );
-  lut->Build( );
-
-  this->SetLookupTable( i, lut );
-  */
+SetLookupTableAsColor( unsigned int i, double r, double g, double b )
+{
+  this->Slices[ 0 ][ 0 ]->SetLookupTableAsColor( 0, r, g, b );
+  this->Slices[ 0 ][ 1 ]->Modified( );
+  this->Slices[ 0 ][ 2 ]->Modified( );
+  this->Slices[ 1 ][ 0 ]->Modified( );
+  this->Slices[ 1 ][ 1 ]->Modified( );
+  this->Slices[ 1 ][ 2 ]->Modified( );
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
index f9fb2132613a1f6214d9bb114305da103758babc..85cee5949c2fba29d3173c290ff1f01613637a98 100644 (file)
@@ -6,21 +6,6 @@
 #include <cpExtensions/cpExtensions_Export.h>
 #include <cpExtensions/Visualization/ImageSliceActors.h>
 
-/*
-#include <vtkSmartPointer.h>
-#include <vtkActor.h>
-#include <vtkImageMapToColors.h>
-*/
-
-// -------------------------------------------------------------------------
-/*
-class vtkAlgorithmOutput;
-class vtkImageData;
-class vtkRenderer;
-class vtkScalarsToColors;
-*/
-
-// -------------------------------------------------------------------------
 namespace cpExtensions
 {
   namespace Visualization
@@ -42,14 +27,9 @@ namespace cpExtensions
 
       ImageSliceActors* GetSliceActors( const int& i ) const;
 
-      int AddInputConnection(
-        vtkAlgorithmOutput* aout,
-        ImageSliceActors::LUTType lut = ImageSliceActors::LUTType_WindowLevel
-        );
-      int AddInputData(
-        vtkImageData* image,
-        ImageSliceActors::LUTType lut = ImageSliceActors::LUTType_WindowLevel
-        );
+      int AddInputConnection( vtkAlgorithmOutput* aout );
+      int AddInputData( vtkImageData* new_image );
+      unsigned int GetNumberOfImages( ) const;
 
       void PushActorsInto(
         vtkRenderWindow* x,
@@ -57,36 +37,16 @@ namespace cpExtensions
         vtkRenderWindow* z,
         vtkRenderWindow* w
         );
-      void PopDataFrom(
-        vtkRenderer* x,
-        vtkRenderer* y,
-        vtkRenderer* z,
-        vtkRenderer* w
+      void PopActorsFrom(
+        vtkRenderWindow* x,
+        vtkRenderWindow* y,
+        vtkRenderWindow* z,
+        vtkRenderWindow* w
         );
 
-      // Lookup table methods
-      void SetLookupTable( unsigned int i, vtkScalarsToColors* lut );
-      vtkScalarsToColors* GetLookupTable( unsigned int i ) const;
-
-      // Grayscale window/level lookup
-      void SetLookupTableToWindowLevel( unsigned int i );
-      double GetMinWindow( unsigned int i ) const;
-      double GetMaxWindow( unsigned int i ) const;
-      double GetMinLevel( unsigned int i ) const;
-      double GetMaxLevel( unsigned int i ) const;
-      double GetWindow( unsigned int i ) const;
-      double GetLevel( unsigned int i ) const;
-      void SetWindow( unsigned int i, const double& w );
-      void SetLevel( unsigned int i, const double& l );
-      void SetWindowLevel( unsigned int i, const double& w, const double& l );
-      void ResetWindowLevel( unsigned int i );
-
       // Color lookup table
-      void SetLookupTableToColor(
-        unsigned int i,
-        const double& r = double( 1 ),
-        const double& g = double( 0 ),
-        const double& b = double( 0 )
+      void SetLookupTableAsColor(
+        unsigned int i, double r, double g, double b
         );
 
       // Slice access
@@ -112,7 +72,6 @@ namespace cpExtensions
       Self& operator=( const Self& );
 
     protected:
-      // TODO: std::vector< vtkSmartPointer< vtkImageMapToColors > > ImageMaps;
       vtkSmartPointer< vtkActor >         ImageOutlineActor;
       vtkSmartPointer< ImageSliceActors > Slices[ 2 ][ 3 ];
     };
index 0e522491b933349501a6286a1fd75682f8799e45..cfee04e58f8f794f1bf45e42306133d2038187c0 100644 (file)
@@ -48,7 +48,7 @@ SetRenderWindows(
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRObjects::
-SetImage( vtkImageData* image )
+AddImage( vtkImageData* image )
 {
   this->m_MPRActors->AddInputData( image );
   this->m_MPRActors->PushActorsInto(
@@ -59,93 +59,25 @@ SetImage( vtkImageData* image )
     );
 
   // First rendering
-  this->m_MPRActors->ResetSlices( );
-  this->ResetCameras( );
+  if( this->m_MPRActors->GetNumberOfImages( ) == 1 )
+  {
+    this->m_MPRActors->ResetSlices( );
+    this->ResetCameras( );
+
+  } // fi
   this->RenderAll( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRObjects::
-AddAuxiliaryImage( vtkImageData* image )
+ClearAll( )
 {
-  // Try to add new image
-  int id = this->m_MPRActors->AddInputData( image );
-  if( id < 0 )
-    return;
-
-  // Push everything on renderers
-  this->m_MPRActors->PushActorsInto(
+  this->m_MPRActors->PopActorsFrom(
     this->m_Windows[ 0 ],
     this->m_Windows[ 1 ],
     this->m_Windows[ 2 ],
     this->m_Windows[ 3 ]
     );
-
-  // Rendering
-  this->RenderAll( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRObjects::
-ActivateInteractors( )
-{
-  // Prepare renderers
-  for( int i = 0; i < 3; ++i )
-  {
-    // Check prerrequisites
-    if( this->m_Windows[ i ] == NULL || this->m_Renderers[ i ] == NULL )
-    {
-      // TODO: this->m_Styles[ i ] = NULL;
-      continue;
-
-    } // fi
-
-    ImageSliceActors* actors = this->m_MPRActors->GetSliceActors( i );
-    if( actors == NULL )
-    {
-      // TODO: this->m_Styles[ i ] = NULL;
-      continue;
-
-    } // fi
-
-    /* TODO
-       this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( );
-       this->m_Styles[ i ]->Configure( actors, this->m_MPRActors );
-       this->m_Styles[ i ]->
-       SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i );
-       this->m_Styles[ i ]->SetModeToNavigation( );
-    */
-
-  } // rof
-
-  // Synch 2D and 3D renderers
-  for( int i = 0; i < 3; ++i )
-  {
-    for( int j = 0; j < 3; ++j )
-    {
-      /* TODO
-         if(
-         this->m_Windows[ i ] != NULL &&
-         this->m_Windows[ j ] != NULL &&
-         i != j
-         )
-         this->m_Styles[ i ]->
-         AssociateInteractor( this->m_Windows[ j ]->GetInteractor( ) );
-      */
-
-    } // rof
-    /* TODO
-       if( this->m_Windows[ 3 ] != NULL )
-       this->m_Styles[ i ]->
-       AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) );
-    */
-
-  } // rof
-
-  // Finish interactor linking
-  // TODO: this->m_MPRActors->LinkInteractors( );
-
-  // Restart rendering
   this->ResetCameras( );
   this->RenderAll( );
 }
index 7d33f3f0698dd6e0b483beb7ba852705075d541e..39e827f978aa80069e5df264a2a16b6c4bb9bde8 100644 (file)
@@ -32,9 +32,8 @@ namespace cpExtensions
         vtkRenderWindow* wx, vtkRenderWindow* wy,
         vtkRenderWindow* wz, vtkRenderWindow* w3D
         );
-      void SetImage( vtkImageData* image );
-      void AddAuxiliaryImage( vtkImageData* image );
-      void ActivateInteractors( );
+      void AddImage( vtkImageData* image );
+      void ClearAll( );
 
       void ResetCamera( const int& id );
       void ResetCameras( );
index cc3f9b3a3c2f74c8ecf4631cf6e67b556156bef7..b43975547a21ccaca3bf3efcfd693dafceda39c8 100644 (file)
@@ -2,21 +2,42 @@
 
 #ifdef cpPlugins_Interface_QT4
 
-#include <cpPlugins/Interface/ui_BaseMPRWindow.h>
+#ifdef _WIN32
+#  define PLUGIN_PREFIX ""
+#  define PLUGIN_EXT "dll"
+#  define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)"
+#else // Linux
+#  define PLUGIN_PREFIX "lib"
+#  define PLUGIN_EXT "so"
+#  define PLUGIN_REGEX "Plugins file (*.so);;All files (*)"
+#endif // _WIN32
+
+#include <fstream>
+#include <sstream>
+
+#include <QFileDialog>
+#include <QMessageBox>
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::BaseMPRWindow::
 BaseMPRWindow( QWidget* parent )
-  : QMainWindow( parent ),
-    m_UI( new Ui::BaseMPRWindow )
+  : cpExtensions::QT::QuadSplitter( parent ),
+    m_LastLoadedPlugin( "." )
 {
-  // Create and associate renderers
+  // Configure splitter
+  this->m_XVTK = new QVTKWidget( this );
+  this->m_YVTK = new QVTKWidget( this );
+  this->m_ZVTK = new QVTKWidget( this );
+  this->m_WVTK = new QVTKWidget( this );
+  this->addWidgets( this->m_XVTK, this->m_YVTK, this->m_ZVTK, this->m_WVTK );
+
+  // Create and associate vtk 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( )
+    this->m_XVTK->GetRenderWindow( ),
+    this->m_YVTK->GetRenderWindow( ),
+    this->m_ZVTK->GetRenderWindow( ),
+    this->m_WVTK->GetRenderWindow( )
     );
 }
 
@@ -24,42 +45,268 @@ BaseMPRWindow( QWidget* parent )
 cpPlugins::Interface::BaseMPRWindow::
 ~BaseMPRWindow( )
 {
-  if( this->m_UI != NULL )
-    delete this->m_UI;
+  if( this->m_WVTK != NULL )
+    delete this->m_WVTK;
+  if( this->m_ZVTK != NULL )
+    delete this->m_ZVTK;
+  if( this->m_YVTK != NULL )
+    delete this->m_YVTK;
+  if( this->m_XVTK != NULL )
+    delete this->m_XVTK;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWindow::
+DialogLoadPlugins( )
+{
+  // Show dialog and check if it was accepted
+  QFileDialog dialog( this );
+  dialog.setFileMode( QFileDialog::ExistingFile );
+  dialog.setDirectory( this->m_LastLoadedPlugin.c_str( ) );
+  dialog.setNameFilter( tr( PLUGIN_REGEX ) );
+  dialog.setDefaultSuffix( tr( PLUGIN_EXT ) );
+  if( !( dialog.exec( ) ) )
+    return;
+
+  std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
+  if( !( this->LoadPlugins( fname ) ) )
+    QMessageBox::critical(
+      this, tr( "Ignoring plugin" ), tr( fname.c_str( ) )
+      );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWindow::
+AssociatePluginsToMenu( QMenu* menu, QObject* obj, const char* slot )
+{
+  std::map< std::string, std::set< std::string > >::const_iterator i;
+  std::set< std::string >::const_iterator j;
+
+  menu->clear( );
+  for( i = this->m_Filters.begin( ); i != this->m_Filters.end( ); i++ )
+  {
+    QMenu* newMenu = menu->addMenu( i->first.c_str( ) );
+    for( j = i->second.begin( ); j != i->second.end( ); ++j )
+    {
+      QAction* a = newMenu->addAction( j->c_str( ) );
+      QObject::connect( a, SIGNAL( triggered( ) ), obj, slot );
+
+    } // rof
+
+  } // rof
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::BaseMPRWindow::
-_LoadPlugins( const std::string& fname )
+LoadPlugins( const std::string& fname )
 {
-  return( false );
+  this->Block( );
+
+  // Is it already loaded?
+  if( this->m_LoadedPlugins.find( fname ) != this->m_LoadedPlugins.end( ) )
+  {
+    this->Unblock( );
+    return( true );
+
+  } // fi
+
+  // Was it succesfully loaded?
+  if( !( this->m_Interface.Load( fname ) ) )
+  {
+    this->Unblock( );
+    return( false );
+
+  } // fi
+
+  // Update a simple track
+  this->m_LoadedPlugins.insert( fname );
+  this->m_LastLoadedPlugin = fname;
+  this->_UpdatePlugins( );
+
+  this->Unblock( );
+  return( true );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWindow::
+LoadPlugins( )
+{
+  // Load file into a char buffer
+  std::ifstream in(
+    "Plugins.cfg", std::ios::in | std::ios::binary | std::ios::ate
+    );
+  if( !in.is_open( ) )
+    return;
+  std::streampos size = in.tellg( );
+  char* buffer = new char[ size ];
+  in.seekg( 0, std::ios::beg );
+  in.read( buffer, size );
+  in.close( );
+
+  // Read stream
+  std::stringstream in_stream( buffer );
+  while( in_stream )
+  {
+    char line[ 2048 ];
+    in_stream.getline( line, 2048 );
+    this->LoadPlugins( line );
+
+  } // elihw
+
+  // Finish
+  delete buffer;
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::BaseMPRWindow::
-_LoadImage( const std::string& fname )
+LoadImage( )
 {
-  return( false );
+  std::string msg = "";
+  bool ret = true;
+  if( this->m_ImageReader.IsNull( ) )
+  {
+    msg = "No valid image reader. Please load a valid plugin file.";
+    ret = false;
+
+  } // fi
+
+  if( this->m_ImageReader->ExecConfigurationDialog( this ) )
+  {
+    this->Block( );
+    msg = this->m_ImageReader->Update( );
+    if( msg == "" )
+    {
+      this->m_Images.push_back(
+        this->m_ImageReader->GetOutput< TImage >( 0 )
+        );
+      this->m_ImageReader->DisconnectOutputs( );
+      this->m_ImageReader->GetParameters( )->ClearStringList( "FileNames" );
+      vtkImageData* vtk_id =
+        this->m_Images.rbegin( )->GetPointer( )->GetVTK< vtkImageData >( );
+      if( vtk_id != NULL )
+      {
+        this->m_MPRObjects->AddImage( vtk_id );
+        /*
+          MementoState(m_state, this->m_Image);         
+          this->m_state++;
+        */
+      }
+      else
+        msg = "Read image does not have a valid VTK converter.";
+    }
+    else
+      ret = false;
+
+  } // fi
+
+  // Show errors and return
+  this->Unblock( );
+  if( msg != "" )
+    QMessageBox::critical(
+      this, tr( "Error reading image." ), tr( msg.c_str( ) )
+      );
+  return( ret );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::BaseMPRWindow::
-_LoadMesh( const std::string& fname )
+LoadMesh( )
 {
   return( false );
 }
 
-/*
-  TInterface m_Interface;
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWindow::
+ExecuteFilter( const std::string& name, int input_id, int output_id )
+{
+  TProcessObject::Pointer filter =
+    this->m_Interface.CreateProcessObject( name );
+  std::string category = filter->GetClassCategory( );
+  if( category == "ImageToBinaryImageFilter" )
+  {
+    if( input_id < this->m_Images.size( ) )
+    {
+      filter->SetInput( 0, this->m_Images[ input_id ] );
+      bool dlg_ok = filter->ExecConfigurationDialog( NULL );
+      if( !dlg_ok )
+        return;
 
-  TProcessObject::Pointer m_ImageReader;
-  TProcessObject::Pointer m_ImageWriter;
-  TProcessObject::Pointer m_MeshReader;
-  TProcessObject::Pointer m_MeshWriter;
+    } // fi
 
-  TImages m_Images;
-  TMeshes m_Meshes;
-*/
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWindow::
+ClearAll( )
+{
+  this->m_MPRObjects->ClearAll( );
+  this->m_Images.clear( );
+  this->m_Meshes.clear( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::BaseMPRWindow::
+_UpdatePlugins( )
+{
+  typedef TInterface::TClasses _C;
+
+  this->m_Filters.clear( );
+  _C& classes = this->m_Interface.GetClasses( );
+  for( _C::const_iterator i = classes.begin( ); i != classes.end( ); ++i )
+  {
+    TProcessObject::Pointer o =
+      this->m_Interface.CreateProcessObject( i->first );
+    std::string name = o->GetClassName( );
+    std::string category = o->GetClassCategory( );
+    if( category == "ImageReader" )
+      this->m_ImageReader = o;
+    else if( category == "ImageWriter" )
+      this->m_ImageWriter = o;
+    else if( category == "MeshReader" )
+      this->m_MeshReader = o;
+    else if( category == "MeshWriter" )
+      this->m_MeshWriter = o;
+    else
+      this->m_Filters[ category ].insert( name );
+
+    /*
+      if( category == "ImageReader" )
+      this->m_ImageReaderClass = name;
+      else if( category == "ImageWriter" )
+      this->m_ImageWriterClass = name;
+      else if( category == "MeshReader" )
+      this->m_MeshReaderClass = name;
+      else if( category == "MeshWriter" )
+      this->m_MeshWriterClass = name;
+      else if( category == "MeshToMeshFilter" )
+      {
+      if( name.find_last_of( "Cutter" ) != std::string::npos )
+      this->m_MeshCutterClass = name;
+      }
+      else if( category == "ImageToImageFilter" )
+      {
+      QAction* action =
+      this->m_UI->MenuImageToImage->addAction( QString( name.c_str( ) ) );
+      QObject::connect(
+      action, SIGNAL( triggered( ) ),
+      this, SLOT( _triggered_actionImageToImage( ) )
+      );
+      }
+      else if( category == "ImageToMeshFilter" )
+      {
+      QAction* action =
+      this->m_UI->MenuImageToMesh->addAction( QString( name.c_str( ) ) );
+      QObject::connect(
+      action, SIGNAL( triggered( ) ),
+      this, SLOT( _triggered_actionImageToMesh( ) )
+      );
+
+      } // fi
+    */
+
+  } // rof
+}
 
 #endif // cpPlugins_Interface_QT4
 
index 37dd18eab94b84030a02601a5d6bb58e0e43ad2e..d0509671da4676f607e378eff898a5c88ae27bbe 100644 (file)
@@ -1,35 +1,36 @@
 #ifndef __CPPLUGINS__INTERFACE__BASEMPRWINDOW__H__
 #define __CPPLUGINS__INTERFACE__BASEMPRWINDOW__H__
 
+#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
 #include <cpPlugins/Interface/Config.h>
 
 #ifdef cpPlugins_Interface_QT4
 
 #include <set>
+#include <string>
+#include <vector>
 
-#include <QMainWindow>
+#include <QApplication>
+#include <QMenu>
+#include <QVTKWidget.h>
 
 #include <vtkSmartPointer.h>
 
+#include <cpExtensions/QT/QuadSplitter.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
+    class cpPlugins_Interface_EXPORT BaseMPRWindow
+      : public cpExtensions::QT::QuadSplitter
     {
       Q_OBJECT;
 
@@ -40,30 +41,64 @@ namespace cpPlugins
       typedef cpPlugins::Interface::Image         TImage;
       typedef cpPlugins::Interface::Mesh          TMesh;
 
-      typedef std::set< TImage::Pointer > TImages;
-      typedef std::set< TMesh::Pointer >  TMeshes;
+      typedef std::vector< TImage::Pointer > TImages;
+      typedef std::vector< TMesh::Pointer >  TMeshes;
+      typedef std::set< std::string >     TOrderedStringContainer;
+      typedef std::map< std::string, std::set< std::string > > TFilters;
 
     public:
-      explicit BaseMPRWindow( QWidget* parent = NULL );
+      explicit BaseMPRWindow( QWidget* parent = 0 );
       virtual ~BaseMPRWindow( );
 
-    protected:
-      bool _LoadPlugins( const std::string& fname );
-      bool _LoadImage( const std::string& fname );
-      bool _LoadMesh( const std::string& fname );
+      void DialogLoadPlugins( );
+      void AssociatePluginsToMenu(
+        QMenu* menu, QObject* obj, const char* slot
+        );
+
+      inline void Block( )
+        {
+          QApplication::setOverrideCursor( Qt::WaitCursor );
+          this->setEnabled( false );
+        }
+      inline void Unblock( )
+        {
+          QApplication::restoreOverrideCursor( );
+          this->setEnabled( true );
+        }
+
+      bool LoadPlugins( const std::string& fname );
+      void LoadPlugins( );
+      bool LoadImage( );
+      bool LoadMesh( );
+
+      void ExecuteFilter(
+        const std::string& name,
+        int input_id, int output_id = -1
+        );
+
+      void ClearAll( );
 
     protected:
-      Ui::BaseMPRWindow* m_UI;
+      void _UpdatePlugins( );
 
+    protected:
       typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
       vtkSmartPointer< TMPRObjects > m_MPRObjects;
 
+      QVTKWidget* m_XVTK;
+      QVTKWidget* m_YVTK;
+      QVTKWidget* m_ZVTK;
+      QVTKWidget* m_WVTK;
+
       TInterface m_Interface;
+      TOrderedStringContainer m_LoadedPlugins;
+      std::string m_LastLoadedPlugin;
 
       TProcessObject::Pointer m_ImageReader;
       TProcessObject::Pointer m_ImageWriter;
       TProcessObject::Pointer m_MeshReader;
       TProcessObject::Pointer m_MeshWriter;
+      TFilters m_Filters;
 
       TImages m_Images;
       TMeshes m_Meshes;
diff --git a/lib/cpPlugins/Interface/BaseMPRWindow.ui b/lib/cpPlugins/Interface/BaseMPRWindow.ui
deleted file mode 100644 (file)
index ad47ad5..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-<?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 9cd9c5a10a7f45c35c10dbc9c7db1d5e089f9cea..83552b22fbd5e95adf1583885c234dae2c26cd67 100644 (file)
@@ -21,7 +21,6 @@ IF(USE_QT4)
   SET(
     LIB_QT_UI
     ParametersListWidget.ui
-    BaseMPRWindow.ui
     )
   SET(
     LIB_QT_Headers
index a7d3df458d6dcf8e62ee046f123e689303b6db5c..c721b5e261a4cf41fb9bfadf7f5a1015df6df457 100644 (file)
@@ -1,5 +1,6 @@
 #include <cpPlugins/Interface/Macros.h>
 
+#undef ITK_MANUAL_INSTANTIATION
 #include <itkMesh.h>
 #include <itkQuadEdgeMesh.h>
 
index 3db15c6b2a4f7ff625f9273f1896df446ba0a4e6..5c4d599372ef423093af347ada1e5e11ee2863ac 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <complex>
 
+#undef ITK_MANUAL_INSTANTIATION
 #include <itkVectorImage.h>
 
 #include <itkCovariantVector.h>
index e4160c623869688f6cfe63bccf98208521651838..4d470b68c4e2d96ec6a4aa1f5ba81714110acc9c 100644 (file)
@@ -61,61 +61,96 @@ CreateProcessObject( const std::string& name ) const
 bool cpPlugins::Interface::Interface::
 Load( const std::string& path )
 {
-  if( this->m_Pluma.load( path ) )
+  bool ret = true;
+  try
   {
-    this->_LoadClasses( );
-    return( true );
+    ret = this->m_Pluma.load( path );
+    if( ret )
+      this->_LoadClasses( );
   }
-  else
-    return( false );
+  catch( ... )
+  {
+    ret = false;
+
+  } // yrt
+  return( ret );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Interface::
 Load( const std::string& folder, const std::string& name )
 {
-  if( this->m_Pluma.load( folder, name ) )
+  bool ret = true;
+  try
   {
-    this->_LoadClasses( );
-    return( true );
+    ret = this->m_Pluma.load( folder, name );
+    if( ret )
+      this->_LoadClasses( );
   }
-  else
-    return( false );
+  catch( ... )
+  {
+    ret = false;
+
+  } // yrt
+  return( ret );
 }
 
 // -------------------------------------------------------------------------
 int cpPlugins::Interface::Interface::
 LoadFromFolder( const std::string& folder, bool r )
 {
-  if( this->m_Pluma.loadFromFolder( folder, r ) )
+  bool ret = true;
+  try
   {
-    this->_LoadClasses( );
-    return( true );
+    ret = this->m_Pluma.loadFromFolder( folder, r );
+    if( ret )
+      this->_LoadClasses( );
   }
-  else
-    return( false );
+  catch( ... )
+  {
+    ret = false;
+
+  } // yrt
+  return( ret );
 }
 
 // -------------------------------------------------------------------------
 bool cpPlugins::Interface::Interface::
 Unload( const std::string& name )
 {
-  if( this->m_Pluma.unload( name ) )
+  bool ret = true;
+  try
   {
-    this->m_Providers.clear( );
-    this->m_Classes.clear( );
-    this->_LoadClasses( );
-    return( true );
+    ret = this->m_Pluma.unload( name );
+    if( ret )
+    {
+      this->m_Providers.clear( );
+      this->m_Classes.clear( );
+      this->_LoadClasses( );
+
+    } // fi
   }
-  else
-    return( false );
+  catch( ... )
+  {
+    ret = false;
+
+  } // yrt
+  return( ret );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Interface::
 UnloadAll( )
 {
-  this->m_Pluma.unloadAll( );
+  try
+  {
+    this->m_Pluma.unloadAll( );
+  }
+  catch( ... )
+  {
+    // Do nothing
+
+  } // yrt
   this->m_Providers.clear( );
   this->m_Classes.clear( );
 }
index d2ae7f16fec1a041f3fdd33f630614d1cfab60d8..b02168b43c60ad92be24bbdc6e03831a975a3474 100644 (file)
@@ -380,7 +380,7 @@ cpPlugins_Parameters_Add( Real );
     TParameters::iterator i = this->m_Parameters.find( name );  \
     if( i == this->m_Parameters.end( ) )                        \
       return;                                                   \
-    if( i->second.first != Self::Y )                            \
+    if( i->second.first != Self::Y##List )                      \
       return;                                                   \
     i->second.second.second = "";                               \
     this->Modified( );                                          \
index fd207a09eb4e188f20e0339f42b9680d4d8172bd..0713edfe9114a51dedf05cee2ff57f423cda6980 100644 (file)
@@ -16,12 +16,7 @@ BinaryErodeImageFilter( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::Uint, "Radius" );
-
-  this->m_DefaultParameters.SetValueAsUint( "Radius", 2 );
-
-  this->m_Parameters = this->m_DefaultParameters;
+  this->m_Parameters->ConfigureAsUint( "Radius", 2 );
 }
 
 // -------------------------------------------------------------------------
@@ -72,19 +67,17 @@ _RealGD( itk::DataObject* image )
 
   // Get parameters
   _RT rad_val;
-  rad_val.Fill( this->m_Parameters.GetValueAsUint( "Radius" ) );
+  rad_val.Fill( this->m_Parameters->GetUint( "Radius" ) );
 
   // Configure filter
 
   StructuringElementType structuringElement;
-  structuringElement.SetRadius(rad_val);
-  structuringElement.CreateStructuringElement();
-
-
+  structuringElement.SetRadius( rad_val );
+  structuringElement.CreateStructuringElement( );
 
   _F* filter = this->_CreateITK< _F >( );
   filter->SetInput( dynamic_cast< I* >( image ) );
-  filter->SetKernel(structuringElement);
+  filter->SetKernel( structuringElement );
   filter->Update( );
 
   // Connect output
index 10704aac29d1681c8abf57d9bd31b68d396ff5dd..21df227a941c125d54a774f0f676d81fb41d6030 100644 (file)
@@ -12,18 +12,10 @@ BinaryThresholdImageFilter( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::Real, "LowerThresholdValue" );
-  this->m_DefaultParameters.Configure( Parameters::Real, "UpperThresholdValue" );
-  this->m_DefaultParameters.Configure( Parameters::Real, "InsideValue" );
-  this->m_DefaultParameters.Configure( Parameters::Real, "OutsideValue" );
-
-  this->m_DefaultParameters.SetValueAsReal( "LowerThresholdValue", 100 );
-  this->m_DefaultParameters.SetValueAsReal( "UpperThresholdValue", 500 );
-  this->m_DefaultParameters.SetValueAsReal( "InsideValue", 255 );
-  this->m_DefaultParameters.SetValueAsReal( "OutsideValue", 0 );
-
-  this->m_Parameters = this->m_DefaultParameters;
+  this->m_Parameters->ConfigureAsReal( "LowerThresholdValue", 0 );
+  this->m_Parameters->ConfigureAsReal( "UpperThresholdValue", 0 );
+  this->m_Parameters->ConfigureAsUint( "InsideValue", 255 );
+  this->m_Parameters->ConfigureAsUint( "OutsideValue", 1 );
 }
 
 // -------------------------------------------------------------------------
@@ -74,10 +66,10 @@ _RealGD( itk::DataObject* image )
   // Get parameters
   //unsigned int bins =
   //  this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" );
-  _IP lower_val = _IP( this->m_Parameters.GetValueAsReal( "LowerValue" ) );
-  _IP upper_val = _IP( this->m_Parameters.GetValueAsReal( "UpperValue" ) );
-  _OP in_val = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) );
-  _OP out_val = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) );
+  _IP lower_val = _IP( this->m_Parameters->GetReal( "LowerValue" ) );
+  _IP upper_val = _IP( this->m_Parameters->GetReal( "UpperValue" ) );
+  _OP in_val = _OP( this->m_Parameters->GetUint( "InsideValue" ) );
+  _OP out_val = _OP( this->m_Parameters->GetUint( "OutsideValue" ) );
 
   // Configure filter
   _F* filter = this->_CreateITK< _F >( );
index 7bfa56c9812c27d23e5cf61d4b6ac18caeff8c2d..6f8331453195c61d06c8fbf4a1e00bcf7d79e61f 100644 (file)
@@ -27,7 +27,7 @@ namespace cpPlugins
         );
       cpPlugins_Id_Macro(
         cpPlugins::BasicFilters::BinaryThresholdImageFilter,
-        "ImageToImageFilter"
+        "ImageToBinaryImageFilter"
         );
 
     protected:
index e0c80b40a7df160cf1741129105f833961058485..e3f1e2b98517296be15f5685f8fb3f8f28ef4c1a 100644 (file)
@@ -16,8 +16,6 @@ Cutter( )
   this->SetNumberOfInputs( 2 );
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
-
-  this->m_Parameters = this->m_DefaultParameters;
 }
 
 // -------------------------------------------------------------------------
index 88b3152d1ee997153445763ead1cebe47f964e61..df46d6f434d8e62a28759818ff816a2f8fc24241 100644 (file)
@@ -12,12 +12,8 @@ ExtractSliceImageFilter( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::Int, "Axis" );
-  this->m_DefaultParameters.Configure( Parameters::Int, "Slice" );
-  this->m_DefaultParameters.SetValueAsInt( "Axis", 0 );
-  this->m_DefaultParameters.SetValueAsInt( "Slice", 0 );
-  this->m_Parameters = this->m_DefaultParameters;
+  this->m_Parameters->ConfigureAsUint( "Axis", 0 );
+  this->m_Parameters->ConfigureAsInt( "Slice", 0 );
 }
 
 // -------------------------------------------------------------------------
@@ -61,11 +57,8 @@ _RealGD( itk::DataObject* image )
   typedef typename O::PixelType _OP;
 
   // Get parameters
-  int axis = this->m_Parameters.GetValueAsInt( "Axis" );
-  int slice = this->m_Parameters.GetValueAsInt( "Slice" );
-
-  std::cout << "HOLA: " << slice << std::endl;
-
+  int axis = this->m_Parameters->GetUint( "Axis" );
+  int slice = this->m_Parameters->GetInt( "Slice" );
 
   // Compute region
   I* img = dynamic_cast< I* >( image );
@@ -77,8 +70,6 @@ _RealGD( itk::DataObject* image )
   region.SetSize( size );
   region.SetIndex( index );
 
-  std::cout << "HOLA-: " << region << std::endl;
-
   // Configure filter
   _F* filter = this->_CreateITK< _F >( );
   filter->SetInput( img );
index 471c10bdb07deb2d961afbc725d4e7cc4a1ade64..07fc9393ec14f52b2a41faaa8542ce38995c9e37 100644 (file)
@@ -13,14 +13,10 @@ FloodFillImageFilter( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::Point, "Seed" );
-  this->m_DefaultParameters.Configure( Parameters::Real, "InsideValue" );
-  this->m_DefaultParameters.Configure( Parameters::Real, "OutsideValue" );
-  this->m_DefaultParameters.SetValueAsPoint( "Seed", 3, 0, 0, 0 );
-  this->m_DefaultParameters.SetValueAsReal( "InsideValue", 255 );
-  this->m_DefaultParameters.SetValueAsReal( "OutsideValue", 0 );
-  this->m_Parameters = this->m_DefaultParameters;
+  double seed[ 3 ] = { double( 0 ) };
+  this->m_Parameters->ConfigureAsPoint( "Seed", 3, seed );
+  this->m_Parameters->ConfigureAsUint( "InsideValue", 0 );
+  this->m_Parameters->ConfigureAsUint( "OutsideValue", 255 );
 }
 
 // -------------------------------------------------------------------------
@@ -119,9 +115,11 @@ _RealGD( itk::DataObject* image )
   typedef itk::FloodFilledImageFunctionConditionalConstIterator< I, _F > _It;
 
   typename I::PointType pseed;
-  pseed = this->m_Parameters.GetValueAsPoint< typename I::PointType >( "Seed" );
-  _OP in_val = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) );
-  _OP out_val = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) );
+  pseed = this->m_Parameters->GetPoint< typename I::PointType >(
+    "Seed", I::ImageDimension
+    );
+  _OP in_val = _OP( this->m_Parameters->GetUint( "InsideValue" ) );
+  _OP out_val = _OP( this->m_Parameters->GetUint( "OutsideValue" ) );
 
   const I* in = dynamic_cast< const I* >( image );
   typename I::IndexType seed;
index 92538607d9b5b98cf2ab446b298bc5157f4e3bca..e8336754e0ed8f1d151c213233d47c88b598ff6d 100644 (file)
@@ -15,9 +15,7 @@ MarchingCubes( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::RealList, "Thresholds" );
-  this->m_Parameters = this->m_DefaultParameters;
+  this->m_Parameters->ConfigureAsRealList( "Thresholds" );
 }
 
 // -------------------------------------------------------------------------
@@ -40,7 +38,7 @@ _GenerateData( )
     return( "MarchingCubes: Input does not have a valid VTK conversion." );
 
   std::vector< double > values;
-  this->m_Parameters.GetValueAsRealList( values, "Thresholds" );
+  this->m_Parameters->GetRealList( values, "Thresholds" );
   vtkPolyData* pd = NULL;
   if( vtk_image->GetDataDimension( ) == 2 )
   {
index 083c6b92f83799799f174e2b1a249aaa8b1499fd..d1205e728cdce5794e032f607380bc855a50760c 100644 (file)
@@ -12,12 +12,7 @@ MedianImageFilter( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::Uint, "Radius" );
-
-  this->m_DefaultParameters.SetValueAsUint( "Radius", 3 );
-
-  this->m_Parameters = this->m_DefaultParameters;
+  this->m_Parameters->ConfigureAsUint( "Radius", 3 );
 }
 
 // -------------------------------------------------------------------------
@@ -66,7 +61,7 @@ _RealGD( itk::DataObject* image )
 
   // Get parameters
   _RT rad_val;
-  rad_val.Fill( this->m_Parameters.GetValueAsUint( "Radius" ) );
+  rad_val.Fill( this->m_Parameters->GetUint( "Radius" ) );
 
   // Configure filter
   _F* filter = this->_CreateITK< _F >( );
index 59f98f5778f5b614b7880225a05ec4a7d70031c2..65df9e012f352533234122fd9d7cdbfca72eb908 100644 (file)
@@ -12,16 +12,9 @@ OtsuThresholdImageFilter( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure(
-    Parameters::Uint, "NumberOfHistogramBins"
-    );
-  this->m_DefaultParameters.Configure( Parameters::Real, "InsideValue" );
-  this->m_DefaultParameters.Configure( Parameters::Real, "OutsideValue" );
-  this->m_DefaultParameters.SetValueAsUint( "NumberOfHistogramBins", 100 );
-  this->m_DefaultParameters.SetValueAsReal( "InsideValue", 255 );
-  this->m_DefaultParameters.SetValueAsReal( "OutsideValue", 0 );
-  this->m_Parameters = this->m_DefaultParameters;
+  this->m_Parameters->ConfigureAsUint( "NumberOfHistogramBins", 100 );
+  this->m_Parameters->ConfigureAsUint( "InsideValue", 255 );
+  this->m_Parameters->ConfigureAsUint( "OutsideValue", 0 );
 }
 
 // -------------------------------------------------------------------------
@@ -69,10 +62,9 @@ _RealGD( itk::DataObject* image )
   typedef typename O::PixelType _OP;
 
   // Get parameters
-  unsigned int bins =
-    this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" );
-  _OP in_val = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) );
-  _OP out_val = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) );
+  unsigned int bins = this->m_Parameters->GetUint( "NumberOfHistogramBins" );
+  _OP in_val = _OP( this->m_Parameters->GetUint( "InsideValue" ) );
+  _OP out_val = _OP( this->m_Parameters->GetUint( "OutsideValue" ) );
 
   // Configure filter
   _F* filter = this->_CreateITK< _F >( );
index 5282f602b4f44f439e55216dc88dd27286d5cc52..31bd0fcaee6739a4965963e738d2e4351c61166b 100644 (file)
@@ -17,8 +17,10 @@ RGBImageToOtherChannelsFilter( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
 
-  this->m_DefaultParameters.Configure( TParameters::String, "OutChannel" );
-  this->m_Parameters = this->m_DefaultParameters;
+  std::vector< std::string > choices;
+  choices.push_back( "HSV" );
+  choices.push_back( "YPbPr" );
+  this->m_Parameters->ConfigureAsChoices( "OutChannel", choices );
 }
 
 // -------------------------------------------------------------------------
@@ -52,7 +54,7 @@ _GD0( itk::DataObject* image )
 {
   typedef typename I::PixelType _P;
 
-  std::string outc = this->m_Parameters.GetValueAsString( "OutChannel" );
+  std::string outc = this->m_Parameters->GetSelectedChoice( "OutChannel" );
   std::string r = "";
 
   using namespace cpExtensions::Algorithms;
index 8ba50cc7459a0a0aaccf21a01a3c817f8f73fa80..78aff5fbebf3ec19d0e5e0db59d279444a9f3c3f 100644 (file)
@@ -14,16 +14,11 @@ SphereMeshSource( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
 
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::Point, "Center" );
-  this->m_DefaultParameters.Configure( Parameters::Real, "Radius" );
-  this->m_DefaultParameters.Configure( Parameters::Uint, "PhiResolution" );
-  this->m_DefaultParameters.Configure( Parameters::Uint, "ThetaResolution" );
-  this->m_DefaultParameters.SetValueAsPoint( "Center", 3, 0, 0, 0 );
-  this->m_DefaultParameters.SetValueAsReal( "Radius", 1 );
-  this->m_DefaultParameters.SetValueAsUint( "PhiResolution", 10 );
-  this->m_DefaultParameters.SetValueAsUint( "ThetaResolution", 10 );
-  this->m_Parameters = this->m_DefaultParameters;
+  double point[ 3 ] = { double( 0 ) };
+  this->m_Parameters->ConfigureAsPoint( "Center", 3, point );
+  this->m_Parameters->ConfigureAsReal( "Radius", 1 );
+  this->m_Parameters->ConfigureAsUint( "PhiResolution", 8 );
+  this->m_Parameters->ConfigureAsUint( "ThetaResolution", 8 );
 }
 
 // -------------------------------------------------------------------------
@@ -37,11 +32,11 @@ std::string cpPlugins::BasicFilters::SphereMeshSource::
 _GenerateData( )
 {
   itk::Point< double, 3 > center =
-    this->m_Parameters.GetValueAsPoint< itk::Point< double, 3 > >( "Center" );
-  center.Fill( double( 0 ) ); // TODO
-  double radius = this->m_Parameters.GetValueAsReal( "Radius" );
-  unsigned int phi = this->m_Parameters.GetValueAsUint( "PhiResolution" );
-  unsigned int theta = this->m_Parameters.GetValueAsUint( "ThetaResolution" );
+    this->m_Parameters->GetPoint< itk::Point< double, 3 > >( "Center", 3 );
+  // TODO: center.Fill( double( 0 ) ); // TODO
+  double radius = this->m_Parameters->GetReal( "Radius" );
+  unsigned int phi = this->m_Parameters->GetUint( "PhiResolution" );
+  unsigned int theta = this->m_Parameters->GetUint( "ThetaResolution" );
 
   vtkSphereSource* src = this->_CreateVTK< vtkSphereSource >( );
   src->SetCenter( center[ 0 ], center[ 1 ], center[ 2 ] );
index f0ab717f050ab346063cc3dc765df69879bd56e5..6fe1263cf23ade46b94ff02cf84ef6e6e7d02d09 100644 (file)
@@ -1,6 +1,6 @@
 SUBDIRS(
   IO
-  ## BasicFilters
+  BasicFilters
   )
 
 ## eof - $RCSfile$
index 60b33b67998b0961d7c04b934c87f9a725fca907..48deb00a14d2f7fa5648465c8a435ec2b5def9a1 100644 (file)
@@ -367,11 +367,13 @@ _RealGD( const TStringList& names )
     {
       reader->Update( );
       out->SetITK< I >( reader->GetOutput( ) );
+      out->SetName( names[ 0 ] );
     }
     catch( itk::ExceptionObject& err )
     {
       r = "ImageReader: " + std::string( err.GetDescription( ) );
       out->SetITK< I >( NULL );
+      out->SetName( "" );
 
     } // yrt
   }
@@ -391,11 +393,13 @@ _RealGD( const TStringList& names )
     {
       reader->Update( );
       out->SetITK< I >( reader->GetOutput( ) );
+      out->SetName( *( ordered_names.begin( ) ) );
     }
     catch( itk::ExceptionObject& err )
     {
       r = "ImageReader: " + std::string( err.GetDescription( ) );
       out->SetITK< I >( NULL );
+      out->SetName( "" );
 
     } // yrt
   }
index 7dd131305cc7b202817d7334d5bdcc02d8ac1320..2b4d89781faba34413c942dbdbeaaaafea5930d1 100644 (file)
@@ -22,6 +22,39 @@ cpPlugins::IO::ImageWriter::
 // -------------------------------------------------------------------------
 std::string cpPlugins::IO::ImageWriter::
 _GenerateData( )
+{
+  // Thank you very much Microsoft !!! :-@
+  std::string   r = this->_GD0_Image< 2 >( );
+  if( r != "" ) r = this->_GD0_Image< 3 >( );
+  if( r != "" ) r = this->_GD0_Image< 4 >( );
+  if( r != "" ) r = this->_GD0_VectorImage< 2 >( );
+  if( r != "" ) r = this->_GD0_VectorImage< 3 >( );
+  if( r != "" ) r = this->_GD0_VectorImage< 4 >( );
+  return( r );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int D >
+std::string cpPlugins::IO::ImageWriter::
+_GD0_Image( )
+{
+  cpPlugins::Interface::Image* image =
+    this->GetInput< cpPlugins::Interface::Image >( 0 );
+  if( image == NULL )
+    return( "ImageWriter: No input image." );
+
+  itk::DataObject* itk_image = NULL;
+  std::string r = "";
+  cpPlugins_Image_Demangle_AllTypes( D, image, itk_image, r, _RealGD );
+  else r = "ImageWriter: Input image type not supported.";
+
+  return( r );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int D >
+std::string cpPlugins::IO::ImageWriter::
+_GD0_VectorImage( )
 {
   cpPlugins::Interface::Image* image =
     this->GetInput< cpPlugins::Interface::Image >( 0 );
@@ -30,12 +63,7 @@ _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 );
+  cpPlugins_VectorImage_Demangle_AllTypes( D, image, itk_image, r, _RealGD );
   else r = "ImageWriter: Input image type not supported.";
 
   return( r );
index 2d72067f71ba231dcdf2f3b79eca37473a7ad2cc..2c97de9beb04da3e58b0a3d021a0cd6a497e1885 100644 (file)
@@ -32,6 +32,15 @@ namespace cpPlugins
 
       virtual std::string _GenerateData( );
 
+      /*
+       * These two methods are Microsort courtesy: inner loop error !
+       */
+      template< unsigned int D >
+        inline std::string _GD0_Image( );
+
+      template< unsigned int D >
+        inline std::string _GD0_VectorImage( );
+
       template< class I >
         inline std::string _RealGD( itk::DataObject* image );
 
index 9b617dbf1dd7ac5a88a13152de88a0275e5d9bcc..923d825272c3538052e47e6e3c03d93169fb457d 100644 (file)
@@ -29,6 +29,7 @@
 #include <Pluma/DLibrary.hpp>\r
 #include <cstdio>\r
 #include <string>\r
+#include <stdexcept>\r
 \r
 \r
 namespace pluma{\r
@@ -36,7 +37,8 @@ namespace pluma{
 ////////////////////////////////////////////////////////////\r
 DLibrary* DLibrary::load(const std::string& path){\r
     if ( path.empty() ){\r
-        fprintf(stderr, "Failed to load library: Empty path\n");\r
+      // fprintf(stderr, "Failed to load library: Empty path\n");\r
+      throw std::runtime_error( "Failed to load library: Empty path." );\r
         return NULL;\r
     }\r
     void* handle = NULL;\r
@@ -45,16 +47,23 @@ DLibrary* DLibrary::load(const std::string& path){
     #ifdef PLUMA_SYS_WINDOWS\r
         handle = ::LoadLibraryA(path.c_str());\r
         if (!handle){\r
-            fprintf(stderr, "Failed to load library \"%s\".\n", path.c_str());\r
-            return NULL;\r
+          //fprintf(stderr, "Failed to load library \"%s\".\n", path.c_str());\r
+          throw std::runtime_error(\r
+            std::string( "Failed to load library \"" ) +\r
+            path +\r
+            std::string( "\"." );\r
+            );\r
+          return NULL;\r
         }\r
     #else\r
         handle = ::dlopen(path.c_str(), RTLD_NOW);\r
         if (!handle){\r
             const char* errorString = ::dlerror();\r
-            fprintf(stderr, "Failed to load library \"%s\".", path.c_str());\r
-            if(errorString) fprintf(stderr, " OS returned error: \"%s\".", errorString);\r
-            fprintf(stderr, "\n");\r
+            std::string error_text = "Failed to load library \"";\r
+            // fprintf(stderr, "Failed to load library \"%s\".", path.c_str());\r
+            if(errorString) error_text += std::string( errorString ); // fprintf(stderr, " OS returned error: \"%s\".", errorString);\r
+            // fprintf(stderr, "\n");\r
+            throw std::runtime_error( error_text + std::string( "\"." ) );\r
             return NULL;\r
         }\r
     #endif\r
@@ -78,7 +87,8 @@ DLibrary::~DLibrary(){
 ////////////////////////////////////////////////////////////\r
 void* DLibrary::getSymbol(const std::string& symbol){\r
     if (!handle){\r
-        fprintf(stderr, "Cannot inspect library symbols, library isn't loaded.\n");\r
+      //fprintf(stderr, "Cannot inspect library symbols, library isn't loaded.\n");\r
+      throw std::runtime_error( "Cannot inspect library symbols, library isn't loaded." );\r
         return NULL;\r
     }\r
     void* res;\r
@@ -88,8 +98,13 @@ void* DLibrary::getSymbol(const std::string& symbol){
         res = (void*)(::dlsym(handle, symbol.c_str()));\r
     #endif\r
     if (!res){\r
-        fprintf(stderr, "Library symbol \"%s\" not found.\n", symbol.c_str());\r
-        return NULL;\r
+      // fprintf(stderr, "Library symbol \"%s\" not found.\n", symbol.c_str());\r
+      throw std::runtime_error(\r
+        std::string( "Library symbol \"" ) +\r
+        symbol +\r
+        std::string( "\" not found." )\r
+        );\r
+      return NULL;\r
     }\r
     return res;\r
 }\r
index 860220e9cca634c6607db2385903b0134ef58689..b0494b7eee64daa7a10a442df42a2edcc2690ba7 100644 (file)
@@ -30,6 +30,7 @@
 #include <Pluma/uce-dirent.h>\r
 #include <cstdio>\r
 #include <queue>\r
+#include <stdexcept>\r
 \r
 \r
 namespace pluma{\r
@@ -46,7 +47,12 @@ void listFiles(std::list<std::string>& list, const std::string& folder, const st
     dir = opendir(folder.c_str());\r
     if (dir == NULL){\r
         // could not open directory\r
-      fprintf(stderr, "Could not open \"%s\" directory.\n", folder.c_str());\r
+      // fprintf(stderr, "Could not open \"%s\" directory.\n", folder.c_str());\r
+      throw std::runtime_error(\r
+        std::string( "Could not open \"" ) +\r
+        folder +\r
+        std::string( "\" directory." )\r
+        );\r
       return;\r
     }else{\r
         // close, we'll process it next\r
index eb37c33195eb45e98613d3fb9963f39b4ee3fe86..6fb5539b89dea0555c7a9988f46e7e4c74555f33 100644 (file)
@@ -28,6 +28,7 @@
 ////////////////////////////////////////////////////////////\r
 #include <Pluma/Host.hpp>\r
 #include <cstdio>\r
+#include <stdexcept>\r
 \r
 \r
 namespace pluma{\r
@@ -41,7 +42,8 @@ Host::Host(){
 ////////////////////////////////////////////////////////////\r
 bool Host::add(Provider* provider){\r
     if (provider == NULL){\r
-        fprintf(stderr, "Trying to add a null provider.\n");\r
+      //fprintf(stderr, "Trying to add a null provider.\n");\r
+      throw std::runtime_error( "Trying to add a null provider." );\r
         return false;\r
     }\r
     if (!validateProvider(provider)){\r
@@ -122,11 +124,19 @@ const std::list<Provider*>* Host::getProviders(const std::string& type) const{
 bool Host::validateProvider(Provider* provider) const{\r
     const std::string& type = provider->plumaGetType();\r
     if ( !knows(type) ){\r
-        fprintf(stderr, "%s provider type isn't registered.\n", type.c_str());\r
+      // fprintf(stderr, "%s provider type isn't registered.\n", type.c_str());\r
+      throw std::runtime_error(\r
+        type + std::string( " provider type isn't registered." )\r
+        );\r
         return false;\r
     }\r
     if (!provider->isCompatible(*this)){\r
-        fprintf(stderr, "Incompatible %s provider version.\n", type.c_str());\r
+      // fprintf(stderr, "Incompatible %s provider version.\n", type.c_str());\r
+      throw std::runtime_error(\r
+        std::string( "Incompatible " ) +\r
+        type +\r
+        std::string( " provider version." )\r
+        );\r
         return false;\r
     }\r
     return true;\r
index 9579da2f2fe4ff59f408e2757adb9e5b5aea03a3..491a1a9f5a9b653b3f939573f01d24f92f1834cf 100644 (file)
@@ -30,6 +30,7 @@
 #include <Pluma/DLibrary.hpp>\r
 #include <Pluma/Dir.hpp>\r
 #include <cstdio>\r
+#include <stdexcept>\r
 \r
 namespace pluma{\r
 \r
@@ -56,16 +57,26 @@ bool PluginManager::load(const std::string& path){
     registerFunction = reinterpret_cast<fnRegisterPlugin*>(lib->getSymbol("connect"));\r
 \r
     if(!registerFunction){\r
-        fprintf(stderr, "Failed to initialize plugin \"%s\": connect function not found\n", plugName.c_str());\r
+      //fprintf(stderr, "Failed to initialize plugin \"%s\": connect function not found\n", plugName.c_str());\r
         delete lib;\r
+        throw std::runtime_error(\r
+          std::string( "Failed to initialize plugin \"" ) +\r
+          plugName +\r
+          std::string( "\": connect function not found" )\r
+          );\r
         return false;\r
     }\r
     // try to initialize plugin:\r
     if (!registerFunction(host)){\r
         // plugin decided to fail\r
-        fprintf(stderr, "Self registry failed on plugin \"%s\".\n", plugName.c_str());\r
+      // fprintf(stderr, "Self registry failed on plugin \"%s\".\n", plugName.c_str());\r
         host.cancelAddictions();\r
         delete lib;\r
+        throw std::runtime_error(\r
+          std::string( "Self registry failed on plugin \"" ) +\r
+          plugName +\r
+          std::string( "\"" )\r
+          );\r
         return false;\r
     }\r
     // Store the library if addictions are confirmed\r
@@ -73,8 +84,13 @@ bool PluginManager::load(const std::string& path){
         libraries[plugName] = lib;\r
     else{\r
         // otherwise nothing was registered\r
-        fprintf(stderr, "Nothing registered by plugin \"%s\".\n", plugName.c_str());\r
+      // fprintf(stderr, "Nothing registered by plugin \"%s\".\n", plugName.c_str());\r
         delete lib;\r
+        throw std::runtime_error(\r
+          std::string( "Nothing registered by plugin \"" ) +\r
+          plugName +\r
+          std::string( "\"." )\r
+          );\r
         return false;\r
     }\r
     return true;\r
@@ -166,7 +182,8 @@ void PluginManager::registerType(const std::string& type, unsigned int version,
 ////////////////////////////////////////////////////////////\r
 bool PluginManager::addProvider(Provider* provider){\r
     if (provider == NULL){\r
-        fprintf(stderr, "Trying to add null provider\n");\r
+      // fprintf(stderr, "Trying to add null provider\n");\r
+      throw std::runtime_error( "Trying to add null provider." );\r
         return false;\r
     }\r
     return host.registerProvider(provider);\r