## = Options =
## ===========
-OPTION(BUILD_EXAMPLES "Build demos" OFF)
+## OPTION(BUILD_EXAMPLES "Build demos" OFF)
OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON)
OPTION(BUILD_FINAL_APPLICATION "Build final application" ON)
// -------------------------------------------------------------------------
MainWnd::MainWnd( QWidget* parent )
+{}
+ /*
: QMainWindow( parent ),
m_UI( new Ui::MainWnd ),
m_InputImage( NULL ),
this->m_DoubleClickCommand =
vtkSmartPointer< DoubleClickCommand >::New( );
this->m_DoubleClickCommand->SetMainWnd( this );
- this->m_MPR->AddDoubleClickObserver( this->m_DoubleClickCommand );
+ // this->m_MPR->AddDoubleClickObserver( this->m_DoubleClickCommand );
// Orientation marks
- /* TODO
vtkSmartPointer< vtkAnnotatedCubeActor > oCube =
vtkSmartPointer< vtkAnnotatedCubeActor >::New( );
oCube->GetCubeProperty( )->SetColor( 0.9, 0.7, 0.2 );
SetInteractor( this->m_UI->m_3DVTK->GetInteractor( ) );
this->m_3DOrientationWidget->SetEnabled( 1 );
this->m_3DOrientationWidget->InteractiveOff( );
- */
// Qt signals <-> slots
IDMS_QT_ACTION( ReloadPlugins );
// Start: load all disponible plugins
this->_triggered_actionReloadPlugins( );
}
-
+*/
// -------------------------------------------------------------------------
MainWnd::
~MainWnd( )
{
- // Close all connections
- this->m_Plugins.UnloadAll( );
-
- // Delete objects
- delete this->m_UI;
- delete this->m_MPR;
- if( this->m_ActiveParameters != NULL )
- {
- this->m_ActiveParameters->close( );
- delete this->m_ActiveParameters;
-
- } // fi
- if( this->m_ActivePlugin != NULL ) delete this->m_ActivePlugin;
- if( this->m_InputImage != NULL ) delete this->m_InputImage;
- if( this->m_SegmentedImage != NULL ) delete this->m_SegmentedImage;
+// // Close all connections
+// this->m_Plugins.UnloadAll( );
+
+// // Delete objects
+// delete this->m_UI;
+// // delete this->m_MPR;
+// if( this->m_ActiveParameters != NULL )
+// {
+// this->m_ActiveParameters->close( );
+// delete this->m_ActiveParameters;
+
+// } // fi
+// if( this->m_ActivePlugin != NULL ) delete this->m_ActivePlugin;
+// if( this->m_InputImage != NULL ) delete this->m_InputImage;
+// if( this->m_SegmentedImage != NULL ) delete this->m_SegmentedImage;
}
// -------------------------------------------------------------------------
void MainWnd::
_LoadApplicationPreferences( )
{
- this->m_ApplicationPreferences.clear( );
- std::ifstream in( this->m_ApplicationPreferencesFile.c_str( ) );
- if( in )
- {
- std::string line;
- std::getline( in, line );
- while( !( in.eof( ) ) )
- {
- long pos = line.find_last_of( "=" );
- std::string key = line.substr( 0, pos );
- std::string value = line.substr( pos + 1 );
- key.erase(
- std::remove_if( key.begin( ), key.end( ), isspace ), key.end( )
- );
- value.erase(
- std::remove_if( value.begin( ), value.end( ), isspace ), value.end( )
- );
- this->m_ApplicationPreferences[ key ] = value;
- std::getline( in, line );
-
- } // elihw
- }
- else
- {
- this->m_ApplicationPreferences[ "data_dimensions" ] = "3";
- this->m_ApplicationPreferences[ "input_image_type" ] = "short";
- this->m_ApplicationPreferences[ "segmented_image_type" ] = "uchar";
- this->m_ApplicationPreferences[ "mesh_type" ] = "double";
-
- } // fi
- in.close( );
+// this->m_ApplicationPreferences.clear( );
+// std::ifstream in( this->m_ApplicationPreferencesFile.c_str( ) );
+// if( in )
+// {
+// std::string line;
+// std::getline( in, line );
+// while( !( in.eof( ) ) )
+// {
+// long pos = line.find_last_of( "=" );
+// std::string key = line.substr( 0, pos );
+// std::string value = line.substr( pos + 1 );
+// key.erase(
+// std::remove_if( key.begin( ), key.end( ), isspace ), key.end( )
+// );
+// value.erase(
+// std::remove_if( value.begin( ), value.end( ), isspace ), value.end( )
+// );
+// this->m_ApplicationPreferences[ key ] = value;
+// std::getline( in, line );
+
+// } // elihw
+// }
+// else
+// {
+// this->m_ApplicationPreferences[ "data_dimensions" ] = "3";
+// this->m_ApplicationPreferences[ "input_image_type" ] = "short";
+// this->m_ApplicationPreferences[ "segmented_image_type" ] = "uchar";
+// this->m_ApplicationPreferences[ "mesh_type" ] = "double";
+
+// } // fi
+// in.close( );
}
// -------------------------------------------------------------------------
TPluginImage* MainWnd::
_LoadImage( const std::string& image_type, const std::string& image_dim )
{
- // Show dialog and check if it was accepted
- QFileDialog dialog( this );
- dialog.setFileMode( QFileDialog::ExistingFiles );
- dialog.setDirectory( tr( this->m_LastOpenedFile.c_str( ) ) );
- dialog.setNameFilter(
- tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
- );
- dialog.setDefaultSuffix( tr( "mhd" ) );
- if( !( dialog.exec( ) ) )
- return( NULL );
-
- TPluginImage* ret = NULL;
- unsigned int nFiles = dialog.selectedFiles( ).size( );
- if( nFiles == 1 )
- {
- if( this->m_BaseClasses[ "ImageReader" ] == "" )
- {
- QMessageBox::critical(
- this,
- tr( "No plugin to read a single image file found!" ),
- tr( "No plugin to read a single image file found!" )
- );
- return( ret );
-
- } // fi
-
- std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
- this->m_LastOpenedFile = fname;
-
- TPlugin* reader =
- dynamic_cast< TPlugin* >(
- this->m_Plugins.CreateObject( this->m_BaseClasses[ "ImageReader" ] )
- );
-
- TParameters reader_params = reader->GetDefaultParameters( );
- reader_params[ "FileName" ].second = fname;
- reader_params[ "PixelType" ].second = image_type;
- reader_params[ "ImageDimension" ].second = image_dim;
- reader_params[ "IsColorImage" ].second = "0";
- reader->SetParameters( reader_params );
- std::string err = reader->Update( );
-
- if( err == "" )
- {
- ret = dynamic_cast< TPluginImage* >( reader->GetOutput( 0 ) );
- reader->DisconnectOutputs( );
- }
- else
- QMessageBox::critical(
- this,
- tr( "Error reading single image" ),
- tr( err.c_str( ) )
- );
- delete reader;
- }
- else if( nFiles > 1 )
- {
- /* TODO
- if( this->m_ImageSeriesReaderClassName == "" )
- {
- QMessageBox::critical(
- this,
- tr( "No plugin to read an image series found!" ),
- tr( "No plugin to read an image series found!" )
- );
- return( ret );
-
- } // fi
- std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
- this->m_LastOpenedFile = fname;
- */
-
- } // fi
- return( ret );
+// // Show dialog and check if it was accepted
+// QFileDialog dialog( this );
+// dialog.setFileMode( QFileDialog::ExistingFiles );
+// dialog.setDirectory( tr( this->m_LastOpenedFile.c_str( ) ) );
+// dialog.setNameFilter(
+// tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
+// );
+// dialog.setDefaultSuffix( tr( "mhd" ) );
+// if( !( dialog.exec( ) ) )
+// return( NULL );
+
+// TPluginImage* ret = NULL;
+// unsigned int nFiles = dialog.selectedFiles( ).size( );
+// if( nFiles == 1 )
+// {
+// if( this->m_BaseClasses[ "ImageReader" ] == "" )
+// {
+// QMessageBox::critical(
+// this,
+// tr( "No plugin to read a single image file found!" ),
+// tr( "No plugin to read a single image file found!" )
+// );
+// return( ret );
+
+// } // fi
+
+// std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
+// this->m_LastOpenedFile = fname;
+
+// TPlugin* reader =
+// dynamic_cast< TPlugin* >(
+// this->m_Plugins.CreateObject( this->m_BaseClasses[ "ImageReader" ] )
+// );
+
+// TParameters reader_params = reader->GetDefaultParameters( );
+// reader_params[ "FileName" ].second = fname;
+// reader_params[ "PixelType" ].second = image_type;
+// reader_params[ "ImageDimension" ].second = image_dim;
+// reader_params[ "IsColorImage" ].second = "0";
+// reader->SetParameters( reader_params );
+// std::string err = reader->Update( );
+
+// if( err == "" )
+// {
+// ret = dynamic_cast< TPluginImage* >( reader->GetOutput( 0 ) );
+// reader->DisconnectOutputs( );
+// }
+// else
+// QMessageBox::critical(
+// this,
+// tr( "Error reading single image" ),
+// tr( err.c_str( ) )
+// );
+// delete reader;
+// }
+// else if( nFiles > 1 )
+// {
+// /* TODO
+// if( this->m_ImageSeriesReaderClassName == "" )
+// {
+// QMessageBox::critical(
+// this,
+// tr( "No plugin to read an image series found!" ),
+// tr( "No plugin to read an image series found!" )
+// );
+// return( ret );
+
+// } // fi
+// std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
+// this->m_LastOpenedFile = fname;
+// */
+
+// } // fi
+// return( ret );
}
// -------------------------------------------------------------------------
void MainWnd::
_UpdateEnabledFlags( )
{
- bool img = ( this->m_InputImage != NULL );
- this->m_UI->menuSegmentInputImage->setEnabled( img );
- this->m_UI->actionOpenSegmentedImage->setEnabled( img );
- this->m_UI->m_3DVTK->setEnabled( img );
- this->m_UI->m_XPlaneVTK->setEnabled( img );
- this->m_UI->m_YPlaneVTK->setEnabled( img );
- this->m_UI->m_ZPlaneVTK->setEnabled( img );
- this->m_UI->m_AuxVTK->setEnabled( img );
-
- bool seg = ( this->m_SegmentedImage != NULL );
- this->m_UI->menuFilterSegmentedImage->setEnabled( seg );
- this->m_UI->menuExtractMesh->setEnabled( seg );
- this->m_UI->menuProcessMesh->setEnabled( seg );
- this->m_UI->actionOpenMesh->setEnabled( seg );
-
- this->m_UI->actionNavigation->setEnabled( img && seg );
- this->m_UI->actionSegmentationInteractiveDeformation->
- setEnabled( img && seg );
+// bool img = ( this->m_InputImage != NULL );
+// this->m_UI->menuSegmentInputImage->setEnabled( img );
+// this->m_UI->actionOpenSegmentedImage->setEnabled( img );
+// this->m_UI->m_3DVTK->setEnabled( img );
+// this->m_UI->m_XPlaneVTK->setEnabled( img );
+// this->m_UI->m_YPlaneVTK->setEnabled( img );
+// this->m_UI->m_ZPlaneVTK->setEnabled( img );
+// this->m_UI->m_AuxVTK->setEnabled( img );
+
+// bool seg = ( this->m_SegmentedImage != NULL );
+// this->m_UI->menuFilterSegmentedImage->setEnabled( seg );
+// this->m_UI->menuExtractMesh->setEnabled( seg );
+// this->m_UI->menuProcessMesh->setEnabled( seg );
+// this->m_UI->actionOpenMesh->setEnabled( seg );
+
+// this->m_UI->actionNavigation->setEnabled( img && seg );
+// this->m_UI->actionSegmentationInteractiveDeformation->
+// setEnabled( img && seg );
}
// -------------------------------------------------------------------------
void MainWnd::
_triggered_actionReloadPlugins( )
{
- if( !( this->_LoadPlugins( ) ) )
- {
- QMessageBox::critical(
- this,
- tr( "Could not load plugins from given file." ),
- tr( "Could not load plugins from given file." )
- );
-
- } // fi
- this->_UpdateEnabledFlags( );
+// if( !( this->_LoadPlugins( ) ) )
+// {
+// QMessageBox::critical(
+// this,
+// tr( "Could not load plugins from given file." ),
+// tr( "Could not load plugins from given file." )
+// );
+
+// } // fi
+// this->_UpdateEnabledFlags( );
}
// -------------------------------------------------------------------------
void MainWnd::
_triggered_actionOpenInputImage( )
{
- if( this->m_InputImage != NULL )
- delete this->m_InputImage;
- this->m_InputImage =
- this->_LoadImage(
- this->m_ApplicationPreferences[ "input_image_type" ],
- this->m_ApplicationPreferences[ "data_dimensions" ]
- );
- if( this->m_InputImage != NULL )
- {
- this->m_MPR->SetImage( this->m_InputImage->GetVTKImageData( ) );
-
- // Update activations
- this->_UpdateEnabledFlags( );
- this->m_UI->actionNavigation->setChecked( true );
- this->_triggered_actionSwitchMode( );
-
- } // fi
+// if( this->m_InputImage != NULL )
+// delete this->m_InputImage;
+// this->m_InputImage =
+// this->_LoadImage(
+// this->m_ApplicationPreferences[ "input_image_type" ],
+// this->m_ApplicationPreferences[ "data_dimensions" ]
+// );
+// if( this->m_InputImage != NULL )
+// {
+// // this->m_MPR->SetImage( this->m_InputImage->GetVTKImageData( ) );
+
+// // Update activations
+// this->_UpdateEnabledFlags( );
+// this->m_UI->actionNavigation->setChecked( true );
+// this->_triggered_actionSwitchMode( );
+
+// } // fi
}
// -------------------------------------------------------------------------
void MainWnd::
_triggered_actionOpenSegmentedImage( )
{
- if( this->m_SegmentedImage != NULL )
- delete this->m_SegmentedImage;
- this->m_SegmentedImage =
- this->_LoadImage(
- this->m_ApplicationPreferences[ "segmented_image_type" ],
- this->m_ApplicationPreferences[ "data_dimensions" ]
- );
- if( this->m_SegmentedImage != NULL )
- {
- this->m_MPR->SetSegmentation(
- this->m_SegmentedImage->GetVTKImageData( )
- );
- /* TODO
- cpPlugins::Interface::Image* img =
- dynamic_cast< cpPlugins::Interface::Image* >( this->m_SegmentedImage );
- this->m_ImageActors->SetSegmentation( img->GetVTKImageData( ) );
- */
-
- // Ok, start!
- this->m_MPR->Render( 0 );
- this->m_MPR->Render( 1 );
- this->m_MPR->Render( 2 );
- this->_UpdateEnabledFlags( );
-
- } // fi
+// if( this->m_SegmentedImage != NULL )
+// delete this->m_SegmentedImage;
+// this->m_SegmentedImage =
+// this->_LoadImage(
+// this->m_ApplicationPreferences[ "segmented_image_type" ],
+// this->m_ApplicationPreferences[ "data_dimensions" ]
+// );
+// if( this->m_SegmentedImage != NULL )
+// {
+// /*
+// this->m_MPR->SetSegmentation(
+// this->m_SegmentedImage->GetVTKImageData( )
+// );
+// */
+// /* TODO
+// cpPlugins::Interface::Image* img =
+// dynamic_cast< cpPlugins::Interface::Image* >( this->m_SegmentedImage );
+// this->m_ImageActors->SetSegmentation( img->GetVTKImageData( ) );
+// */
+
+// // Ok, start!
+// /*
+// this->m_MPR->Render( 0 );
+// this->m_MPR->Render( 1 );
+// this->m_MPR->Render( 2 );
+// */
+// this->_UpdateEnabledFlags( );
+
+// } // fi
}
// -------------------------------------------------------------------------
void MainWnd::
_triggered_actionSwitchMode( )
{
- QAction* snd = dynamic_cast< QAction* >( this->sender( ) );
- if( snd == this->m_UI->actionNavigation )
- {
- this->m_UI->actionSegmentationInteractiveDeformation->setChecked(
- !( this->m_UI->actionNavigation->isChecked( ) )
- );
- }
- else if( snd == this->m_UI->actionSegmentationInteractiveDeformation )
- {
- this->m_UI->actionNavigation->setChecked(
- !( this->m_UI->actionSegmentationInteractiveDeformation->isChecked( ) )
- );
- }
- else
- {
- this->m_UI->actionNavigation->setChecked( true );
- this->m_UI->actionSegmentationInteractiveDeformation->setChecked( false );
-
- } // fi
-
- /* TODO
- if( this->m_UI->aNavigation->isChecked( ) )
- {
- this->m_XStyle->SetModeToNavigation( );
- this->m_YStyle->SetModeToNavigation( );
- this->m_ZStyle->SetModeToNavigation( );
- this->m_ImageActors->HideRegion( 0 );
- this->m_ImageActors->HideRegion( 1 );
- this->m_ImageActors->HideRegion( 2 );
- this->m_3DRenderer->RemoveActor(
- this->m_ImageActors->GetCursorActor( )
- );
- this->m_3DRenderer->RemoveActor(
- this->m_ImageActors->GetRegionActor( )
- );
- this->m_UI->m_3DVTK->GetRenderWindow( )->Render( );
- }
- else if( this->m_UI->aSegmentationInteractiveDeformation->isChecked( ) )
- {
- this->m_XStyle->SetModeToDeformation( );
- this->m_YStyle->SetModeToDeformation( );
- this->m_ZStyle->SetModeToDeformation( );
- this->m_ImageActors->ShowRegion( 0 );
- this->m_ImageActors->ShowRegion( 1 );
- this->m_ImageActors->ShowRegion( 2 );
- this->m_3DRenderer->AddActor(
- this->m_ImageActors->GetCursorActor( )
- );
- this->m_3DRenderer->AddActor(
- this->m_ImageActors->GetRegionActor( )
- );
- this->m_UI->m_3DVTK->GetRenderWindow( )->Render( );
-
- } // fi
- */
+// QAction* snd = dynamic_cast< QAction* >( this->sender( ) );
+// if( snd == this->m_UI->actionNavigation )
+// {
+// this->m_UI->actionSegmentationInteractiveDeformation->setChecked(
+// !( this->m_UI->actionNavigation->isChecked( ) )
+// );
+// }
+// else if( snd == this->m_UI->actionSegmentationInteractiveDeformation )
+// {
+// this->m_UI->actionNavigation->setChecked(
+// !( this->m_UI->actionSegmentationInteractiveDeformation->isChecked( ) )
+// );
+// }
+// else
+// {
+// this->m_UI->actionNavigation->setChecked( true );
+// this->m_UI->actionSegmentationInteractiveDeformation->setChecked( false );
+
+// } // fi
+
+// /* TODO
+// if( this->m_UI->aNavigation->isChecked( ) )
+// {
+// this->m_XStyle->SetModeToNavigation( );
+// this->m_YStyle->SetModeToNavigation( );
+// this->m_ZStyle->SetModeToNavigation( );
+// this->m_ImageActors->HideRegion( 0 );
+// this->m_ImageActors->HideRegion( 1 );
+// this->m_ImageActors->HideRegion( 2 );
+// this->m_3DRenderer->RemoveActor(
+// this->m_ImageActors->GetCursorActor( )
+// );
+// this->m_3DRenderer->RemoveActor(
+// this->m_ImageActors->GetRegionActor( )
+// );
+// this->m_UI->m_3DVTK->GetRenderWindow( )->Render( );
+// }
+// else if( this->m_UI->aSegmentationInteractiveDeformation->isChecked( ) )
+// {
+// this->m_XStyle->SetModeToDeformation( );
+// this->m_YStyle->SetModeToDeformation( );
+// this->m_ZStyle->SetModeToDeformation( );
+// this->m_ImageActors->ShowRegion( 0 );
+// this->m_ImageActors->ShowRegion( 1 );
+// this->m_ImageActors->ShowRegion( 2 );
+// this->m_3DRenderer->AddActor(
+// this->m_ImageActors->GetCursorActor( )
+// );
+// this->m_3DRenderer->AddActor(
+// this->m_ImageActors->GetRegionActor( )
+// );
+// this->m_UI->m_3DVTK->GetRenderWindow( )->Render( );
+
+// } // fi
+// */
}
// -------------------------------------------------------------------------
#include <cpPlugins/Interface/ProcessObject.h>
#include <cpPlugins/Interface/Image.h>
#include <cpPlugins/Interface/DataObject.h>
-#include <cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.h>
+// #include <cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.h>
// -------------------------------------------------------------------------
class MainWnd;
typedef cpPlugins::Interface::Image TPluginImage;
typedef cpPlugins::Interface::ProcessObject TPlugin;
typedef cpPlugins::Interface::Parameters TParameters;
- typedef cpPlugins::Extensions::Visualization::MPRWithDifferentWindows TMPR;
+ // typedef cpPlugins::Extensions::Visualization::MPRWithDifferentWindows TMPR;
typedef std::map< std::string, std::string > TStringMap;
*/
private:
+ /*
Ui::MainWnd* m_UI;
// Application preferences
TPluginImage* m_SegmentedImage;
// Visualization stuff
- TMPR* m_MPR;
+ // TMPR* m_MPR;
// Active plugin
TPlugin* m_ActivePlugin;
Self::PluginCategory m_ActivePluginCategory;
vtkSmartPointer< DoubleClickCommand > m_DoubleClickCommand;
+ */
};
#endif // __MAINWND__H__
bool MainWnd::
_ParametersDialog( const TParameters& parameters )
{
- if( this->m_ActiveParameters != NULL )
- this->m_ActiveParameters->close( );
- this->m_ActiveParameters = new QWidget( NULL );
- this->m_ActiveParameters->setWindowFlags( Qt::FramelessWindowHint );
- this->m_ActiveParameters->setWindowFlags( Qt::WindowTitleHint );
-
- QGridLayout* gridLayout = new QGridLayout( this->m_ActiveParameters );
- QVBoxLayout* verticalLayout = new QVBoxLayout( );
-
- // Put values
- QLabel* title = new QLabel( this->m_ActiveParameters );
- title->setText( this->m_ActivePlugin->GetClassName( ).c_str( ) );
- verticalLayout->addWidget( title );
-
- TParameters::const_iterator pIt = parameters.begin( );
- for( ; pIt != parameters.end( ); ++pIt )
- {
- std::string par_name = pIt->first;
- std::string par_type = pIt->second.first;
- std::string par_value = pIt->second.second;
-
- if( par_type == "double" )
- {
- QHBoxLayout* horizontalLayout = new QHBoxLayout( );
- QLabel* label = new QLabel( this->m_ActiveParameters );
- label->setText( QString( par_name.c_str( ) ) );
- horizontalLayout->addWidget( label );
-
- QDoubleSpinBox* v_double =
- new QDoubleSpinBox( this->m_ActiveParameters );
- v_double->setDecimals( 3 );
- v_double->setMinimum( -( std::numeric_limits< double >::max( ) ) );
- v_double->setMaximum( std::numeric_limits< double >::max( ) );
- v_double->setValue( std::atof( par_value.c_str( ) ) );
- v_double->setObjectName( QString( par_name.c_str( ) ) );
- horizontalLayout->addWidget( v_double );
- verticalLayout->addLayout( horizontalLayout );
-
- } // fi
-
- } // rof
- gridLayout->addLayout( verticalLayout, 0, 0, 1, 1 );
-
- // Infere plugin type
- TParameters::const_iterator seedIt = parameters.find( "Seed" );
- TParameters::const_iterator radiusIt = parameters.find( "Radius" );
- TParameters::const_iterator endIt = parameters.end( );
- if( seedIt == endIt && radiusIt == endIt )
- this->m_ActivePluginType = Self::GlobalPluginType;
- else if( seedIt != endIt && radiusIt == endIt )
- this->m_ActivePluginType = Self::DoubleClickPluginType;
- else if( seedIt != endIt && radiusIt != endIt )
- this->m_ActivePluginType = Self::SpherePluginType;
- else
- this->m_ActivePluginType = Self::NonePluginType;
-
- QMetaObject::connectSlotsByName( this->m_ActiveParameters );
- this->m_ActiveParameters->show( );
-
- return( false );
+// if( this->m_ActiveParameters != NULL )
+// this->m_ActiveParameters->close( );
+// this->m_ActiveParameters = new QWidget( NULL );
+// this->m_ActiveParameters->setWindowFlags( Qt::FramelessWindowHint );
+// this->m_ActiveParameters->setWindowFlags( Qt::WindowTitleHint );
+
+// QGridLayout* gridLayout = new QGridLayout( this->m_ActiveParameters );
+// QVBoxLayout* verticalLayout = new QVBoxLayout( );
+
+// // Put values
+// QLabel* title = new QLabel( this->m_ActiveParameters );
+// title->setText( this->m_ActivePlugin->GetClassName( ).c_str( ) );
+// verticalLayout->addWidget( title );
+
+// TParameters::const_iterator pIt = parameters.begin( );
+// for( ; pIt != parameters.end( ); ++pIt )
+// {
+// std::string par_name = pIt->first;
+// std::string par_type = pIt->second.first;
+// std::string par_value = pIt->second.second;
+
+// if( par_type == "double" )
+// {
+// QHBoxLayout* horizontalLayout = new QHBoxLayout( );
+// QLabel* label = new QLabel( this->m_ActiveParameters );
+// label->setText( QString( par_name.c_str( ) ) );
+// horizontalLayout->addWidget( label );
+
+// QDoubleSpinBox* v_double =
+// new QDoubleSpinBox( this->m_ActiveParameters );
+// v_double->setDecimals( 3 );
+// v_double->setMinimum( -( std::numeric_limits< double >::max( ) ) );
+// v_double->setMaximum( std::numeric_limits< double >::max( ) );
+// v_double->setValue( std::atof( par_value.c_str( ) ) );
+// v_double->setObjectName( QString( par_name.c_str( ) ) );
+// horizontalLayout->addWidget( v_double );
+// verticalLayout->addLayout( horizontalLayout );
+
+// } // fi
+
+// } // rof
+// gridLayout->addLayout( verticalLayout, 0, 0, 1, 1 );
+
+// // Infere plugin type
+// TParameters::const_iterator seedIt = parameters.find( "Seed" );
+// TParameters::const_iterator radiusIt = parameters.find( "Radius" );
+// TParameters::const_iterator endIt = parameters.end( );
+// if( seedIt == endIt && radiusIt == endIt )
+// this->m_ActivePluginType = Self::GlobalPluginType;
+// else if( seedIt != endIt && radiusIt == endIt )
+// this->m_ActivePluginType = Self::DoubleClickPluginType;
+// else if( seedIt != endIt && radiusIt != endIt )
+// this->m_ActivePluginType = Self::SpherePluginType;
+// else
+// this->m_ActivePluginType = Self::NonePluginType;
+
+// QMetaObject::connectSlotsByName( this->m_ActiveParameters );
+// this->m_ActiveParameters->show( );
+
+// return( false );
}
// -------------------------------------------------------------------------
void MainWnd::
_ExecuteDoubleClickPlugin( const double* pnt )
{
- if(
- this->m_InputImage == NULL ||
- this->m_SegmentedImage == NULL ||
- this->m_ActivePlugin == NULL ||
- this->m_ActiveParameters == NULL ||
- this->m_ActivePluginType != Self::DoubleClickPluginType
- )
- return;
-
- TParameters parameters = this->m_ActivePlugin->GetDefaultParameters( );
-
- // Variable parameters
- for(
- TParameters::iterator pIt = parameters.begin( );
- pIt != parameters.end( );
- ++pIt
- )
- {
- if( pIt->first != "Seed" )
- {
- if( pIt->second.first == "double" )
- {
- QDoubleSpinBox* v_double = this->m_ActiveParameters->
- findChild< QDoubleSpinBox* >( pIt->first.c_str( ) );
- if( v_double != NULL )
- parameters[ pIt->first ] =
- TParameter( "double", v_double->text( ).toStdString( ) );
+// if(
+// this->m_InputImage == NULL ||
+// this->m_SegmentedImage == NULL ||
+// this->m_ActivePlugin == NULL ||
+// this->m_ActiveParameters == NULL ||
+// this->m_ActivePluginType != Self::DoubleClickPluginType
+// )
+// return;
+
+// TParameters parameters = this->m_ActivePlugin->GetDefaultParameters( );
+
+// // Variable parameters
+// for(
+// TParameters::iterator pIt = parameters.begin( );
+// pIt != parameters.end( );
+// ++pIt
+// )
+// {
+// if( pIt->first != "Seed" )
+// {
+// if( pIt->second.first == "double" )
+// {
+// QDoubleSpinBox* v_double = this->m_ActiveParameters->
+// findChild< QDoubleSpinBox* >( pIt->first.c_str( ) );
+// if( v_double != NULL )
+// parameters[ pIt->first ] =
+// TParameter( "double", v_double->text( ).toStdString( ) );
- } // fi
-
- } // fi
-
- } // rof
-
- // Seed
- std::stringstream seed_str;
- seed_str << pnt[ 0 ] << ":" << pnt[ 1 ] << ":" << pnt[ 2 ];
- parameters[ "Seed" ] = TParameter( "point", seed_str.str( ) );
-
- // Execute
- this->m_ActivePlugin->SetParameters( parameters );
- this->m_ActivePlugin->SetInput( 0, this->m_InputImage );
- this->m_ActivePlugin->SetInput( 1, this->m_SegmentedImage );
- std::string err = this->m_ActivePlugin->Update( );
- if( err != "" )
- {
- QMessageBox::critical( this, tr( "Error caugth!" ), tr( err.c_str( ) ) );
- return;
-
- } // fi
-
- // Join results
- itk::DataObject* s = this->m_SegmentedImage->GetDataObject( );
- if( dynamic_cast< itk::Image< char, 3 >* >( s ) != NULL )
- this->_JoinSegmentations< char >( );
- else if( dynamic_cast< itk::Image< short, 3 >* >( s ) != NULL )
- this->_JoinSegmentations< short >( );
- else if( dynamic_cast< itk::Image< int, 3 >* >( s ) != NULL )
- this->_JoinSegmentations< int >( );
- else if( dynamic_cast< itk::Image< long, 3 >* >( s ) != NULL )
- this->_JoinSegmentations< long >( );
- else if( dynamic_cast< itk::Image< unsigned char, 3 >* >( s ) != NULL )
- this->_JoinSegmentations< unsigned char >( );
- else if( dynamic_cast< itk::Image< unsigned short, 3 >* >( s ) != NULL )
- this->_JoinSegmentations< unsigned short >( );
- else if( dynamic_cast< itk::Image< unsigned int, 3 >* >( s ) != NULL )
- this->_JoinSegmentations< unsigned int >( );
- else if( dynamic_cast< itk::Image< unsigned long, 3 >* >( s ) != NULL )
- this->_JoinSegmentations< unsigned long >( );
-
- // Update visualization
- this->m_SegmentedImage->UpdateVTKImageData( );
- this->m_MPR->Render( 0 );
- this->m_MPR->Render( 1 );
- this->m_MPR->Render( 2 );
+// } // fi
+
+// } // fi
+
+// } // rof
+
+// // Seed
+// std::stringstream seed_str;
+// seed_str << pnt[ 0 ] << ":" << pnt[ 1 ] << ":" << pnt[ 2 ];
+// parameters[ "Seed" ] = TParameter( "point", seed_str.str( ) );
+
+// // Execute
+// this->m_ActivePlugin->SetParameters( parameters );
+// this->m_ActivePlugin->SetInput( 0, this->m_InputImage );
+// this->m_ActivePlugin->SetInput( 1, this->m_SegmentedImage );
+// std::string err = this->m_ActivePlugin->Update( );
+// if( err != "" )
+// {
+// QMessageBox::critical( this, tr( "Error caugth!" ), tr( err.c_str( ) ) );
+// return;
+
+// } // fi
+
+// // Join results
+// itk::DataObject* s = this->m_SegmentedImage->GetDataObject( );
+// if( dynamic_cast< itk::Image< char, 3 >* >( s ) != NULL )
+// this->_JoinSegmentations< char >( );
+// else if( dynamic_cast< itk::Image< short, 3 >* >( s ) != NULL )
+// this->_JoinSegmentations< short >( );
+// else if( dynamic_cast< itk::Image< int, 3 >* >( s ) != NULL )
+// this->_JoinSegmentations< int >( );
+// else if( dynamic_cast< itk::Image< long, 3 >* >( s ) != NULL )
+// this->_JoinSegmentations< long >( );
+// else if( dynamic_cast< itk::Image< unsigned char, 3 >* >( s ) != NULL )
+// this->_JoinSegmentations< unsigned char >( );
+// else if( dynamic_cast< itk::Image< unsigned short, 3 >* >( s ) != NULL )
+// this->_JoinSegmentations< unsigned short >( );
+// else if( dynamic_cast< itk::Image< unsigned int, 3 >* >( s ) != NULL )
+// this->_JoinSegmentations< unsigned int >( );
+// else if( dynamic_cast< itk::Image< unsigned long, 3 >* >( s ) != NULL )
+// this->_JoinSegmentations< unsigned long >( );
+
+// // Update visualization
+// this->m_SegmentedImage->UpdateVTKImageData( );
+// this->m_MPR->Render( 0 );
+// this->m_MPR->Render( 1 );
+// this->m_MPR->Render( 2 );
}
// -------------------------------------------------------------------------
void MainWnd::
_triggered_actionFilterSegmentation( )
{
- // Get filter name
- if( this->m_SegmentedImage == NULL )
- return;
- QAction* action = dynamic_cast< QAction* >( this->sender( ) );
- if( action == NULL )
- return;
- std::string filter_name = action->text( ).toStdString( );
-
- // Create plugin
- if( this->m_ActivePlugin != NULL ) delete this->m_ActivePlugin;
- this->m_ActivePlugin =
- dynamic_cast< TPlugin* >(
- this->m_Plugins.CreateObject(
- this->m_SegmentationFilterClasses[ filter_name ]
- )
- );
- this->m_ActivePluginCategory = Self::SegmentationFilteringPluginCategory;
-
- // Show parameters dialog
- this->_ParametersDialog( this->m_ActivePlugin->GetDefaultParameters( ) );
+// // Get filter name
+// if( this->m_SegmentedImage == NULL )
+// return;
+// QAction* action = dynamic_cast< QAction* >( this->sender( ) );
+// if( action == NULL )
+// return;
+// std::string filter_name = action->text( ).toStdString( );
+
+// // Create plugin
+// if( this->m_ActivePlugin != NULL ) delete this->m_ActivePlugin;
+// this->m_ActivePlugin =
+// dynamic_cast< TPlugin* >(
+// this->m_Plugins.CreateObject(
+// this->m_SegmentationFilterClasses[ filter_name ]
+// )
+// );
+// this->m_ActivePluginCategory = Self::SegmentationFilteringPluginCategory;
+
+// // Show parameters dialog
+// this->_ParametersDialog( this->m_ActivePlugin->GetDefaultParameters( ) );
}
// -------------------------------------------------------------------------
void MainWnd::
_JoinSegmentations( )
{
- typedef itk::Image< P, 3 > _TImage;
-
- _TImage* old_segmentation =
- dynamic_cast< _TImage* >( this->m_SegmentedImage->GetDataObject( ) );
- _TImage* new_segmentation =
- dynamic_cast< _TImage* >(
- dynamic_cast< TPluginImage* >(
- this->m_ActivePlugin->GetOutput( 0 )
- )->GetDataObject( )
- );
-
- /* TODO: InPlaceOn does not execute correctly on input image
- typedef itk::AndImageFilter< _TImage, _TImage, _TImage > _TFilter;
- typename _TFilter::Pointer filter = _TFilter::New( );
- filter->InPlaceOn( );
- filter->SetInput( 0, old_segmentation );
- filter->SetInput( 1, new_segmentation );
- filter->Update( );
- //old_segmentation->DisconnectPipeline( );
-
- std::cout << old_segmentation->GetRequestedRegion( ) << std::endl;
- std::cout << new_segmentation->GetRequestedRegion( ) << std::endl;
- std::cout << old_segmentation->GetBufferedRegion( ) << std::endl;
- std::cout << new_segmentation->GetBufferedRegion( ) << std::endl;
- */
- typedef itk::ImageRegionConstIterator< _TImage > _TConstIt;
- typedef itk::ImageRegionIterator< _TImage > _TIt;
- _TConstIt nIt( new_segmentation, new_segmentation->GetRequestedRegion( ) );
- _TIt oIt( old_segmentation, old_segmentation->GetRequestedRegion( ) );
- nIt.GoToBegin( );
- oIt.GoToBegin( );
- for( ; !nIt.IsAtEnd( ); ++nIt, ++oIt )
- oIt.Set( nIt.Get( ) | oIt.Get( ) );
+// typedef itk::Image< P, 3 > _TImage;
+
+// _TImage* old_segmentation =
+// dynamic_cast< _TImage* >( this->m_SegmentedImage->GetDataObject( ) );
+// _TImage* new_segmentation =
+// dynamic_cast< _TImage* >(
+// dynamic_cast< TPluginImage* >(
+// this->m_ActivePlugin->GetOutput( 0 )
+// )->GetDataObject( )
+// );
+
+// /* TODO: InPlaceOn does not execute correctly on input image
+// typedef itk::AndImageFilter< _TImage, _TImage, _TImage > _TFilter;
+// typename _TFilter::Pointer filter = _TFilter::New( );
+// filter->InPlaceOn( );
+// filter->SetInput( 0, old_segmentation );
+// filter->SetInput( 1, new_segmentation );
+// filter->Update( );
+// //old_segmentation->DisconnectPipeline( );
+
+// std::cout << old_segmentation->GetRequestedRegion( ) << std::endl;
+// std::cout << new_segmentation->GetRequestedRegion( ) << std::endl;
+// std::cout << old_segmentation->GetBufferedRegion( ) << std::endl;
+// std::cout << new_segmentation->GetBufferedRegion( ) << std::endl;
+// */
+// typedef itk::ImageRegionConstIterator< _TImage > _TConstIt;
+// typedef itk::ImageRegionIterator< _TImage > _TIt;
+// _TConstIt nIt( new_segmentation, new_segmentation->GetRequestedRegion( ) );
+// _TIt oIt( old_segmentation, old_segmentation->GetRequestedRegion( ) );
+// nIt.GoToBegin( );
+// oIt.GoToBegin( );
+// for( ; !nIt.IsAtEnd( ); ++nIt, ++oIt )
+// oIt.Set( nIt.Get( ) | oIt.Get( ) );
}
// -------------------------------------------------------------------------
DoubleClickCommand* DoubleClickCommand::
New( )
{
- return( new DoubleClickCommand( ) );
+// return( new DoubleClickCommand( ) );
}
// -------------------------------------------------------------------------
void DoubleClickCommand::
SetMainWnd( MainWnd* wnd )
{
- this->m_MainWnd = wnd;
+// this->m_MainWnd = wnd;
}
// -------------------------------------------------------------------------
void DoubleClickCommand::
Execute( vtkObject* caller, unsigned long eid, void* data )
{
- if( this->m_MainWnd != NULL )
- this->m_MainWnd->_ExecuteDoubleClickPlugin(
- reinterpret_cast< const double* >( data )
- );
+// If( This->M_Mainwnd != Null )
+// This->M_Mainwnd->_Executedoubleclickplugin(
+// Reinterpret_Cast< Const Double* >( Data )
+// );
}
// -------------------------------------------------------------------------
DoubleClickCommand::
DoubleClickCommand( )
+{
+}
+/*
: Superclass( ),
m_MainWnd( NULL )
{
}
+*/
// -------------------------------------------------------------------------
DoubleClickCommand::
bool MainWnd::
_LoadPlugins( )
{
- // Clear states
- this->m_Plugins.UnloadAll( );
- this->m_BaseClasses.clear( );
- this->m_SegmentationClasses.clear( );
- this->m_SegmentationFilterClasses.clear( );
- this->m_MeshFilterClasses.clear( );
-
- // Read file and load plugins
- std::ifstream in( this->m_PluginsConfigurationFile.c_str( ) );
- if( !in )
- return( false );
- this->m_LastOpenedFile = this->m_PluginsConfigurationFile;
- std::string line, actual_section = "";
- std::getline( in, line );
- while( !( in.eof( ) ) )
- {
- std::string clean_line = line;
- clean_line.erase(
- std::remove_if( clean_line.begin( ), clean_line.end( ), isspace ),
- clean_line.end( )
- );
- if( clean_line[ 0 ] != '#' )
- {
- if(
- clean_line != "sectionplugins" &&
- clean_line != "sectionbase_classes" &&
- clean_line != "sectionsegmentation_classes" &&
- clean_line != "sectionsegmentation_filter_classes" &&
- clean_line != "sectionmesh_filter_classes"
- )
- {
- if( clean_line != "" )
- {
- if( actual_section == "sectionplugins" )
- {
- if( !( this->m_Plugins.Load( clean_line ) ) )
- {
- QMessageBox::warning(
- this,
- tr( "Ignoring plugin" ),
- tr( clean_line.c_str( ) )
- );
-
- } // fi
- }
- else
- {
- std::string name =
- clean_line.substr( clean_line.find_last_of( ":" ) + 1 );
- if( actual_section == "sectionbase_classes" )
- this->m_BaseClasses[ name ] = clean_line;
- else if( actual_section == "sectionsegmentation_classes" )
- this->m_SegmentationClasses[ name ] = clean_line;
- else if( actual_section == "sectionsegmentation_filter_classes" )
- this->m_SegmentationFilterClasses[ name ] = clean_line;
- else if( actual_section == "sectionmesh_filter_classes" )
- this->m_MeshFilterClasses[ name ] = clean_line;
-
- } // fi
-
- } // fi
- }
- else if( clean_line != "" )
- {
- if( clean_line[ 0 ] != '#' )
- actual_section = clean_line;
-
- } // fi
-
- } // fi
- std::getline( in, line );
-
- } // elihw
- in.close( );
-
- // Check classes existence
- if( !( this->_CheckClassesInPlugins( this->m_BaseClasses ) ) )
- {
- QMessageBox::critical(
- this,
- tr( "Could not load all base plugins." ),
- tr( "Could not load all base plugins... Closing application!" )
- );
- std::exit( 1 );
-
- } // fi
-
- // Needed object from plugins
- this->_AddPluginActions(
- this->m_SegmentationClasses, this->m_UI->menuSegmentInputImage,
- SLOT( _triggered_actionSegmentImage( ) )
- );
- this->_AddPluginActions(
- this->m_SegmentationFilterClasses, this->m_UI->menuFilterSegmentedImage,
- SLOT( _triggered_actionFilterSegmentation( ) )
- );
- this->_AddPluginActions(
- this->m_MeshFilterClasses, this->m_UI->menuProcessMesh,
- SLOT( _triggered_actionProcessMesh( ) )
- );
-
- // Historic objects
+// // Clear states
+// this->m_Plugins.UnloadAll( );
+// this->m_BaseClasses.clear( );
+// this->m_SegmentationClasses.clear( );
+// this->m_SegmentationFilterClasses.clear( );
+// this->m_MeshFilterClasses.clear( );
+
+// // Read file and load plugins
+// std::ifstream in( this->m_PluginsConfigurationFile.c_str( ) );
+// if( !in )
+// return( false );
+// this->m_LastOpenedFile = this->m_PluginsConfigurationFile;
+// std::string line, actual_section = "";
+// std::getline( in, line );
+// while( !( in.eof( ) ) )
+// {
+// std::string clean_line = line;
+// clean_line.erase(
+// std::remove_if( clean_line.begin( ), clean_line.end( ), isspace ),
+// clean_line.end( )
+// );
+// if( clean_line[ 0 ] != '#' )
+// {
+// if(
+// clean_line != "sectionplugins" &&
+// clean_line != "sectionbase_classes" &&
+// clean_line != "sectionsegmentation_classes" &&
+// clean_line != "sectionsegmentation_filter_classes" &&
+// clean_line != "sectionmesh_filter_classes"
+// )
+// {
+// if( clean_line != "" )
+// {
+// if( actual_section == "sectionplugins" )
+// {
+// if( !( this->m_Plugins.Load( clean_line ) ) )
+// {
+// QMessageBox::warning(
+// this,
+// tr( "Ignoring plugin" ),
+// tr( clean_line.c_str( ) )
+// );
+
+// } // fi
+// }
+// else
+// {
+// std::string name =
+// clean_line.substr( clean_line.find_last_of( ":" ) + 1 );
+// if( actual_section == "sectionbase_classes" )
+// this->m_BaseClasses[ name ] = clean_line;
+// else if( actual_section == "sectionsegmentation_classes" )
+// this->m_SegmentationClasses[ name ] = clean_line;
+// else if( actual_section == "sectionsegmentation_filter_classes" )
+// this->m_SegmentationFilterClasses[ name ] = clean_line;
+// else if( actual_section == "sectionmesh_filter_classes" )
+// this->m_MeshFilterClasses[ name ] = clean_line;
+
+// } // fi
+
+// } // fi
+// }
+// else if( clean_line != "" )
+// {
+// if( clean_line[ 0 ] != '#' )
+// actual_section = clean_line;
+
+// } // fi
+
+// } // fi
+// std::getline( in, line );
+
+// } // elihw
+// in.close( );
+
+// // Check classes existence
+// if( !( this->_CheckClassesInPlugins( this->m_BaseClasses ) ) )
+// {
+// QMessageBox::critical(
+// this,
+// tr( "Could not load all base plugins." ),
+// tr( "Could not load all base plugins... Closing application!" )
+// );
+// std::exit( 1 );
+
+// } // fi
+
+// // Needed object from plugins
+// this->_AddPluginActions(
+// this->m_SegmentationClasses, this->m_UI->menuSegmentInputImage,
+// SLOT( _triggered_actionSegmentImage( ) )
+// );
+// this->_AddPluginActions(
+// this->m_SegmentationFilterClasses, this->m_UI->menuFilterSegmentedImage,
+// SLOT( _triggered_actionFilterSegmentation( ) )
+// );
+// this->_AddPluginActions(
+// this->m_MeshFilterClasses, this->m_UI->menuProcessMesh,
+// SLOT( _triggered_actionProcessMesh( ) )
+// );
+
+// // Historic objects
}
// -------------------------------------------------------------------------
bool MainWnd::
_CheckClassesInPlugins( const TStringMap& classes )
{
- bool r = true;
- TStringMap::const_iterator cIt = classes.begin( );
- for( ; cIt != classes.end( ); ++cIt )
- {
- TPluginObject* o = this->m_Plugins.CreateObject( cIt->second );
- if( o != NULL )
- delete o;
- else
- r &= false;
+// bool r = true;
+// TStringMap::const_iterator cIt = classes.begin( );
+// for( ; cIt != classes.end( ); ++cIt )
+// {
+// TPluginObject* o = this->m_Plugins.CreateObject( cIt->second );
+// if( o != NULL )
+// delete o;
+// else
+// r &= false;
- } // rof
- return( r );
+// } // rof
+// return( r );
}
// -------------------------------------------------------------------------
const TStringMap& classes, QMenu* menu, const char* method
)
{
- TStringMap::const_iterator clIt = classes.begin( );
- for( ; clIt != classes.end( ); ++clIt )
- {
- QAction* action = menu->addAction( QString( clIt->first.c_str( ) ) );
- QObject::connect( action, SIGNAL( triggered( ) ), this, method );
+// TStringMap::const_iterator clIt = classes.begin( );
+// for( ; clIt != classes.end( ); ++clIt )
+// {
+// QAction* action = menu->addAction( QString( clIt->first.c_str( ) ) );
+// QObject::connect( action, SIGNAL( triggered( ) ), this, method );
- } // rof
+// } // rof
}
// eof - $RCSfile$
#include <Pluma/Connector.hpp>
-#include <cpm/Plugins/SimpleFillRegion.h>
+// TODO #include <cpm/Plugins/SimpleFillRegion.h>
/// TODO: doc
PLUMA_CONNECTOR
bool connect( pluma::Host& host )
{
- host.add( new cpm::Plugins::SimpleFillRegionProvider( ) );
+ // TODO: host.add( new cpm::Plugins::SimpleFillRegionProvider( ) );
return( true );
}
#ifndef __CPM__PLUGINS__SIMPLEFILLREGION__H__
#define __CPM__PLUGINS__SIMPLEFILLREGION__H__
-#include <cpPlugins/Interface/ImageToImageFilter.h>
+#include <cpPlugins/Interface/BaseProcessObjects.h>
namespace cpm
{