mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-15 04:22:27 -04:00
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:
parent
fbb177dd66
commit
edd7bf7c31
6 changed files with 158 additions and 453 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
71
retroshare-gui/src/gui/statistics/dhtgraph.cpp
Normal file
71
retroshare-gui/src/gui/statistics/dhtgraph.cpp
Normal 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) ;
|
||||
}
|
||||
|
||||
|
51
retroshare-gui/src/gui/statistics/dhtgraph.h
Normal file
51
retroshare-gui/src/gui/statistics/dhtgraph.h
Normal 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;
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue