Exemple #1
0
void ZSwcNodeObjsModel::setupModelData(ZObjsItem *parent)
{
  QList<QVariant> data;

  m_typeToRow.clear();
  m_swcTreeNodeToRow.clear();
  m_swcTreeNodeToType.clear();

  m_typeToRow[SwcTreeNode::TERMINAL] = 0;
  m_typeToRow[SwcTreeNode::BRANCH_POINT] = 1;

  data.clear();
  data << "Termini" << "id" << "type" << "radius" << "x" << "y" << "z"
       << "label";
  ZObjsItem *terminalItem = new ZObjsItem(data, NULL, parent);
  terminalItem->setCheckState(Qt::Checked);
  parent->appendChild(terminalItem);

  data.clear();
  data << "Branch Points" << "id" << "type" << "radius" << "x" << "y" << "z"
       << "label";
  ZObjsItem *branchPointItem = new ZObjsItem(data, NULL, parent);
  branchPointItem->setCheckState(Qt::Checked);
  parent->appendChild(branchPointItem);

  int terminalRow = 0;
  int branchPointRow = 0;

  QList<ZSwcTree*> swcList = m_doc->getSwcList();
  for (int i=0; i<swcList.size(); i++) {
    data.clear();
    ZSwcTree *swcTree = swcList.at(i);

    //ZObjsItem *nodeParent = new ZObjsItem(data, swcTree, parent);
    //nodeParent->setCheckState(swcTree->isVisible() ? Qt::Checked : Qt::Unchecked);
    //nodeParent->setToolTip(QString("source: %1").arg(QString::fromStdString(swcTree->source())));
    //parent->appendChild(nodeParent);

    swcTree->updateIterator(SWC_TREE_ITERATOR_DEPTH_FIRST);   //depth first
    for (Swc_Tree_Node *tn = swcTree->begin(); tn != swcTree->end(); tn = swcTree->next()) {
      if (!SwcTreeNode::isVirtual(tn)) {
        data.clear();
        data << "" << tn->node.id << tn->node.type << tn->node.d << tn->node.x
             << tn->node.y << tn->node.z  << tn->node.label << "";
        if (SwcTreeNode::isBranchPoint(tn)) {
          m_swcTreeNodeToType[tn] = SwcTreeNode::BRANCH_POINT;
          m_swcTreeNodeToRow[tn] = branchPointRow++;
          ZObjsItem *node = new ZObjsItem(data, tn, branchPointItem);
          branchPointItem->appendChild(node);
        } else if (SwcTreeNode::isRoot(tn) || SwcTreeNode::isLeaf(tn)) {
          m_swcTreeNodeToType[tn] = SwcTreeNode::TERMINAL;
          m_swcTreeNodeToRow[tn] = terminalRow++;
          ZObjsItem *node = new ZObjsItem(data, tn, terminalItem);
          terminalItem->appendChild(node);
        }
      }
    }
  }
}
void ZPunctaObjsModel::setupModelData(ZObjsItem *parent)
{
  QList<QVariant> data;

  m_punctaSourceToParent.clear();
  m_punctaSourceToCount.clear();
  m_punctaToRow.clear();
  m_punctaSourceParentToRow.clear();
  m_punctaSeparatedByFile.clear();
  int sourceParentRow = 0;
  int numDigit = numDigits(m_doc->punctaList()->size()+1);
  for (int i=0; i<m_doc->punctaList()->size(); i++) {
    data.clear();
    ZPunctum *p = m_doc->punctaList()->at(i);
    QFileInfo sourceInfo(p->source());
    if (m_punctaSourceToParent.find(p->source()) != m_punctaSourceToParent.end()) {
      ZObjsItem *sourceParent = m_punctaSourceToParent[p->source()];
      data << QString("puncta %1").arg(m_punctaSourceToCount[p->source()] + 1, numDigit, 10, QLatin1Char('0')) << p->score() << p->name() << p->comment() << p->x() << p->y() <<
              p->z() << p->sDevOfIntensity() << p->volSize() << p->mass() << p->radius() <<
              p->meanIntensity() << p->maxIntensity() << p->property1() << p->property2() <<
              p->property3() << p->color() << sourceInfo.fileName();
      m_punctaToRow[p] = m_punctaSourceToCount[p->source()];
      m_punctaSourceToCount[p->source()]++;
      ZObjsItem *punctum = new ZObjsItem(data, p, sourceParent);
      punctum->setCheckState(p->isVisible() ? Qt::Checked : Qt::Unchecked);
      punctum->setToolTip(QString("puncta from: %1").arg(p->source()));
      sourceParent->appendChild(punctum);
      m_punctaSeparatedByFile[m_punctaSourceParentToRow[sourceParent]].push_back(m_doc->punctaList()->at(i));
    } else {
      data << sourceInfo.fileName() << "score" << "name" << "comment" << "x" << "y" << "z" << "sDev" <<
              "volSize" << "mass" << "radius" << "meanIntensity" << "maxIntensity" <<
              "property1" << "property2" << "property3" << "color" << "source";
      m_punctaSeparatedByFile.push_back(std::vector<ZPunctum*>());
      ZObjsItem *sourceParent = new ZObjsItem(data, NULL, parent);
      sourceParent->setToolTip(QString("puncta source: %1").arg(p->source()));
      m_punctaSourceToParent[p->source()] = sourceParent;
      m_punctaSourceToCount[p->source()] = 0;
      parent->appendChild(sourceParent);
      m_punctaSourceParentToRow[sourceParent] = sourceParentRow++;

      data.clear();
      data << QString("puncta %1").arg(m_punctaSourceToCount[p->source()] + 1, numDigit, 10, QLatin1Char('0')) << p->score() << p->name() << p->comment() << p->x() << p->y() <<
              p->z() << p->sDevOfIntensity() << p->volSize() << p->mass() << p->radius() <<
              p->meanIntensity() << p->maxIntensity() << p->property1() << p->property2() <<
              p->property3() << p->color() << sourceInfo.fileName();
      m_punctaToRow[p] = m_punctaSourceToCount[p->source()];
      m_punctaSourceToCount[p->source()]++;
      ZObjsItem *punctum = new ZObjsItem(data, p, sourceParent);
      punctum->setCheckState(p->isVisible() ? Qt::Checked : Qt::Unchecked);
      punctum->setToolTip(QString("puncta from: %1").arg(p->source()));
      sourceParent->appendChild(punctum);
      m_punctaSeparatedByFile[m_punctaSourceParentToRow[sourceParent]].push_back(m_doc->punctaList()->at(i));
    }
  }
}