<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 "mitkUSTelemedProbesControls.h"
#include "mitkUSTelemedDevice.h"
#include <mitkException.h>

mitk::USTelemedProbesControls::USTelemedProbesControls(itk::SmartPointer<USTelemedDevice> device)
  : mitk::USControlInterfaceProbes(device.GetPointer()),
    m_IsActive(false), m_TelemedDevice(device),
    m_ProbesCollection(0), m_Probe(0)
{
}

mitk::USTelemedProbesControls::~USTelemedProbesControls()
{
  SAFE_RELEASE(m_ProbesCollection);
}

void mitk::USTelemedProbesControls::SetIsActive(bool isActive)
{
  if ( ! m_TelemedDevice )
  {
    MITK_WARN("USTelemedProbesControls")("USControlInterfaceProbes")
      << "Cannot activate probe controls while device is not set.";
    return;
  }

  if ( isActive && m_ProbesCollection == 0 )
  {
    this->CreateProbesCollection();
    this->CreateProbesSet();
  }
  else
  {
  }

  m_IsActive = isActive;
}

bool mitk::USTelemedProbesControls::GetIsActive()
{
  return m_IsActive;
}

std::vector<mitk::USProbe::Pointer> mitk::USTelemedProbesControls::GetProbeSet()
{
  // create a new vector of base class (USProbe) objects, because
  // interface wants a vector of this type
  std::vector<mitk::USProbe::Pointer> usProbes(m_ProbesSet.size(), 0);
  for (unsigned int n = 0; n < m_ProbesSet.size(); ++n)
  {
    usProbes.at(n) = m_ProbesSet.at(n).GetPointer();
  }
  return usProbes;
}

void mitk::USTelemedProbesControls::OnSelectProbe(unsigned int index)
{
  if (index >= m_ProbesSet.size())
  {
    MITK_ERROR("USTelemedProbesControls")("USControlInterfaceProbes")
      << "Cannot select probe with index " << index << ". Maximum possible index is " << m_ProbesSet.size()-1 << ".";
    mitkThrow() << "Cannot select probe with index " << index <<
      ". Maximum possible index is " << m_ProbesSet.size()-1 << ".";
  }

  m_TelemedDevice->SetActiveDataView(m_ProbesSet.at(index)->GetUsgDataView());

  m_SelectedProbeIndex = index;
}

void mitk::USTelemedProbesControls::OnSelectProbe(mitk::USProbe::Pointer probe)
{
}

mitk::USProbe::Pointer mitk::USTelemedProbesControls::GetSelectedProbe()
{
  if (m_SelectedProbeIndex >= m_ProbesSet.size())
  {
    MITK_ERROR("USTelemedProbesControls")("USControlInterfaceProbes")
      << "Cannot get active probe as the current index is" << m_SelectedProbeIndex <<
      ". Maximum possible index is " << m_ProbesSet.size()-1 << ".";
    mitkThrow() << "Cannot get active probe as the current index is" << m_SelectedProbeIndex <<
      ". Maximum possible index is " << m_ProbesSet.size()-1 << ".";
  }

  return m_ProbesSet.at(m_SelectedProbeIndex);
}

unsigned int mitk::USTelemedProbesControls::GetProbesCount() const
{
  return m_ProbesSet.size();
}

/*void mitk::USTelemedProbesControls::SetTelemedDevice(itk::SmartPointer<USTelemedDevice> telemedDevice)
{
  m_TelemedDevice = telemedDevice;
}*/

void mitk::USTelemedProbesControls::ProbeRemoved(unsigned int index)
{
  MITK_INFO << "Probe removed...";

  if ( m_ProbesSet.size() > index )
  {
    m_ProbesSet.erase(m_ProbesSet.begin() + index);
  }
}
<commit_msg>Fixed MSVC10 warning about implicit convertions.<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 "mitkUSTelemedProbesControls.h"
#include "mitkUSTelemedDevice.h"
#include <mitkException.h>

