// Configure filter
TPluginFilter::Pointer filter =
this->m_Plugins.CreateProcessObject( name );
- TParameters parameters = filter->GetDefaultParameters( );
- bool dlg_ok =
- cpPlugins::Interface::ParametersQtDialog(
- parameters, filter->GetClassName( )
- );
+ bool dlg_ok = filter->ExecConfigurationDialog( NULL );
if( !dlg_ok )
return;
// Execute filter
QApplication::setOverrideCursor( Qt::WaitCursor );
this->setEnabled( false );
- filter->SetParameters( parameters );
filter->SetInput( 0, this->m_InputImage );
std::string err = filter->Update( );
QApplication::restoreOverrideCursor( );
// Configure filter
TPluginFilter::Pointer filter =
this->m_Plugins.CreateProcessObject( name );
- TParameters parameters = filter->GetDefaultParameters( );
- bool dlg_ok =
- cpPlugins::Interface::ParametersQtDialog(
- parameters, filter->GetClassName( )
- );
+ bool dlg_ok = filter->ExecConfigurationDialog( NULL );
if( !dlg_ok )
return;
// Execute filter
QApplication::setOverrideCursor( Qt::WaitCursor );
this->setEnabled( false );
- filter->SetParameters( parameters );
filter->SetInput( 0, this->m_InputImage );
std::string err = filter->Update( );
QApplication::restoreOverrideCursor( );
SET(LIBRARY_NAME cpPlugins_Interface)
+CONFIGURE_FILE(
+ Config.h.in
+ ${PROJECT_BINARY_DIR}/lib/cpPlugins/Interface/Config.h
+ @ONLY
+ )
+
## ===============
## = Source code =
## ===============
${LIB_SOURCES_CXX}
ParametersQtDialog.cxx
)
+
+ SET(
+ LIB_QT_UI
+ ParametersListWidget.ui
+ )
+ SET(
+ LIB_QT_Headers
+ ParametersListWidget.h
+ )
+ SET(
+ LIB_QT_Sources
+ ParametersListWidget.cxx
+ )
+ SET(
+ LIB_QT_Resources
+ )
+
+ QT4_WRAP_UI(LIB_QT_Wrapped_Headers ${LIB_QT_UI})
+ QT4_WRAP_CPP(LIB_QT_Wrapped_MOC_Sources ${LIB_QT_Headers})
+ QT4_ADD_RESOURCES(LIB_QT_Wrapped_Resources_Sources ${LIB_QT_Resources})
+
+ SET(
+ LIB_HEADERS_H
+ ${LIB_HEADERS_H}
+ ${LIB_QT_Wrapped_Headers}
+ )
+
+ SET(
+ LIB_SOURCES_CXX
+ ${LIB_SOURCES_CXX}
+ ${LIB_QT_Sources}
+ ${LIB_QT_Wrapped_Headers}
+ ${LIB_QT_Wrapped_MOC_Sources}
+ ${LIB_QT_Wrapped_Resources_Sources}
+ )
+
ENDIF(USE_QT4)
## =====================
--- /dev/null
+#ifndef __CPPLUGINS__INTERFACE__CONFIG__H__
+#define __CPPLUGINS__INTERFACE__CONFIG__H__
+
+
+#define cpPlugins_MAJOR_VERSION @prj_MAJOR_VERSION@
+#define cpPlugins_MINOR_VERSION @prj_MINOR_VERSION@
+#define cpPlugins_RELEASE_VERSION @prj_RELEASE_VERSION@
+#define cpPlugins_VERSION "@prj_VERSION@"
+
+#define cpPlugins_Interface_QT4_USED @QT4_FOUND@
+#if cpPlugins_Interface_QT4_USED == 1
+# define cpPlugins_Interface_QT4
+#else // cpPlugins_Interface_QT4_USED == 1
+# undef cpPlugins_Interface_QT4
+#endif // cpPlugins_Interface_QT4_USED == 1
+
+#endif // __CPPLUGINS__INTERFACE__CONFIG__H__
+
+// eof - $RCSfile$
--- /dev/null
+#include <cpPlugins/Interface/ParametersListWidget.h>
+#include <cpPlugins/Interface/ui_ParametersListWidget.h>
+
+#include <set>
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ParametersListWidget::
+ParametersListWidget( const std::string& list_name, QWidget* parent )
+ : QWidget( parent ),
+ m_UI( new Ui::ParametersListWidget )
+{
+ this->m_UI->setupUi( this );
+
+ // Configure table
+ QTableWidget* table = this->m_UI->ValuesTable;
+ table->setColumnCount( 1 );
+ table->setRowCount( 1 );
+
+ QStringList header;
+ header << list_name.c_str( );
+ table->setHorizontalHeaderLabels( header );
+ table->setShowGrid( true );
+ table->setSelectionBehavior( QAbstractItemView::SelectRows );
+
+ // Connect signals
+ QObject::connect(
+ this->m_UI->AddValueButton, SIGNAL( clicked( ) ),
+ this, SLOT( _changeValuesCount( ) )
+ );
+ QObject::connect(
+ this->m_UI->RemoveValueButton, SIGNAL( clicked( ) ),
+ this, SLOT( _changeValuesCount( ) )
+ );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ParametersListWidget::
+~ParametersListWidget( )
+{
+ delete this->m_UI;
+}
+
+// -------------------------------------------------------------------------
+std::vector< std::string > cpPlugins::Interface::ParametersListWidget::
+GetStringValues( ) const
+{
+ std::vector< std::string > values;
+
+ QTableWidget* table = this->m_UI->ValuesTable;
+ for( int i = 0; i < table->rowCount( ); ++i )
+ values.push_back( table->item( i, 0 )->text( ).toStdString( ) );
+ return( values );
+}
+
+// -------------------------------------------------------------------------
+std::vector< int > cpPlugins::Interface::ParametersListWidget::
+GetIntValues( ) const
+{
+ std::vector< int > values;
+
+ QTableWidget* table = this->m_UI->ValuesTable;
+ for( int i = 0; i < table->rowCount( ); ++i )
+ {
+ const char* text = table->item( i, 0 )->text( ).toStdString( ).c_str( );
+ char* ptr = 0;
+ double v = std::strtod( text, &ptr );
+ if( *ptr == '\0' && ptr != text )
+ values.push_back( int( v ) );
+
+ } // rof
+ return( values );
+}
+
+// -------------------------------------------------------------------------
+std::vector< unsigned int > cpPlugins::Interface::ParametersListWidget::
+GetUintValues( ) const
+{
+ std::vector< unsigned int > values;
+
+ QTableWidget* table = this->m_UI->ValuesTable;
+ for( int i = 0; i < table->rowCount( ); ++i )
+ {
+ const char* text = table->item( i, 0 )->text( ).toStdString( ).c_str( );
+ char* ptr = 0;
+ double v = std::strtod( text, &ptr );
+ if( *ptr == '\0' && ptr != text && v >= double( 0 ) )
+ values.push_back( ( unsigned int )( v ) );
+
+ } // rof
+ return( values );
+}
+
+// -------------------------------------------------------------------------
+std::vector< double > cpPlugins::Interface::ParametersListWidget::
+GetDoubleValues( ) const
+{
+ std::vector< double > values;
+
+ QTableWidget* table = this->m_UI->ValuesTable;
+ for( int i = 0; i < table->rowCount( ); ++i )
+ {
+ const char* text = table->item( i, 0 )->text( ).toStdString( ).c_str( );
+ char* ptr = 0;
+ double v = std::strtod( text, &ptr );
+ if( *ptr == '\0' && ptr != text )
+ values.push_back( v );
+
+ } // rof
+ return( values );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ParametersListWidget::
+_changeValuesCount( )
+{
+ QPushButton* btn = dynamic_cast< QPushButton* >( this->sender( ) );
+ if( btn == NULL )
+ return;
+ QTableWidget* table = this->m_UI->ValuesTable;
+
+ if( btn == this->m_UI->RemoveValueButton )
+ {
+ std::set< int > to_delete;
+ QList< QTableWidgetItem* > lst = table->selectedItems( );
+ QList< QTableWidgetItem* >::iterator i = lst.begin( );
+ for( ; i != lst.end( ); ++i )
+ to_delete.insert( ( *i )->row( ) );
+
+ std::set< int >::const_reverse_iterator d = to_delete.rbegin( );
+ for( ; d != to_delete.rend( ); ++d )
+ table->removeRow( *d );
+ }
+ else
+ table->insertRow( table->rowCount( ) );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__INTERFACE__PARAMETERSLISTWIDGET__H__
+#define __CPPLUGINS__INTERFACE__PARAMETERSLISTWIDGET__H__
+
+#include <vector>
+#include <QWidget>
+
+// -------------------------------------------------------------------------
+namespace Ui
+{
+ class ParametersListWidget;
+}
+
+// -------------------------------------------------------------------------
+/**
+ */
+namespace cpPlugins
+{
+ namespace Interface
+ {
+ class ParametersListWidget
+ : public QWidget
+ {
+ Q_OBJECT;
+
+ public:
+
+ public:
+ explicit ParametersListWidget(
+ const std::string& list_name, QWidget* parent = 0
+ );
+ virtual ~ParametersListWidget( );
+
+ std::vector< std::string > GetStringValues( ) const;
+ std::vector< int > GetIntValues( ) const;
+ std::vector< unsigned int > GetUintValues( ) const;
+ std::vector< double > GetDoubleValues( ) const;
+
+ private slots:
+ void _changeValuesCount( );
+
+ private:
+ Ui::ParametersListWidget* m_UI;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__INTERFACE__PARAMETERSLISTWIDGET__H__
+
+// eof - $RCSfile$
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ParametersListWidget</class>
+ <widget class="QWidget" name="ParametersListWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>230</width>
+ <height>310</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTableWidget" name="ValuesTable"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="RemoveValueButton">
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="AddValueButton">
+ <property name="text">
+ <string>+</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
#include <limits>
#include <vector>
+#include <cpPlugins/Interface/ParametersListWidget.h>
#include <QCheckBox>
#include <QDialog>
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
-#include <QTableWidget>
#include <QWidget>
// -------------------------------------------------------------------------
v_double->setValue( parameters.GetValueAsReal( *nIt ) );
w_input = v_double;
}
- else if( pt == Parameters::RealList )
+ else if(
+ pt == Parameters::StringList ||
+ pt == Parameters::IntList ||
+ pt == Parameters::UintList ||
+ pt == Parameters::RealList
+ )
{
- QStringList header;
- header << nIt->c_str( );
-
- QTableWidget* l_double = new QTableWidget( dlg );
- l_double->setColumnCount( 1 );
- l_double->setRowCount( 1 );
- l_double->setHorizontalHeaderLabels( header );
- l_double->setShowGrid( true );
- l_double->setSelectionBehavior( QAbstractItemView::SelectRows );
- l_double->setSelectionMode( QAbstractItemView::SingleSelection );
-
- QObject::connect(
- l_double, SIGNAL( cellDoubleClicked( int, int ) ),
- l_double, SLOT( insertRow( int ) )
- );
-
+ cpPlugins::Interface::ParametersListWidget* l_double =
+ new cpPlugins::Interface::ParametersListWidget( *nIt, dlg );
w_input = l_double;
} // fi
if( v_double != NULL )
parameters.SetValueAsReal( *nIt, v_double->value( ) );
}
- else if( pt == Parameters::RealList )
+ else if(
+ pt == Parameters::StringList ||
+ pt == Parameters::IntList ||
+ pt == Parameters::UintList ||
+ pt == Parameters::RealList
+ )
{
- QTableWidget* l_double =
- dlg->findChild< QTableWidget* >( nIt->c_str( ) );
+ cpPlugins::Interface::ParametersListWidget* l_double =
+ dlg->findChild< cpPlugins::Interface::ParametersListWidget* >(
+ nIt->c_str( )
+ );
if( l_double != NULL )
{
- for( int r = 0; r < l_double->rowCount( ); ++r )
+ if( pt == Parameters::StringList )
+ {
+ std::vector< std::string > values = l_double->GetStringValues( );
+ for( int r = 0; r < values.size( ); ++r )
+ parameters.AddValueToStringList( *nIt, values[ r ] );
+ }
+ else if( pt == Parameters::IntList )
+ {
+ std::vector< int > values = l_double->GetIntValues( );
+ for( int r = 0; r < values.size( ); ++r )
+ parameters.AddValueToIntList( *nIt, values[ r ] );
+ }
+ else if( pt == Parameters::UintList )
+ {
+ std::vector< unsigned int > values = l_double->GetUintValues( );
+ for( int r = 0; r < values.size( ); ++r )
+ parameters.AddValueToUintList( *nIt, values[ r ] );
+ }
+ else if( pt == Parameters::RealList )
{
- double v =
- std::atof(
- l_double->item( r, 0 )->text( ).toStdString( ).c_str( )
- );
- parameters.AddValueToRealList( *nIt, v );
+ std::vector< double > values = l_double->GetDoubleValues( );
+ for( int r = 0; r < values.size( ); ++r )
+ parameters.AddValueToRealList( *nIt, values[ r ] );
- } // rof
+ } // fi
} // fi
#include <cpPlugins/Interface/ProcessObject.h>
+#ifdef cpPlugins_Interface_QT4
+#include <cpPlugins/Interface/ParametersQtDialog.h>
+#endif // cpPlugins_Interface_QT4
+
// -------------------------------------------------------------------------
const cpPlugins::Interface::Parameters&
cpPlugins::Interface::ProcessObject::
this->m_Outputs[ idx ]->DisconnectPipeline( );
}
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::ProcessObject::
+ExecConfigurationDialog( QWidget* parent )
+{
+ bool r = false;
+
+#ifdef cpPlugins_Interface_QT4
+
+ Parameters parameters = this->m_DefaultParameters;
+ r = cpPlugins::Interface::ParametersQtDialog(
+ parameters,
+ this->m_ClassName + std::string( " basic configuration" ),
+ parent
+ );
+ if( r )
+ this->m_Parameters = parameters;
+
+#endif // cpPlugins_Interface_QT4
+
+ return( r );
+}
+
// -------------------------------------------------------------------------
cpPlugins::Interface::ProcessObject::
ProcessObject( )
#define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+#include <cpPlugins/Interface/Config.h>
#include <cpPlugins/Interface/Object.h>
#include <cpPlugins/Interface/DataObject.h>
#include <cpPlugins/Interface/Parameters.h>
+#ifdef cpPlugins_Interface_QT4
+class QWidget;
+#else
+typedef char QWidget
+#endif // cpPlugins_Interface_QT4
+
#include <itkProcessObject.h>
namespace cpPlugins
virtual std::string Update( );
virtual void DisconnectOutputs( );
+ virtual bool ExecConfigurationDialog( QWidget* parent );
+
template< class T >
inline T* GetInput( unsigned int idx );