#include "MainWnd.h"
#include "ui_MainWnd.h"
+#include <algorithm>
+#include <cctype>
#include <fstream>
-#include <limits>
-#include <map>
-#include <set>
-#include <sstream>
-
-#include <QDialog>
-#include <QDialogButtonBox>
-#include <QDoubleSpinBox>
+
#include <QFileDialog>
-#include <QGridLayout>
-#include <QHBoxLayout>
-#include <QLabel>
#include <QMessageBox>
-#include <QVBoxLayout>
-
-#include <itkGDCMImageIO.h>
-#include <itkImageFileReader.h>
-#include <itkImageSeriesReader.h>
+#include <vtkAnnotatedCubeActor.h>
+#include <vtkAxesActor.h>
+#include <vtkPropAssembly.h>
+#include <vtkProperty.h>
#include <vtkRenderWindow.h>
-/*
- #include "ui_SegmentationParametersDlg.h"
-
- #include <set>
-
-
- #include <itkImageFileWriter.h>
- #include <itkMinimumMaximumImageCalculator.h>
- #include <itkBinaryMask3DMeshSource.h>
-
- #include <itkIdentityTransform.h>
- #include <itkLinearInterpolateImageFunction.h>
- #include <itkResampleImageFilter.h>
- #include <itkSignedDanielssonDistanceMapImageFilter.h>
- #include <vtkImageMarchingCubes.h>
- #include <cpm/VTK/PolyDataToMeshFilter.h>
- #include <itkBinaryMinMaxCurvatureFlowImageFilter.h>
- #include <itkLaplacianRecursiveGaussianImageFilter.h>
- #include <itkThresholdImageFilter.h>
- #include <itkSubtractImageFilter.h>
-
- #include <vtkAnnotatedCubeActor.h>
- #include <vtkAxesActor.h>
- #include <vtkPropAssembly.h>
- #include <vtkProperty.h>
- #include <vtkTextProperty.h>
- #include <vtkCallbackCommand.h>
-
- #include <vtkCamera.h>
-*/
+#include <cpPlugins/Interface/Image.h>
// -------------------------------------------------------------------------
-#define IDMS_QT_ACTION( action ) \
- QObject::connect( \
- this->m_UI->a##action, SIGNAL( triggered( ) ), \
- this, SLOT( triggered_a##action( ) ) \
+#define IDMS_QT_ACTION( name ) \
+ QObject::connect( \
+ this->m_UI->action##name, SIGNAL( triggered( ) ), \
+ this, SLOT( _triggered_action##name( ) ) \
)
// -------------------------------------------------------------------------
MainWnd::MainWnd( QWidget* parent )
: QMainWindow( parent ),
- m_UI( new Ui::MainWnd )
+ m_UI( new Ui::MainWnd ),
+ m_InputImage( NULL ),
+ m_SegmentedImage( NULL )
{
this->m_UI->setupUi( this );
- // Configure strings
- this->m_LastOpenedFile = ".";
+ // Configuration files
+ this->m_ApplicationPreferencesFile = "idms.config";
this->m_PluginsConfigurationFile = "idms.plugins";
+ this->_LoadApplicationPreferences( );
// Create and associate renderers
this->m_3DRenderer = vtkSmartPointer< vtkRenderer >::New( );
this->m_UI->m_ZPlaneVTK->GetInteractor( )->
SetInteractorStyle( this->m_ZStyle );
- /*
- vtkSmartPointer< vtkCallbackCommand > z_callback =
- vtkSmartPointer< vtkCallbackCommand >::New( );
- z_callback->SetCallback( MainWnd::_SliceEventCallback );
- z_callback->SetClientData( this );
- zstyle->AddObserver( idms::InteractorStyleImage::SliceEvent, z_callback );
-
- // Orientation marks
- vtkSmartPointer< vtkAnnotatedCubeActor > oCube =
+ // Orientation marks
+ vtkSmartPointer< vtkAnnotatedCubeActor > oCube =
vtkSmartPointer< vtkAnnotatedCubeActor >::New( );
- oCube->GetCubeProperty( )->SetColor( 0.9, 0.7, 0.2 );
- oCube->GetTextEdgesProperty( )->SetLineWidth( 1 );
- oCube->GetTextEdgesProperty( )->SetDiffuse( 0 );
- oCube->GetTextEdgesProperty( )->SetAmbient( 1 );
- oCube->GetTextEdgesProperty( )->SetColor( 0.18, 0.28, 0.23 );
- oCube->GetXPlusFaceProperty( )->SetColor( 1, 0, 0 );
- oCube->GetXPlusFaceProperty( )->SetInterpolationToFlat( );
- oCube->GetXMinusFaceProperty( )->SetColor( 1, 0, 0 );
- oCube->GetXMinusFaceProperty( )->SetInterpolationToFlat( );
- oCube->GetYPlusFaceProperty( )->SetColor( 0, 1, 0 );
- oCube->GetYPlusFaceProperty( )->SetInterpolationToFlat( );
- oCube->GetYMinusFaceProperty( )->SetColor( 0, 1, 0 );
- oCube->GetYMinusFaceProperty( )->SetInterpolationToFlat( );
- oCube->GetZPlusFaceProperty( )->SetColor( 0, 0, 1 );
- oCube->GetZPlusFaceProperty( )->SetInterpolationToFlat( );
- oCube->GetZMinusFaceProperty( )->SetColor( 0, 0, 1 );
- oCube->GetZMinusFaceProperty( )->SetInterpolationToFlat( );
-
- vtkSmartPointer< vtkAxesActor > oAxes =
+ oCube->GetCubeProperty( )->SetColor( 0.9, 0.7, 0.2 );
+ oCube->GetTextEdgesProperty( )->SetLineWidth( 1 );
+ oCube->GetTextEdgesProperty( )->SetDiffuse( 0 );
+ oCube->GetTextEdgesProperty( )->SetAmbient( 1 );
+ oCube->GetTextEdgesProperty( )->SetColor( 0.18, 0.28, 0.23 );
+ oCube->GetXPlusFaceProperty( )->SetColor( 1, 0, 0 );
+ oCube->GetXPlusFaceProperty( )->SetInterpolationToFlat( );
+ oCube->GetXMinusFaceProperty( )->SetColor( 1, 0, 0 );
+ oCube->GetXMinusFaceProperty( )->SetInterpolationToFlat( );
+ oCube->GetYPlusFaceProperty( )->SetColor( 0, 1, 0 );
+ oCube->GetYPlusFaceProperty( )->SetInterpolationToFlat( );
+ oCube->GetYMinusFaceProperty( )->SetColor( 0, 1, 0 );
+ oCube->GetYMinusFaceProperty( )->SetInterpolationToFlat( );
+ oCube->GetZPlusFaceProperty( )->SetColor( 0, 0, 1 );
+ oCube->GetZPlusFaceProperty( )->SetInterpolationToFlat( );
+ oCube->GetZMinusFaceProperty( )->SetColor( 0, 0, 1 );
+ oCube->GetZMinusFaceProperty( )->SetInterpolationToFlat( );
+
+ vtkSmartPointer< vtkAxesActor > oAxes =
vtkSmartPointer< vtkAxesActor >::New( );
- oAxes->AxisLabelsOff( );
- oAxes->SetShaftTypeToCylinder( );
- oAxes->SetTotalLength( 2.5, 2.5, 2.5 );
+ oAxes->AxisLabelsOff( );
+ oAxes->SetShaftTypeToCylinder( );
+ oAxes->SetTotalLength( 2.5, 2.5, 2.5 );
- vtkSmartPointer< vtkPropAssembly > oActors =
+ vtkSmartPointer< vtkPropAssembly > oActors =
vtkSmartPointer< vtkPropAssembly >::New( );
- oActors->AddPart( oCube );
- oActors->AddPart( oAxes );
+ oActors->AddPart( oCube );
+ oActors->AddPart( oAxes );
- this->m_3DOrientationWidget =
+ this->m_3DOrientationWidget =
vtkSmartPointer< vtkOrientationMarkerWidget >::New( );
- this->m_3DOrientationWidget->SetOutlineColor( 0.93, 0.57, 0.13 );
- this->m_3DOrientationWidget->SetOrientationMarker( oActors );
- this->m_3DOrientationWidget->SetViewport( 0.0, 0.0, 0.2, 0.2 );
+ this->m_3DOrientationWidget->SetOutlineColor( 0.93, 0.57, 0.13 );
+ this->m_3DOrientationWidget->SetOrientationMarker( oActors );
+ this->m_3DOrientationWidget->SetViewport( 0.0, 0.0, 0.2, 0.2 );
- // Add actors, widgets, stuff, ...
- this->m_3DOrientationWidget->
+ // Add actors, widgets, stuff, ...
+ this->m_3DOrientationWidget->
SetInteractor( this->m_UI->m_3DVTK->GetInteractor( ) );
- this->m_3DOrientationWidget->SetEnabled( 1 );
- this->m_3DOrientationWidget->InteractiveOff( );
+ this->m_3DOrientationWidget->SetEnabled( 1 );
+ this->m_3DOrientationWidget->InteractiveOff( );
- IDMS_QT_ACTION( aLoadInputImage );
- IDMS_QT_ACTION( aLoadSegmentedImage );
- */
// Qt signals <-> slots
+ IDMS_QT_ACTION( ReloadPlugins );
+ IDMS_QT_ACTION( OpenInputImage );
+ IDMS_QT_ACTION( OpenSegmentedImage );
QObject::connect(
- this->m_UI->aNavigation, SIGNAL( triggered( ) ),
- this, SLOT( triggered_aSwitchMode( ) )
+ this->m_UI->actionNavigation, SIGNAL( triggered( ) ),
+ this, SLOT( _triggered_actionSwitchMode( ) )
);
QObject::connect(
- this->m_UI->aSegmentationInteractiveDeformation, SIGNAL( triggered( ) ),
- this, SLOT( triggered_aSwitchMode( ) )
+ this->m_UI->actionSegmentationInteractiveDeformation,
+ SIGNAL( triggered( ) ),
+ this, SLOT( _triggered_actionSwitchMode( ) )
);
- IDMS_QT_ACTION( OpenInputImage );
- IDMS_QT_ACTION( OpenSegmentedImage );
- IDMS_QT_ACTION( ReloadPlugins );
+ // Historic configuration
+ this->m_LastOpenedFile = ".";
// Start: load all disponible plugins
- this->triggered_aReloadPlugins( );
+ this->_triggered_actionReloadPlugins( );
}
// -------------------------------------------------------------------------
~MainWnd( )
{
delete this->m_UI;
+ 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( );
+}
+
+// -------------------------------------------------------------------------
+MainWnd::
+TPluginData* 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 );
+
+ TPluginData* ret = NULL;
+ unsigned int nFiles = dialog.selectedFiles( ).size( );
+ if( nFiles == 1 )
+ {
+ if( this->m_ImageReaderClassName == "" )
+ {
+ 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_ImageReaderClassName )
+ );
+
+ 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 = reader->GetOutput( 0 );
+ reader->DisconnectOutputs( );
+ }
+ else
+ QMessageBox::critical(
+ this,
+ tr( "Error reading single image" ),
+ tr( err.c_str( ) )
+ );
+ delete reader;
+ return( ret );
+ }
+ else if( nFiles > 1 )
+ {
+ 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
+
+ /* TODO
+ std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
+ this->m_LastOpenedFile = fname;
+ */
+ return( ret );
+
+ } // fi
+ return( ret );
}
// -------------------------------------------------------------------------
void MainWnd::
_UpdateEnabledFlags( )
{
- bool img = this->m_Image.IsNotNull( );
+ bool img = ( this->m_InputImage != NULL );
this->m_UI->menuSegmentInputImage->setEnabled( img );
- this->m_UI->aOpenSegmentedImage->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_Segmentation.IsNotNull( );
- this->m_UI->menuFilterSegmentedImage->setEnabled( seg );
- this->m_UI->menuExtractMesh->setEnabled( seg );
- this->m_UI->aOpenMesh->setEnabled( seg );
+ /* TODO
+ bool seg = this->m_Segmentation.IsNotNull( );
+ this->m_UI->menuFilterSegmentedImage->setEnabled( seg );
+ this->m_UI->menuExtractMesh->setEnabled( seg );
+ this->m_UI->actionOpenMesh->setEnabled( seg );
+
+ this->m_UI->actionNavigation->setEnabled( img && seg );
+ this->m_UI->actionSegmentationInteractiveDeformation->
+ setEnabled( img && seg );
+ */
+}
- this->m_UI->aNavigation->setEnabled( img && seg );
- this->m_UI->aSegmentationInteractiveDeformation->setEnabled( img && seg );
+// -------------------------------------------------------------------------
+void MainWnd::
+_triggered_actionReloadPlugins( )
+{
+ this->m_Plugins.UnloadAll( );
+
+ this->m_ImageReaderClassName = "";
+ this->m_ImageSeriesReaderClassName = "";
+ this->m_ImageWriterClassName = "";
+
+ std::ifstream in( this->m_PluginsConfigurationFile.c_str( ) );
+ if( in )
+ {
+ std::string plugin;
+ std::getline( in, plugin );
+ while( !( in.eof( ) ) )
+ {
+ if( this->m_Plugins.Load( plugin ) )
+ {
+ TPluginsInterface::TClassesIterator cIt =
+ this->m_Plugins.GetClasses( ).begin( );
+ TPluginsInterface::TClassesIterator end_cIt =
+ this->m_Plugins.GetClasses( ).end( );
+ for( ; cIt != end_cIt; ++cIt )
+ {
+ std::string c_name = cIt->first;
+ c_name = c_name.substr( c_name.find_last_of( ":" ) + 1 );
+ if( c_name == "ImageReader" )
+ {
+ this->m_ImageReaderClassName = cIt->first;
+ }
+ else if( c_name == "ImageWriter" )
+ {
+ this->m_ImageWriterClassName = cIt->first;
+ }
+ else
+ {
+ } // fi
+
+ } // rof
+
+ /* TODO
+ TFilterPlugins::TClassesIterator cIt =
+ this->m_Plugins.BeginClasses( );
+ for( ; cIt != this->m_Plugins.EndClasses( ); ++cIt )
+ {
+ TFilterObject* filter =
+ this->m_Plugins.CreateObject( cIt->first );
+ if( filter == NULL )
+ continue;
+ std::string cat = filter->GetCategory( );
+ std::string catType = cat.substr( cat.find_last_of( ":" ) );
+ if( catType == ":BinaryImageToBinaryImageFilter" )
+ {
+ QAction* action = this->m_UI->menuFilterSegmentedImage->
+ addAction( QString( cIt->first.c_str( ) ) );
+ QObject::connect(
+ action, SIGNAL( triggered( ) ),
+ this, SLOT( triggered_aFilterSegmentedImage( ) )
+ );
+ }
+ else if( catType == ":ImageToMeshFilter" )
+ {
+ QAction* action = this->m_UI->menuExtractMesh->
+ addAction( QString( cIt->first.c_str( ) ) );
+ QObject::connect(
+ action, SIGNAL( triggered( ) ),
+ this, SLOT( triggered_aSegmentedImageToMesh( ) )
+ );
+
+ } // fi
+ delete filter;
+ } // rof
+ */
+ }
+ else
+ {
+ QMessageBox::warning(
+ this,
+ tr( "Ignoring plugin" ),
+ tr( plugin.c_str( ) )
+ );
+
+ } // fi
+ std::getline( in, plugin );
+
+ } // elihw
+ }
+ else
+ {
+ QMessageBox::critical(
+ this,
+ tr( "No plugins file loaded!" ),
+ tr( this->m_PluginsConfigurationFile.c_str( ) )
+ );
+
+ } // fi
+ in.close( );
+
+ if( this->m_ImageReaderClassName == "" )
+ {
+ QMessageBox::critical(
+ this,
+ tr( "No ImageReader found in plugins!" ),
+ tr( this->m_PluginsConfigurationFile.c_str( ) )
+ );
+
+ } // fi
+
+ if( this->m_ImageWriterClassName == "" )
+ {
+ QMessageBox::critical(
+ this,
+ tr( "No ImageWriter found in plugins!" ),
+ tr( this->m_PluginsConfigurationFile.c_str( ) )
+ );
+
+ } // 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 )
+ {
+ cpPlugins::Interface::Image* img =
+ dynamic_cast< cpPlugins::Interface::Image* >( this->m_InputImage );
+ this->m_ImageActors->Configure(
+ img->GetVTKImageData( ),
+ this->m_UI->m_XPlaneVTK->GetInteractor( ),
+ this->m_UI->m_YPlaneVTK->GetInteractor( ),
+ this->m_UI->m_ZPlaneVTK->GetInteractor( )
+ );
+ this->m_ImageActors->
+ AddAuxiliaryInteractor( this->m_UI->m_3DVTK->GetInteractor( ) );
+
+ // Associate actors
+ this->m_3DRenderer->AddActor(
+ this->m_ImageActors->GetImageOutlineActor( )
+ );
+ this->m_3DRenderer->AddActor(
+ this->m_ImageActors->GetXBoundsActor( )
+ );
+ this->m_3DRenderer->AddActor(
+ this->m_ImageActors->GetYBoundsActor( )
+ );
+ this->m_3DRenderer->AddActor(
+ this->m_ImageActors->GetZBoundsActor( )
+ );
+
+ // Reset all cameras
+ this->m_3DRenderer->ResetCamera( );
+ this->m_ImageActors->ResetCameras( );
+
+ // Ok, start!
+ this->m_UI->m_3DVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_XPlaneVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_YPlaneVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_ZPlaneVTK->GetRenderWindow( )->Render( );
+
+ // 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 )
+ {
+ cpPlugins::Interface::Image* img =
+ dynamic_cast< cpPlugins::Interface::Image* >( this->m_SegmentedImage );
+ this->m_ImageActors->SetSegmentation( img->GetVTKImageData( ) );
+
+ // Ok, start!
+ this->m_UI->m_XPlaneVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_YPlaneVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_ZPlaneVTK->GetRenderWindow( )->Render( );
+ this->_UpdateEnabledFlags( );
+
+ /*
+ this->m_ImageActors->Configure(
+ img->GetVTKImageData( ),
+ this->m_UI->m_XPlaneVTK->GetInteractor( ),
+ this->m_UI->m_YPlaneVTK->GetInteractor( ),
+ this->m_UI->m_ZPlaneVTK->GetInteractor( )
+ );
+ this->m_ImageActors->
+ AddAuxiliaryInteractor( this->m_UI->m_3DVTK->GetInteractor( ) );
+
+ // Associate actors
+ this->m_3DRenderer->AddActor(
+ this->m_ImageActors->GetImageOutlineActor( )
+ );
+ this->m_3DRenderer->AddActor(
+ this->m_ImageActors->GetXBoundsActor( )
+ );
+ this->m_3DRenderer->AddActor(
+ this->m_ImageActors->GetYBoundsActor( )
+ );
+ this->m_3DRenderer->AddActor(
+ this->m_ImageActors->GetZBoundsActor( )
+ );
+
+ // Reset all cameras
+ this->m_3DRenderer->ResetCamera( );
+ this->m_ImageActors->ResetCameras( );
+
+ // Ok, start!
+ this->m_UI->m_3DVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_XPlaneVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_YPlaneVTK->GetRenderWindow( )->Render( );
+ this->m_UI->m_ZPlaneVTK->GetRenderWindow( )->Render( );
+
+ // Update activations
+ this->_UpdateEnabledFlags( );
+ this->m_UI->actionNavigation->setChecked( true );
+ this->_triggered_actionSwitchMode( );
+ */
+
+ } // 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
- menuProcessMesh
+ 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
*/
}
+// -------------------------------------------------------------------------
+/* TODO
+
// -------------------------------------------------------------------------
bool MainWnd::
_ParametersDialog( TParameters& parameters )
return( true );
}
return( false );
-}
+ }
-// -------------------------------------------------------------------------
-template< class I >
-bool MainWnd::
-_LoadImage( typename I::Pointer& image )
-{
+ // -------------------------------------------------------------------------
+ template< class I >
+ bool MainWnd::
+ _LoadImage( typename I::Pointer& image )
+ {
QStringList qList =
- QFileDialog::getOpenFileNames(
- this,
- tr( "Open an image" ),
- tr( this->m_LastOpenedFile.c_str( ) ),
- tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
- );
+ QFileDialog::getOpenFileNames(
+ this,
+ tr( "Open an image" ),
+ tr( this->m_LastOpenedFile.c_str( ) ),
+ tr( "Medical image files (*.mhd *.bin *.dcm);;All files (*)" )
+ );
if( qList.size( ) == 0 )
- return( false );
+ return( false );
bool ret = true;
QStringList::Iterator fIt = qList.begin( );
if( qList.size( ) == 1 )
{
- // Read a single image
- std::string fn = fIt->toStdString( );
- this->m_LastOpenedFile = fn;
-
- typename itk::ImageFileReader< I >::Pointer reader =
- itk::ImageFileReader< I >::New( );
- reader->SetFileName( fn );
- try
- {
- reader->Update( );
- }
- catch( itk::ExceptionObject& err )
- {
- QMessageBox::critical(
- this,
- tr( "Error opening single image!" ),
- tr( err.GetDescription( ) )
- );
- ret = false;
-
- } // yrt
- image = reader->GetOutput( );
- image->DisconnectPipeline( );
+ // Read a single image
+ std::string fn = fIt->toStdString( );
+ this->m_LastOpenedFile = fn;
+
+ typename itk::ImageFileReader< I >::Pointer reader =
+ itk::ImageFileReader< I >::New( );
+ reader->SetFileName( fn );
+ try
+ {
+ reader->Update( );
}
- else if( qList.size( ) > 1 )
+ catch( itk::ExceptionObject& err )
{
- typedef std::set< std::string > _TOrderedStringList;
-
- // Read a slice set
- _TOrderedStringList filenames;
- for( ; fIt != qList.end( ); ++fIt )
- filenames.insert( fIt->toStdString( ) );
- typename itk::ImageSeriesReader< I >::Pointer reader =
- itk::ImageSeriesReader< I >::New( );
- reader->SetImageIO( itk::GDCMImageIO::New( ) );
- _TOrderedStringList::const_iterator oIt = filenames.begin( );
- for( ; oIt != filenames.end( ); ++oIt )
- {
- reader->AddFileName( *oIt );
- this->m_LastOpenedFile = *oIt;
-
- } // rof
- try
- {
- reader->Update( );
- }
- catch( itk::ExceptionObject& err )
- {
- QMessageBox::critical(
- this,
- tr( "Error opening image series!" ),
- tr( err.GetDescription( ) )
- );
- ret = false;
-
- } // yrt
- image = reader->GetOutput( );
- image->DisconnectPipeline( );
-
- } // fi
- return( ret );
-}
+ QMessageBox::critical(
+ this,
+ tr( "Error opening single image!" ),
+ tr( err.GetDescription( ) )
+ );
+ ret = false;
-// -------------------------------------------------------------------------
-void MainWnd::
-triggered_aSwitchMode( )
-{
- QAction* snd = dynamic_cast< QAction* >( this->sender( ) );
- if( snd == this->m_UI->aNavigation )
- {
- this->m_UI->aSegmentationInteractiveDeformation->setChecked(
- !( this->m_UI->aNavigation->isChecked( ) )
- );
+ } // yrt
+ image = reader->GetOutput( );
+ image->DisconnectPipeline( );
}
- else if( snd == this->m_UI->aSegmentationInteractiveDeformation )
+ else if( qList.size( ) > 1 )
{
- this->m_UI->aNavigation->setChecked(
- !( this->m_UI->aSegmentationInteractiveDeformation->isChecked( ) )
- );
- }
- else
+ typedef std::set< std::string > _TOrderedStringList;
+
+ // Read a slice set
+ _TOrderedStringList filenames;
+ for( ; fIt != qList.end( ); ++fIt )
+ filenames.insert( fIt->toStdString( ) );
+ typename itk::ImageSeriesReader< I >::Pointer reader =
+ itk::ImageSeriesReader< I >::New( );
+ reader->SetImageIO( itk::GDCMImageIO::New( ) );
+ _TOrderedStringList::const_iterator oIt = filenames.begin( );
+ for( ; oIt != filenames.end( ); ++oIt )
{
- this->m_UI->aNavigation->setChecked( true );
- this->m_UI->aSegmentationInteractiveDeformation->setChecked( false );
-
- } // fi
+ reader->AddFileName( *oIt );
+ this->m_LastOpenedFile = *oIt;
- if( this->m_UI->aNavigation->isChecked( ) )
+ } // rof
+ try
{
- 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( );
+ reader->Update( );
}
- 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( );
+ catch( itk::ExceptionObject& err )
+ {
+ QMessageBox::critical(
+ this,
+ tr( "Error opening image series!" ),
+ tr( err.GetDescription( ) )
+ );
+ ret = false;
+
+ } // yrt
+ image = reader->GetOutput( );
+ image->DisconnectPipeline( );
} // fi
-}
+ return( ret );
+ }
// -------------------------------------------------------------------------
void MainWnd::
triggered_aReloadPlugins( )
{
- this->m_FilterPlugins.UnloadAll( );
-
- std::ifstream in( this->m_PluginsConfigurationFile.c_str( ) );
- if( in )
- {
- std::string plugin;
- std::getline( in, plugin );
- while( !( in.eof( ) ) )
- {
- if( this->m_FilterPlugins.Load( plugin ) )
- {
- TFilterPlugins::TClassesIterator cIt =
- this->m_FilterPlugins.BeginClasses( );
- for( ; cIt != this->m_FilterPlugins.EndClasses( ); ++cIt )
- {
- TFilterObject* filter =
- this->m_FilterPlugins.CreateObject( cIt->first );
- if( filter == NULL )
- continue;
- std::string cat = filter->GetCategory( );
- std::string catType = cat.substr( cat.find_last_of( ":" ) );
- if( catType == ":BinaryImageToBinaryImageFilter" )
- {
- QAction* action = this->m_UI->menuFilterSegmentedImage->
- addAction( QString( cIt->first.c_str( ) ) );
- QObject::connect(
- action, SIGNAL( triggered( ) ),
- this, SLOT( triggered_aFilterSegmentedImage( ) )
- );
- }
- else if( catType == ":ImageToMeshFilter" )
- {
- QAction* action = this->m_UI->menuExtractMesh->
- addAction( QString( cIt->first.c_str( ) ) );
- QObject::connect(
- action, SIGNAL( triggered( ) ),
- this, SLOT( triggered_aSegmentedImageToMesh( ) )
- );
-
- } // fi
- delete filter;
-
- } // rof
- }
- else
- std::cerr
- << std::endl
- << "Ignoring \"" << plugin << "\""
- << std::endl;
- std::getline( in, plugin );
-
- } // elihw
- }
- else
- {
- QMessageBox::critical(
- this,
- tr( "No plugins file loaded!" ),
- tr( "No plugins file loaded!" )
- );
-
- } // fi
- in.close( );
- this->_UpdateEnabledFlags( );
}
// -------------------------------------------------------------------------
std::string filter_name = action->text( ).toStdString( );
// Create filter
- TFilterObject* filter = this->m_FilterPlugins.CreateObject( filter_name );
+ TFilterObject* filter = this->m_Plugins.CreateObject( filter_name );
if( filter == NULL )
return;
std::string result = filter->Update( );
// Get modified segmentation
- /* TODO
this->m_Mesh = filter->GetCastedOutput< TMesh >( );
if( this->m_Mesh.IsNotNull( ) )
{
this->m_Mesh->DisconnectPipeline( );
} // fi
- */
// Ok, it seems to have runned fine
delete filter;
}
std::string filter_name = action->text( ).toStdString( );
// Create filter
- TFilterObject* filter = this->m_FilterPlugins.CreateObject( filter_name );
+ TFilterObject* filter = this->m_Plugins.CreateObject( filter_name );
if( filter == NULL )
return;
// Ok, it seems to have runned fine
delete filter;
}
+*/
// -------------------------------------------------------------------------
/*