From 9bf2f5ce97fcebb99a460fb506465d3dc289ec21 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sun, 27 Nov 2011 16:25:27 +1000 Subject: [PATCH] Graph Y axis scaling improvements, AHI graph edge fixes --- Graphs/gGraphView.cpp | 35 ++++++++++++++++++-------- Graphs/gGraphView.h | 5 +++- Graphs/gLineChart.cpp | 24 ++++++++++++------ SleepLib/loader_plugins/zeo_loader.cpp | 20 ++++++++++++++- daily.cpp | 9 +++++-- 5 files changed, 71 insertions(+), 22 deletions(-) diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp index 8c9b9ed9..cbf6bb34 100644 --- a/Graphs/gGraphView.cpp +++ b/Graphs/gGraphView.cpp @@ -897,6 +897,9 @@ gGraph::gGraph(gGraphView *graphview,QString title,int height,short group) : m_quad->forceAntiAlias(true); f_miny=f_maxy=0; m_forceMinY=m_forceMaxY=false; + rec_miny=rec_maxy=0; + m_recMinY=true; + m_recMaxY=false; } gGraph::~gGraph() { @@ -1597,33 +1600,43 @@ void gGraph::ToolTip(QString text, int x, int y, int timeout) void gGraph::roundY(EventDataType &miny, EventDataType &maxy) { int m; + if (m_recMinY) { + if (miny>rec_miny) + miny=rec_miny; + } + if (m_recMaxY) { + if (maxy500) { m=ceil(maxy/100.0); maxy=m*100; - m=floor(miny/100.0); - miny=m*100; + //m=floor(miny/100.0); + //miny=m*100; } else if (maxy>150) { m=ceil(maxy/50.0); maxy=m*50; - m=floor(miny/50.0); - miny=m*50; + //m=floor(miny/50.0); + //miny=m*50; } else if (maxy>100) { m=ceil(maxy/20.0); maxy=m*20; - m=floor(miny/20.0); - miny=m*20; + //m=floor(miny/20.0); + //miny=m*20; } else if (maxy>40) { m=ceil(maxy/10.0); m++; maxy=m*10; - m=floor(miny/10.0); - if(m<0) m--; - miny=m*10; + //m=floor(miny/10.0); + //if(m<0) m--; + //miny=m*10; } else if (maxy>=5) { m=ceil(maxy/5.0)+1; maxy=m*5; - m=floor(miny/5.0); - miny=m*5; + //m=floor(miny/5.0); + //miny=m*5; } else { if (maxy==miny && maxy==0) { maxy=0.5; diff --git a/Graphs/gGraphView.h b/Graphs/gGraphView.h index 4e65b948..2863f7fa 100644 --- a/Graphs/gGraphView.h +++ b/Graphs/gGraphView.h @@ -309,11 +309,13 @@ public: 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; } + 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.. 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 unforceMaxY() { m_forceMaxY=false; } bool blockZoom() { return m_blockzoom; } @@ -372,6 +374,7 @@ protected: Day * m_day; GLBuffer * m_quad; bool m_forceMinY,m_forceMaxY; + bool m_recMinY,m_recMaxY; signals: protected slots: diff --git a/Graphs/gLineChart.cpp b/Graphs/gLineChart.cpp index 366a0b7a..9f11dfe2 100644 --- a/Graphs/gLineChart.cpp +++ b/Graphs/gLineChart.cpp @@ -492,25 +492,35 @@ void AHIChart::paint(gGraph & w,int left, int top, int width, int height) EventDataType yy=maxy-miny; EventDataType ymult=EventDataType(height-3)/yy; // time to pixel conversion multiplier - bool first=false; + bool first=true; double px,py; double lastpx,lastpy; double top1=top+height; + bool done=false; for (int i=0;i=minx) && (timaxx) done=true; + if (first) { + if (i>0) { + ti=m_time[i-1]; + v=m_data[i-1]; + i--; + } px=left+(double(ti-minx)*xmult); py=top1-(double(v-miny)*ymult); - if (!first) { - first=true; - } else { - lines->add(px,py,lastpx,lastpy,m_color); - } + first=false; + } else { + px=left+(double(ti-minx)*xmult); + py=top1-(double(v-miny)*ymult); + lines->add(px,py,lastpx,lastpy,m_color); } lastpx=px; lastpy=py; + if (done) break; } + lines->scissor(left,w.flipY(top+height+2),width+1,height+1); } void AHIChart::SetDay(Day *d) diff --git a/SleepLib/loader_plugins/zeo_loader.cpp b/SleepLib/loader_plugins/zeo_loader.cpp index 1c89953a..864923c0 100644 --- a/SleepLib/loader_plugins/zeo_loader.cpp +++ b/SleepLib/loader_plugins/zeo_loader.cpp @@ -13,7 +13,7 @@ License: GPL //******************************************************************************************** -//#include +#include #include "zeo_loader.h" #include "SleepLib/machine.h" @@ -30,6 +30,24 @@ int ZEOLoader::Open(QString & path,Profile *profile) { Q_UNUSED(path) 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. return 0; // number of machines affected diff --git a/daily.cpp b/daily.cpp index 60c1f4a0..4fc1f362 100644 --- a/daily.cpp +++ b/daily.cpp @@ -188,7 +188,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw) PTB->AddLayer(AddCPAP(new gLineChart(CPAP_PTB,Qt::gray,square))); 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))); MV->AddLayer(AddCPAP(new gLineChart(CPAP_MinuteVent,Qt::darkCyan,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))); SPO2->forceMaxY(100); - SPO2->forceMinY(70); + SPO2->forceMinY(75); PULSE->forceMinY(40); + + LEAK->recMinY(0); + LEAK->recMaxY(80); + PRD->recMinY(4.0); + PRD->recMaxY(15.0); for (int i=0;iAddLayer(new gYAxis(),LayerLeft,gYAxis::Margin); graphs[i]->AddLayer(new gXAxis(),LayerBottom,0,20);