diff --git a/Graphs/gBarChart.cpp b/Graphs/gBarChart.cpp index 07550084..d0f1d6e1 100644 --- a/Graphs/gBarChart.cpp +++ b/Graphs/gBarChart.cpp @@ -9,7 +9,7 @@ #include "gBarChart.h" gBarChart::gBarChart(ChannelID code,QColor col,Qt::Orientation o) -:gLayer(code),m_orientation(o) +:Layer(code),m_orientation(o) { color.clear(); color.push_back(col); @@ -21,23 +21,21 @@ gBarChart::~gBarChart() delete Xaxis; } -void gBarChart::Plot(gGraphWindow & w,float scrx,float scry) +void gBarChart::paint(gGraphWindow & w,int left, int top, int width, int height) { if (!m_visible) return; - /*if (!data) return; - if (!data->IsReady()) return; + // if (!data) return; + //if (!data->IsReady()) return; - int start_px=w.GetLeftMargin(); - int start_py=w.GetBottomMargin(); - int width=scrx-(w.GetLeftMargin()+w.GetRightMargin()); - int height=scry-(w.GetTopMargin()+w.GetBottomMargin()); + int start_px=left; + int start_py=top; double xx=w.max_x - w.min_x; double days=int(xx); //days=data->np[0]; days=0; - for (int i=0;inp[0];i++) { +/* for (int i=0;inp[0];i++) { if ((data->point[0][i].x() >= w.min_x) && (data->point[0][i].x()count(m_codes[i])>0) { + m_empty=false; + break; + } + } } bool gSegmentChart::isEmpty() { - bool res=true; - if (!m_day) return true; - for (int i=0;icount(m_codes[i])>0) { - res=false; - break; - } - } - return res; + return m_empty; } void gSegmentChart::paint(gGraph & w,int left, int top, int width, int height) @@ -84,7 +84,7 @@ void gSegmentChart::paint(gGraph & w,int left, int top, int width, int height) float x,y; GetTextExtent(a,x,y,bigfont); - w.renderText(a,start_px+xoffset-x/2, (start_py+yoffset-y/2),0,col,bigfont); + w.renderText(a,start_px+xoffset-x/2, (start_py+yoffset+y/2),0,col,bigfont); return; } diff --git a/Graphs/gSegmentChart.h b/Graphs/gSegmentChart.h index af6f7b99..bcec4df4 100644 --- a/Graphs/gSegmentChart.h +++ b/Graphs/gSegmentChart.h @@ -31,6 +31,7 @@ protected: GraphSegmentType m_graph_type; QColor m_gradient_color; QColor m_outline_color; + bool m_empty; }; class gTAPGraph:public gSegmentChart diff --git a/Graphs/gStatsLine.cpp b/Graphs/gStatsLine.cpp new file mode 100644 index 00000000..4c3548f2 --- /dev/null +++ b/Graphs/gStatsLine.cpp @@ -0,0 +1,73 @@ +#include "SleepLib/day.h" +#include "gYAxis.h" +#include "gStatsLine.h" + +gStatsLine::gStatsLine(ChannelID code,QString label,QColor textcolor) + :Layer(code),m_label(label),m_textcolor(textcolor) +{ +} +void gStatsLine::paint(gGraph & w, int left, int top, int width, int height) +{ + if (!m_visible) return; + //if (m_empty) return; + + float x,y; + m_text=m_label; + GetTextExtent(m_text,x,y); + int z=(width+gYAxis::Margin)/5; + int p=left-gYAxis::Margin; + + + top+=8+y; + w.renderText(m_text,p,top,0,m_textcolor); + + p+=z; + m_text="Min="+QString::number(m_min,'f',2); + GetTextExtent(m_text,x,y); + w.renderText(m_text,p,top,0,m_textcolor); + + p+=z; + m_text="Avg="+QString::number(m_avg,'f',2); + GetTextExtent(m_text,x,y); + w.renderText(m_text,p,top,0,m_textcolor); + + p+=z; + m_text="90%="+QString::number(m_p90,'f',2); + GetTextExtent(m_text,x,y); + w.renderText(m_text,p,top,0,m_textcolor); + + p+=z; + m_text="Max="+QString::number(m_max,'f',2); + GetTextExtent(m_text,x,y); + w.renderText(m_text,p,top,0,m_textcolor); + +// GetTextExtent(m_text,m_tx,m_ty); + +} + + +void gStatsLine::SetDay(Day *d) +{ + Layer::SetDay(d); + if (!m_day) return; + m_min=d->min(m_code); + m_max=d->max(m_code); + m_avg=d->wavg(m_code); + m_p90=d->p90(m_code); + + m_text.clear(); + + // m_stext.setText(m_text); + // m_empty=true; +/* for (int i=0;icount(m_codes[i])>0) { + m_empty=false; + break; + } + } */ + +} +//bool gStatsLine::isEmpty() +//{ +// return m_empty; +//} diff --git a/Graphs/gStatsLine.h b/Graphs/gStatsLine.h new file mode 100644 index 00000000..d0eae345 --- /dev/null +++ b/Graphs/gStatsLine.h @@ -0,0 +1,26 @@ +#ifndef GSTATSLINE_H +#define GSTATSLINE_H + +#include "SleepLib/machine.h" +#include +#include "gGraphView.h" + +class gStatsLine : public Layer +{ +public: + gStatsLine(ChannelID code,QString label="",QColor textcolor=Qt::black); + virtual void paint(gGraph & w, int left, int top, int width, int height); + void SetDay(Day *d); + //bool isEmpty(); + +protected: + QColor m_textcolor; + //bool m_empty; + EventDataType m_min,m_max,m_avg,m_p90; + QString m_label; + QString m_text; + QStaticText m_stext; + float m_tx,m_ty; +}; + +#endif // GSTATSLINE_H diff --git a/SleepyHeadQT.pro b/SleepyHeadQT.pro index 0e625678..ef0f6896 100644 --- a/SleepyHeadQT.pro +++ b/SleepyHeadQT.pro @@ -56,7 +56,8 @@ SOURCES += main.cpp\ qextserialport/qextserialport.cpp \ Graphs/gSplitter.cpp \ preferencesdialog.cpp \ - Graphs/gGraphView.cpp + Graphs/gGraphView.cpp \ + Graphs/gStatsLine.cpp unix:SOURCES += qextserialport/posix_qextserialport.cpp unix:!macx:SOURCES += qextserialport/qextserialenumerator_unix.cpp @@ -108,7 +109,8 @@ HEADERS += \ qextserialport/qextserialenumerator.h \ Graphs/gSplitter.h \ preferencesdialog.h \ - Graphs/gGraphView.h + Graphs/gGraphView.h \ + Graphs/gStatsLine.h FORMS += \ diff --git a/daily.cpp b/daily.cpp index 2bf940aa..05a0b0b0 100644 --- a/daily.cpp +++ b/daily.cpp @@ -27,6 +27,7 @@ #include "Graphs/gYAxis.h" #include "Graphs/gBarChart.h" #include "Graphs/gSegmentChart.h" +#include "Graphs/gStatsLine.h" const int min_height=150; const int default_height=150; @@ -98,6 +99,8 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw) IE=new gGraph(GraphView,"I:E",default_height); TE=new gGraph(GraphView,"Te",default_height); TI=new gGraph(GraphView,"Ti",default_height); + INTPULSE=new gGraph(GraphView,"Pulse",default_height,1); + INTSPO2=new gGraph(GraphView,"SPO2",default_height,1); PULSE=new gGraph(GraphView,"Pulse",default_height,1); SPO2=new gGraph(GraphView,"SPO2",default_height,1); PLETHY=new gGraph(GraphView,"Plethy",default_height,1); @@ -145,16 +148,32 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw) FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_ClearAirway,QColor("purple"),"CA"))); - gGraph *graphs[]={ PRD, LEAK, SNORE, PTB, MP, RR, MV, TV, FLG, IE, TI, TE, SPO2, PLETHY, PULSE }; + gGraph *graphs[]={ PRD, LEAK, SNORE, PTB, MP, RR, MV, TV, FLG, IE, TI, TE, SPO2, PLETHY, PULSE,INTPULSE, INTSPO2 }; int ng=sizeof(graphs)/sizeof(gGraph*); for (int i=0;iAddLayer(new gXGrid()); } + PRD->AddLayer(AddCPAP(new gStatsLine(CPAP_Pressure,"Pressure")),LayerBottom,0,20,1); + PRD->AddLayer(AddCPAP(new gStatsLine(CPAP_EPAP,"EPAP")),LayerBottom,0,20,1); + PRD->AddLayer(AddCPAP(new gStatsLine(CPAP_IPAP,"IPAP")),LayerBottom,0,20,1); + LEAK->AddLayer(AddCPAP(new gStatsLine(CPAP_Leak)),LayerBottom,0,20,1); + SNORE->AddLayer(AddCPAP(new gStatsLine(CPAP_Snore)),LayerBottom,0,20,1); + PTB->AddLayer(AddCPAP(new gStatsLine(CPAP_PatientTriggeredBreaths)),LayerBottom,0,20,1); + RR->AddLayer(AddCPAP(new gStatsLine(CPAP_RespiratoryRate)),LayerBottom,0,20,1); + MV->AddLayer(AddCPAP(new gStatsLine(CPAP_MinuteVentilation)),LayerBottom,0,20,1); + TV->AddLayer(AddCPAP(new gStatsLine(CPAP_TidalVolume)),LayerBottom,0,20,1); + FLG->AddLayer(AddCPAP(new gStatsLine(CPAP_FlowLimitGraph)),LayerBottom,0,20,1); + IE->AddLayer(AddCPAP(new gStatsLine(CPAP_IE)),LayerBottom,0,20,1); + TE->AddLayer(AddCPAP(new gStatsLine(CPAP_Te)),LayerBottom,0,20,1); + TI->AddLayer(AddCPAP(new gStatsLine(CPAP_Ti)),LayerBottom,0,20,1); + + PRD->AddLayer(AddCPAP(new gLineChart(CPAP_Pressure,QColor("dark green"),true))); PRD->AddLayer(AddCPAP(new gLineChart(CPAP_EPAP,Qt::blue,true))); PRD->AddLayer(AddCPAP(new gLineChart(CPAP_IPAP,Qt::red,true))); LEAK->AddLayer(AddCPAP(new gLineChart(CPAP_Leak,Qt::darkYellow,true))); SNORE->AddLayer(AddCPAP(new gLineChart(CPAP_Snore,Qt::darkGray,true))); + PTB->AddLayer(AddCPAP(new gLineChart(CPAP_PatientTriggeredBreaths,Qt::gray,true))); MP->AddLayer(AddCPAP(new gLineChart(CPAP_MaskPressure,Qt::blue,false))); RR->AddLayer(AddCPAP(new gLineChart(CPAP_RespiratoryRate,Qt::darkMagenta,true))); @@ -165,6 +184,8 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw) IE->AddLayer(AddCPAP(new gLineChart(CPAP_IE,Qt::darkRed,true))); TE->AddLayer(AddCPAP(new gLineChart(CPAP_Te,Qt::darkGreen,true))); TI->AddLayer(AddCPAP(new gLineChart(CPAP_Ti,Qt::darkBlue,true))); + INTPULSE->AddLayer(AddCPAP(new gLineChart(CPAP_Pulse,Qt::red,true))); + INTSPO2->AddLayer(AddCPAP(new gLineChart(CPAP_SPO2,Qt::blue,true))); PULSE->AddLayer(AddOXI(new gLineChart(OXI_Pulse,Qt::red,true))); SPO2->AddLayer(AddOXI(new gLineChart(OXI_SPO2,Qt::blue,true))); PLETHY->AddLayer(AddOXI(new gLineChart(OXI_Plethysomogram,Qt::darkBlue,false))); @@ -174,6 +195,8 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw) graphs[i]->AddLayer(new gXAxis(),LayerBottom,0,20); } + + layout->layout(); QTextCharFormat format = ui->calendar->weekdayTextFormat(Qt::Saturday); diff --git a/oximetry.h b/oximetry.h index 14b434ff..f10a9e54 100644 --- a/oximetry.h +++ b/oximetry.h @@ -17,7 +17,6 @@ #include "SleepLib/day.h" #include "SleepLib/session.h" -//#include "Graphs/graphwindow.h" #include "Graphs/gLineChart.h" #include "Graphs/gFooBar.h"