Beispiel #1
0
void QmitkThresholdAction::Run(const vector<DataNode *> &selectedNodes)
{
  m_ThresholdingToolManager = ToolManager::New(m_DataStorage);

  m_ThresholdingToolManager->RegisterClient();
  m_ThresholdingToolManager->ActiveToolChanged += mitk::MessageDelegate<QmitkThresholdAction>(this, &QmitkThresholdAction::OnThresholdingToolManagerToolModified);

  m_ThresholdingDialog = new QDialog;
  connect(m_ThresholdingDialog, SIGNAL(finished(int)), this, SLOT(ThresholdingDone(int)));

  QVBoxLayout *layout = new QVBoxLayout;
  layout->setContentsMargins(0, 0, 0, 0);

  Tool *binaryThresholdTool = m_ThresholdingToolManager->GetToolById(m_ThresholdingToolManager->GetToolIdByToolType<mitk::BinaryThresholdTool>());
  
  if (binaryThresholdTool != NULL)
  {
    QmitkToolGUI *gui = dynamic_cast<QmitkToolGUI *>(binaryThresholdTool->GetGUI("Qmitk", "GUI").GetPointer());
    
    if (gui != NULL)
    {
      gui->SetTool(binaryThresholdTool);
      gui->setParent(m_ThresholdingDialog);

      layout->addWidget(gui);

      m_ThresholdingDialog->setLayout(layout);
      m_ThresholdingDialog->setFixedSize(300, 80);

      m_ThresholdingDialog->open();
    }

    m_ThresholdingToolManager->SetReferenceData(selectedNodes[0]);
    m_ThresholdingToolManager->ActivateTool(m_ThresholdingToolManager->GetToolIdByToolType<mitk::BinaryThresholdTool>());
  }
}