bool QmitkDataStorageTableModel::DataNodeCompareFunction::operator()(const mitk::DataNode::Pointer &_Left,
                                                                     const mitk::DataNode::Pointer &_Right) const
{
  switch (m_CompareCriteria)
  {
    case CompareByClassName:
      if (m_CompareOperator == Less)
        return (_Left->GetData()->GetNameOfClass() < _Right->GetData()->GetNameOfClass());
      else
        return (_Left->GetData()->GetNameOfClass() > _Right->GetData()->GetNameOfClass());
      break;

    case CompareByVisibility:
    {
      bool _LeftVisibility = false;
      bool _RightVisibility = false;
      _Left->GetVisibility(_LeftVisibility, nullptr);
      _Right->GetVisibility(_RightVisibility, nullptr);

      if (m_CompareOperator == Less)
        return (_LeftVisibility < _RightVisibility);
      else
        return (_LeftVisibility > _RightVisibility);
    }
    break;

    // CompareByName:
    default:
      if (m_CompareOperator == Less)
        return (_Left->GetName() < _Right->GetName());
      else
        return (_Left->GetName() > _Right->GetName());
      break;
  }
}
void QmitkNavigationToolCreationAdvancedWidget::SetToolTipSurface( bool cone, mitk::DataNode::Pointer node /*= NULL*/ )
{
  m_ToolTipSurface = NULL;
  if(cone)
  {
    m_ToolTipSurface = mitk::Surface::New();
    vtkConeSource *vtkData = vtkConeSource::New();
    vtkData->SetAngle(5.0);
    vtkData->SetResolution(50);
    vtkData->SetHeight(6.0f);
    vtkData->SetRadius(2.0f);
    vtkData->SetCenter(0.0, 0.0, 0.0);

    vtkData->Update();
    m_ToolTipSurface->SetVtkPolyData(vtkData->GetOutput());

    vtkData->Delete();
    m_SurfaceNodeName ="";
  }
  else if(!cone && node.IsNotNull())
  {
    m_ToolTipSurface = dynamic_cast<mitk::Surface*>(node->GetData());
    m_SurfaceNodeName = node->GetName();
  }
}
  foreach ( mitk::DataNode::Pointer referenceNode, selectedNodes )
  {
    if (referenceNode.IsNotNull())
    {
      mitk::LabelSetImage::Pointer referenceImage = dynamic_cast<mitk::LabelSetImage*>( referenceNode->GetData() );
      assert(referenceImage);

      if(referenceImage->GetNumberOfLabels() <= 1)
      {
        QMessageBox::information(nullptr, "Create LabelSetImage Preset", "Could not create a LabelSetImage preset.\nNo Labels defined!\n");\
        return;
      }

      std::string sName = referenceNode->GetName();
      QString qName;
      qName.sprintf("%s.lsetp",sName.c_str());
      QString filename = QFileDialog::getSaveFileName( nullptr,"save file dialog",QString(),"LabelSet Preset(*.lsetp)");
      if ( filename.isEmpty() )
        return;

      std::string fileName = filename.toStdString();
      bool wasSaved = mitk::LabelSetIOHelper::SaveLabelSetImagePreset(fileName,referenceImage);

      if(!wasSaved)
      {
        QMessageBox::information(nullptr, "Create LabelSetImage Preset", "Could not save a LabelSetImage preset as Xml.\n");\
        return;
      }
    }
  }
