void
RoutingStatsScene::addToProxyWidgetsMap(uint32_t nodeId, QString title, QString content)
{

    if(m_nodeIdProxyWidgets.find(nodeId) == m_nodeIdProxyWidgets.end())
    {
        TextBubble * tb = new TextBubble (title, content);
        QFont f(tb->font());
        f.setPointSizeF(StatsMode::getInstance()->getCurrentFontSize());
        tb->setFont(f);
        QGraphicsProxyWidget * pw = addWidget(tb);


        QFontMetrics fm(f);
        pw->setMaximumHeight(fm.height() * tb->text().count("\n"));
        pw->adjustSize();
        showInfoWidget(false);
        m_nodeIdProxyWidgets[nodeId] = pw;
        qreal newX = m_lastX + pw->widget()->width();
        if(newX >= sceneRect().right())
        {
            m_lastX = 0;
            m_lastY += pw->widget()->height() + INTERSTATS_SPACE;
        }
        pw->setPos(m_lastX, m_lastY);

        m_lastX = pw->pos().x() + pw->widget()->width() + INTERSTATS_SPACE;
        m_lastY = pw->pos().y();
        m_bottomY = m_lastY + pw->widget()->height();
        //qDebug(QString("Last X" + QString::number(m_lastX) + " w:" + QString::number(pw->widget()->width())));
        adjustRect();
        return;
    }

}
void
RoutingStatsScene::updateContent(uint32_t nodeId, QGraphicsProxyWidget *pw)
{
    //qDebug ("Updating for :" + QString::number(nodeId));
    TimeValue <QString> & v = m_nodeIdTimeValues[nodeId];
    v.setCurrentTime(StatsMode::getInstance()->getCurrentTime());
    TextBubble * tb = ((TextBubble *)pw->widget());
    QFont f(tb->font());
    f.setPointSizeF(StatsMode::getInstance()->getCurrentFontSize());
    tb->setFont(f);
    QFontMetrics fm(f);
    pw->setMaximumHeight(fm.height() * tb->text().count("\n"));
    pw->adjustSize();
    tb->setText(v.getCurrent());
}
void
FlowMonStatsScene::align()
{
    m_lastX = 0;
    m_lastY = 0;
    m_bottomY = 0;
    qreal currentMaxHeight = 0;

    for(FlowIdProxyWidgetMap_t::const_iterator i = m_flowIdProxyWidgets.begin();
        i != m_flowIdProxyWidgets.end();
        ++i)
    {
        QGraphicsProxyWidget * pw = i->second;
        bool flowIsActive = StatsMode::getInstance()->isNodeActive(i->first);
        pw->setVisible(flowIsActive);
        if(flowIsActive)
        {
            TextBubble * tb = (TextBubble *) pw->widget();
            QFont f(tb->font());
            f.setPointSizeF(StatsMode::getInstance()->getCurrentFontSize());
            tb->setFont(f);

            QFontMetrics fm(f);
            pw->setMaximumHeight(fm.height() * tb->text().count("\n"));
            pw->adjustSize();

            qreal newX = m_lastX + pw->size().width();
            currentMaxHeight = qMax(currentMaxHeight, pw->size().height());
            if(newX >= sceneRect().right())
            {
                m_lastX = 0;
                m_lastY += currentMaxHeight + INTERSTATS_SPACE;
                currentMaxHeight = 0;
            }
            pw->setPos(m_lastX, m_lastY);
            m_lastX = pw->pos().x() + pw->size().width() + INTERSTATS_SPACE;
            m_lastY = pw->pos().y();
            m_bottomY = m_lastY + currentMaxHeight;
            adjustRect();
        }
    }
    if(m_flowProbeWidget)
    {
            QGraphicsProxyWidget * pw = m_flowProbeWidget;
            TextBubble * tb = (TextBubble *) pw->widget();
            QFont f(tb->font());
            f.setPointSizeF(StatsMode::getInstance()->getCurrentFontSize());
            tb->setFont(f);

            QFontMetrics fm(f);
            pw->setMaximumHeight(fm.height() * tb->text().count("\n"));
            pw->adjustSize();

            qreal newX = m_lastX + pw->size().width();
            currentMaxHeight = qMax(currentMaxHeight, pw->size().height());
            if(newX >= sceneRect().right())
            {
                m_lastX = 0;
                m_lastY += currentMaxHeight + INTERSTATS_SPACE;
                currentMaxHeight = 0;
            }
            pw->setPos(m_lastX, m_lastY);
            m_lastX = pw->pos().x() + pw->size().width() + INTERSTATS_SPACE;
            m_lastY = pw->pos().y();
            m_bottomY = m_lastY + currentMaxHeight;
            adjustRect();

    }

}
Пример #4
0
void
InterfaceStatsScene::add (uint32_t nodeId, QString pointADescription, uint32_t otherNodeId, QString pointBDescription, QString linkDescription)
{
  if (!StatsMode::getInstance ()->isNodeActive (nodeId))
    {
      return;
    }
  if (!pointADescription.contains ("~"))
    {
      return;
    }
  showInfoWidget (false);
  QStringList parts = pointADescription.split ('~');
  //qDebug (pointADescription);
  QString IP = parts.at (0);
  //qDebug (IP);
  QString MAC = parts.at (1);
  QString otherIP = "";
  QString otherMAC = "";

  if (pointBDescription != "")
    {
      parts = pointBDescription.split ('~');
      otherIP = parts.at (0);
      otherMAC = parts.at (1);
    }

  QString title = "Node:" + QString::number (nodeId);
  QString content = "IP:" + IP ;
  content += "\nMAC:" + MAC ;

  if (pointBDescription != "")
    {
      content += "\nOther Node:" + QString::number (otherNodeId) ;
      content += "\nOther IP:" + otherIP;
      content += "\nOther MAC:" + otherMAC;
      content += "\nInfo:" + linkDescription;
    }
  TextBubble * tb = new TextBubble (title, content);
  QGraphicsProxyWidget * pw = addWidget (tb);
  QFont f (tb->font ());
  f.setPointSizeF (StatsMode::getInstance ()->getCurrentFontSize ());
  tb->setFont (f);
  QFontMetrics fm (f);
  pw->setMaximumHeight (fm.height () * tb->text ().count ("\n"));

  addToProxyWidgetsMap (nodeId, pw);
  qreal newX = m_lastX + pw->widget ()->width ();
  m_currentMaxHeight = qMax (m_currentMaxHeight, pw->size ().height ());
  if (newX >= sceneRect ().right ())
    {
      m_lastX = 0;
      m_lastY += m_currentMaxHeight + INTERSTATS_SPACE;
      m_currentMaxHeight = 0;
    }
  pw->setPos (m_lastX, m_lastY);
  m_lastX = pw->pos ().x () + pw->widget ()->width () + INTERSTATS_SPACE;
  m_lastY = pw->pos ().y ();
  m_bottomY = m_lastY + m_currentMaxHeight;
  //qDebug (QString ("Last X" + QString::number (m_lastX) + " w:" + QString::number (pw->widget ()->width ())));
  adjustRect ();

}