From bac8e0be70e062ab385ea3d56475758a408e5fc0 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 8 Jul 2020 23:35:44 +0200 Subject: [PATCH] added widget for displaying info about identities. Not ready yet --- .../src/gui/statistics/Histogram.cpp | 51 +++++++++++++++++++ retroshare-gui/src/gui/statistics/Histogram.h | 43 ++++++++++++++++ .../src/gui/statistics/StatisticsWindow.cpp | 7 ++- .../src/gui/statistics/StatisticsWindow.h | 2 + retroshare-gui/src/retroshare-gui.pro | 5 ++ 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 retroshare-gui/src/gui/statistics/Histogram.cpp create mode 100644 retroshare-gui/src/gui/statistics/Histogram.h diff --git a/retroshare-gui/src/gui/statistics/Histogram.cpp b/retroshare-gui/src/gui/statistics/Histogram.cpp new file mode 100644 index 000000000..6c03e7aaa --- /dev/null +++ b/retroshare-gui/src/gui/statistics/Histogram.cpp @@ -0,0 +1,51 @@ +/******************************************************************************* + * gui/statistics/Histogram.cpp * + * * + * Copyright (c) 2020 Retroshare Team * + * * + * 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 . * + * * + *******************************************************************************/ + +#include + +#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 * + * * + * 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 . * + * * + *******************************************************************************/ + +#include +#include + +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 mBins; + + friend std::ostream& operator<<(std::ostream& o,const Histogram& h); +}; + diff --git a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp index bbda5101a..50c947822 100644 --- a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp +++ b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -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; diff --git a/retroshare-gui/src/gui/statistics/StatisticsWindow.h b/retroshare-gui/src/gui/statistics/StatisticsWindow.h index db2d75939..2450812d7 100644 --- a/retroshare-gui/src/gui/statistics/StatisticsWindow.h +++ b/retroshare-gui/src/gui/statistics/StatisticsWindow.h @@ -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: diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index bf76f36a2..b60edbce6 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -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 \