#ifdef cpPlugins_Interface_QT4
-#ifdef _WIN32
-# define PLUGIN_PREFIX ""
-# define PLUGIN_EXT "dll"
-# define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)"
-#else // Linux
-# define PLUGIN_PREFIX "lib"
-# define PLUGIN_EXT "so"
-# define PLUGIN_REGEX "Plugins file (*.so);;All files (*)"
-#endif // _WIN32
-
-#include <fstream>
-#include <sstream>
-
-#include <QFileDialog>
-#include <QMessageBox>
-
// -------------------------------------------------------------------------
cpPlugins::Interface::BaseMPRWindow::
BaseMPRWindow( QWidget* parent )
- : cpExtensions::QT::QuadSplitter( parent ),
- m_LastLoadedPlugin( "." )
+ : cpExtensions::QT::QuadSplitter( parent )
{
// Configure splitter
this->m_XVTK = new QVTKWidget( this );
cpPlugins::Interface::BaseMPRWindow::
~BaseMPRWindow( )
{
- if( this->m_WVTK != NULL )
- delete this->m_WVTK;
- if( this->m_ZVTK != NULL )
- delete this->m_ZVTK;
- if( this->m_YVTK != NULL )
- delete this->m_YVTK;
- if( this->m_XVTK != NULL )
- delete this->m_XVTK;
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWindow::
-DialogLoadPlugins( )
-{
- // Show dialog and check if it was accepted
- QFileDialog dialog( this );
- dialog.setFileMode( QFileDialog::ExistingFile );
- dialog.setDirectory( this->m_LastLoadedPlugin.c_str( ) );
- dialog.setNameFilter( tr( PLUGIN_REGEX ) );
- dialog.setDefaultSuffix( tr( PLUGIN_EXT ) );
- if( !( dialog.exec( ) ) )
- return;
-
- std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
- if( !( this->LoadPlugins( fname ) ) )
- QMessageBox::critical(
- this, tr( "Ignoring plugin" ), tr( fname.c_str( ) )
- );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWindow::
-AssociatePluginsToMenu( QMenu* menu, QObject* obj, const char* slot )
-{
- std::map< std::string, std::set< std::string > >::const_iterator i;
- std::set< std::string >::const_iterator j;
-
- menu->clear( );
- for( i = this->m_Filters.begin( ); i != this->m_Filters.end( ); i++ )
- {
- QMenu* newMenu = menu->addMenu( i->first.c_str( ) );
- for( j = i->second.begin( ); j != i->second.end( ); ++j )
- {
- QAction* a = newMenu->addAction( j->c_str( ) );
- QObject::connect( a, SIGNAL( triggered( ) ), obj, slot );
-
- } // rof
-
- } // rof
+ if( this->m_WVTK != NULL ) delete this->m_WVTK;
+ if( this->m_ZVTK != NULL ) delete this->m_ZVTK;
+ if( this->m_YVTK != NULL ) delete this->m_YVTK;
+ if( this->m_XVTK != NULL ) delete this->m_XVTK;
}
// -------------------------------------------------------------------------
bool cpPlugins::Interface::BaseMPRWindow::
-LoadPlugins( const std::string& fname )
+ShowImage( vtkImageData* image )
{
- this->Block( );
-
- // Is it already loaded?
- if( this->m_LoadedPlugins.find( fname ) != this->m_LoadedPlugins.end( ) )
- {
- this->Unblock( );
- return( true );
-
- } // fi
-
- // Was it succesfully loaded?
- if( !( this->m_Interface.Load( fname ) ) )
- {
- this->Unblock( );
- return( false );
-
- } // fi
-
- // Update a simple track
- this->m_LoadedPlugins.insert( fname );
- this->m_LastLoadedPlugin = fname;
- this->_UpdatePlugins( );
-
- this->Unblock( );
- return( true );
+ bool r = ( image != NULL );
+ if( r )
+ this->m_MPRObjects->AddImage( image );
+ return( r );
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWindow::
-LoadPlugins( )
+bool cpPlugins::Interface::BaseMPRWindow::
+ShowImage( vtkImageData* image, double r, double g, double b )
{
- // Load file into a char buffer
- std::ifstream in(
- "Plugins.cfg", std::ios::in | std::ios::binary | std::ios::ate
- );
- if( !in.is_open( ) )
- return;
- std::streampos size = in.tellg( );
- char* buffer = new char[ size ];
- in.seekg( 0, std::ios::beg );
- in.read( buffer, size );
- in.close( );
-
- // Read stream
- std::stringstream in_stream( buffer );
- while( in_stream )
- {
- char line[ 2048 ];
- in_stream.getline( line, 2048 );
- this->LoadPlugins( line );
-
- } // elihw
-
- // Finish
- delete buffer;
+ return( false );
}
// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::BaseMPRWindow::
-LoadImage( )
+bool cpPlugins::Interface::BaseMPRWindow::
+ShowMesh( vtkPolyData* mesh )
{
- std::string msg = "";
- std::string ret = "";
- if( this->m_ImageReader.IsNull( ) )
- msg = "No valid image reader. Please load a valid plugin file.";
-
- if( this->m_ImageReader->ExecConfigurationDialog( this ) )
- {
- this->Block( );
- msg = this->m_ImageReader->Update( );
- if( msg == "" )
- {
- TImage::Pointer image =
- this->m_ImageReader->GetOutput< TImage >( "Output" );
- if( this->m_Images.size( ) == 0 )
- ret = image->GetName( );
- else
- ret = "Segmentation";
- this->m_Images[ ret ] = image;
- this->m_ImageReader->DisconnectOutputs( );
- this->m_ImageReader->GetParameters( )->ClearStringList( "FileNames" );
- vtkImageData* vtk_id = image->GetVTK< vtkImageData >( );
- if( vtk_id != NULL )
- {
- this->m_MPRObjects->AddImage( vtk_id );
- /*
- MementoState(m_state, this->m_Image);
- this->m_state++;
- */
- }
- else
- msg = "Read image does not have a valid VTK converter.";
- }
- else
- ret = "";
-
- } // fi
-
- // Show errors and return
- this->Unblock( );
- if( msg != "" )
- QMessageBox::critical(
- this, tr( "Error reading image." ), tr( msg.c_str( ) )
- );
- return( ret );
+ return( false );
}
// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::BaseMPRWindow::
-LoadDicomSeries( )
-{
- std::string msg = "";
- std::string ret = "";
- if( this->m_DicomSeriesReader.IsNull( ) )
- msg = "No valid DICOM series reader. Please load a valid plugin file.";
-
- if( this->m_DicomSeriesReader->ExecConfigurationDialog( this ) )
+/*
+ void cpPlugins::Interface::BaseMPRWindow::
+ AddImage( const std::string& name, TImage* image )
{
- this->Block( );
- msg = this->m_DicomSeriesReader->Update( );
- if( msg == "" )
- {
- TImage::Pointer image =
- this->m_DicomSeriesReader->GetOutput< TImage >( "Output" );
- if( this->m_Images.size( ) == 0 )
- ret = image->GetName( );
- else
- ret = "Segmentation";
- this->m_Images[ ret ] = image;
- this->m_DicomSeriesReader->DisconnectOutputs( );
- this->m_DicomSeriesReader->GetParameters( )->
- ClearStringList( "FileNames" );
- vtkImageData* vtk_id = image->GetVTK< vtkImageData >( );
- if( vtk_id != NULL )
- {
- this->m_MPRObjects->AddImage( vtk_id );
- /*
- MementoState(m_state, this->m_Image);
- this->m_state++;
- */
- }
- else
- msg = "Read dicom series does not have a valid VTK converter.";
- }
- else
- ret = "";
-
- } // fi
-
- // Show errors and return
- this->Unblock( );
- if( msg != "" )
- QMessageBox::critical(
- this, tr( "Error reading dicom series." ), tr( msg.c_str( ) )
- );
- return( ret );
-}
+ this->m_Images[ name ] = image;
+ vtkImageData* vtk_id =
+ this->m_Images[ name ]->GetVTK< vtkImageData >( );
+ if( vtk_id != NULL )
+ this->m_MPRObjects->AddImage( vtk_id );
+ }
+*/
// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::BaseMPRWindow::
-LoadMesh( )
+double cpPlugins::Interface::BaseMPRWindow::
+GetWindow( ) const
{
- return( "" );
+ return( this->m_MPRObjects->GetWindow( ) );
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWindow::
-ExecuteFilter(
- const std::string& name,
- const std::string& input_id,
- const std::string& output_id
- )
+double cpPlugins::Interface::BaseMPRWindow::
+GetLevel( ) const
{
- TProcessObject::Pointer filter =
- this->m_Interface.CreateProcessObject( name );
- std::string category = filter->GetClassCategory( );
- if( category == "ImageToBinaryImageFilter" )
- {
- TImages::iterator iIt = this->m_Images.find( input_id );
- if( iIt != this->m_Images.end( ) )
- {
- filter->SetInput( "Input", this->m_Images[ input_id ] );
- bool dlg_ok = filter->ExecConfigurationDialog( NULL );
- if( !dlg_ok )
- return;
-
- std::string err = filter->Update( );
- if( err == "" )
- {
- this->m_Images[ "Segmentation" ] =
- filter->GetOutput< TImage >( "Output" );
- filter->DisconnectOutputs( );
-
- vtkImageData* vtk_id =
- this->m_Images[ "Segmentation" ]->GetVTK< vtkImageData >( );
- if( vtk_id != NULL )
- this->m_MPRObjects->AddImage( vtk_id );
- }
- else
- QMessageBox::critical(
- this, tr( "Error with plugin" ), tr( err.c_str( ) )
- );
-
- } // fi
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWindow::
-AddImage( const std::string& name, TImage* image )
-{
- this->m_Images[ name ] = image;
- vtkImageData* vtk_id =
- this->m_Images[ name ]->GetVTK< vtkImageData >( );
- if( vtk_id != NULL )
- this->m_MPRObjects->AddImage( vtk_id );
+ return( this->m_MPRObjects->GetLevel( ) );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::BaseMPRWindow::
ClearAll( )
{
- this->m_MPRObjects->ClearAll( );
- this->m_Images.clear( );
- this->m_Meshes.clear( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::BaseMPRWindow::
-_UpdatePlugins( )
-{
- typedef TInterface::TClasses _C;
-
- this->m_Filters.clear( );
- _C& classes = this->m_Interface.GetClasses( );
- for( _C::const_iterator i = classes.begin( ); i != classes.end( ); ++i )
- {
- TProcessObject::Pointer o =
- this->m_Interface.CreateProcessObject( i->first );
- std::string name = o->GetClassName( );
- std::string category = o->GetClassCategory( );
- if( category == "ImageReader" )
- this->m_ImageReader = o;
- else if( category == "ImageWriter" )
- this->m_ImageWriter = o;
- else if( category == "MeshReader" )
- this->m_MeshReader = o;
- else if( category == "MeshWriter" )
- this->m_MeshWriter = o;
- else if( category == "DicomSeriesReader" )
- this->m_DicomSeriesReader = o;
- else
- this->m_Filters[ category ].insert( name );
-
- /*
- if( category == "ImageReader" )
- this->m_ImageReaderClass = name;
- else if( category == "ImageWriter" )
- this->m_ImageWriterClass = name;
- else if( category == "MeshReader" )
- this->m_MeshReaderClass = name;
- else if( category == "MeshWriter" )
- this->m_MeshWriterClass = name;
- else if( category == "MeshToMeshFilter" )
- {
- if( name.find_last_of( "Cutter" ) != std::string::npos )
- this->m_MeshCutterClass = name;
- }
- else if( category == "ImageToImageFilter" )
- {
- QAction* action =
- this->m_UI->MenuImageToImage->addAction( QString( name.c_str( ) ) );
- QObject::connect(
- action, SIGNAL( triggered( ) ),
- this, SLOT( _triggered_actionImageToImage( ) )
- );
- }
- else if( category == "ImageToMeshFilter" )
- {
- QAction* action =
- this->m_UI->MenuImageToMesh->addAction( QString( name.c_str( ) ) );
- QObject::connect(
- action, SIGNAL( triggered( ) ),
- this, SLOT( _triggered_actionImageToMesh( ) )
- );
-
- } // fi
- */
-
- } // rof
+ /*
+ this->m_MPRObjects->ClearAll( );
+ this->m_Images.clear( );
+ this->m_Meshes.clear( );
+ */
}
#endif // cpPlugins_Interface_QT4