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

Program:   Medical Imaging & Interaction Toolkit
Module:    $RCSfile$
Language:  C++
Date:      $Date$
Version:   $Revision$ 

Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.

This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "QmitkPixelGreyValueManipulatorComponent.h"
#include "QmitkPixelGreyValueManipulatorComponentGUI.h"

#include <QmitkDataTreeComboBox.h>

#include "mitkRenderWindow.h"
#include "mitkRenderingManager.h"
#include "mitkProperties.h"
#include "mitkDataTreeFilterFunctions.h"

#include <qlineedit.h>
#include <qslider.h>
#include <qgroupbox.h>


/***************       CONSTRUCTOR      ***************/
QmitkPixelGreyValueManipulatorComponent::QmitkPixelGreyValueManipulatorComponent(QObject *parent, const char *parentName, QmitkStdMultiWidget *mitkStdMultiWidget, mitk::DataTreeIteratorBase* it, bool updateSelector, bool showSelector):
m_ParentName(parentName),
m_ComponentName("SurfaceCreator"),
m_MultiWidget(mitkStdMultiWidget),
m_DataTreeIteratorClone(NULL),
m_UpdateSelector(updateSelector),
m_ShowSelector(showSelector),
m_Active(false),
m_GUI(NULL),
m_SelectedImage(NULL),
m_Spacer(NULL)
{
  SetDataTreeIterator(it);
}

/***************        DESTRUCTOR      ***************/
QmitkPixelGreyValueManipulatorComponent::~QmitkPixelGreyValueManipulatorComponent()
{

}

/*************** GET FUNCTIONALITY NAME ***************/
QString QmitkPixelGreyValueManipulatorComponent::GetFunctionalityName()
{
  return m_ParentName;
}

/*************** SET FUNCTIONALITY NAME ***************/
void QmitkPixelGreyValueManipulatorComponent::SetFunctionalityName(QString parentName)
{
  m_ParentName = parentName;
}

/***************   GET COMPONENT NAME   ***************/
QString QmitkPixelGreyValueManipulatorComponent::GetComponentName()
{
  return m_ComponentName;
}

/*************** GET DATA TREE ITERATOR ***************/
mitk::DataTreeIteratorBase* QmitkPixelGreyValueManipulatorComponent::GetDataTreeIterator()
{
  return m_DataTreeIterator.GetPointer();
}

/*************** SET DATA TREE ITERATOR ***************/
void QmitkPixelGreyValueManipulatorComponent::SetDataTreeIterator(mitk::DataTreeIteratorBase* it)
{
  m_DataTreeIterator = it;
}

/***************         GET GUI        ***************/
QWidget* QmitkPixelGreyValueManipulatorComponent::GetGUI()
{
  return m_GUI;
}

/*************** TREE CHANGED (       ) ***************/
void QmitkPixelGreyValueManipulatorComponent::TreeChanged()
{

}

/***************       CONNECTIONS      ***************/
void QmitkPixelGreyValueManipulatorComponent::CreateConnections()
{
  if ( m_GUI )
  {
    connect( (QObject*)(m_GUI->GetTreeNodeSelector()), SIGNAL(activated(const mitk::DataTreeFilter::Item *)), (QObject*) this, SLOT(ImageSelected(const mitk::DataTreeFilter::Item *)));        
    connect( (QObject*)(m_GUI->GetPixelGreyValueManipulatorGroupBox()), SIGNAL(toggled(bool)), (QObject*) this, SLOT(ShowPixelGreyValueManipulatorContent(bool)));
    connect( (QObject*)(m_GUI->GetSelectDataGroupBox()), SIGNAL(toggled(bool)), (QObject*) this, SLOT(ShowImageContent(bool)));

    //Button "create new manipulated image" pressed
    connect( (QObject*)(m_GUI->GetCreateNewManipulatedImageButton()), SIGNAL(pressed()), (QObject*) this, SLOT(PipelineControlerToCreateManipulatedImage()));
    connect( (QObject*)(m_GUI->GetManipulationModeComboBox()), SIGNAL(activated (int)), (QObject*) this, SLOT(HideOrShowValue2(int)));    
  }
}

