diff --git a/SleepyHead.depend b/SleepyHead.depend index 781fe77f..1ec462cb 100644 --- a/SleepyHead.depend +++ b/SleepyHead.depend @@ -7871,11 +7871,11 @@ "tinyxml/tinyxml.h" -1306804928 /home/mark/projects/git/sleepyhead/graphs/graph.h +1306817262 /home/mark/projects/git/sleepyhead/graphs/graph.h -1306815962 /home/mark/projects/git/sleepyhead/version.h +1306817290 /home/mark/projects/git/sleepyhead/version.h 1306724655 /home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.h "machine.h" @@ -7892,7 +7892,7 @@ "preferences.h" "tinyxml/tinyxml.h" -1306815066 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp +1306816925 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp "wx_pch.h" "version.h" @@ -7910,7 +7910,7 @@ "sleeplib/profiles.h" "sleeplib/machine_loader.h" -1306815882 source:/home/mark/projects/git/sleepyhead/graphs/graph.cpp +1306817190 source:/home/mark/projects/git/sleepyhead/graphs/graph.cpp diff --git a/SleepyHeadMain.cpp b/SleepyHeadMain.cpp index 6551cb23..f14fb2bb 100644 --- a/SleepyHeadMain.cpp +++ b/SleepyHeadMain.cpp @@ -333,6 +333,7 @@ Summary::Summary(wxWindow *win,Profile *_profile) AHI=new gGraphWindow(ScrolledWindow,-1,wxT("AHI"),wxPoint(0,0), wxSize(400,160), wxNO_BORDER); AHI->SetMargins(10,15,65,80); AHI->AddLayer(new gBarChart(ahidata,wxRED)); + AHI->AddLayer(new gFooBar()); // AHI->AddLayer(new gXAxis(NULL,wxBLACK)); //AHI->AddLayer(new gLineChart(ahidata,wxRED)); fgSizer->Add(AHI,1,wxEXPAND); @@ -343,7 +344,7 @@ Summary::Summary(wxWindow *win,Profile *_profile) PRESSURE->AddLayer(new gLineChart(pressure,wxDARK_GREEN,6192)); PRESSURE->AddLayer(new gLineChart(pressure_eap,wxRED,6192,false,true)); PRESSURE->AddLayer(new gLineChart(pressure_iap,wxBLUE,6192,false,true)); - PRESSURE->AddLayer(new gXAxis(NULL,wxBLACK)); + PRESSURE->AddLayer(new gXAxis(wxBLACK)); fgSizer->Add(PRESSURE,1,wxEXPAND); @@ -351,14 +352,15 @@ Summary::Summary(wxWindow *win,Profile *_profile) LEAK->SetMargins(10,15,65,80); //LEAK->AddLayer(new gBarChart(leak,wxYELLOW)); LEAK->AddLayer(new gLineChart(leak,wxPURPLE,6192)); - LEAK->AddLayer(new gXAxis(NULL,wxBLACK)); + LEAK->AddLayer(new gXAxis(wxBLACK)); fgSizer->Add(LEAK,1,wxEXPAND); USAGE=new gGraphWindow(ScrolledWindow,-1,wxT("Usage (Hours)"),wxPoint(0,0), wxSize(400,160), wxNO_BORDER); USAGE->SetMargins(10,15,65,80); USAGE->AddLayer(new gBarChart(usage,wxGREEN)); - //USAGE->AddLayer(new gXAxis(NULL,wxBLACK)); + USAGE->AddLayer(new gFooBar()); + //USAGE->AddLayer(new gXAxis(wxBLACK)); //USAGE->AddLayer(new gLineChart(usage,wxGREEN)); fgSizer->Add(USAGE,1,wxEXPAND); @@ -525,7 +527,7 @@ Daily::Daily(wxWindow *win,Profile *p) AddData(leakdata=new PressureData(CPAP_Leak,0)); LEAK=new gGraphWindow(ScrolledWindow,-1,wxT("Mask Leaks"),wxPoint(0,0), wxSize(600,130), wxNO_BORDER); LEAK->AddLayer(new gLineChart(leakdata,wxPURPLE,4096,false)); - LEAK->AddLayer(new gXAxis(NULL,wxBLACK)); + LEAK->AddLayer(new gXAxis(wxBLACK)); AddData(pressure_iap=new PressureData(CPAP_IAP)); AddData(pressure_eap=new PressureData(CPAP_EAP)); @@ -534,7 +536,7 @@ Daily::Daily(wxWindow *win,Profile *p) PRD->AddLayer(new gLineChart(prd,wxDARK_GREEN,4096,false)); PRD->AddLayer(new gLineChart(pressure_iap,wxBLUE,4096,false,true)); PRD->AddLayer(new gLineChart(pressure_eap,wxRED,4096,false,true)); - PRD->AddLayer(new gXAxis(NULL,wxBLACK)); + PRD->AddLayer(new gXAxis(wxBLACK)); AddData(frw=new FlowData()); FRW=new gGraphWindow(ScrolledWindow,-1,wxT("Flow Rate"),wxPoint(0,0), wxSize(600,150), wxNO_BORDER); @@ -560,7 +562,7 @@ Daily::Daily(wxWindow *win,Profile *p) FRW->AddLayer(new gLineOverlayBar(flags[3],wxBLUE,wxT("H"))); FRW->AddLayer(new gLineOverlayBar(flags[2],wxAQUA,wxT("OA"))); FRW->AddLayer(new gLineOverlayBar(flags[1],wxPURPLE,wxT("CA"))); - FRW->AddLayer(new gXAxis(NULL,wxBLACK)); + FRW->AddLayer(new gXAxis(wxBLACK)); SF=new gGraphWindow(ScrolledWindow,-1,wxT("Event Flags"),wxPoint(0,0), wxSize(600,180), wxNO_BORDER); // SF->SetMargins(10,15,20,80); @@ -583,8 +585,8 @@ Daily::Daily(wxWindow *win,Profile *p) SF->AddLayer(new gFlagsLine(flags[2],wxAQUA,wxT("OA"),2,sfc)); SF->AddLayer(new gFlagsLine(flags[1],wxPURPLE,wxT("CA"),1,sfc)); SF->AddLayer(new gFlagsLine(flags[0],wxGREEN2,wxT("CSR"),0,sfc)); - SF->AddLayer(new gXAxis(NULL,wxBLACK)); - + SF->AddLayer(new gXAxis(wxBLACK)); + SF->AddLayer(new gFooBar()); fgSizer->Add(SF,1,wxEXPAND); fgSizer->Add(G_AHI,1,wxEXPAND); diff --git a/graphs/graph.cpp b/graphs/graph.cpp index b866d5d3..1f05bc07 100644 --- a/graphs/graph.cpp +++ b/graphs/graph.cpp @@ -25,12 +25,13 @@ wxColor zwxLIGHT_YELLOW(228,228,168,255); wxColor *wxLIGHT_YELLOW=&zwxLIGHT_YELLOW; wxColor zwxDARK_GREEN=wxColor(20,128,20,255); wxColor *wxDARK_GREEN=&zwxDARK_GREEN; +wxColor zwxDARK_GREY(0xA0,0xA0,0xA0,0xA0); +wxColor *wxDARK_GREY=&zwxDARK_GREY; const wxColor *gradient_start_color=wxWHITE, *gradient_end_color=wxLIGHT_YELLOW; wxDirection gradient_direction=wxEAST; const wxColor *selection_color=wxBLUE; //GREEN2; -wxColor wxDARK_GREY(0xA0,0xA0,0xA0,0xA0); gGraphData::gGraphData(int mp,gDataType t) :vc(0),type(t),max_points(mp) @@ -638,8 +639,8 @@ void gGraphWindow::DataChanged(gLayer *layer) } -gXAxis::gXAxis(gPointData *d,const wxColor * col) -:gLayer(d) +gXAxis::gXAxis(const wxColor * col) +:gLayer(NULL) { if (col) { color.clear(); @@ -780,8 +781,8 @@ void gXAxis::Plot(wxDC & dc, gGraphWindow & w) } -gYAxis::gYAxis(gPointData *d,const wxColor * col) -:gLayer(d) +gYAxis::gYAxis(const wxColor * col) +:gLayer(NULL) { if (col) { color.clear(); @@ -870,6 +871,46 @@ void gYAxis::Plot(wxDC & dc,gGraphWindow &w) dc.DrawRotatedText(w.Title(), start_px-8-labelW - y, start_py+((height + x)>>1), 90); } +gFooBar::gFooBar(const wxColor * col,const wxColor * col2) +:gLayer(NULL) +{ + if (col && col2) { + color.clear(); + color.push_back(col); + color.push_back(col2); + } +} +gFooBar::~gFooBar() +{ +} +void gFooBar::Plot(wxDC & dc, gGraphWindow & w) +{ + if (!m_visible) return; + + double xx=w.max_x-w.min_x; + if (xx==0) return; + + int scrx = w.GetScrX(); + int scry = w.GetScrY(); + + int start_px=w.GetLeftMargin(); + int start_py=w.GetTopMargin(); + int width=scrx-(w.GetLeftMargin()+w.GetRightMargin()); + int height=scry-(w.GetTopMargin()+w.GetBottomMargin()); + + wxPen pen2(*color[0], 1, wxDOT); + wxPen pen3(*color[1], 2, wxSOLID); + + dc.SetPen( pen2 ); + dc.DrawLine(start_px, start_py+height+10, start_px+width, start_py+height+10); + double rmx=w.rmax_x-w.rmin_x; + double px=((1/rmx)*(w.min_x-w.rmin_x))*width; + double py=((1/rmx)*(w.max_x-w.rmin_x))*width; + dc.SetPen(pen3); + dc.DrawLine(start_px+px, start_py+height+10, start_px+py, start_py+height+10); + dc.DrawLine(start_px+px, start_py+height+8, start_px+px, start_py+height+12); + dc.DrawLine(start_px+py, start_py+height+8, start_px+py, start_py+height+12); +} gCandleStick::gCandleStick(gPointData *d,wxOrientation o) :gLayer(d) @@ -965,8 +1006,8 @@ gBarChart::gBarChart(gPointData *d,const wxColor *col,wxOrientation o) color.clear(); color.push_back(col); } - Xaxis=new gXAxis(NULL,wxBLACK); - Yaxis=new gYAxis(NULL,wxBLACK); + Xaxis=new gXAxis(wxBLACK); + Yaxis=new gYAxis(wxBLACK); } gBarChart::~gBarChart() { @@ -1055,7 +1096,7 @@ void gBarChart::Plot(wxDC & dc, gGraphWindow & w) if (m_direction==wxVERTICAL) { dc.DrawRotatedText(str,start_px-textX-8,j,0); } else { - dc.DrawRotatedText(str,j,start_py+height+4+textX,90); + dc.DrawRotatedText(str,j,start_py+height+16+textX,90); } } else draw_xticks_instead=true; @@ -1074,13 +1115,15 @@ gLineChart::gLineChart(gPointData *d,const wxColor * col,int dlsize,bool a,bool m_drawlist=new wxPoint [dlsize]; color.clear(); color.push_back(col); - Yaxis=new gYAxis(NULL,wxBLACK); + foobar=new gFooBar(); + Yaxis=new gYAxis(wxBLACK); Yaxis->SetShowMajorLines(true); Yaxis->SetShowMinorLines(true); } gLineChart::~gLineChart() { delete Yaxis; + delete foobar; delete [] m_drawlist; } @@ -1127,18 +1170,7 @@ void gLineChart::Plot(wxDC & dc, gGraphWindow & w) dc.DrawLine(start_px+width+1,start_py,start_px+width+1,start_py+height+1); - // Funky Bar.. move this to it's own layer. - wxPen pen2(wxDARK_GREY, 1, wxDOT); - wxPen pen3(*wxGREEN, 2, wxSOLID); - dc.SetPen( pen2 ); - dc.DrawLine(start_px,start_py+height+10,start_px+width,start_py+height+10); - double rmx=w.rmax_x-w.rmin_x; - px=((1/rmx)*(w.min_x-w.rmin_x))*width; - py=((1/rmx)*(w.max_x-w.rmin_x))*width; - dc.SetPen(pen3); - dc.DrawLine(start_px+px,start_py+height+10,start_px+py,start_py+height+10); - dc.DrawLine(start_px+px,start_py+height+8,start_px+px,start_py+height+12); - dc.DrawLine(start_px+py,start_py+height+8,start_px+py,start_py+height+12); + foobar->Plot(dc,w); if (!m_hide_axes) { Yaxis->Plot(dc,w); @@ -1388,20 +1420,6 @@ void gFlagsLine::Plot(wxDC & dc, gGraphWindow & w) static wxBrush linebr1(col1, wxSOLID); static wxBrush linebr2(col2, wxSOLID); - static wxPen pen2(wxDARK_GREY, 1, wxDOT); - static wxPen pen3(*wxGREEN, 2, wxSOLID); - - dc.SetPen( pen2 ); - dc.DrawLine(start_px,start_py+height+10,start_px+width,start_py+height+10); - double rmx=w.rmax_x-w.rmin_x; - double px=((1/rmx)*(w.min_x-w.rmin_x))*width; - double py=((1/rmx)*(w.max_x-w.rmin_x))*width; - dc.SetPen(pen3); - dc.DrawLine(start_px+px,start_py+height+10,start_px+py,start_py+height+10); - dc.DrawLine(start_px+px,start_py+height+8,start_px+px,start_py+height+12); - dc.DrawLine(start_px+py,start_py+height+8,start_px+py,start_py+height+12); - - wxPen sfp1(*color[0], 1, wxSOLID); wxBrush brush(*color[0],wxSOLID); //FDIAGONAL_HATCH); diff --git a/graphs/graph.h b/graphs/graph.h index b856d94d..27152162 100644 --- a/graphs/graph.h +++ b/graphs/graph.h @@ -19,6 +19,7 @@ extern wxColor *wxPURPLE; extern wxColor *wxGREEN2; extern wxColor *wxLIGHT_YELLOW; extern wxColor *wxDARK_GREEN; +extern wxColor *wxDARK_GREY; #define MIN(a,b) (a