void ImageMPR::
_aOpenImage( )
{
- // Clear all, since we are loading the main image
- if( this->m_Objects.size( ) > 0 )
- {
- this->m_UI->MPR->ClearAll( );
- this->m_Objects.clear( );
-
- } // fi
-
// Read and show image, if possible
TPlugins::TImage::Pointer image;
if( this->m_Plugins->ReadImage( image, true ) )
{
vtkImageData* vimage = image->GetVTK< vtkImageData >( );
if( vimage == NULL )
+ {
QMessageBox::critical(
this,
QMessageBox::tr( "Error showing image." ),
"Image was read, but no valid VTK conversion was found."
)
);
+ return;
+ }
else
- this->m_UI->MPR->ShowImage( vimage, image->GetName( ) );
+ {
+ // Since we are opening an image, clear all
+ this->m_UI->MPR->DeleteAllData( );
+ this->m_Objects.clear( );
- // Keep a track on a local data tree
- this->m_Objects[ image->GetName( ) ] =
- TTreeNode( "", image.GetPointer( ) );
+ // Update references
+ std::string name = image->GetName( );
+ this->m_Objects[ name ] = TTreeNode( "", image.GetPointer( ) );
+ this->m_UI->MPR->AddImage( vimage, name );
+ this->m_UI->MPR->ShowData( name );
+
+ } // fi
} // fi
}
void ImageMPR::
_aOpenDICOMSeries( )
{
- // Clear all, since we are loading the main image
- if( this->m_Objects.size( ) > 0 )
- {
- this->m_UI->MPR->ClearAll( );
- this->m_Objects.clear( );
-
- } // fi
-
// Read and show image, if possible
TPlugins::TImage::Pointer image;
if( this->m_Plugins->ReadDicomSeries( image ) )
{
vtkImageData* vimage = image->GetVTK< vtkImageData >( );
if( vimage == NULL )
+ {
QMessageBox::critical(
this,
QMessageBox::tr( "Error showing image." ),
"Image was read, but no valid VTK conversion was found."
)
);
+ return;
+ }
else
- this->m_UI->MPR->ShowImage( vimage, image->GetName( ) );
+ {
+ // Since we are opening an image, clear all
+ this->m_UI->MPR->DeleteAllData( );
+ this->m_Objects.clear( );
- // Keep a track on a local data tree
- this->m_Objects[ image->GetName( ) ] =
- TTreeNode( "", image.GetPointer( ) );
+ // Update references
+ std::string name = image->GetName( );
+ this->m_Objects[ name ] = TTreeNode( "", image.GetPointer( ) );
+ this->m_UI->MPR->AddImage( vimage, name );
+ this->m_UI->MPR->ShowData( name );
+
+ } // fi
} // fi
}
void ImageMPR::
_execPlugin( )
{
- // Get filter name
+ // Get filter's name and category
QAction* action = dynamic_cast< QAction* >( this->sender( ) );
if( action == NULL )
return;
std::string filter_name = action->text( ).toStdString( );
// Create filter
- TPlugins::TProcessObject::Pointer filter;
- if( !( this->m_Plugins->CreateFilter( filter, filter_name ) ) )
+ if( !( this->m_Plugins->CreateFilter( this->m_ActiveFilter, filter_name ) ) )
{
QMessageBox::critical(
this,
std::string( "\"defined." )
).c_str( ) )
);
+ this->m_ActiveFilter = NULL;
return;
} // fi
// Configure filter
- if( !( filter->ExecConfigurationDialog( this ) ) )
+ this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 0 ) );
+ this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 1 ) );
+ this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 2 ) );
+ this->m_ActiveFilter->AddInteractor( this->m_UI->MPR->GetInteractor( 3 ) );
+
+ TPlugins::TProcessObject::DialogResult res =
+ this->m_ActiveFilter->ExecConfigurationDialog( this );
+ if( res == TPlugins::TProcessObject::DialogResult_Cancel )
+ {
+ this->m_ActiveFilter = NULL;
return;
+ } // fi
+
// Assign inputs
std::string data_name = this->m_UI->MPR->GetSelectedData( );
- std::vector< std::string > inputs_names = filter->GetInputsNames( );
+ std::vector< std::string > inputs_names =
+ this->m_ActiveFilter->GetInputsNames( );
if( inputs_names.size( ) == 1 )
{
TTree::iterator iIt = this->m_Objects.find( data_name );
tr( "Error configuring filter" ),
tr( "No valid input found. Please select a valid input." )
);
+ this->m_ActiveFilter = NULL;
return;
} //fi
- filter->SetInput( inputs_names[ 0 ], iIt->second.second );
+ this->m_ActiveFilter->SetInput( inputs_names[ 0 ], iIt->second.second );
}
else if( inputs_names.size( ) > 1 )
{
} // fi
// Execute filter
- this->_Block( );
- std::string filter_err = filter->Update( );
- this->_Unblock( );
- if( filter_err != "" )
- {
- QMessageBox::critical(
- this,
- tr( "Error executing" ),
- tr( filter_err.c_str( ) )
- );
- return;
-
- } // fi
+ /*
+ if( res == TPlugins::TProcessObject::DialogResult_NoModal )
+ {
+ this->_Block( );
+ std::string filter_err = this->m_ActiveFilter->Update( );
+ this->_Unblock( );
+ if( filter_err != "" )
+ {
+ QMessageBox::critical(
+ this,
+ tr( "Error executing" ),
+ tr( filter_err.c_str( ) )
+ );
+ this->m_ActiveFilter = NULL;
+ return;
- // Get outputs
- std::vector< std::string > outputs_names = filter->GetOutputsNames( );
- for(
- auto oIt = outputs_names.begin( );
- oIt != outputs_names.end( );
- ++oIt
- )
- {
- std::string out_name = filter_name + "_" + *oIt;
+ } // fi
- TPlugins::TImage* image = filter->GetOutput< TPlugins::TImage >( *oIt );
- if( image != NULL )
+ // Get outputs
+ std::vector< std::string > outputs_names = filter->GetOutputsNames( );
+ for(
+ auto oIt = outputs_names.begin( );
+ oIt != outputs_names.end( );
+ ++oIt
+ )
{
- if( filter_cate == "ImageToBinaryImageFilter" )
- {
- this->m_UI->MPR->ShowImage(
- image->GetVTK< vtkImageData >( ),
- out_name,
- data_name, 1, 0, 0
- );
- }
- else if( filter_cate == "ImageToImageFilter" )
+ std::string out_name = filter_name + "_" + *oIt;
+
+ TPlugins::TImage* image =
+ this->m_ActiveFilter->GetOutput< TPlugins::TImage >( *oIt );
+ if( image != NULL )
{
+ if( filter_cate == "ImageToBinaryImageFilter" )
+ {
+ this->m_UI->MPR->ShowImage(
+ image->GetVTK< vtkImageData >( ),
+ out_name,
+ data_name, 1, 0, 0
+ );
+ }
+ else if( filter_cate == "ImageToImageFilter" )
+ {
+ } // fi
+
+ // Keep a track on a local data tree and go to next output
+ this->m_Objects[ out_name ] = TTreeNode( data_name, image );
+ continue;
+
} // fi
- // Keep a track on a local data tree and go to next output
- this->m_Objects[ out_name ] = TTreeNode( data_name, image );
- continue;
+ TPlugins::TMesh* mesh = filter->GetOutput< TPlugins::TMesh >( *oIt );
+ if( mesh != NULL )
+ {
+ // Show mesh
+ this->_Block( );
+ this->m_UI->MPR->ShowMesh(
+ mesh->GetVTK< vtkPolyData >( ),
+ out_name,
+ data_name
+ );
+ this->_Unblock( );
- } // fi
+ // Keep a track on a local data tree and go to next output
+ this->m_Objects[ out_name ] = TTreeNode( data_name, mesh );
+ continue;
- TPlugins::TMesh* mesh = filter->GetOutput< TPlugins::TMesh >( *oIt );
- if( mesh != NULL )
- {
- // Show mesh
- this->_Block( );
- this->m_UI->MPR->ShowMesh(
- mesh->GetVTK< vtkPolyData >( ),
- out_name,
- data_name
- );
- this->_Unblock( );
+ } // fi
- // Keep a track on a local data tree and go to next output
- this->m_Objects[ out_name ] = TTreeNode( data_name, mesh );
- continue;
+ } // rof
- } // fi
+ // No-modal filters just exists for one usage
+ this->m_ActiveFilter = NULL;
- } // rof
+ } // fi
+ */
}
// -------------------------------------------------------------------------
typedef std::map< std::string, TTreeNode > TTree;
TTree m_Objects;
+ // Active filter (for modal configuration)
+ TPlugins::TProcessObject::Pointer m_ActiveFilter;
+
// Plugins objects
/*
TPluginsInterface m_Plugins;
#include <cpExtensions/Interaction/ImageInteractorStyle.h>
+#include <vtkCommand.h>
#include <vtkImageActor.h>
#include <vtkPropCollection.h>
#include <vtkProperty.h>
} // fi
}
+// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageInteractorStyle::
+SetSeedWidgetCommand( vtkCommand* cmd )
+{
+ if( cmd == NULL || this->m_SeedWidget == NULL )
+ return;
+ this->m_SeedWidget->Widget->
+ AddObserver( vtkCommand::PlacePointEvent, cmd );
+}
+
// -------------------------------------------------------------------------
cpExtensions::Interaction::ImageInteractorStyle::
ImageInteractorStyle( )
#include <cpExtensions/Interaction/SeedWidget.h>
// Forward definitions
+class vtkCommand;
class vtkImageActor;
namespace cpExtensions
// Widgets
void SeedWidgetOn( );
void SeedWidgetOff( );
+ void SetSeedWidgetCommand( vtkCommand* cmd );
protected:
ImageInteractorStyle( );
this->RenderAll( 1e-3 );
}
+// -------------------------------------------------------------------------
+unsigned int cpExtensions::Visualization::MPRObjects::
+GetNumberOfImages( ) const
+{
+ return( this->m_MPRActors->GetNumberOfImages( ) );
+}
+
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRObjects::
ClearAll( )
vtkRenderWindow* wz, vtkRenderWindow* w3D
);
void AddImage( vtkImageData* image );
+ unsigned int GetNumberOfImages( ) const;
void ClearAll( );
void ResetCamera( const int& id );
cpPlugins::Interface::BaseMPRWidget::
BaseMPRWidget( QWidget* parent )
: QWidget( parent ),
- m_UI( new Ui::BaseMPRWidget )
+ m_UI( new Ui::BaseMPRWidget ),
+ m_MainImage( "" )
{
this->m_UI->setupUi( this );
~BaseMPRWidget( )
{
delete this->m_UI;
+}
- // Delete polydata actors
- std::map< std::string, PolyDataActor* >::iterator mIt =
- this->m_Meshes.begin( );
- for( ; mIt != this->m_Meshes.end( ); ++mIt )
- delete mIt->second;
- this->m_Meshes.clear( );
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::BaseMPRWidget::
+AddImage(
+ vtkImageData* image, const std::string& name, const std::string& parent
+ )
+{
+ if( name == "" )
+ return( false );
+
+ if( parent == "" )
+ this->DeleteAllData( );
+
+ auto iIt = this->m_Data.find( name );
+ if( iIt == this->m_Data.end( ) )
+ {
+ // Update tree
+ if( parent != "" )
+ {
+ auto pIt = this->m_Data.find( parent );
+ if( pIt != this->m_Data.end( ) )
+ this->m_Tree[ name ] = parent;
+ else
+ return( false );
+ }
+ else
+ this->m_MainImage = name;
+
+ // Add new data
+ Data nd;
+ nd.Tag = Data::IMAGE;
+ nd.Image = image;
+ this->m_Data[ name ] = nd;
+
+ // Add to tree view
+ this->_UpdateItem( name, parent );
+ return( true );
+ }
+ else
+ return( false );
}
// -------------------------------------------------------------------------
bool cpPlugins::Interface::BaseMPRWidget::
-ShowImage(
+AddMesh(
+ vtkPolyData* mesh, const std::string& name, const std::string& parent
+ )
+{
+ if( name == "" || parent == "" )
+ return( false );
+
+ auto iIt = this->m_Data.find( name );
+ if( iIt == this->m_Data.end( ) )
+ {
+ // Add new data
+ Data nd;
+ nd.Tag = Data::MESH;
+ nd.Mesh.Configure( mesh );
+ this->m_Data[ name ] = nd;
+
+ // Update tree
+ auto pIt = this->m_Data.find( parent );
+ if( pIt != this->m_Data.end( ) )
+ this->m_Tree[ name ] = parent;
+ else
+ return( false );
+
+ // Add to tree view
+ this->_UpdateItem( name, parent );
+ return( true );
+ }
+ 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->_FindItem( 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->ClearAll( );
+ 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 )
+ {
+ this->m_MPRObjects->AddImage( iIt->second.Image );
+ }
+ else if( iIt->second.Tag == Data::MESH )
+ {
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+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->_UpdateItem( name, parent );
if( new_item == NULL )
- return( false );
+ return( false );
// Associate new data
this->m_Images[ name ] = image;
// Show image and return
this->m_MPRObjects->AddImage( image );
return( true );
-}
+ }
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::BaseMPRWidget::
-ShowImage(
+ // -------------------------------------------------------------------------
+ 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->_UpdateItem( name, parent );
if( new_item == NULL )
- return( false );
+ return( false );
// Associate new data
this->m_Images[ name ] = image;
// Show image and return
this->m_MPRObjects->AddImage( image );
return( true );
-}
+ }
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::BaseMPRWidget::
-ShowMesh(
+ // -------------------------------------------------------------------------
+ bool cpPlugins::Interface::BaseMPRWidget::
+ ShowMesh(
vtkPolyData* mesh,
const std::string& name,
const std::string& parent
)
-{
+ {
// Update tree view
QTreeWidgetItem* new_item = this->_UpdateItem( name, parent );
if( new_item == NULL )
- return( false );
+ return( false );
// Associate new data
PolyDataActor* actor = new PolyDataActor( mesh );
// Show mesh
this->_Add3DActor( actor->Actor );
return( true );
-}
+ }
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::BaseMPRWidget::
-ShowMesh(
+ // -------------------------------------------------------------------------
+ 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( );
- */
-}
+ // -------------------------------------------------------------------------
+ void cpPlugins::Interface::BaseMPRWidget::
+ ClearAll( )
+ {
+ this->m_MPRObjects->ClearAll( );
+ this->m_Images.clear( );
+ this->m_Meshes.clear( );
+ }
+*/
// -------------------------------------------------------------------------
std::string cpPlugins::Interface::BaseMPRWidget::
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWidget::
-_Add3DActor( vtkProp3D* prop )
-{
+/*
+ void cpPlugins::Interface::BaseMPRWidget::
+ _Add3DActor( vtkProp3D* prop )
+ {
vtkRenderer* ren =
- this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
+ this->m_VTK[ 3 ]->GetRenderWindow( )->GetRenderers( )->GetFirstRenderer( );
if( ren == NULL )
- return;
+ return;
ren->AddActor( prop );
this->m_VTK[ 3 ]->GetRenderWindow( )->Render( );
-}
+ }
+*/
// -------------------------------------------------------------------------
void cpPlugins::Interface::BaseMPRWidget::
}
// -------------------------------------------------------------------------
-cpPlugins::Interface::BaseMPRWidget::PolyDataActor::
-PolyDataActor( vtkPolyData* pd )
+void cpPlugins::Interface::BaseMPRWidget::PolyDataActor::
+Configure( vtkPolyData* pd )
{
if( pd == NULL )
return;
this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
this->Actor = vtkSmartPointer< vtkQuadricLODActor >::New( );
+ this->Mesh = pd;
this->Normals->SetInputData( pd );
this->Normals->SetFeatureAngle( 60.0 );
this->Stripper->SetInputConnection( this->Normals->GetOutputPort( ) );
#include <QWidget>
#include <vtkSmartPointer.h>
+#include <vtkImageData.h>
#include <vtkPolyDataMapper.h>
#include <vtkPolyDataNormals.h>
#include <vtkQuadricLODActor.h>
explicit BaseMPRWidget( QWidget* parent = 0 );
virtual ~BaseMPRWidget( );
+ // Data management
+ bool AddImage(
+ vtkImageData* image,
+ const std::string& name,
+ const std::string& parent = ""
+ );
+ bool AddMesh(
+ vtkPolyData* mesh,
+ const std::string& name,
+ const std::string& parent
+ );
+ void DeleteData( const std::string& name );
+ void DeleteAllData( );
+
// Some visualization accessors
- bool ShowImage(
+ void SetDataColor(
+ const std::string& name,
+ const double& r,
+ const double& g,
+ const double& b
+ );
+ void ShowData( const std::string& name );
+
+ vtkRenderWindowInteractor* GetInteractor( unsigned int i );
+
+ /*
+ bool ShowImage(
vtkImageData* image,
const std::string& name,
const std::string& parent = ""
);
- bool ShowImage(
+ bool ShowImage(
vtkImageData* image,
const std::string& name,
const std::string& parent,
const double& r, const double& g, const double& b
);
- bool ShowMesh(
+ bool ShowMesh(
vtkPolyData* mesh,
const std::string& name,
const std::string& parent
);
- bool ShowMesh(
+ bool ShowMesh(
vtkPolyData* mesh,
const std::string& name,
const std::string& parent,
const double& r, const double& g, const double& b
);
- void ClearAll( );
+ void ClearAll( );
+ */
// Visual objects accessors
std::string GetSelectedData( ) const;
const std::string& name,
const std::string& parent
);
-
- void _Add3DActor( vtkProp3D* prop );
+
+ /* TODO
+ void _Add3DActor( vtkProp3D* prop );
+ */
private slots:
void _SyncBottom( int a, int b );
protected:
Ui::BaseMPRWidget* m_UI;
vtkSmartPointer< TMPRObjects > m_MPRObjects;
+ QVTKWidget* m_VTK[ 4 ];
struct PolyDataActor
{
+ vtkSmartPointer< vtkPolyData > Mesh;
vtkSmartPointer< vtkPolyDataNormals > Normals;
vtkSmartPointer< vtkStripper > Stripper;
vtkSmartPointer< vtkPolyDataMapper > Mapper;
vtkSmartPointer< vtkQuadricLODActor > Actor;
- PolyDataActor( vtkPolyData* pd );
+ void Configure( vtkPolyData* pd );
};
- std::map< std::string, vtkImageData* > m_Images;
- std::map< std::string, PolyDataActor* > m_Meshes;
- std::map< std::string, std::string > m_Tree;
+ struct Data
+ {
+ enum { IMAGE, MESH } Tag;
+ union
+ {
+ vtkImageData* Image;
+ PolyDataActor Mesh;
+ };
+
+ Data( ) { }
+ virtual ~Data( ) { }
+
+ inline Data& operator=( const Data& data )
+ {
+ this->Tag = data.Tag;
+ if( this->Tag == Data::IMAGE )
+ this->Image = data.Image;
+ else if( this->Tag == Data::MESH )
+ this->Mesh = data.Mesh;
+ return( *this );
+ }
+
+ inline vtkImageData* GetImage( )
+ {
+ if( this->Tag == Data::IMAGE )
+ return( this->Image );
+ else
+ return( NULL );
+ }
+ inline vtkPolyData* GetMesh( )
+ {
+ if( this->Tag == Data::MESH )
+ return( this->Mesh.Mesh.GetPointer( ) );
+ else
+ return( NULL );
+ }
+ inline vtkProp* GetMeshActor( )
+ {
+ if( this->Tag == Data::MESH )
+ return( this->Mesh.Actor.GetPointer( ) );
+ else
+ return( NULL );
+ }
+ };
- QVTKWidget* m_VTK[ 4 ];
+ std::string m_MainImage;
+ std::map< std::string, Data > m_Data;
+ std::map< std::string, std::string > m_Tree;
};
} // ecapseman
#include <cpPlugins/Interface/ParametersListWidget.h>
+#include <vtkCommand.h>
#include <vtkRenderWindowInteractor.h>
#include <QCheckBox>
#include <QLineEdit>
#include <QWidget>
+// -------------------------------------------------------------------------
+class SingleSeedCommand
+ : public vtkCommand
+{
+public:
+ static SingleSeedCommand* New( )
+ { return( new SingleSeedCommand ); }
+ virtual void Execute( vtkObject* caller, unsigned long eid, void* data )
+ {
+ if( eid != vtkCommand::PlacePointEvent )
+ return;
+#error ACA VOY
+ }
+};
+
// -------------------------------------------------------------------------
cpPlugins::Interface::ParametersQtDialog::
ParametersQtDialog( QWidget* parent, Qt::WindowFlags f )
}
else if( pt == Parameters::Point || pt == Parameters::Index )
{
+ vtkSmartPointer< SingleSeedCommand > command =
+ vtkSmartPointer< SingleSeedCommand >::New( );
+
auto iIt = this->m_Interactors.begin( );
for( ; iIt != this->m_Interactors.end( ); ++iIt )
{
TStyle* style =
dynamic_cast< TStyle* >( ( *iIt )->GetInteractorStyle( ) );
- std::cout << "ACA VOY --> " << style << std::endl;
-
- } // rof
- this->m_IsModal = false;
-
- /*
- if( this->m_Interactor != NULL )
+ if( style != NULL )
{
+ style->SeedWidgetOn( );
+ style->SetSeedWidgetCommand( command );
} // fi
- */
+
+ } // rof
+ this->m_IsModal = false;
} // fi
if( ret == "" )
{
- bool execute = true;
+ TProcessObject::DialogResult dret = TProcessObject::DialogResult_NoModal;
if( exec_qt )
- execute = this->m_ImageReader->ExecConfigurationDialog( this->m_Widget );
- if( execute )
+ dret = this->m_ImageReader->ExecConfigurationDialog( this->m_Widget );
+ if( dret != TProcessObject::DialogResult_Cancel )
{
this->BlockWidget( );
ret = this->m_ImageReader->Update( );
if( ret == "" )
{
- if( this->m_DicomSeriesReader->ExecConfigurationDialog( this->m_Widget ) )
+ TProcessObject::DialogResult dret =
+ this->m_DicomSeriesReader->ExecConfigurationDialog( this->m_Widget );
+ if( dret != TProcessObject::DialogResult_Cancel )
{
this->BlockWidget( );
ret = this->m_DicomSeriesReader->Update( );
if( ret == "" )
{
- bool execute = true;
+ TProcessObject::DialogResult dret = TProcessObject::DialogResult_NoModal;
if( exec_qt )
- execute = this->m_MeshReader->ExecConfigurationDialog( this->m_Widget );
- if( execute )
+ dret = this->m_MeshReader->ExecConfigurationDialog( this->m_Widget );
+ if( dret != TProcessObject::DialogResult_Cancel )
{
this->BlockWidget( );
ret = this->m_MeshReader->Update( );
if( ret == "" )
{
- bool execute = true;
+ TProcessObject::DialogResult dret = TProcessObject::DialogResult_NoModal;
if( exec_qt )
- execute = this->m_ImageWriter->ExecConfigurationDialog( this->m_Widget );
- if( execute )
+ dret = this->m_ImageWriter->ExecConfigurationDialog( this->m_Widget );
+ if( dret != TProcessObject::DialogResult_Cancel )
{
this->m_ImageWriter->SetInput( "Input", image );
this->BlockWidget( );
if( ret == "" )
{
- bool execute = true;
+ TProcessObject::DialogResult dret = TProcessObject::DialogResult_NoModal;
if( exec_qt )
- execute = this->m_MeshWriter->ExecConfigurationDialog( this->m_Widget );
- if( execute )
+ dret = this->m_MeshWriter->ExecConfigurationDialog( this->m_Widget );
+ if( dret != TProcessObject::DialogResult_Cancel )
{
this->m_MeshWriter->SetInput( "Input", mesh );
this->BlockWidget( );
#include <cpPlugins/Interface/ParametersQtDialog.h>
#endif // cpPlugins_Interface_QT4
+#include <vtkRenderWindowInteractor.h>
+
// -------------------------------------------------------------------------
void cpPlugins::Interface::ProcessObject::
Modified( ) const
}
// -------------------------------------------------------------------------
-bool cpPlugins::Interface::ProcessObject::
+void cpPlugins::Interface::ProcessObject::
+AddInteractor( vtkRenderWindowInteractor* interactor )
+{
+#ifdef cpPlugins_Interface_QT4
+ this->m_ParametersDialog->addInteractor( interactor );
+#endif // cpPlugins_Interface_QT4
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+DialogResult cpPlugins::Interface::ProcessObject::
ExecConfigurationDialog( QWidget* parent )
{
- bool r = false;
+ DialogResult r = Self::DialogResult_Cancel;
#ifdef cpPlugins_Interface_QT4
- if( this->m_ParametersDialog == NULL )
- {
- this->m_ParametersDialog = new ParametersQtDialog( parent );
- this->m_ParametersDialog->setTitle(
- this->GetClassName( ) + std::string( " basic configuration" )
- );
- this->m_ParametersDialog->setParameters( this->m_Parameters );
-
- } // fi
+ this->m_ParametersDialog->setParent( NULL );
+ this->m_ParametersDialog->setParameters( this->m_Parameters );
if( !( this->m_ParametersDialog->IsModal( ) ) )
{
this->m_ParametersDialog->show( );
- r = true;
+ r = Self::DialogResult_Modal;
}
else
- r = ( this->m_ParametersDialog->exec( ) == 1 );
+ {
+ if( this->m_ParametersDialog->exec( ) == 1 )
+ r = Self::DialogResult_NoModal;
+ else
+ r = Self::DialogResult_Cancel;
- /*
- r = cpPlugins::Interface::ParametersQtDialog(
- this->m_Parameters,
- this->GetClassName( ) + std::string( " basic configuration" ),
- parent
- );
- if( r )
- */
+ } // fi
#endif // cpPlugins_Interface_QT4
ProcessObject( )
: Superclass( ),
m_ITKObject( NULL ),
- m_VTKObject( NULL ),
- m_ParametersDialog( NULL )
+ m_VTKObject( NULL )
{
this->m_Parameters = TParameters::New( );
+
+ this->m_ParametersDialog = new ParametersQtDialog( );
+ this->m_ParametersDialog->setTitle(
+ this->GetClassName( ) + std::string( " basic configuration" )
+ );
}
// -------------------------------------------------------------------------
cpPlugins::Interface::ProcessObject::
~ProcessObject( )
{
- if( this->m_ParametersDialog == NULL )
- delete this->m_ParametersDialog;
+ delete this->m_ParametersDialog;
}
// -------------------------------------------------------------------------
#include <vtkSmartPointer.h>
#include <vtkAlgorithm.h>
+class vtkRenderWindowInteractor;
+
namespace cpPlugins
{
namespace Interface
typedef Parameters TParameters;
+ enum DialogResult
+ {
+ DialogResult_NoModal = 0,
+ DialogResult_Modal,
+ DialogResult_Cancel
+ };
+
public:
itkTypeMacro( ProcessObject, Object );
cpPlugins_Id_Macro(
virtual std::string Update( );
virtual void DisconnectOutputs( );
- virtual bool ExecConfigurationDialog( QWidget* parent );
+ virtual void AddInteractor( vtkRenderWindowInteractor* interactor );
+ virtual DialogResult ExecConfigurationDialog( QWidget* parent );
template< class T >
inline T* GetITK( );
#include <itkGDCMSeriesFileNames.h>
// -------------------------------------------------------------------------
-bool cpPlugins::IO::DicomSeriesReader::
+cpPlugins::IO::DicomSeriesReader::
+DialogResult cpPlugins::IO::DicomSeriesReader::
ExecConfigurationDialog( QWidget* parent )
{
- bool r = false;
+ DialogResult r = Self::DialogResult_Cancel;
#ifdef cpPlugins_Interface_QT4
dialog.setFileMode( QFileDialog::DirectoryOnly );
dialog.setDirectory( QFileDialog::tr( "." ) );
if( !dialog.exec( ) )
- return( false );
+ return( Self::DialogResult_Cancel );
// Prepare dialog
QApplication::setOverrideCursor( Qt::WaitCursor );
{
delete tree_widget;
delete tree_dialog;
- return( false );
+ return( Self::DialogResult_Cancel );
} // fi
parent->setEnabled( true );
if( tree_dialog->exec( ) == 0 )
- return( false );
+ return( Self::DialogResult_Cancel );
QTreeWidgetItem* item = tree_widget->currentItem( );
if( item != NULL )
for( unsigned int f = 0; f < names.size( ); ++f )
this->m_Parameters->AddToStringList( "FileNames", names[ f ] );
- r = true;
+ r = Self::DialogResult_NoModal;
QApplication::restoreOverrideCursor( );
if( parent != NULL )
);
public:
- virtual bool ExecConfigurationDialog( QWidget* parent );
+ virtual DialogResult ExecConfigurationDialog( QWidget* parent );
protected:
DicomSeriesReader( );
#endif // cpPlugins_Interface_QT4
// -------------------------------------------------------------------------
-bool cpPlugins::IO::ImageReader::
+cpPlugins::IO::ImageReader::
+DialogResult cpPlugins::IO::ImageReader::
ExecConfigurationDialog( QWidget* parent )
{
- bool r = false;
+ DialogResult r = Self::DialogResult_Cancel;
#ifdef cpPlugins_Interface_QT4
"FileNames", qIt->toStdString( )
);
this->m_Parameters->SetBool( "VectorType", false );
- r = true;
+ r = Self::DialogResult_NoModal;
} // fi
);
public:
- virtual bool ExecConfigurationDialog( QWidget* parent );
+ virtual DialogResult ExecConfigurationDialog( QWidget* parent );
protected:
ImageReader( );
#endif // cpPlugins_Interface_QT4
// -------------------------------------------------------------------------
-bool cpPlugins::IO::ImageWriter::
+cpPlugins::IO::ImageWriter::
+DialogResult cpPlugins::IO::ImageWriter::
ExecConfigurationDialog( QWidget* parent )
{
- bool r = false;
+ DialogResult r = Self::DialogResult_Cancel;
#ifdef cpPlugins_Interface_QT4
if( name != "" )
{
this->m_Parameters->SetString( "FileName", name );
- r = true;
+ r = Self::DialogResult_NoModal;
} // fi
);
public:
- virtual bool ExecConfigurationDialog( QWidget* parent );
+ virtual DialogResult ExecConfigurationDialog( QWidget* parent );
protected:
ImageWriter( );
#endif // cpPlugins_Interface_QT4
// -------------------------------------------------------------------------
-bool cpPlugins::IO::MeshReader::
+cpPlugins::IO::MeshReader::
+DialogResult cpPlugins::IO::MeshReader::
ExecConfigurationDialog( QWidget* parent )
{
- bool r = false;
+ DialogResult r = Self::DialogResult_Cancel;
#ifdef cpPlugins_Interface_QT4
this->m_Parameters->SetSelectedChoice( "PixelType", "float" );
this->m_Parameters->SetUint( "Dimension", 3 );
- r = true;
+ r = Self::DialogResult_NoModal;
} // fi
);
public:
- virtual bool ExecConfigurationDialog( QWidget* parent );
+ virtual DialogResult ExecConfigurationDialog( QWidget* parent );
protected:
MeshReader( );
#endif // cpPlugins_Interface_QT4
// -------------------------------------------------------------------------
-bool cpPlugins::IO::MeshWriter::
+cpPlugins::IO::MeshWriter::
+DialogResult cpPlugins::IO::MeshWriter::
ExecConfigurationDialog( QWidget* parent )
{
- bool r = false;
+ DialogResult r = Self::DialogResult_Cancel;
#ifdef cpPlugins_Interface_QT4
if( name != "" )
{
this->m_Parameters->SetString( "FileName", name );
- r = true;
+ r = Self::DialogResult_NoModal;
} // fi
);
public:
- virtual bool ExecConfigurationDialog( QWidget* parent );
+ virtual DialogResult ExecConfigurationDialog( QWidget* parent );
protected:
MeshWriter( );