mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -05:00
added widget for displaying info about identities. Not ready yet
This commit is contained in:
parent
6d665868e8
commit
bac8e0be70
51
retroshare-gui/src/gui/statistics/Histogram.cpp
Normal file
51
retroshare-gui/src/gui/statistics/Histogram.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
/*******************************************************************************
|
||||
* gui/statistics/Histogram.cpp *
|
||||
* *
|
||||
* Copyright (c) 2020 Retroshare Team <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "Histogram.h"
|
||||
|
||||
Histogram::Histogram(double start, double end, int bins)
|
||||
: mStart(start),mEnd(end),mBins(bins,0)
|
||||
{
|
||||
if(mEnd <= mStart)
|
||||
std::cerr << "Null histogram created! Please check your parameters" << std::endl;
|
||||
}
|
||||
|
||||
void Histogram::draw(QPainter *painter) const
|
||||
{
|
||||
}
|
||||
|
||||
void Histogram::insert(double val)
|
||||
{
|
||||
long int bin = (uint32_t)floor((val - mStart)/(mEnd - mStart) * mBins.size());
|
||||
|
||||
if(bin >= 0 && bin < mBins.size())
|
||||
++mBins[bin];
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& o,const Histogram& h)
|
||||
{
|
||||
o << "Histogram: [" << h.mStart << "..." << h.mEnd << "] " << h.mBins.size() << " bins." << std::endl;
|
||||
for(uint32_t i=0;i<h.mBins.size();++i)
|
||||
o << " " << h.mStart + i*(double)(h.mEnd - h.mStart)/(double)h.mBins.size() << " : " << h.mBins[i] << std::endl;
|
||||
|
||||
return o;
|
||||
}
|
43
retroshare-gui/src/gui/statistics/Histogram.h
Normal file
43
retroshare-gui/src/gui/statistics/Histogram.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*******************************************************************************
|
||||
* gui/statistics/Histogram.h *
|
||||
* *
|
||||
* Copyright (c) 2020 Retroshare Team <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
class QPainter;
|
||||
|
||||
class Histogram
|
||||
{
|
||||
public:
|
||||
Histogram(double start, double end, int bins);
|
||||
|
||||
void draw(QPainter *painter) const ;
|
||||
|
||||
void insert(double val);
|
||||
|
||||
private:
|
||||
double mStart;
|
||||
double mEnd;
|
||||
|
||||
std::vector<uint32_t> mBins;
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& o,const Histogram& h);
|
||||
};
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include <gui/statistics/TurtleRouterStatistics.h>
|
||||
#include <gui/statistics/GlobalRouterStatistics.h>
|
||||
#include <gui/statistics/GxsIdStatistics.h>
|
||||
#include <gui/statistics/GxsTransportStatistics.h>
|
||||
#include <gui/statistics/BwCtrlWindow.h>
|
||||
#include <gui/statistics/DhtWindow.h>
|
||||
@ -52,6 +53,7 @@
|
||||
|
||||
#define IMAGE_DHT ":/icons/DHT128.png"
|
||||
#define IMAGE_TURTLE ":/icons/turtle128.png"
|
||||
#define IMAGE_IDENTITIES ":/icons/avatar_128.png"
|
||||
#define IMAGE_BWGRAPH ":/icons/bandwidth128.png"
|
||||
#define IMAGE_GLOBALROUTER ":/icons/GRouter128.png"
|
||||
#define IMAGE_GXSTRANSPORT ":/icons/transport128.png"
|
||||
@ -143,6 +145,9 @@ void StatisticsWindow::initStackedPage()
|
||||
ui->stackPages->add(trsdlg = new TurtleRouterStatistics(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_TURTLE), tr("Turtle Router"), grp));
|
||||
|
||||
ui->stackPages->add(gxsiddlg = new GxsIdStatistics(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_IDENTITIES), tr("Identities"), grp));
|
||||
|
||||
ui->stackPages->add(grsdlg = new GlobalRouterStatistics(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_GLOBALROUTER), tr("Global Router"), grp));
|
||||
|
||||
@ -150,7 +155,7 @@ void StatisticsWindow::initStackedPage()
|
||||
action = createPageAction(QIcon(IMAGE_GXSTRANSPORT), tr("Gxs Transport"), grp));
|
||||
|
||||
ui->stackPages->add(rttdlg = new RttStatistics(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_RTT), tr("RTT Statistics"), grp));
|
||||
action = createPageAction(QIcon(IMAGE_RTT), tr("RTT Statistics"), grp));
|
||||
|
||||
bool showdht = true;
|
||||
RsPeerDetails detail;
|
||||
|
@ -38,6 +38,7 @@ class TurtleRouterStatistics;
|
||||
class GlobalRouterStatistics;
|
||||
class GxsTransportStatistics;
|
||||
class RttStatistics;
|
||||
class GxsIdStatistics;
|
||||
|
||||
class StatisticsWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
@ -57,6 +58,7 @@ public:
|
||||
BwCtrlWindow *bwdlg;
|
||||
TurtleRouterStatistics *trsdlg;
|
||||
RttStatistics *rttdlg;
|
||||
GxsIdStatistics *gxsiddlg;
|
||||
|
||||
|
||||
public slots:
|
||||
|
@ -437,7 +437,9 @@ HEADERS += rshare.h \
|
||||
gui/FileTransfer/BannedFilesDialog.h \
|
||||
gui/statistics/TurtleRouterDialog.h \
|
||||
gui/statistics/TurtleRouterStatistics.h \
|
||||
gui/statistics/GxsIdStatistics.h \
|
||||
gui/statistics/dhtgraph.h \
|
||||
gui/statistics/Histogram.h \
|
||||
gui/statistics/BandwidthGraphWindow.h \
|
||||
gui/statistics/turtlegraph.h \
|
||||
gui/statistics/BandwidthStatsWidget.h \
|
||||
@ -755,6 +757,7 @@ FORMS += gui/StartDialog.ui \
|
||||
gui/statistics/DhtWindow.ui \
|
||||
gui/statistics/TurtleRouterDialog.ui \
|
||||
gui/statistics/TurtleRouterStatistics.ui \
|
||||
gui/statistics/GxsIdStatistics.ui \
|
||||
gui/statistics/GlobalRouterStatistics.ui \
|
||||
gui/statistics/GxsTransportStatistics.ui \
|
||||
gui/statistics/StatisticsWindow.ui \
|
||||
@ -995,8 +998,10 @@ SOURCES += main.cpp \
|
||||
gui/statistics/BandwidthGraphWindow.cpp \
|
||||
gui/statistics/BandwidthStatsWidget.cpp \
|
||||
gui/statistics/DhtWindow.cpp \
|
||||
gui/statistics/Histogram.cpp \
|
||||
gui/statistics/TurtleRouterDialog.cpp \
|
||||
gui/statistics/TurtleRouterStatistics.cpp \
|
||||
gui/statistics/GxsIdStatistics.cpp \
|
||||
gui/statistics/GlobalRouterStatistics.cpp \
|
||||
gui/statistics/GxsTransportStatistics.cpp \
|
||||
gui/statistics/StatisticsWindow.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user