コード例 #1
0
UString Debugger::varInfo(const UString &ident)
{
  if (!eng)
    return UString();
  const List *chain = Context::current()->pScopeChain();
  ListIterator scope = chain->begin();
  while (scope != chain->end()) {
    if (scope->hasProperty(ident)) {
      KJSO val = scope->get(ident);
      return UString(val.imp()->typeInfo()->name) + ":" +
	val.toString().value();
    }
    scope++;
  }
  return UString();
}
コード例 #2
0
ファイル: graphwidget.cpp プロジェクト: nbombau/phyloloc
QPointF GraphWidget::drawTreeAux(QGraphicsScene* scene, GuiNode* node, float depth, unsigned int* leafNumber)
{
    ListIterator<GuiNode, Domain::Node>  it = node->getChildrenIterator<GuiNode>();
    list<QPointF> points;
    QPointF nodeCoord;
    QPointF ret;
    QPointF first;
    QPointF last;
    QGraphicsTextItem* text;
    Edge* edge;
    if (node->isLeaf())
    {
        nodeCoord.setX((*leafNumber) * 100);
        nodeCoord.setY((depth + node->getBranchLength()) * 100);
        ++(*leafNumber);
    }
    else
    {
        while (!it.end())
        {
            GuiNode* auxNode = it.get();
            ret = drawTreeAux(scene, auxNode, depth + node->getBranchLength(), leafNumber);
            points.push_front(ret);
            it.next();
        }
        last = points.front();
        first = points.back();
        nodeCoord.setX((first.x() + (last.x() - first.x()) / 2.0));
        nodeCoord.setY((depth + node->getBranchLength()) * 100);
    }

    node->setPos(nodeCoord.x() + 200, nodeCoord.y() + 200);

    if (node->isLeaf())
    {
        text = new QGraphicsTextItem(QString(node->getName().c_str()));
        text->setPos(nodeCoord.x() + 200 + 10, nodeCoord.y() + 200 + 20);
        text->rotate(90);
        node->setGraphicsName(text);
        scene->addItem(text);
    }

    it.restart();

    for (; !it.end(); it.next())
    {
        GuiNode* auxNode = it.get();
        edge = new Edge(node, auxNode);
        if (!node->isExpanded() || !node->isVisible())
        {
            edge->setVisible(false);
        }

        scene->addItem(edge);

        auxNode->addEdgeFrom(edge);
        node->addEdgeTo(edge);
    }
    scene->addItem(node);

    return nodeCoord;
}