#include "ui_PipelineEditor.h"
#include <cpPipelineEditor/Editor.h>
-
-#include <QFileDialog>
#include <QMessageBox>
-#include <vtkImageData.h>
-#include <vtkPolyData.h>
-
-#include <cpPlugins/DataObject.h>
-
-// -------------------------------------------------------------------------
-#define PipelineEditor_ConnectAction( ACTION ) \
- this->connect( \
- this->m_UI->Action##ACTION, SIGNAL( triggered( ) ), \
- this, SLOT( _Action##ACTION( ) ) \
- )
-
-// -------------------------------------------------------------------------
-#define PipelineEditor_ConnectButton( BUTTON ) \
- this->connect( \
- this->m_UI->Button##BUTTON, SIGNAL( clicked( ) ), \
- this, SLOT( _Button##BUTTON( ) ) \
- )
-
-// -------------------------------------------------------------------------
-bool PipelineEditor_Blocker::
-eventFilter( QObject* obj, QEvent* event )
-{
- return( true ); // -> Block all events
- /* NOTE: correct implementation:
- switch( event->type( ) )
- {
- //list event you want to prevent here ...
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonDblClick:
- //...
- return( true );
- } // hctiws
- return( this->QObject::eventFilter( obj, event ) );
- */
-}
-
// -------------------------------------------------------------------------
PipelineEditor::
PipelineEditor( int argc, char* argv[], QApplication* app, QWidget* parent )
- : QMainWindow( parent ),
- m_UI( new Ui::PipelineEditor ),
- m_Application( app ),
- m_Workspace( NULL ),
- m_PluginsPath( "." )
+ : Superclass( argc, argv, app, parent ),
+ m_UI( new Ui::PipelineEditor )
{
+ // Basic configuration
this->m_UI->setupUi( this );
-
- // Prepare plugins interface
- QFileInfo info( argv[ 0 ] );
- if( info.exists( ) )
- {
- if( !( this->m_Interface.LoadConfiguration( cpPlugins_CONFIG_FILE ) ) )
- {
- this->m_PluginsPath = info.canonicalPath( ).toStdString( );
- this->_LoadPluginsFromPath( this->m_PluginsPath );
- }
- /*
- else
- this->_UpdateLoadedPlugins( );
- */
-
- } // fi
- QDir exec_dir( "." );
- if( exec_dir.exists( ) )
- this->_LoadPluginsFromPath( exec_dir.canonicalPath( ).toStdString( ) );
-
- /* TODO
- this->m_Interface = new cpPlugins::Interface( );
- this->m_PluginsPath = info.canonicalPath( ).toStdString( );
- if( !( this->m_Interface->LoadDefaultConfiguration( this->m_PluginsPath ) ) )
- if( this->m_Interface->LoadFromFolder( this->m_PluginsPath, false ) != "" )
- if( !( this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath ) ) )
- QMessageBox::critical(
- this,
- "Error creating default plugins configuration",
- "Could not save default plugins configuration"
- );
- this->_UpdateLoadedPlugins( );
-
- } // fi
- */
-
- // Create an empty workspace
- this->m_Workspace = new cpPlugins::Workspace( );
- this->m_Workspace->SetInterface( &( this->m_Interface ) );
- this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
- this->m_Workspace->SetMPRViewer( this->m_UI->Viewer );
+ this->_Configure(
+ this->m_UI->LoadedPlugins,
+ this->m_UI->Viewer,
+ this->m_UI->Canvas->editor( )
+ );
// Connect actions to slots
- PipelineEditor_ConnectButton( LoadPluginsFile );
- PipelineEditor_ConnectButton( LoadPluginsPath );
- PipelineEditor_ConnectAction( OpenWorkspace );
- PipelineEditor_ConnectAction( SaveWorkspace );
+ this->connect(
+ this->m_UI->ButtonLoadPluginsFile, SIGNAL( clicked( ) ),
+ this, SLOT( _InteractiveLoadPlugins( ) )
+ );
+ this->connect(
+ this->m_UI->ButtonLoadPluginsPath, SIGNAL( clicked( ) ),
+ this, SLOT( _InteractiveLoadPluginsFromPath( ) )
+ );
+ this->connect(
+ this->m_UI->ActionOpenWorkspace, SIGNAL( triggered( ) ),
+ this, SLOT( _InteractiveLoadWorkspace( ) )
+ );
+ this->connect(
+ this->m_UI->ActionSaveWorkspace, SIGNAL( triggered( ) ),
+ this, SLOT( _InteractiveSaveWorkspace( ) )
+ );
this->connect(
this->m_UI->Canvas->editor( ),
SIGNAL( execFilter( const std::string& ) ),
PipelineEditor::
~PipelineEditor( )
{
- if( this->m_Workspace != NULL )
- delete this->m_Workspace;
delete this->m_UI;
}
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_LoadPluginsFromPath( const std::string& path )
-{
- QDir dir( path.c_str( ) );
- std::stringstream filters_str;
- filters_str << "*." << cpPlugins_PLUGIN_EXT;
- QStringList filters;
- filters << filters_str.str( ).c_str( );
- auto files = dir.entryList( filters );
- for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt )
- {
- try
- {
- this->m_Interface.LoadPluginFile(
- ( dir.absolutePath( ) + QDir::separator( ) + *fIt ).toStdString( )
- );
- }
- catch( std::exception& err )
- {
- // Just ignore un-loadable libraries
- } // yrt
-
- } // rof
- this->_UpdateLoadedPlugins( );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_UpdateLoadedPlugins( )
-{
- this->_Block( );
- auto filters = this->m_Interface.GetFilters( );
- if( filters.size( ) == 0 )
- {
- QMessageBox::critical(
- this,
- "Error loading default plugins",
- "No plugins loaded: remember to load some!!!"
- );
- this->_UnBlock( );
- return;
-
- } // fi
-
- for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt )
- {
- // Create or get category
- QList< QTreeWidgetItem* > cat_items =
- this->m_UI->LoadedPlugins->findItems(
- cIt->first.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
- );
- QTreeWidgetItem* cat = NULL;
- if( cat_items.size( ) == 0 )
- {
- cat = new QTreeWidgetItem(
- ( QTreeWidgetItem* )( NULL ), QStringList( cIt->first.c_str( ) )
- );
- this->m_UI->LoadedPlugins->addTopLevelItem( cat );
- }
- else
- cat = cat_items[ 0 ];
-
- // Create filters
- auto fIt = cIt->second.begin( );
- for( ; fIt != cIt->second.end( ); ++fIt )
- {
- QList< QTreeWidgetItem* > filter_items =
- this->m_UI->LoadedPlugins->findItems(
- fIt->c_str( ), Qt::MatchExactly | Qt::MatchRecursive
- );
- auto fiIt = filter_items.begin( );
- auto found_fiIt = filter_items.end( );
- for( ; fiIt != filter_items.end( ); ++fiIt )
- if( ( *fiIt )->parent( ) == cat )
- found_fiIt = fiIt;
-
- // Add filter
- if( found_fiIt == filter_items.end( ) )
- QTreeWidgetItem* filter = new QTreeWidgetItem(
- cat, QStringList( fIt->c_str( ) )
- );
-
- } // rof
-
- } // rof
- this->_UnBlock( );
- this->m_Interface.SaveConfiguration( cpPlugins_CONFIG_FILE );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_Block( )
-{
- this->m_Application->setOverrideCursor( Qt::WaitCursor );
- this->m_Application->installEventFilter( &( this->m_Blocker ) );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_UnBlock( )
-{
- while( this->m_Application->overrideCursor( ) )
- this->m_Application->restoreOverrideCursor( );
- this->m_Application->removeEventFilter( &( this->m_Blocker ) );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ButtonLoadPluginsFile( )
-{
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::ExistingFiles );
- dlg.setDirectory( "." );
-
- std::stringstream name_filter;
- std::string suffix = std::string( cpPlugins_PLUGIN_EXT );
- name_filter
- << "Plugins file (*." << cpPlugins_PLUGIN_EXT << ");;All files (*)";
- dlg.setNameFilter( name_filter.str( ).c_str( ) );
- dlg.setDefaultSuffix( suffix.c_str( ) );
-
- if( !( dlg.exec( ) ) )
- return;
-
- // Read
- QStringList names = dlg.selectedFiles( );
- std::stringstream err_str;
- for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt )
- {
- try
- {
- this->m_Interface.LoadPluginFile( qIt->toStdString( ) );
- }
- catch( std::exception& err )
- {
- err_str << err.what( ) << std::endl;
-
- } // yrt
-
- } // rof
-
- // Show an error message
- std::string err = err_str.str( );
- if( err.size( ) > 0 )
- QMessageBox::critical(
- this,
- "Error loading plugins",
- err.c_str( )
- );
-
- // Update view
- // TODO: this->m_Interface.SaveDefaultConfiguration( this->m_PluginsPath );
- this->_UpdateLoadedPlugins( );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ButtonLoadPluginsPath( )
-{
- /*
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::DirectoryOnly );
- dlg.setDirectory( "." );
- if( !( dlg.exec( ) ) )
- return;
-
- // Read
- std::string dir = dlg.selectedFiles( ).begin( )->toStdString( );
- std::string err = this->m_Interface->LoadFromFolder( dir, false );
- if( err != "" )
- QMessageBox::critical(
- this,
- "Error loading plugins directory",
- err.c_str( )
- );
-
- // Update view
- this->m_Interface->SaveDefaultConfiguration( this->m_PluginsPath );
- this->_UpdateLoadedPlugins( );
- */
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ActionOpenWorkspace( )
-{
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::ExistingFile );
- dlg.setDirectory( "." );
- dlg.setNameFilter(
- QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
- );
- dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
- if( !( dlg.exec( ) ) )
- return;
-
- std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( );
- if( this->m_Workspace != NULL )
- delete this->m_Workspace;
- this->m_Workspace = new cpPlugins::Workspace( );
- this->m_Workspace->SetInterface( &( this->m_Interface ) );
- this->m_Workspace->SetMPRViewer( this->m_UI->Viewer );
- std::string err = this->m_Workspace->LoadWorkspace( fname );
- if( err != "" )
- {
- delete this->m_Workspace;
- this->m_Workspace = NULL;
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error loading workspace" ),
- QMessageBox::tr( err.c_str( ) )
- );
- }
- else
- this->m_UI->Canvas->editor( )->setWorkspace( this->m_Workspace );
-}
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ActionSaveWorkspace( )
-{
- if( this->m_Workspace == NULL )
- return;
-
- QFileDialog dlg( this );
- dlg.setFileMode( QFileDialog::AnyFile );
- dlg.setDirectory( "." );
- dlg.setAcceptMode( QFileDialog::AcceptSave );
- dlg.setNameFilter(
- QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
- );
- dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
- if( !( dlg.exec( ) ) )
- return;
- std::string fname = dlg.selectedFiles( ).at( 0 ).toStdString( );
-
- std::string err = this->m_Workspace->SaveWorkspace( fname );
- if( err != "" )
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error saving workspace" ),
- QMessageBox::tr( err.c_str( ) )
- );
-}
-
-
-// -------------------------------------------------------------------------
-void PipelineEditor::
-_ExecFilter( const std::string& filter_name )
-{
- if( this->m_Workspace != NULL )
- {
- // Update filter, if needed
- this->_Block( );
- std::string err = this->m_Workspace->Execute( filter_name );
- this->_UnBlock( );
- if( err != "" )
- QMessageBox::critical(
- this,
- QMessageBox::tr( "Error executing filter" ),
- QMessageBox::tr( err.c_str( ) )
- );
-
- } // fi
-}
-
// -------------------------------------------------------------------------
void PipelineEditor::
_ShowFilterOutput(
this->_ExecFilter( filter_name );
// Get output
- auto filter = this->m_Workspace->GetFilter( filter_name );
+ auto filter = this->m_Workspace.GetFilter( filter_name );
if( filter != NULL )
{
auto output = filter->GetOutputData( output_name );
QMessageBox::tr( "No known VTK conversion!" )
);
- /* TODO
- if( this->m_UI->Viewer->AddData( output, data_name, "" ) )
- {
- if( this->m_UI->Viewer->GetNumberOfData( ) > 1 )
- this->m_UI->Viewer->SetDataColor( data_name, 1, 0, 0 );
- else
- this->m_UI->Viewer->SetMainImage( data_name );
- this->m_UI->Viewer->ShowData( data_name );
- }
- else
- */
-
} // fi
} // fi
#ifndef __PIPELINEEDITOR__H__
#define __PIPELINEEDITOR__H__
-// Qt stuff
-#include <QApplication>
-#include <QMainWindow>
-#include <cpPlugins/Interface.h>
-#include <cpPlugins/Workspace.h>
-
-/**
- */
-class PipelineEditor_Blocker
- : public QObject
-{
-protected:
- virtual bool eventFilter( QObject* obj, QEvent* event ) ITK_OVERRIDE;
-};
+#include <cpPlugins/BaseQtMainWindow.h>
// -------------------------------------------------------------------------
namespace Ui
/**
*/
class PipelineEditor
- : public QMainWindow
+ : public cpPlugins::BaseQtMainWindow
{
Q_OBJECT;
public:
- typedef PipelineEditor Self;
- typedef QMainWindow Superclass;
+ typedef PipelineEditor Self;
+ typedef cpPlugins::BaseQtMainWindow Superclass;
public:
explicit PipelineEditor(
);
virtual ~PipelineEditor( );
-protected:
- void _LoadPluginsFromPath( const std::string& path );
- void _UpdateLoadedPlugins( );
- void _Block( );
- void _UnBlock( );
-
protected slots:
- void _ButtonLoadPluginsFile( );
- void _ButtonLoadPluginsPath( );
- void _ActionOpenWorkspace( );
- void _ActionSaveWorkspace( );
- void _ExecFilter( const std::string& filter_name );
void _ShowFilterOutput(
const std::string& filter_name, const std::string& output_name
);
private:
- Ui::PipelineEditor* m_UI;
- QApplication* m_Application;
- PipelineEditor_Blocker m_Blocker;
- cpPlugins::Workspace* m_Workspace;
- cpPlugins::Interface m_Interface;
- std::string m_PluginsPath;
+ Ui::PipelineEditor* m_UI;
};
#endif // __CPPIPELINEEDITOR__H__
FOREACH(example ${examples_SOURCES})
ADD_EXECUTABLE(${example} ${example}.cxx)
- TARGET_LINK_LIBRARIES(${example} cpPlugins)
+ TARGET_LINK_LIBRARIES(${example} cpPlugins cpPipelineEditor)
ENDFOREACH(example)
## eof - $RCSfile$
# ===================
SET(cpExtensions_LIBRARY cpExtensions)
+SET(cpPlugins_tinyxml2_LIBRARY cpPlugins_tinyxml2)
SET(cpPlugins_LIBRARY cpPlugins)
+SET(cpPipelineEditor_LIBRARY cpPipelineEditor)
# ======================
# -- Executable names --
typedef std::set< double > TScalesContainer;
- enum FilterId
- {
- Gradient = 0,
- GradientMagnitude,
- Hessian,
- None
- };
-
protected:
/**
*/
itkTypeMacro( MultiScaleGaussianImageFilter, itkImageToImageFilter );
public:
- void SetFilterToGradient( );
- void SetFilterToGradientMagnitude( );
- void SetFilterToHessian( );
-
- bool IsGradientFilter( ) const;
- bool IsGradientMagnitudeFilter( ) const;
- bool IsHessianFilter( ) const;
-
void AddScale( const double& s );
unsigned long GetNumberOfScales( ) const;
protected:
TScalesContainer m_Scales;
- FilterId m_FilterId;
};
} // ecapseman
#include <itkBinaryFunctorImageFilter.h>
#include <itkUnaryFunctorImageFilter.h>
-#include <itkGradientMagnitudeRecursiveGaussianImageFilter.h>
#include <itkGradientRecursiveGaussianImageFilter.h>
-#include <itkHessianRecursiveGaussianImageFilter.h>
// -------------------------------------------------------------------------
template< class I, class O >
return( ( vb.magnitude( ) < va.magnitude( ) )? a: b );
}
-// -------------------------------------------------------------------------
-template< class I, class O >
-void
-cpExtensions::Algorithms::
-MultiScaleGaussianImageFilter< I, O >::
-SetFilterToGradient( )
-{
- if(
- itk::NumericTraits< typename O::PixelType >::GetLength( ) ==
- I::ImageDimension
- )
- this->m_FilterId = Self::Gradient;
- else
- this->m_FilterId = Self::None;
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class I, class O >
-void
-cpExtensions::Algorithms::
-MultiScaleGaussianImageFilter< I, O >::
-SetFilterToGradientMagnitude( )
-{
- if( itk::NumericTraits< typename O::PixelType >::GetLength( ) == 1 )
- this->m_FilterId = Self::GradientMagnitude;
- else
- this->m_FilterId = Self::None;
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class I, class O >
-void
-cpExtensions::Algorithms::
-MultiScaleGaussianImageFilter< I, O >::
-SetFilterToHessian( )
-{
- itkExceptionMacro( << "Check for hessian definition." );
-}
-
-// -------------------------------------------------------------------------
-template< class I, class O >
-bool
-cpExtensions::Algorithms::
-MultiScaleGaussianImageFilter< I, O >::
-IsGradientFilter( ) const
-{
- return( this->m_FilterId == Self::Gradient );
-}
-
-// -------------------------------------------------------------------------
-template< class I, class O >
-bool
-cpExtensions::Algorithms::
-MultiScaleGaussianImageFilter< I, O >::
-IsGradientMagnitudeFilter( ) const
-{
- return( this->m_FilterId == Self::GradientMagnitude );
-}
-
-// -------------------------------------------------------------------------
-template< class I, class O >
-bool
-cpExtensions::Algorithms::
-MultiScaleGaussianImageFilter< I, O >::
-IsHessianFilter( ) const
-{
- return( this->m_FilterId == Self::Hessian );
-}
-
// -------------------------------------------------------------------------
template< class I, class O >
void
MultiScaleGaussianImageFilter( )
: Superclass( )
{
- this->SetFilterToGradientMagnitude( );
- if( !this->IsGradientMagnitudeFilter( ) )
- {
- this->SetFilterToGradient( );
- if( !this->IsGradientFilter( ) )
- this->SetFilterToHessian( );
-
- } // fi
}
// -------------------------------------------------------------------------
MultiScaleGaussianImageFilter< I, O >::
GenerateData( )
{
- typedef itk::GradientRecursiveGaussianImageFilter< I, O > _TGF;
- typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< I, O > _TGMF;
- typedef itk::HessianRecursiveGaussianImageFilter< I, O > _THF;
-
- if( this->IsGradientFilter( ) )
- this->_GenerateData< _TGF >( );
- else if( this->IsGradientMagnitudeFilter( ) )
- this->_GenerateData< _TGMF >( );
- else if( this->IsHessianFilter( ) )
- this->_GenerateData< _THF >( );
+ typedef itk::GradientRecursiveGaussianImageFilter< I, O > _TGF;
+ this->_GenerateData< _TGF >( );
}
// -------------------------------------------------------------------------
{
}
+// -------------------------------------------------------------------------
+void cpExtensions::QT::SimpleMPRWidget::
+SetWindowLevel( const double& w, const double& l )
+{
+ this->m_MPRObjects->SetWindowLevel( w, l );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::QT::SimpleMPRWidget::
+GetWindow( ) const
+{
+ return( this->m_MPRObjects->GetWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::QT::SimpleMPRWidget::
+GetLevel( ) const
+{
+ return( this->m_MPRObjects->GetLevel( ) );
+}
+
// -------------------------------------------------------------------------
vtkRenderWindowInteractor* cpExtensions::QT::SimpleMPRWidget::
GetInteractor( unsigned int i )
);
void ShowData( const std::string& name );
void HideData( const std::string& name );
+ void SetWindowLevel( const double& w, const double& l );
+ double GetWindow( ) const;
+ double GetLevel( ) const;
vtkRenderWindowInteractor* GetInteractor( unsigned int i );
--- /dev/null
+#include <cpPlugins/BaseQtMainWindow.h>
+
+#ifdef cpPlugins_QT4
+
+#include <cpExtensions/QT/SimpleMPRWidget.h>
+#include <cpPipelineEditor/Editor.h>
+#include <QApplication>
+#include <QDir>
+#include <QFileDialog>
+#include <QFileInfo>
+#include <QMessageBox>
+#include <QTreeWidget>
+
+// -------------------------------------------------------------------------
+bool cpPlugins::BaseQtMainWindow::_TBlocker::
+eventFilter( QObject* obj, QEvent* event )
+{
+ return( true ); // -> Block all events
+ /* NOTE: correct implementation:
+ switch( event->type( ) )
+ {
+ //list event you want to prevent here ...
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonDblClick:
+ //...
+ return( true );
+ } // hctiws
+ return( this->QObject::eventFilter( obj, event ) );
+ */
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::BaseQtMainWindow::
+BaseQtMainWindow(
+ int argc, char* argv[],
+ QApplication* app,
+ QWidget* parent
+ )
+ : Superclass( parent ),
+ m_Application( app ),
+ m_PluginsPath( "." ),
+ m_TreeWidget( NULL ),
+ m_Editor( NULL )
+{
+ // Prepare plugins interface
+ QFileInfo info( argv[ 0 ] );
+ if( info.exists( ) )
+ {
+ this->m_Interface.LoadConfiguration( cpPlugins_CONFIG_FILE );
+ this->_LoadPluginsFromPath( this->m_PluginsPath );
+ this->m_PluginsPath = info.canonicalPath( ).toStdString( );
+
+ } // fi
+ QDir exec_dir( "." );
+ if( exec_dir.exists( ) )
+ {
+ this->_LoadPluginsFromPath( exec_dir.canonicalPath( ).toStdString( ) );
+ this->m_PluginsPath = exec_dir.canonicalPath( ).toStdString( );
+
+ } // fi
+
+ // Prepare workspace
+ this->m_Workspace.SetInterface( &( this->m_Interface ) );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::BaseQtMainWindow::
+~BaseQtMainWindow( )
+{
+ this->m_Interface.UnloadAll( );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_Configure(
+ QTreeWidget* tree,
+ cpExtensions::QT::SimpleMPRWidget* mpr,
+ cpPipelineEditor::Editor* editor
+ )
+{
+ this->m_TreeWidget = tree;
+ if( this->m_TreeWidget != NULL )
+ this->_UpdateLoadedPlugins( );
+ this->m_Editor = editor;
+ if( this->m_Editor != NULL )
+ this->m_Editor->setWorkspace( &( this->m_Workspace ) );
+ if( mpr != NULL )
+ this->m_Workspace.SetMPRViewer( mpr );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_LoadPlugins( const std::string& filename )
+{
+ try
+ {
+ this->m_Interface.LoadPluginFile( filename );
+ this->_UpdateLoadedPlugins( );
+ }
+ catch( std::exception& err )
+ {
+ QMessageBox::critical(
+ this,
+ "Error loading plugins path",
+ err.what( )
+ );
+
+ } // yrt
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_LoadPluginsFromPath( const std::string& path )
+{
+ try
+ {
+ this->m_Interface.LoadPluginDir( path );
+ this->_UpdateLoadedPlugins( );
+ }
+ catch( std::exception& err )
+ {
+ QMessageBox::critical(
+ this,
+ "Error loading plugins path",
+ err.what( )
+ );
+
+ } // yrt
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_UpdateLoadedPlugins( )
+{
+ this->_Block( );
+ auto filters = this->m_Interface.GetFilters( );
+ if( filters.size( ) == 0 )
+ {
+ this->_UnBlock( );
+ QMessageBox::critical(
+ this,
+ "Error loading default plugins",
+ "No plugins loaded: remember to load some!!!"
+ );
+ return;
+
+ } // fi
+
+ if( this->m_TreeWidget != NULL )
+ {
+ for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt )
+ {
+ // Create or get category
+ QList< QTreeWidgetItem* > cat_items =
+ this->m_TreeWidget->findItems(
+ cIt->first.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
+ );
+ QTreeWidgetItem* cat = NULL;
+ if( cat_items.size( ) == 0 )
+ {
+ cat = new QTreeWidgetItem(
+ ( QTreeWidgetItem* )( NULL ), QStringList( cIt->first.c_str( ) )
+ );
+ this->m_TreeWidget->addTopLevelItem( cat );
+ }
+ else
+ cat = cat_items[ 0 ];
+
+ // Create filters
+ auto fIt = cIt->second.begin( );
+ for( ; fIt != cIt->second.end( ); ++fIt )
+ {
+ QList< QTreeWidgetItem* > filter_items =
+ this->m_TreeWidget->findItems(
+ fIt->c_str( ), Qt::MatchExactly | Qt::MatchRecursive
+ );
+ auto fiIt = filter_items.begin( );
+ auto found_fiIt = filter_items.end( );
+ for( ; fiIt != filter_items.end( ); ++fiIt )
+ if( ( *fiIt )->parent( ) == cat )
+ found_fiIt = fiIt;
+
+ // Add filter
+ if( found_fiIt == filter_items.end( ) )
+ QTreeWidgetItem* filter = new QTreeWidgetItem(
+ cat, QStringList( fIt->c_str( ) )
+ );
+
+ } // rof
+
+ } // rof
+
+ } // fi
+ this->_UnBlock( );
+ this->m_Interface.SaveConfiguration( cpPlugins_CONFIG_FILE );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_Block( )
+{
+ this->m_Application->setOverrideCursor( Qt::WaitCursor );
+ this->m_Application->installEventFilter( &( this->m_Blocker ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_UnBlock( )
+{
+ while( this->m_Application->overrideCursor( ) )
+ this->m_Application->restoreOverrideCursor( );
+ this->m_Application->removeEventFilter( &( this->m_Blocker ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_LoadWorkspace( const std::string& filename )
+{
+ std::string err = this->m_Workspace.LoadWorkspace( filename );
+ if( err != "" )
+ {
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error loading workspace" ),
+ QMessageBox::tr( err.c_str( ) )
+ );
+ }
+ else
+ {
+ if( this->m_Editor != NULL )
+ this->m_Editor->setWorkspace( &( this->m_Workspace ) );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_SaveWorkspace( const std::string& filename )
+{
+ std::string err = this->m_Workspace.SaveWorkspace( filename );
+ if( err != "" )
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error saving workspace" ),
+ QMessageBox::tr( err.c_str( ) )
+ );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_InteractiveLoadPlugins( )
+{
+ QFileDialog dlg( this );
+ dlg.setFileMode( QFileDialog::ExistingFiles );
+ dlg.setDirectory( this->m_PluginsPath.c_str( ) );
+
+ std::stringstream name_filter;
+ std::string suffix = std::string( cpPlugins_PLUGIN_EXT );
+ name_filter
+ << "Plugins file (*." << cpPlugins_PLUGIN_EXT << ");;All files (*)";
+ dlg.setNameFilter( name_filter.str( ).c_str( ) );
+ dlg.setDefaultSuffix( suffix.c_str( ) );
+ if( !( dlg.exec( ) ) )
+ return;
+
+ QStringList names = dlg.selectedFiles( );
+ for( auto qIt = names.begin( ); qIt != names.end( ); ++qIt )
+ this->_LoadPlugins( qIt->toStdString( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_InteractiveLoadPluginsFromPath( )
+{
+ QFileDialog dlg( this );
+ dlg.setFileMode( QFileDialog::DirectoryOnly );
+ dlg.setDirectory( this->m_PluginsPath.c_str( ) );
+ if( !( dlg.exec( ) ) )
+ return;
+ this->_LoadPluginsFromPath( dlg.selectedFiles( ).begin( )->toStdString( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_InteractiveLoadWorkspace( )
+{
+ QFileDialog dlg( this );
+ dlg.setFileMode( QFileDialog::ExistingFile );
+ dlg.setDirectory( "." );
+ dlg.setNameFilter(
+ QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
+ );
+ dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
+ if( !( dlg.exec( ) ) )
+ return;
+ this->_LoadWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_InteractiveSaveWorkspace( )
+{
+ QFileDialog dlg( this );
+ dlg.setFileMode( QFileDialog::AnyFile );
+ dlg.setDirectory( "." );
+ dlg.setAcceptMode( QFileDialog::AcceptSave );
+ dlg.setNameFilter(
+ QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" )
+ );
+ dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) );
+ if( !( dlg.exec( ) ) )
+ return;
+ this->_SaveWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseQtMainWindow::
+_ExecFilter( const std::string& filter_name )
+{
+ this->_Block( );
+ std::string err = this->m_Workspace.Execute( filter_name );
+ this->_UnBlock( );
+ if( err != "" )
+ QMessageBox::critical(
+ this,
+ QMessageBox::tr( "Error executing filter" ),
+ QMessageBox::tr( err.c_str( ) )
+ );
+}
+
+#endif // cpPlugins_QT4
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__BASEQTMAINWINDOW__H__
+#define __CPPLUGINS__BASEQTMAINWINDOW__H__
+
+#include <cpPlugins/Config.h>
+
+#ifdef cpPlugins_QT4
+
+#include <QMainWindow>
+#include <cpPlugins/Interface.h>
+#include <cpPlugins/Workspace.h>
+
+namespace cpExtensions
+{
+ namespace QT
+ {
+ class SimpleMPRWidget;
+ }
+}
+namespace cpPipelineEditor
+{
+ class Editor;
+}
+class QTreeWidget;
+
+namespace cpPlugins
+{
+ /**
+ */
+ class cpPlugins_EXPORT BaseQtMainWindow
+ : public QMainWindow
+ {
+ Q_OBJECT;
+
+ public:
+ typedef BaseQtMainWindow Self;
+ typedef QMainWindow Superclass;
+
+ protected:
+ /**
+ */
+ class _TBlocker
+ : public QObject
+ {
+ protected:
+ virtual bool eventFilter( QObject* obj, QEvent* event ) ITK_OVERRIDE;
+ };
+
+ public:
+ explicit BaseQtMainWindow(
+ int argc, char* argv[],
+ QApplication* app,
+ QWidget* parent = NULL
+ );
+ virtual ~BaseQtMainWindow( );
+
+ protected:
+ void _Configure(
+ QTreeWidget* tree,
+ cpExtensions::QT::SimpleMPRWidget* mpr,
+ cpPipelineEditor::Editor* editor
+ );
+ void _LoadPlugins( const std::string& filename );
+ void _LoadPluginsFromPath( const std::string& path );
+ void _UpdateLoadedPlugins( );
+ void _Block( );
+ void _UnBlock( );
+
+ void _LoadWorkspace( const std::string& filename );
+ void _SaveWorkspace( const std::string& filename );
+
+ protected slots:
+ void _InteractiveLoadPlugins( );
+ void _InteractiveLoadPluginsFromPath( );
+ void _InteractiveLoadWorkspace( );
+ void _InteractiveSaveWorkspace( );
+ void _ExecFilter( const std::string& filter_name );
+
+ protected:
+ QApplication* m_Application;
+ _TBlocker m_Blocker;
+ Workspace m_Workspace;
+ Interface m_Interface;
+ std::string m_PluginsPath;
+
+ QTreeWidget* m_TreeWidget;
+ cpPipelineEditor::Editor* m_Editor;
+ };
+
+} // ecapseman
+
+#endif // cpPlugins_QT4
+
+#endif // __CPPLUGINS__BASEQTMAINWINDOW__H__
+
+// eof - $RCSfile$
)
SET(
lib_QT_Headers
+ BaseQtMainWindow.h
ParametersQtDialog.h
)
SET(
lib_QT_Sources
+ BaseQtMainWindow.cxx
ParametersQtDialog.cxx
)
SET(
#define cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, PIXEL, D ) \
this->FUNC( dynamic_cast< itk::Image< PIXEL, D >* >( INPUT ) )
+#define cpPlugin_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, PIXEL, D ) \
+ this->FUNC( dynamic_cast< itk::Image< VECTOR< PIXEL, D >, D >* >( INPUT ) )
+
#define cpPlugin_Image_Demangle_Pixel_AllScalars( r, FUNC, INPUT, D ) \
r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, char, D ); \
if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, short, D ); \
if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned int >, D ); \
if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned long >, D )
+#define cpPlugin_Image_Demangle_VectorPixel_AllFloats( r, FUNC, INPUT, VECTOR, D ) \
+ r = cpPlugin_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, float, D ); \
+ if( r != "" ) r = cpPlugin_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, double, D )
+
#endif // __CPPLUGINS__IMAGE__HXX__
// eof - $RCSfile$
);
// Check if it was already loaded
- if( this->m_DynLibraries.find( canonical_fn ) != this->m_DynLibraries.end( ) )
+ if(
+ this->m_DynLibraries.find( canonical_fn ) != this->m_DynLibraries.end( )
+ )
return;
// Ok, try to load the library
{
try
{
- this->LoadPluginFile( ent->d_name );
+ this->LoadPluginFile(
+ dirname +
+ std::string( "/" ) +
+ ent->d_name
+ );
count++;
}
catch( ... )
#include <cpPlugins/Mesh.h>
#include <itkMesh.h>
-#include <itkQuadEdgeMesh.h>
#include <itkLineCell.h>
#include <itkTriangleCell.h>
#include <itkPolygonCell.h>
if( !r ) r = this->_ITK_2_VTK< itk::Mesh< double, 2 > >( o );
if( !r ) r = this->_ITK_2_VTK< itk::Mesh< float, 3 > >( o );
if( !r ) r = this->_ITK_2_VTK< itk::Mesh< double, 3 > >( o );
- if( !r ) r = this->_ITK_2_VTK< itk::QuadEdgeMesh< float, 2 > >( o );
- if( !r ) r = this->_ITK_2_VTK< itk::QuadEdgeMesh< double, 2 > >( o );
- if( !r ) r = this->_ITK_2_VTK< itk::QuadEdgeMesh< float, 3 > >( o );
- if( !r ) r = this->_ITK_2_VTK< itk::QuadEdgeMesh< double, 3 > >( o );
}
// -------------------------------------------------------------------------
namespace itk
{
+ cpPlugins_ITKInstances_Base_ostream( FixedArray, float, 2 );
+ cpPlugins_ITKInstances_Base_ostream( FixedArray, double, 2 );
+ cpPlugins_ITKInstances_Base_ostream( FixedArray, float, 3 );
+ cpPlugins_ITKInstances_Base_ostream( FixedArray, double, 3 );
+
cpPlugins_ITKInstances_Base_ostream( Point, float, 1 );
cpPlugins_ITKInstances_Base_ostream( Vector, float, 1 );
cpPlugins_ITKInstances_Base_ostream( Point, double, 1 );
i string
i vector
i itkArray.h
+i itkArray2D.h
i itkConvertPixelBuffer.h
i itkDefaultConvertPixelTraits.h
i itkFixedArray.h
i itkIndex.h
i itkMatrix.h
i itkPoint.h
+i itkCovariantVector.h
i itkVector.h
i itkRGBPixel.h
i itkRGBAPixel.h
i itkSimpleDataObjectDecorator.h
+i itkDataObjectDecorator.h
+i itkAffineTransform.h
+i itkTransform.h
c itk::Array< #1 >
c itk::FixedArray< #1 , #2 >
c itk::FixedArray< float , 6 >
c itk::Point< #5 , #2 >
c itk::Vector< #5 , #2 >
+c itk::CovariantVector< #5 , #2 >
c itk::Matrix< #5 , #2 , #2 >
c #7 < #1 >
+c itk::Array2D < #5 >
+c itk::Transform < #5 , #2 , #2 >
+c itk::DataObjectDecorator< itk::Transform < #5 , #2 , #2 > >
c itk::SimpleDataObjectDecorator< #1 >
c itk::SimpleDataObjectDecorator< #3 >
c itk::SimpleDataObjectDecorator< std::vector< itk::Index< #6 > > >
c itk::ImportImageContainer< unsigned long , #1 >
c itk::ImportImageContainer< unsigned long , std::complex< #5 > >
c itk::ImportImageContainer< unsigned long , #7 < #1 > >
+c itk::ImportImageContainer< unsigned long , #8 < #5 , #2 > >
a #1 = #integers;#floats
a #2 = #all_dims
a #3 = bool;std::string
a #5 = #floats
a #6 = #all_visual_dims
a #7 = itk::RGBPixel;itk::RGBAPixel
+a #8 = itk::Vector;itk::CovariantVector
#include <cpPlugins_ITKInstances/Image.h>
+#include <itkFixedArray.h>
// -------------------------------------------------------------------------
#define cpPlugins_ITKInstances_Image_ImageRegion( D ) \
c itk::ImageSource< itk::Image< std::complex< #3 > , #2 > >
c itk::ImageSource< itk::Image< #5 < #1 > , #2 > >
c itk::ImageToImageFilter< itk::Image< #1 , #2 > , itk::Image< #4 , #2 > >
+c itk::ImageToImageFilter< itk::Image< #1 , 2 > , itk::Image< #1 , 3 > >
+c itk::ImageToImageFilter< itk::Image< #1 , 3 > , itk::Image< #1 , 2 > >
c itk::InPlaceImageFilter< itk::Image< #1 , #2 > , itk::Image< #4 , #2 > >
+c itk::InPlaceImageFilter< itk::Image< #1 , 3 > , itk::Image< #1 , 2 > >
c itk::ImageTransformer< itk::Image< #1 , #2 > >
a #1 = #integers;#floats
a #2 = #all_dims
c itk::Image< #1 , #2 >
c itk::Image< std::complex< #4 > , #2 >
c itk::Image< #6 < #1 > , #2 >
+c itk::Image< #7 < #4 , #2 > , #2 >
c itk::ImageToVTKImageFilter< itk::Image< #1 , #3 > >
c itk::ImageToVTKImageFilter< itk::Image< #6 < #1 > , #3 > >
a #1 = #integers;#floats
a #4 = #floats
a #5 = #integers_ptr;#floats_ptr
a #6 = itk::RGBPixel;itk::RGBAPixel
+a #7 = itk::Vector;itk::CovariantVector
i itkBoundingBox.h
i itkPointSet.h
i itkMesh.h
-i itkQuadEdgeMesh.h
i itkLineCell.h
i itkPolygonCell.h
i itkTriangleCell.h
c itk::VectorContainer< unsigned long, itk::Point< #1 , #2 > >
-c itk::MapContainer< unsigned long , itk::QuadEdgeMeshPoint< #1 , #2 , itk::GeometricalQuadEdge< unsigned long, unsigned long, bool, bool, true > > >
c itk::BoundingBox< unsigned long , #2 , float, itk::VectorContainer< unsigned long , itk::Point< float , #2 > > >
c itk::PointSet< #1 , #2 >
c #4 < #1 , #2 >
a #1 = #floats
a #2 = #all_visual_dims
a #3 = itk::LineCell;itk::PolygonCell;itk::TriangleCell
-a #4 = itk::Mesh;itk::QuadEdgeMesh
+a #4 = itk::Mesh
EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h
STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC
)
-TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES})
+TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES})
## ========================
## -- Installation rules --
EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h
STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC
)
-TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES})
+TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES})
## ========================
## -- Installation rules --
--- /dev/null
+#include <cpPluginsImageFilters/ExtractImageFilter.h>
+#include <cpPlugins/Image.h>
+#include <cpPlugins_ITKInstances/ImageFilters.h>
+
+#include <itkExtractImageFilter.h>
+#include <itkExtractImageFilter.hxx>
+#include <itkImageAlgorithm.hxx>
+
+// -------------------------------------------------------------------------
+cpPluginsImageFilters::ExtractImageFilter::
+ExtractImageFilter( )
+ : Superclass( )
+{
+ this->_AddInput( "Input" );
+ this->_AddOutput< cpPlugins::Image >( "Output" );
+ this->m_Parameters.ConfigureAsBool( "ReduceDimension" );
+ this->m_Parameters.SetBool( "ReduceDimension", false );
+
+ /* TODO
+ std::vector< std::string > choices;
+ choices.push_back( "float" );
+ choices.push_back( "double" );
+ this->m_Parameters.ConfigureAsChoices( "ScalarType", choices );
+ this->m_Parameters.SetSelectedChoice( "ScalarType", "float" );
+ this->m_Parameters.ConfigureAsReal( "UpperThresholdValue" );
+ this->m_Parameters.ConfigureAsUint( "InsideValue" );
+ this->m_Parameters.ConfigureAsUint( "OutsideValue" );
+
+ this->m_Parameters.SetReal( "LowerThresholdValue", 0 );
+ this->m_Parameters.SetReal( "UpperThresholdValue", 10000 );
+ this->m_Parameters.SetReal( "InsideValue", 1 );
+ this->m_Parameters.SetReal( "OutsideValue", 0 );
+ */
+}
+
+// -------------------------------------------------------------------------
+cpPluginsImageFilters::ExtractImageFilter::
+~ExtractImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPluginsImageFilters::ExtractImageFilter::
+_GenerateData( )
+{
+ auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
+ std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+std::string cpPluginsImageFilters::ExtractImageFilter::
+_GD0( _TImage* image )
+{
+ typedef
+ itk::Image< typename _TImage::PixelType, _TImage::ImageDimension - 1 >
+ _TOutImage;
+ typedef itk::ExtractImageFilter< _TImage, _TOutImage > _TFilter;
+
+ if( image == NULL )
+ return(
+ "ImageFilters::ExtractImageFilter: No valid input image."
+ );
+
+
+ // Configure filter
+ typename _TImage::RegionType reg;
+
+ _TFilter* filter = this->_CreateITK< _TFilter >( );
+ filter->SetInput( image );
+ filter->SetExtractionRegion( reg );
+
+ // Connect output
+ this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
+ return( "" );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINSIMAGEFILTERS__EXTRACTIMAGEFILTER__H__
+#define __CPPLUGINSIMAGEFILTERS__EXTRACTIMAGEFILTER__H__
+
+#include <plugins/cpPluginsImageFilters/cpPluginsImageFilters_Export.h>
+#include <cpPlugins/ProcessObject.h>
+
+namespace cpPluginsImageFilters
+{
+ /**
+ */
+ class cpPluginsImageFilters_EXPORT ExtractImageFilter
+ : public cpPlugins::ProcessObject
+ {
+ public:
+ typedef ExtractImageFilter Self;
+ typedef cpPlugins::ProcessObject Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( ExtractImageFilter, cpPlugins::ProcessObject );
+ cpPlugins_Id_Macro( ExtractImageFilter, ImageFilters );
+
+ protected:
+ ExtractImageFilter( );
+ virtual ~ExtractImageFilter( );
+
+ virtual std::string _GenerateData( );
+
+ template< class _TImage >
+ inline std::string _GD0( _TImage* image );
+
+ private:
+ // Purposely not implemented
+ ExtractImageFilter( const Self& );
+ Self& operator=( const Self& );
+ };
+
+} // ecapseman
+
+#endif // __CPPLUGINSIMAGEFILTERS__EXTRACTIMAGEFILTER__H__
+
+// eof - $RCSfile$
--- /dev/null
+#include <cpPluginsImageFilters/IsoImageSlicer.h>
+#include <cpPlugins/Image.h>
+#include <cpPlugins_ITKInstances/ImageFilters.h>
+
+#include <cpExtensions/Algorithms/IsoImageSlicer.h>
+#include <cpExtensions/Algorithms/IsoImageSlicer.hxx>
+#include <itkAffineTransform.hxx>
+#include <itkMatrixOffsetTransformBase.hxx>
+#include <itkVariableLengthVector.hxx>
+#include <itkDiffusionTensor3D.hxx>
+#include <itkOptimizerParameters.hxx>
+/*
+ #include <itkIsoImageSlicer.h>
+ #include <itkIsoImageSlicer.hxx>
+ #include <itkUnaryFunctorImageFilter.hxx>
+*/
+
+// -------------------------------------------------------------------------
+cpPluginsImageFilters::IsoImageSlicer::
+IsoImageSlicer( )
+ : Superclass( )
+{
+ this->_AddInput( "Input" );
+ this->_AddOutput< cpPlugins::Image >( "Output" );
+
+ std::vector< std::string > choices;
+ choices.push_back( "float" );
+ choices.push_back( "double" );
+ this->m_Parameters.ConfigureAsChoices( "ScalarType", choices );
+ this->m_Parameters.SetSelectedChoice( "ScalarType", "float" );
+ /* TODO
+ this->m_Parameters.ConfigureAsReal( "LowerThresholdValue" );
+ this->m_Parameters.ConfigureAsReal( "UpperThresholdValue" );
+ this->m_Parameters.ConfigureAsUint( "InsideValue" );
+ this->m_Parameters.ConfigureAsUint( "OutsideValue" );
+
+ this->m_Parameters.SetReal( "LowerThresholdValue", 0 );
+ this->m_Parameters.SetReal( "UpperThresholdValue", 10000 );
+ this->m_Parameters.SetReal( "InsideValue", 1 );
+ this->m_Parameters.SetReal( "OutsideValue", 0 );
+ */
+}
+
+// -------------------------------------------------------------------------
+cpPluginsImageFilters::IsoImageSlicer::
+~IsoImageSlicer( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPluginsImageFilters::IsoImageSlicer::
+_GenerateData( )
+{
+ auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
+ std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+std::string cpPluginsImageFilters::IsoImageSlicer::
+_GD0( _TImage* image )
+{
+ if( image != NULL )
+ {
+ auto choice = this->m_Parameters.GetSelectedChoice( "OutputResolution" );
+ if( choice == "float" )
+ return( this->_GD1< _TImage, float >( image ) );
+ else if( choice == "double" )
+ return( this->_GD1< _TImage, double >( image ) );
+ else return( "IsoImageSlicer: no valid scalar type." );
+ }
+ else
+ return(
+ "ImageFilters::IsoImageSlicer: No valid input image."
+ );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage, class _TScalar >
+std::string cpPluginsImageFilters::IsoImageSlicer::
+_GD1( _TImage* image )
+{
+ typedef
+ cpExtensions::Algorithms::IsoImageSlicer< _TImage, _TScalar >
+ _TFilter;
+ typedef typename _TFilter::TVector _TVector;
+ typedef typename _TFilter::TMatrix _TMatrix;
+
+ // Configure filter
+ _TFilter* filter = this->_CreateITK< _TFilter >( );
+ filter->SetInput( image );
+ filter->SetInterpolator( NULL );
+ filter->SetTranslation( _TVector( ) );
+ filter->SetRotation( _TMatrix( ) );
+ filter->SetSize( 1 );
+ /* TODO
+ filter->SetLowerThreshold( lower_val );
+ filter->SetUpperThreshold( upper_val );
+ filter->SetInsideValue( in_val );
+ filter->SetOutsideValue( out_val );
+ filter->Update( );
+ */
+
+ // Connect output
+ this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
+ return( "" );
+}
+
+#include <cpExtensions/Algorithms/BezierCurveFunction.h>
+#include <cpExtensions/Algorithms/BezierCurveFunction.hxx>
+
+template class cpPluginsImageFilters_EXPORT cpExtensions::Algorithms::BezierCurveFunction< itk::Vector< float, 3 > >;
+template class cpPluginsImageFilters_EXPORT cpExtensions::Algorithms::BezierCurveFunction< itk::Vector< double, 3 > >;
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINSIMAGEFILTERS__ISOIMAGESLICER__H__
+#define __CPPLUGINSIMAGEFILTERS__ISOIMAGESLICER__H__
+
+#include <plugins/cpPluginsImageFilters/cpPluginsImageFilters_Export.h>
+#include <cpPlugins/ProcessObject.h>
+
+namespace cpPluginsImageFilters
+{
+ /**
+ */
+ class cpPluginsImageFilters_EXPORT IsoImageSlicer
+ : public cpPlugins::ProcessObject
+ {
+ public:
+ typedef IsoImageSlicer Self;
+ typedef cpPlugins::ProcessObject Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( IsoImageSlicer, cpPlugins::ProcessObject );
+ cpPlugins_Id_Macro( IsoImageSlicer, ImageFilters );
+
+ protected:
+ IsoImageSlicer( );
+ virtual ~IsoImageSlicer( );
+
+ virtual std::string _GenerateData( );
+
+ template< class _TImage >
+ inline std::string _GD0( _TImage* image );
+
+ template< class _TImage, class _TScalar >
+ inline std::string _GD1( _TImage* image );
+
+ private:
+ // Purposely not implemented
+ IsoImageSlicer( const Self& );
+ Self& operator=( const Self& );
+ };
+
+} // ecapseman
+
+#endif // __CPPLUGINSIMAGEFILTERS__ISOIMAGESLICER__H__
+
+// eof - $RCSfile$
--- /dev/null
+#include <cpPluginsImageFilters/JoinSeriesImageFilter.h>
+#include <cpPlugins/Image.h>
+#include <cpPlugins_ITKInstances/ImageFilters.h>
+
+#include <itkJoinSeriesImageFilter.h>
+#include <itkJoinSeriesImageFilter.hxx>
+#include <itkImageAlgorithm.hxx>
+
+// -------------------------------------------------------------------------
+cpPluginsImageFilters::JoinSeriesImageFilter::
+JoinSeriesImageFilter( )
+ : Superclass( )
+{
+ this->_AddInput( "Input" );
+ this->_AddOutput< cpPlugins::Image >( "Output" );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsImageFilters::JoinSeriesImageFilter::
+~JoinSeriesImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPluginsImageFilters::JoinSeriesImageFilter::
+_GenerateData( )
+{
+ auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
+ std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+std::string cpPluginsImageFilters::JoinSeriesImageFilter::
+_GD0( _TImage* image )
+{
+ typedef
+ itk::Image< typename _TImage::PixelType, _TImage::ImageDimension + 1 >
+ _TOutImage;
+ typedef itk::JoinSeriesImageFilter< _TImage, _TOutImage > _TFilter;
+
+ if( image == NULL )
+ return(
+ "ImageFilters::JoinSeriesImageFilter: No valid input image."
+ );
+
+ // Configure filter
+ _TFilter* filter = this->_CreateITK< _TFilter >( );
+ filter->SetInput( image );
+ /* TODO
+ filter->SetLowerThreshold( lower_val );
+ filter->SetUpperThreshold( upper_val );
+ filter->SetInsideValue( in_val );
+ filter->SetOutsideValue( out_val );
+ filter->Update( );
+ */
+
+ // Connect output
+ this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
+ return( "" );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINSIMAGEFILTERS__JOINSERIESIMAGEFILTER__H__
+#define __CPPLUGINSIMAGEFILTERS__JOINSERIESIMAGEFILTER__H__
+
+#include <plugins/cpPluginsImageFilters/cpPluginsImageFilters_Export.h>
+#include <cpPlugins/ProcessObject.h>
+
+namespace cpPluginsImageFilters
+{
+ /**
+ */
+ class cpPluginsImageFilters_EXPORT JoinSeriesImageFilter
+ : public cpPlugins::ProcessObject
+ {
+ public:
+ typedef JoinSeriesImageFilter Self;
+ typedef cpPlugins::ProcessObject Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( JoinSeriesImageFilter, cpPlugins::ProcessObject );
+ cpPlugins_Id_Macro( JoinSeriesImageFilter, ImageFilters );
+
+ protected:
+ JoinSeriesImageFilter( );
+ virtual ~JoinSeriesImageFilter( );
+
+ virtual std::string _GenerateData( );
+
+ template< class _TImage >
+ inline std::string _GD0( _TImage* image );
+
+ template< class _TImage, class _TScalar >
+ inline std::string _GD1( _TImage* image );
+
+ private:
+ // Purposely not implemented
+ JoinSeriesImageFilter( const Self& );
+ Self& operator=( const Self& );
+ };
+
+} // ecapseman
+
+#endif // __CPPLUGINSIMAGEFILTERS__JOINSERIESIMAGEFILTER__H__
+
+// eof - $RCSfile$
--- /dev/null
+#include <cpPluginsImageFilters/MultiScaleGaussianImageFilter.h>
+#include <cpPlugins/Image.h>
+#include <cpPlugins_ITKInstances/ImageFilters.h>
+
+#include <cpExtensions/Algorithms/MultiScaleGaussianImageFilter.h>
+#include <cpExtensions/Algorithms/MultiScaleGaussianImageFilter.hxx>
+#include <itkGradientRecursiveGaussianImageFilter.hxx>
+#include <itkImageAdaptor.hxx>
+#include <itkImageToImageFilter.hxx>
+#include <itkInPlaceImageFilter.hxx>
+#include <itkUnaryFunctorImageFilter.hxx>
+#include <itkRecursiveGaussianImageFilter.hxx>
+#include <itkImageConstIteratorWithIndex.hxx>
+#include <itkRecursiveSeparableImageFilter.hxx>
+#include <itkBinaryFunctorImageFilter.hxx>
+#include <itkImageRegionConstIterator.hxx>
+#include <itkImageScanlineIterator.hxx>
+#include <itkImageSource.hxx>
+#include <itkImageRegionIteratorWithIndex.hxx>
+#include <itkImageScanlineConstIterator.hxx>
+#include <itkImageRegionIterator.hxx>
+#include <itkSimpleDataObjectDecorator.hxx>
+#include <itkImageRegionConstIteratorWithIndex.hxx>
+
+// -------------------------------------------------------------------------
+cpPluginsImageFilters::MultiScaleGaussianImageFilter::
+MultiScaleGaussianImageFilter( )
+ : Superclass( )
+{
+ this->_AddInput( "Input" );
+ this->_AddOutput< cpPlugins::Image >( "Output" );
+
+ this->m_Parameters.ConfigureAsRealList( "Sigmas" );
+
+ std::vector< std::string > choices;
+ choices.push_back( "float" );
+ choices.push_back( "double" );
+ this->m_Parameters.ConfigureAsChoices( "ScalarType", choices );
+ this->m_Parameters.SetSelectedChoice( "ScalarType", "float" );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsImageFilters::MultiScaleGaussianImageFilter::
+~MultiScaleGaussianImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter::
+_GenerateData( )
+{
+ auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
+ std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
+ if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter::
+_GD0( _TImage* image )
+{
+ if( image != NULL )
+ {
+ auto choice = this->m_Parameters.GetSelectedChoice( "ScalarType" );
+ if( choice == "float" )
+ return( this->_GD1< _TImage, float >( image ) );
+ else if( choice == "double" )
+ return( this->_GD1< _TImage, double >( image ) );
+ else return( "MultiScaleGaussianImageFilter: no valid scalar type." );
+ }
+ else
+ return(
+ "MultiScaleGaussianImageFilter: No valid input image."
+ );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage, class _TScalar >
+std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter::
+_GD1( _TImage* image )
+{
+ typedef itk::CovariantVector< _TScalar, _TImage::ImageDimension > _TVector;
+ typedef itk::Image< _TVector, _TImage::ImageDimension > _TGradient;
+ typedef
+ cpExtensions::Algorithms::MultiScaleGaussianImageFilter< _TImage, _TGradient >
+ _TFilter;
+
+ auto sigmas = this->m_Parameters.GetRealList( "Sigmas" );
+ if( sigmas.size( ) == 0 )
+ return(
+ "MultiScaleGaussianImageFilter: No given sigmas."
+ );
+
+ // Configure filter
+ _TFilter* filter = this->_CreateITK< _TFilter >( );
+ filter->SetInput( image );
+ for( auto sIt = sigmas.begin( ); sIt != sigmas.end( ); ++sIt )
+ filter->AddScale( *sIt );
+ filter->Update( );
+
+ // Connect output
+ this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
+ return( "" );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINSIMAGEFILTERS__MULTISCALEGAUSSIANIMAGEFILTER__H__
+#define __CPPLUGINSIMAGEFILTERS__MULTISCALEGAUSSIANIMAGEFILTER__H__
+
+#include <plugins/cpPluginsImageFilters/cpPluginsImageFilters_Export.h>
+#include <cpPlugins/ProcessObject.h>
+
+namespace cpPluginsImageFilters
+{
+ /**
+ */
+ class cpPluginsImageFilters_EXPORT MultiScaleGaussianImageFilter
+ : public cpPlugins::ProcessObject
+ {
+ public:
+ typedef MultiScaleGaussianImageFilter Self;
+ typedef cpPlugins::ProcessObject Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( MultiScaleGaussianImageFilter, cpPlugins::ProcessObject );
+ cpPlugins_Id_Macro( MultiScaleGaussianImageFilter, ImageFilters );
+
+ protected:
+ MultiScaleGaussianImageFilter( );
+ virtual ~MultiScaleGaussianImageFilter( );
+
+ virtual std::string _GenerateData( );
+
+ template< class _TImage >
+ inline std::string _GD0( _TImage* image );
+
+ template< class _TImage, class _TScalar >
+ inline std::string _GD1( _TImage* image );
+
+ private:
+ // Purposely not implemented
+ MultiScaleGaussianImageFilter( const Self& );
+ Self& operator=( const Self& );
+ };
+
+} // ecapseman
+
+#endif // __CPPLUGINSIMAGEFILTERS__MULTISCALEGAUSSIANIMAGEFILTER__H__
+
+// eof - $RCSfile$
--- /dev/null
+#include <cpPluginsImageFilters/ResampleImageFilter.h>
+#include <cpPlugins/Image.h>
+#include <cpPlugins_ITKInstances/ImageFilters.h>
+
+#include <itkResampleImageFilter.h>
+#include <itkResampleImageFilter.hxx>
+#include <itkImageFunction.hxx>
+#include <itkLinearInterpolateImageFunction.hxx>
+#include <itkImageAlgorithm.hxx>
+
+// -------------------------------------------------------------------------
+cpPluginsImageFilters::ResampleImageFilter::
+ResampleImageFilter( )
+ : Superclass( )
+{
+ this->_AddInput( "Input" );
+ this->_AddOutput< cpPlugins::Image >( "Output" );
+ std::vector< std::string > choices;
+ choices.push_back( "float" );
+ choices.push_back( "double" );
+ this->m_Parameters.ConfigureAsChoices( "ScalarType", choices );
+ this->m_Parameters.SetSelectedChoice( "ScalarType", "float" );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsImageFilters::ResampleImageFilter::
+~ResampleImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPluginsImageFilters::ResampleImageFilter::
+_GenerateData( )
+{
+ auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( );
+ std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 1 );
+ if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 );
+ if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 );
+ if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 4 );
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+std::string cpPluginsImageFilters::ResampleImageFilter::
+_GD0( _TImage* image )
+{
+ if( image != NULL )
+ {
+ auto choice = this->m_Parameters.GetSelectedChoice( "OutputResolution" );
+ if( choice == "float" )
+ return( this->_GD1< _TImage, float >( image ) );
+ else if( choice == "double" )
+ return( this->_GD1< _TImage, double >( image ) );
+ else return( "ResampleImageFilter: no valid scalar type." );
+ }
+ else
+ return(
+ "ResampleImageFilter: No valid input image."
+ );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage, class _TScalar >
+std::string cpPluginsImageFilters::ResampleImageFilter::
+_GD1( _TImage* image )
+{
+ typedef
+ itk::ResampleImageFilter< _TImage, _TImage, _TScalar, _TScalar >
+ _TFilter;
+
+ if( image == NULL )
+ return(
+ "ImageFilters::ResampleImageFilter: No valid input image."
+ );
+
+
+ // Configure filter
+ _TFilter* filter = this->_CreateITK< _TFilter >( );
+ filter->SetInput( image );
+
+ // Connect output
+ this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
+ return( "" );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINSIMAGEFILTERS__RESAMPLEIMAGEFILTER__H__
+#define __CPPLUGINSIMAGEFILTERS__RESAMPLEIMAGEFILTER__H__
+
+#include <plugins/cpPluginsImageFilters/cpPluginsImageFilters_Export.h>
+#include <cpPlugins/ProcessObject.h>
+
+namespace cpPluginsImageFilters
+{
+ /**
+ */
+ class cpPluginsImageFilters_EXPORT ResampleImageFilter
+ : public cpPlugins::ProcessObject
+ {
+ public:
+ typedef ResampleImageFilter Self;
+ typedef cpPlugins::ProcessObject Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( ResampleImageFilter, cpPlugins::ProcessObject );
+ cpPlugins_Id_Macro( ResampleImageFilter, ImageFilters );
+
+ protected:
+ ResampleImageFilter( );
+ virtual ~ResampleImageFilter( );
+
+ virtual std::string _GenerateData( );
+
+ template< class _TImage >
+ inline std::string _GD0( _TImage* image );
+
+ template< class _TImage, class _TScalar >
+ inline std::string _GD1( _TImage* image );
+
+ private:
+ // Purposely not implemented
+ ResampleImageFilter( const Self& );
+ Self& operator=( const Self& );
+ };
+
+} // ecapseman
+
+#endif // __CPPLUGINSIMAGEFILTERS__RESAMPLEIMAGEFILTER__H__
+
+// eof - $RCSfile$
EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h
STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC
)
-TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES})
+TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES})
## ========================
## -- Installation rules --
EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h
STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC
)
-TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES})
+TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES})
## ========================
## -- Installation rules --
EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h
STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC
)
-TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES})
+TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES})
## ========================
## -- Installation rules --
EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/plugins/${lib_DIR}/${lib_NAME}_Export.h
STATIC_DEFINE ${lib_NAME}_BUILT_AS_STATIC
)
-TARGET_LINK_LIBRARIES(${lib_NAME} ${target_LIBRARIES})
+TARGET_LINK_LIBRARIES(${lib_NAME} cpPipelineEditor ${target_LIBRARIES})
## ========================
## -- Installation rules --