Пример #1
0
void ZDvidDialog::setServer(int index)
{
  ZDvidTarget dvidTarget = m_dvidRepo[index];

  ui->addressLineEdit->setText(dvidTarget.getAddress().c_str());
  ui->portSpinBox->setValue(dvidTarget.getPort());
  ui->uuidLineEdit->setText(dvidTarget.getUuid().c_str());
  ui->infoLabel->setText(dvidTarget.getComment().c_str());
  ui->bodyLineEdit->setText(dvidTarget.getBodyLabelName().c_str());
  ui->grayScalelineEdit->setText(dvidTarget.getGrayScaleName().c_str());
  ui->labelBlockLineEdit->setText(dvidTarget.getLabelBlockName().c_str());
  ui->tileLineEdit->setText(dvidTarget.getMultiscale2dName().c_str());

  ui->addressLineEdit->setReadOnly(index > 0);
  ui->portSpinBox->setReadOnly(index > 0);
  ui->uuidLineEdit->setReadOnly(index > 0);
//  ui->bodyLineEdit->setReadOnly(index > 0);
}
int ZSplitTaskUploadCommand::run(
    const std::vector<std::string> &input, const std::string &/*output*/,
    const ZJsonObject &config)
{
  ZJsonObject dvidJson(config.value("dvid"));
  if (dvidJson.isEmpty()) {
    std::cerr << "No dvid server specified. Abort." << std::endl;
    return 1;
  }

  if (input.empty()) {
    std::cerr << "No input file specified. Abort." << std::endl;
    return 1;
  }

  ZDvidTarget target;
  target.loadJsonObject(dvidJson);
  if (!target.isValid()) {
    std::cerr << "No valide dvid server specified. Abort." << std::endl;
    return 1;
  }

  if (target.getBodyLabelName().empty()) {
    std::cerr << "No sparsevol data specified. Abort." << std::endl;
    return 1;
  }

  ZJsonObject docJson;
  docJson.load(input.front());

  ZJsonArray rootObj(docJson.value("meshReview"));
  if (rootObj.isEmpty()) {
    std::cerr << "Unrecognized input format. Abort." << std::endl;
    return 1;
  }

  ZDvidWriter *writer = ZGlobal::GetInstance().getDvidWriterFromUrl(
        GET_FLYEM_CONFIG.getTaskServer());
  if (writer == NULL) {
    std::cerr << "Unable to Initialize the task server: "
              << GET_FLYEM_CONFIG.getTaskServer() << std::endl;
    std::cerr << "Abort" << std::endl;
    return 1;
  } else {
    std::cout << "Task server: " << writer->getDvidTarget().getSourceString()
              << std::endl;
  }

  ZDvidUrl dvidUrl(target);

  std::cout << std::endl;
  std::cout << "Uploading tasks: " << std::endl << std::endl;
  int count = 0;
  for (size_t i = 0; i < rootObj.size(); ++i) {
    ZJsonObject obj(rootObj.value(i));
    ZJsonArray markerJson(obj.value("pointMarkers"));
#ifdef _DEBUG_2
      std::cout << "Here";
#endif
    if (!markerJson.isEmpty()) {
      uint64_t bodyId =
          ZString(obj.value("file").toString()).firstUint64();

      if (bodyId > 0) {
        ZJsonObject taskJson;
        ZFlyEmMisc::SetSplitTaskSignalUrl(taskJson, bodyId, target);
        for (size_t i = 0; i < markerJson.size(); ++i) {
          ZJsonObject markerObj(markerJson.value(i));
          ZStroke2d stroke =
              ZFlyEmMisc::SyGlassSeedToStroke(markerObj);
          ZFlyEmMisc::AddSplitTaskSeed(taskJson, stroke);
        }

        std::string location = writer->writeServiceTask("split", taskJson);
        ZJsonObject entryJson;
        entryJson.setEntry(neutube::json::REF_KEY, location);
        QString taskKey = dvidUrl.getSplitTaskKey(bodyId).c_str();
        writer->writeSplitTask(taskKey, taskJson);
        std::cout << "*    Task for " << bodyId << " is saved @ "
                  << taskKey.toStdString() << "->" << location << std::endl;
        ++count;
      }
    }
  }
  std::cout << std::endl;
  std::cout << count << " tasks uploaded." << std::endl;

  return 0;
}