IF(BUILD_EXAMPLES)
SUBDIRS(
examples
- ImageMPR
+ #ImageMPR
)
IF(USE_QT4)
SUBDIRS(
App_cpPipelineEditor( int argc, char* argv[], QWidget* parent )
: QMainWindow( parent ),
m_UI( new Ui::App_cpPipelineEditor ),
- m_Workspace( NULL )
+ m_Workspace( NULL ),
+ m_PluginsPath( "." )
{
this->m_UI->setupUi( this );
QFileInfo info( argv[ 0 ] );
if( info.exists( ) )
{
- std::string path = info.canonicalPath( ).toStdString( );
- if( !( this->m_Plugins->LoadDefaultConfiguration( path ) ) )
- if( this->m_Plugins->LoadFromFolder( path, false ) )
- if( !( this->m_Plugins->SaveDefaultConfiguration( path ) ) )
+ this->m_PluginsPath = info.canonicalPath( ).toStdString( );
+ if( !( this->m_Plugins->LoadDefaultConfiguration( this->m_PluginsPath ) ) )
+ if( this->m_Plugins->LoadFromFolder( this->m_PluginsPath, false ) )
+ if( !( this->m_Plugins->SaveDefaultConfiguration( this->m_PluginsPath ) ) )
QMessageBox::critical(
this,
"Error creating default plugins configuration",
);
// Update view
+ this->m_Plugins->SaveDefaultConfiguration( this->m_PluginsPath );
this->_UpdateLoadedPlugins( );
}
);
// Update view
+ this->m_Plugins->SaveDefaultConfiguration( this->m_PluginsPath );
this->_UpdateLoadedPlugins( );
}
delete this->m_Workspace;
this->m_Workspace = new cpPlugins::Interface::Workspace( );
this->m_Workspace->SetPlugins( this->m_Plugins );
+ this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 0 ) );
+ this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 1 ) );
+ this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 2 ) );
+ this->m_Workspace->AddInteractor( this->m_UI->Viewer->GetInteractor( 3 ) );
std::string err = this->m_Workspace->LoadWorkspace( fname );
if( err != "" )
{
Ui::App_cpPipelineEditor* m_UI;
cpPlugins::Interface::Workspace* m_Workspace;
cpPlugins::Interface::Interface* m_Plugins;
+ std::string m_PluginsPath;
};
#endif // __CPPIPELINEEDITOR__H__
example_TestParameters
example_LoadPlugins
example_LoadPluginsFromPath
- example_WorkspaceSandBox
+ #example_WorkspaceSandBox
)
FOREACH(prog ${EXAMPLES_PROGRAMS_ONLY_INTERFACE})
SET(
EXAMPLES_PROGRAMS_WITH_PLUGINS
- example_ReadWriteImage
- example_MarchingCubes
+ #example_ReadWriteImage
+ #example_MarchingCubes
#example_MPR
- example_View2DImage
- example_ViewImageThreshold
- example_HandleWidget
- example_SeedWidget
- example_SphereWidget
- example_Test_Memento
+ #example_View2DImage
+ #example_ViewImageThreshold
+ #example_HandleWidget
+ #example_SeedWidget
+ #example_SphereWidget
+ #example_Test_Memento
##example_OtsuFilter
##example_RGBImageToHSVChannels
##example_RGBImageToYPbPrChannels
SET(
NOPLUGINS_EXAMPLES_PROGRAMS
- example_BaseInteractorStyle
+ #example_BaseInteractorStyle
- example_ContourWidget
+ #example_ContourWidget
##example_Test_async
## example_MacheteFilter
## example_Test_DoubleClick
} // rof
// Show loaded classes
- auto c = interface.GetClasses( ).begin( );
- for( ; c != interface.GetClasses( ).end( ); ++c )
- std::cout << "Class -> " << c->first << std::endl;
+ auto cat = interface.GetClasses( ).begin( );
+ for( ; cat != interface.GetClasses( ).end( ); ++cat )
+ {
+ std::cout << "Catergory -> " << cat->first << std::endl;
+ auto cla = cat->second.begin( );
+ for( ; cla != cat->second.end( ); ++cla )
+ std::cout << "\tClass -> " << cla->first << std::endl;
+
+ } // rof
return( 0 );
}
} // rof
- // Show loaded classes
- auto c = interface.GetClasses( ).begin( );
- for( ; c != interface.GetClasses( ).end( ); ++c )
- std::cout << "Class -> " << c->first << std::endl;
+ // Show loaded classes
+ auto cat = interface.GetClasses( ).begin( );
+ for( ; cat != interface.GetClasses( ).end( ); ++cat )
+ {
+ std::cout << "Catergory -> " << cat->first << std::endl;
+ auto cla = cat->second.begin( );
+ for( ; cla != cat->second.end( ); ++cla )
+ std::cout << "\tClass -> " << cla->first << std::endl;
+
+ } // rof
return( 0 );
}
#include <iostream>
#include <vector>
-#include <itkIndex.h>
-#include <itkPoint.h>
-
#include <cpPlugins/Interface/Parameters.h>
// -------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
typedef cpPlugins::Interface::Parameters TParameters;
- typedef itk::Index< 3 > TIndex;
- typedef itk::Point< float, 3 > TPoint;
TParameters::Pointer parameters = TParameters::New( );
- TIndex idx; idx[ 0 ] = 1; idx[ 1 ] = 2; idx[ 2 ] = 3;
- TPoint pnt; pnt[ 0 ] = 3.1; pnt[ 1 ] = 2.2; pnt[ 2 ] = 1.3;
-
parameters->ConfigureAsString( "StringParam" );
parameters->ConfigureAsBool( "BoolParam" );
parameters->ConfigureAsInt( "IntParam" );
parameters->ConfigureAsUint( "UintParam" );
parameters->ConfigureAsReal( "RealParam" );
- parameters->ConfigureAsIndex( "IndexParam" );
- parameters->ConfigureAsPoint( "PointParam" );
parameters->ConfigureAsStringList( "StringListParam" );
parameters->ConfigureAsBoolList( "BoolListParam" );
parameters->ConfigureAsIntList( "IntListParam" );
parameters->ConfigureAsUintList( "UintListParam" );
parameters->ConfigureAsRealList( "RealListParam" );
- parameters->ConfigureAsIndexList( "IndexListParam" );
- parameters->ConfigureAsPointList( "PointListParam" );
std::vector< std::string > choices;
choices.push_back( "bat" );
parameters->SetUint( "UintParam", 1234567 );
parameters->SetReal( "RealParam", 3.14159244444 );
- idx[ 0 ] = 10; idx[ 1 ] = 20; idx[ 2 ] = 30;
- pnt[ 0 ] = 30.1; pnt[ 1 ] = 21.2; pnt[ 2 ] = 12.3;
- parameters->SetIndex( "IndexParam", 3, idx );
- parameters->SetPoint( "PointParam", 3, pnt );
-
std::cout << "---------------------------------------------" << std::endl;
parameters->Print( std::cout );
std::cout << "---------------------------------------------" << std::endl;
parameters->ClearIntList( "IntListParam" );
parameters->ClearUintList( "UintListParam" );
parameters->ClearRealList( "RealListParam" );
- parameters->ClearIndexList( "IndexListParam" );
- parameters->ClearPointList( "PointListParam" );
parameters->AddToStringList( "StringListParam", "one" );
parameters->AddToStringList( "StringListParam", "two" );
parameters->AddToRealList( "RealListParam", 1.0012 );
parameters->AddToRealList( "RealListParam", 1.131245 );
- idx.Fill( 1 );
- parameters->AddToIndexList( "IndexListParam", 3, idx );
- idx.Fill( 2 );
- parameters->AddToIndexList( "IndexListParam", 3, idx );
- idx.Fill( 3 );
- parameters->AddToIndexList( "IndexListParam", 3, idx );
-
- pnt.Fill( 1.2 );
- parameters->AddToPointList( "PointListParam", 3, pnt );
- pnt.Fill( 3.14 );
- parameters->AddToPointList( "PointListParam", 3, pnt );
- pnt.Fill( 6.28 );
- parameters->AddToPointList( "PointListParam", 3, pnt );
- pnt.Fill( 1.63 );
- parameters->AddToPointList( "PointListParam", 3, pnt );
-
std::cout << "---------------------------------------------" << std::endl;
parameters->Print( std::cout );
std::cout << "---------------------------------------------" << std::endl;
this->_setTypePort( this->m_Filter->GetClassName( ) );\r
\r
// Add input ports\r
- std::set< std::string > inputs;\r
- this->m_Filter->GetInputsNames( inputs );\r
+ auto inputs = this->m_Filter->GetInputsNames( );\r
for( auto iIt = inputs.begin( ); iIt != inputs.end( ); ++iIt )\r
this->addInputPort( iIt->c_str( ) );\r
\r
// Add output ports\r
- std::set< std::string > outputs;\r
- this->m_Filter->GetOutputsNames( outputs );\r
+ auto outputs = this->m_Filter->GetOutputsNames( );\r
for( auto oIt = outputs.begin( ); oIt != outputs.end( ); ++oIt )\r
this->addOutputPort( oIt->c_str( ) );\r
}\r
void cpPipelineEditor::Block::\r
_setTypePort( const QString& txt )\r
{\r
- if( this->m_TypePort == NULL )\r
- this->m_TypePort = new TypePort( this );\r
- this->m_TypePort->setName( txt );\r
- this->_configPort( this->m_TypePort );\r
+ /* TODO\r
+ if( this->m_TypePort == NULL )\r
+ this->m_TypePort = new TypePort( this );\r
+ this->m_TypePort->setName( txt );\r
+ this->_configPort( this->m_TypePort );\r
+ */\r
+ this->setToolTip( txt );\r
}\r
\r
// -------------------------------------------------------------------------\r
\r
// Mark exposed inputs\r
auto& e_in = this->m_Workspace->GetExposedInputPorts( );\r
- std::set< std::string > f_in;\r
- f->GetInputsNames( f_in );\r
+ auto f_in = f->GetInputsNames( );\r
for( auto iIt = f_in.begin( ); iIt != f_in.end( ); ++iIt )\r
{\r
auto eIt = e_in.begin( );\r
\r
// Mark exposed outputs\r
auto& e_out = this->m_Workspace->GetExposedOutputPorts( );\r
- std::set< std::string > f_out;\r
- f->GetOutputsNames( f_out );\r
+ auto f_out = f->GetOutputsNames( );\r
for( auto iIt = f_out.begin( ); iIt != f_out.end( ); ++iIt )\r
{\r
auto eIt = e_out.begin( );\r
+++ /dev/null
-#ifndef __CPPLUGINS__INTERFACE__BASEAPPLICATION__H__
-#define __CPPLUGINS__INTERFACE__BASEAPPLICATION__H__
-
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
-
-namespace cpPlugins
-{
- namespace Interface
- {
- /**
- */
- class cpPlugins_Interface_EXPORT BaseApplication
- {
- public:
- BaseApplication( ) { }
- virtual ~BaseApplication( ) { }
-
- virtual void UpdateActualFilter( ) = 0;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // __CPPLUGINS__INTERFACE__BASEAPPLICATION__H__
-
-// eof - $RCSfile$
+++ /dev/null
-#include <cpPlugins/Interface/BaseMPRWidget.h>
-
-#ifdef cpPlugins_Interface_QT4
-
-#include <cpPlugins/Interface/ui_BaseMPRWidget.h>
-#include <cpPlugins/Interface/DataObject.h>
-#include <cpPlugins/Interface/Image.h>
-#include <cpPlugins/Interface/Mesh.h>
-#include <QTreeWidgetItem>
-#include <vtkRendererCollection.h>
-
-double cpPlugins::Interface::BaseMPRWidget::
-cm_Colors[ 8 ][ 3 ] =
-{
- { 1.0, 0.0, 0.0 },
- { 0.0, 1.0, 0.0 },
- { 0.0, 0.0, 1.0 },
- { 0.0, 1.0, 1.0 },
- { 1.0, 0.0, 1.0 },
- { 1.0, 1.0, 0.0 },
- { 1.0, 0.5, 0.0 },
- { 1.0, 0.0, 0.5 }
-};
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::BaseMPRWidget::
-BaseMPRWidget( QWidget* parent )
- : QWidget( parent ),
- m_UI( new Ui::BaseMPRWidget ),
- m_MainImage( "" )
-{
- this->m_UI->setupUi( this );
-
- // Configure VTK widgets
- this->m_VTK[ 0 ] = this->m_UI->VTK01;
- this->m_VTK[ 1 ] = this->m_UI->VTK00;
- this->m_VTK[ 2 ] = this->m_UI->VTK10;
- this->m_VTK[ 3 ] = this->m_UI->VTK11;
-
- this->m_MPRObjects = vtkSmartPointer< TMPRObjects >::New( );
- this->m_MPRObjects->SetRenderWindows(
- this->m_VTK[ 0 ]->GetRenderWindow( ),
- this->m_VTK[ 1 ]->GetRenderWindow( ),
- this->m_VTK[ 2 ]->GetRenderWindow( ),
- this->m_VTK[ 3 ]->GetRenderWindow( )
- );
-
- // Connect slots
- QObject::connect(
- this->m_UI->TopSplitter, SIGNAL( splitterMoved( int, int ) ),
- this, SLOT( _SyncBottom( int, int ) )
- );
- QObject::connect(
- this->m_UI->BottomSplitter, SIGNAL( splitterMoved( int, int ) ),
- this, SLOT( _SyncTop( int, int ) )
- );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::BaseMPRWidget::
-~BaseMPRWidget( )
-{
- delete this->m_UI;
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::BaseMPRWidget::
-AddData(
- cpPlugins::Interface::DataObject* data, const std::string& name,
- const std::string& parent
- )
-{
- if( name == "" )
- return( false );
-
- auto iIt = this->m_Data.find( name );
- if( iIt == this->m_Data.end( ) )
- {
- if( parent != "" )
- {
- auto pIt = this->m_Data.find( parent );
- if( pIt == this->m_Data.end( ) )
- return( false );
-
- } // fi
-
- // Add new data
- this->m_Data[ name ].SetSourceDataObject( data );
-
- // Add to tree view
- this->_UpdateTreeItem( name, parent );
- return( true );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-const std::string& cpPlugins::Interface::BaseMPRWidget::
-GetMainImage( ) const
-{
- return( this->m_MainImage );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::BaseMPRWidget::
-SetMainImage( const std::string& name )
-{
- auto iIt = this->m_Data.find( name );
- if( iIt != this->m_Data.end( ) )
- {
- if( iIt->second.Tag == Data::IMAGE )
- {
- this->m_MainImage = name;
- return( true );
- }
- else
- return( false );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::
-DeleteData( const std::string& name )
-{
- auto iIt = this->m_Data.find( name );
- if( iIt != this->m_Data.end( ) )
- {
- this->m_Data.erase( iIt );
-
- // Get children
- std::vector< std::string > to_erase;
- auto tIt = this->m_Tree.begin( );
- for( ; tIt != this->m_Tree.end( ); ++tIt )
- if( tIt->second == name )
- to_erase.push_back( tIt->first );
-
- // Delete from tree
- tIt = this->m_Tree.find( name );
- if( tIt != this->m_Tree.end( ) )
- this->m_Tree.erase( tIt );
-
- // Recursive erase
- auto dIt = to_erase.begin( );
- for( ; dIt != to_erase.end( ); ++dIt )
- this->DeleteData( *dIt );
-
- // Delete from tree widget
- QTreeWidgetItem* item = this->_FindItemInTree( name );
- if( item != NULL )
- this->m_UI->LoadedData->removeItemWidget( item, 0 );
-
- // Reset main image, just in case
- if( this->m_Data.size( ) == 0 )
- this->m_MainImage = "";
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::
-DeleteAllData( )
-{
- this->m_MPRObjects->Clear( );
- this->m_Data.clear( );
- this->m_Tree.clear( );
- this->m_UI->LoadedData->clear( );
- this->m_MainImage = "";
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::
-SetDataColor(
- const std::string& name, const double& r, const double& g, const double& b
- )
-{
- /*
- auto iIt = this->m_Data.find( name );
- if( iIt == this->m_Data.end( ) )
- return;
-
- if( iIt->second.Tag == Data::IMAGE )
- {
- }
- else if( iIt->second.Tag == Data::MESH )
- {
- } // fi
- */
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::
-ShowData( const std::string& name )
-{
- auto iIt = this->m_Data.find( name );
- if( iIt == this->m_Data.end( ) )
- return;
-
- if( iIt->second.Tag == Data::IMAGE )
- {
- if( name == this->m_MainImage )
- this->m_MPRObjects->SetInputImage( iIt->second.Image );
- else
- {
- unsigned int i = ( this->m_MPRObjects->GetNumberOfImages( ) - 1 ) % 8;
- this->m_MPRObjects->AddBinaryImage(
- iIt->second.Image,
- Self::cm_Colors[ i ][ 0 ],
- Self::cm_Colors[ i ][ 1 ],
- Self::cm_Colors[ i ][ 2 ]
- );
- }
- this->m_MPRObjects->Show( );
- }
- else if( iIt->second.Tag == Data::MESH )
- {
- /* TODO
- vtkRenderer* ren =
- this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
- if( ren == NULL )
- return;
- ren->AddActor( iIt->second.GetMeshActor( ) );
- this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
- */
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::
-HideData( const std::string& name )
-{
-}
-
-// -------------------------------------------------------------------------
-vtkRenderWindowInteractor* cpPlugins::Interface::BaseMPRWidget::
-GetInteractor( unsigned int i )
-{
- if( i < 4 )
- {
- if( this->m_VTK[ i ] != NULL )
- return( this->m_VTK[ i ]->GetInteractor( ) );
- else
- return( NULL );
- }
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-/*
- bool cpPlugins::Interface::BaseMPRWidget::
- ShowImage(
- vtkImageData* image,
- const std::string& name,
- const std::string& parent
- )
- {
- // Update tree view
- QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
- if( new_item == NULL )
- return( false );
-
- // Associate new data
- this->m_Images[ name ] = image;
- this->m_Tree[ name ] = parent;
-
- // Show image and return
- this->m_MPRObjects->AddImage( image );
- return( true );
- }
-
- // -------------------------------------------------------------------------
- bool cpPlugins::Interface::BaseMPRWidget::
- ShowImage(
- vtkImageData* image,
- const std::string& name,
- const std::string& parent,
- const double& r, const double& g, const double& b
- )
- {
- // Update tree view
- QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
- if( new_item == NULL )
- return( false );
-
- // Associate new data
- this->m_Images[ name ] = image;
- this->m_Tree[ name ] = parent;
-
- // Show image and return
- this->m_MPRObjects->AddImage( image );
- return( true );
- }
-
- // -------------------------------------------------------------------------
- bool cpPlugins::Interface::BaseMPRWidget::
- ShowMesh(
- vtkPolyData* mesh,
- const std::string& name,
- const std::string& parent
- )
- {
- // Update tree view
- QTreeWidgetItem* new_item = this->_UpdateTreeItem( name, parent );
- if( new_item == NULL )
- return( false );
-
- // Associate new data
- PolyDataActor* actor = new PolyDataActor( mesh );
- this->m_Meshes[ name ] = actor;
- this->m_Tree[ name ] = parent;
-
- // Show mesh
- this->_Add3DActor( actor->Actor );
- return( true );
- }
-
- // -------------------------------------------------------------------------
- bool cpPlugins::Interface::BaseMPRWidget::
- ShowMesh(
- vtkPolyData* mesh,
- const std::string& name,
- const std::string& parent,
- const double& r, const double& g, const double& b
- )
- {
- return false;
- }
-
- // -------------------------------------------------------------------------
- void cpPlugins::Interface::BaseMPRWidget::
- ClearAll( )
- {
- this->m_MPRObjects->ClearAll( );
- this->m_Images.clear( );
- this->m_Meshes.clear( );
- }
-*/
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::BaseMPRWidget::
-GetSelectedData( ) const
-{
- QTreeWidgetItem* item = this->m_UI->LoadedData->currentItem( );
- if( item != NULL )
- return( item->text( 0 ).toStdString( ) );
- else
- return( "" );
-}
-
-// -------------------------------------------------------------------------
-QTreeWidgetItem* cpPlugins::Interface::BaseMPRWidget::
-_FindItemInTree( const std::string& name ) const
-{
- QList< QTreeWidgetItem* > items =
- this->m_UI->LoadedData->findItems(
- name.c_str( ), Qt::MatchExactly | Qt::MatchRecursive
- );
- if( items.size( ) > 0 )
- return( items[ 0 ] );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-QTreeWidgetItem* cpPlugins::Interface::BaseMPRWidget::
-_UpdateTreeItem( const std::string& name, const std::string& parent )
-{
- // Update tree view
- QTreeWidgetItem* new_item = NULL;
- if( parent != "" )
- {
- QTreeWidgetItem* parent_item = this->_FindItemInTree( parent );
- if( parent_item != NULL )
- {
- QTreeWidgetItem* old_item = this->_FindItemInTree( name );
- if( old_item == NULL )
- {
- new_item =
- new QTreeWidgetItem( parent_item, QStringList( name.c_str( ) ) );
- parent_item->setExpanded( true );
-
- } // fi
-
- } // fi
- }
- else
- {
- new_item = new QTreeWidgetItem(
- ( QTreeWidgetItem* )( NULL ), QStringList( name.c_str( ) )
- );
- this->m_UI->LoadedData->addTopLevelItem( new_item );
-
- } // fi
- return( new_item );
-}
-
-// -------------------------------------------------------------------------
-/*
- void cpPlugins::Interface::BaseMPRWidget::
- _Add3DActor( vtkProp3D* prop )
- {
- vtkRenderer* ren =
- this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
- if( ren == NULL )
- return;
- ren->AddActor( prop );
- this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
- }
-*/
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::
-_SyncBottom( int a, int b )
-{
- this->m_UI->BottomSplitter->setSizes( this->m_UI->TopSplitter->sizes( ) );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::
-_SyncTop( int a, int b )
-{
- this->m_UI->TopSplitter->setSizes( this->m_UI->BottomSplitter->sizes( ) );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::BaseMPRWidget::PolyDataActor::
-PolyDataActor( )
- : Mesh( NULL ),
- Normals( NULL ),
- Stripper( NULL ),
- Mapper( NULL ),
- Actor( NULL )
-{
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::BaseMPRWidget::PolyDataActor::
-~PolyDataActor( )
-{
- if( this->Actor != NULL ) this->Actor->Delete( );
- if( this->Mapper != NULL ) this->Mapper->Delete( );
- if( this->Stripper != NULL ) this->Stripper->Delete( );
- if( this->Normals != NULL ) this->Normals->Delete( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::PolyDataActor::
-Configure( vtkPolyData* pd )
-{
- if( pd == NULL )
- return;
-
- double range[ 2 ];
- pd->GetScalarRange( range );
-
- this->Normals = vtkPolyDataNormals::New( );
- this->Stripper = vtkStripper::New( );
- this->Mapper = vtkPolyDataMapper::New( );
- this->Actor = vtkQuadricLODActor::New( );
-
- this->Mesh = pd;
- this->Normals->SetInputData( pd );
- this->Normals->SetFeatureAngle( 60.0 );
- this->Stripper->SetInputConnection( this->Normals->GetOutputPort( ) );
- this->Mapper->SetInputConnection( this->Stripper->GetOutputPort( ) );
- this->Mapper->UseLookupTableScalarRangeOff( );
- this->Mapper->SetScalarRange(
- range[ 0 ], ( ( range[ 1 ] - range[ 0 ] ) * 0.75 ) + range[ 0 ]
- );
- this->Actor->SetMapper( this->Mapper );
- this->Actor->DeferLODConstructionOff( );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::BaseMPRWidget::Data::
-Data( )
-{
- this->Tag = Data::IMAGE;
- this->Source = NULL;
- this->Image = NULL;
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::BaseMPRWidget::Data::
-~Data( )
-{
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::BaseMPRWidget::
-Data& cpPlugins::Interface::BaseMPRWidget::Data::
-operator=( const Data& data )
-{
- this->Tag = data.Tag;
- this->Source = data.Source;
- if( this->Tag == Data::IMAGE )
- this->Image = data.Image;
- else if( this->Tag == Data::MESH )
- this->Mesh = data.Mesh;
- return( *this );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::
-DataObject* cpPlugins::Interface::BaseMPRWidget::Data::
-GetSourceDataObject( )
-{
- return( this->Source );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::
-DataObject* cpPlugins::Interface::BaseMPRWidget::Data::
-GetSourceDataObject( ) const
-{
- return( this->Source );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::Data::
-SetSourceDataObject( cpPlugins::Interface::DataObject* dobj )
-{
- typedef cpPlugins::Interface::Image _TImage;
- typedef cpPlugins::Interface::Mesh _TMesh;
-
- this->Source = dobj;
- _TImage* image = dynamic_cast< _TImage* >( dobj );
- if( image != NULL )
- {
- this->Tag = Data::IMAGE;
- this->Image = image->GetVTK< vtkImageData >( );
- }
- else
- {
- _TMesh* mesh = dynamic_cast< _TMesh* >( dobj );
- if( mesh == NULL )
- return;
-
- this->Tag = Data::MESH;
- this->Mesh.Configure( mesh->GetVTK< vtkPolyData >( ) );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-vtkImageData* cpPlugins::Interface::BaseMPRWidget::Data::
-GetImage( )
-{
- if( this->Tag == Data::IMAGE )
- return( this->Image );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-vtkPolyData* cpPlugins::Interface::BaseMPRWidget::Data::
-GetMesh( )
-{
- if( this->Tag == Data::MESH )
- return( this->Mesh.Mesh );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-vtkProp* cpPlugins::Interface::BaseMPRWidget::Data::
-GetMeshActor( )
-{
- if( this->Tag == Data::MESH )
- return( this->Mesh.Actor );
- else
- return( NULL );
-}
-
-#endif // cpPlugins_Interface_QT4
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__
-#define __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__
-
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
-#include <cpPlugins/Interface/Config.h>
-
-#ifdef cpPlugins_Interface_QT4
-
-#include <map>
-#include <string>
-
-#include <QWidget>
-
-#include <vtkSmartPointer.h>
-#include <vtkImageData.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkPolyDataNormals.h>
-#include <vtkQuadricLODActor.h>
-#include <vtkStripper.h>
-
-#include <cpExtensions/Visualization/MPRObjects.h>
-
-// -------------------------------------------------------------------------
-class QTreeWidgetItem;
-class QVTKWidget;
-
-namespace Ui
-{
- class BaseMPRWidget;
-}
-
-// -------------------------------------------------------------------------
-namespace cpPlugins
-{
- namespace Interface
- {
- // Some forward declarations
- class DataObject;
-
- /**
- */
- class cpPlugins_Interface_EXPORT BaseMPRWidget
- : public QWidget
- {
- Q_OBJECT;
-
- public:
- typedef BaseMPRWidget Self;
- typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
-
- typedef TMPRObjects::TStyle TStyle;
- typedef TMPRObjects::TMouseCommand TMouseCommand;
- typedef TMPRObjects::TMouseWheelCommand TMouseWheelCommand;
- typedef TMPRObjects::TKeyCommand TKeyCommand;
- typedef TMPRObjects::TVoidCommand TVoidCommand;
- typedef TMPRObjects::TMouseMoveCommand TMouseMoveCommand;
- typedef TMPRObjects::TMouseClickCommand TMouseClickCommand;
- typedef TMPRObjects::TMouseDoubleClickCommand TMouseDoubleClickCommand;
- typedef TMPRObjects::TExposeCommand TExposeCommand;
- typedef TMPRObjects::TConfigureCommand TConfigureCommand;
- typedef TMPRObjects::TEnterCommand TEnterCommand;
- typedef TMPRObjects::TLeaveCommand TLeaveCommand;
-
- public:
- explicit BaseMPRWidget( QWidget* parent = 0 );
- virtual ~BaseMPRWidget( );
-
- // Data management
- bool AddData(
- DataObject* data, const std::string& name,
- const std::string& parent
- );
- const std::string& GetMainImage( ) const;
- bool SetMainImage( const std::string& name );
- void DeleteData( const std::string& name );
- void DeleteAllData( );
-
- // Some visualization accessors
- void SetDataColor(
- const std::string& name,
- const double& r, const double& g, const double& b
- );
- void ShowData( const std::string& name );
- void HideData( const std::string& name );
-
- vtkRenderWindowInteractor* GetInteractor( unsigned int i );
-
- // Visual objects accessors
- std::string GetSelectedData( ) const;
-
- protected:
- QTreeWidgetItem* _FindItemInTree( const std::string& name ) const;
- QTreeWidgetItem* _UpdateTreeItem(
- const std::string& name,
- const std::string& parent
- );
-
- private slots:
- void _SyncBottom( int a, int b );
- void _SyncTop( int a, int b );
-
- protected:
- static double cm_Colors[ 8 ][ 3 ];
-
- Ui::BaseMPRWidget* m_UI;
- vtkSmartPointer< TMPRObjects > m_MPRObjects;
- QVTKWidget* m_VTK[ 4 ];
-
- struct PolyDataActor
- {
- vtkPolyData* Mesh;
- vtkPolyDataNormals* Normals;
- vtkStripper* Stripper;
- vtkPolyDataMapper* Mapper;
- vtkQuadricLODActor* Actor;
-
- PolyDataActor( );
- virtual ~PolyDataActor( );
- void Configure( vtkPolyData* pd );
- };
-
- struct Data
- {
- enum { IMAGE, MESH } Tag;
- DataObject* Source;
- vtkImageData* Image;
- PolyDataActor Mesh;
-
- Data( );
- virtual ~Data( );
-
- Data& operator=( const Data& data );
-
- DataObject* GetSourceDataObject( );
- const DataObject* GetSourceDataObject( ) const;
- void SetSourceDataObject( DataObject* dobj );
-
- vtkImageData* GetImage( );
- vtkPolyData* GetMesh( );
- vtkProp* GetMeshActor( );
- };
-
- std::string m_MainImage;
- std::map< std::string, Data > m_Data;
- std::map< std::string, std::string > m_Tree;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#endif // cpPlugins_Interface_QT4
-
-#endif // __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__
-
-// eof - $RCSfile$
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>BaseMPRWidget</class>
- <widget class="QWidget" name="BaseMPRWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>580</width>
- <height>424</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QSplitter" name="MainSplitter">
- <property name="minimumSize">
- <size>
- <width>562</width>
- <height>406</height>
- </size>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <widget class="QTreeWidget" name="LoadedData">
- <property name="minimumSize">
- <size>
- <width>150</width>
- <height>406</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>500</width>
- <height>16777215</height>
- </size>
- </property>
- <column>
- <property name="text">
- <string>Data</string>
- </property>
- </column>
- </widget>
- <widget class="QSplitter" name="QuadSplitter">
- <property name="minimumSize">
- <size>
- <width>406</width>
- <height>406</height>
- </size>
- </property>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <widget class="QSplitter" name="TopSplitter">
- <property name="minimumSize">
- <size>
- <width>406</width>
- <height>200</height>
- </size>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <widget class="QVTKWidget" name="VTK00" native="true">
- <property name="minimumSize">
- <size>
- <width>200</width>
- <height>200</height>
- </size>
- </property>
- </widget>
- <widget class="QVTKWidget" name="VTK01" native="true">
- <property name="minimumSize">
- <size>
- <width>200</width>
- <height>200</height>
- </size>
- </property>
- </widget>
- </widget>
- <widget class="QSplitter" name="BottomSplitter">
- <property name="minimumSize">
- <size>
- <width>406</width>
- <height>200</height>
- </size>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <widget class="QVTKWidget" name="VTK10" native="true">
- <property name="minimumSize">
- <size>
- <width>200</width>
- <height>200</height>
- </size>
- </property>
- </widget>
- <widget class="QVTKWidget" name="VTK11" native="true">
- <property name="minimumSize">
- <size>
- <width>200</width>
- <height>200</height>
- </size>
- </property>
- </widget>
- </widget>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <customwidgets>
- <customwidget>
- <class>QVTKWidget</class>
- <extends>QWidget</extends>
- <header location="global">QVTKWidget.h</header>
- <container>1</container>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
IF(USE_QT4)
SET(
LIB_QT_UI
- BaseMPRWidget.ui
SimpleMPRWidget.ui
ParametersListWidget.ui
)
LIB_QT_Headers
ParametersListWidget.h
ParametersQtDialog.h
- BaseMPRWidget.h
SimpleMPRWidget.h
)
SET(
LIB_QT_Sources
ParametersListWidget.cxx
ParametersQtDialog.cxx
- BaseMPRWidget.cxx
SimpleMPRWidget.cxx
)
SET(
cpPlugins::Interface::DataObject::
DataObject( )
: Superclass( ),
- m_ITKObject( NULL ),
- m_VTKObject( NULL ),
m_Source( NULL )
{
}
#include <cpPlugins/Interface/Object.h>
-#include <itkObject.h>
-#include <vtkSmartPointer.h>
-#include <vtkObject.h>
-
namespace cpPlugins
{
namespace Interface
void DisconnectPipeline( );
- template< class T >
- inline T* GetITK( );
-
- template< class T >
- inline const T* GetITK( ) const;
-
- template< class T >
- inline T* GetVTK( );
-
- template< class T >
- inline const T* GetVTK( ) const;
-
protected:
DataObject( );
virtual ~DataObject( );
Self& operator=( const Self& );
protected:
- itk::Object::Pointer m_ITKObject;
- vtkSmartPointer< vtkObject > m_VTKObject;
- ProcessObject* m_Source;
+ ProcessObject* m_Source;
};
} // ecapseman
} // ecapseman
-#include <cpPlugins/Interface/DataObject.hxx>
-
#endif // __CPPLUGINS__INTERFACE__DATAOBJECT__H__
// eof - $RCSfile$
#include <itkProcessObject.h>
-// -------------------------------------------------------------------------
+// Some forward declarations
+class vtkObject;
+
namespace cpPlugins
{
namespace Interface
this->m_VTKObject = NULL;
this->m_ITKvVTKConnection = NULL;
this->Modified( );
+ return;
} // fi
typedef itk::Image< P, D > _I;
typedef itk::ImageToVTKImageFilter< _I > _I2Vtk;
- // Check if input object has the desired type
+ // Check (yes, again!!!) if input object has the desired type
_I* image = dynamic_cast< _I* >( object );
if( image == NULL )
return;
#include <cpPlugins/Interface/ImplicitFunction.h>
+#include <itkSpatialObject.h>
+
+#include <vtkSmartPointer.h>
#include <vtkBox.h>
#include <vtkCone.h>
#include <vtkCylinder.h>
#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
#include <cpPlugins/Interface/DataObject.h>
-#include <itkSpatialObject.h>
-
-#include <vtkSmartPointer.h>
-#include <vtkImplicitFunction.h>
+// Sompe forward declarations
+class vtkImplicitFunction;
namespace cpPlugins
{
#include <cpPlugins/Interface/Interface.h>
+#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cpPlugins/Interface/Config.h>
// -------------------------------------------------------------------------
-#define cpPlugins_Id_Macro( name, category ) \
+#define cpPlugins_Id_Macro( N, C ) \
public: \
- virtual const char* GetClassName( ) const { return( #name ); } \
- virtual const char* GetClassCategory( ) const { return( #category ); }
+ virtual const char* GetClassName( ) const { return( #N ); } \
+ virtual const char* GetClassCategory( ) const { return( #C ); }
// -------------------------------------------------------------------------
#define CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE ) \
#include <cpPlugins/Interface/DataObject.h>
+// Some forward declarations
+class vtkObject;
+
namespace cpPlugins
{
namespace Interface
#include <cpPlugins/Interface/Object.h>
+#include <itkObject.h>
+#include <vtkObject.h>
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Object::
+Modified( ) const
+{
+ const itk::Object* i = this->GetITK< itk::Object >( );
+ vtkObject* v = const_cast< vtkObject* >( this->GetVTK< vtkObject >( ) );
+ if( i != NULL ) i->Modified( );
+ if( v != NULL ) v->Modified( );
+ this->Superclass::Modified( );
+}
+
+// -------------------------------------------------------------------------
+float cpPlugins::Interface::Object::
+SetViewCoords( float x, float y )
+{
+ this->SetViewX( x );
+ this->SetViewY( y );
+}
+
// -------------------------------------------------------------------------
cpPlugins::Interface::Object::
Object( )
: Superclass( ),
+ m_ITKObject( NULL ),
+ m_VTKObject( NULL ),
m_Name( "" ),
m_ViewX( float( 0 ) ),
m_ViewY( float( 0 ) )
#include <cpPlugins/Interface/Macros.h>
#include <string>
+
#include <itkObject.h>
#include <itkObjectFactory.h>
+#include <vtkSmartPointer.h>
+#include <vtkObjectBase.h>
+
namespace cpPlugins
{
namespace Interface
itkSetMacro( ViewY, float );
public:
- inline float SetViewCoords( float x, float y )
- {
- this->SetViewX( x );
- this->SetViewY( y );
- }
+ virtual void Modified( ) const;
+ float SetViewCoords( float x, float y );
+
+ template< class T >
+ inline T* GetITK( );
+
+ template< class T >
+ inline const T* GetITK( ) const;
+
+ template< class T >
+ inline T* GetVTK( );
+
+ template< class T >
+ inline const T* GetVTK( ) const;
protected:
Object( );
Self& operator=( const Self& );
protected:
- std::string m_Name;
- float m_ViewX, m_ViewY;
+ itk::LightObject::Pointer m_ITKObject;
+ vtkSmartPointer< vtkObjectBase > m_VTKObject;
+ std::string m_Name;
+
+ float m_ViewX;
+ float m_ViewY;
};
} // ecapseman
} // ecapseman
+#include <cpPlugins/Interface/Object.hxx>
+
#endif // __CPPLUGINS__INTERFACE__OBJECT__H__
// eof - $RCSfile$
-#ifndef __CPPLUGINS__INTERFACE__DATAOBJECT__HXX__
-#define __CPPLUGINS__INTERFACE__DATAOBJECT__HXX__
+#ifndef __CPPLUGINS__INTERFACE__OBJECT__HXX__
+#define __CPPLUGINS__INTERFACE__OBJECT__HXX__
// -------------------------------------------------------------------------
template< class T >
-T* cpPlugins::Interface::DataObject::
+T* cpPlugins::Interface::Object::
GetITK( )
{
return( dynamic_cast< T* >( this->m_ITKObject.GetPointer( ) ) );
// -------------------------------------------------------------------------
template< class T >
-const T* cpPlugins::Interface::DataObject::
+const T* cpPlugins::Interface::Object::
GetITK( ) const
{
return( dynamic_cast< const T* >( this->m_ITKObject.GetPointer( ) ) );
// -------------------------------------------------------------------------
template< class T >
-T* cpPlugins::Interface::DataObject::
+T* cpPlugins::Interface::Object::
GetVTK( )
{
return( dynamic_cast< T* >( this->m_VTKObject.GetPointer( ) ) );
// -------------------------------------------------------------------------
template< class T >
-const T* cpPlugins::Interface::DataObject::
+const T* cpPlugins::Interface::Object::
GetVTK( ) const
{
return( dynamic_cast< const T* >( this->m_VTKObject.GetPointer( ) ) );
}
-#endif // __CPPLUGINS__INTERFACE__DATAOBJECT__HXX__
+#endif // __CPPLUGINS__INTERFACE__OBJECT__HXX__
// eof - $RCSfile$
// -------------------------------------------------------------------------
void cpPlugins::Interface::Parameters::
-GetNames( std::vector< TString >& container ) const
+GetNames( std::vector< std::string >& container ) const
{
container.clear( );
TParameters::const_iterator i = this->m_Parameters.begin( );
// -------------------------------------------------------------------------
cpPlugins::Interface::Parameters::
Type cpPlugins::Interface::Parameters::
-GetType( const TString& name ) const
+GetType( const std::string& name ) const
{
auto i = this->m_Parameters.find( name );
if( i != this->m_Parameters.end( ) )
return( #Y )
std::string cpPlugins::Interface::Parameters::
-GetTypeAsString( const TString& name ) const
+GetTypeAsString( const std::string& name ) const
{
auto i = this->m_Parameters.find( name );
cpPlugins_Parameters_TypeAsString( String );
else cpPlugins_Parameters_TypeAsString( Int );
else cpPlugins_Parameters_TypeAsString( Uint );
else cpPlugins_Parameters_TypeAsString( Real );
- else cpPlugins_Parameters_TypeAsString( Index );
- else cpPlugins_Parameters_TypeAsString( Point );
- else cpPlugins_Parameters_TypeAsString( Vector );
else cpPlugins_Parameters_TypeAsString( OpenFileName );
else cpPlugins_Parameters_TypeAsString( SaveFileName );
else cpPlugins_Parameters_TypeAsString( PathName );
else cpPlugins_Parameters_TypeAsString( IntList );
else cpPlugins_Parameters_TypeAsString( UintList );
else cpPlugins_Parameters_TypeAsString( RealList );
- else cpPlugins_Parameters_TypeAsString( IndexList );
- else cpPlugins_Parameters_TypeAsString( PointList );
- else cpPlugins_Parameters_TypeAsString( VectorList );
else cpPlugins_Parameters_TypeAsString( OpenFileNameList );
else cpPlugins_Parameters_TypeAsString( SaveFileNameList );
else cpPlugins_Parameters_TypeAsString( PathNameList );
else cpPlugins_Parameters_TypeFromString( Int, t );
else cpPlugins_Parameters_TypeFromString( Uint, t );
else cpPlugins_Parameters_TypeFromString( Real, t );
- else cpPlugins_Parameters_TypeFromString( Index, t );
- else cpPlugins_Parameters_TypeFromString( Point, t );
- else cpPlugins_Parameters_TypeFromString( Vector, t );
else cpPlugins_Parameters_TypeFromString( OpenFileName, t );
else cpPlugins_Parameters_TypeFromString( SaveFileName, t );
else cpPlugins_Parameters_TypeFromString( PathName, t );
else cpPlugins_Parameters_TypeFromString( IntList, t );
else cpPlugins_Parameters_TypeFromString( UintList, t );
else cpPlugins_Parameters_TypeFromString( RealList, t );
- else cpPlugins_Parameters_TypeFromString( IndexList, t );
- else cpPlugins_Parameters_TypeFromString( PointList, t );
- else cpPlugins_Parameters_TypeFromString( VectorList, t );
else cpPlugins_Parameters_TypeFromString( OpenFileNameList, t );
else cpPlugins_Parameters_TypeFromString( SaveFileNameList, t );
else cpPlugins_Parameters_TypeFromString( PathNameList, t );
// -------------------------------------------------------------------------
std::vector< std::string > cpPlugins::Interface::Parameters::
-GetChoices( const TString& name ) const
+GetChoices( const std::string& name ) const
{
std::vector< std::string > choices;
// -------------------------------------------------------------------------
bool cpPlugins::Interface::Parameters::
-SetSelectedChoice( const TString& name, const TString& choice )
+SetSelectedChoice( const std::string& name, const std::string& choice )
{
auto i = this->m_Parameters.find( name );
if( i != this->m_Parameters.end( ) )
{
if( i->second.first == Self::Choices )
{
- std::vector< std::string > c = this->GetChoices( name );
- if( std::find( c.begin( ), c.end( ), choice ) != c.end( ) )
+ std::istringstream str_choices( i->second.second );
+ std::string choices;
+ std::getline( str_choices, choices, '@' );
+ if( choices.find( choice ) != std::string::npos )
{
- std::istringstream str_choices( i->second.second );
- std::string choices;
- std::getline( str_choices, choices, '@' );
std::stringstream new_choices;
new_choices << choices << "@" << choice;
i->second.second = new_choices.str( );
return( false );
}
-// -------------------------------------------------------------------------
-#define cpPlugins_Parameters_ClearList( Y ) \
- void cpPlugins::Interface::Parameters:: \
- Clear##Y##List( const TString& name ) \
- { \
- auto i = this->m_Parameters.find( name ); \
- if( i == this->m_Parameters.end( ) ) \
- return; \
- if( i->second.first != Self::Y##List ) \
- return; \
- i->second.second = ""; \
- this->Modified( ); \
- }
-
-cpPlugins_Parameters_ClearList( Index );
-cpPlugins_Parameters_ClearList( Point );
-cpPlugins_Parameters_ClearList( Vector );
-
// -------------------------------------------------------------------------
bool cpPlugins::Interface::Parameters::
ToXML( TiXmlElement* parent_elem ) const
enum Type
{
String , Bool , Int ,
- Uint , Real , Index ,
- Point , Vector , OpenFileName ,
+ Uint , Real , OpenFileName ,
SaveFileName , PathName , StringList ,
BoolList , IntList , UintList ,
- RealList , IndexList , PointList ,
- VectorList , OpenFileNameList , SaveFileNameList ,
+ RealList , OpenFileNameList , SaveFileNameList ,
PathNameList , Choices , NoType
};
cpPlugins_Parameters_Configure( Int );
cpPlugins_Parameters_Configure( Uint );
cpPlugins_Parameters_Configure( Real );
- cpPlugins_Parameters_Configure( Index );
- cpPlugins_Parameters_Configure( Point );
- cpPlugins_Parameters_Configure( Vector );
cpPlugins_Parameters_Configure( OpenFileName );
cpPlugins_Parameters_Configure( SaveFileName );
cpPlugins_Parameters_Configure( PathName );
cpPlugins_Parameters_Configure( IntList );
cpPlugins_Parameters_Configure( UintList );
cpPlugins_Parameters_Configure( RealList );
- cpPlugins_Parameters_Configure( IndexList );
- cpPlugins_Parameters_Configure( PointList );
- cpPlugins_Parameters_Configure( VectorList );
cpPlugins_Parameters_Configure( OpenFileNameList );
cpPlugins_Parameters_Configure( SaveFileNameList );
cpPlugins_Parameters_Configure( PathNameList );
const std::string& name, const std::string& choice
);
- // Some templated methods
- template< class I >
- I GetIndex(
- const std::string& name, const unsigned int& dim
- ) const;
- template< class P >
- P GetPoint(
- const std::string& name, const unsigned int& dim
- ) const;
- template< class V >
- V GetVector(
- const std::string& name, const unsigned int& dim
- ) const;
-
- template< class I >
- void SetIndex(
- const std::string& name, const unsigned int& dim, const I& v
- );
- template< class P >
- void SetPoint(
- const std::string& name, const unsigned int& dim, const P& v
- );
- template< class V >
- void SetVector(
- const std::string& name, const unsigned int& dim, const V& v
- );
-
- template< class I >
- std::vector< I > GetIndexList(
- const std::string& name, const unsigned int& dim
- ) const;
- template< class P >
- std::vector< P > GetPointList(
- const std::string& name, const unsigned int& dim
- ) const;
- template< class V >
- std::vector< V > GetVectorList(
- const std::string& name, const unsigned int& dim
- ) const;
-
- template< class I >
- void AddToIndexList(
- const std::string& name, const unsigned int& dim, const I& v
- );
- template< class P >
- void AddToPointList(
- const std::string& name, const unsigned int& dim, const P& v
- );
- template< class P >
- void AddToVectorList(
- const std::string& name, const unsigned int& dim, const P& v
- );
-
- void ClearIndexList( const std::string& name );
- void ClearPointList( const std::string& name );
- void ClearVectorList( const std::string& name );
-
// XML "streaming"
bool ToXML( TiXmlElement* parent_elem ) const;
bool FromXML( const TiXmlElement* filter_elem );
} // ecapseman
-#include <cpPlugins/Interface/Parameters.hxx>
-
#endif // __CPPLUGINS__INTERFACE__PARAMETERS__H__
// eof - $RCSfile$
+++ /dev/null
-#ifndef __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
-#define __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
-
-// -------------------------------------------------------------------------
-template< class I >
-I cpPlugins::Interface::Parameters::
-GetIndex( const std::string& name, const unsigned int& dim ) const
-{
- I v;
- auto i = this->m_Parameters.find( name );
- if( i != this->m_Parameters.end( ) )
- {
- if( i->second.first == Self::Index )
- {
- std::istringstream str( i->second.second );
- std::string token;
- unsigned int d = 0;
- while( std::getline( str, token, ';' ) && d < dim )
- {
- v[ d ] = std::atoi( token.c_str( ) );
- d++;
-
- } // elihw
- return( v );
-
- } // fi
-
- } // fi
-
- // If parameter not found
- for( unsigned int d = 0; d < dim; ++d )
- v[ d ] = 0;
- return( v );
-}
-
-// -------------------------------------------------------------------------
-template< class P >
-P cpPlugins::Interface::Parameters::
-GetPoint( const std::string& name, const unsigned int& dim ) const
-{
- P v;
- auto i = this->m_Parameters.find( name );
- if( i != this->m_Parameters.end( ) )
- {
- if( i->second.first == Self::Point )
- {
- std::istringstream str( i->second.second );
- std::string token;
- unsigned int d = 0;
- while( std::getline( str, token, ';' ) && d < dim )
- {
- std::istringstream tok_str( token );
- tok_str >> v[ d ];
- d++;
-
- } // elihw
- return( v );
-
- } // fi
-
- } // fi
-
- // If parameter not found
- for( unsigned int d = 0; d < dim; ++d )
- v[ d ] = float( 0 );
- return( v );
-}
-
-// -------------------------------------------------------------------------
-template< class V >
-V cpPlugins::Interface::Parameters::
-GetVector( const std::string& name, const unsigned int& dim ) const
-{
- V v;
- auto i = this->m_Parameters.find( name );
- if( i != this->m_Parameters.end( ) )
- {
- if( i->second.first == Self::Vector )
- {
- std::istringstream str( i->second.second );
- std::string token;
- unsigned int d = 0;
- while( std::getline( str, token, ';' ) && d < dim )
- {
- std::istringstream tok_str( token );
- tok_str >> v[ d ];
- d++;
-
- } // elihw
- return( v );
-
- } // fi
-
- } // fi
-
- // If parameter not found
- for( unsigned int d = 0; d < dim; ++d )
- v[ d ] = float( 0 );
- return( v );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-SetIndex( const std::string& name, const unsigned int& dim, const I& v )
-{
- TParameters::iterator i = this->m_Parameters.find( name );
- if( i == this->m_Parameters.end( ) )
- return;
- if( i->second.first != Self::Index )
- return;
-
- std::stringstream str;
- str << v[ 0 ];
- for( unsigned int d = 1; d < dim; ++d )
- str << ";" << v[ d ];
- i->second.second = str.str( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class P >
-void cpPlugins::Interface::Parameters::
-SetPoint( const std::string& name, const unsigned int& dim, const P& v )
-{
- TParameters::iterator i = this->m_Parameters.find( name );
- if( i == this->m_Parameters.end( ) )
- return;
- if( i->second.first != Self::Point )
- return;
-
- std::stringstream str;
- str << v[ 0 ];
- for( unsigned int d = 1; d < dim; ++d )
- str << ";" << v[ d ];
- i->second.second = str.str( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class V >
-void cpPlugins::Interface::Parameters::
-SetVector( const std::string& name, const unsigned int& dim, const V& v )
-{
- TParameters::iterator i = this->m_Parameters.find( name );
- if( i == this->m_Parameters.end( ) )
- return;
- if( i->second.first != Self::Vector )
- return;
-
- std::stringstream str;
- str << v[ 0 ];
- for( unsigned int d = 1; d < dim; ++d )
- str << ";" << v[ d ];
- i->second.second = str.str( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-std::vector< I > cpPlugins::Interface::Parameters::
-GetIndexList( const std::string& name, const unsigned int& dim ) const
-{
- std::vector< I > lst;
- auto i = this->m_Parameters.find( name );
- if( i != this->m_Parameters.end( ) )
- {
- if( i->second.first == Self::IndexList )
- {
- std::istringstream str( i->second.second );
- std::string token;
- unsigned int d = 0;
- while( std::getline( str, token, '#' ) )
- {
- std::istringstream str2( token );
- std::string token2;
- unsigned int d = 0;
- I v;
- while( std::getline( str2, token2, ';' ) && d < dim )
- {
- v[ d ] = std::atoi( token.c_str( ) );
- d++;
-
- } // elihw
- lst.push_back( v );
-
- } // elihw
-
- } // fi
-
- } // fi
- return( lst );
-}
-
-// -------------------------------------------------------------------------
-template< class P >
-std::vector< P > cpPlugins::Interface::Parameters::
-GetPointList( const std::string& name, const unsigned int& dim ) const
-{
- std::vector< P > lst;
-
- auto i = this->m_Parameters.find( name );
- if( i != this->m_Parameters.end( ) )
- {
- if( i->second.first == Self::PointList )
- {
- std::istringstream str( i->second.second );
- std::string token;
- unsigned int d = 0;
- while( std::getline( str, token, '#' ) )
- {
- std::istringstream str2( token );
- std::string token2;
- unsigned int d = 0;
- P v;
- while( std::getline( str2, token2, ';' ) && d < dim )
- {
- std::istringstream tok_str( token );
- tok_str >> v[ d ];
- d++;
-
- } // elihw
- lst.push_back( v );
-
- } // elihw
-
- } // fi
-
- } // fi
- return( lst );
-}
-
-// -------------------------------------------------------------------------
-template< class V >
-std::vector< V > cpPlugins::Interface::Parameters::
-GetVectorList( const std::string& name, const unsigned int& dim ) const
-{
- std::vector< V > lst;
-
- auto i = this->m_Parameters.find( name );
- if( i != this->m_Parameters.end( ) )
- {
- if( i->second.first == Self::VectorList )
- {
- std::istringstream str( i->second.second );
- std::string token;
- unsigned int d = 0;
- while( std::getline( str, token, '#' ) )
- {
- std::istringstream str2( token );
- std::string token2;
- unsigned int d = 0;
- V v;
- while( std::getline( str2, token2, ';' ) && d < dim )
- {
- std::istringstream tok_str( token );
- tok_str >> v[ d ];
- d++;
-
- } // elihw
- lst.push_back( v );
-
- } // elihw
-
- } // fi
-
- } // fi
- return( lst );
-}
-
-// -------------------------------------------------------------------------
-template< class I >
-void cpPlugins::Interface::Parameters::
-AddToIndexList( const std::string& name, const unsigned int& dim, const I& v )
-{
- TParameters::iterator i = this->m_Parameters.find( name );
- if( i == this->m_Parameters.end( ) )
- return;
- if( i->second.first != Self::IndexList )
- return;
-
- std::stringstream str;
- if( i->second.second == "" )
- str << v[ 0 ];
- else
- str << "#" << v[ 0 ];
- for( unsigned int d = 1; d < dim; ++d )
- str << ";" << v[ d ];
- i->second.second += str.str( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class P >
-void cpPlugins::Interface::Parameters::
-AddToPointList( const std::string& name, const unsigned int& dim, const P& v )
-{
- TParameters::iterator i = this->m_Parameters.find( name );
- if( i == this->m_Parameters.end( ) )
- return;
- if( i->second.first != Self::PointList )
- return;
-
- std::stringstream str;
- if( i->second.second == "" )
- str << v[ 0 ];
- else
- str << "#" << v[ 0 ];
- for( unsigned int d = 1; d < dim; ++d )
- str << ";" << v[ d ];
- i->second.second += str.str( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class V >
-void cpPlugins::Interface::Parameters::
-AddToVectorList( const std::string& name, const unsigned int& dim, const V& v )
-{
- TParameters::iterator i = this->m_Parameters.find( name );
- if( i == this->m_Parameters.end( ) )
- return;
- if( i->second.first != Self::VectorList )
- return;
-
- std::stringstream str;
- if( i->second.second == "" )
- str << v[ 0 ];
- else
- str << "#" << v[ 0 ];
- for( unsigned int d = 1; d < dim; ++d )
- str << ";" << v[ d ];
- i->second.second += str.str( );
- this->Modified( );
-}
-
-#endif // __CPPLUGINS__INTERFACE__PARAMETERS__HXX__
-
-// eof - $RCSfile$
#include <limits>
#include <cpPlugins/Interface/ParametersListWidget.h>
+#include <cpPlugins/Interface/ProcessObject.h>
#include <vtkCommand.h>
#include <vtkRenderWindowInteractor.h>
#include <QPushButton>
#include <QWidget>
-// -------------------------------------------------------------------------
-#include <cpPlugins/Interface/ProcessObject.h>
-#include <cpPlugins/Interface/Plugins.h>
-#include <cpPlugins/Interface/BaseApplication.h>
-
/* TODO
class SingleSeedCommand
: public vtkCommand
w_input = v_double;
}
break;
- case Parameters::Index:
- break;
- case Parameters::Point:
- break;
- case Parameters::Vector:
- break;
case Parameters::OpenFileName:
{
QFrame* frame = new QFrame( this );
w_input = frame;
}
break;
- case Parameters::IndexList:
- break;
- case Parameters::PointList:
- break;
- case Parameters::VectorList:
- break;
case Parameters::OpenFileNameList:
{
QFrame* frame = new QFrame( this );
} // fi
}
break;
- case Parameters::Index:
- break;
- case Parameters::Point:
- break;
- case Parameters::Vector:
- break;
case Parameters::StringList:
break;
case Parameters::BoolList:
break;
- case Parameters::IndexList:
- break;
- case Parameters::PointList:
- break;
- case Parameters::VectorList:
- break;
case Parameters::SaveFileNameList:
break;
case Parameters::PathNameList:
} // fi
}
break;
- case Parameters::Index:
- break;
- case Parameters::Point:
- break;
- case Parameters::Vector:
- break;
case Parameters::StringList:
break;
case Parameters::BoolList:
break;
- case Parameters::IndexList:
- break;
- case Parameters::PointList:
- break;
- case Parameters::VectorList:
- break;
case Parameters::SaveFileNameList:
break;
case Parameters::PathNameList:
+++ /dev/null
-#include <cpPlugins/Interface/Plugins.h>
-
-#include <stdexcept>
-
-#include <cpPlugins/Interface/Image.h>
-#include <cpPlugins/Interface/Mesh.h>
-
-#ifdef cpPlugins_Interface_QT4
-
-#include <QApplication>
-#include <QFileDialog>
-#include <QMessageBox>
-#include <QWidget>
-
-#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
-
-#endif // cpPlugins_Interface_QT4
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::Plugins::
-Plugins( )
- : m_Widget( NULL ),
- m_Application( NULL ),
- m_LastLoadedPlugin( "" ),
- m_ActiveFilter( NULL )
-{
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::Plugins::
-~Plugins( )
-{
-}
-
-// -------------------------------------------------------------------------
-QWidget* cpPlugins::Interface::Plugins::
-GetWidget( )
-{
- return( this->m_Widget );
-}
-
-// -------------------------------------------------------------------------
-const QWidget* cpPlugins::Interface::Plugins::
-GetWidget( ) const
-{
- return( this->m_Widget );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-SetWidget( QWidget* widget )
-{
- this->m_Widget = widget;
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-BlockWidget( )
-{
-#ifdef cpPlugins_Interface_QT4
- if( this->m_Widget != NULL )
- {
- QApplication::setOverrideCursor( Qt::WaitCursor );
- this->m_Widget->setEnabled( false );
-
- } // fi
-#endif // cpPlugins_Interface_QT4
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-UnblockWidget( )
-{
-#ifdef cpPlugins_Interface_QT4
- if( this->m_Widget != NULL )
- {
- QApplication::restoreOverrideCursor( );
- this->m_Widget->setEnabled( true );
-
- } // fi
-#endif // cpPlugins_Interface_QT4
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-DialogLoadPlugins( )
-{
-#ifdef cpPlugins_Interface_QT4
- if( this->m_Widget != NULL )
- {
- QFileDialog dialog( this->m_Widget );
- dialog.setFileMode( QFileDialog::ExistingFile );
- dialog.setDirectory( this->m_LastLoadedPlugin.c_str( ) );
- dialog.setNameFilter( QFileDialog::tr( PLUGIN_REGEX ) );
- dialog.setDefaultSuffix( QFileDialog::tr( PLUGIN_EXT ) );
- if( !( dialog.exec( ) ) )
- return;
-
- std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
- if( !( this->LoadPlugins( fname ) ) )
- QMessageBox::critical(
- this->m_Widget,
- QMessageBox::tr( "Ignoring plugin" ),
- QMessageBox::tr( fname.c_str( ) )
- );
-
- } // fi
-#endif // cpPlugins_Interface_QT4
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::
-BaseApplication* cpPlugins::Interface::Plugins::
-GetApplication( )
-{
- return( this->m_Application );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::
-BaseApplication* cpPlugins::Interface::Plugins::
-GetApplication( ) const
-{
- return( this->m_Application );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-SetApplication( BaseApplication* a )
-{
- this->m_Application = a;
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-LoadPluginsPath( const std::string& path, bool r )
-{
- /* TODO
- this->BlockWidget( );
-
- // Load all plugins from given folder
- std::list< std::string > files =
- this->m_Interface.LoadFromFolder( path, r );
-
- // Update a simple track
- bool ret = false;
- if( files.size( ) > 0 )
- {
- for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt )
- {
- this->m_LoadedPlugins.insert( *fIt );
- this->m_LastLoadedPlugin = *fIt;
- ret = true;
-
- } // rof
- this->_UpdateLoadedPluginsInformation( );
-
- } // fi
-
- this->UnblockWidget( );
- return( ret );
- */
- return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-LoadPlugins( const std::string& fname )
-{
- this->BlockWidget( );
-
- // Is it already loaded?
- bool ret = true;
- if( this->m_LoadedPlugins.find( fname ) == this->m_LoadedPlugins.end( ) )
- {
- // Was it succesfully loaded?
- ret = this->m_Interface.Load( fname );
-
- // Update a simple track
- if( ret )
- {
- this->m_LoadedPlugins.insert( fname );
- this->m_LastLoadedPlugin = fname;
- this->_UpdateLoadedPluginsInformation( );
-
- } // fi
-
- } // fi
-
- this->UnblockWidget( );
- return( ret );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-LoadPluginsConfigurationFile( const std::string& fname )
-{
- // Load file into a char buffer
- std::ifstream in(
- fname.c_str( ), std::ios::in | std::ios::binary | std::ios::ate
- );
- if( !in.is_open( ) )
- return( false );
-
- 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 );
- char line[ 4096 ];
- while( in_stream )
- {
- in_stream.getline( line, 4096 );
- this->LoadPlugins( line );
-
- } // elihw
- delete buffer;
-
- return( true );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::Plugins::
-TStringContainer& cpPlugins::Interface::Plugins::
-GetLoadedPlugins( ) const
-{
- return( this->m_LoadedPlugins );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetLoadedCategories( TStringContainer& categories ) const
-{
- categories.clear( );
- auto fIt = this->m_LoadedFilters.begin( );
- for( ; fIt != this->m_LoadedFilters.end( ); ++fIt )
- categories.insert( fIt->first );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetLoadedFilters( TStringContainer& filters ) const
-{
- filters.clear( );
- auto pIt = this->m_LoadedFilters.begin( );
- for( ; pIt != this->m_LoadedFilters.end( ); ++pIt )
- for( auto fIt = pIt->second.begin( ); fIt != pIt->second.end( ); ++fIt )
- filters.insert( *fIt );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::Plugins::
-TStringContainer& cpPlugins::Interface::Plugins::
-GetLoadedFilters( const std::string& category ) const
-{
- static const TStringContainer EMPTY;
- auto pIt = this->m_LoadedFilters.find( category );
- if( pIt != this->m_LoadedFilters.end( ) )
- return( pIt->second );
- else
- return( EMPTY );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-AddInteractor( vtkRenderWindowInteractor* interactor )
-{
- this->m_Interactors.insert( interactor );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-RemoveInteractor( vtkRenderWindowInteractor* interactor )
-{
- this->m_Interactors.erase( interactor );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-ClearInteractors( )
-{
- this->m_Interactors.clear( );
-}
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Plugins_HasMacro( F ) \
- bool cpPlugins::Interface::Plugins:: \
- Has##F( ) const \
- { \
- return( this->m_IOFilters.find( #F ) != this->m_IOFilters.end( ) ); \
- }
-
-cpPlugins_Plugins_HasMacro( ImageReader );
-cpPlugins_Plugins_HasMacro( DicomSeriesReader );
-cpPlugins_Plugins_HasMacro( MeshReader );
-cpPlugins_Plugins_HasMacro( ImageWriter );
-cpPlugins_Plugins_HasMacro( MeshWriter );
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadImage( const std::string& fname, const std::string& parent )
-{
- std::vector< std::string > fnames( 1, fname );
- return( this->ReadImage( fnames, parent ) );
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadImage(
- const std::vector< std::string >& fnames, const std::string& parent
- )
-{
- // Load source
- this->_ActivateIOFilter( "ImageReader" );
-
- // Configure reader
- TParameters* params = this->GetActiveFilterParameters( );
- params->ClearStringList( "FileNames" );
- for( auto nIt = fnames.begin( ); nIt != fnames.end( ); ++nIt )
- params->AddToStringList( "FileNames", *nIt );
-
- // Execute filter
- return( this->_ReadData( parent ) );
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadImage( const std::string& parent )
-{
- // Load source
- this->_ActivateIOFilter( "ImageReader" );
-
- // Try to configure source
- if( !( this->ConfigureActiveFilter( ) ) )
- {
- this->DeactivateFilter( );
- return( "" );
-
- } // fi
-
- // Execute filter
- return( this->_ReadData( parent ) );
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadDicomSeries( const std::string& parent )
-{
- // Load source
- this->_ActivateIOFilter( "DicomSeriesReader" );
-
- // Try to configure source
- if( !( this->ConfigureActiveFilter( ) ) )
- {
- this->DeactivateFilter( );
- return( "" );
-
- } // fi
-
- // Execute filter
- return( this->_ReadData( parent ) );
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadMesh( const std::string& fname, const std::string& parent )
-{
- // Load source
- this->_ActivateIOFilter( "MeshReader" );
-
- // Configure reader
- TParameters* params = this->GetActiveFilterParameters( );
- params->SetString( "FileName", fname );
-
- // Execute filter
- return( this->_ReadData( parent ) );
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-ReadMesh( const std::string& parent )
-{
- // Load source
- this->_ActivateIOFilter( "MeshReader" );
-
- // Try to configure source
- if( !( this->ConfigureActiveFilter( ) ) )
- {
- this->DeactivateFilter( );
- return( "" );
-
- } // fi
-
- // Execute filter
- return( this->_ReadData( parent ) );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-WriteDataObject( const std::string& fname, const std::string& name )
-{
- typedef cpPlugins::Interface::Image _TImage;
- typedef cpPlugins::Interface::Mesh _TMesh;
-
- // Activate sink
- TDataObject* obj = this->GetData< TDataObject >( name );
- if( dynamic_cast< cpPlugins::Interface::Image* >( obj ) != NULL )
- this->_ActivateIOFilter( "ImageWriter" );
- else if( dynamic_cast< cpPlugins::Interface::Mesh* >( obj ) != NULL )
- this->_ActivateIOFilter( "MeshWriter" );
- else
- {
- this->DeactivateFilter( );
- return( false );
-
- } // fi
-
- // Configure writer
- TParameters* params = this->GetActiveFilterParameters( );
- params->SetString( "FileName", fname );
-
- // Execute filter
- return( this->_WriteData( name ) );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-WriteDataObject( const std::string& name )
-{
- typedef cpPlugins::Interface::Image _TImage;
- typedef cpPlugins::Interface::Mesh _TMesh;
-
- // Activate sink
- TDataObject* obj = this->GetData< TDataObject >( name );
- if( dynamic_cast< cpPlugins::Interface::Image* >( obj ) != NULL )
- this->_ActivateIOFilter( "ImageWriter" );
- else if( dynamic_cast< cpPlugins::Interface::Mesh* >( obj ) != NULL )
- this->_ActivateIOFilter( "MeshWriter" );
- else
- {
- this->DeactivateFilter( );
- return( false );
-
- } // fi
-
- // Try to configure source
- if( !( this->ConfigureActiveFilter( ) ) )
- {
- this->DeactivateFilter( );
- return( false );
-
- } // fi
-
- // Execute filter
- return( this->_WriteData( name ) );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-ClearDataObjects( )
-{
- this->m_DataObjects.clear( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-DeleteDataObject( const std::string& name )
-{
- // Find and delete object
- auto oIt = this->m_DataObjects.find( name );
- if( oIt == this->m_DataObjects.end( ) )
- return;
- this->m_DataObjects.erase( oIt );
-
- // Delete children
- TStringContainer children;
- this->GetChildren( children, name );
- auto cIt = children.begin( );
- for( ; cIt != children.end( ); ++cIt )
- this->DeleteDataObject( *cIt );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetDataObjects( TStringContainer& names )
-{
- names.clear( );
- auto oIt = this->m_DataObjects.begin( );
- for( ; oIt != this->m_DataObjects.end( ); ++oIt )
- names.insert( oIt->first );
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-GetParent( const std::string& name ) const
-{
- // Find and delete object
- auto oIt = this->m_DataObjects.find( name );
- if( oIt != this->m_DataObjects.end( ) )
- return( oIt->second.first );
- else
- return( "" );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetChildren( TStringContainer& names, const std::string& name ) const
-{
- names.clear( );
- auto oIt = this->m_DataObjects.begin( );
- for( ; oIt != this->m_DataObjects.end( ); ++oIt )
- if( oIt->second.first == name )
- names.insert( oIt->first );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetRoots( TStringContainer& names ) const
-{
- this->GetChildren( names, "" );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-ActivateFilter( const std::string& name )
-{
- this->m_ActiveFilter = this->m_Interface.CreateObject( name );
- if( this->m_ActiveFilter.IsNotNull( ) )
- {
- this->m_ActiveFilter->SetPlugins( this );
- auto iIt = this->m_Interactors.begin( );
- for( ; iIt != this->m_Interactors.end( ); ++iIt )
- this->m_ActiveFilter->AddInteractor( *iIt );
- return( true );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-DeactivateFilter( )
-{
- if( this->m_ActiveFilter.IsNotNull( ) )
- this->m_ActiveFilter->DisconnectOutputs( );
- this->m_ActiveFilter = NULL;
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-HasActiveFilter( ) const
-{
- return( this->m_ActiveFilter.IsNotNull( ) );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-IsActiveFilterInteractive( ) const
-{
- if( this->m_ActiveFilter.IsNotNull( ) )
- return( this->m_ActiveFilter->GetInteractive( ) );
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetActiveFilterInputsNames( TStringContainer& names ) const
-{
- if( this->m_ActiveFilter.IsNotNull( ) )
- this->m_ActiveFilter->GetInputsNames( names );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-GetActiveFilterOutputsNames( TStringContainer& names ) const
-{
- if( this->m_ActiveFilter.IsNotNull( ) )
- this->m_ActiveFilter->GetOutputsNames( names );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-ConnectInputInActiveFilter(
- const std::string& object_name, const std::string& input_name
- )
-{
- if( this->m_ActiveFilter.IsNotNull( ) )
- {
- TDataObject* dobj = this->GetData< TDataObject >( object_name );
- if( dobj != NULL )
- {
- this->m_ActiveFilter->SetInput( input_name, dobj );
- return( true );
-
- } // fi
-
- } // fi
- return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-SetOutputNameInActiveFilter(
- const std::string& new_object_name, const std::string& output_name
- )
-{
- if( this->m_ActiveFilter.IsNotNull( ) )
- return(
- this->m_ActiveFilter->SetOutputObjectName(
- new_object_name, output_name
- )
- );
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::Plugins::
-TParameters* cpPlugins::Interface::Plugins::
-GetActiveFilterParameters( )
-{
- if( this->m_ActiveFilter.IsNotNull( ) )
- return( this->m_ActiveFilter->GetParameters( ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::Plugins::
-TParameters* cpPlugins::Interface::Plugins::
-GetActiveFilterParameters( ) const
-{
- if( this->m_ActiveFilter.IsNotNull( ) )
- return( this->m_ActiveFilter->GetParameters( ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::Plugins::
-TProcessObject::DialogResult cpPlugins::Interface::Plugins::
-ConfigureActiveFilter( )
-{
- if( this->m_ActiveFilter.IsNotNull( ) )
- return( this->m_ActiveFilter->ExecConfigurationDialog( this->m_Widget ) );
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-UpdateActiveFilter( TStringContainer& outputs, const std::string& parent )
-{
- if( this->m_ActiveFilter.IsNull( ) )
- return( false );
-
- // Execute filter
- this->BlockWidget( );
- std::string err = this->m_ActiveFilter->Update( );
- this->UnblockWidget( );
-
- // Associate outputs
- outputs.clear( );
- if( err == "" )
- {
- std::set< std::string > names;
- this->m_ActiveFilter->GetOutputsNames( names );
- for( auto oIt = names.begin( ); oIt != names.end( ); ++oIt )
- {
- TDataObject* dobj =
- this->m_ActiveFilter->GetOutput< TDataObject >( *oIt );
-
- if( std::string( dobj->GetName( ) ) == std::string( "" ) )
- dobj->SetName(
- this->m_ActiveFilter->GetName( ) + std::string( "_" ) + *oIt
- );
- this->_InsertNewData( dobj, parent );
- outputs.insert( dobj->GetName( ) );
-
- } // rof
- // this->m_ActiveFilter->DisconnectOutputs( );
- return( true );
- }
- else
- {
-#ifdef cpPlugins_Interface_QT4
- if( this->m_Widget != NULL )
- QMessageBox::critical(
- this->m_Widget,
- QMessageBox::tr( "Error reading image." ),
- QMessageBox::tr( err.c_str( ) )
- );
- else
- throw std::runtime_error(
- std::string( "Error reading image: " ) + err
- );
-#else // cpPlugins_Interface_QT4
- throw std::runtime_error(
- std::string( "Error reading image: " ) + err
- );
-#endif // cpPlugins_Interface_QT4
- return( false );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::Plugins::
-_UpdateLoadedPluginsInformation( )
-{
- this->m_LoadedFilters.clear( );
- const TInterface::TClasses& cls = this->m_Interface.GetClasses( );
- for( auto i = cls.begin( ); i != cls.end( ); ++i )
- {
- TProcessObject::Pointer o = this->m_Interface.CreateObject( i->first );
- std::string name = o->GetClassName( );
- std::string category = o->GetClassCategory( );
-
- if(
- category == "ImageReader" ||
- category == "ImageWriter" ||
- category == "MeshReader" ||
- category == "MeshWriter" ||
- category == "DicomSeriesReader"
- )
- this->m_IOFilters[ category ] = o;
- else
- this->m_LoadedFilters[ category ].insert( name );
-
- } // rof
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-_ActivateIOFilter( const std::string& filter )
-{
- // Activate reader
- auto fIt = this->m_IOFilters.find( filter );
- if( fIt != this->m_IOFilters.end( ) )
- {
- this->m_ActiveFilter = fIt->second;
- return( true );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::Plugins::
-_ReadData( const std::string& parent )
-{
- if( !( this->HasActiveFilter( ) ) )
- return( "" );
-
- TStringContainer outputs;
- if( this->UpdateActiveFilter( outputs, parent ) )
- return( *( outputs.begin( ) ) );
- else
- return( "" );
-}
-
-// ------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-_WriteData( const std::string& name )
-{
- if( !( this->HasActiveFilter( ) ) )
- return( false );
-
- TStringContainer inputs;
- this->GetActiveFilterInputsNames( inputs );
- bool r = true;
- for( auto iIt = inputs.begin( ); iIt != inputs.end( ); ++iIt )
- r &= this->ConnectInputInActiveFilter( name, *iIt );
-
- if( r )
- {
- TStringContainer outputs;
- return( this->UpdateActiveFilter( outputs, "" ) );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::Plugins::
-_InsertNewData( TDataObject* dobj, const std::string& parent )
-{
- if( parent != "" )
- {
- auto oIt = this->m_DataObjects.find( parent );
- if( oIt == this->m_DataObjects.end( ) )
- return( false );
-
- } // fi
- this->m_DataObjects[ dobj->GetName( ) ] = _TTreeNode( parent, dobj );
- return( true );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __CPPLUGINS__INTERFACE__PLUGINS__H__
-#define __CPPLUGINS__INTERFACE__PLUGINS__H__
-
-#include <cpPlugins/Interface/Interface.h>
-#include <cpPlugins/Interface/DataObject.h>
-#include <cpPlugins/Interface/ProcessObject.h>
-
-#include <map>
-#include <set>
-#include <string>
-#include <vector>
-
-// Some forward declarations
-class vtkRenderWindowInteractor;
-#ifdef cpPlugins_Interface_QT4
-class QWidget;
-#else
-typedef char QWidget;
-#endif // cpPlugins_Interface_QT4
-
-namespace cpPlugins
-{
- namespace Interface
- {
- // Some forward declarations
- class BaseApplication;
-
- /**
- */
- class cpPlugins_Interface_EXPORT Plugins
- {
- public:
- typedef cpPlugins::Interface::Interface TInterface;
- typedef cpPlugins::Interface::ProcessObject TProcessObject;
- typedef cpPlugins::Interface::DataObject TDataObject;
- typedef TProcessObject::TParameters TParameters;
-
- typedef std::set< std::string > TStringContainer;
-
- public:
- Plugins( );
- virtual ~Plugins( );
-
- // Qt oriented methods
- QWidget* GetWidget( );
- const QWidget* GetWidget( ) const;
- void SetWidget( QWidget* widget );
- void BlockWidget( );
- void UnblockWidget( );
- void DialogLoadPlugins( );
-
- // Connection to main application
- BaseApplication* GetApplication( );
- const BaseApplication* GetApplication( ) const;
- void SetApplication( BaseApplication* a );
-
- // Plugins management
- bool LoadPluginsPath( const std::string& path, bool r = false );
- bool LoadPlugins( const std::string& fname );
- bool LoadPluginsConfigurationFile( const std::string& fname );
- const TStringContainer& GetLoadedPlugins( ) const;
- void GetLoadedCategories( TStringContainer& categories ) const;
- void GetLoadedFilters( TStringContainer& filters ) const;
- const TStringContainer& GetLoadedFilters(
- const std::string& category
- ) const;
-
- // Interactors
- void AddInteractor( vtkRenderWindowInteractor* interactor );
- void RemoveInteractor( vtkRenderWindowInteractor* interactor );
- void ClearInteractors( );
-
- // Data IO
- bool HasImageReader( ) const;
- bool HasDicomSeriesReader( ) const;
- bool HasMeshReader( ) const;
- bool HasImageWriter( ) const;
- bool HasMeshWriter( ) const;
-
- std::string ReadImage(
- const std::string& fname, const std::string& parent
- );
- std::string ReadImage(
- const std::vector< std::string >& fnames, const std::string& parent
- );
- std::string ReadImage( const std::string& parent );
- std::string ReadDicomSeries( const std::string& parent );
- std::string ReadMesh(
- const std::string& fname, const std::string& parent
- );
- std::string ReadMesh( const std::string& parent );
-
- bool WriteDataObject(
- const std::string& fname, const std::string& name
- );
- bool WriteDataObject( const std::string& name );
-
- // Data objects
- void ClearDataObjects( );
- void DeleteDataObject( const std::string& name );
- void GetDataObjects( TStringContainer& names );
- std::string GetParent( const std::string& name ) const;
- void GetChildren(
- TStringContainer& names, const std::string& name
- ) const;
- void GetRoots( TStringContainer& names ) const;
-
- template< class T >
- inline T* GetData( const std::string& name );
-
- template< class T >
- inline const T* GetData( const std::string& name ) const;
-
- // Filter acces
- bool ActivateFilter( const std::string& name );
- void DeactivateFilter( );
- bool HasActiveFilter( ) const;
- bool IsActiveFilterInteractive( ) const;
- void GetActiveFilterInputsNames( TStringContainer& names ) const;
- void GetActiveFilterOutputsNames( TStringContainer& names ) const;
- bool ConnectInputInActiveFilter(
- const std::string& object_name, const std::string& input_name
- );
- bool SetOutputNameInActiveFilter(
- const std::string& new_object_name, const std::string& output_name
- );
- TParameters* GetActiveFilterParameters( );
- const TParameters* GetActiveFilterParameters( ) const;
- TProcessObject::DialogResult ConfigureActiveFilter( );
- bool UpdateActiveFilter(
- TStringContainer& outputs,
- const std::string& parent
- );
-
- protected:
- void _UpdateLoadedPluginsInformation( );
- bool _ActivateIOFilter( const std::string& filter );
- std::string _ReadData( const std::string& parent );
- bool _WriteData( const std::string& name );
- bool _InsertNewData( TDataObject* dobj, const std::string& parent );
-
- protected:
- // MVC objects
- QWidget* m_Widget;
- BaseApplication* m_Application;
-
- // Plugins interface
- TInterface m_Interface;
- TStringContainer m_LoadedPlugins;
- std::string m_LastLoadedPlugin;
- std::map< std::string, TStringContainer > m_LoadedFilters;
-
- // Loaded filters
- std::map< std::string, TProcessObject::Pointer > m_IOFilters;
- TProcessObject::Pointer m_ActiveFilter;
-
- // Loaded data objects
- typedef std::pair< std::string, TDataObject::Pointer > _TTreeNode;
- std::map< std::string, _TTreeNode > m_DataObjects;
-
- // Associated interactors
- std::set< vtkRenderWindowInteractor* > m_Interactors;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#include <cpPlugins/Interface/Plugins.hxx>
-
-#endif // __CPPLUGINS__INTERFACE__PLUGINS__H__
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __CPPLUGINS__INTERFACE__PLUGINS__HXX__
-#define __CPPLUGINS__INTERFACE__PLUGINS__HXX__
-
-// -------------------------------------------------------------------------
-template< class T >
-T* cpPlugins::Interface::Plugins::
-GetData( const std::string& name )
-{
- auto dIt = this->m_DataObjects.find( name );
- if( dIt != this->m_DataObjects.end( ) )
- return( dynamic_cast< T* >( dIt->second.second.GetPointer( ) ) );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-template< class T >
-const T* cpPlugins::Interface::Plugins::
-GetData( const std::string& name ) const
-{
- auto dIt = this->m_DataObjects.find( name );
- if( dIt != this->m_DataObjects.end( ) )
- return( dynamic_cast< const T* >( dIt->second.second.GetPointer( ) ) );
- else
- return( NULL );
-}
-
-#endif // __CPPLUGINS__INTERFACE__PLUGINS__HXX__
-
-// eof - $RCSfile$
#include <vtkRenderWindowInteractor.h>
// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-Modified( ) const
-{
- if( this->m_ITKObject.IsNotNull( ) )
- this->m_ITKObject->Modified( );
- if( this->m_VTKObject.GetPointer( ) != NULL )
- this->m_VTKObject->Modified( );
- this->Superclass::Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-GetInputsNames( std::set< std::string >& names ) const
+std::set< std::string > cpPlugins::Interface::ProcessObject::
+GetInputsNames( ) const
{
- names.clear( );
+ std::set< std::string > names;
auto dIt = this->m_Inputs.begin( );
for( ; dIt != this->m_Inputs.end( ); ++dIt )
names.insert( dIt->first );
+ return( names );
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-GetOutputsNames( std::set< std::string >& names ) const
+std::set< std::string > cpPlugins::Interface::ProcessObject::
+GetOutputsNames( ) const
{
- names.clear( );
+ std::set< std::string > names;
auto dIt = this->m_Outputs.begin( );
for( ; dIt != this->m_Outputs.end( ); ++dIt )
names.insert( dIt->first );
+ return( names );
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
bool cpPlugins::Interface::ProcessObject::
-SetOutputObjectName(
- const std::string& new_object_name, const std::string& output_name
- )
-{
- auto oIt = this->m_Outputs.find( output_name );
- if( oIt != this->m_Outputs.end( ) )
- {
- this->m_OutputObjectsNames[ output_name ] = new_object_name;
- this->Modified( );
- return( true );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
SetInput( const std::string& id, cpPlugins::Interface::DataObject* dobj )
{
_TDataContainer::iterator i = this->m_Inputs.find( id );
{
i->second = dobj;
this->Modified( );
-
- } // fi
+ return( true );
+ }
+ else
+ return( false );
}
// -------------------------------------------------------------------------
if( r == "" )
r = this->_GenerateData( );
- // Configure output names
- auto oIt = this->m_Outputs.begin( );
- for( ; oIt != this->m_Outputs.end( ); ++oIt )
- {
- auto nIt = this->m_OutputObjectsNames.find( oIt->first );
- if( nIt != this->m_OutputObjectsNames.end( ) )
- oIt->second->SetName( nIt->second );
-
- } // rof
-
// Return error description, if any
return( r );
}
void cpPlugins::Interface::ProcessObject::
AddInteractor( vtkRenderWindowInteractor* interactor )
{
+ this->m_Interactors.insert( interactor );
#ifdef cpPlugins_Interface_QT4
- if( this->m_ParametersDialog == NULL )
- this->m_ParametersDialog = new ParametersQtDialog( );
this->m_ParametersDialog->addInteractor( interactor );
#endif // cpPlugins_Interface_QT4
- this->m_Interactors.insert( interactor );
}
// -------------------------------------------------------------------------
ExecConfigurationDialog( QWidget* parent )
{
bool r = false;
-
#ifdef cpPlugins_Interface_QT4
-
- if( QApplication::instance( ) != NULL )
+ if( this->m_ParametersDialog != NULL )
{
- if( this->m_ParametersDialog == NULL )
- this->m_ParametersDialog = new ParametersQtDialog( );
- /* TODO
- this->m_ParametersDialog->setTitle(
- this->GetClassName( ) + std::string( " basic configuration" )
- );
- */
-
this->m_ParametersDialog->setParent( NULL );
this->m_ParametersDialog->setParameters( this->m_Parameters );
-
r = ( this->m_ParametersDialog->exec( ) == 1 );
}
else
r = false;
-
#endif // cpPlugins_Interface_QT4
-
return( r );
}
cpPlugins::Interface::ProcessObject::
ProcessObject( )
: Superclass( ),
- m_ITKObject( NULL ),
- m_VTKObject( NULL ),
- m_ParametersDialog( NULL ),
- m_Plugins( NULL )
+ m_ParametersDialog( NULL )
{
this->m_Parameters = TParameters::New( );
this->m_Parameters->SetProcessObject( this );
+
+#ifdef cpPlugins_Interface_QT4
+ if( QApplication::instance( ) != NULL )
+ this->m_ParametersDialog = new ParametersQtDialog( );
+#endif // cpPlugins_Interface_QT4
}
// -------------------------------------------------------------------------
cpPlugins::Interface::ProcessObject::
~ProcessObject( )
{
+#ifdef cpPlugins_Interface_QT4
if( this->m_ParametersDialog != NULL )
delete this->m_ParametersDialog;
+#endif // cpPlugins_Interface_QT4
}
// -------------------------------------------------------------------------
#include <set>
+#include <itkDataObject.h>
+
#include <cpPlugins/Interface/DataObject.h>
#include <cpPlugins/Interface/Parameters.h>
-#include <itkProcessObject.h>
-#include <vtkSmartPointer.h>
-#include <vtkAlgorithm.h>
-
// Some forward declarations
class vtkRenderWindowInteractor;
#ifdef cpPlugins_Interface_QT4
namespace Interface
{
// Some forward declarations
- class Plugins;
#ifdef cpPlugins_Interface_QT4
class ParametersQtDialog;
#else
cpPlugins_Id_Macro( ProcessObject, BaseObject );
itkBooleanMacro( Interactive );
+ itkGetConstMacro( Interactive, bool );
+ itkSetMacro( Interactive, bool );
itkGetConstObjectMacro( Parameters, TParameters );
itkGetObjectMacro( Parameters, TParameters );
- itkGetConstMacro( Plugins, const Plugins* );
- itkGetMacro( Plugins, Plugins* );
- itkGetConstMacro( Interactive, bool );
-
- itkSetObjectMacro( Plugins, Plugins );
- itkSetMacro( Interactive, bool );
public:
- // To impact pipeline
- virtual void Modified( ) const;
-
- virtual void GetInputsNames( std::set< std::string >& names ) const;
- virtual void GetOutputsNames( std::set< std::string >& names ) const;
+ virtual std::set< std::string > GetInputsNames( ) const;
+ virtual std::set< std::string > GetOutputsNames( ) const;
unsigned int GetNumberOfInputs( ) const;
unsigned int GetNumberOfOutputs( ) const;
- virtual bool SetOutputObjectName(
- const std::string& new_object_name,
- const std::string& output_name
- );
-
- virtual void SetInput( const std::string& id, DataObject* dobj );
+ virtual bool SetInput( const std::string& id, DataObject* dobj );
virtual std::string Update( );
virtual void DisconnectOutputs( );
virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
virtual bool ExecConfigurationDialog( QWidget* parent );
- template< class T >
- inline T* GetITK( );
-
- template< class T >
- inline const T* GetITK( ) const;
-
- template< class T >
- inline T* GetVTK( );
-
- template< class T >
- inline const T* GetVTK( ) const;
-
template< class T >
inline T* GetInput( const std::string& id );
virtual void _AddInput( const std::string& name );
+ template< class O >
+ inline void _AddOutput( const std::string& id );
+
template< class F >
inline F* _CreateITK( );
template< class F >
inline F* _CreateVTK( );
- template< class O >
- inline void _MakeOutput( const std::string& id );
-
virtual std::string _GenerateData( ) = 0;
private:
Self& operator=( const Self& );
protected:
- itk::ProcessObject::Pointer m_ITKObject;
- vtkSmartPointer< vtkAlgorithm > m_VTKObject;
-
Parameters::Pointer m_Parameters;
ParametersQtDialog* m_ParametersDialog;
- TInteractors m_Interactors;
- Plugins* m_Plugins;
- bool m_Interactive;
+
+ TInteractors m_Interactors;
+ bool m_Interactive;
typedef std::map< std::string, DataObject::Pointer > _TDataContainer;
_TDataContainer m_Inputs;
_TDataContainer m_Outputs;
- std::map< std::string, std::string > m_OutputObjectsNames;
};
/**
#ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
#define __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
-// -------------------------------------------------------------------------
-template< class T >
-T* cpPlugins::Interface::ProcessObject::
-GetITK( )
-{
- return( dynamic_cast< T* >( this->m_ITKObject.GetPointer( ) ) );
-}
-
-// -------------------------------------------------------------------------
-template< class T >
-const T* cpPlugins::Interface::ProcessObject::
-GetITK( ) const
-{
- return( dynamic_cast< const T* >( this->m_ITKObject.GetPointer( ) ) );
-}
-
-// -------------------------------------------------------------------------
-template< class T >
-T* cpPlugins::Interface::ProcessObject::
-GetVTK( )
-{
- return( dynamic_cast< T* >( this->m_VTKObject.GetPointer( ) ) );
-}
-
-// -------------------------------------------------------------------------
-template< class T >
-const T* cpPlugins::Interface::ProcessObject::
-GetVTK( ) const
-{
- return( dynamic_cast< const T* >( this->m_VTKObject.GetPointer( ) ) );
-}
-
// -------------------------------------------------------------------------
template< class T >
T* cpPlugins::Interface::ProcessObject::
return( NULL );
}
+// -------------------------------------------------------------------------
+template< class O >
+void cpPlugins::Interface::ProcessObject::
+_AddOutput( const std::string& id )
+{
+ this->m_Outputs[ id ] = O::New( );
+ this->m_Outputs[ id ]->SetSource( this );
+ this->Modified( );
+}
+
// -------------------------------------------------------------------------
template< class F >
F* cpPlugins::Interface::ProcessObject::
return( filter );
}
-// -------------------------------------------------------------------------
-template< class O >
-void cpPlugins::Interface::ProcessObject::
-_MakeOutput( const std::string& id )
-{
- this->m_Outputs[ id ] = O::New( );
- this->m_Outputs[ id ]->SetSource( this );
- this->Modified( );
-}
-
#endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
// eof - $RCSfile$
: Superclass( )
{
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
this->m_Parameters->ConfigureAsUint( "Radius" );
this->m_Parameters->SetUint( "Radius", 2 );
: Superclass( )
{
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
this->m_Parameters->ConfigureAsReal( "LowerThresholdValue" );
this->m_Parameters->ConfigureAsReal( "UpperThresholdValue" );
{
this->_AddInput( "InputMesh" );
this->_AddInput( "InputFunction" );
- this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" );
}
// -------------------------------------------------------------------------
#include "DoubleFloodImageFilter.h"
#include <cpPlugins/Interface/Image.h>
-#include <cpPlugins/Interface/BaseApplication.h>
-#include <cpPlugins/Interface/Plugins.h>
#include <cpExtensions/Interaction/ImageInteractorStyle.h>
#include <cpExtensions/Visualization/ImageSliceActors.h>
: QDialog( parent, f | Qt::WindowStaysOnTopHint ),
m_Filter( filter )
{
+/* TODO
this->m_Title = new QLabel( this );
this->m_Title->setText( "Execute simple vessel segmentation filter" );
QObject::connect( bb, SIGNAL( accepted( ) ), this, SLOT( accept( ) ) );
QObject::connect( bb, SIGNAL( rejected( ) ), this, SLOT( reject( ) ) );
this->m_ToolsLayout->addWidget( bb );
+*/
}
// -------------------------------------------------------------------------
cpPlugins::BasicFilters::DoubleFloodImageFilter_Dialog::
~DoubleFloodImageFilter_Dialog( )
{
+/*
delete this->m_Title;
delete this->m_ToolsLayout;
delete this->m_MainLayout;
+*/
}
// -------------------------------------------------------------------------
void cpPlugins::BasicFilters::DoubleFloodImageFilter_Dialog::
accept( )
{
+/*
// Get interactive widget
if( this->m_Filter == NULL )
return;
app->UpdateActualFilter( );
} // fi
+*/
}
// -------------------------------------------------------------------------
void cpPlugins::BasicFilters::DoubleFloodImageFilter_Dialog::
reject( )
{
+/*
auto plugins = this->m_Filter->GetPlugins( );
if( plugins != NULL )
plugins->DeactivateFilter( );
this->Superclass::reject( );
+*/
}
-
#endif // cpPlugins_Interface_QT4
// -------------------------------------------------------------------------
DialogResult cpPlugins::BasicFilters::DoubleFloodImageFilter::
ExecConfigurationDialog( QWidget* parent )
{
+/* TODO
#ifdef cpPlugins_Interface_QT4
typedef cpExtensions::Interaction::ImageInteractorStyle _TImageStyle;
#else // cpPlugins_Interface_QT4
return( false );
#endif // cpPlugins_Interface_QT4
+*/
+ return( false );
}
// -------------------------------------------------------------------------
DoubleFloodImageFilter( )
: Superclass( )
{
+ /* TODO
this->_AddInput( "Input" );
this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
this->m_Parameters->SetReal( "Level", 0 );
this->m_Parameters->SetUint( "InsideValue", 255 );
this->m_Parameters->SetUint( "OutsideValue", 0 );
+ */
}
// -------------------------------------------------------------------------
std::string cpPlugins::BasicFilters::DoubleFloodImageFilter::
_GenerateData( )
{
+ /* TODO
cpPlugins::Interface::Image* image =
this->GetInput< cpPlugins::Interface::Image >( "Input" );
if( image == NULL )
else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
else r = "DoubleFloodImageFilter: Input image type not supported.";
return( r );
+ */
+ return( "" );
}
// -------------------------------------------------------------------------
std::string cpPlugins::BasicFilters::DoubleFloodImageFilter::
_GD0( itk::DataObject* image )
{
+ /* TODO
return(
this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >(
image
)
);
+ */
+ return( "" );
+
}
// -------------------------------------------------------------------------
+/* TODO
template< class I, class R = float >
class cpPlugins_BasicFilters_DoubleFloodImageFilter_Function
: public itk::ImageFunction< I, bool, R >
mutable unsigned char m_StartValue;
mutable bool m_Start;
};
+*/
// -------------------------------------------------------------------------
template< class I, class O >
inline std::string cpPlugins::BasicFilters::DoubleFloodImageFilter::
_RealGD( itk::DataObject* image )
{
+ /* TODO
typedef typename O::PixelType _OP;
typedef cpPlugins_BasicFilters_DoubleFloodImageFilter_Function< I > _F;
typedef itk::FloodFilledImageFunctionConditionalConstIterator< I, _F > _It;
}
else
return( "DoubleFloodImageFilter: output not correctly created." );
+ */
+ return( "" );
}
// eof - $RCSfile$
#ifdef cpPlugins_Interface_QT4
class DoubleFloodImageFilter;
- /**
- */
class DoubleFloodImageFilter_Dialog
: public QDialog
{
: Superclass( )
{
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
this->m_Parameters->ConfigureAsUint( "Axis" );
this->m_Parameters->ConfigureAsInt( "Slice" );
#include "FloodFillImageFilter.h"
#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Interface/PointList.h>
#include <itkFloodFilledImageFunctionConditionalConstIterator.h>
#include <itkImageFunction.h>
FloodFillImageFilter( )
: Superclass( )
{
+ /* TODO
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+ this->_AddInput( "Seed" );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
- this->m_Parameters->ConfigureAsPoint( "Seed" );
this->m_Parameters->ConfigureAsReal( "Window" );
this->m_Parameters->ConfigureAsReal( "Level" );
this->m_Parameters->ConfigureAsUint( "InsideValue" );
this->m_Parameters->SetReal( "Level", 0 );
this->m_Parameters->SetUint( "InsideValue", 0 );
this->m_Parameters->SetUint( "OutsideValue", 255 );
+ */
}
// -------------------------------------------------------------------------
std::string cpPlugins::BasicFilters::FloodFillImageFilter::
_GenerateData( )
{
+ /* TODO
cpPlugins::Interface::Image* image =
this->GetInput< cpPlugins::Interface::Image >( "Input" );
if( image == NULL )
else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
else r = "FloodFillImageFilter: Input image type not supported.";
return( r );
+ */
+ return( "" );
}
// -------------------------------------------------------------------------
std::string cpPlugins::BasicFilters::FloodFillImageFilter::
_GD0( itk::DataObject* image )
{
+ /* TODO
return(
this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >(
image
)
);
+ */
+ return( "" );
}
// -------------------------------------------------------------------------
+/* TODO
template< class I, class R = float >
class cpPlugins_BasicFilters_FloodFillImageFilter_Function
: public itk::ImageFunction< I, bool, R >
mutable unsigned char m_StartValue;
mutable bool m_Start;
};
+*/
// -------------------------------------------------------------------------
template< class I, class O >
inline std::string cpPlugins::BasicFilters::FloodFillImageFilter::
_RealGD( itk::DataObject* image )
{
+ /* TODO
typedef typename O::PixelType _OP;
typedef cpPlugins_BasicFilters_FloodFillImageFilter_Function< I > _F;
typedef itk::FloodFilledImageFunctionConditionalConstIterator< I, _F > _It;
}
else
return( "FloodFillImageFilter: output not correctly created." );
+ */
+ return( "" );
}
// eof - $RCSfile$
#include "MacheteFilter.h"
-#include <cpPlugins/Interface/BaseApplication.h>
-#include <cpPlugins/Interface/Plugins.h>
-
#include <cpPlugins/Interface/DataObject.h>
#include <cpPlugins/Interface/Image.h>
#include <cpPlugins/Interface/Mesh.h>
wdg->GetCenter( center );
wdg->GetNormal( normal );
- this->m_Filter->GetParameters( )->SetPoint( "PlaneCenter", 3, center );
- this->m_Filter->GetParameters( )->SetVector( "PlaneNormal", 3, normal );
+ /* TODO
+ this->m_Filter->GetParameters( )->SetPoint( "PlaneCenter", 3, center );
+ this->m_Filter->GetParameters( )->SetVector( "PlaneNormal", 3, normal );
+ */
// Update filter
- auto plugins = this->m_Filter->GetPlugins( );
- if( plugins != NULL )
- {
- auto app = plugins->GetApplication( );
- if( app != NULL )
- app->UpdateActualFilter( );
-
- } // fi
+ /* TODO
+ auto plugins = this->m_Filter->GetPlugins( );
+ if( plugins != NULL )
+ {
+ auto app = plugins->GetApplication( );
+ if( app != NULL )
+ app->UpdateActualFilter( );
+
+ } // fi
+ */
}
// -------------------------------------------------------------------------
void cpPlugins::BasicFilters::MacheteFilter_Dialog::
reject( )
{
+ /*
auto plugins = this->m_Filter->GetPlugins( );
if( plugins != NULL )
plugins->DeactivateFilter( );
+ */
this->Superclass::reject( );
}
m_PlaneWidget( NULL )
{
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::DataObject >( "PositiveOutput" );
- this->_MakeOutput< cpPlugins::Interface::DataObject >( "NegativeOutput" );
+ this->_AddOutput< cpPlugins::Interface::DataObject >( "PositiveOutput" );
+ this->_AddOutput< cpPlugins::Interface::DataObject >( "NegativeOutput" );
+ /*
this->m_Parameters->ConfigureAsPoint( "PlaneCenter" );
this->m_Parameters->ConfigureAsVector( "PlaneNormal" );
+ */
}
// -------------------------------------------------------------------------
I* image = dynamic_cast< I* >( dobj );
+ /*
_TPoint c = this->m_Parameters->GetPoint< _TPoint >(
"PlaneCenter", I::ImageDimension
);
_TVector n = this->m_Parameters->GetVector< _TVector >(
"PlaneNormal", I::ImageDimension
);
+ */
+ _TPoint c;
+ _TVector n;
typename _TPlane::Pointer plane = _TPlane::New( );
plane->SetCenter( c );
_TImage* pos_out = this->GetOutput< _TImage >( "PositiveOutput" );
if( pos_out == NULL )
{
- this->_MakeOutput< _TImage >( "PositiveOutput" );
+ this->_AddOutput< _TImage >( "PositiveOutput" );
pos_out = this->GetOutput< _TImage >( "PositiveOutput" );
pos_out->SetName( pos_name );
_TImage* neg_out = this->GetOutput< _TImage >( "NegativeOutput" );
if( neg_out == NULL )
{
- this->_MakeOutput< _TImage >( "NegativeOutput" );
+ this->_AddOutput< _TImage >( "NegativeOutput" );
neg_out = this->GetOutput< _TImage >( "NegativeOutput" );
neg_out->SetName( neg_name );
MacheteImageFilter()
: Superclass()
{
- this->_AddInput("Input");
- this->_MakeOutput< cpPlugins::Interface::Image >("Output");
+ this->_AddInput( "Input" );
+ this->_AddOutput< cpPlugins::Interface::Image >("Output");
this->m_Parameters->ConfigureAsReal("Radius");
//this->m_Parameters->ConfigureAsPoint("Point", 3, 3);
: public cpPlugins::Interface::ImageToImageFilter
{
public:
- typedef MacheteImageFilter Self;
+ typedef MacheteImageFilter Self;
typedef cpPlugins::Interface::ImageToImageFilter Superclass;
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
: Superclass( )
{
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" );
this->m_Parameters->ConfigureAsRealList( "Thresholds" );
}
: Superclass( )
{
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
this->m_Parameters->ConfigureAsUint( "Radius" );
this->m_Parameters->SetUint( "Radius", 3 );
: Superclass( )
{
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
this->m_Parameters->ConfigureAsUint( "NumberOfHistogramBins" );
this->m_Parameters->ConfigureAsUint( "InsideValue" );
typedef cpPlugins::Interface::Parameters TParameters;
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
std::vector< std::string > choices;
choices.push_back( "HSV" );
: Superclass( )
{
this->_AddInput( "Input" );
- this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
this->m_Parameters->ConfigureAsReal( "BackgroundValue" );
this->m_Parameters->ConfigureAsBool( "InsideIsPositive" );
SphereMeshSource( )
: Superclass( )
{
- this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" );
+ this->_AddInput( "Center" );
+ this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" );
- this->m_Parameters->ConfigureAsPoint( "Center" );
this->m_Parameters->ConfigureAsReal( "Radius" );
this->m_Parameters->ConfigureAsUint( "PhiResolution" );
this->m_Parameters->ConfigureAsUint( "ThetaResolution" );
std::string cpPlugins::BasicFilters::SphereMeshSource::
_GenerateData( )
{
- itk::Point< double, 3 > center =
- this->m_Parameters->GetPoint< itk::Point< double, 3 > >( "Center", 3 );
- // TODO: center.Fill( double( 0 ) ); // TODO
+ itk::Point< double, 3 > center;
+ center.Fill( double( 0 ) );
+ /* TODO
+ itk::Point< double, 3 > center =
+ this->m_Parameters->GetPoint< itk::Point< double, 3 > >( "Center", 3 );
+ */
double radius = this->m_Parameters->GetReal( "Radius" );
unsigned int phi = this->m_Parameters->GetUint( "PhiResolution" );
unsigned int theta = this->m_Parameters->GetUint( "ThetaResolution" );
ImageReader( )
: Superclass( )
{
- this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Image >( "Output" );
this->m_Parameters->ConfigureAsOpenFileNameList( "FileNames" );
this->m_Parameters->ConfigureAsBool( "VectorType" );
MeshReader( )
: Superclass( )
{
- this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" );
std::vector< TParameters::TString > valid_types;
valid_types.push_back( "float" );
m_Configured( false )
{
this->_AddInput( "ReferenceImage" );
- this->_MakeOutput< cpPlugins::Interface::PointList >( "Output" );
+ this->_AddOutput< cpPlugins::Interface::PointList >( "Output" );
this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" );
this->m_Parameters->SetBool( "SeedsAreInRealSpace", true );