From 475357a8594cc2db4bae696a84ab8d5c59ca5609 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Mon, 6 Jun 2011 20:06:57 +1000 Subject: [PATCH] Genericised graph Event & Waveform data classes --- Projects/CodeBlocks/SleepyHead.cbp | 8 +- Projects/CodeBlocks/SleepyHead.depend | 8 +- Projects/CodeBlocks/SleepyHead.layout | 29 +++---- src/SleepyHeadMain.cpp | 14 ++-- src/graphs/graph.cpp | 106 +++----------------------- src/graphs/graph.h | 26 +++---- src/version.h | 12 +-- 7 files changed, 57 insertions(+), 146 deletions(-) diff --git a/Projects/CodeBlocks/SleepyHead.cbp b/Projects/CodeBlocks/SleepyHead.cbp index 6394c700..2fc04f84 100644 --- a/Projects/CodeBlocks/SleepyHead.cbp +++ b/Projects/CodeBlocks/SleepyHead.cbp @@ -27,6 +27,8 @@ + + @@ -56,8 +58,8 @@ - - + + @@ -101,7 +103,7 @@ - + diff --git a/Projects/CodeBlocks/SleepyHead.depend b/Projects/CodeBlocks/SleepyHead.depend index 71f2baa1..4fd9f299 100644 --- a/Projects/CodeBlocks/SleepyHead.depend +++ b/Projects/CodeBlocks/SleepyHead.depend @@ -8291,11 +8291,11 @@ "tinyxml/tinyxml.h" -1307330909 /home/mark/projects/git/sleepyhead/src/graphs/graph.h +1307354721 /home/mark/projects/git/sleepyhead/src/graphs/graph.h -1307342695 /home/mark/projects/git/sleepyhead/src/version.h +1307354721 /home/mark/projects/git/sleepyhead/src/version.h 1307245704 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/prs1_loader.h "machine.h" @@ -8312,7 +8312,7 @@ "preferences.h" "tinyxml/tinyxml.h" -1307342349 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp +1307354717 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp "wx_pch.h" "version.h" @@ -8332,7 +8332,7 @@ "sleeplib/profiles.h" "sleeplib/machine_loader.h" -1307337296 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp +1307354731 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp diff --git a/Projects/CodeBlocks/SleepyHead.layout b/Projects/CodeBlocks/SleepyHead.layout index 501ae35c..c9af2028 100644 --- a/Projects/CodeBlocks/SleepyHead.layout +++ b/Projects/CodeBlocks/SleepyHead.layout @@ -2,33 +2,36 @@ - + - - + + - + - - + + - - + + - - + + + + + - - + + - + diff --git a/src/SleepyHeadMain.cpp b/src/SleepyHeadMain.cpp index 9f94363f..6eb9b502 100644 --- a/src/SleepyHeadMain.cpp +++ b/src/SleepyHeadMain.cpp @@ -586,7 +586,7 @@ Daily::Daily(wxWindow *win,Profile *p) l->color.push_back(wxGREEN2); G_AHI->AddLayer(l); - AddOXIData(pulse=new SkipZeroData(OXI_Pulse,0,32768)); + AddOXIData(pulse=new EventData(OXI_Pulse,0,32768,true)); //pulse->ForceMinY(40); //pulse->ForceMaxY(120); @@ -594,7 +594,7 @@ Daily::Daily(wxWindow *win,Profile *p) PULSE->AddLayer(new gLineChart(pulse,wxRED,32768,false,false,true)); PULSE->AddLayer(new gXAxis(wxBLACK)); - AddOXIData(spo2=new SkipZeroData(OXI_SPO2,0,32768)); + AddOXIData(spo2=new EventData(OXI_SPO2,0,32768,true)); //spo2->ForceMinY(60); //spo2->ForceMaxY(100); SPO2=new gGraphWindow(ScrolledWindow,-1,wxT("SpO2"),wxPoint(0,0), wxSize(600,130), wxNO_BORDER); @@ -604,23 +604,23 @@ Daily::Daily(wxWindow *win,Profile *p) PULSE->LinkZoom(SPO2); - AddCPAPData(leakdata=new PressureData(CPAP_Leak,0)); + AddCPAPData(leakdata=new EventData(CPAP_Leak,0)); //leakdata->ForceMinY(0); //leakdata->ForceMaxY(120); LEAK=new gGraphWindow(ScrolledWindow,-1,wxT("Mask Leaks"),wxPoint(0,0), wxSize(600,130), wxNO_BORDER); LEAK->AddLayer(new gLineChart(leakdata,wxPURPLE,4096,false,false,true)); LEAK->AddLayer(new gXAxis(wxBLACK)); - AddCPAPData(pressure_iap=new PressureData(CPAP_IAP)); - AddCPAPData(pressure_eap=new PressureData(CPAP_EAP)); - AddCPAPData(prd=new PressureData(CPAP_Pressure)); + AddCPAPData(pressure_iap=new EventData(CPAP_IAP)); + AddCPAPData(pressure_eap=new EventData(CPAP_EAP)); + AddCPAPData(prd=new EventData(CPAP_Pressure)); PRD=new gGraphWindow(ScrolledWindow,-1,wxT("Pressure"),wxPoint(0,0), wxSize(600,130), wxNO_BORDER); PRD->AddLayer(new gLineChart(prd,wxDARK_GREEN,4096,false,false,true)); PRD->AddLayer(new gLineChart(pressure_iap,wxBLUE,4096,false,true,true)); PRD->AddLayer(new gLineChart(pressure_eap,wxRED,4096,false,true,true)); PRD->AddLayer(new gXAxis(wxBLACK)); - AddCPAPData(frw=new FlowData()); + AddCPAPData(frw=new WaveData(CPAP_FlowRate)); FRW=new gGraphWindow(ScrolledWindow,-1,wxT("Flow Rate"),wxPoint(0,0), wxSize(600,150), wxNO_BORDER); AddCPAPData(flags[0]=new FlagData(CPAP_CSR,7,1,0)); diff --git a/src/graphs/graph.cpp b/src/graphs/graph.cpp index 5685dcdd..8efd1e7f 100644 --- a/src/graphs/graph.cpp +++ b/src/graphs/graph.cpp @@ -1523,14 +1523,14 @@ void gFlagsLine::Plot(wxDC & dc, gGraphWindow & w) } -FlowData::FlowData() -:gPointData(250000) +WaveData::WaveData(MachineCode _code, int _size) +:gPointData(_size),code(_code) { } -FlowData::~FlowData() +WaveData::~WaveData() { } -void FlowData::Reload(Day *day) +void WaveData::Reload(Day *day) { vc=0; if (!day) { @@ -1538,7 +1538,6 @@ void FlowData::Reload(Day *day) return; } //wxRealPoint *rpl; - MachineCode code=CPAP_FlowRate; min_x=day->first().GetMJD(); max_x=day->last().GetMJD(); max_y=0; @@ -1576,7 +1575,7 @@ void FlowData::Reload(Day *day) max_y=ceil(max_y); //double t1=MAX(fabs(min_y),fabs(max_y)); - + // Get clever here.. if (max_y>128) { } else if (max_y>90) { max_y=120; @@ -1603,15 +1602,14 @@ void FlowData::Reload(Day *day) } -// This can be merged back in with PressureData (and can be renamed while we are at it) -SkipZeroData::SkipZeroData(MachineCode _code,int _field,int _size) -:gPointData(_size),code(_code),field(_field) +EventData::EventData(MachineCode _code,int _field,int _size,bool _skipzero) +:gPointData(_size),code(_code),field(_field),skipzero(_skipzero) { } -SkipZeroData::~SkipZeroData() +EventData::~EventData() { } -void SkipZeroData::Reload(Day *day) +void EventData::Reload(Day *day) { vc=0; if (!day) { @@ -1636,7 +1634,7 @@ void SkipZeroData::Reload(Day *day) EventDataType p; for (vector::iterator ev=(*s)->events[code].begin(); ev!=(*s)->events[code].end(); ev++) { p=(*(*ev))[field]; - if (p!=0) { + if (((p!=0) && skipzero) || !skipzero) { wxRealPoint r((*ev)->time().GetMJD(),p); point[vc][t++]=r; assert(tfirst().GetMJD(); - max_x=day->last().GetMJD(); - assert(min_x::iterator s=day->begin();s!=day->end(); s++) { - if ((*s)->events.find(code)==(*s)->events.end()) continue; - if (vc>=(int)point.size()) { - AddSegment(max_points); - } - - int t=0; - EventDataType p; //,lastp=-1; - for (vector::iterator ev=(*s)->events[code].begin(); ev!=(*s)->events[code].end(); ev++) { - p=(*(*ev))[field]; - wxRealPoint r((*ev)->time().GetMJD(),p); - point[vc][t++]=r; - assert(tmax_y) max_y=r.y; - } - - //lastp=p; - } - np[vc]=t; - tt+=t; - vc++; - - } - /*if ((code==CPAP_Pressure) || (code==CPAP_EAP) || (code==CPAP_IAP)) { - if (day->summary_max(CPAP_Mode)==MODE_CPAP) { - min_y=4; - max_y=ceil(max_y+1); - } else { - if (min_y>day->summary_min(CPAP_PressureMin)) min_y=day->summary_min(CPAP_PressureMin); - if (max_ysummary_max(CPAP_PressureMax)) max_y=day->summary_min(CPAP_PressureMax); - //max_y=ceil(day->summary_max(CPAP_PressureMax)); - min_y=floor(min_y); - max_y=ceil(max_y); - } - } else { */ - if (tt>0) { - min_y=floor(min_y); - max_y=ceil(max_y+1); - if (min_y>1) min_y-=1; - } - - //} - if (force_min_y!=force_max_y) { - min_y=force_min_y; - max_y=force_max_y; - } - - - real_min_x=min_x; - real_min_y=min_y; - real_max_x=max_x; - real_max_y=max_y; - m_ready=true; - - //max_y=25; - //max_y=max_y/25)*25; - //graph->Refresh(false); -} TAPData::TAPData(MachineCode _code) :gPointData(256),code(_code) diff --git a/src/graphs/graph.h b/src/graphs/graph.h index 0938a100..055cc638 100644 --- a/src/graphs/graph.h +++ b/src/graphs/graph.h @@ -457,34 +457,26 @@ public: }; -class FlowData:public gPointData +class WaveData:public gPointData { public: - FlowData(); - virtual ~FlowData(); + WaveData(MachineCode _code,int _size=250000); + virtual ~WaveData(); virtual void Reload(Day *day=NULL); +protected: + MachineCode code; }; -class PressureData:public gPointData +class EventData:public gPointData { public: - PressureData(MachineCode _code,int _field=0,int _size=4096); - virtual ~PressureData(); - virtual void Reload(Day *day=NULL); -protected: - MachineCode code; - int field; -}; - -class SkipZeroData:public gPointData -{ -public: - SkipZeroData(MachineCode _code,int _field=0,int _size=4096); - virtual ~SkipZeroData(); + EventData(MachineCode _code,int _field=0,int _size=4096,bool _skipzero=false); + virtual ~EventData(); virtual void Reload(Day *day=NULL); protected: MachineCode code; int field; + bool skipzero; }; diff --git a/src/version.h b/src/version.h index 850281da..441d35dd 100644 --- a/src/version.h +++ b/src/version.h @@ -16,14 +16,14 @@ namespace AutoVersion{ //Standard Version Type static const long MAJOR = 0; static const long MINOR = 7; - static const long BUILD = 3267; - static const long REVISION = 949; + static const long BUILD = 3279; + static const long REVISION = 1025; //Miscellaneous Version Types - static const long BUILDS_COUNT = 339; - #define RC_FILEVERSION 0,7,3267,949 - #define RC_FILEVERSION_STRING "0, 7, 3267, 949\0" - static const char FULLVERSION_STRING[] = "0.7.3267.949"; + static const long BUILDS_COUNT = 369; + #define RC_FILEVERSION 0,7,3279,1025 + #define RC_FILEVERSION_STRING "0, 7, 3279, 1025\0" + static const char FULLVERSION_STRING[] = "0.7.3279.1025"; //These values are to keep track of your versioning state, don't modify them. static const long BUILD_HISTORY = 0;