## = 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)
@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$
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
IF(USE_QT4)
+ CONFIGURE_FILE(
+ Plugins.cfg.in
+ ${PROJECT_BINARY_DIR}/Plugins.cfg
+ @ONLY
+ )
+
## ====================================================
## = Source code, user interafaces and resources here =
## ====================================================
#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>
}
+*/
// eof - $RCSfile$
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;
</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>&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>&Edit</string>
</property>
+ <widget class="QMenu" name="MenuOptionPlugins">
+ <property name="title">
+ <string>&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>&Help</string>
</property>
</widget>
- <widget class="QMenu" name="menuEdit">
+ <widget class="QMenu" name="MenuFilters">
<property name="title">
- <string>Edit</string>
+ <string>&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>&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>&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>
reader->Update();
return reader;
*/
+return( NULL );
}
// eof - $RCSfile$
--- /dev/null
+@CMAKE_SHARED_LIBRARY_PREFIX@cpPluginsIO@CMAKE_SHARED_LIBRARY_SUFFIX@
+@CMAKE_SHARED_LIBRARY_PREFIX@cpPluginsBasicFilters@CMAKE_SHARED_LIBRARY_SUFFIX@
// -------------------------------------------------------------------------
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 ) )
);
}
{
}
-// -------------------------------------------------------------------------
-void cpExtensions::QT::QuadSplitter::
-show( )
-{
- this->m_Parent.show( );
-}
-
// -------------------------------------------------------------------------
void cpExtensions::QT::QuadSplitter::
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
#ifndef __CPEXTENSIONS__QT__QUADSPLITTER__H__
#define __CPEXTENSIONS__QT__QUADSPLITTER__H__
+#include <cpExtensions/cpExtensions_Export.h>
#include <cpExtensions/Config.h>
#ifdef cpExtensions_Interface_QT4
* https://forum.qt.io/topic/7144/quad-splitter-windows-an-implementation/2
*/
-#include <QFrame>
#include <QSplitter>
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;
};
// -------------------------------------------------------------------------
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( ) )
if( new_map == NULL )
{
// Configure LUT
- this->_ConfigureNewLUT( data, lut );
+ this->_ConfigureNewLUT( data );
new_map = *( this->ImageMaps.rbegin( ) );
if( new_map != NULL )
{
// -------------------------------------------------------------------------
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 )
{
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( );
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( );
// -------------------------------------------------------------------------
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 ) );
}
// -------------------------------------------------------------------------
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 ) );
}
// -------------------------------------------------------------------------
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
// -------------------------------------------------------------------------
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
// -------------------------------------------------------------------------
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
// -------------------------------------------------------------------------
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 );
}
// -------------------------------------------------------------------------
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 );
} // fi
this->PlaneFunction->Modified( );
- this->PlaneSource->Modified( );
+ this->Plane->Modified( );
this->PlaneMapper->Modified( );
this->PlaneActor->Modified( );
this->SetSliceNumber( ijk[ this->GetAxis( ) ] );
}
-// -------------------------------------------------------------------------
-/* TODO
- void cpExtensions::Visualization::ImageSliceActors::
- SetSlices( double pos[ 3 ] )
- {
- }
-*/
-
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
UpdateText( )
);
str << ")";
std::sprintf(
- this->TextBuffer, "Axis: %c (%d) | Pixel %s",
+ this->TextBuffer, "Axis: %c (%d)\nPixel %s",
axis, slice, str.str( ).c_str( )
);
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
);
}
// -------------------------------------------------------------------------
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 );
}
// -------------------------------------------------------------------------
dx *= actors->StartWindowLevel[ 0 ];
dy *= actors->StartWindowLevel[ 1 ];
actors->SetWindowLevel(
- 0,
actors->StartWindowLevel[ 0 ] + dx,
actors->StartWindowLevel[ 1 ] + dy
);
actors->StartWindowLevelPos[ 0 ] = pos[ 0 ];
actors->StartWindowLevelPos[ 1 ] = pos[ 1 ];
actors->StartWindowLevelPos[ 2 ] = pos[ 2 ];
- actors->StartWindowLevel[ 0 ] = actors->GetWindow( 0 );
- actors->StartWindowLevel[ 1 ] = actors->GetLevel( 0 );
+ actors->StartWindowLevel[ 0 ] = actors->GetWindow( );
+ actors->StartWindowLevel[ 1 ] = actors->GetLevel( );
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
class vtkAlgorithmOutput;
class vtkImageData;
+class vtkLookupTable;
// -------------------------------------------------------------------------
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 );
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;
ImageSliceActors( );
virtual ~ImageSliceActors( );
- void _ConfigureNewLUT( vtkImageData* data, LUTType lut_t );
+ void _ConfigureNewLUT( vtkImageData* data );
void _ConfigureNewInput( int axis );
// Events
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;
vtkSmartPointer< vtkPolyDataMapper > CursorMapper;
vtkSmartPointer< vtkActor > CursorActor;
vtkSmartPointer< vtkPlane > PlaneFunction;
- vtkSmartPointer< vtkPolyData > PlaneSource;
+ vtkSmartPointer< vtkPolyData > Plane;
vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
char TextBuffer[ 1024 ];
vtkSmartPointer< vtkTextActor > TextActor;
#include <cpExtensions/Visualization/MPRActors.h>
+#include <vtkAlgorithmOutput.h>
#include <vtkImageData.h>
#include <vtkRenderer.h>
#include <vtkRendererCollection.h>
// -------------------------------------------------------------------------
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 );
// -------------------------------------------------------------------------
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 )
{
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( ) );
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
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( );
}
// -------------------------------------------------------------------------
#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
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,
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
Self& operator=( const Self& );
protected:
- // TODO: std::vector< vtkSmartPointer< vtkImageMapToColors > > ImageMaps;
vtkSmartPointer< vtkActor > ImageOutlineActor;
vtkSmartPointer< ImageSliceActors > Slices[ 2 ][ 3 ];
};
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRObjects::
-SetImage( vtkImageData* image )
+AddImage( vtkImageData* image )
{
this->m_MPRActors->AddInputData( image );
this->m_MPRActors->PushActorsInto(
);
// 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( );
}
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( );
#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( )
);
}
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
#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;
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;
+++ /dev/null
-<?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>&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>
SET(
LIB_QT_UI
ParametersListWidget.ui
- BaseMPRWindow.ui
)
SET(
LIB_QT_Headers
#include <cpPlugins/Interface/Macros.h>
+#undef ITK_MANUAL_INSTANTIATION
#include <itkMesh.h>
#include <itkQuadEdgeMesh.h>
#include <complex>
+#undef ITK_MANUAL_INSTANTIATION
#include <itkVectorImage.h>
#include <itkCovariantVector.h>
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( );
}
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( ); \
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 );
}
// -------------------------------------------------------------------------
// 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
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 );
}
// -------------------------------------------------------------------------
// 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 >( );
);
cpPlugins_Id_Macro(
cpPlugins::BasicFilters::BinaryThresholdImageFilter,
- "ImageToImageFilter"
+ "ImageToBinaryImageFilter"
);
protected:
this->SetNumberOfInputs( 2 );
this->SetNumberOfOutputs( 1 );
this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
-
- this->m_Parameters = this->m_DefaultParameters;
}
// -------------------------------------------------------------------------
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 );
}
// -------------------------------------------------------------------------
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 );
region.SetSize( size );
region.SetIndex( index );
- std::cout << "HOLA-: " << region << std::endl;
-
// Configure filter
_F* filter = this->_CreateITK< _F >( );
filter->SetInput( img );
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 );
}
// -------------------------------------------------------------------------
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;
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" );
}
// -------------------------------------------------------------------------
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 )
{
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 );
}
// -------------------------------------------------------------------------
// 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 >( );
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 );
}
// -------------------------------------------------------------------------
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 >( );
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 );
}
// -------------------------------------------------------------------------
{
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;
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 );
}
// -------------------------------------------------------------------------
_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 ] );
SUBDIRS(
IO
- ## BasicFilters
+ BasicFilters
)
## eof - $RCSfile$
{
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
}
{
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
}
// -------------------------------------------------------------------------
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 );
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 );
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 );
#include <Pluma/DLibrary.hpp>\r
#include <cstdio>\r
#include <string>\r
+#include <stdexcept>\r
\r
\r
namespace pluma{\r
////////////////////////////////////////////////////////////\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
#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
////////////////////////////////////////////////////////////\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
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
#include <Pluma/uce-dirent.h>\r
#include <cstdio>\r
#include <queue>\r
+#include <stdexcept>\r
\r
\r
namespace pluma{\r
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
////////////////////////////////////////////////////////////\r
#include <Pluma/Host.hpp>\r
#include <cstdio>\r
+#include <stdexcept>\r
\r
\r
namespace pluma{\r
////////////////////////////////////////////////////////////\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
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
#include <Pluma/DLibrary.hpp>\r
#include <Pluma/Dir.hpp>\r
#include <cstdio>\r
+#include <stdexcept>\r
\r
namespace pluma{\r
\r
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
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
////////////////////////////////////////////////////////////\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