mitk::USTelemedProbesControls::USTelemedProbesControls(itk::SmartPointer<USTelemedDevice> device)
  : mitk::USControlInterfaceProbes(device.GetPointer()),
    m_IsActive(false), m_TelemedDevice(device),
    m_ProbesCollection(0), m_Probe(0)
{
}

mitk::USTelemedProbesControls::~USTelemedProbesControls()
{
  SAFE_RELEASE(m_ProbesCollection);
}

void mitk::USTelemedProbesControls::SetIsActive(bool isActive)
{
  if ( ! m_TelemedDevice )
  {
    MITK_WARN("USTelemedProbesControls")("USControlInterfaceProbes")
      << "Cannot activate probe controls while device is not set.";
    return;
  }

  if ( isActive && m_ProbesCollection == 0 )
  {
    this->CreateProbesCollection();
    this->CreateProbesSet();
  }
  else
  {
  }

  m_IsActive = isActive;
}

bool mitk::USTelemedProbesControls::GetIsActive()
{
  return m_IsActive;
}

std::vector<mitk::USProbe::Pointer> mitk::USTelemedProbesControls::GetProbeSet()
{
  // create a new vector of base class (USProbe) objects, because
  // interface wants a vector of this type
  std::vector<mitk::USProbe::Pointer> usProbes(m_ProbesSet.size(), 0);
  for (unsigned int n = 0; n < m_ProbesSet.size(); ++n)
  {
    usProbes.at(n) = m_ProbesSet.at(n).GetPointer();
  }
  return usProbes;
}

void mitk::USTelemedProbesControls::OnSelectProbe(unsigned int index)
{
  if (index >= m_ProbesSet.size())
  {
    MITK_ERROR("USTelemedProbesControls")("USControlInterfaceProbes")
      << "Cannot select probe with index " << index << ". Maximum possible index is " << m_ProbesSet.size()-1 << ".";
    mitkThrow() << "Cannot select probe with index " << index <<
      ". Maximum possible index is " << m_ProbesSet.size()-1 << ".";
  }

  m_TelemedDevice->SetActiveDataView(m_ProbesSet.at(index)->GetUsgDataView());

  m_SelectedProbeIndex = index;
}

void mitk::USTelemedProbesControls::OnSelectProbe(mitk::USProbe::Pointer probe)
{
}

mitk::USProbe::Pointer mitk::USTelemedProbesControls::GetSelectedProbe()
{
  if (m_SelectedProbeIndex >= m_ProbesSet.size())
  {
    MITK_ERROR("USTelemedProbesControls")("USControlInterfaceProbes")
      << "Cannot get active probe as the current index is" << m_SelectedProbeIndex <<
      ". Maximum possible index is " << m_ProbesSet.size()-1 << ".";
    mitkThrow() << "Cannot get active probe as the current index is" << m_SelectedProbeIndex <<
      ". Maximum possible index is " << m_ProbesSet.size()-1 << ".";
  }

  return m_ProbesSet.at(m_SelectedProbeIndex).GetPointer();
}

unsigned int mitk::USTelemedProbesControls::GetProbesCount() const
{
  return m_ProbesSet.size();
}

/*void mitk::USTelemedProbesControls::SetTelemedDevice(itk::SmartPointer<USTelemedDevice> telemedDevice)
{
  m_TelemedDevice = telemedDevice;
}*/

void mitk::USTelemedProbesControls::ProbeRemoved(unsigned int index)
{
  MITK_INFO << "Probe removed...";

  if ( m_ProbesSet.size() > index )
  {
    m_ProbesSet.erase(m_ProbesSet.begin() + index);
  }
}

{'fraction_non_alphanumeric': 0.16296087813115676, 'fraction_numerical': 0.0028145229383619475, 'mean_word_length': 5.356887298747764, 'pattern_counts': {'":': 0, '<': 103, '<?xml version=': 0, '>': 27, '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': '7148726', 'n_tokens_mistral': 2351, 'n_tokens_neox': 2301, 'n_words': 465}