\r
#include <QPen>\r
#include <QGraphicsScene>\r
+#include <QGraphicsSceneContextMenuEvent>\r
#include <QFontMetrics>\r
+#include <QMenu>\r
#include <QPainter>\r
#include <QStyleOptionGraphicsItem>\r
+#include <QGraphicsWidget>\r
\r
#include "Port.h"\r
#include "Connection.h"\r
this->Superclass::mouseReleaseEvent( evt );\r
}\r
\r
+// -------------------------------------------------------------------------\r
+void cpPipelineEditor::Block::\r
+contextMenuEvent( QGraphicsSceneContextMenuEvent* evt )\r
+{\r
+ QMenu menu;\r
+ QAction* configureAction = menu.addAction( "Configure" );\r
+ QAction* updateAction = menu.addAction( "Update" );\r
+ QAction* selectedAction = menu.exec( evt->screenPos( ) );\r
+\r
+ if( selectedAction == configureAction )\r
+ {\r
+ auto res = this->m_Filter->ExecConfigurationDialog( NULL );\r
+ }\r
+ else if( selectedAction == updateAction )\r
+ {\r
+ } // fi\r
+}\r
+\r
// eof - $RCSfile$\r
void _configPort( Port* port );\r
\r
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* evt );\r
+ virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* evt );\r
\r
private:\r
int m_HorzMargin;\r
#include <cpPlugins/Interface/ProcessObject.h>
#include <third_party/tinyxml/tinyxml.h>
-#include <sstream>
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::Parameters::
+TParameters& cpPlugins::Interface::Parameters::
+GetRawParameters( ) const
+{
+ return( this->m_Parameters );
+}
// -------------------------------------------------------------------------
cpPlugins::Interface::
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
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
}
// -------------------------------------------------------------------------
-#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 ) \
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::
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
{
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
#include <map>
#include <ostream>
+#include <sstream>
#include <string>
#include <vector>
#include <itkObject.h>
#include <itkObjectFactory.h>
+// 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
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;
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 );
// 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 );
// -------------------------------------------------------------------------
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 )
// -------------------------------------------------------------------------
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 )
// -------------------------------------------------------------------------
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 )
// -------------------------------------------------------------------------
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( ) )
// -------------------------------------------------------------------------
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( ) )
// -------------------------------------------------------------------------
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( ) )
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( ) )
// -------------------------------------------------------------------------
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( ) )
// -------------------------------------------------------------------------
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( ) )
#include <QDoubleSpinBox>
#include <QHBoxLayout>
#include <QLineEdit>
+#include <QPushButton>
#include <QWidget>
// -------------------------------------------------------------------------
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 );
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( )
} // rof
}
-
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersQtDialog::
+_dlg_MultipleFiles( )
+{
+ QObject* sender = this->sender( );
+ // std::cout << "OK " << sender << " " << sender->objectName( ).toStdString( ) << std::endl;
+}
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;
{
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 );
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 )
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 )
{
#include <itkImageFileReader.h>
#include <itkImageSeriesReader.h>
-#ifdef cpPlugins_Interface_QT4
-#include <QFileDialog>
-#endif // cpPlugins_Interface_QT4
+/* TODO
+ #ifdef cpPlugins_Interface_QT4
+ #include <QFileDialog>
+ #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::
{
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 );
}
_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 )
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( );
#include <itkImageFileWriter.h>
-#ifdef cpPlugins_Interface_QT4
-#include <QFileDialog>
-#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 <QFileDialog>
+ #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::
: Superclass( )
{
this->_AddInput( "Input" );
- this->m_Parameters->ConfigureAsString( "FileName" );
+ this->m_Parameters->ConfigureAsFileName( "FileName" );
}
// -------------------------------------------------------------------------
_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 >( );
itkTypeMacro( ImageWriter, cpPluginsInterfaceImageSink );
cpPlugins_Id_Macro( cpPlugins::IO::ImageWriter, IO );
- public:
- virtual DialogResult ExecConfigurationDialog( QWidget* parent );
-
protected:
ImageWriter( );
virtual ~ImageWriter( );
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( );
#include <vtkPolyData.h>
#include <vtkPolyDataReader.h>
+/* TODO
#ifdef cpPlugins_Interface_QT4
#include <QFileDialog>
#endif // cpPlugins_Interface_QT4
return( r );
}
+*/
// -------------------------------------------------------------------------
cpPlugins::IO::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" );
_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( ) );
itkTypeMacro( MeshReader, cpPluginsInterfaceMeshSource );
cpPlugins_Id_Macro( cpPlugins::IO::MeshReader, IO );
- public:
- virtual DialogResult ExecConfigurationDialog( QWidget* parent );
-
protected:
MeshReader( );
virtual ~MeshReader( );
#include <vtkPolyData.h>
#include <vtkPolyDataWriter.h>
-#ifdef cpPlugins_Interface_QT4
-#include <QFileDialog>
-#endif // cpPlugins_Interface_QT4
+/* TODO
+ #ifdef cpPlugins_Interface_QT4
+ #include <QFileDialog>
+ #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::
: Superclass( )
{
this->_AddInput( "Input" );
- this->m_Parameters->ConfigureAsString( "FileName" );
+ this->m_Parameters->ConfigureAsFileName( "FileName" );
}
// -------------------------------------------------------------------------
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 );
itkTypeMacro( MeshWriter, cpPluginsInterfaceMeshSink );
cpPlugins_Id_Macro( cpPlugins::IO::MeshWriter, IO );
- public:
- virtual DialogResult ExecConfigurationDialog( QWidget* parent );
-
protected:
MeshWriter( );
virtual ~MeshWriter( );