mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
PieCharts return, plus Memory Hog option in View Menu (defaults on)
This commit is contained in:
parent
d422a46802
commit
ee6bc766f4
@ -1,22 +1,41 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "gpiechart.h"
|
#include "gpiechart.h"
|
||||||
|
|
||||||
gPieChart::gPieChart(MachineCode code,QColor col)
|
gPieChart::gPieChart(QColor outline_color)
|
||||||
:gLayer(code)
|
:gLayer(MC_UNKNOWN),m_outline_color(outline_color)
|
||||||
{
|
{
|
||||||
color.clear();
|
|
||||||
color.push_back(col);
|
|
||||||
}
|
}
|
||||||
gPieChart::~gPieChart()
|
gPieChart::~gPieChart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
void gPieChart::AddSlice(MachineCode code,QColor color,QString name)
|
||||||
|
{
|
||||||
|
m_counts[code]=code;
|
||||||
|
m_colors[code]=color;
|
||||||
|
m_names[code]=name;
|
||||||
|
m_total=0;
|
||||||
|
}
|
||||||
|
void gPieChart::SetDay(Day *d)
|
||||||
|
{
|
||||||
|
gLayer::SetDay(d);
|
||||||
|
m_total=0;
|
||||||
|
if (!m_day) return;
|
||||||
|
for (map<MachineCode,int>::iterator c=m_counts.begin();c!=m_counts.end();c++) {
|
||||||
|
c->second=0;
|
||||||
|
for (vector<Session *>::iterator s=m_day->begin();s!=m_day->end();s++) {
|
||||||
|
int cnt=(*s)->count(c->first);
|
||||||
|
c->second+=cnt;
|
||||||
|
m_total+=cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void gPieChart::Plot(gGraphWindow & w,float scrx,float scry)
|
void gPieChart::Plot(gGraphWindow & w,float scrx,float scry)
|
||||||
{
|
{
|
||||||
if (!m_visible) return;
|
if (!m_visible) return;
|
||||||
/*if (!data) return;
|
if (!m_day) return;
|
||||||
if (!data->IsReady()) return;
|
if (!m_total) return;
|
||||||
|
|
||||||
int start_px=w.GetLeftMargin();
|
int start_px=w.GetLeftMargin();
|
||||||
int start_py=w.GetBottomMargin();
|
int start_py=w.GetBottomMargin();
|
||||||
int width=scrx-(w.GetLeftMargin()+w.GetRightMargin());
|
int width=scrx-(w.GetLeftMargin()+w.GetRightMargin());
|
||||||
@ -26,29 +45,19 @@ void gPieChart::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
diameter-=8;
|
diameter-=8;
|
||||||
float radius=diameter/2.0;
|
float radius=diameter/2.0;
|
||||||
|
|
||||||
double total=0;
|
|
||||||
for (int i=0;i<data->np[0];i++)
|
|
||||||
total+=data->point[0][i].y();
|
|
||||||
|
|
||||||
|
|
||||||
double j=0.0;
|
double j=0.0;
|
||||||
double sum=0.0;
|
double sum=0.0;
|
||||||
double step=1.0/45.0;
|
double step=1.0/45.0;
|
||||||
float px,py;
|
float px,py;
|
||||||
//glEnable(GL_TEXTURE_2D);
|
|
||||||
//glEnable(GL_DEPTH_TEST);
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
//glEnable(GL_POLYGON_SMOOTH);
|
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
glLineWidth(1.5);
|
glLineWidth(1.5);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
//glBlendFunc( GL_SRC_ALPHA_SATURATE, GL_ONE );
|
|
||||||
//glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
|
||||||
|
|
||||||
for (int i=0;i<data->np[0];i++) {
|
for (map<MachineCode,int>::iterator m=m_counts.begin();m!=m_counts.end();m++) {
|
||||||
j=(data->point[0][i].y()/total); // ratio of this pie slice
|
if (!m->second) continue;
|
||||||
QColor col1=color[i % color.size()];
|
j=float(m->second)/float(m_total); // ratio of this pie slice
|
||||||
w.qglColor(col1);
|
w.qglColor(m_colors[m->first]);
|
||||||
glPolygonMode(GL_BACK,GL_FILL);
|
glPolygonMode(GL_BACK,GL_FILL);
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
glVertex2f(start_px+radius+4, start_py+radius+4);
|
glVertex2f(start_px+radius+4, start_py+radius+4);
|
||||||
@ -65,7 +74,7 @@ void gPieChart::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glPolygonMode(GL_BACK,GL_LINE);
|
glPolygonMode(GL_BACK,GL_LINE);
|
||||||
w.qglColor(Qt::black);
|
w.qglColor(m_outline_color);
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
glVertex2f(start_px+radius+4, start_py+radius+4);
|
glVertex2f(start_px+radius+4, start_py+radius+4);
|
||||||
for (q=sum;q<sum+j;q+=step) {
|
for (q=sum;q<sum+j;q+=step) {
|
||||||
@ -79,11 +88,7 @@ void gPieChart::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
glVertex2f(px,py);
|
glVertex2f(px,py);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
sum=q;
|
sum=q;
|
||||||
}
|
}
|
||||||
glDisable(GL_POLYGON_SMOOTH);
|
glDisable(GL_BLEND);
|
||||||
glDisable(GL_BLEND); */
|
|
||||||
//glDisable(GL_DEPTH_TEST);
|
|
||||||
//glDisable(GL_TEXTURE_2D);
|
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,20 @@
|
|||||||
class gPieChart : public gLayer
|
class gPieChart : public gLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
gPieChart(MachineCode code=MC_UNKNOWN,QColor col=Qt::black);
|
gPieChart(QColor color=Qt::black);
|
||||||
virtual ~gPieChart();
|
virtual ~gPieChart();
|
||||||
|
|
||||||
virtual void Plot(gGraphWindow & w,float scrx,float scry);
|
virtual void Plot(gGraphWindow & w,float scrx,float scry);
|
||||||
void AddName(QString name) { m_names.push_back(name); }
|
virtual void SetDay(Day *d);
|
||||||
|
|
||||||
|
void AddSlice(MachineCode code,QColor col,QString name="");
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
vector<QString> m_names;
|
map <MachineCode,QString> m_names;
|
||||||
|
map <MachineCode,int> m_counts;
|
||||||
|
map <MachineCode,QColor> m_colors;
|
||||||
|
int m_total;
|
||||||
|
QColor m_outline_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GPIECHART_H
|
#endif // GPIECHART_H
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
License: GPL
|
License: GPL
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#include "graphdata.h"
|
//#include "graphdata.h"
|
||||||
/*
|
/*
|
||||||
gGraphData::gGraphData(int mp,gDataType t)
|
gGraphData::gGraphData(int mp,gDataType t)
|
||||||
:vc(0),type(t),max_points(mp)
|
:vc(0),type(t),max_points(mp)
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
License: GPL
|
License: GPL
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#include <cmath>
|
//#include <cmath>
|
||||||
#include <QDebug>
|
//#include <QDebug>
|
||||||
#include "graphdata_custom.h"
|
//#include "graphdata_custom.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
WaveData::WaveData(MachineCode _code, int _size)
|
WaveData::WaveData(MachineCode _code, int _size)
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
vector<QColor> color;
|
vector<QColor> color;
|
||||||
|
|
||||||
virtual void SetDay(Day * d);
|
virtual void SetDay(Day * d);
|
||||||
void SetCode(MachineCode c) { m_code=c; }
|
virtual void SetCode(MachineCode c) { m_code=c; }
|
||||||
virtual qint64 Minx() { if (m_day) return m_day->first(); return m_minx; }
|
virtual qint64 Minx() { if (m_day) return m_day->first(); return m_minx; }
|
||||||
virtual qint64 Maxx() { if (m_day) return m_day->last(); return m_maxx; }
|
virtual qint64 Maxx() { if (m_day) return m_day->last(); return m_maxx; }
|
||||||
virtual EventDataType Miny() { return m_miny; }
|
virtual EventDataType Miny() { return m_miny; }
|
||||||
|
37
daily.cpp
37
daily.cpp
@ -201,30 +201,23 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) :
|
|||||||
//TAP_IAP->AddLayer(new gCandleStick(tap_iap));
|
//TAP_IAP->AddLayer(new gCandleStick(tap_iap));
|
||||||
|
|
||||||
|
|
||||||
//G_AHI->SetMargins(0,0,0,0);
|
G_AHI->SetMargins(0,0,0,0);
|
||||||
//AddCPAPData(g_ahi=new AHIData());
|
//AddCPAPData(g_ahi=new AHIData());
|
||||||
//gCandleStick *l=new gCandleStick(g_ahi);
|
//gCandleStick *l=new gCandleStick(g_ahi);
|
||||||
/*gPieChart *l=new gPieChart(g_ahi);
|
gPieChart *l=new gPieChart(Qt::black);
|
||||||
l->AddName(tr("H"));
|
l->AddSlice(CPAP_Hypopnea,QColor(0x40,0x40,0xff,0xff),"H");
|
||||||
l->AddName(tr("OA"));
|
l->AddSlice(CPAP_Obstructive,QColor(0x40,0xaf,0xbf,0xff),"OA");
|
||||||
l->AddName(tr("CA"));
|
l->AddSlice(CPAP_ClearAirway,QColor(0xb2,0x54,0xcd,0xff),"CA");
|
||||||
l->AddName(tr("RE"));
|
l->AddSlice(CPAP_RERA,QColor(0xff,0xff,0x80,0xff),"RE");
|
||||||
l->AddName(tr("FL"));
|
l->AddSlice(CPAP_FlowLimit,QColor(0x40,0x40,0x40,0xff),"FL");
|
||||||
// l->AddName(tr("CSR"));
|
|
||||||
l->color.clear();
|
|
||||||
l->color.push_back(QColor(0x40,0x40,0xff,0xff)); // blue
|
|
||||||
l->color.push_back(QColor(0x40,0xaf,0xbf,0xff)); // aqua
|
|
||||||
l->color.push_back(QColor(0xb2,0x54,0xcd,0xff)); // purple
|
|
||||||
l->color.push_back(QColor(0xff,0xff,0x80,0xff)); // yellow
|
|
||||||
l->color.push_back(QColor(0x40,0x40,0x40,0xff)); // dark grey
|
|
||||||
//l->color.push_back(QColor(0x60,0xff,0x60,0xff)); // green
|
//l->color.push_back(QColor(0x60,0xff,0x60,0xff)); // green
|
||||||
G_AHI->AddLayer(l);
|
G_AHI->AddLayer(AddCPAP(l));
|
||||||
G_AHI->SetGradientBackground(false);
|
G_AHI->SetGradientBackground(false);
|
||||||
|
|
||||||
//G_AHI->setMaximumSize(2000,30);
|
//G_AHI->setMaximumSize(2000,30);
|
||||||
//TAP->setMaximumSize(2000,30);
|
//TAP->setMaximumSize(2000,30);
|
||||||
G_AHI->hide();
|
G_AHI->hide();
|
||||||
TAP->hide();
|
/*TAP->hide();
|
||||||
TAP_IAP->hide();
|
TAP_IAP->hide();
|
||||||
TAP_EAP->hide(); */
|
TAP_EAP->hide(); */
|
||||||
|
|
||||||
@ -417,9 +410,11 @@ void Daily::Load(QDate date)
|
|||||||
Day *oxi=profile->GetDay(date,MT_OXIMETER);
|
Day *oxi=profile->GetDay(date,MT_OXIMETER);
|
||||||
// Day *sleepstage=profile->GetDay(date,MT_SLEEPSTAGE);
|
// Day *sleepstage=profile->GetDay(date,MT_SLEEPSTAGE);
|
||||||
|
|
||||||
if (lastcpapday && (lastcpapday!=cpap)) {
|
if (!pref["MemoryHog"].toBool()) {
|
||||||
for (vector<Session *>::iterator s=lastcpapday->begin();s!=lastcpapday->end();s++) {
|
if (lastcpapday && (lastcpapday!=cpap)) {
|
||||||
(*s)->TrashEvents();
|
for (vector<Session *>::iterator s=lastcpapday->begin();s!=lastcpapday->end();s++) {
|
||||||
|
(*s)->TrashEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastcpapday=cpap;
|
lastcpapday=cpap;
|
||||||
@ -526,13 +521,13 @@ void Daily::Load(QDate date)
|
|||||||
html+="</tr>\n<tr><td colspan=4 align=center><i>"+tr("Event Breakdown")+"</i></td></tr>\n";
|
html+="</tr>\n<tr><td colspan=4 align=center><i>"+tr("Event Breakdown")+"</i></td></tr>\n";
|
||||||
if (1) {
|
if (1) {
|
||||||
|
|
||||||
/* G_AHI->setFixedSize(gwwidth,gwheight);
|
G_AHI->setFixedSize(gwwidth,gwheight);
|
||||||
QPixmap pixmap=G_AHI->renderPixmap(120,120,false); //gwwidth,gwheight,false);
|
QPixmap pixmap=G_AHI->renderPixmap(120,120,false); //gwwidth,gwheight,false);
|
||||||
QByteArray byteArray;
|
QByteArray byteArray;
|
||||||
QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray
|
QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray
|
||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
pixmap.save(&buffer, "PNG");
|
pixmap.save(&buffer, "PNG");
|
||||||
html += "<tr><td colspan=4 align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\"></td></tr>\n"; */
|
html += "<tr><td colspan=4 align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\"></td></tr>\n";
|
||||||
}
|
}
|
||||||
html+="</table>"
|
html+="</table>"
|
||||||
"<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n"
|
"<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n"
|
||||||
|
@ -99,10 +99,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
if (!pref.Exists("NoonDateSplit")) pref["NoonDateSplit"]=false;
|
if (!pref.Exists("NoonDateSplit")) pref["NoonDateSplit"]=false;
|
||||||
ui->action_Noon_Date_Split->setChecked(pref["NoonDateSplit"].toBool());
|
ui->action_Noon_Date_Split->setChecked(pref["NoonDateSplit"].toBool());
|
||||||
|
|
||||||
|
if (!pref.Exists("MemoryHog")) pref["MemoryHog"]=true;
|
||||||
|
ui->action_Memory_Hog->setChecked(pref["MemoryHog"].toBool());
|
||||||
|
|
||||||
if (!pref.Exists("fruitsalad")) pref["fruitsalad"]=true;
|
if (!pref.Exists("fruitsalad")) pref["fruitsalad"]=true;
|
||||||
|
|
||||||
if (!pref.Exists("UseAntiAliasing")) pref["UseAntiAliasing"]=false;
|
if (!pref.Exists("UseAntiAliasing")) pref["UseAntiAliasing"]=false;
|
||||||
ui->actionUse_AntiAliasing->setChecked(pref["UseAntiAliasing"].toBool());
|
ui->actionUse_AntiAliasing->setChecked(pref["UseAntiAliasing"].toBool());
|
||||||
|
|
||||||
|
|
||||||
first_load=true;
|
first_load=true;
|
||||||
|
|
||||||
if (!pref.Exists("AlwaysShowOverlayBars")) pref["AlwaysShowOverlayBars"]=true;
|
if (!pref.Exists("AlwaysShowOverlayBars")) pref["AlwaysShowOverlayBars"]=true;
|
||||||
@ -333,3 +338,8 @@ void MainWindow::on_actionOverlay_Bars_toggled(bool checked)
|
|||||||
if (daily)
|
if (daily)
|
||||||
daily->RedrawGraphs();
|
daily->RedrawGraphs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_action_Memory_Hog_toggled(bool checked)
|
||||||
|
{
|
||||||
|
pref["MemoryHog"]=checked;
|
||||||
|
}
|
||||||
|
@ -74,6 +74,8 @@ private slots:
|
|||||||
|
|
||||||
void on_actionOverlay_Bars_toggled(bool arg1);
|
void on_actionOverlay_Bars_toggled(bool arg1);
|
||||||
|
|
||||||
|
void on_action_Memory_Hog_toggled(bool arg1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
Daily * daily;
|
Daily * daily;
|
||||||
|
@ -591,9 +591,10 @@
|
|||||||
<addaction name="actionView_Welcome"/>
|
<addaction name="actionView_Welcome"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionUse_AntiAliasing"/>
|
<addaction name="actionUse_AntiAliasing"/>
|
||||||
|
<addaction name="actionOverlay_Bars"/>
|
||||||
<addaction name="action_Link_Graphs"/>
|
<addaction name="action_Link_Graphs"/>
|
||||||
<addaction name="action_Noon_Date_Split"/>
|
<addaction name="action_Noon_Date_Split"/>
|
||||||
<addaction name="actionOverlay_Bars"/>
|
<addaction name="action_Memory_Hog"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_Fullscreen"/>
|
<addaction name="action_Fullscreen"/>
|
||||||
</widget>
|
</widget>
|
||||||
@ -715,7 +716,15 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Overlay Bars</string>
|
<string>&Overlay Bars</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_Memory_Hog">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Memory Hog</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user