#include <vtkRenderWindowInteractor.h>
#include <QCheckBox>
+#include <QComboBox>
#include <QDoubleSpinBox>
#include <QFileDialog>
#include <QHBoxLayout>
case Parameters::PathNameList:
break;
case Parameters::Choices:
- break;
+ {
+ QComboBox* v_choices = new QComboBox( this );
+ v_choices->setObjectName( pIt->first.c_str( ) );
+
+ std::istringstream str0( pIt->second.second );
+ std::string choices;
+ std::getline( str0, choices, '@' );
+ std::istringstream str1( choices );
+ std::string token;
+ int id = 0;
+ while( std::getline( str1, token, '#' ) )
+ v_choices->insertItem( id++, token.c_str( ) );
+ w_input = v_choices;
+ }
+ break;
default:
w_input = NULL;
break;
);
this->m_ToolsLayout->addWidget( this->m_Buttons );
+ // Update values
+ this->updateView( );
+
return( true );
}
case Parameters::PathNameList:
break;
case Parameters::Choices:
- break;
+ {
+ QComboBox* v_choices = this->findChild< QComboBox* >( pName );
+ if( v_choices != NULL )
+ {
+ std::istringstream str_choices( pIt->second.second );
+ std::string real_choices;
+ std::getline( str_choices, real_choices, '@' );
+ pIt->second.second =
+ real_choices + "@" +
+ v_choices->currentText( ).toStdString( );
+
+ } // fi
+ }
+ break;
default:
break;
} // hctiws
case Parameters::PathNameList:
break;
case Parameters::Choices:
- break;
+ {
+ QComboBox* v_choices = this->findChild< QComboBox* >( pName );
+ if( v_choices != NULL )
+ {
+ std::istringstream str_choices( pIt->second.second );
+ std::string choices, real_choice;
+ std::getline( str_choices, choices, '@' );
+ std::getline( str_choices, real_choice, '@' );
+ std::istringstream str( choices );
+ std::string token;
+ int id = -1, cont = 0;
+ while( std::getline( str, token, '#' ) )
+ {
+ if( token == real_choice )
+ id = cont;
+ cont++;
+
+ } // elihw
+
+ if( id > -1 )
+ v_choices->setCurrentIndex( id );
+
+ } // fi
+ }
+ break;
default:
break;
} // hctiws
--- /dev/null
+#include "SignedMaurerDistanceMapImageFilter.h"
+#include <cpPlugins/Interface/Image.h>
+
+#include <itkSignedMaurerDistanceMapImageFilter.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
+SignedMaurerDistanceMapImageFilter( )
+ : Superclass( )
+{
+ this->_AddInput( "Input" );
+ this->_MakeOutput< cpPlugins::Interface::Image >( "Output" );
+
+ this->m_Parameters->ConfigureAsReal( "BackgroundValue" );
+ this->m_Parameters->ConfigureAsBool( "InsideIsPositive" );
+ this->m_Parameters->ConfigureAsBool( "SquaredDistance" );
+ this->m_Parameters->ConfigureAsBool( "UseImageSpacing" );
+
+ std::vector< std::string > choices;
+ choices.push_back( "float" );
+ choices.push_back( "double" );
+ this->m_Parameters->ConfigureAsChoices( "OutputResolution", choices );
+
+ this->m_Parameters->SetReal( "BackgroundValue", 0 );
+ this->m_Parameters->SetBool( "InsideIsPositive", true );
+ this->m_Parameters->SetBool( "SquaredDistance", false );
+ this->m_Parameters->SetBool( "UseImageSpacing", true );
+ this->m_Parameters->SetSelectedChoice( "OutputResolution", "float" );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
+~SignedMaurerDistanceMapImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
+_GenerateData( )
+{
+ cpPlugins::Interface::Image* image =
+ this->GetInput< cpPlugins::Interface::Image >( "Input" );
+ if( image == NULL )
+ return( "SignedMaurerDistanceMapImageFilter: No input image." );
+
+ itk::DataObject* itk_image = NULL;
+ std::string r = "";
+ cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 );
+ else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 );
+ else r = "SignedMaurerDistanceMapImageFilter: Input image type not supported.";
+ return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
+_GD0( itk::DataObject* image )
+{
+ std::string out_res =
+ this->m_Parameters->GetSelectedChoice( "OutputResolution" );
+ if( out_res == "float" )
+ return(
+ this->_RealGD< I, itk::Image< float, I::ImageDimension > >(
+ image
+ )
+ );
+ else if( out_res == "double" )
+ return(
+ this->_RealGD< I, itk::Image< double, I::ImageDimension > >(
+ image
+ )
+ );
+ else
+ return( "SignedMaurerDistanceMapImageFilter: Output resolution not supported." );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+inline std::string cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter::
+_RealGD( itk::DataObject* image )
+{
+ typedef itk::SignedMaurerDistanceMapImageFilter< I, O > _F;
+
+ // Get parameters
+ double back_value = this->m_Parameters->GetReal( "BackgroundValue" );
+ bool pos_inside = this->m_Parameters->GetBool( "InsideIsPositive" );
+ bool sqr_dist = this->m_Parameters->GetBool( "SquaredDistance" );
+ bool use_spac = this->m_Parameters->GetBool( "UseImageSpacing" );
+
+ // Configure filter
+ _F* filter = this->_CreateITK< _F >( );
+ filter->SetInput( dynamic_cast< I* >( image ) );
+ filter->SetBackgroundValue( ( typename I::PixelType )( back_value ) );
+ filter->SetInsideIsPositive( pos_inside );
+ filter->SetSquaredDistance( sqr_dist );
+ filter->SetUseImageSpacing( use_spac );
+
+ filter->Update( );
+
+ // Connect output
+ cpPlugins::Interface::Image* out =
+ this->GetOutput< cpPlugins::Interface::Image >( "Output" );
+ if( out != NULL )
+ {
+ out->SetITK< O >( filter->GetOutput( ) );
+ return( "" );
+ }
+ else
+ return( "SignedMaurerDistanceMapImageFilter: output not correctly created." );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__PLUGINS__SIGNEDMAURERDISTANCEMAPIMAGEFILTER__H__
+#define __CPPLUGINS__PLUGINS__SIGNEDMAURERDISTANCEMAPIMAGEFILTER__H__
+
+#include <cpPlugins/BasicFilters/cpPluginsBasicFilters_Export.h>
+#include <cpPlugins/Interface/BaseProcessObjects.h>
+
+namespace cpPlugins
+{
+ namespace BasicFilters
+ {
+ /**
+ */
+ class cpPluginsBasicFilters_EXPORT SignedMaurerDistanceMapImageFilter
+ : public cpPlugins::Interface::ImageToImageFilter
+ {
+ public:
+ typedef SignedMaurerDistanceMapImageFilter Self;
+ typedef cpPlugins::Interface::ImageToImageFilter Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro(
+ SignedMaurerDistanceMapImageFilter,
+ cpPluginsInterfaceImageToImageFilter
+ );
+ cpPlugins_Id_Macro(
+ cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter,
+ DistanceMapFilter
+ );
+
+ protected:
+ SignedMaurerDistanceMapImageFilter( );
+ virtual ~SignedMaurerDistanceMapImageFilter( );
+
+ virtual std::string _GenerateData( );
+
+ template< class I >
+ inline std::string _GD0( itk::DataObject* image );
+
+ template< class I, class O >
+ inline std::string _RealGD( itk::DataObject* image );
+
+ private:
+ // Purposely not implemented
+ SignedMaurerDistanceMapImageFilter( const Self& );
+ Self& operator=( const Self& );
+ };
+
+ // ---------------------------------------------------------------------
+ CPPLUGINS_INHERIT_PROVIDER( SignedMaurerDistanceMapImageFilter );
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__SIGNEDMAURERDISTANCEMAPIMAGEFILTER__H__
+
+// eof - $RCSfile$