--- /dev/null
+#include "MainWnd.h"
+#include "ui_MainWnd.h"
+
+#include <cstdlib>
+
+#include <QDoubleSpinBox>
+#include <QLabel>
+
+// -------------------------------------------------------------------------
+bool MainWnd::
+_ParametersDialog( const TParameters& parameters )
+{
+ if( this->m_ActiveParameters != NULL )
+ this->m_ActiveParameters->close( );
+ this->m_ActiveParameters = new QWidget( NULL );
+ this->m_ActiveParameters->setWindowFlags( Qt::FramelessWindowHint );
+ this->m_ActiveParameters->setWindowFlags( Qt::WindowTitleHint );
+
+ QGridLayout* gridLayout = new QGridLayout( this->m_ActiveParameters );
+ QVBoxLayout* verticalLayout = new QVBoxLayout( );
+
+ // Put values
+ QLabel* title = new QLabel( this->m_ActiveParameters );
+ title->setText( this->m_ActivePlugin->GetClassName( ).c_str( ) );
+ verticalLayout->addWidget( title );
+
+ TParameters::const_iterator pIt = parameters.begin( );
+ for( ; pIt != parameters.end( ); ++pIt )
+ {
+ std::string par_name = pIt->first;
+ std::string par_type = pIt->second.first;
+ std::string par_value = pIt->second.second;
+
+ if( par_type == "double" )
+ {
+ QHBoxLayout* horizontalLayout = new QHBoxLayout( );
+ QLabel* label = new QLabel( this->m_ActiveParameters );
+ label->setText( QString( par_name.c_str( ) ) );
+ horizontalLayout->addWidget( label );
+
+ QDoubleSpinBox* v_double =
+ new QDoubleSpinBox( this->m_ActiveParameters );
+ v_double->setDecimals( 3 );
+ v_double->setMinimum( -( std::numeric_limits< double >::max( ) ) );
+ v_double->setMaximum( std::numeric_limits< double >::max( ) );
+ v_double->setValue( std::atof( par_value.c_str( ) ) );
+ v_double->setObjectName( QString( par_name.c_str( ) ) );
+ horizontalLayout->addWidget( v_double );
+ verticalLayout->addLayout( horizontalLayout );
+
+ } // fi
+
+ } // rof
+ gridLayout->addLayout( verticalLayout, 0, 0, 1, 1 );
+ QMetaObject::connectSlotsByName( this->m_ActiveParameters );
+ this->m_ActiveParameters->show( );
+
+ /*
+ typedef std::map< std::string, QWidget* > _TWidgets;
+ _TWidgets widgets;
+ TParameters::const_iterator pIt = parameters.begin( );
+ for( ; pIt != parameters.end( ); ++pIt )
+ {
+ unsigned long pos = pIt->first.find_last_of( ":" );
+ std::string v_name = pIt->first.substr( 0, pos );
+ std::string v_type = pIt->first.substr( pos + 1 );
+ QHBoxLayout* horizontalLayout = new QHBoxLayout( );
+ QLabel* label = new QLabel( this->m_ActiveParameters );
+ label->setText( QString( v_name.c_str( ) ) );
+ horizontalLayout->addWidget( label );
+ if( v_type == "real" )
+ {
+ QDoubleSpinBox* v_double = new QDoubleSpinBox( this->m_ActiveParameters );
+ v_double->setDecimals( 3 );
+ v_double->setMinimum( -( std::numeric_limits< double >::max( ) ) );
+ v_double->setMaximum( std::numeric_limits< double >::max( ) );
+ v_double->setValue( std::atof( pIt->second.c_str( ) ) );
+ horizontalLayout->addWidget( v_double );
+ widgets[ pIt->first ] = v_double;
+ }
+ else if( v_type == "atomic_real" )
+ {
+ if( v_name == "MeshType" )
+ {
+ QLabel* info = new QLabel( this->m_ActiveParameters );
+ if( typeid( TScalar ) == typeid( float ) )
+ info->setText( QString( "float" ) );
+ else if( typeid( TScalar ) == typeid( double ) )
+ info->setText( QString( "double" ) );
+ horizontalLayout->addWidget( info );
+ widgets[ pIt->first ] = info;
+ } // fi
+ } // fi
+ verticalLayout.addLayout( horizontalLayout );
+ } // rof
+ gridLayout.addLayout( &verticalLayout, 0, 0, 1, 1 );
+ // Buttons box
+ QDialogButtonBox buttonBox( this->m_ActiveParameters );
+ buttonBox.setOrientation( Qt::Horizontal );
+ buttonBox.setStandardButtons(
+ QDialogButtonBox::Cancel | QDialogButtonBox::Ok
+ );
+ gridLayout.addWidget( &buttonBox, 1, 0, 1, 1 );
+ QObject::connect(
+ &buttonBox, SIGNAL( accepted( ) ),
+ this->m_ActiveParameters, SLOT( accept( ) )
+ );
+ QObject::connect(
+ &buttonBox, SIGNAL( rejected( ) ),
+ this->m_ActiveParameters, SLOT( reject( ) )
+ );
+ QMetaObject::connectSlotsByName( this->m_ActiveParameters );
+
+ // Execute dialog
+ if( dlg.exec( ) == QDialog::Accepted )
+ {
+ _TWidgets::const_iterator wIt = widgets.begin( );
+ for( ; wIt != widgets.end( ); ++wIt )
+ {
+ unsigned long pos = wIt->first.find_last_of( ":" );
+ std::string v_name = wIt->first.substr( 0, pos );
+ std::string v_type = wIt->first.substr( pos + 1 );
+ std::stringstream sstr;
+ if( v_type == "real" )
+ {
+ QDoubleSpinBox* v_double =
+ dynamic_cast< QDoubleSpinBox* >( wIt->second );
+ if( v_double != NULL )
+ sstr << v_double->value( );
+ }
+ else if( v_type == "atomic_real" )
+ {
+ if( v_name == "MeshType" )
+ {
+ QLabel* info = dynamic_cast< QLabel* >( wIt->second );
+ if( info != NULL )
+ sstr << info->text( ).toStdString( );
+
+ } // fi
+
+ } // fi
+ parameters[ wIt->first ] = sstr.str( );
+
+ } // rof
+ return( true );
+ }
+ */
+ return( false );
+}
+
+// -------------------------------------------------------------------------
+void MainWnd::
+_triggered_actionSegmentImage( )
+{
+}
+
+// -------------------------------------------------------------------------
+void MainWnd::
+_triggered_actionFilterSegmentation( )
+{
+ // Get filter name
+ if( this->m_SegmentedImage == NULL )
+ return;
+ QAction* action = dynamic_cast< QAction* >( this->sender( ) );
+ if( action == NULL )
+ return;
+ std::string filter_name = action->text( ).toStdString( );
+
+ // Create plugin
+ if( this->m_ActivePlugin != NULL ) delete this->m_ActivePlugin;
+ this->m_ActivePlugin =
+ dynamic_cast< TPlugin* >(
+ this->m_Plugins.CreateObject(
+ this->m_SegmentationFilterClasses[ filter_name ]
+ )
+ );
+
+ // Show parameters dialog
+ this->_ParametersDialog( this->m_ActivePlugin->GetDefaultParameters( ) );
+}
+
+// -------------------------------------------------------------------------
+void MainWnd::
+_triggered_actionProcessMesh( )
+{
+}
+
+// eof - $RCSfile$