From e992c2468610352a34187d9180e2e8f3fd3a6e68 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Fri, 15 Jan 2016 17:09:47 -0500 Subject: [PATCH] ... --- lib/cpPipelineEditor/Block.cxx | 21 + lib/cpPipelineEditor/Block.h | 1 + lib/cpPlugins/Interface/Parameters.cxx | 560 +++++------------- lib/cpPlugins/Interface/Parameters.h | 347 +++++++---- lib/cpPlugins/Interface/Parameters.hxx | 243 ++++---- .../Interface/ParametersQtDialog.cxx | 197 ++++-- lib/cpPlugins/Interface/ParametersQtDialog.h | 4 +- lib/cpPlugins/Interface/ProcessObject.cxx | 8 +- lib/cpPlugins/Interface/Workspace.cxx | 52 -- .../Plugins/BasicFilters/MarchingCubes.cxx | 4 +- lib/cpPlugins/Plugins/IO/ImageReader.cxx | 80 +-- lib/cpPlugins/Plugins/IO/ImageReader.h | 7 +- lib/cpPlugins/Plugins/IO/ImageWriter.cxx | 80 +-- lib/cpPlugins/Plugins/IO/ImageWriter.h | 5 +- lib/cpPlugins/Plugins/IO/MeshReader.cxx | 6 +- lib/cpPlugins/Plugins/IO/MeshReader.h | 3 - lib/cpPlugins/Plugins/IO/MeshWriter.cxx | 74 +-- lib/cpPlugins/Plugins/IO/MeshWriter.h | 3 - 18 files changed, 796 insertions(+), 899 deletions(-) diff --git a/lib/cpPipelineEditor/Block.cxx b/lib/cpPipelineEditor/Block.cxx index 6d473ef..7263cad 100644 --- a/lib/cpPipelineEditor/Block.cxx +++ b/lib/cpPipelineEditor/Block.cxx @@ -2,9 +2,12 @@ #include #include +#include #include +#include #include #include +#include #include "Port.h" #include "Connection.h" @@ -249,4 +252,22 @@ mouseReleaseEvent( QGraphicsSceneMouseEvent* evt ) this->Superclass::mouseReleaseEvent( evt ); } +// ------------------------------------------------------------------------- +void cpPipelineEditor::Block:: +contextMenuEvent( QGraphicsSceneContextMenuEvent* evt ) +{ + QMenu menu; + QAction* configureAction = menu.addAction( "Configure" ); + QAction* updateAction = menu.addAction( "Update" ); + QAction* selectedAction = menu.exec( evt->screenPos( ) ); + + if( selectedAction == configureAction ) + { + auto res = this->m_Filter->ExecConfigurationDialog( NULL ); + } + else if( selectedAction == updateAction ) + { + } // fi +} + // eof - $RCSfile$ diff --git a/lib/cpPipelineEditor/Block.h b/lib/cpPipelineEditor/Block.h index 81de86f..763ecda 100644 --- a/lib/cpPipelineEditor/Block.h +++ b/lib/cpPipelineEditor/Block.h @@ -58,6 +58,7 @@ namespace cpPipelineEditor void _configPort( Port* port ); virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* evt ); + virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* evt ); private: int m_HorzMargin; diff --git a/lib/cpPlugins/Interface/Parameters.cxx b/lib/cpPlugins/Interface/Parameters.cxx index 1b23972..3423bea 100644 --- a/lib/cpPlugins/Interface/Parameters.cxx +++ b/lib/cpPlugins/Interface/Parameters.cxx @@ -2,7 +2,13 @@ #include #include -#include +// ------------------------------------------------------------------------- +const cpPlugins::Interface::Parameters:: +TParameters& cpPlugins::Interface::Parameters:: +GetRawParameters( ) const +{ + return( this->m_Parameters ); +} // ------------------------------------------------------------------------- cpPlugins::Interface:: @@ -44,53 +50,6 @@ Clear( ) this->Modified( ); } -// ------------------------------------------------------------------------- -#define cpPlugins_Parameters_Configure( Y ) \ - void cpPlugins::Interface::Parameters:: \ - ConfigureAs##Y( const TString& name ) \ - { \ - this->m_Parameters[ name ] = TParameter( Self::Y, "" ); \ - this->Modified( ); \ - } - -cpPlugins_Parameters_Configure( String ); -cpPlugins_Parameters_Configure( Bool ); -cpPlugins_Parameters_Configure( Int ); -cpPlugins_Parameters_Configure( Uint ); -cpPlugins_Parameters_Configure( Real ); -cpPlugins_Parameters_Configure( Index ); -cpPlugins_Parameters_Configure( Point ); -cpPlugins_Parameters_Configure( Vector ); -cpPlugins_Parameters_Configure( StringList ); -cpPlugins_Parameters_Configure( BoolList ); -cpPlugins_Parameters_Configure( IntList ); -cpPlugins_Parameters_Configure( UintList ); -cpPlugins_Parameters_Configure( RealList ); -cpPlugins_Parameters_Configure( IndexList ); -cpPlugins_Parameters_Configure( PointList ); -cpPlugins_Parameters_Configure( VectorList ); -cpPlugins_Parameters_Configure( Choices ); - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -ConfigureAsChoices( - const TString& name, const std::vector< TString >& choices - ) -{ - // It is invalid not to give choices when configuring - if( choices.size( ) == 0 ) - return; - - std::stringstream str_choices; - str_choices << choices[ 0 ]; - for( unsigned int i = 1; i < choices.size( ); ++i ) - str_choices << "#" << choices[ i ]; - str_choices << "@"; - this->m_Parameters[ name ] = - TParameter( Self::Choices, str_choices.str( ) ); - this->Modified( ); -} - // ------------------------------------------------------------------------- void cpPlugins::Interface::Parameters:: GetNames( std::vector< TString >& container ) const @@ -106,7 +65,7 @@ cpPlugins::Interface::Parameters:: Type cpPlugins::Interface::Parameters:: GetType( const TString& name ) const { - TParameters::const_iterator i = this->m_Parameters.find( name ); + auto i = this->m_Parameters.find( name ); if( i != this->m_Parameters.end( ) ) return( i->second.first ); else @@ -114,310 +73,207 @@ GetType( const TString& name ) const } // ------------------------------------------------------------------------- -#define cpPlugins_Parameters_Has( Y ) \ - bool cpPlugins::Interface::Parameters:: \ - Has##Y( const TString& name ) const \ - { \ - TParameters::const_iterator i = this->m_Parameters.find( name ); \ - if( i != this->m_Parameters.end( ) ) \ - return( i->second.first == Self::Y ); \ - else \ - return( false ); \ - } - -cpPlugins_Parameters_Has( String ); -cpPlugins_Parameters_Has( Bool ); -cpPlugins_Parameters_Has( Int ); -cpPlugins_Parameters_Has( Uint ); -cpPlugins_Parameters_Has( Real ); -cpPlugins_Parameters_Has( Index ); -cpPlugins_Parameters_Has( Point ); -cpPlugins_Parameters_Has( Vector ); -cpPlugins_Parameters_Has( StringList ); -cpPlugins_Parameters_Has( BoolList ); -cpPlugins_Parameters_Has( IntList ); -cpPlugins_Parameters_Has( UintList ); -cpPlugins_Parameters_Has( RealList ); -cpPlugins_Parameters_Has( IndexList ); -cpPlugins_Parameters_Has( PointList ); -cpPlugins_Parameters_Has( VectorList ); -cpPlugins_Parameters_Has( Choices ); +#define cpPlugins_Parameters_TypeAsString( Y ) \ + if( i->second.first == Self::Y ) \ + return( #Y ) -// ------------------------------------------------------------------------- -cpPlugins::Interface::Parameters:: -TString cpPlugins::Interface::Parameters:: -GetString( const TString& name, bool force ) const +std::string cpPlugins::Interface::Parameters:: +GetTypeAsString( const TString& name ) const { - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i != this->m_Parameters.end( ) ) - { - if( i->second.first == Self::String || !force ) - return( i->second.second ); - - } // fi - return( "" ); + auto i = this->m_Parameters.find( name ); + cpPlugins_Parameters_TypeAsString( String ); + else cpPlugins_Parameters_TypeAsString( Bool ); + else cpPlugins_Parameters_TypeAsString( Int ); + else cpPlugins_Parameters_TypeAsString( Uint ); + else cpPlugins_Parameters_TypeAsString( Real ); + else cpPlugins_Parameters_TypeAsString( Index ); + else cpPlugins_Parameters_TypeAsString( Point ); + else cpPlugins_Parameters_TypeAsString( Vector ); + else cpPlugins_Parameters_TypeAsString( FileName ); + else cpPlugins_Parameters_TypeAsString( PathName ); + else cpPlugins_Parameters_TypeAsString( StringList ); + else cpPlugins_Parameters_TypeAsString( BoolList ); + else cpPlugins_Parameters_TypeAsString( IntList ); + else cpPlugins_Parameters_TypeAsString( UintList ); + else cpPlugins_Parameters_TypeAsString( RealList ); + else cpPlugins_Parameters_TypeAsString( IndexList ); + else cpPlugins_Parameters_TypeAsString( PointList ); + else cpPlugins_Parameters_TypeAsString( VectorList ); + else cpPlugins_Parameters_TypeAsString( FileNameList ); + else cpPlugins_Parameters_TypeAsString( PathNameList ); + else cpPlugins_Parameters_TypeAsString( Choices ); + else return( "NoType" ); } // ------------------------------------------------------------------------- -cpPlugins::Interface::Parameters:: -TBool cpPlugins::Interface::Parameters:: -GetBool( const TString& name ) const -{ - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i != this->m_Parameters.end( ) ) - { - if( i->second.first == Self::Bool ) - return( std::atoi( i->second.second.c_str( ) ) == 1 ); +#define cpPlugins_Parameters_TypeFromString( Y, str ) \ + if( str == std::string( #Y ) ) \ + return( Self::Y ) - } // fi - return( false ); -} - -// ------------------------------------------------------------------------- cpPlugins::Interface::Parameters:: -TInt cpPlugins::Interface::Parameters:: -GetInt( const TString& name ) const +Type cpPlugins::Interface::Parameters:: +GetTypeFromString( const std::string& t ) { - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i != this->m_Parameters.end( ) ) - { - if( i->second.first == Self::Int ) - return( TInt( std::atoi( i->second.second.c_str( ) ) ) ); - - } // fi - return( TInt( 0 ) ); + cpPlugins_Parameters_TypeFromString( String, t ); + else cpPlugins_Parameters_TypeFromString( Bool, t ); + else cpPlugins_Parameters_TypeFromString( Int, t ); + else cpPlugins_Parameters_TypeFromString( Uint, t ); + else cpPlugins_Parameters_TypeFromString( Real, t ); + else cpPlugins_Parameters_TypeFromString( Index, t ); + else cpPlugins_Parameters_TypeFromString( Point, t ); + else cpPlugins_Parameters_TypeFromString( Vector, t ); + else cpPlugins_Parameters_TypeFromString( FileName, t ); + else cpPlugins_Parameters_TypeFromString( PathName, t ); + else cpPlugins_Parameters_TypeFromString( StringList, t ); + else cpPlugins_Parameters_TypeFromString( BoolList, t ); + else cpPlugins_Parameters_TypeFromString( IntList, t ); + else cpPlugins_Parameters_TypeFromString( UintList, t ); + else cpPlugins_Parameters_TypeFromString( RealList, t ); + else cpPlugins_Parameters_TypeFromString( IndexList, t ); + else cpPlugins_Parameters_TypeFromString( PointList, t ); + else cpPlugins_Parameters_TypeFromString( VectorList, t ); + else cpPlugins_Parameters_TypeFromString( FileNameList, t ); + else cpPlugins_Parameters_TypeFromString( PathNameList, t ); + else cpPlugins_Parameters_TypeFromString( Choices, t ); + else return( Self::NoType ); } // ------------------------------------------------------------------------- -cpPlugins::Interface::Parameters:: -TUint cpPlugins::Interface::Parameters:: -GetUint( const TString& name ) const +std::string cpPlugins::Interface::Parameters:: +GetString( const std::string& name, bool force ) const { - TParameters::const_iterator i = this->m_Parameters.find( name ); + auto i = this->m_Parameters.find( name ); if( i != this->m_Parameters.end( ) ) { - if( i->second.first == Self::Uint ) - return( TUint( std::atoi( i->second.second.c_str( ) ) ) ); - - } // fi - return( TUint( 0 ) ); + if( i->second.first == Self::String || force ) + return( i->second.second ); + else + return( "" ); + } + else + return( "" ); } // ------------------------------------------------------------------------- -cpPlugins::Interface::Parameters:: -TReal cpPlugins::Interface::Parameters:: -GetReal( const TString& name ) const +void cpPlugins::Interface::Parameters:: +SetString( const std::string& name, const std::string& v, bool force ) { - TParameters::const_iterator i = this->m_Parameters.find( name ); + auto i = this->m_Parameters.find( name ); if( i != this->m_Parameters.end( ) ) { - if( i->second.first == Self::Real ) + if( i->second.first == Self::String || force ) { - std::istringstream tok_str( i->second.second ); - float v; - tok_str >> v; - return( TReal( v ) ); + i->second.second = v; + this->Modified( ); } // fi } // fi - return( TReal( 0 ) ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::Parameters:: -GetStringList( std::vector< TString >& lst, const TString& name ) const -{ - lst.clear( ); - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::StringList ) - return; - - std::istringstream str( i->second.second ); - std::string token; - while( std::getline( str, token, '#' ) ) - lst.push_back( token ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -GetBoolList( std::vector< TBool >& lst, const TString& name ) const -{ - lst.clear( ); - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::BoolList ) - return; - - std::istringstream str( i->second.second ); - std::string token; - while( std::getline( str, token, '#' ) ) - lst.push_back( std::atoi( token.c_str( ) ) == 1 ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -GetIntList( std::vector< TInt >& lst, const TString& name ) const +ConfigureAsChoices( + const std::string& name, const std::vector< std::string >& choices + ) { - lst.clear( ); - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::IntList ) + // It is invalid not to give choices when configuring + if( choices.size( ) == 0 ) return; - std::istringstream str( i->second.second ); - std::string token; - while( std::getline( str, token, '#' ) ) - lst.push_back( TInt( std::atoi( token.c_str( ) ) ) ); + std::stringstream str_choices; + str_choices << choices[ 0 ]; + for( unsigned int i = 1; i < choices.size( ); ++i ) + str_choices << "#" << choices[ i ]; + str_choices << "@"; + this->m_Parameters[ name ] = + TParameter( Self::Choices, str_choices.str( ) ); + this->Modified( ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -GetUintList( std::vector< TUint >& lst, const TString& name ) const +std::vector< std::string > cpPlugins::Interface::Parameters:: +GetChoices( const TString& name ) const { - lst.clear( ); - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::UintList ) - return; + std::vector< std::string > choices; - std::istringstream str( i->second.second ); - std::string token; - while( std::getline( str, token, '#' ) ) - lst.push_back( TUint( std::atoi( token.c_str( ) ) ) ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -GetRealList( std::vector< TReal >& lst, const TString& name ) const -{ - lst.clear( ); TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::RealList ) - return; - - std::istringstream str( i->second.second ); - std::string token; - while( std::getline( str, token, '#' ) ) + if( i != this->m_Parameters.end( ) ) { - std::istringstream tok_str( token ); - float v; - tok_str >> v; - lst.push_back( TReal( v ) ); - - } // elihw -} + if( i->second.first == Self::Choices ) + { + std::istringstream str_choices( i->second.second ); + std::string real_choices; + std::getline( str_choices, real_choices, '@' ); + std::istringstream str( real_choices ); + std::string token; + while( std::getline( str, token, '#' ) ) + choices.push_back( token ); -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -GetChoices( std::vector< TString >& choices, const TString& name ) const -{ - choices.clear( ); - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::Choices ) - return; + } // fi - std::istringstream str_choices( i->second.second ); - std::string real_choices; - std::getline( str_choices, real_choices, '@' ); - std::istringstream str( real_choices ); - std::string token; - while( std::getline( str, token, '#' ) ) - choices.push_back( token ); + } // fi + return( choices ); } // ------------------------------------------------------------------------- -cpPlugins::Interface::Parameters:: -TString cpPlugins::Interface::Parameters:: -GetSelectedChoice( const TString& name ) const +std::string cpPlugins::Interface::Parameters:: +GetSelectedChoice( const std::string& name ) const { - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return( "" ); - if( i->second.first != Self::Choices ) + auto i = this->m_Parameters.find( name ); + if( i != this->m_Parameters.end( ) ) + { + if( i->second.first == Self::Choices ) + { + std::istringstream str_choices( i->second.second ); + std::string real_choice; + std::getline( str_choices, real_choice, '@' ); + std::getline( str_choices, real_choice, '@' ); + return( real_choice ); + } + else + return( "" ); + } + else return( "" ); - - std::istringstream str_choices( i->second.second ); - std::string real_choice; - std::getline( str_choices, real_choice, '@' ); - std::getline( str_choices, real_choice, '@' ); - return( real_choice ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::Parameters:: -SetString( const TString& name, const TString& v, bool force ) +bool cpPlugins::Interface::Parameters:: +SetSelectedChoice( const TString& name, const TString& choice ) { - TParameters::iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first != Self::String && force ) - return; - i->second.second = v; - this->Modified( ); -} - -// ------------------------------------------------------------------------- -#define cpPlugins_Parameters_Set( Y ) \ - void cpPlugins::Interface::Parameters:: \ - Set##Y( const TString& name, const T##Y& v ) \ - { \ - TParameters::iterator i = this->m_Parameters.find( name ); \ - if( i == this->m_Parameters.end( ) ) \ - return; \ - if( i->second.first != Self::Y ) \ - return; \ - std::stringstream str; \ - str << v; \ - i->second.second = str.str( ); \ - this->Modified( ); \ - } - -cpPlugins_Parameters_Set( Bool ); -cpPlugins_Parameters_Set( Int ); -cpPlugins_Parameters_Set( Uint ); -cpPlugins_Parameters_Set( Real ); - -// ------------------------------------------------------------------------- -#define cpPlugins_Parameters_Add( Y ) \ - void cpPlugins::Interface::Parameters:: \ - AddTo##Y##List( const TString& name, const T##Y& v ) \ - { \ - TParameters::iterator i = this->m_Parameters.find( name ); \ - if( i == this->m_Parameters.end( ) ) \ - return; \ - if( i->second.first != Self::Y##List ) \ - return; \ - std::stringstream str; \ - if( i->second.second == "" ) \ - str << v; \ - else \ - str << "#" << v; \ - i->second.second += str.str( ); \ - this->Modified( ); \ + auto i = this->m_Parameters.find( name ); + if( i != this->m_Parameters.end( ) ) + { + if( i->second.first == Self::Choices ) + { + std::vector< std::string > c = this->GetChoices( name ); + if( std::find( c.begin( ), c.end( ), choice ) != c.end( ) ) + { + std::istringstream str_choices( i->second.second ); + std::string choices; + std::getline( str_choices, choices, '@' ); + std::stringstream new_choices; + new_choices << choices << "@" << choice; + i->second.second = new_choices.str( ); + return( true ); + } + else + return( false ); + } + else + return( false ); } - -cpPlugins_Parameters_Add( String ); -cpPlugins_Parameters_Add( Bool ); -cpPlugins_Parameters_Add( Int ); -cpPlugins_Parameters_Add( Uint ); -cpPlugins_Parameters_Add( Real ); + else + return( false ); +} // ------------------------------------------------------------------------- -#define cpPlugins_Parameters_Clear( Y ) \ +#define cpPlugins_Parameters_ClearList( Y ) \ void cpPlugins::Interface::Parameters:: \ Clear##Y##List( const TString& name ) \ { \ - TParameters::iterator i = this->m_Parameters.find( name ); \ + auto i = this->m_Parameters.find( name ); \ if( i == this->m_Parameters.end( ) ) \ return; \ if( i->second.first != Self::Y##List ) \ @@ -426,40 +282,9 @@ cpPlugins_Parameters_Add( Real ); this->Modified( ); \ } -cpPlugins_Parameters_Clear( String ); -cpPlugins_Parameters_Clear( Bool ); -cpPlugins_Parameters_Clear( Int ); -cpPlugins_Parameters_Clear( Uint ); -cpPlugins_Parameters_Clear( Real ); -cpPlugins_Parameters_Clear( Index ); -cpPlugins_Parameters_Clear( Point ); -cpPlugins_Parameters_Clear( Vector ); - -// ------------------------------------------------------------------------- -bool cpPlugins::Interface::Parameters:: -SetSelectedChoice( const TString& name, const TString& choice ) -{ - TParameters::iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return( false ); - if( i->second.first != Self::Choices ) - return( false ); - - std::vector< TString > c; - this->GetChoices( c, name ); - if( std::find( c.begin( ), c.end( ), choice ) != c.end( ) ) - { - std::istringstream str_choices( i->second.second ); - std::string choices; - std::getline( str_choices, choices, '@' ); - std::stringstream new_choices; - new_choices << choices << "@" << choice; - i->second.second = new_choices.str( ); - return( true ); - } - else - return( false ); -} +cpPlugins_Parameters_ClearList( Index ); +cpPlugins_Parameters_ClearList( Point ); +cpPlugins_Parameters_ClearList( Vector ); // ------------------------------------------------------------------------- bool cpPlugins::Interface::Parameters:: @@ -474,40 +299,7 @@ ToXML( TiXmlElement* parent_elem ) const TiXmlElement* p = new TiXmlElement( "parameter" ); p->SetAttribute( "name", pIt->first.c_str( ) ); p->SetAttribute( "value", pIt->second.second.c_str( ) ); - if( pIt->second.first == Self::String ) - p->SetAttribute( "type", "String" ); - else if( pIt->second.first == Self::Bool ) - p->SetAttribute( "type", "Bool" ); - else if( pIt->second.first == Self::Int ) - p->SetAttribute( "type", "Int" ); - else if( pIt->second.first == Self::Uint ) - p->SetAttribute( "type", "Uint" ); - else if( pIt->second.first == Self::Real ) - p->SetAttribute( "type", "Real" ); - else if( pIt->second.first == Self::Index ) - p->SetAttribute( "type", "Index" ); - else if( pIt->second.first == Self::Point ) - p->SetAttribute( "type", "Point" ); - else if( pIt->second.first == Self::Vector ) - p->SetAttribute( "type", "Vector" ); - else if( pIt->second.first == Self::StringList ) - p->SetAttribute( "type", "StringList" ); - else if( pIt->second.first == Self::BoolList ) - p->SetAttribute( "type", "BoolList" ); - else if( pIt->second.first == Self::IntList ) - p->SetAttribute( "type", "IntList" ); - else if( pIt->second.first == Self::UintList ) - p->SetAttribute( "type", "UintList" ); - else if( pIt->second.first == Self::RealList ) - p->SetAttribute( "type", "RealList" ); - else if( pIt->second.first == Self::IndexList ) - p->SetAttribute( "type", "IndexList" ); - else if( pIt->second.first == Self::PointList ) - p->SetAttribute( "type", "PointList" ); - else if( pIt->second.first == Self::VectorList ) - p->SetAttribute( "type", "VectorList" ); - else if( pIt->second.first == Self::Choices ) - p->SetAttribute( "type", "Choices" ); + p->SetAttribute( "type", this->GetTypeAsString( pIt->first ).c_str( ) ); parent_elem->LinkEndChild( p ); } // rof @@ -530,43 +322,7 @@ FromXML( const TiXmlElement* filter_elem ) { TParameter value; value.second = param->Attribute( "value" ); - - std::string param_type_str( param_type ); - if( param_type_str == "Bool" ) - value.first = Self::Bool; - else if( param_type_str == "Int" ) - value.first = Self::Int; - else if( param_type_str == "Uint" ) - value.first = Self::Uint; - else if( param_type_str == "Real" ) - value.first = Self::Real; - else if( param_type_str == "Index" ) - value.first = Self::Index; - else if( param_type_str == "Point" ) - value.first = Self::Point; - else if( param_type_str == "Vector" ) - value.first = Self::Vector; - else if( param_type_str == "StringList" ) - value.first = Self::StringList; - else if( param_type_str == "BoolList" ) - value.first = Self::BoolList; - else if( param_type_str == "IntList" ) - value.first = Self::IntList; - else if( param_type_str == "UintList" ) - value.first = Self::UintList; - else if( param_type_str == "RealList" ) - value.first = Self::RealList; - else if( param_type_str == "IndexList" ) - value.first = Self::IndexList; - else if( param_type_str == "PointList" ) - value.first = Self::PointList; - else if( param_type_str == "VectorList" ) - value.first = Self::VectorList; - else if( param_type_str == "Choices" ) - value.first = Self::Choices; - else - value.first = Self::String; - + value.first = Self::GetTypeFromString( param_type ); this->m_Parameters[ param_name ] = value; } // fi diff --git a/lib/cpPlugins/Interface/Parameters.h b/lib/cpPlugins/Interface/Parameters.h index d8a1f57..a2cb861 100644 --- a/lib/cpPlugins/Interface/Parameters.h +++ b/lib/cpPlugins/Interface/Parameters.h @@ -5,14 +5,134 @@ #include #include +#include #include #include #include #include +// Some forward declarations class TiXmlElement; +// ------------------------------------------------------------------------- +#define cpPlugins_Parameters_Configure( Y ) \ + void ConfigureAs##Y( const std::string& name ) \ + { \ + this->m_Parameters[ name ] = TParameter( Self::Y, "" ); \ + this->Modified( ); \ + } \ + bool Has##Y( const std::string& name ) const \ + { \ + auto i = this->m_Parameters.find( name ); \ + if( i != this->m_Parameters.end( ) ) \ + return( i->second.first == Self::Y ); \ + else \ + return( false ); \ + } + +// ------------------------------------------------------------------------- +#define cpPlugins_Parameters_GetSet( Y ) \ + T##Y Get##Y( const std::string& name ) const \ + { \ + auto i = this->m_Parameters.find( name ); \ + if( i != this->m_Parameters.end( ) ) \ + { \ + if( i->second.first == Self::Y ) \ + { \ + if( typeid( T##Y ) != typeid( std::string ) ) \ + { \ + std::istringstream tok_str( i->second.second ); \ + T##Y v; \ + tok_str >> v; \ + return( v ); \ + } \ + else \ + { \ + const T##Y* ptr = \ + reinterpret_cast< const T##Y* >( \ + &( i->second.second ) \ + ); \ + return( *ptr ); \ + } \ + } \ + } \ + return( T##Y( 0 ) ); \ + } \ + void Set##Y( const std::string& name, const T##Y& v ) \ + { \ + auto i = this->m_Parameters.find( name ); \ + if( i != this->m_Parameters.end( ) ) \ + { \ + if( i->second.first == Self::Y ) \ + { \ + if( typeid( T##Y ) != typeid( std::string ) ) \ + { \ + std::stringstream str; \ + str << v; \ + i->second.second = str.str( ); \ + } \ + else \ + i->second.second = \ + *( reinterpret_cast< const std::string* >( &v ) ); \ + this->Modified( ); \ + } \ + } \ + } + +// ------------------------------------------------------------------------- +#define cpPlugins_Parameters_GetSetList( Y ) \ + std::vector< T##Y > Get##Y##List( const std::string& name ) const \ + { \ + std::vector< T##Y > lst; \ + std::vector< std::string >* slst = \ + reinterpret_cast< std::vector< std::string >* >( &lst ); \ + auto i = this->m_Parameters.find( name ); \ + if( i != this->m_Parameters.end( ) ) \ + { \ + if( i->second.first == Self::Y##List ) \ + { \ + std::istringstream str( i->second.second ); \ + std::string token; \ + while( std::getline( str, token, '#' ) ) \ + { \ + if( typeid( T##Y ) != typeid( std::string ) ) \ + { \ + std::istringstream tok_str( token ); \ + T##Y v; \ + tok_str >> v; \ + lst.push_back( v ); \ + } \ + else \ + slst->push_back( token ); \ + } \ + } \ + } \ + return( lst ); \ + } \ + void AddTo##Y##List( const std::string& name, const T##Y& v ) \ + { \ + auto i = this->m_Parameters.find( name ); \ + if( i != this->m_Parameters.end( ) ) \ + { \ + if( i->second.first == Self::Y##List ) \ + { \ + std::stringstream str; \ + str << i->second.second << "#" << v; \ + i->second.second = str.str( ); \ + } \ + } \ + } \ + void Clear##Y##List( const std::string& name ) \ + { \ + auto i = this->m_Parameters.find( name ); \ + if( i != this->m_Parameters.end( ) ) \ + { \ + if( i->second.first == Self::Y##List ) \ + i->second.second = ""; \ + } \ + } + namespace cpPlugins { namespace Interface @@ -33,12 +153,14 @@ namespace cpPlugins enum Type { - String , Bool , Int , - Uint , Real , Index , - Point , Vector , StringList , - BoolList , IntList , UintList , - RealList , IndexList , PointList , - VectorList , Choices , NoType + String , Bool , Int , + Uint , Real , Index , + Point , Vector , FileName , + PathName , StringList , BoolList , + IntList , UintList , RealList , + IndexList , PointList , VectorList , + FileNameList , PathNameList , Choices , + NoType }; typedef bool TBool; @@ -46,16 +168,56 @@ namespace cpPlugins typedef unsigned long TUint; typedef double TReal; typedef std::string TString; + typedef std::string TFileName; + typedef std::string TPathName; - typedef std::pair< Self::Type, TString > TParameter; - typedef std::map< TString, TParameter > TParameters; + typedef std::pair< Self::Type, std::string > TParameter; + typedef std::map< std::string, TParameter > TParameters; public: itkNewMacro( Self ); itkTypeMacro( cpPlugins::Interface::Parameters, itk::Object ); + cpPlugins_Parameters_Configure( String ); + cpPlugins_Parameters_Configure( Bool ); + cpPlugins_Parameters_Configure( Int ); + cpPlugins_Parameters_Configure( Uint ); + cpPlugins_Parameters_Configure( Real ); + cpPlugins_Parameters_Configure( Index ); + cpPlugins_Parameters_Configure( Point ); + cpPlugins_Parameters_Configure( Vector ); + cpPlugins_Parameters_Configure( FileName ); + cpPlugins_Parameters_Configure( PathName ); + cpPlugins_Parameters_Configure( StringList ); + cpPlugins_Parameters_Configure( BoolList ); + cpPlugins_Parameters_Configure( IntList ); + cpPlugins_Parameters_Configure( UintList ); + cpPlugins_Parameters_Configure( RealList ); + cpPlugins_Parameters_Configure( IndexList ); + cpPlugins_Parameters_Configure( PointList ); + cpPlugins_Parameters_Configure( VectorList ); + cpPlugins_Parameters_Configure( FileNameList ); + cpPlugins_Parameters_Configure( PathNameList ); + cpPlugins_Parameters_Configure( Choices ); + + cpPlugins_Parameters_GetSet( Bool ); + cpPlugins_Parameters_GetSet( Int ); + cpPlugins_Parameters_GetSet( Uint ); + cpPlugins_Parameters_GetSet( Real ); + cpPlugins_Parameters_GetSet( FileName ); + cpPlugins_Parameters_GetSet( PathName ); + + cpPlugins_Parameters_GetSetList( String ); + cpPlugins_Parameters_GetSetList( Bool ); + cpPlugins_Parameters_GetSetList( Int ); + cpPlugins_Parameters_GetSetList( Uint ); + cpPlugins_Parameters_GetSetList( Real ); + cpPlugins_Parameters_GetSetList( FileName ); + cpPlugins_Parameters_GetSetList( PathName ); + public: // To impact pipeline + const TParameters& GetRawParameters( ) const; virtual ProcessObject* GetProcessObject( ); virtual const ProcessObject* GetProcessObject( ) const; virtual void SetProcessObject( ProcessObject* v ); @@ -64,148 +226,87 @@ namespace cpPlugins // Parameters container configuration void Clear( ); - void ConfigureAsString( const TString& name ); - void ConfigureAsBool( const TString& name ); - void ConfigureAsInt( const TString& name ); - void ConfigureAsUint( const TString& name ); - void ConfigureAsReal( const TString& name ); - void ConfigureAsIndex( const TString& name ); - void ConfigureAsPoint( const TString& name ); - void ConfigureAsVector( const TString& name ); - void ConfigureAsStringList( const TString& name ); - void ConfigureAsBoolList( const TString& name ); - void ConfigureAsIntList( const TString& name ); - void ConfigureAsUintList( const TString& name ); - void ConfigureAsRealList( const TString& name ); - void ConfigureAsIndexList( const TString& name ); - void ConfigureAsPointList( const TString& name ); - void ConfigureAsVectorList( const TString& name ); - void ConfigureAsChoices( const TString& name ); - void ConfigureAsChoices( - const TString& name, const std::vector< TString >& choices - ); - // Get methods - void GetNames( std::vector< TString >& container ) const; - Type GetType( const TString& name ) const; - - bool HasString( const TString& name ) const; - bool HasBool( const TString& name ) const; - bool HasInt( const TString& name ) const; - bool HasUint( const TString& name ) const; - bool HasReal( const TString& name ) const; - bool HasIndex( const TString& name ) const; - bool HasPoint( const TString& name ) const; - bool HasVector( const TString& name ) const; - bool HasStringList( const TString& name ) const; - bool HasBoolList( const TString& name ) const; - bool HasIntList( const TString& name ) const; - bool HasUintList( const TString& name ) const; - bool HasRealList( const TString& name ) const; - bool HasIndexList( const TString& name ) const; - bool HasPointList( const TString& name ) const; - bool HasVectorList( const TString& name ) const; - bool HasChoices( const TString& name ) const; - - TString GetString( const TString& name, bool force = true ) const; - TBool GetBool( const TString& name ) const; - TInt GetInt( const TString& name ) const; - TUint GetUint( const TString& name ) const; - TReal GetReal( const TString& name ) const; - - void GetStringList( - std::vector< TString >& lst, const TString& name - ) const; - void GetBoolList( - std::vector< TBool >& lst, const TString& name - ) const; - void GetIntList( - std::vector< TInt >& lst, const TString& name - ) const; - void GetUintList( - std::vector< TUint >& lst, const TString& name + void GetNames( std::vector< std::string >& container ) const; + Type GetType( const std::string& name ) const; + std::string GetTypeAsString( const std::string& name ) const; + static Type GetTypeFromString( const std::string& t ); + + // Base string methods + std::string GetString( + const std::string& name, bool force = true ) const; - void GetRealList( - std::vector< TReal >& lst, const TString& name - ) const; - - void GetChoices( - std::vector< TString >& choices, const TString& name - ) const; - TString GetSelectedChoice( const TString& name ) const; + void SetString( + const std::string& name, const std::string& v, bool force = true + ); - template< class I > - inline I GetIndex( const TString& name, const TUint& dim ) const; - template< class P > - inline P GetPoint( const TString& name, const TUint& dim ) const; - template< class V > - inline V GetVector( const TString& name, const TUint& dim ) const; + void ConfigureAsChoices( + const std::string& name, const std::vector< std::string >& choices + ); + std::vector< std::string > GetChoices( const std::string& name ) const; + std::string GetSelectedChoice( const std::string& name ) const; + bool SetSelectedChoice( + const std::string& name, const std::string& choice + ); + // Some templated methods template< class I > - inline void GetIndexList( - std::vector< I >& lst, const TString& name, const TUint& dim + I GetIndex( + const std::string& name, const unsigned int& dim ) const; template< class P > - inline void GetPointList( - std::vector< P >& lst, const TString& name, const TUint& dim + P GetPoint( + const std::string& name, const unsigned int& dim ) const; template< class V > - inline void GetVectorList( - std::vector< V >& lst, const TString& name, const TUint& dim + V GetVector( + const std::string& name, const unsigned int& dim ) const; - // Set methods - void SetString( - const TString& name, const TString& v, bool force = true - ); - void SetBool( const TString& name, const TBool& v ); - void SetInt( const TString& name, const TInt& v ); - void SetUint( const TString& name, const TUint& v ); - void SetReal( const TString& name, const TReal& v ); - template< class I > - inline void SetIndex( - const TString& name, const TUint& dim, const I& v + void SetIndex( + const std::string& name, const unsigned int& dim, const I& v ); template< class P > - inline void SetPoint( - const TString& name, const TUint& dim, const P& v + void SetPoint( + const std::string& name, const unsigned int& dim, const P& v ); template< class V > - inline void SetVector( - const TString& name, const TUint& dim, const V& v + void SetVector( + const std::string& name, const unsigned int& dim, const V& v ); - void AddToStringList( const TString& name, const TString& v ); - void AddToBoolList( const TString& name, const TBool& v ); - void AddToIntList( const TString& name, const TInt& v ); - void AddToUintList( const TString& name, const TUint& v ); - void AddToRealList( const TString& name, const TReal& v ); + template< class I > + std::vector< I > GetIndexList( + const std::string& name, const unsigned int& dim + ) const; + template< class P > + std::vector< P > GetPointList( + const std::string& name, const unsigned int& dim + ) const; + template< class V > + std::vector< V > GetVectorList( + const std::string& name, const unsigned int& dim + ) const; template< class I > - inline void AddToIndexList( - const TString& name, const TUint& dim, const I& v + void AddToIndexList( + const std::string& name, const unsigned int& dim, const I& v ); template< class P > - inline void AddToPointList( - const TString& name, const TUint& dim, const P& v + void AddToPointList( + const std::string& name, const unsigned int& dim, const P& v ); template< class P > - inline void AddToVectorList( - const TString& name, const TUint& dim, const P& v + void AddToVectorList( + const std::string& name, const unsigned int& dim, const P& v ); - void ClearStringList( const TString& name ); - void ClearBoolList( const TString& name ); - void ClearIntList( const TString& name ); - void ClearUintList( const TString& name ); - void ClearRealList( const TString& name ); - void ClearIndexList( const TString& name ); - void ClearPointList( const TString& name ); - void ClearVectorList( const TString& name ); - - bool SetSelectedChoice( const TString& name, const TString& choice ); + void ClearIndexList( const std::string& name ); + void ClearPointList( const std::string& name ); + void ClearVectorList( const std::string& name ); + // XML "streaming" bool ToXML( TiXmlElement* parent_elem ) const; bool FromXML( const TiXmlElement* filter_elem ); diff --git a/lib/cpPlugins/Interface/Parameters.hxx b/lib/cpPlugins/Interface/Parameters.hxx index d0fb9c2..eecb2b6 100644 --- a/lib/cpPlugins/Interface/Parameters.hxx +++ b/lib/cpPlugins/Interface/Parameters.hxx @@ -4,10 +4,10 @@ // ------------------------------------------------------------------------- template< class I > I cpPlugins::Interface::Parameters:: -GetIndex( const TString& name, const TUint& dim ) const +GetIndex( const std::string& name, const unsigned int& dim ) const { I v; - TParameters::const_iterator i = this->m_Parameters.find( name ); + auto i = this->m_Parameters.find( name ); if( i != this->m_Parameters.end( ) ) { if( i->second.first == Self::Index ) @@ -36,10 +36,10 @@ GetIndex( const TString& name, const TUint& dim ) const // ------------------------------------------------------------------------- template< class P > P cpPlugins::Interface::Parameters:: -GetPoint( const TString& name, const TUint& dim ) const +GetPoint( const std::string& name, const unsigned int& dim ) const { P v; - TParameters::const_iterator i = this->m_Parameters.find( name ); + auto i = this->m_Parameters.find( name ); if( i != this->m_Parameters.end( ) ) { if( i->second.first == Self::Point ) @@ -69,10 +69,10 @@ GetPoint( const TString& name, const TUint& dim ) const // ------------------------------------------------------------------------- template< class V > V cpPlugins::Interface::Parameters:: -GetVector( const TString& name, const TUint& dim ) const +GetVector( const std::string& name, const unsigned int& dim ) const { V v; - TParameters::const_iterator i = this->m_Parameters.find( name ); + auto i = this->m_Parameters.find( name ); if( i != this->m_Parameters.end( ) ) { if( i->second.first == Self::Vector ) @@ -102,114 +102,7 @@ GetVector( const TString& name, const TUint& dim ) const // ------------------------------------------------------------------------- template< class I > void cpPlugins::Interface::Parameters:: -GetIndexList( - std::vector< I >& lst, const TString& name, const TUint& dim - ) const -{ - lst.clear( ); - - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first == Self::IndexList ) - return; - - std::istringstream str( i->second.second ); - std::string token; - unsigned int d = 0; - while( std::getline( str, token, '#' ) ) - { - std::istringstream str2( token ); - std::string token2; - unsigned int d = 0; - I v; - while( std::getline( str2, token2, ';' ) && d < dim ) - { - v[ d ] = std::atoi( token.c_str( ) ); - d++; - - } // elihw - lst.push_back( v ); - - } // elihw -} - -// ------------------------------------------------------------------------- -template< class P > -void cpPlugins::Interface::Parameters:: -GetPointList( - std::vector< P >& lst, const TString& name, const TUint& dim - ) const -{ - lst.clear( ); - - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first == Self::PointList ) - return; - - std::istringstream str( i->second.second ); - std::string token; - unsigned int d = 0; - while( std::getline( str, token, '#' ) ) - { - std::istringstream str2( token ); - std::string token2; - unsigned int d = 0; - P v; - while( std::getline( str2, token2, ';' ) && d < dim ) - { - std::istringstream tok_str( token ); - tok_str >> v[ d ]; - d++; - - } // elihw - lst.push_back( v ); - - } // elihw -} - -// ------------------------------------------------------------------------- -template< class V > -void cpPlugins::Interface::Parameters:: -GetVectorList( - std::vector< V >& lst, const TString& name, const TUint& dim - ) const -{ - lst.clear( ); - - TParameters::const_iterator i = this->m_Parameters.find( name ); - if( i == this->m_Parameters.end( ) ) - return; - if( i->second.first == Self::VectorList ) - return; - - std::istringstream str( i->second.second ); - std::string token; - unsigned int d = 0; - while( std::getline( str, token, '#' ) ) - { - std::istringstream str2( token ); - std::string token2; - unsigned int d = 0; - V v; - while( std::getline( str2, token2, ';' ) && d < dim ) - { - std::istringstream tok_str( token ); - tok_str >> v[ d ]; - d++; - - } // elihw - lst.push_back( v ); - - } // elihw -} - -// ------------------------------------------------------------------------- -template< class I > -void cpPlugins::Interface::Parameters:: -SetIndex( const TString& name, const TUint& dim, const I& v ) +SetIndex( const std::string& name, const unsigned int& dim, const I& v ) { TParameters::iterator i = this->m_Parameters.find( name ); if( i == this->m_Parameters.end( ) ) @@ -228,7 +121,7 @@ SetIndex( const TString& name, const TUint& dim, const I& v ) // ------------------------------------------------------------------------- template< class P > void cpPlugins::Interface::Parameters:: -SetPoint( const TString& name, const TUint& dim, const P& v ) +SetPoint( const std::string& name, const unsigned int& dim, const P& v ) { TParameters::iterator i = this->m_Parameters.find( name ); if( i == this->m_Parameters.end( ) ) @@ -247,7 +140,7 @@ SetPoint( const TString& name, const TUint& dim, const P& v ) // ------------------------------------------------------------------------- template< class V > void cpPlugins::Interface::Parameters:: -SetVector( const TString& name, const TUint& dim, const V& v ) +SetVector( const std::string& name, const unsigned int& dim, const V& v ) { TParameters::iterator i = this->m_Parameters.find( name ); if( i == this->m_Parameters.end( ) ) @@ -263,10 +156,122 @@ SetVector( const TString& name, const TUint& dim, const V& v ) this->Modified( ); } +// ------------------------------------------------------------------------- +template< class I > +std::vector< I > cpPlugins::Interface::Parameters:: +GetIndexList( const std::string& name, const unsigned int& dim ) const +{ + std::vector< I > lst; + auto i = this->m_Parameters.find( name ); + if( i != this->m_Parameters.end( ) ) + { + if( i->second.first == Self::IndexList ) + { + std::istringstream str( i->second.second ); + std::string token; + unsigned int d = 0; + while( std::getline( str, token, '#' ) ) + { + std::istringstream str2( token ); + std::string token2; + unsigned int d = 0; + I v; + while( std::getline( str2, token2, ';' ) && d < dim ) + { + v[ d ] = std::atoi( token.c_str( ) ); + d++; + + } // elihw + lst.push_back( v ); + + } // elihw + + } // fi + + } // fi + return( lst ); +} + +// ------------------------------------------------------------------------- +template< class P > +std::vector< P > cpPlugins::Interface::Parameters:: +GetPointList( const std::string& name, const unsigned int& dim ) const +{ + std::vector< P > lst; + + auto i = this->m_Parameters.find( name ); + if( i != this->m_Parameters.end( ) ) + { + if( i->second.first == Self::PointList ) + { + std::istringstream str( i->second.second ); + std::string token; + unsigned int d = 0; + while( std::getline( str, token, '#' ) ) + { + std::istringstream str2( token ); + std::string token2; + unsigned int d = 0; + P v; + while( std::getline( str2, token2, ';' ) && d < dim ) + { + std::istringstream tok_str( token ); + tok_str >> v[ d ]; + d++; + + } // elihw + lst.push_back( v ); + + } // elihw + + } // fi + + } // fi + return( lst ); +} + +// ------------------------------------------------------------------------- +template< class V > +std::vector< V > cpPlugins::Interface::Parameters:: +GetVectorList( const std::string& name, const unsigned int& dim ) const +{ + std::vector< V > lst; + + auto i = this->m_Parameters.find( name ); + if( i != this->m_Parameters.end( ) ) + { + if( i->second.first == Self::VectorList ) + { + std::istringstream str( i->second.second ); + std::string token; + unsigned int d = 0; + while( std::getline( str, token, '#' ) ) + { + std::istringstream str2( token ); + std::string token2; + unsigned int d = 0; + V v; + while( std::getline( str2, token2, ';' ) && d < dim ) + { + std::istringstream tok_str( token ); + tok_str >> v[ d ]; + d++; + + } // elihw + lst.push_back( v ); + + } // elihw + + } // fi + + } // fi + return( lst ); +} + // ------------------------------------------------------------------------- template< class I > void cpPlugins::Interface::Parameters:: -AddToIndexList( const TString& name, const TUint& dim, const I& v ) +AddToIndexList( const std::string& name, const unsigned int& dim, const I& v ) { TParameters::iterator i = this->m_Parameters.find( name ); if( i == this->m_Parameters.end( ) ) @@ -288,7 +293,7 @@ AddToIndexList( const TString& name, const TUint& dim, const I& v ) // ------------------------------------------------------------------------- template< class P > void cpPlugins::Interface::Parameters:: -AddToPointList( const TString& name, const TUint& dim, const P& v ) +AddToPointList( const std::string& name, const unsigned int& dim, const P& v ) { TParameters::iterator i = this->m_Parameters.find( name ); if( i == this->m_Parameters.end( ) ) @@ -310,7 +315,7 @@ AddToPointList( const TString& name, const TUint& dim, const P& v ) // ------------------------------------------------------------------------- template< class V > void cpPlugins::Interface::Parameters:: -AddToVectorList( const TString& name, const TUint& dim, const V& v ) +AddToVectorList( const std::string& name, const unsigned int& dim, const V& v ) { TParameters::iterator i = this->m_Parameters.find( name ); if( i == this->m_Parameters.end( ) ) diff --git a/lib/cpPlugins/Interface/ParametersQtDialog.cxx b/lib/cpPlugins/Interface/ParametersQtDialog.cxx index 90393ff..431ddfe 100644 --- a/lib/cpPlugins/Interface/ParametersQtDialog.cxx +++ b/lib/cpPlugins/Interface/ParametersQtDialog.cxx @@ -14,6 +14,7 @@ #include #include #include +#include #include // ------------------------------------------------------------------------- @@ -157,96 +158,163 @@ setParameters( Parameters* parameters ) if( this->m_Parameters == NULL ) return( false ); + // Set dialog title + auto filter = this->m_Parameters->GetProcessObject( ); + std::stringstream title; + title << "Parameters for \"" << filter->GetName( ) << "\""; + this->m_Title->setText( title.str( ).c_str( ) ); + // Put values - std::vector< std::string > names; - this->m_Parameters->GetNames( names ); - std::vector< std::string >::const_iterator nIt = names.begin( ); - for( ; nIt != names.end( ); ++nIt ) + auto& raw_params = this->m_Parameters->GetRawParameters( ); + for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt ) { - Parameters::Type pt = this->m_Parameters->GetType( *nIt ); - QWidget* w_input = NULL; - if( pt == Parameters::String ) + switch( pIt->second.first ) + { + case Parameters::String: { QLineEdit* v_string = new QLineEdit( this ); - v_string->setText( "Enter some text!!!" ); + v_string->setText( pIt->second.second.c_str( ) ); w_input = v_string; } - else if( pt == Parameters::Bool ) + break; + case Parameters::Bool: { QCheckBox* v_bool = new QCheckBox( this ); v_bool->setText( "[ON/OFF]" ); - v_bool->setChecked( this->m_Parameters->GetBool( *nIt ) ); + v_bool->setChecked( pIt->second.second == "1" ); w_input = v_bool; } - else if( pt == Parameters::Uint ) + break; + case Parameters::Int: + case Parameters::Uint: { + std::istringstream tok_str( pIt->second.second ); + int v; + tok_str >> v; QSpinBox* v_uint = new QSpinBox( this ); - v_uint->setMinimum( 0 ); + if( pIt->second.first == Parameters::Uint ) + v_uint->setMinimum( 0 ); + else + v_uint->setMinimum( -std::numeric_limits< int >::max( ) ); v_uint->setMaximum( std::numeric_limits< int >::max( ) ); - v_uint->setValue( this->m_Parameters->GetUint( *nIt ) ); + v_uint->setValue( v ); w_input = v_uint; } - else if( pt == Parameters::Int ) - { - QSpinBox* v_int = new QSpinBox( this ); - v_int->setMinimum( -std::numeric_limits< int >::max( ) ); - v_int->setMaximum( std::numeric_limits< int >::max( ) ); - v_int->setValue( this->m_Parameters->GetInt( *nIt ) ); - w_input = v_int; - } - else if( pt == Parameters::Real ) + break; + case Parameters::Real: { + std::istringstream tok_str( pIt->second.second ); + double v; + tok_str >> v; QDoubleSpinBox* v_double = new QDoubleSpinBox( this ); v_double->setDecimals( 3 ); v_double->setMinimum( -std::numeric_limits< double >::max( ) ); v_double->setMaximum( std::numeric_limits< double >::max( ) ); - v_double->setValue( this->m_Parameters->GetReal( *nIt ) ); + v_double->setValue( v ); w_input = v_double; } - else if( - pt == Parameters::StringList || - pt == Parameters::IntList || - pt == Parameters::UintList || - pt == Parameters::RealList - ) + break; + case Parameters::Index: + break; + case Parameters::Point: + break; + case Parameters::Vector: + break; + case Parameters::FileName: { - cpPlugins::Interface::ParametersListWidget* l_double = - new cpPlugins::Interface::ParametersListWidget( *nIt, this ); - w_input = l_double; + QFrame* frame = new QFrame( this ); + QHBoxLayout* layout = new QHBoxLayout( frame ); + QLineEdit* v_string = new QLineEdit( frame ); + v_string->setText( pIt->second.second.c_str( ) ); + QPushButton* v_button = new QPushButton( frame ); + v_button->setObjectName( pIt->first.c_str( ) ); + v_button->setText( "..." ); + v_button->connect( + v_button, SIGNAL( clicked( ) ), + this, SLOT( _dlg_MultipleFiles( ) ) + ); + + layout->addWidget( v_string ); + layout->addWidget( v_button ); + w_input = frame; } - else if( pt == Parameters::Point || pt == Parameters::Index ) - { - vtkSmartPointer< SingleSeedCommand > command = - vtkSmartPointer< SingleSeedCommand >::New( ); - command->Dialog = this; - command->Name = *nIt; - - auto iIt = this->m_Interactors.begin( ); - for( ; iIt != this->m_Interactors.end( ); ++iIt ) - { - TStyle* style = - dynamic_cast< TStyle* >( ( *iIt )->GetInteractorStyle( ) ); - if( style != NULL ) - { - style->SeedWidgetOn( ); - style->SetSeedWidgetCommand( command ); - - } // fi - - } // rof - this->m_IsModal = false; - - } // fi + break; + case Parameters::PathName: + break; + case Parameters::StringList: + break; + case Parameters::BoolList: + break; + case Parameters::IntList: + break; + case Parameters::UintList: + break; + case Parameters::RealList: + break; + case Parameters::IndexList: + break; + case Parameters::PointList: + break; + case Parameters::VectorList: + break; + case Parameters::FileNameList: + break; + case Parameters::PathNameList: + break; + case Parameters::Choices: + break; + default: + w_input = NULL; + break; + } // hctiws + + /* TODO + else if( pt == Parameters::Real ) + else if( + pt == Parameters::StringList || + pt == Parameters::IntList || + pt == Parameters::UintList || + pt == Parameters::RealList + ) + { + cpPlugins::Interface::ParametersListWidget* l_double = + new cpPlugins::Interface::ParametersListWidget( *nIt, this ); + w_input = l_double; + } + else if( pt == Parameters::Point || pt == Parameters::Index ) + { + vtkSmartPointer< SingleSeedCommand > command = + vtkSmartPointer< SingleSeedCommand >::New( ); + command->Dialog = this; + command->Name = *nIt; + + auto iIt = this->m_Interactors.begin( ); + for( ; iIt != this->m_Interactors.end( ); ++iIt ) + { + TStyle* style = + dynamic_cast< TStyle* >( ( *iIt )->GetInteractorStyle( ) ); + if( style != NULL ) + { + style->SeedWidgetOn( ); + style->SetSeedWidgetCommand( command ); + + } // fi + + } // rof + this->m_IsModal = false; + + } // fi + */ // Ok, a representation was created if( w_input != NULL ) { - w_input->setObjectName( QString( nIt->c_str( ) ) ); + w_input->setObjectName( QString( pIt->first.c_str( ) ) ); QHBoxLayout* new_layout = new QHBoxLayout( ); QLabel* label = new QLabel( this ); - label->setText( QString( nIt->c_str( ) ) ); + label->setText( QString( pIt->first.c_str( ) ) ); new_layout->addWidget( label ); new_layout->addWidget( w_input ); this->m_ToolsLayout->addLayout( new_layout ); @@ -257,13 +325,6 @@ setParameters( Parameters* parameters ) return( this->m_IsModal ); } -// ------------------------------------------------------------------------- -void cpPlugins::Interface::ParametersQtDialog:: -setTitle( const std::string& title ) -{ - this->m_Title->setText( title.c_str( ) ); -} - // ------------------------------------------------------------------------- int cpPlugins::Interface::ParametersQtDialog:: exec( ) @@ -392,7 +453,13 @@ syncParameters( ) } // rof } - +// ------------------------------------------------------------------------- +void cpPlugins::Interface::ParametersQtDialog:: +_dlg_MultipleFiles( ) +{ + QObject* sender = this->sender( ); + // std::cout << "OK " << sender << " " << sender->objectName( ).toStdString( ) << std::endl; +} diff --git a/lib/cpPlugins/Interface/ParametersQtDialog.h b/lib/cpPlugins/Interface/ParametersQtDialog.h index d19d314..ee5c238 100644 --- a/lib/cpPlugins/Interface/ParametersQtDialog.h +++ b/lib/cpPlugins/Interface/ParametersQtDialog.h @@ -44,12 +44,14 @@ namespace cpPlugins TInteractors& getInteractors( ); const TInteractors& getInteractors( ) const; bool setParameters( Parameters* parameters ); - void setTitle( const std::string& title ); virtual int exec( ); virtual void show( ); void syncParameters( ); + protected slots: + void _dlg_MultipleFiles( ); + protected: Parameters* m_Parameters; QLabel* m_Title; diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index 266b0ea..fc010b8 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -156,9 +156,11 @@ ExecConfigurationDialog( QWidget* parent ) { if( this->m_ParametersDialog == NULL ) this->m_ParametersDialog = new ParametersQtDialog( ); - this->m_ParametersDialog->setTitle( - this->GetClassName( ) + std::string( " basic configuration" ) - ); + /* TODO + this->m_ParametersDialog->setTitle( + this->GetClassName( ) + std::string( " basic configuration" ) + ); + */ this->m_ParametersDialog->setParent( NULL ); this->m_ParametersDialog->setParameters( this->m_Parameters ); diff --git a/lib/cpPlugins/Interface/Workspace.cxx b/lib/cpPlugins/Interface/Workspace.cxx index 022f9fa..67eaf0a 100644 --- a/lib/cpPlugins/Interface/Workspace.cxx +++ b/lib/cpPlugins/Interface/Workspace.cxx @@ -292,58 +292,6 @@ GetExposedOutputPorts( ) const return( this->m_ExposedOutputPorts ); } -// ------------------------------------------------------------------------- -/* TODO -cpPlugins::Interface::Workspace:: -TData* cpPlugins::Interface::Workspace:: -GetOutput( const std::string& name ) -{ - auto port = this->m_ExposedOutputPorts.find( name ); - if( port != this->m_ExposedOutputPorts.end( ) ) - { - TFilter* f = this->GetFilter( port->second.first ); - if( f != NULL ) - return( f->GetOutput< TData >( port->second.second ) ); - else - return( NULL ); - } - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -const cpPlugins::Interface::Workspace:: -TData* cpPlugins::Interface::Workspace:: -GetOutput( const std::string& name ) const -{ - auto port = this->m_ExposedOutputPorts.find( name ); - if( port != this->m_ExposedOutputPorts.end( ) ) - { - const TFilter* f = this->GetFilter( port->second.first ); - if( f != NULL ) - return( f->GetOutput< TData >( port->second.second ) ); - else - return( NULL ); - } - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Workspace:: -ClearInputPorts( ) -{ - this->m_ExposedInputPorts.clear( ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::Workspace:: -ClearOutputPorts( ) -{ - this->m_ExposedOutputPorts.clear( ); -} -*/ - // ------------------------------------------------------------------------- std::string cpPlugins::Interface::Workspace:: Execute( QWidget* p ) diff --git a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx index 625838c..51bc937 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx @@ -36,8 +36,8 @@ _GenerateData( ) if( vtk_image == NULL ) return( "MarchingCubes: Input does not have a valid VTK conversion." ); - std::vector< double > values; - this->m_Parameters->GetRealList( values, "Thresholds" ); + std::vector< double > values = + this->m_Parameters->GetRealList( "Thresholds" ); vtkPolyData* pd = NULL; if( vtk_image->GetDataDimension( ) == 2 ) { diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.cxx b/lib/cpPlugins/Plugins/IO/ImageReader.cxx index 17744fa..e18c987 100644 --- a/lib/cpPlugins/Plugins/IO/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageReader.cxx @@ -4,51 +4,52 @@ #include #include -#ifdef cpPlugins_Interface_QT4 -#include -#endif // cpPlugins_Interface_QT4 +/* TODO + #ifdef cpPlugins_Interface_QT4 + #include + #endif // cpPlugins_Interface_QT4 -// ------------------------------------------------------------------------- -cpPlugins::IO::ImageReader:: -DialogResult cpPlugins::IO::ImageReader:: -ExecConfigurationDialog( QWidget* parent ) -{ - DialogResult r = Self::DialogResult_Cancel; + // ------------------------------------------------------------------------- + cpPlugins::IO::ImageReader:: + DialogResult cpPlugins::IO::ImageReader:: + ExecConfigurationDialog( QWidget* parent ) + { + DialogResult r = Self::DialogResult_Cancel; -#ifdef cpPlugins_Interface_QT4 + #ifdef cpPlugins_Interface_QT4 - QStringList filters; - filters - << "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)" - << "Any files (*)"; + QStringList filters; + filters + << "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)" + << "Any files (*)"; - std::vector< std::string > names; - this->m_Parameters->GetStringList( names, "FileNames" ); - std::string name = ( names.size( ) > 0 )? names[ 0 ]: "."; + TStringList names = this->m_Parameters->GetFileNameList( "FileNames" ); + std::string name = ( names.size( ) > 0 )? names[ 0 ]: "."; - // Show dialog and check if it was accepted - QFileDialog dialog( parent ); - dialog.setFileMode( QFileDialog::ExistingFiles ); - dialog.setDirectory( QFileDialog::tr( name.c_str( ) ) ); - dialog.setNameFilters( filters ); - dialog.setAcceptMode( QFileDialog::AcceptOpen ); - if( dialog.exec( ) ) - { - QStringList names = dialog.selectedFiles( ); - QStringList::const_iterator qIt = names.begin( ); - for( ; qIt != names.end( ); ++qIt ) - this->m_Parameters->AddToStringList( - "FileNames", qIt->toStdString( ) - ); - this->m_Parameters->SetBool( "VectorType", false ); - r = Self::DialogResult_NoModal; + // Show dialog and check if it was accepted + QFileDialog dialog( parent ); + dialog.setFileMode( QFileDialog::ExistingFiles ); + dialog.setDirectory( QFileDialog::tr( name.c_str( ) ) ); + dialog.setNameFilters( filters ); + dialog.setAcceptMode( QFileDialog::AcceptOpen ); + if( dialog.exec( ) ) + { + QStringList names = dialog.selectedFiles( ); + QStringList::const_iterator qIt = names.begin( ); + for( ; qIt != names.end( ); ++qIt ) + this->m_Parameters->AddToStringList( + "FileNames", qIt->toStdString( ) + ); + this->m_Parameters->SetBool( "VectorType", false ); + r = Self::DialogResult_NoModal; - } // fi + } // fi -#endif // cpPlugins_Interface_QT4 + #endif // cpPlugins_Interface_QT4 - return( r ); -} + return( r ); + } +*/ // ------------------------------------------------------------------------- cpPlugins::IO::ImageReader:: @@ -57,7 +58,7 @@ ImageReader( ) { this->_MakeOutput< cpPlugins::Interface::Image >( "Output" ); - this->m_Parameters->ConfigureAsStringList( "FileNames" ); + this->m_Parameters->ConfigureAsFileNameList( "FileNames" ); this->m_Parameters->ConfigureAsBool( "VectorType" ); this->m_Parameters->SetBool( "VectorType", false ); } @@ -73,8 +74,7 @@ std::string cpPlugins::IO::ImageReader:: _GenerateData( ) { // Get filenames - TStringList names; - this->m_Parameters->GetStringList( names, "FileNames" ); + TStringList names = this->m_Parameters->GetFileNameList( "FileNames" ); std::string r = ""; if( names.size( ) >= 1 ) diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.h b/lib/cpPlugins/Plugins/IO/ImageReader.h index 520ab94..340c5db 100644 --- a/lib/cpPlugins/Plugins/IO/ImageReader.h +++ b/lib/cpPlugins/Plugins/IO/ImageReader.h @@ -26,17 +26,14 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; - typedef Superclass::TParameters TParameters; - typedef std::vector< TParameters::TString > TStringList; + typedef Superclass::TParameters TParameters; + typedef std::vector< std::string > TStringList; public: itkNewMacro( Self ); itkTypeMacro( ImageReader, cpPluginsInterfaceImageSource ); cpPlugins_Id_Macro( cpPlugins::IO::ImageReader, IO ); - public: - virtual DialogResult ExecConfigurationDialog( QWidget* parent ); - protected: ImageReader( ); virtual ~ImageReader( ); diff --git a/lib/cpPlugins/Plugins/IO/ImageWriter.cxx b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx index 67b1390..76ffd84 100644 --- a/lib/cpPlugins/Plugins/IO/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx @@ -3,43 +3,45 @@ #include -#ifdef cpPlugins_Interface_QT4 -#include -#endif // cpPlugins_Interface_QT4 - -// ------------------------------------------------------------------------- -cpPlugins::IO::ImageWriter:: -DialogResult cpPlugins::IO::ImageWriter:: -ExecConfigurationDialog( QWidget* parent ) -{ - DialogResult r = Self::DialogResult_Cancel; - -#ifdef cpPlugins_Interface_QT4 - - std::string name = this->m_Parameters->GetString( "FileName" ); - if( name == "" ) - name = "save.mhd"; - - // Show dialog and check if it was accepted - QString qname = - QFileDialog::getSaveFileName( - parent, - QFileDialog::tr( "Save File" ), - QFileDialog::tr( name.c_str( ) ), - QFileDialog::tr( "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff);;Any file (*)") - ); - name = qname.toStdString( ); - if( name != "" ) - { - this->m_Parameters->SetString( "FileName", name ); - r = Self::DialogResult_NoModal; - - } // fi - -#endif // cpPlugins_Interface_QT4 - - return( r ); -} +/* TODO + #ifdef cpPlugins_Interface_QT4 + #include + #endif // cpPlugins_Interface_QT4 + + // ------------------------------------------------------------------------- + cpPlugins::IO::ImageWriter:: + DialogResult cpPlugins::IO::ImageWriter:: + ExecConfigurationDialog( QWidget* parent ) + { + DialogResult r = Self::DialogResult_Cancel; + + #ifdef cpPlugins_Interface_QT4 + + std::string name = this->m_Parameters->GetString( "FileName" ); + if( name == "" ) + name = "save.mhd"; + + // Show dialog and check if it was accepted + QString qname = + QFileDialog::getSaveFileName( + parent, + QFileDialog::tr( "Save File" ), + QFileDialog::tr( name.c_str( ) ), + QFileDialog::tr( "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff);;Any file (*)") + ); + name = qname.toStdString( ); + if( name != "" ) + { + this->m_Parameters->SetString( "FileName", name ); + r = Self::DialogResult_NoModal; + + } // fi + + #endif // cpPlugins_Interface_QT4 + + return( r ); + } +*/ // ------------------------------------------------------------------------- cpPlugins::IO::ImageWriter:: @@ -47,7 +49,7 @@ ImageWriter( ) : Superclass( ) { this->_AddInput( "Input" ); - this->m_Parameters->ConfigureAsString( "FileName" ); + this->m_Parameters->ConfigureAsFileName( "FileName" ); } // ------------------------------------------------------------------------- @@ -112,7 +114,7 @@ std::string cpPlugins::IO::ImageWriter:: _RealGD( itk::DataObject* image ) { // Get filename - std::string fname = this->m_Parameters->GetString( "FileName" ); + std::string fname = this->m_Parameters->GetFileName( "FileName" ); typedef itk::ImageFileWriter< I > _W; _W* writer = this->_CreateITK< _W >( ); diff --git a/lib/cpPlugins/Plugins/IO/ImageWriter.h b/lib/cpPlugins/Plugins/IO/ImageWriter.h index 0dd3a25..bfde61b 100644 --- a/lib/cpPlugins/Plugins/IO/ImageWriter.h +++ b/lib/cpPlugins/Plugins/IO/ImageWriter.h @@ -24,9 +24,6 @@ namespace cpPlugins itkTypeMacro( ImageWriter, cpPluginsInterfaceImageSink ); cpPlugins_Id_Macro( cpPlugins::IO::ImageWriter, IO ); - public: - virtual DialogResult ExecConfigurationDialog( QWidget* parent ); - protected: ImageWriter( ); virtual ~ImageWriter( ); @@ -34,7 +31,7 @@ namespace cpPlugins virtual std::string _GenerateData( ); /* - * These two methods are Microsort courtesy: inner loop error ! + * These two methods are Micro$oft courtesy: inner loop error ! */ template< unsigned int D > inline std::string _GD0_Image( ); diff --git a/lib/cpPlugins/Plugins/IO/MeshReader.cxx b/lib/cpPlugins/Plugins/IO/MeshReader.cxx index 35b95d4..cfcd512 100644 --- a/lib/cpPlugins/Plugins/IO/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshReader.cxx @@ -4,6 +4,7 @@ #include #include +/* TODO #ifdef cpPlugins_Interface_QT4 #include #endif // cpPlugins_Interface_QT4 @@ -37,6 +38,7 @@ ExecConfigurationDialog( QWidget* parent ) return( r ); } +*/ // ------------------------------------------------------------------------- cpPlugins::IO::MeshReader:: @@ -48,7 +50,7 @@ MeshReader( ) std::vector< TParameters::TString > valid_types; valid_types.push_back( "float" ); valid_types.push_back( "double" ); - this->m_Parameters->ConfigureAsString( "FileName" ); + this->m_Parameters->ConfigureAsFileName( "FileName" ); this->m_Parameters->ConfigureAsChoices( "PixelType", valid_types ); this->m_Parameters->ConfigureAsUint( "Dimension" ); @@ -95,7 +97,7 @@ std::string cpPlugins::IO::MeshReader:: _GD1( ) { // Get filename - std::string fname = this->m_Parameters->GetString( "FileName" ); + std::string fname = this->m_Parameters->GetFileName( "FileName" ); vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( ); pdr->SetFileName( fname.c_str( ) ); diff --git a/lib/cpPlugins/Plugins/IO/MeshReader.h b/lib/cpPlugins/Plugins/IO/MeshReader.h index c26c3ae..48c1164 100644 --- a/lib/cpPlugins/Plugins/IO/MeshReader.h +++ b/lib/cpPlugins/Plugins/IO/MeshReader.h @@ -26,9 +26,6 @@ namespace cpPlugins itkTypeMacro( MeshReader, cpPluginsInterfaceMeshSource ); cpPlugins_Id_Macro( cpPlugins::IO::MeshReader, IO ); - public: - virtual DialogResult ExecConfigurationDialog( QWidget* parent ); - protected: MeshReader( ); virtual ~MeshReader( ); diff --git a/lib/cpPlugins/Plugins/IO/MeshWriter.cxx b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx index e3408b2..e45367d 100644 --- a/lib/cpPlugins/Plugins/IO/MeshWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx @@ -5,43 +5,45 @@ #include #include -#ifdef cpPlugins_Interface_QT4 -#include -#endif // cpPlugins_Interface_QT4 +/* TODO + #ifdef cpPlugins_Interface_QT4 + #include + #endif // cpPlugins_Interface_QT4 -// ------------------------------------------------------------------------- -cpPlugins::IO::MeshWriter:: -DialogResult cpPlugins::IO::MeshWriter:: -ExecConfigurationDialog( QWidget* parent ) -{ - DialogResult r = Self::DialogResult_Cancel; - -#ifdef cpPlugins_Interface_QT4 + // ------------------------------------------------------------------------- + cpPlugins::IO::MeshWriter:: + DialogResult cpPlugins::IO::MeshWriter:: + ExecConfigurationDialog( QWidget* parent ) + { + DialogResult r = Self::DialogResult_Cancel; - std::string name = this->m_Parameters->GetString( "FileName" ); - if( name == "" ) - name = "save.vtk"; + #ifdef cpPlugins_Interface_QT4 - // Show dialog and check if it was accepted - QString qname = - QFileDialog::getSaveFileName( - parent, - QFileDialog::tr( "Save File" ), - QFileDialog::tr( name.c_str( ) ), - QFileDialog::tr( "Mesh files (*.vtk *.stl *.obj);;Any file (*)") - ); - name = qname.toStdString( ); - if( name != "" ) - { - this->m_Parameters->SetString( "FileName", name ); - r = Self::DialogResult_NoModal; - - } // fi - -#endif // cpPlugins_Interface_QT4 - - return( r ); -} + std::string name = this->m_Parameters->GetString( "FileName" ); + if( name == "" ) + name = "save.vtk"; + + // Show dialog and check if it was accepted + QString qname = + QFileDialog::getSaveFileName( + parent, + QFileDialog::tr( "Save File" ), + QFileDialog::tr( name.c_str( ) ), + QFileDialog::tr( "Mesh files (*.vtk *.stl *.obj);;Any file (*)") + ); + name = qname.toStdString( ); + if( name != "" ) + { + this->m_Parameters->SetString( "FileName", name ); + r = Self::DialogResult_NoModal; + + } // fi + + #endif // cpPlugins_Interface_QT4 + + return( r ); + } +*/ // ------------------------------------------------------------------------- cpPlugins::IO::MeshWriter:: @@ -49,7 +51,7 @@ MeshWriter( ) : Superclass( ) { this->_AddInput( "Input" ); - this->m_Parameters->ConfigureAsString( "FileName" ); + this->m_Parameters->ConfigureAsFileName( "FileName" ); } // ------------------------------------------------------------------------- @@ -69,7 +71,7 @@ _GenerateData( ) vtkPolyData* i = mesh->GetVTK< vtkPolyData >( ); if( i == NULL ) return( "MeshWriter: No suitable input." ); - std::string fname = this->m_Parameters->GetString( "FileName" ); + std::string fname = this->m_Parameters->GetFileName( "FileName" ); vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( ); pdw->SetInputData( i ); diff --git a/lib/cpPlugins/Plugins/IO/MeshWriter.h b/lib/cpPlugins/Plugins/IO/MeshWriter.h index 2dc64a6..c1f4a7e 100644 --- a/lib/cpPlugins/Plugins/IO/MeshWriter.h +++ b/lib/cpPlugins/Plugins/IO/MeshWriter.h @@ -26,9 +26,6 @@ namespace cpPlugins itkTypeMacro( MeshWriter, cpPluginsInterfaceMeshSink ); cpPlugins_Id_Macro( cpPlugins::IO::MeshWriter, IO ); - public: - virtual DialogResult ExecConfigurationDialog( QWidget* parent ); - protected: MeshWriter( ); virtual ~MeshWriter( ); -- 2.47.1