mitk::NavigationToolStorage::Pointer mitk::NavigationToolStorageDeserializer::Deserialize(std::string filename)
  {
  //decompress zip file into temporary directory
  decompressFiles(filename,m_tempDirectory);

  //now read all files and convert them to navigation tools
  mitk::NavigationToolStorage::Pointer returnValue = mitk::NavigationToolStorage::New(m_DataStorage);
  bool cont = true;
  int i;
  for (i=0; cont==true; i++)
    {
    std::string fileName = m_tempDirectory + Poco::Path::separator() + "NavigationTool" + convertIntToString(i) + ".tool";
    mitk::NavigationToolReader::Pointer myReader = mitk::NavigationToolReader::New();
    mitk::NavigationTool::Pointer readTool = myReader->DoRead(fileName);
    if (readTool.IsNull()) cont = false;
    else returnValue->AddTool(readTool);
    //delete file
    std::remove(fileName.c_str());
    }
  if(i==1)
    {
    //throw an exception here in case of not finding any tool
    m_ErrorMessage = "Error: did not find any tool. \n Is this a tool storage file?";
    mitkThrowException(mitk::IGTException)<<"Error: did not find any tool. \n Is this a tool storage file?";
    }
  return returnValue;
  }
Ejemplo n.º 2
0
void MainWindow::on_actionLoadData_triggered()
{
    int ret = QMessageBox::warning(this, "Загрузка новых данных",
                          "Внимание! Текущая сохраненная конфигурация будет потеряна. Продолжить?",
                                   QMessageBox::Ok | QMessageBox::Cancel);
    if(ret == QMessageBox::Ok)
    {
        QString archive = QFileDialog::getOpenFileName(this, "Открытие архива базы данных", "",
                          "DB Compressed Files (*.dbc)");

        if (!archive.isEmpty())
        {
            decompressFiles(archive);
            loadAll();
            configuratorWidget->refreshPlatformBox();
            configuratorWidget->clearOtherSettings();
            this->setWindowModified(false);
        }
        else
        {
            qDebug() << "архив не выбран";
            ui->statusBar->showMessage("архив не выбран");
        }
    }
}