// Unbind source
this->m_Source = NULL;
+ this->Modified( );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::Parameters::
SetProcessObject( ProcessObject* v )
{
- this->m_Process = v;
+ if( this->m_Process != v )
+ {
+ this->m_Process = v;
+ this->Modified( );
+
+ } // fi
}
// -------------------------------------------------------------------------
{
if( i->second.first == Self::String || force )
{
- i->second.second = v;
- this->Modified( );
+ if( i->second.second != v )
+ {
+ i->second.second = v;
+ this->Modified( );
+
+ } // fi
} // fi
std::stringstream new_choices;
new_choices << choices << "@" << choice;
i->second.second = new_choices.str( );
+ this->Modified( );
return( true );
}
else
return( false );
}
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::Parameters::
+GetAcceptedFileExtensions( const std::string& name ) const
+{
+ auto i = this->m_AcceptedFileExtensions.find( name );
+ if( i != this->m_AcceptedFileExtensions.end( ) )
+ return( i->second );
+ else
+ return( "" );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::Parameters::
+SetAcceptedFileExtensions(
+ const std::string& name, const std::string& extensions
+ )
+{
+ auto i = this->m_Parameters.find( name );
+ if( i != this->m_Parameters.end( ) )
+ {
+ bool is_valid = ( i->second.first == Self::OpenFileName );
+ is_valid |= ( i->second.first == Self::SaveFileName );
+ is_valid |= ( i->second.first == Self::OpenFileNameList );
+ is_valid |= ( i->second.first == Self::SaveFileNameList );
+ if( is_valid )
+ this->m_AcceptedFileExtensions[ name ] = extensions;
+
+ } // fi
+}
+
// -------------------------------------------------------------------------
bool cpPlugins::Interface::Parameters::
ToXML( TiXmlElement* parent_elem ) const
ret = true;
} // elihw
+ this->Modified( );
return( ret );
}
{ \
std::stringstream str; \
str << v; \
- i->second.second = str.str( ); \
+ if( i->second.second != str.str( ) ) \
+ { \
+ i->second.second = str.str( ); \
+ this->Modified( ); \
+ } \
} \
else \
- i->second.second = \
- *( reinterpret_cast< const std::string* >( &v ) ); \
- this->Modified( ); \
+ { \
+ const std::string* str = \
+ reinterpret_cast< const std::string* >( &v ); \
+ if( i->second.second != *str ) \
+ { \
+ i->second.second = *str; \
+ this->Modified( ); \
+ } \
+ } \
} \
} \
}
str << i->second.second << "#"; \
str << v; \
i->second.second = str.str( ); \
+ this->Modified( ); \
} \
} \
} \
if( i != this->m_Parameters.end( ) ) \
{ \
if( i->second.first == Self::Y##List ) \
- i->second.second = ""; \
+ { \
+ if( i->second.second != "" ) \
+ { \
+ i->second.second = ""; \
+ this->Modified( ); \
+ } \
+ } \
} \
}
const std::string& name, const std::string& choice
);
+ std::string GetAcceptedFileExtensions( const std::string& name ) const;
+ void SetAcceptedFileExtensions(
+ const std::string& name, const std::string& extensions
+ );
+
// XML "streaming"
bool ToXML( TiXmlElement* parent_elem ) const;
bool FromXML( const TiXmlElement* filter_elem );
Self& operator=( const Self& other );
protected:
- TParameters m_Parameters;
- ProcessObject* m_Process;
+ TParameters m_Parameters;
+ std::map< std::string, std::string > m_AcceptedFileExtensions;
+ ProcessObject* m_Process;
};
} // ecapseman
#include <limits>
-#include <cpPlugins/Interface/ParametersListWidget.h>
#include <cpPlugins/Interface/ProcessObject.h>
-#include <vtkCommand.h>
-#include <vtkRenderWindowInteractor.h>
-
#include <QCheckBox>
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QPushButton>
#include <QWidget>
-/* TODO
-class SingleSeedCommand
- : public vtkCommand
-{
-public:
- static SingleSeedCommand* New( )
- { return( new SingleSeedCommand ); }
- virtual void Execute( vtkObject* caller, unsigned long eid, void* data )
- {
- // Get seed, avoiding segfaults!!!
- if( eid != vtkCommand::PlacePointEvent || this->Dialog == NULL )
- return;
- vtkSeedWidget* widget = dynamic_cast< vtkSeedWidget* >( caller );
- if( widget == NULL )
- return;
- vtkSeedRepresentation* rep = widget->GetSeedRepresentation( );
- if( rep == NULL )
- return;
- if( rep->GetNumberOfSeeds( ) == 0 )
- return;
- double seed[ 3 ];
- rep->GetSeedWorldPosition( 0, seed );
-
- // Delete all seeds (remember that this command is just for one seed)
- while( rep->GetNumberOfSeeds( ) > 0 )
- widget->DeleteSeed( 0 );
-
- if( this->Dialog->getParameters( )->HasIndex( this->Name ) )
- {
- }
- else if( this->Dialog->getParameters( )->HasPoint( this->Name ) )
- {
- this->Dialog->getParameters( )->SetPoint( this->Name, 3, seed );
- this->Dialog->updateParameters( );
- auto filter = this->Dialog->getParameters( )->GetProcessObject( );
- if( filter != NULL )
- {
- auto plugins = filter->GetPlugins( );
- if( plugins != NULL )
- {
- auto app = plugins->GetApplication( );
- if( app != NULL )
- app->UpdateActualFilter( );
-
- } // fi
-
- } // fi
-
- } // fi
- }
-protected:
- SingleSeedCommand( )
- : vtkCommand( ),
- Dialog( NULL )
- {
- }
- virtual ~SingleSeedCommand( )
- {
- }
-
-public:
- cpPlugins::Interface::ParametersQtDialog* Dialog;
- std::string Name;
-};
-*/
-
// -------------------------------------------------------------------------
cpPlugins::Interface::ParametersQtDialog::
ParametersQtDialog( QWidget* parent, Qt::WindowFlags f )
: QDialog( parent, f ),
m_Parameters( NULL ),
- m_Interactive( false )
+ m_WidgetsUpdated( false )
{
this->m_Title = new QLabel( this );
this->m_Title->setText( "Parameters dialog title" );
}
// -------------------------------------------------------------------------
-void cpPlugins::Interface::ParametersQtDialog::
-addInteractor( vtkRenderWindowInteractor* interactor )
-{
- this->m_Interactors.insert( interactor );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::ParametersQtDialog::
-TInteractors& cpPlugins::Interface::ParametersQtDialog::
-getInteractors( )
+bool cpPlugins::Interface::ParametersQtDialog::
+setParameters( Parameters* parameters )
{
- return( this->m_Interactors );
+ if( this->m_Parameters != NULL || parameters == NULL )
+ return( false );
+ this->m_Parameters = parameters;
+ this->m_WidgetsUpdated = false;
+ return( true );
}
// -------------------------------------------------------------------------
-const cpPlugins::Interface::ParametersQtDialog::
-TInteractors& cpPlugins::Interface::ParametersQtDialog::
-getInteractors( ) const
+int cpPlugins::Interface::ParametersQtDialog::
+exec( )
{
- return( this->m_Interactors );
-}
+ this->_updateWidgets( );
-// -------------------------------------------------------------------------
-bool cpPlugins::Interface::ParametersQtDialog::
-isInteractive( ) const
-{
- return( this->m_Interactive );
+ int ret = this->QDialog::exec( );
+ if( ret == 1 )
+ this->updateParameters( );
+ else
+ this->updateView( );
+ return( ret );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::ParametersQtDialog::
-setInteractive( bool i )
+updateParameters( )
{
- this->m_Interactive = i;
-}
+ if( this->m_Parameters == NULL )
+ return;
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ParametersQtDialog::
-interactiveOn( )
-{
- this->m_Interactive = true;
+ // Put values
+ auto& raw_params = this->m_Parameters->GetRawParameters( );
+ for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt )
+ {
+ QString pName = pIt->first.c_str( );
+ switch( pIt->second.first )
+ {
+ case Parameters::String:
+ case Parameters::OpenFileName:
+ case Parameters::SaveFileName:
+ case Parameters::PathName:
+ case Parameters::IntList:
+ case Parameters::UintList:
+ case Parameters::RealList:
+ case Parameters::OpenFileNameList:
+ {
+ QLineEdit* v_string = this->findChild< QLineEdit* >( pName );
+ if( v_string != NULL )
+ pIt->second.second = v_string->text( ).toStdString( );
+ }
+ break;
+ case Parameters::Bool:
+ {
+ QCheckBox* v_bool = this->findChild< QCheckBox* >( pName );
+ if( v_bool != NULL )
+ pIt->second.second = ( v_bool->isChecked( ) )? "1": "0";
+ }
+ break;
+ case Parameters::Int:
+ case Parameters::Uint:
+ {
+ QSpinBox* v_uint = this->findChild< QSpinBox* >( pName );
+ if( v_uint )
+ {
+ std::stringstream str;
+ str << v_uint->value( );
+ pIt->second.second = str.str( );
+
+ } // fi
+ }
+ break;
+ case Parameters::Real:
+ {
+ QDoubleSpinBox* v_double = this->findChild< QDoubleSpinBox* >( pName );
+ if( v_double )
+ {
+ std::stringstream str;
+ str << v_double->value( );
+ pIt->second.second = str.str( );
+
+ } // fi
+ }
+ break;
+ case Parameters::StringList:
+ break;
+ case Parameters::BoolList:
+ break;
+ case Parameters::SaveFileNameList:
+ break;
+ case Parameters::PathNameList:
+ break;
+ case Parameters::Choices:
+ {
+ QComboBox* v_choices = this->findChild< QComboBox* >( pName );
+ if( v_choices != NULL )
+ {
+ std::istringstream str_choices( pIt->second.second );
+ std::string real_choices;
+ std::getline( str_choices, real_choices, '@' );
+ pIt->second.second =
+ real_choices + "@" +
+ v_choices->currentText( ).toStdString( );
+
+ } // fi
+ }
+ break;
+ default:
+ break;
+ } // hctiws
+
+ } // rof
+ this->m_Parameters->Modified( );
}
// -------------------------------------------------------------------------
void cpPlugins::Interface::ParametersQtDialog::
-interactiveOff( )
+updateView( )
{
- this->m_Interactive = false;
+ if( this->m_Parameters == NULL )
+ return;
+
+ // Put values
+ auto& raw_params = this->m_Parameters->GetRawParameters( );
+ for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt )
+ {
+ QString pName = pIt->first.c_str( );
+ switch( pIt->second.first )
+ {
+ case Parameters::String:
+ case Parameters::OpenFileName:
+ case Parameters::SaveFileName:
+ case Parameters::PathName:
+ case Parameters::IntList:
+ case Parameters::UintList:
+ case Parameters::RealList:
+ case Parameters::OpenFileNameList:
+ {
+ QLineEdit* v_string = this->findChild< QLineEdit* >( pName );
+ if( v_string != NULL )
+ v_string->setText( pIt->second.second.c_str( ) );
+ }
+ break;
+ case Parameters::Bool:
+ {
+ QCheckBox* v_bool = this->findChild< QCheckBox* >( pName );
+ if( v_bool != NULL )
+ v_bool->setChecked( pIt->second.second == "1" );
+ }
+ break;
+ case Parameters::Int:
+ case Parameters::Uint:
+ {
+ QSpinBox* v_uint = this->findChild< QSpinBox* >( pName );
+ if( v_uint )
+ {
+ std::istringstream tok_str( pIt->second.second );
+ int v;
+ tok_str >> v;
+ v_uint->setValue( v );
+
+ } // fi
+ }
+ break;
+ case Parameters::Real:
+ {
+ QDoubleSpinBox* v_double = this->findChild< QDoubleSpinBox* >( pName );
+ if( v_double )
+ {
+ std::istringstream tok_str( pIt->second.second );
+ double v;
+ tok_str >> v;
+ v_double->setValue( v );
+
+ } // fi
+ }
+ break;
+ case Parameters::StringList:
+ break;
+ case Parameters::BoolList:
+ break;
+ case Parameters::SaveFileNameList:
+ break;
+ case Parameters::PathNameList:
+ break;
+ case Parameters::Choices:
+ {
+ QComboBox* v_choices = this->findChild< QComboBox* >( pName );
+ if( v_choices != NULL )
+ {
+ std::istringstream str_choices( pIt->second.second );
+ std::string choices, real_choice;
+ std::getline( str_choices, choices, '@' );
+ std::getline( str_choices, real_choice, '@' );
+ std::istringstream str( choices );
+ std::string token;
+ int id = -1, cont = 0;
+ while( std::getline( str, token, '#' ) )
+ {
+ if( token == real_choice )
+ id = cont;
+ cont++;
+
+ } // elihw
+
+ if( id > -1 )
+ v_choices->setCurrentIndex( id );
+
+ } // fi
+ }
+ break;
+ default:
+ break;
+ } // hctiws
+
+ } // rof
}
// -------------------------------------------------------------------------
-bool cpPlugins::Interface::ParametersQtDialog::
-setParameters( Parameters* parameters )
+void cpPlugins::Interface::ParametersQtDialog::
+_updateWidgets( )
{
- if( this->m_Parameters != NULL || parameters == NULL )
- return( false );
- this->m_Parameters = parameters;
+ if( this->m_WidgetsUpdated || this->m_Parameters == NULL )
+ return;
// Set dialog title
auto filter = this->m_Parameters->GetProcessObject( );
this->m_Title->setText( title.str( ).c_str( ) );
// Put values
- this->m_Widgets.clear( );
auto& raw_params = this->m_Parameters->GetRawParameters( );
for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt )
{
QHBoxLayout* layout = new QHBoxLayout( frame );
QLineEdit* v_string = new QLineEdit( frame );
v_string->setObjectName( pIt->first.c_str( ) );
+ v_string->setMaxLength( std::numeric_limits< int >::max( ) );
v_string->setText( pIt->second.second.c_str( ) );
QPushButton* v_button = new QPushButton( frame );
v_button->setObjectName( ( pIt->first + "_=?btn" ).c_str( ) );
// Update values
this->updateView( );
-
- return( true );
-}
-
-// -------------------------------------------------------------------------
-int cpPlugins::Interface::ParametersQtDialog::
-exec( )
-{
- int ret = this->QDialog::exec( );
- if( ret == 1 )
- this->updateParameters( );
- else
- this->updateView( );
- return( ret );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ParametersQtDialog::
-show( )
-{
- this->QDialog::show( );
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ParametersQtDialog::
-updateParameters( )
-{
- if( this->m_Parameters == NULL )
- return;
-
- // Put values
- auto& raw_params = this->m_Parameters->GetRawParameters( );
- for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt )
- {
- QString pName = pIt->first.c_str( );
- switch( pIt->second.first )
- {
- case Parameters::String:
- case Parameters::OpenFileName:
- case Parameters::SaveFileName:
- case Parameters::PathName:
- case Parameters::IntList:
- case Parameters::UintList:
- case Parameters::RealList:
- case Parameters::OpenFileNameList:
- {
- QLineEdit* v_string = this->findChild< QLineEdit* >( pName );
- if( v_string != NULL )
- pIt->second.second = v_string->text( ).toStdString( );
- }
- break;
- case Parameters::Bool:
- {
- QCheckBox* v_bool = this->findChild< QCheckBox* >( pName );
- if( v_bool != NULL )
- pIt->second.second = ( v_bool->isChecked( ) )? "1": "0";
- }
- break;
- case Parameters::Int:
- case Parameters::Uint:
- {
- QSpinBox* v_uint = this->findChild< QSpinBox* >( pName );
- if( v_uint )
- {
- std::stringstream str;
- str << v_uint->value( );
- pIt->second.second = str.str( );
-
- } // fi
- }
- break;
- case Parameters::Real:
- {
- QDoubleSpinBox* v_double = this->findChild< QDoubleSpinBox* >( pName );
- if( v_double )
- {
- std::stringstream str;
- str << v_double->value( );
- pIt->second.second = str.str( );
-
- } // fi
- }
- break;
- case Parameters::StringList:
- break;
- case Parameters::BoolList:
- break;
- case Parameters::SaveFileNameList:
- break;
- case Parameters::PathNameList:
- break;
- case Parameters::Choices:
- {
- QComboBox* v_choices = this->findChild< QComboBox* >( pName );
- if( v_choices != NULL )
- {
- std::istringstream str_choices( pIt->second.second );
- std::string real_choices;
- std::getline( str_choices, real_choices, '@' );
- pIt->second.second =
- real_choices + "@" +
- v_choices->currentText( ).toStdString( );
-
- } // fi
- }
- break;
- default:
- break;
- } // hctiws
-
- } // rof
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Interface::ParametersQtDialog::
-updateView( )
-{
- if( this->m_Parameters == NULL )
- return;
-
- // Put values
- auto& raw_params = this->m_Parameters->GetRawParameters( );
- for( auto pIt = raw_params.begin( ); pIt != raw_params.end( ); ++pIt )
- {
- QString pName = pIt->first.c_str( );
- switch( pIt->second.first )
- {
- case Parameters::String:
- case Parameters::OpenFileName:
- case Parameters::SaveFileName:
- case Parameters::PathName:
- case Parameters::IntList:
- case Parameters::UintList:
- case Parameters::RealList:
- case Parameters::OpenFileNameList:
- {
- QLineEdit* v_string = this->findChild< QLineEdit* >( pName );
- if( v_string != NULL )
- v_string->setText( pIt->second.second.c_str( ) );
- }
- break;
- case Parameters::Bool:
- {
- QCheckBox* v_bool = this->findChild< QCheckBox* >( pName );
- if( v_bool != NULL )
- v_bool->setChecked( pIt->second.second == "1" );
- }
- break;
- case Parameters::Int:
- case Parameters::Uint:
- {
- QSpinBox* v_uint = this->findChild< QSpinBox* >( pName );
- if( v_uint )
- {
- std::istringstream tok_str( pIt->second.second );
- int v;
- tok_str >> v;
- v_uint->setValue( v );
-
- } // fi
- }
- break;
- case Parameters::Real:
- {
- QDoubleSpinBox* v_double = this->findChild< QDoubleSpinBox* >( pName );
- if( v_double )
- {
- std::istringstream tok_str( pIt->second.second );
- double v;
- tok_str >> v;
- v_double->setValue( v );
-
- } // fi
- }
- break;
- case Parameters::StringList:
- break;
- case Parameters::BoolList:
- break;
- case Parameters::SaveFileNameList:
- break;
- case Parameters::PathNameList:
- break;
- case Parameters::Choices:
- {
- QComboBox* v_choices = this->findChild< QComboBox* >( pName );
- if( v_choices != NULL )
- {
- std::istringstream str_choices( pIt->second.second );
- std::string choices, real_choice;
- std::getline( str_choices, choices, '@' );
- std::getline( str_choices, real_choice, '@' );
- std::istringstream str( choices );
- std::string token;
- int id = -1, cont = 0;
- while( std::getline( str, token, '#' ) )
- {
- if( token == real_choice )
- id = cont;
- cont++;
-
- } // elihw
-
- if( id > -1 )
- v_choices->setCurrentIndex( id );
-
- } // fi
- }
- break;
- default:
- break;
- } // hctiws
-
- } // rof
+ this->m_WidgetsUpdated = true;
}
// -------------------------------------------------------------------------
this->m_Parameters->GetOpenFileName( param_name );
if( param_value == "" )
param_value = ".";
- QStringList filters;
- filters << "Any file (*)";
+ QStringList dialog_filters;
+ std::string extensions =
+ this->m_Parameters->GetAcceptedFileExtensions( param_name );
+ if( extensions != "" )
+ dialog_filters << extensions.c_str( );
+ dialog_filters << "Any file (*)";
// Show dialog and check if it was accepted
QFileDialog dialog( this );
dialog.setFileMode( QFileDialog::ExistingFile );
dialog.setDirectory( QFileDialog::tr( param_value.c_str( ) ) );
- dialog.setNameFilters( filters );
+ dialog.setNameFilters( dialog_filters );
dialog.setAcceptMode( QFileDialog::AcceptOpen );
if( dialog.exec( ) )
line->setText( *( dialog.selectedFiles( ).begin( ) ) );
this->m_Parameters->GetSaveFileName( param_name );
if( param_value == "" )
param_value = ".";
- QStringList filters;
- filters << "Any file (*)";
+ QStringList dialog_filters;
+ std::string extensions =
+ this->m_Parameters->GetAcceptedFileExtensions( param_name );
+ if( extensions != "" )
+ dialog_filters << extensions.c_str( );
+ dialog_filters << "Any file (*)";
// Show dialog and check if it was accepted
QFileDialog dialog( this );
dialog.setFileMode( QFileDialog::AnyFile );
dialog.setDirectory( QFileDialog::tr( param_value.c_str( ) ) );
- dialog.setNameFilters( filters );
+ dialog.setNameFilters( dialog_filters );
dialog.setAcceptMode( QFileDialog::AcceptSave );
if( dialog.exec( ) )
line->setText( *( dialog.selectedFiles( ).begin( ) ) );
std::string param_name = line->objectName( ).toStdString( );
if( param_name != "" )
{
- QStringList filters;
- filters << "Any file (*)";
+ QStringList dialog_filters;
+ std::string extensions =
+ this->m_Parameters->GetAcceptedFileExtensions( param_name );
+ if( extensions != "" )
+ dialog_filters << extensions.c_str( );
+ dialog_filters << "Any file (*)";
// Show dialog and check if it was accepted
QFileDialog dialog( this );
dialog.setFileMode( QFileDialog::ExistingFiles );
- dialog.setNameFilters( filters );
+ dialog.setNameFilters( dialog_filters );
dialog.setAcceptMode( QFileDialog::AcceptOpen );
if( dialog.exec( ) )
{
std::string( "\"" )
).c_str( ),
"Value:",
- 0, -2147483647, 2147483647, 1,
- &ok
+ 0,
+ -std::numeric_limits< int >::max( ),
+ std::numeric_limits< int >::max( ),
+ 1, &ok
);
if( ok )
{
std::string( "\"" )
).c_str( ),
"Value:",
- 0, 0, 2147483647, 1,
+ 0, 0, std::numeric_limits< int >::max( ), 1,
&ok
);
if( ok )
std::string( "\"" )
).c_str( ),
"Value:",
- 0, -2147483647, 2147483647, 1,
- &ok
+ 0,
+ -std::numeric_limits< double >::max( ),
+ std::numeric_limits< double >::max( ),
+ 1, &ok
);
if( ok )
{
#include <set>
-#include <vtkInteractorObserver.h>
-#include <vtkSmartPointer.h>
-
#include <QDialog>
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QLabel>
#include <QVBoxLayout>
-class vtkRenderWindowInteractor;
-
namespace cpPlugins
{
namespace Interface
{
Q_OBJECT;
- public:
- typedef std::set< vtkRenderWindowInteractor* > TInteractors;
- typedef
- std::map< std::string, vtkSmartPointer< vtkInteractorObserver > >
- TWidgets;
-
public:
ParametersQtDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 );
virtual ~ParametersQtDialog( );
Parameters* getParameters( ) const;
- void addInteractor( vtkRenderWindowInteractor* interactor );
- TInteractors& getInteractors( );
- const TInteractors& getInteractors( ) const;
- bool isInteractive( ) const;
- void setInteractive( bool i );
- void interactiveOn( );
- void interactiveOff( );
bool setParameters( Parameters* parameters );
virtual int exec( );
- virtual void show( );
void updateParameters( );
void updateView( );
+ protected:
+ void _updateWidgets( );
+
protected slots:
- void _dlg_OpenSingleFile( );
- void _dlg_SaveSingleFile( );
- void _dlg_OpenSinglePath( );
- void _dlg_OpenMultipleFiles( );
- void _dlg_AddInt( );
- void _dlg_AddUint( );
- void _dlg_AddReal( );
+ virtual void _dlg_OpenSingleFile( );
+ virtual void _dlg_SaveSingleFile( );
+ virtual void _dlg_OpenSinglePath( );
+ virtual void _dlg_OpenMultipleFiles( );
+ virtual void _dlg_AddInt( );
+ virtual void _dlg_AddUint( );
+ virtual void _dlg_AddReal( );
protected:
Parameters* m_Parameters;
+ bool m_WidgetsUpdated;
QLabel* m_Title;
QGridLayout* m_MainLayout;
QVBoxLayout* m_ToolsLayout;
QDialogButtonBox* m_Buttons;
-
- TInteractors m_Interactors;
- TWidgets m_Widgets;
- bool m_Interactive;
};
} // ecapseman
auto i = this->m_Inputs.find( id );
if( i != this->m_Inputs.end( ) )
{
- i->second = port;
- this->Modified( );
+ if( i->second.GetPointer( ) != port.GetPointer( ) )
+ {
+ i->second = port;
+ this->Modified( );
+
+ } // fi
return( true );
}
else
std::string cpPlugins::Interface::ProcessObject::
Update( )
{
- static
std::string r = "";
// Force upstream updates
typedef typename _TDataContainer::value_type _TValue;
auto i = this->m_Inputs.find( name );
if( i == this->m_Inputs.end( ) )
+ {
i = this->m_Inputs.insert( _TValue( name, NULL ) ).first;
+ this->Modified( );
+
+ } // fi
}
// eof - $RCSfile$
typename O::Pointer o = O::New( );
o->SetSource( this );
this->m_Outputs[ name ] = o;
+ this->Modified( );
} // fi
}
this->SetITK( filter_ptr.GetPointer( ) );
this->SetVTK( NULL );
filter = filter_ptr.GetPointer( );
+ this->Modified( );
} // fi
return( filter );
this->SetITK( NULL );
this->SetVTK( filter_ptr );
filter = filter_ptr.GetPointer( );
+ this->Modified( );
} // fi
return( filter );
#include <QTreeWidget>
#include <QVBoxLayout>
-#endif // cpPlugins_Interface_QT4
+#include <cpPlugins/Interface/ParametersQtDialog.h>
#include <itkGDCMSeriesFileNames.h>
-// -------------------------------------------------------------------------
-/*
-bool cpPlugins::IO::DicomSeriesReader::
-ExecConfigurationDialog( QWidget* parent )
+/**
+ */
+class cpPlugins_IO_DicomSeriesReader_ParametersQtDialog
+ : public cpPlugins::Interface::ParametersQtDialog
{
- bool r = false;
+ // Q_OBJECT;
-#ifdef cpPlugins_Interface_QT4
+public:
+ cpPlugins_IO_DicomSeriesReader_ParametersQtDialog(
+ QWidget* parent = 0, Qt::WindowFlags f = 0
+ )
+ : cpPlugins::Interface::ParametersQtDialog( parent, f )
+ {
+ }
+ virtual ~cpPlugins_IO_DicomSeriesReader_ParametersQtDialog( )
+ {
+ }
- // DICOM series analyzer
- itk::GDCMSeriesFileNames::GlobalWarningDisplayOff( );
- itk::GDCMSeriesFileNames::Pointer series =
- itk::GDCMSeriesFileNames::New( );
-
- // Show dialog and check if it was accepted
- QFileDialog dialog( parent );
- dialog.setFileMode( QFileDialog::DirectoryOnly );
- dialog.setDirectory( QFileDialog::tr( "." ) );
- if( !dialog.exec( ) )
- return( false );
-
- // Prepare dialog
- QApplication::setOverrideCursor( Qt::WaitCursor );
- if( parent != NULL )
- parent->setEnabled( false );
-
- QDialog* tree_dialog = new QDialog( parent );
- QTreeWidget* tree_widget = new QTreeWidget( tree_dialog );
- QList< QTreeWidgetItem* > tree_items;
- std::map< std::string, std::map< std::string, TStringList > > found_files;
-
- std::string main_dir_name =
- dialog.selectedFiles( ).begin( )->toStdString( );
- std::queue< std::string > q;
- q.push( main_dir_name );
- while( !( q.empty( ) ) )
- {
- std::string dir_name = q.front( );
- q.pop( );
-
- // Get DICOM information
- series->SetUseSeriesDetails( true );
- series->AddSeriesRestriction( "0008|0021" );
- series->SetDirectory( dir_name );
- const TStringList& seriesUID = series->GetSeriesUIDs( );
- if( seriesUID.size( ) > 0 )
+protected:
+ virtual void _dlg_OpenMultipleFiles( )
{
- QTreeWidgetItem* new_item = new QTreeWidgetItem(
- ( QTreeWidgetItem* )( NULL ),
- QStringList( dir_name.c_str( ) )
- );
- QTreeWidgetItem* new_leaf = NULL;
- TStringList::const_iterator sIt = seriesUID.begin( );
- for( ; sIt != seriesUID.end( ); ++sIt )
+ // DICOM series analyzer
+ itk::GDCMSeriesFileNames::GlobalWarningDisplayOff( );
+ itk::GDCMSeriesFileNames::Pointer series =
+ itk::GDCMSeriesFileNames::New( );
+
+ // Show dialog and check if it was accepted
+ QWidget* parent = dynamic_cast< QWidget* >( this->parent( ) );
+ QFileDialog dialog( parent );
+ dialog.setFileMode( QFileDialog::DirectoryOnly );
+ dialog.setDirectory( QFileDialog::tr( "." ) );
+ if( !dialog.exec( ) )
+ return;
+
+ // Prepare dialog
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ if( parent != NULL )
+ parent->setEnabled( false );
+
+ QDialog* tree_dialog = new QDialog( parent );
+ QTreeWidget* tree_widget = new QTreeWidget( tree_dialog );
+ QList< QTreeWidgetItem* > tree_items;
+ std::map< std::string, std::map< std::string, std::vector< std::string > > >
+ found_files;
+
+ std::string main_dir_name =
+ dialog.selectedFiles( ).begin( )->toStdString( );
+ std::queue< std::string > q;
+ q.push( main_dir_name );
+ while( !( q.empty( ) ) )
{
- TStringList filenames = series->GetFileNames( *sIt );
- if( filenames.size( ) > 0 )
+ std::string dir_name = q.front( );
+ q.pop( );
+
+ // Get DICOM information
+ series->SetUseSeriesDetails( true );
+ series->AddSeriesRestriction( "0008|0021" );
+ series->SetDirectory( dir_name );
+ const std::vector< std::string >& seriesUID = series->GetSeriesUIDs( );
+ if( seriesUID.size( ) > 0 )
{
- std::stringstream ss;
- ss << "(" << filenames.size( ) << "): " << *sIt;
- new_leaf =
- new QTreeWidgetItem(
- new_item, QStringList( ss.str( ).c_str( ) )
- );
- new_item->addChild( new_leaf );
- found_files[ dir_name ][ *sIt ] = filenames;
+ QTreeWidgetItem* new_item = new QTreeWidgetItem(
+ ( QTreeWidgetItem* )( NULL ),
+ QStringList( dir_name.c_str( ) )
+ );
+ QTreeWidgetItem* new_leaf = NULL;
+ std::vector< std::string >::const_iterator sIt = seriesUID.begin( );
+ for( ; sIt != seriesUID.end( ); ++sIt )
+ {
+ std::vector< std::string > filenames = series->GetFileNames( *sIt );
+ if( filenames.size( ) > 0 )
+ {
+ std::stringstream ss;
+ ss << "(" << filenames.size( ) << "): " << *sIt;
+ new_leaf =
+ new QTreeWidgetItem(
+ new_item, QStringList( ss.str( ).c_str( ) )
+ );
+ new_item->addChild( new_leaf );
+ found_files[ dir_name ][ *sIt ] = filenames;
+
+ } // fi
+
+ } // rof
+
+ if( new_leaf != NULL )
+ tree_items.append( new_item );
+ else
+ delete new_item;
} // fi
- } // rof
-
- if( new_leaf != NULL )
- tree_items.append( new_item );
- else
- delete new_item;
-
- } // fi
-
- // Update queue
- QDir dir( dir_name.c_str( ) );
- QFileInfoList contents = dir.entryInfoList( );
- QFileInfoList::const_iterator i = contents.begin( );
- for( ; i != contents.end( ); ++i )
- {
- if( i->isDir( ) )
- {
- std::string new_dir_name = i->absoluteFilePath( ).toStdString( );
- if( new_dir_name.size( ) > dir_name.size( ) )
- q.push( new_dir_name );
+ // Update queue
+ QDir dir( dir_name.c_str( ) );
+ QFileInfoList contents = dir.entryInfoList( );
+ QFileInfoList::const_iterator i = contents.begin( );
+ for( ; i != contents.end( ); ++i )
+ {
+ if( i->isDir( ) )
+ {
+ std::string new_dir_name = i->absoluteFilePath( ).toStdString( );
+ if( new_dir_name.size( ) > dir_name.size( ) )
+ q.push( new_dir_name );
- } // fi
+ } // fi
- } // rof
+ } // rof
- } // elihw
+ } // elihw
- // Show second dialog
- if( tree_items.size( ) == 0 )
- {
- delete tree_widget;
- delete tree_dialog;
- return( false );
+ // Show second dialog
+ if( tree_items.size( ) == 0 )
+ {
+ delete tree_widget;
+ delete tree_dialog;
+ return;
- } // fi
+ } // fi
- QLabel* title = new QLabel( tree_dialog );
- title->setText( "Choose a DICOM series" );
- QGridLayout* mainLayout = new QGridLayout( tree_dialog );
- QVBoxLayout* toolsLayout = new QVBoxLayout( );
- toolsLayout->addWidget( title );
- mainLayout->addLayout( toolsLayout, 0, 0, 1, 1 );
-
- tree_widget->insertTopLevelItems( 0, tree_items );
- toolsLayout->addWidget( tree_widget );
-
- QDialogButtonBox* bb = new QDialogButtonBox(
- QDialogButtonBox::Ok | QDialogButtonBox::Cancel
- );
- tree_dialog->connect(
- bb, SIGNAL( accepted( ) ), tree_dialog, SLOT( accept( ) )
- );
- tree_dialog->connect(
- bb, SIGNAL( rejected( ) ), tree_dialog, SLOT( reject( ) )
- );
- toolsLayout->addWidget( bb );
-
- QApplication::restoreOverrideCursor( );
- if( parent != NULL )
- parent->setEnabled( true );
-
- if( tree_dialog->exec( ) == 0 )
- return( false );
-
- QTreeWidgetItem* item = tree_widget->currentItem( );
- if( item != NULL )
- {
- QTreeWidgetItem* item_parent = item->parent( );
- if( item_parent != NULL )
- {
- QApplication::setOverrideCursor( Qt::WaitCursor );
- if( parent != NULL )
- parent->setEnabled( false );
+ QLabel* title = new QLabel( tree_dialog );
+ title->setText( "Choose a DICOM series" );
+ QGridLayout* mainLayout = new QGridLayout( tree_dialog );
+ QVBoxLayout* toolsLayout = new QVBoxLayout( );
+ toolsLayout->addWidget( title );
+ mainLayout->addLayout( toolsLayout, 0, 0, 1, 1 );
- std::string serie_dir = item_parent->text( 0 ).toStdString( );
- std::string serie_id = item->text( 0 ).toStdString( );
- serie_id = serie_id.substr( serie_id.find_first_of( " " ) + 1 );
- this->m_Parameters->ClearOpenFileNameList( "FileNames" );
- const TStringList& names = found_files[ serie_dir ][ serie_id ];
- for( unsigned int f = 0; f < names.size( ); ++f )
- this->m_Parameters->AddToOpenFileNameList( "FileNames", names[ f ] );
+ tree_widget->insertTopLevelItems( 0, tree_items );
+ toolsLayout->addWidget( tree_widget );
- r = true;
+ QDialogButtonBox* bb = new QDialogButtonBox(
+ QDialogButtonBox::Ok | QDialogButtonBox::Cancel
+ );
+ tree_dialog->connect(
+ bb, SIGNAL( accepted( ) ), tree_dialog, SLOT( accept( ) )
+ );
+ tree_dialog->connect(
+ bb, SIGNAL( rejected( ) ), tree_dialog, SLOT( reject( ) )
+ );
+ toolsLayout->addWidget( bb );
QApplication::restoreOverrideCursor( );
if( parent != NULL )
parent->setEnabled( true );
- } // fi
+ if( tree_dialog->exec( ) == 0 )
+ return;
- } // fi
+ QTreeWidgetItem* item = tree_widget->currentItem( );
+ if( item != NULL )
+ {
+ QTreeWidgetItem* item_parent = item->parent( );
+ if( item_parent != NULL )
+ {
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ if( parent != NULL )
+ parent->setEnabled( false );
+
+ std::string serie_dir = item_parent->text( 0 ).toStdString( );
+ std::string serie_id = item->text( 0 ).toStdString( );
+ serie_id = serie_id.substr( serie_id.find_first_of( " " ) + 1 );
+ this->m_Parameters->ClearOpenFileNameList( "FileNames" );
+ const std::vector< std::string >& names =
+ found_files[ serie_dir ][ serie_id ];
+ for( unsigned int f = 0; f < names.size( ); ++f )
+ this->m_Parameters->AddToOpenFileNameList( "FileNames", names[ f ] );
+ this->updateView( );
+
+ QApplication::restoreOverrideCursor( );
+ if( parent != NULL )
+ parent->setEnabled( true );
- itk::GDCMSeriesFileNames::GlobalWarningDisplayOn( );
+ } // fi
-#endif // cpPlugins_Interface_QT4
+ } // fi
+ itk::GDCMSeriesFileNames::GlobalWarningDisplayOn( );
+ }
+};
- return( r );
-}
-*/
+#endif // cpPlugins_Interface_QT4
// -------------------------------------------------------------------------
cpPlugins::IO::DicomSeriesReader::
DicomSeriesReader( )
: Superclass( )
{
+#ifdef cpPlugins_Interface_QT4
+ if( QApplication::instance( ) != NULL )
+ {
+ this->m_ParametersDialog =
+ new cpPlugins_IO_DicomSeriesReader_ParametersQtDialog( );
+ this->m_ParametersDialog->setParameters( this->m_Parameters );
+
+ } // fi
+#endif // cpPlugins_Interface_QT4
}
// -------------------------------------------------------------------------
itkTypeMacro( DicomSeriesReader, ImageReader );
cpPlugins_Id_Macro( cpPlugins::IO::DicomSeriesReader, IO );
- /* TODO
- public:
- virtual bool ExecConfigurationDialog( QWidget* parent );
- */
-
protected:
DicomSeriesReader( );
virtual ~DicomSeriesReader( );
#include <itkImageFileReader.h>
#include <itkImageSeriesReader.h>
-/* 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;
-
- #ifdef cpPlugins_Interface_QT4
-
- QStringList filters;
- filters
- << "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)"
- << "Any files (*)";
-
- 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;
-
- } // fi
-
- #endif // cpPlugins_Interface_QT4
-
- return( r );
- }
-*/
-
// -------------------------------------------------------------------------
cpPlugins::IO::ImageReader::
ImageReader( )
this->m_Parameters->ConfigureAsOpenFileNameList( "FileNames" );
this->m_Parameters->ConfigureAsBool( "VectorType" );
this->m_Parameters->SetBool( "VectorType", false );
+ this->m_Parameters->SetAcceptedFileExtensions(
+ "FileNames",
+ "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)"
+ );
}
// -------------------------------------------------------------------------
#include <itkImageFileWriter.h>
-/* 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::
ImageWriter( )
{
this->_AddInput( "Input" );
this->m_Parameters->ConfigureAsSaveFileName( "FileName" );
+ this->m_Parameters->SetAcceptedFileExtensions(
+ "FileName",
+ "Image files (*.bmp *.png *.jpg *.jpeg *.dcm *.mhd *.nhdr *.nrrd *.tiff)"
+ );
}
// -------------------------------------------------------------------------
#include <vtkPolyData.h>
#include <vtkPolyDataReader.h>
-/* TODO
-#ifdef cpPlugins_Interface_QT4
-#include <QFileDialog>
-#endif // cpPlugins_Interface_QT4
-
-// -------------------------------------------------------------------------
-cpPlugins::IO::MeshReader::
-DialogResult cpPlugins::IO::MeshReader::
-ExecConfigurationDialog( QWidget* parent )
-{
- DialogResult r = Self::DialogResult_Cancel;
-
-#ifdef cpPlugins_Interface_QT4
-
- // Show dialog and check if it was accepted
- QFileDialog dialog( parent );
- dialog.setFileMode( QFileDialog::ExistingFile );
- dialog.setDirectory( QFileDialog::tr( "." ) );
- dialog.setNameFilter( QFileDialog::tr( "All files (*)" ) );
- if( dialog.exec( ) )
- {
- QStringList names = dialog.selectedFiles( );
- this->m_Parameters->SetString( "FileName", names[ 0 ].toStdString( ) );
- this->m_Parameters->SetSelectedChoice( "PixelType", "float" );
- this->m_Parameters->SetUint( "Dimension", 3 );
-
- r = Self::DialogResult_NoModal;
-
- } // fi
-
-#endif // cpPlugins_Interface_QT4
-
- return( r );
-}
-*/
-
// -------------------------------------------------------------------------
cpPlugins::IO::MeshReader::
MeshReader( )
this->m_Parameters->ConfigureAsUint( "Dimension" );
this->m_Parameters->SetUint( "Dimension", 3 );
+ this->m_Parameters->SetAcceptedFileExtensions(
+ "FileName",
+ "Mesh files (*.vtk *.stl *.obj)"
+ );
}
// -------------------------------------------------------------------------
#include <vtkPolyData.h>
#include <vtkPolyDataWriter.h>
-/* 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
-
- 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::
MeshWriter( )
{
this->_AddInput( "Input" );
this->m_Parameters->ConfigureAsSaveFileName( "FileName" );
+ this->m_Parameters->SetAcceptedFileExtensions(
+ "FileName",
+ "Mesh files (*.vtk *.stl *.obj)"
+ );
}
// -------------------------------------------------------------------------