/***************     IMAGE SELECTED     ***************/
void QmitkPixelGreyValueManipulatorComponent::ImageSelected(const mitk::DataTreeFilter::Item * imageIt)
{
  m_SelectedImage = imageIt;
  mitk::DataTreeFilter::Item* currentItem(NULL);
  if(m_GUI)
  {
    if(mitk::DataTreeFilter* filter = m_GUI->GetTreeNodeSelector()->GetFilter())
    {
      if(imageIt)
      {
        currentItem = const_cast <mitk::DataTreeFilter::Item*> ( filter->FindItem( imageIt->GetNode() ) );
      }
    }
  }
  if(currentItem)
  {
    currentItem->SetSelected(true);
  }
  if(m_GUI != NULL)
  {

    for(unsigned int i = 0;  i < m_AddedChildList.size(); i++) 
    {
      m_AddedChildList[i]->ImageSelected(m_SelectedImage);
    }
  }
  TreeChanged();
}

/*************** CREATE CONTAINER WIDGET **************/
QWidget* QmitkPixelGreyValueManipulatorComponent::CreateContainerWidget(QWidget* parent)
{
  m_GUI = new QmitkPixelGreyValueManipulatorComponentGUI(parent);
  m_GUI->GetTreeNodeSelector()->SetDataTree(GetDataTreeIterator());
 
  if(!m_ShowSelector)
  {
    m_GUI->GetSelectDataGroupBox()->setShown(false);
  }
  //m_GUI->GetTreeNodeSelector()->GetFilter()->SetFilter(mitk::IsBaseDataTypeWithBoolProperty<mitk::Image>("segmentation"));
  
  

  return m_GUI;

}

/************** SET SELECTOR VISIBILITY ***************/
void QmitkPixelGreyValueManipulatorComponent::SetSelectorVisibility(bool visibility)
{
  if(m_GUI)
  {
    m_GUI->GetSelectDataGroupBox()->setShown(visibility);
  }
  m_ShowSelector = visibility;
}


/***************        ACTIVATED       ***************/
void QmitkPixelGreyValueManipulatorComponent::Activated()
{
  m_Active = true;
}

/***************       DEACTIVATED      ***************/
void QmitkPixelGreyValueManipulatorComponent::Deactivated()
{
  m_Active = false;
}

///*********** SHOW PIXEL MANIPULATOR CONTENT ***********/
void QmitkPixelGreyValueManipulatorComponent::ShowPixelGreyValueManipulatorContent(bool)
{
m_GUI->GetPixelManipulatorContentGroupBox()->setShown(m_GUI->GetPixelGreyValueManipulatorGroupBox()->isChecked());
}

///***************    SHOW IMAGE CONTENT   **************/
void QmitkPixelGreyValueManipulatorComponent::ShowImageContent(bool)
{
 m_GUI->GetImageContent()->setShown(m_GUI->GetSelectDataGroupBox()->isChecked());
}

void QmitkPixelGreyValueManipulatorComponent::HideOrShowValue2(int index)
{
  if(m_GUI->GetManipulationModeComboBox()->currentItem() != 2)
  {
    m_GUI->GetValue2GroupBox()->setShown(false);
  }
  else if(m_GUI->GetManipulationModeComboBox()->currentItem() == 2)
  {
    m_GUI->GetValue2GroupBox()->setShown(true);
  }
}



