void GraphGraphicsView::depthFirstSearch()
{
    clearArrows();
    clearWeights();
    drawAllEdges();
    drawWeights();

    bool hasCircle = false;
    int depthNo = 1;
    int endNo = 1;
    QList<int> prev;

    for (int u = 0; u < nodes.length(); ++u) {
        nodes[u]->setDepthNo(0);
        nodes[u]->setEndNo(0);
        prev.push_back(-1);
    }

    for (int u = 0; u < nodes.length(); ++u) {
        if (nodes[u]->getDepthNo() == 0) {
            DFS(u,depthNo, endNo, prev, hasCircle);
        }
    }
    if (hasCircle) {
        QMessageBox::warning(0, "Warning","This graph has a circle.");
    }
    else
    {
        QMessageBox::information(0, "Done", "Sum of all weights: ");
    }

    scene.update();
}
void GraphGraphicsView::reposition()
{
    if (nodes.length() == 0)
        return;
    qsrand(QTime::currentTime().msec());
    for (int i = 0; i < lines.length(); ++i) {
        scene.removeItem(lines[i]);
    }
    lines.clear();
    for (int i = 0; i < arrows.length(); ++i) {
        scene.removeItem(arrows[i]);
    }
    arrows.clear();
    for (int i = 0; i < weights.size(); ++i) {
        scene.removeItem(weights[i]);
    }
    weights.clear();

    for (int i = 0; i < nodes.length(); ++i)
    {
        NodeGraphicsItem* item = nodes[i];
        qreal powX;
        qreal powY = qPow(-1,i);
        if (qrand() % 2)
            powX = -1;
        else
            powX = 1;
        item->setPos(powX * (qrand() % 450), powY * (qrand() % 220));

        bool tooClose = false;
        for (int j = 0; j < nodes.length(); ++j)
        {
            if (i != j)
            {
                tooClose = tooClose || itemLevelTooClose(nodes[j], item);
                //qDebug() << "tooClose " << tooClose;
            }
        }
        while(tooClose)
        {
            tooClose = false;
            //qDebug() << "too close";
            item->setPos(powX * (qrand() % 450), powY * (qrand() % 220));
            for (int j = 0; j < nodes.length(); ++j) {
                if (i != j)
                {
                    tooClose = tooClose || itemLevelTooClose(nodes[j], item);
                }
            }
        }
    }

    drawAllEdges();
    drawWeights();
}
Esempio n. 3
0
void FramesWeightFrame::paintEvent(QPaintEvent *)
{
  QSize newSize(frames_count*FrameBarWidth, TrackHeight);
  if(newSize != size())
    resize(newSize);

  drawWeights();

  QPainter p(this);
  p.drawPixmap(0, 0, *offscreen);
}
Esempio n. 4
0
void BCIViz::draw( M3dView & view, const MDagPath & path, 
							 M3dView::DisplayStyle style,
							 M3dView::DisplayStatus status )
{ 	
	MObject thisNode = thisMObject();
	view.beginGL(); 
	
	glPushAttrib (GL_CURRENT_BIT);
	glDisable(GL_DEPTH_TEST);
	drawDriver();
	drawTargets();
	drawNeighbours();
	drawWeights();
	glEnable(GL_DEPTH_TEST);
	glPopAttrib();
	view.endGL();
}