예제 #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;
}
예제 #2
0
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;
}
예제 #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;
}
예제 #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);
}
예제 #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;
}
예제 #6
0
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));
}
예제 #7
0
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;
}