mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-17 03:00:46 +00:00
Graph Tweaks, Implementation of Min/Max Y cap code
This commit is contained in:
parent
35e08ab6fe
commit
fb9143ef8f
@ -19,14 +19,14 @@ void InitGraphs()
|
||||
{
|
||||
if (!_graph_init) {
|
||||
defaultfont=new QFont("Sans Serif",10);
|
||||
defaultfont->setPixelSize(11);
|
||||
mediumfont=new QFont("Sans Serif",12);
|
||||
// defaultfont->setPixelSize(11);
|
||||
mediumfont=new QFont("Serif",11);
|
||||
bigfont=new QFont("Serif",35);
|
||||
|
||||
defaultfont->setStyleHint(QFont::SansSerif,QFont::OpenGLCompatible);
|
||||
mediumfont->setStyleHint(QFont::SansSerif,QFont::OpenGLCompatible);
|
||||
bigfont->setStyleHint(QFont::Serif ,QFont::OpenGLCompatible);
|
||||
|
||||
mediumfont->setBold(true);
|
||||
_graph_init=true;
|
||||
}
|
||||
}
|
||||
@ -550,6 +550,8 @@ gGraph::gGraph(gGraphView *graphview,QString title,int height,short group) :
|
||||
|
||||
m_quad=new GLBuffer(QColor(128,128,255,128),64,GL_QUADS);
|
||||
m_quad->forceAntiAlias(true);
|
||||
f_miny=f_maxy=0;
|
||||
m_forceMinY=m_forceMaxY=false;
|
||||
}
|
||||
gGraph::~gGraph()
|
||||
{
|
||||
@ -1133,6 +1135,7 @@ EventDataType gGraph::MinY()
|
||||
{
|
||||
bool first=true;
|
||||
EventDataType val=0,tmp;
|
||||
if (m_forceMinY) return rmin_y=f_miny;
|
||||
for (QVector<Layer *>::iterator l=m_layers.begin();l!=m_layers.end();l++) {
|
||||
if ((*l)->isEmpty()) continue;
|
||||
tmp=(*l)->Miny();
|
||||
@ -1150,6 +1153,7 @@ EventDataType gGraph::MaxY()
|
||||
{
|
||||
bool first=true;
|
||||
EventDataType val=0,tmp;
|
||||
if (m_forceMaxY) return rmax_y=f_maxy;
|
||||
for (QVector<Layer *>::iterator l=m_layers.begin();l!=m_layers.end();l++) {
|
||||
if ((*l)->isEmpty()) continue;
|
||||
tmp=(*l)->Maxy();
|
||||
@ -1262,6 +1266,8 @@ void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
|
||||
miny/=4.0;
|
||||
}
|
||||
}
|
||||
if (m_forceMinY && miny<f_miny) miny=f_miny;
|
||||
if (m_forceMaxY && maxy>f_maxy) maxy=f_maxy;
|
||||
}
|
||||
|
||||
gGraphView::gGraphView(QWidget *parent, gGraphView * shared) :
|
||||
|
@ -262,12 +262,15 @@ public:
|
||||
virtual void SetMaxX(qint64 v);
|
||||
virtual void SetMinY(EventDataType v);
|
||||
virtual void SetMaxY(EventDataType v);
|
||||
virtual void forceMinY(EventDataType v) { f_miny=v; m_forceMinY=true; }
|
||||
virtual void forceMaxY(EventDataType v) { f_maxy=v; m_forceMaxY=true; }
|
||||
|
||||
void resize(int width, int height); // margin recalcs..
|
||||
|
||||
qint64 max_x,min_x,rmax_x,rmin_x;
|
||||
EventDataType max_y,min_y,rmax_y,rmin_y;
|
||||
|
||||
EventDataType max_y,min_y,rmax_y,rmin_y, f_miny, f_maxy;
|
||||
void unforceMinY() { m_forceMinY=false; }
|
||||
void unforceMaxY() { m_forceMaxY=false; }
|
||||
bool blockZoom() { return m_blockzoom; }
|
||||
void setBlockZoom(bool b) { m_blockzoom=b; }
|
||||
int flipY(int y); // flip GL coordinates
|
||||
@ -318,6 +321,7 @@ protected:
|
||||
short m_lastx23;
|
||||
Day * m_day;
|
||||
GLBuffer * m_quad;
|
||||
bool m_forceMinY,m_forceMaxY;
|
||||
};
|
||||
|
||||
class gGraphView : public QGLWidget
|
||||
|
@ -244,6 +244,9 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
|
||||
done=false;
|
||||
first=true;
|
||||
|
||||
if (!accel) {
|
||||
lines->setSize(1.5);
|
||||
} else lines->setSize(1);
|
||||
bool firstpx=true;
|
||||
if (el.type()==EVL_Waveform) { // Waveform Plot
|
||||
if (idx>sam) idx-=sam;
|
||||
|
@ -259,7 +259,7 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
|
||||
col=QColor("gold");
|
||||
}
|
||||
|
||||
tmp=g.value();
|
||||
tmp=g.value()-miny;
|
||||
totalvalues[j]+=tmp;
|
||||
totalcounts[j]++;
|
||||
h=tmp*ymult; // height in pixels
|
||||
@ -427,151 +427,3 @@ bool SummaryChart::mouseReleaseEvent(QMouseEvent * event)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
UsageChart::UsageChart(Profile *profile)
|
||||
:gBarChart()
|
||||
{
|
||||
m_profile=profile;
|
||||
m_colors.push_back(Qt::green);
|
||||
m_label="Hours";
|
||||
}
|
||||
|
||||
void UsageChart::SetDay(Day * day)
|
||||
{
|
||||
if (!m_profile) {
|
||||
qWarning() << "Forgot to set profile for gBarChart dummy!";
|
||||
m_day=NULL;
|
||||
return;
|
||||
}
|
||||
Layer::SetDay(day);
|
||||
//m_empty=true;
|
||||
// if (!day) return;
|
||||
|
||||
m_values.clear();
|
||||
m_miny=9999999;
|
||||
m_maxy=-9999999;
|
||||
m_minx=0;
|
||||
m_maxx=0;
|
||||
|
||||
int dn;
|
||||
EventDataType tmp,total;
|
||||
ChannelID code;
|
||||
|
||||
m_fday=0;
|
||||
qint64 tt;
|
||||
|
||||
int days=0;
|
||||
for (QMap<QDate,QVector<Day *> >::iterator d=m_profile->daylist.begin();d!=m_profile->daylist.end();d++) {
|
||||
tt=QDateTime(d.key(),QTime(0,0,0),Qt::UTC).toTime_t();
|
||||
dn=tt/86400;
|
||||
tt*=1000L;
|
||||
// there could possibly may be a bug by doing this.. if charts don't match up.. come back here and enable the m_minx right down the bottom of this function.
|
||||
if (!m_minx || tt<m_minx) m_minx=tt;
|
||||
if (!m_maxx || tt>m_maxx) m_maxx=tt;
|
||||
|
||||
Day *day=m_profile->GetDay(d.key(),MT_CPAP);
|
||||
if (day) {
|
||||
total=day->hours();
|
||||
|
||||
m_values[dn][0]=total;
|
||||
m_values[dn][1]=total;
|
||||
if (total<m_miny) m_miny=total;
|
||||
if (total>m_maxy) m_maxy=total;
|
||||
days++;
|
||||
}
|
||||
}
|
||||
if (!days) m_empty=true; else m_empty=false;
|
||||
//m_maxy=ceil(m_maxy);
|
||||
//m_miny=floor(m_miny);
|
||||
m_miny=0;
|
||||
|
||||
// m_minx=qint64(QDateTime(m_profile->FirstDay(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L;
|
||||
m_maxx=qint64(QDateTime(m_profile->LastDay().addDays(1),QTime(0,0,0),Qt::UTC).toTime_t())*1000L;
|
||||
}
|
||||
|
||||
|
||||
AHIChart::AHIChart(Profile *profile)
|
||||
:gBarChart()
|
||||
{
|
||||
m_label="AHI";
|
||||
m_profile=profile;
|
||||
}
|
||||
|
||||
void AHIChart::SetDay(Day * nullday)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AvgChart::AvgChart(Profile *profile)
|
||||
:gBarChart()
|
||||
{
|
||||
m_label="Avg";
|
||||
m_profile=profile;
|
||||
}
|
||||
|
||||
void AvgChart::SetDay(Day * day)
|
||||
{
|
||||
if (!m_profile) {
|
||||
qWarning() << "Forgot to set profile for gBarChart dummy!";
|
||||
m_day=NULL;
|
||||
return;
|
||||
}
|
||||
Layer::SetDay(day);
|
||||
|
||||
m_values.clear();
|
||||
m_miny=9999999;
|
||||
m_maxy=-9999999;
|
||||
m_minx=0;
|
||||
m_maxx=0;
|
||||
|
||||
int dn;
|
||||
EventDataType tmp,total;
|
||||
ChannelID code;
|
||||
|
||||
m_fday=0;
|
||||
qint64 tt;
|
||||
|
||||
for (QMap<QDate,QVector<Day *> >::iterator d=m_profile->daylist.begin();d!=m_profile->daylist.end();d++) {
|
||||
tt=QDateTime(d.key(),QTime(0,0,0),Qt::UTC).toTime_t();
|
||||
//tt=QDateTime(d.key(),QTime(12,0,0)).toTime_t();
|
||||
dn=tt/86400;
|
||||
tt*=1000L;
|
||||
if (!m_minx || tt<m_minx) m_minx=tt;
|
||||
if (!m_maxx || tt>m_maxx) m_maxx=tt;
|
||||
|
||||
|
||||
total=0;
|
||||
bool fnd=false;
|
||||
for (int j=0;j<m_codes.size();j++) {
|
||||
code=m_codes[j];
|
||||
for (int i=0;i<d.value().size();i++) {
|
||||
Day *day=d.value()[i];
|
||||
if (day->channelExists(code)) { // too many lookups happening here.. stop the crap..
|
||||
tmp=day->wavg(code);
|
||||
if (tmp>0) {
|
||||
fnd=true;
|
||||
total+=tmp;
|
||||
m_values[dn][j+1]=tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fnd) {
|
||||
if (!m_fday) m_fday=dn;
|
||||
m_values[dn][0]=total;
|
||||
if (total<m_miny) m_miny=total;
|
||||
if (total>m_maxy) m_maxy=total;
|
||||
}
|
||||
}
|
||||
m_miny=0;
|
||||
|
||||
// m_minx=qint64(QDateTime(m_profile->FirstDay(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L;
|
||||
m_maxx=qint64(QDateTime(m_profile->LastDay().addDays(1),QTime(0,0,0),Qt::UTC).toTime_t())*1000L;
|
||||
|
||||
m_empty=m_values.size()==0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
@ -136,7 +136,7 @@ void gXAxis::paint(gGraph & w,int left,int top, int width, int height)
|
||||
GLBuffer *lines=w.backlines();
|
||||
|
||||
|
||||
int utcoff=m_utcfix ? -tz_hours : 0;
|
||||
int utcoff=m_utcfix ? tz_hours : 0;
|
||||
|
||||
//utcoff=0;
|
||||
int num_minor_ticks;
|
||||
|
@ -23,7 +23,7 @@ void init()
|
||||
if (schema_initialized) return;
|
||||
schema_initialized=true;
|
||||
|
||||
EmptyChannel=Channel(0,DATA,DAY,"Empty","Empty Channel","Empty","");
|
||||
EmptyChannel=Channel(0,DATA,DAY,"Empty","Empty Channel","","");
|
||||
|
||||
ChanTypes["data"]=DATA;
|
||||
//Types["waveform"]=WAVEFORM;
|
||||
|
@ -80,10 +80,12 @@ Overview::Overview(QWidget *parent,Profile * _profile,gGraphView * shared) :
|
||||
|
||||
|
||||
pr=new SummaryChart(profile,"cmH2O",GT_LINE);
|
||||
|
||||
PR->forceMinY(4.0);
|
||||
//PR->forceMaxY(12.0);
|
||||
pr->addSlice(CPAP_Pressure,QColor("dark green"),ST_WAVG);
|
||||
pr->addSlice(CPAP_Pressure,QColor("orange"),ST_MIN);
|
||||
pr->addSlice(CPAP_Pressure,QColor("red"),ST_MAX);
|
||||
//pr->addSlice(CPAP_Pressure,QColor("grey"),ST_90P);
|
||||
pr->addSlice(CPAP_EPAP,QColor("light green"),ST_MIN);
|
||||
pr->addSlice(CPAP_IPAP,QColor("light blue"),ST_MAX);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user