qtdcmDataSourceSerieToolBox::qtdcmDataSourceSerieToolBox ( QWidget* parent ) : medToolBox ( parent ), d ( new qtdcmDataSourceSerieToolBoxPrivate )
{
    d->parent = parent;
    
    d->main = new QWidget(this);
    QVBoxLayout *mainLayout = new QVBoxLayout;
    d->main->setLayout(mainLayout);
    
    d->preview = new QtDcmPreviewWidget(d->main);
    d->serieInfoWidget = new QtDcmSerieInfoWidget(d->main);
    d->importWidget = new QtDcmImportWidget(d->main);
    
    mainLayout->addWidget(d->preview);
    mainLayout->addWidget(d->serieInfoWidget);
    mainLayout->addWidget(d->importWidget);
    
    this->addWidget(d->main);
    this->setTitle("Series preview and import");

    // Add about plugin
    medPluginManager* pm = medPluginManager::instance();
    dtkPlugin* plugin = pm->plugin ( "QtDCM Data Source" );
    setAboutPluginButton ( plugin );
    setAboutPluginVisibility( true );
}
ITKProcessExampleToolBox::ITKProcessExampleToolBox(QWidget *parent) : medFilteringAbstractToolBox(parent), d(new ITKProcessExampleToolBoxPrivate)
{
    // Parameters:

    QLabel *varianceLabel = new QLabel("Sigma : ");
    d->variance = new QLineEdit("1.0");

    QHBoxLayout *varianceLayout = new QHBoxLayout();
    varianceLayout->addWidget(varianceLabel);
    varianceLayout->addWidget(d->variance);

    // Run button:

    QPushButton *runButton = new QPushButton(tr("Run"));

    // Principal layout:

    QWidget *widget = new QWidget(this);

    d->progression_stack = new medProgressionStack(widget);

    QVBoxLayout *layprinc = new QVBoxLayout();
    layprinc->addLayout(varianceLayout);
    layprinc->addWidget(runButton);
    layprinc->addWidget(d->progression_stack);

    widget->setLayout(layprinc);

    // Main toolbox:
    this->setTitle("ITK Gaussian Smoothing");
    this->addWidget(widget);

    //enable about plugin. Construtor called after the plugin has been registered, go ahead call it.
    medPluginManager* pm = medPluginManager::instance();
    dtkPlugin* plugin = pm->plugin(
                "ITKProcessExamplePlugin");
    setAboutPluginButton(plugin);
    setAboutPluginVisibility(true);

    connect(runButton, SIGNAL(clicked()), this, SLOT(run()));

}
itkProcessRegistrationDiffeomorphicDemonsToolBox::itkProcessRegistrationDiffeomorphicDemonsToolBox(QWidget *parent) : medRegistrationAbstractToolBox(parent), d(new itkProcessRegistrationDiffeomorphicDemonsToolBoxPrivate)
{
    QWidget *widget = new QWidget(this);

    QPushButton *runButton = new QPushButton(tr("Run"), this);
    runButton->setToolTip(tr("Start Registration"));

    QFormLayout *layout = new QFormLayout(widget);

    d->iterationsBox = new QLineEdit(this);
    d->iterationsBox->setText("15x10x5");
    d->iterationsBox->setToolTip(tr("Each number of iteration per level must be separated by \"x\". From coarser to finest levels"));

    d->maxStepLengthBox = new QDoubleSpinBox(this);
    d->maxStepLengthBox->setMinimum(0);
    d->maxStepLengthBox->setMaximum(1000);
    d->maxStepLengthBox->setSingleStep(0.01);
    d->maxStepLengthBox->setValue(2.0);
    d->maxStepLengthBox->setToolTip(tr(
                "Maximum length of an update vector (voxel units)."
                " Setting it to 0 implies no restrictions will be made"
                " on the step length."));

    d->updateFieldStdDevBox = new QDoubleSpinBox(this);
    d->updateFieldStdDevBox->setMinimum(0);
    d->updateFieldStdDevBox->setMaximum(1000);
    d->updateFieldStdDevBox->setSingleStep(0.01);
    d->updateFieldStdDevBox->setValue(0.0);
    d->updateFieldStdDevBox->setToolTip(tr(
                "Standard deviation of the Gaussian smoothing"
                "of the update field (voxel units). Setting it below 0.1"
                "means no smoothing will be performed (default 0.0)."));

    d->disFieldStdDevBox = new QDoubleSpinBox(this);
    d->disFieldStdDevBox->setMinimum(0);
    d->disFieldStdDevBox->setMaximum(1000);
    d->disFieldStdDevBox->setSingleStep(0.01);
    d->disFieldStdDevBox->setValue(1.5);
    d->disFieldStdDevBox->setToolTip(tr(
                "Standard deviation of the Gaussian smoothing of "
                "the displacement field (voxel units). Setting it below 0.1 "
                "means no smoothing will be performed (default 1.5)."));
    d->updateRuleBox = new QComboBox(this);
    QStringList updateRules;
    updateRules<< tr("Diffeomorphic") << tr ("Additive") << tr("Compositive");
    d->updateRuleBox->addItems(updateRules);
    //WARNING IF YOU CHANGE THE ORDER OF THE ITEMS, CHANGE TOOLTIPS also!!!
    d->updateRuleBox->setItemData(0,"s <- s o exp(u)",Qt::ToolTipRole);
    d->updateRuleBox->setItemData(1,"s <- s + u",Qt::ToolTipRole);
    d->updateRuleBox->setItemData(2,"s <- s o (Id+u)",Qt::ToolTipRole);

    d->gradientTypeBox = new QComboBox(this);
    d->gradientTypeBox->setToolTip(tr(
                "Type of gradient used for computing the demons force."));
    QStringList gradientTypes;
    gradientTypes<< tr("Symmetrized") << tr ("Fixed Image")
                 << tr("Warped Moving Image")
                 << tr("Mapped Moving Image");
    d->gradientTypeBox->addItems(gradientTypes);
    d->useHistogramBox =  new QCheckBox(this);
    d->useHistogramBox->setChecked(false);
    d->useHistogramBox->setToolTip(tr(
                "Use histogram matching before processing?"));

    this->setTitle("Diffeomorphic Demons");
    layout->addRow(new QLabel(tr("Iterations per level of res."),this),d->iterationsBox);
    layout->addRow(new QLabel(tr("Update Rule"),this),d->updateRuleBox);
    layout->addRow(new QLabel(tr("Gradient Type"),this),d->gradientTypeBox);
    layout->addRow(new QLabel(tr("Max. Update Step Length"),this),d->maxStepLengthBox);
    layout->addRow(new QLabel(tr("Update Field Std. Deviation"),this),
                   d->updateFieldStdDevBox);
    layout->addRow(new QLabel(tr("Displ. Field Std. Deviation"),this),
                   d->disFieldStdDevBox);
    layout->addRow(new QLabel(tr("Histogram Matching"),this),d->useHistogramBox);

    // progression stack
    d->progression_stack = new medProgressionStack(widget);
//    QHBoxLayout *progressStackLayout = new QHBoxLayout;
//    progressStackLayout->addWidget(d->progression_stack);

    this->addWidget(widget);
    this->addWidget(runButton);
    this->addWidget(d->progression_stack);

    //enable about plugin. Constructor called after the plugin has been registered, go ahead call it.
    medPluginManager* pm = medPluginManager::instance();
    dtkPlugin* plugin = pm->plugin(
                "itkProcessRegistrationDiffeomorphicDemonsPlugin");
    setAboutPluginButton(plugin);
    setAboutPluginVisibility(true);

    connect(runButton, SIGNAL(clicked()), this, SLOT(run()));
}
itkMorphologicalFiltersToolBox::itkMorphologicalFiltersToolBox ( QWidget *parent ) : medFilteringAbstractToolBox ( parent ), d ( new itkMorphologicalFiltersToolBoxPrivate )
{
    qDebug() << "itkMorphologicalFiltersToolBox";
    //Filters selection combobox
    d->filters = new QComboBox;
    QStringList filtersList;
    filtersList << "Dilate "
                << "Erode "
                << "Close "
                << "Open ";
    
    d->filters->addItems ( filtersList );

    QLabel * dataTypeLabel = new QLabel ( tr ( "Data type :" ) );
    d->dataTypeValue = new QLabel ( tr ( "Unknown" ) );

    QHBoxLayout * dataTypeLayout = new QHBoxLayout;
    dataTypeLayout->addWidget ( dataTypeLabel );
    dataTypeLayout->addWidget ( d->dataTypeValue );

    // We use the same widget for all the morphological filters
    d->filterWidget = new QWidget(this);
    d->kernelSize = new QDoubleSpinBox;
    d->kernelSize->setMaximum ( 10 );
    d->kernelSize->setValue ( 1 );
    QLabel * morphoFilterLabel = new QLabel ( tr ( "Kernel radius:" ) );
    QHBoxLayout * morphoFilterLayout = new QHBoxLayout;
    QLabel * morphoFilterLabel2 = new QLabel ( tr ( " pixels" ) );
    morphoFilterLayout->addWidget ( morphoFilterLabel );
    morphoFilterLayout->addWidget ( d->kernelSize );
    morphoFilterLayout->addWidget ( morphoFilterLabel2 );
    morphoFilterLayout->addStretch ( 1 );
    d->filterWidget->setLayout ( morphoFilterLayout );


    // Run button:
    QPushButton *runButton = new QPushButton ( tr ( "Run" ) );
    runButton->setFocusPolicy ( Qt::NoFocus );
    runButton->setToolTip(tr("Launch the selected filter"));

    // Principal layout:
    QWidget *widget = new QWidget ( this );

    d->progressionStack = new medProgressionStack ( widget );

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget ( d->filters );
    layout->addLayout ( dataTypeLayout );
    layout->addWidget ( d->filterWidget );
    layout->addWidget ( runButton );
    layout->addWidget ( d->progressionStack );
    layout->addStretch ( 1 );

    widget->setLayout ( layout );

    // Main toolbox:
    this->setTitle ( tr ( "ITK Morphological Filters" ) );
    this->addWidget ( widget );

    // Add about plugin
    medPluginManager* pm = medPluginManager::instance();
    dtkPlugin* plugin = pm->plugin ( "itkFiltersPlugin" );
    setAboutPluginButton ( plugin );
    setAboutPluginVisibility ( true );

    connect ( runButton, SIGNAL ( clicked() ), this, SLOT ( run() ) );

}