<commit_before>#include "QmitkUSCombinedModalityCreationWidget.h"
#include "ui_QmitkUSCombinedModalityCreationWidget.h"

QmitkUSCombinedModalityCreationWidget::QmitkUSCombinedModalityCreationWidget(QWidget *parent) :
  QWidget(parent),
  ui(new Ui::QmitkUSCombinedModalityCreationWidget)
{
  ui->setupUi(this);

  std::string filterExcludeCombinedModalities = "(&(" + us::ServiceConstants::OBJECTCLASS() + "=" + "org.mitk.services.UltrasoundDevice)(!(" + mitk::USDevice::US_PROPKEY_CLASS + "=" + mitk::USCombinedModality::DeviceClassIdentifier + ")))";

  ui->usDevicesServiceList->Initialize<mitk::USDevice>(mitk::USDevice::US_PROPKEY_LABEL, filterExcludeCombinedModalities);
  ui->trackingDevicesServiceList->Initialize<mitk::NavigationDataSource>(mitk::NavigationDataSource::US_PROPKEY_DEVICENAME);

  connect( ui->usDevicesServiceList,       SIGNAL( ServiceSelectionChanged(us::ServiceReferenceU) ), this, SLOT(OnSelectedUltrasoundOrTrackingDevice()) );
  connect( ui->trackingDevicesServiceList, SIGNAL( ServiceSelectionChanged(us::ServiceReferenceU) ), this, SLOT(OnSelectedUltrasoundOrTrackingDevice()) );

  connect( ui->createButton, SIGNAL(clicked()), this, SLOT(OnCreation()) );
  connect( ui->cancelButton, SIGNAL(clicked()), this, SIGNAL(SignalAborted()) );
}

QmitkUSCombinedModalityCreationWidget::~QmitkUSCombinedModalityCreationWidget()
{
  delete ui;
}

void QmitkUSCombinedModalityCreationWidget::OnCreation()
{
  mitk::USDevice::Pointer usDevice = ui->usDevicesServiceList->GetSelectedService<mitk::USDevice>();
  if (usDevice.IsNull())
  {
      MITK_WARN << "No Ultrasound Device selected for creation of Combined Modality.";
      return;
  }

  mitk::NavigationDataSource::Pointer trackingDevice = ui->trackingDevicesServiceList->GetSelectedService<mitk::NavigationDataSource>();
  if (trackingDevice.IsNull())
  {
      MITK_WARN << "No Traccking Device selected for creation of Combined Modality.";
      return;
  }

  QString vendor = ui->vendorLineEdit->text();
  QString name = ui->nameLineEdit->text();
  if (name.isEmpty()) { name = "Combined Modality"; }

  mitk::USCombinedModality::Pointer combinedModality = mitk::USCombinedModality::New(
    usDevice, trackingDevice, vendor.toStdString(), name.toStdString());
  combinedModality->Initialize(); // register as micro service

  emit SignalCreated();
  emit SignalCreated(combinedModality);
}

void QmitkUSCombinedModalityCreationWidget::OnSelectedUltrasoundOrTrackingDevice()
{
  // create button is enabled only if an ultrasound
  // and a tracking device is selected
  ui->createButton->setEnabled(
              ui->usDevicesServiceList->GetIsServiceSelected()
          && ui->trackingDevicesServiceList->GetIsServiceSelected());
}
<commit_msg>Connect slots before initializing the service list widgets.<commit_after>#include "QmitkUSCombinedModalityCreationWidget.h"
#include "ui_QmitkUSCombinedModalityCreationWidget.h"

QmitkUSCombinedModalityCreationWidget::QmitkUSCombinedModalityCreationWidget(QWidget *parent) :
  QWidget(parent),
  ui(new Ui::QmitkUSCombinedModalityCreationWidget)
{
  ui->setupUi(this);

  std::string filterExcludeCombinedModalities = "(&(" + us::ServiceConstants::OBJECTCLASS() + "=" + "org.mitk.services.UltrasoundDevice)(!(" + mitk::USDevice::US_PROPKEY_CLASS + "=" + mitk::USCombinedModality::DeviceClassIdentifier + ")))";

  connect( ui->usDevicesServiceList,       SIGNAL( ServiceSelectionChanged(us::ServiceReferenceU) ), this, SLOT(OnSelectedUltrasoundOrTrackingDevice()) );
  connect( ui->trackingDevicesServiceList, SIGNAL( ServiceSelectionChanged(us::ServiceReferenceU) ), this, SLOT(OnSelectedUltrasoundOrTrackingDevice()) );

  ui->usDevicesServiceList->Initialize<mitk::USDevice>(mitk::USDevice::US_PROPKEY_LABEL, filterExcludeCombinedModalities);
  ui->trackingDevicesServiceList->Initialize<mitk::NavigationDataSource>(mitk::NavigationDataSource::US_PROPKEY_DEVICENAME);

  connect( ui->createButton, SIGNAL(clicked()), this, SLOT(OnCreation()) );
  connect( ui->cancelButton, SIGNAL(clicked()), this, SIGNAL(SignalAborted()) );
}

QmitkUSCombinedModalityCreationWidget::~QmitkUSCombinedModalityCreationWidget()
{
  delete ui;
}

void QmitkUSCombinedModalityCreationWidget::OnCreation()
{
  mitk::USDevice::Pointer usDevice = ui->usDevicesServiceList->GetSelectedService<mitk::USDevice>();
  if (usDevice.IsNull())
  {
      MITK_WARN << "No Ultrasound Device selected for creation of Combined Modality.";
      return;
  }

  mitk::NavigationDataSource::Pointer trackingDevice = ui->trackingDevicesServiceList->GetSelectedService<mitk::NavigationDataSource>();
  if (trackingDevice.IsNull())
  {
      MITK_WARN << "No Traccking Device selected for creation of Combined Modality.";
      return;
  }

  QString vendor = ui->vendorLineEdit->text();
  QString name = ui->nameLineEdit->text();
  if (name.isEmpty()) { name = "Combined Modality"; }

  mitk::USCombinedModality::Pointer combinedModality = mitk::USCombinedModality::New(
    usDevice, trackingDevice, vendor.toStdString(), name.toStdString());
  combinedModality->Initialize(); // register as micro service

  emit SignalCreated();
  emit SignalCreated(combinedModality);
}

void QmitkUSCombinedModalityCreationWidget::OnSelectedUltrasoundOrTrackingDevice()
{
  // create button is enabled only if an ultrasound
  // and a tracking device is selected
  ui->createButton->setEnabled(
              ui->usDevicesServiceList->GetIsServiceSelected()
          && ui->trackingDevicesServiceList->GetIsServiceSelected());
}

{'fraction_non_alphanumeric': 0.12568008705114256, 'fraction_numerical': 0.0, 'mean_word_length': 7.0276564774381365, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5630985', 'n_tokens_mistral': 1668, 'n_tokens_neox': 1629, 'n_words': 255}