Exemple #1
0
Swc_Tree_Node *ZSwcNodeObjsModel::getSwcTreeNode(const QModelIndex &index) const
{
  if (!index.isValid())
    return NULL;

  ZObjsItem *item = static_cast<ZObjsItem*>(index.internalPointer());

  if (item->parent() && item->parent()->parent() == m_rootItem)
    return static_cast<Swc_Tree_Node*>(item->getActuralData());
  else
    return NULL;
}
ZPunctum *ZPunctaObjsModel::getPunctum(const QModelIndex &index) const
{
  if (!index.isValid())
    return NULL;

  ZObjsItem *item = static_cast<ZObjsItem*>(index.internalPointer());

  if (item->parent() && item->parent()->parent() == m_rootItem)
    return static_cast<ZPunctum*>(item->getObj());
  else
    return NULL;
}
Exemple #3
0
std::set<Swc_Tree_Node*> ZSwcNodeObjsModel::getSwcTreeNodeSet(
    const QModelIndex &index) const
{
  std::set<Swc_Tree_Node*> nodeSet;
  if (index.isValid()) {
    ZObjsItem *item = static_cast<ZObjsItem*>(index.internalPointer());
    if (item->parent() == m_rootItem) {
      int childNumber = item->childCount();
      for (int i = 0; i < childNumber; ++i) {
        ZObjsItem *childItem = item->child(i);
        Swc_Tree_Node *tn = static_cast<Swc_Tree_Node*>(childItem->getActuralData());
        if (tn != NULL) {
          nodeSet.insert(tn);
        }
      }
    } else {
      Swc_Tree_Node *tn = getSwcTreeNode(index);
      if (tn != NULL) {
        nodeSet.insert(tn);
      }
    }
  }

  return nodeSet;
}
Exemple #4
0
QModelIndex ZObjsModel::parent(const QModelIndex &index) const
{
  if (!index.isValid())
    return QModelIndex();

  ZObjsItem *childItem = static_cast<ZObjsItem*>(index.internalPointer());
  ZObjsItem *parentItem = childItem->parent();

  if (parentItem == m_rootItem)
    return QModelIndex();

  return createIndex(parentItem->row(), 0, parentItem);
}
Exemple #5
0
ZStroke2d* ZStroke2dObjsModel::getStroke2d(const QModelIndex &index) const
{
  ZStroke2d *stroke = NULL;
  if (index.isValid()) {
    ZObjsItem *item = static_cast<ZObjsItem*>(index.internalPointer());

    if (item->parent() == m_rootItem) {
      stroke = ZStackObject::CastVoidPointer<ZStroke2d>(item->getActuralData());
    }
  }

  return stroke;
}
void ZPunctaObjsModel::updateData(ZPunctum *punctum)
{
  QModelIndex index = getIndex(punctum);
  if (!index.isValid())
    return;
  ZObjsItem *item = static_cast<ZObjsItem*>(index.internalPointer());
  QList<QVariant> &data = item->getItemData();
  ZPunctum *p = punctum;
  QList<QVariant>::iterator beginit = data.begin();
  beginit++;
  data.erase(beginit, data.end());
  data << 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() << p->source();
  emit dataChanged(index, getIndex(punctum, item->parent()->columnCount()-1));
}
const std::vector<ZPunctum *> *ZPunctaObjsModel::getPuncta(const QModelIndex &index) const
{
  if (!index.isValid())
    return NULL;

  ZObjsItem *item = static_cast<ZObjsItem*>(index.internalPointer());

  if (item->parent() == m_rootItem) {
    std::map<ZObjsItem*, int>::const_iterator it;
    it = m_punctaSourceParentToRow.find(item);
    if (it == m_punctaSourceParentToRow.end()) {
      LERROR() << "Wrong Index";
    } else
      return &(m_punctaSeparatedByFile[it->second]);
  }

  return NULL;
}