예제 #4
0
void QmitkIGTTrackingLabView::OnToolLoaded(int index, mitk::DataNode::Pointer toolNode)
{
  if(m_Source.IsNull() || m_Visualizer.IsNull())
    return;

  mitk::DataStorage* ds = this->GetDefaultDataStorage();
  if(ds == NULL)
  {
    QMessageBox::warning(NULL,"DataStorage Access Error", "Could not access DataStorage. Loaded tool representation can not be shown!");
    return;
  }

  mitk::NavigationData::Pointer tempND = m_Source->GetOutput(index);
  if(tempND.IsNull())
    return;

  // try to find DataNode for tool in DataStorage
  const char* toolName = tempND->GetName();
  mitk::DataNode::Pointer tempNode = ds->GetNamedNode(toolName);

  if(tempNode.IsNull())
  {
    tempNode = mitk::DataNode::New();  // create new node, if none was found
    ds->Add(tempNode);
  }

  tempNode->SetData(toolNode->GetData());
  tempNode->SetName(toolNode->GetName());

  m_PSRecToolSelectionComboBox->setItemText(index,toolNode->GetName().c_str());

  m_VirtualViewToolSelectionWidget->ChangeToolName(index, QString(toolNode->GetName().c_str()));
  m_PermanentRegistrationToolSelectionWidget->ChangeToolName(index, QString(toolNode->GetName().c_str()));

  m_Visualizer->SetRepresentationObject(index, tempNode->GetData());
  m_Visualizer->Update();

  tempNode->Modified();
  this->GlobalReinit();
}
  foreach ( mitk::DataNode::Pointer referenceNode, selectedNodes )
  {

    if (referenceNode.IsNull()) return;

    mitk::LabelSetImage::Pointer referenceImage = dynamic_cast<mitk::LabelSetImage*>( referenceNode->GetData() );
    assert(referenceImage);

    std::string sName = referenceNode->GetName();
    QString qName;
    qName.sprintf("%s.lsetp",sName.c_str());
    QString filename = QFileDialog::getOpenFileName(nullptr,"Load file",QString(),"LabelSet Preset(*.lsetp)");
    if ( filename.isEmpty() )
      return;

    std::string fileName = filename.toStdString();
    mitk::LabelSetIOHelper::LoadLabelSetImagePreset(fileName, referenceImage);
  }
mitk::NavigationTool::Pointer mitk::NavigationToolReader::ConvertDataNodeToNavigationTool(mitk::DataNode::Pointer node, std::string toolPath)
  {
  mitk::NavigationTool::Pointer returnValue = mitk::NavigationTool::New();

  //DateTreeNode with Name and Surface
  mitk::DataNode::Pointer newNode = mitk::DataNode::New();
  newNode->SetName(node->GetName());
  newNode->SetData(node->GetData());
  returnValue->SetDataNode(newNode);

  //Identifier
  std::string identifier;
  node->GetStringProperty("identifier",identifier);
  returnValue->SetIdentifier(identifier);

  //Serial Number
  std::string serial;
  node->GetStringProperty("serial number",serial);
  returnValue->SetSerialNumber(serial);

  //Tracking Device
  int device_type;
  node->GetIntProperty("tracking device type",device_type);
  returnValue->SetTrackingDeviceType(static_cast<mitk::TrackingDeviceType>(device_type));

  //Tool Type
  int type;
  node->GetIntProperty("tracking tool type",type);
  returnValue->SetType(static_cast<mitk::NavigationTool::NavigationToolType>(type));

  //Calibration File Name
  std::string calibration_filename;
  node->GetStringProperty("toolfileName",calibration_filename);
  if (calibration_filename=="none")
    {
    returnValue->SetCalibrationFile("none");
    }
  else
    {
    std::string calibration_filename_with_path = toolPath + Poco::Path::separator() + calibration_filename;
    returnValue->SetCalibrationFile(calibration_filename_with_path);
    }

  //Tool Landmarks
  mitk::PointSet::Pointer ToolRegLandmarks = mitk::PointSet::New();
  mitk::PointSet::Pointer ToolCalLandmarks = mitk::PointSet::New();
  std::string RegLandmarksString;
  std::string CalLandmarksString;
  node->GetStringProperty("ToolRegistrationLandmarks",RegLandmarksString);
  node->GetStringProperty("ToolCalibrationLandmarks",CalLandmarksString);
  ToolRegLandmarks = ConvertStringToPointSet(RegLandmarksString);
  ToolCalLandmarks = ConvertStringToPointSet(CalLandmarksString);
  returnValue->SetToolRegistrationLandmarks(ToolRegLandmarks);
  returnValue->SetToolCalibrationLandmarks(ToolCalLandmarks);

  //Tool Tip
  std::string toolTipPositionString;
  std::string toolTipOrientationString;
  bool positionSet = node->GetStringProperty("ToolTipPosition",toolTipPositionString);
  bool orientationSet = node->GetStringProperty("ToolTipOrientation",toolTipOrientationString);

  if(positionSet && orientationSet) //only define tooltip if it is set
    {
    returnValue->SetToolTipPosition(ConvertStringToPoint(toolTipPositionString));
    returnValue->SetToolTipOrientation(ConvertStringToQuaternion(toolTipOrientationString));
    }
  else if(positionSet != orientationSet)
    {
    MITK_WARN << "Tooltip definition incomplete: position and orientation have to be set! Skipping tooltip definition.";
    }

  return returnValue;
  }