Graph Y axis scaling improvements, AHI graph edge fixes

This commit is contained in:
Mark Watkins 2011-11-27 16:25:27 +10:00
parent d02bf56570
commit 9bf2f5ce97
5 changed files with 71 additions and 22 deletions

View File

@ -897,6 +897,9 @@ gGraph::gGraph(gGraphView *graphview,QString title,int height,short group) :
m_quad->forceAntiAlias(true); m_quad->forceAntiAlias(true);
f_miny=f_maxy=0; f_miny=f_maxy=0;
m_forceMinY=m_forceMaxY=false; m_forceMinY=m_forceMaxY=false;
rec_miny=rec_maxy=0;
m_recMinY=true;
m_recMaxY=false;
} }
gGraph::~gGraph() gGraph::~gGraph()
{ {
@ -1597,33 +1600,43 @@ void gGraph::ToolTip(QString text, int x, int y, int timeout)
void gGraph::roundY(EventDataType &miny, EventDataType &maxy) void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
{ {
int m; int m;
if (m_recMinY) {
if (miny>rec_miny)
miny=rec_miny;
}
if (m_recMaxY) {
if (maxy<rec_maxy) {
maxy=rec_maxy;
return;
}
}
if (maxy>500) { if (maxy>500) {
m=ceil(maxy/100.0); m=ceil(maxy/100.0);
maxy=m*100; maxy=m*100;
m=floor(miny/100.0); //m=floor(miny/100.0);
miny=m*100; //miny=m*100;
} else if (maxy>150) { } else if (maxy>150) {
m=ceil(maxy/50.0); m=ceil(maxy/50.0);
maxy=m*50; maxy=m*50;
m=floor(miny/50.0); //m=floor(miny/50.0);
miny=m*50; //miny=m*50;
} else if (maxy>100) { } else if (maxy>100) {
m=ceil(maxy/20.0); m=ceil(maxy/20.0);
maxy=m*20; maxy=m*20;
m=floor(miny/20.0); //m=floor(miny/20.0);
miny=m*20; //miny=m*20;
} else if (maxy>40) { } else if (maxy>40) {
m=ceil(maxy/10.0); m=ceil(maxy/10.0);
m++; m++;
maxy=m*10; maxy=m*10;
m=floor(miny/10.0); //m=floor(miny/10.0);
if(m<0) m--; //if(m<0) m--;
miny=m*10; //miny=m*10;
} else if (maxy>=5) { } else if (maxy>=5) {
m=ceil(maxy/5.0)+1; m=ceil(maxy/5.0)+1;
maxy=m*5; maxy=m*5;
m=floor(miny/5.0); //m=floor(miny/5.0);
miny=m*5; //miny=m*5;
} else { } else {
if (maxy==miny && maxy==0) { if (maxy==miny && maxy==0) {
maxy=0.5; maxy=0.5;

View File

@ -309,11 +309,13 @@ public:
virtual void SetMaxY(EventDataType v); virtual void SetMaxY(EventDataType v);
virtual void forceMinY(EventDataType v) { f_miny=v; m_forceMinY=true; } virtual void forceMinY(EventDataType v) { f_miny=v; m_forceMinY=true; }
virtual void forceMaxY(EventDataType v) { f_maxy=v; m_forceMaxY=true; } virtual void forceMaxY(EventDataType v) { f_maxy=v; m_forceMaxY=true; }
virtual void recMinY(EventDataType v) { rec_miny=v; m_recMinY=true; }
virtual void recMaxY(EventDataType v) { rec_maxy=v; m_recMaxY=true; }
void resize(int width, int height); // margin recalcs.. void resize(int width, int height); // margin recalcs..
qint64 max_x,min_x,rmax_x,rmin_x; qint64 max_x,min_x,rmax_x,rmin_x;
EventDataType max_y,min_y,rmax_y,rmin_y, f_miny, f_maxy; EventDataType max_y,min_y,rmax_y,rmin_y, f_miny, f_maxy, rec_miny, rec_maxy;
void unforceMinY() { m_forceMinY=false; } void unforceMinY() { m_forceMinY=false; }
void unforceMaxY() { m_forceMaxY=false; } void unforceMaxY() { m_forceMaxY=false; }
bool blockZoom() { return m_blockzoom; } bool blockZoom() { return m_blockzoom; }
@ -372,6 +374,7 @@ protected:
Day * m_day; Day * m_day;
GLBuffer * m_quad; GLBuffer * m_quad;
bool m_forceMinY,m_forceMaxY; bool m_forceMinY,m_forceMaxY;
bool m_recMinY,m_recMaxY;
signals: signals:
protected slots: protected slots:

View File

@ -492,25 +492,35 @@ void AHIChart::paint(gGraph & w,int left, int top, int width, int height)
EventDataType yy=maxy-miny; EventDataType yy=maxy-miny;
EventDataType ymult=EventDataType(height-3)/yy; // time to pixel conversion multiplier EventDataType ymult=EventDataType(height-3)/yy; // time to pixel conversion multiplier
bool first=false; bool first=true;
double px,py; double px,py;
double lastpx,lastpy; double lastpx,lastpy;
double top1=top+height; double top1=top+height;
bool done=false;
for (int i=0;i<m_time.size();i++) { for (int i=0;i<m_time.size();i++) {
qint64 ti=m_time[i]; qint64 ti=m_time[i];
EventDataType v=m_data[i]; EventDataType v=m_data[i];
if ((ti>=minx) && (ti<maxx)) { if (ti<minx) continue;
if (ti>maxx) done=true;
if (first) {
if (i>0) {
ti=m_time[i-1];
v=m_data[i-1];
i--;
}
px=left+(double(ti-minx)*xmult); px=left+(double(ti-minx)*xmult);
py=top1-(double(v-miny)*ymult); py=top1-(double(v-miny)*ymult);
if (!first) { first=false;
first=true; } else {
} else { px=left+(double(ti-minx)*xmult);
lines->add(px,py,lastpx,lastpy,m_color); py=top1-(double(v-miny)*ymult);
} lines->add(px,py,lastpx,lastpy,m_color);
} }
lastpx=px; lastpx=px;
lastpy=py; lastpy=py;
if (done) break;
} }
lines->scissor(left,w.flipY(top+height+2),width+1,height+1);
} }
void AHIChart::SetDay(Day *d) void AHIChart::SetDay(Day *d)

View File

@ -13,7 +13,7 @@ License: GPL
//******************************************************************************************** //********************************************************************************************
//#include <wx/log.h> #include <QDir>
#include "zeo_loader.h" #include "zeo_loader.h"
#include "SleepLib/machine.h" #include "SleepLib/machine.h"
@ -30,6 +30,24 @@ int ZEOLoader::Open(QString & path,Profile *profile)
{ {
Q_UNUSED(path) Q_UNUSED(path)
Q_UNUSED(profile) Q_UNUSED(profile)
QString newpath;
QString dirtag="zeo";
if (path.toLower().endsWith(QDir::separator()+dirtag)) {
return 0;
//newpath=path;
} else {
newpath=path+QDir::separator()+dirtag.toUpper();
}
QString filename;
if (path.toLower().endsWith(".csv")) {
} else if (path.toLower().endsWith(".dat")) {
// not supported.
}
// ZEO folder structure detection stuff here. // ZEO folder structure detection stuff here.
return 0; // number of machines affected return 0; // number of machines affected

View File

@ -188,7 +188,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw)
PTB->AddLayer(AddCPAP(new gLineChart(CPAP_PTB,Qt::gray,square))); PTB->AddLayer(AddCPAP(new gLineChart(CPAP_PTB,Qt::gray,square)));
MP->AddLayer(AddCPAP(new gLineChart(CPAP_MaskPressure,Qt::blue,false))); MP->AddLayer(AddCPAP(new gLineChart(CPAP_MaskPressure,Qt::blue,false)));
RR->AddLayer(AddCPAP(new gLineChart("RespRate2",Qt::red,false))); RR->AddLayer(AddCPAP(new gLineChart("RespRate2",Qt::red,square)));
RR->AddLayer(AddCPAP(new gLineChart(CPAP_RespRate,Qt::darkMagenta,square))); RR->AddLayer(AddCPAP(new gLineChart(CPAP_RespRate,Qt::darkMagenta,square)));
MV->AddLayer(AddCPAP(new gLineChart(CPAP_MinuteVent,Qt::darkCyan,square))); MV->AddLayer(AddCPAP(new gLineChart(CPAP_MinuteVent,Qt::darkCyan,square)));
TV->AddLayer(AddCPAP(new gLineChart(CPAP_TidalVolume,Qt::magenta,square))); TV->AddLayer(AddCPAP(new gLineChart(CPAP_TidalVolume,Qt::magenta,square)));
@ -205,8 +205,13 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw)
PLETHY->AddLayer(AddOXI(new gLineChart(OXI_Plethy,Qt::darkBlue,false))); PLETHY->AddLayer(AddOXI(new gLineChart(OXI_Plethy,Qt::darkBlue,false)));
SPO2->forceMaxY(100); SPO2->forceMaxY(100);
SPO2->forceMinY(70); SPO2->forceMinY(75);
PULSE->forceMinY(40); PULSE->forceMinY(40);
LEAK->recMinY(0);
LEAK->recMaxY(80);
PRD->recMinY(4.0);
PRD->recMaxY(15.0);
for (int i=0;i<ng;i++){ for (int i=0;i<ng;i++){
graphs[i]->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin); graphs[i]->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin);
graphs[i]->AddLayer(new gXAxis(),LayerBottom,0,20); graphs[i]->AddLayer(new gXAxis(),LayerBottom,0,20);