/***************      ADD COMPONENT     ***************/
void QmitkPixelGreyValueManipulatorComponent::AddComponent(QmitkFunctionalityComponentContainer* componentContainer)
{  
  if(componentContainer!=NULL)
  {
    QWidget* componentWidget = componentContainer->CreateContainerWidget(m_GUI);
    m_AddedChildList.push_back(componentContainer);
    m_GUI->layout()->add(componentWidget);
    if(m_Spacer != NULL)
    {<commit_msg>FIX warning comment unused parameters<commit_after>/*=========================================================================

Program:   Medical Imaging & Interaction Toolkit
Module:    $RCSfile$
Language:  C++
Date:      $Date$
Version:   $Revision$ 

Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.

This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "QmitkPixelGreyValueManipulatorComponent.h"
#include "QmitkPixelGreyValueManipulatorComponentGUI.h"

#include <QmitkDataTreeComboBox.h>

#include "mitkRenderWindow.h"
#include "mitkRenderingManager.h"
#include "mitkProperties.h"
#include "mitkDataTreeFilterFunctions.h"

#include <qlineedit.h>
#include <qslider.h>
#include <qgroupbox.h>


/***************       CONSTRUCTOR      ***************/
QmitkPixelGreyValueManipulatorComponent::QmitkPixelGreyValueManipulatorComponent(QObject *parent, const char *parentName, QmitkStdMultiWidget *mitkStdMultiWidget, mitk::DataTreeIteratorBase* it, bool updateSelector, bool showSelector):
m_ParentName(parentName),
m_ComponentName("SurfaceCreator"),
m_MultiWidget(mitkStdMultiWidget),
m_DataTreeIteratorClone(NULL),
m_UpdateSelector(updateSelector),
m_ShowSelector(showSelector),
m_Active(false),
m_GUI(NULL),
m_SelectedImage(NULL),
m_Spacer(NULL)
{
  SetDataTreeIterator(it);
}

/***************        DESTRUCTOR      ***************/
QmitkPixelGreyValueManipulatorComponent::~QmitkPixelGreyValueManipulatorComponent()
{

}

/*************** GET FUNCTIONALITY NAME ***************/
QString QmitkPixelGreyValueManipulatorComponent::GetFunctionalityName()
{
  return m_ParentName;
}

/*************** SET FUNCTIONALITY NAME ***************/
void QmitkPixelGreyValueManipulatorComponent::SetFunctionalityName(QString parentName)
{
  m_ParentName = parentName;
}

/***************   GET COMPONENT NAME   ***************/
QString QmitkPixelGreyValueManipulatorComponent::GetComponentName()
{
  return m_ComponentName;
}

/*************** GET DATA TREE ITERATOR ***************/
mitk::DataTreeIteratorBase* QmitkPixelGreyValueManipulatorComponent::GetDataTreeIterator()
{
  return m_DataTreeIterator.GetPointer();
}

/*************** SET DATA TREE ITERATOR ***************/
void QmitkPixelGreyValueManipulatorComponent::SetDataTreeIterator(mitk::DataTreeIteratorBase* it)
{
  m_DataTreeIterator = it;
}

/***************         GET GUI        ***************/
QWidget* QmitkPixelGreyValueManipulatorComponent::GetGUI()
{
  return m_GUI;
}

/*************** TREE CHANGED (       ) ***************/
void QmitkPixelGreyValueManipulatorComponent::TreeChanged()
{

}

/***************       CONNECTIONS      ***************/
void QmitkPixelGreyValueManipulatorComponent::CreateConnections()
{
  if ( m_GUI )
  {
    connect( (QObject*)(m_GUI->GetTreeNodeSelector()), SIGNAL(activated(const mitk::DataTreeFilter::Item *)), (QObject*) this, SLOT(ImageSelected(const mitk::DataTreeFilter::Item *)));        
    connect( (QObject*)(m_GUI->GetPixelGreyValueManipulatorGroupBox()), SIGNAL(toggled(bool)), (QObject*) this, SLOT(ShowPixelGreyValueManipulatorContent(bool)));
    connect( (QObject*)(m_GUI->GetSelectDataGroupBox()), SIGNAL(toggled(bool)), (QObject*) this, SLOT(ShowImageContent(bool)));

    //Button "create new manipulated image" pressed
    connect( (QObject*)(m_GUI->GetCreateNewManipulatedImageButton()), SIGNAL(pressed()), (QObject*) this, SLOT(PipelineControlerToCreateManipulatedImage()));
    connect( (QObject*)(m_GUI->GetManipulationModeComboBox()), SIGNAL(activated (int)), (QObject*) this, SLOT(HideOrShowValue2(int)));    
  }
}

/***************     IMAGE SELECTED     ***************/
void QmitkPixelGreyValueManipulatorComponent::ImageSelected(const mitk::DataTreeFilter::Item * imageIt)
{
  m_SelectedImage = imageIt;
  mitk::DataTreeFilter::Item* currentItem(NULL);
  if(m_GUI)
  {
    if(mitk::DataTreeFilter* filter = m_GUI->GetTreeNodeSelector()->GetFilter())
    {
      if(imageIt)
      {
        currentItem = const_cast <mitk::DataTreeFilter::Item*> ( filter->FindItem( imageIt->GetNode() ) );
      }
    }
  }
  if(currentItem)
  {
    currentItem->SetSelected(true);
  }
  if(m_GUI != NULL)
  {

    for(unsigned int i = 0;  i < m_AddedChildList.size(); i++) 
    {
      m_AddedChildList[i]->ImageSelected(m_SelectedImage);
    }
  }
  TreeChanged();
}

/*************** CREATE CONTAINER WIDGET **************/
QWidget* QmitkPixelGreyValueManipulatorComponent::CreateContainerWidget(QWidget* parent)
{
  m_GUI = new QmitkPixelGreyValueManipulatorComponentGUI(parent);
  m_GUI->GetTreeNodeSelector()->SetDataTree(GetDataTreeIterator());
 
  if(!m_ShowSelector)
  {
    m_GUI->GetSelectDataGroupBox()->setShown(false);
  }
  //m_GUI->GetTreeNodeSelector()->GetFilter()->SetFilter(mitk::IsBaseDataTypeWithBoolProperty<mitk::Image>("segmentation"));
  
  

  return m_GUI;

}

/************** SET SELECTOR VISIBILITY ***************/
void QmitkPixelGreyValueManipulatorComponent::SetSelectorVisibility(bool visibility)
{
  if(m_GUI)
  {
    m_GUI->GetSelectDataGroupBox()->setShown(visibility);
  }
  m_ShowSelector = visibility;
}


/***************        ACTIVATED       ***************/
void QmitkPixelGreyValueManipulatorComponent::Activated()
{
  m_Active = true;
}

/***************       DEACTIVATED      ***************/
void QmitkPixelGreyValueManipulatorComponent::Deactivated()
{
  m_Active = false;
}

///*********** SHOW PIXEL MANIPULATOR CONTENT ***********/
void QmitkPixelGreyValueManipulatorComponent::ShowPixelGreyValueManipulatorContent(bool)
{
m_GUI->GetPixelManipulatorContentGroupBox()->setShown(m_GUI->GetPixelGreyValueManipulatorGroupBox()->isChecked());
}

///***************    SHOW IMAGE CONTENT   **************/
void QmitkPixelGreyValueManipulatorComponent::ShowImageContent(bool)
{
 m_GUI->GetImageContent()->setShown(m_GUI->GetSelectDataGroupBox()->isChecked());
}

void QmitkPixelGreyValueManipulatorComponent::HideOrShowValue2(int /*index*/)
{ 
  if(m_GUI->GetManipulationModeComboBox()->currentItem() != 2)
  {
    m_GUI->GetValue2GroupBox()->setShown(false);
  }
  else if(m_GUI->GetManipulationModeComboBox()->currentItem() == 2)
  {
    m_GUI->GetValue2GroupBox()->setShown(true);
  }
}



/***************      ADD COMPONENT     ***************/
void QmitkPixelGreyValueManipulatorComponent::AddComponent(QmitkFunctionalityComponentContainer* componentContainer)
{  
  if(componentContainer!=NULL)
  {
    QWidget* componentWidget = componentContainer->CreateContainerWidget(m_GUI);
    m_AddedChildList.push_back(componentContainer);
    m_GUI->layout()->add(componentWidget);
    if(m_Spacer != NULL)
    {
{'fraction_non_alphanumeric': 0.20290064218197562, 'fraction_numerical': 0.0010101738942203623, 'mean_word_length': 6.435622317596566, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 93, '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': '2279751', 'n_tokens_mistral': 4324, 'n_tokens_neox': 4298, 'n_words': 618}