created a generic class for graphs, and used it for DHT. The plan is to use the same class to draw all graphs.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7601 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-10-12 19:04:43 +00:00
parent fbb177dd66
commit edd7bf7c31
6 changed files with 158 additions and 453 deletions

View file

@ -73,7 +73,6 @@ void DhtWindow::updateDisplay()
updateNetPeers();
updateDhtPeers();
updateRelays();
getDHTStatus();
RsAutoUpdatePage::unlockAllEvents() ;
}
@ -667,39 +666,39 @@ void DhtWindow::updateDhtPeers()
void DhtWindow::getDHTStatus()
{
RsConfigNetStatus config;
rsConfig->getConfigNetStatus(config);
if (!(config.DHTActive))
{
// GRAY.
}
else
{
if (config.netDhtOk)
{
#define MIN_RS_NET_SIZE 10
// YELLOW or GREEN.
if (config.netDhtRsNetSize < MIN_RS_NET_SIZE)
{
updateGraph(config.netDhtRsNetSize,config.netDhtNetSize);
}
else
{
updateGraph(config.netDhtRsNetSize,config.netDhtNetSize);
}
}
else
{
// RED - some issue.
}
}
// RsConfigNetStatus config;
// rsConfig->getConfigNetStatus(config);
//
// if (!(config.DHTActive))
// {
// // GRAY.
// }
// else
// {
// if (config.netDhtOk)
// {
// #define MIN_RS_NET_SIZE 10
// // YELLOW or GREEN.
// if (config.netDhtRsNetSize < MIN_RS_NET_SIZE)
// {
// updateGraph(config.netDhtRsNetSize,config.netDhtNetSize);
// }
// else
// {
// updateGraph(config.netDhtRsNetSize,config.netDhtNetSize);
// }
// }
// else
// {
// // RED - some issue.
//
// }
// }
}
/** Adds new data to the graph. */
void DhtWindow::updateGraph(qreal rsDHT, qreal allDHT)
{
ui.frmGraph->addPoints(rsDHT, allDHT);
// ui.frmGraph->addPoints(rsDHT, allDHT);
}

View file

@ -0,0 +1,71 @@
/****************************************************************
* This file is distributed under the following license:
*
* Copyright (C) 2014 RetroShare Team
* Copyright (c) 2006-2007, crypton
* Copyright (c) 2006, Matt Edman, Justin Hipple
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QtGlobal>
#include <retroshare/rsdht.h>
#include <retroshare/rsconfig.h>
#include "dhtgraph.h"
class DHTGraphSource: public RSGraphSource
{
public:
virtual int n_values() const
{
return 2 ;
}
virtual void getValues(std::vector<float>& values) const
{
RsConfigNetStatus config;
rsConfig->getConfigNetStatus(config);
if (config.DHTActive && config.netDhtOk)
{
values.push_back(config.netDhtRsNetSize) ;
values.push_back(config.netDhtNetSize) ;
}
else
{
values.push_back(0.0f) ;
values.push_back(0.0f) ;
}
}
};
/** Default contructor */
DhtGraph::DhtGraph(QWidget *parent)
: RSGraphWidget(parent)
{
DHTGraphSource *src = new DHTGraphSource() ;
src->setCollectionTimeLimit(30*60*1000) ; // 30 mins
src->setCollectionTimePeriod(1000) ; // collect every second
src->start() ;
addSource(src) ;
setTimeScale(10.0f) ;
}

View file

@ -0,0 +1,51 @@
/****************************************************************
* This file is distributed under the following license:
*
* Copyright (C) 2014 RetroShare Team
* Copyright (c) 2006-2007, crypton
* Copyright (c) 2006, Matt Edman, Justin Hipple
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#pragma once
#include <QApplication>
#include <gui/common/RSGraphWidget.h>
#define HOR_SPC 2 /** Space between data points */
#define SCALE_WIDTH 75 /** Width of the scale */
#define MINUSER_SCALE 2000 /** 2000 users is the minimum scale */
#define SCROLL_STEP 4 /** Horizontal change on graph update */
#define BACK_COLOR Qt::white
#define SCALE_COLOR Qt::black
#define GRID_COLOR Qt::black
#define RSDHT_COLOR Qt::magenta
#define ALLDHT_COLOR Qt::yellow
#define FONT_SIZE 11
class DhtGraph : public RSGraphWidget
{
public:
DhtGraph(QWidget *parent = 0);
/** Show the respective lines and counters. */
bool _showRSDHT;
bool _showALLDHT;
};