<commit_before>/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include <QMessageBox>
#include <QThreadPool>

#include "mitkWorkbenchUtil.h"

#include "PerfusionCurveDescriptionParameterView.h"
#include "QmitkDescriptionParameterBackgroundJob.h"
#include "mitkAreaUnderTheCurveDescriptionParameter.h"
#include "mitkAreaUnderFirstMomentDescriptionParameter.h"
#include "mitkMeanResidenceTimeDescriptionParameter.h"
#include "mitkTimeToPeakCurveDescriptionParameter.h"
#include "mitkMaximumCurveDescriptionParameter.h"
#include "mitkPixelBasedDescriptionParameterImageGenerator.h"
#include "mitkCurveParameterFunctor.h"
#include "mitkExtractTimeGrid.h"

#include <iostream>

const std::string PerfusionCurveDescriptionParameterView::VIEW_ID =
  "org.mitk.gui.qt.pharmacokinetics.curvedescriptor";

void PerfusionCurveDescriptionParameterView::SetFocus()
{
  m_Controls.btnCalculateParameters->setFocus();
}

void PerfusionCurveDescriptionParameterView::CreateQtPartControl(QWidget* parent)
{
  m_Controls.setupUi(parent);
  m_Controls.btnCalculateParameters->setEnabled(false);



  connect(m_Controls.btnCalculateParameters, SIGNAL(clicked()), this,
          SLOT(OnCalculateParametersButtonClicked()));


  InitParameterList();
}


void PerfusionCurveDescriptionParameterView::OnSelectionChanged(
  berry::IWorkbenchPart::Pointer /*source*/, const QList<mitk::DataNode::Pointer>& /*nodes*/)
{

  m_Controls.btnCalculateParameters->setEnabled(false);



  QList<mitk::DataNode::Pointer> dataNodes = this->GetDataManagerSelection();

  if (dataNodes.empty())
  {
    m_selectedNode = NULL;
    m_selectedImage = NULL;
  }
  else
  {
    m_selectedNode = dataNodes[0];
    m_selectedImage = dynamic_cast<mitk::Image*>(m_selectedNode->GetData());
  }

  if (m_selectedImage.IsNotNull())
  {
    if (m_selectedImage->GetTimeGeometry()->CountTimeSteps() > 1)
    {
      m_Controls.btnCalculateParameters->setEnabled(true);
    }
    else
    {
      this->OnJobStatusChanged("Cannot compute parameters. Selected image must have multiple time steps.");
    }
  }
  else if (m_selectedNode.IsNotNull())
  {
    this->OnJobStatusChanged("Cannot compute parameters. Selected node is not an image.");
  }
  else
  {
    this->OnJobStatusChanged("Cannot compute parameters. No node selected.");
  }
}<commit_msg>Fixed T26698<commit_after>/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include <QMessageBox>
#include <QThreadPool>

#include "mitkWorkbenchUtil.h"

#include "PerfusionCurveDescriptionParameterView.h"
#include "QmitkDescriptionParameterBackgroundJob.h"
#include "mitkAreaUnderTheCurveDescriptionParameter.h"
#include "mitkAreaUnderFirstMomentDescriptionParameter.h"
#include "mitkMeanResidenceTimeDescriptionParameter.h"
#include "mitkTimeToPeakCurveDescriptionParameter.h"
#include "mitkMaximumCurveDescriptionParameter.h"
#include "mitkPixelBasedDescriptionParameterImageGenerator.h"
#include "mitkCurveParameterFunctor.h"
#include "mitkExtractTimeGrid.h"

#include <iostream>

const std::string PerfusionCurveDescriptionParameterView::VIEW_ID =
  "org.mitk.gui.qt.pharmacokinetics.curvedescriptor";

void PerfusionCurveDescriptionParameterView::SetFocus()
{
  m_Controls.btnCalculateParameters->setFocus();
}

void PerfusionCurveDescriptionParameterView::CreateQtPartControl(QWidget* parent)
{
  m_Controls.setupUi(parent);
  m_Controls.btnCalculateParameters->setEnabled(false);



  connect(m_Controls.btnCalculateParameters, SIGNAL(clicked()), this,
          SLOT(OnCalculateParametersButtonClicked()));


  InitParameterList();
}


void PerfusionCurveDescriptionParameterView::OnSelectionChanged(
  berry::IWorkbenchPart::Pointer /*source*/, const QList<mitk::DataNode::Pointer>& /*nodes*/)
{

  m_Controls.btnCalculateParameters->setEnabled(false);



  QList<mitk::DataNode::Pointer> dataNodes = this->GetDataManagerSelection();

  if (dataNodes.empty())
  {
    m_selectedNode = NULL;
    m_selectedImage = NULL;
  }
  else
  {
    m_selectedNode = dataNodes[0];
    m_selectedImage = dynamic_cast<mitk::Image*>(m_selectedNode->GetData());
  }

  m_Controls.lableSelectedImage->setText("No series selected.");

  if (m_selectedImage.IsNotNull())
  {
    if (m_selectedImage->GetTimeGeometry()->CountTimeSteps() > 1)
    {
      m_Controls.btnCalculateParameters->setEnabled(true);
      m_Controls.lableSelectedImage->setText((this->m_selectedNode->GetName()).c_str());
    }
    else
    {
      this->OnJobStatusChanged("Cannot compute parameters. Selected image must have multiple time steps.");
    }
  }
  else if (m_selectedNode.IsNotNull())
  {
    this->OnJobStatusChanged("Cannot compute parameters. Selected node is not an image.");
  }
  else
  {
    this->OnJobStatusChanged("Cannot compute parameters. No node selected.");
  }
}
{'fraction_non_alphanumeric': 0.1487107029318262, 'fraction_numerical': 0.0015895443306252208, 'mean_word_length': 6.2695763799743265, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6967041', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1574, 'n_words': 307}