From 845ddfc5d415c791c64513d23bb61e2221f507be Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Tue, 7 Jun 2011 19:17:22 +1000 Subject: [PATCH] Added RenderBitmap() to gGraphWindow, AHI experiment.. --- Projects/CodeBlocks/SleepyHead.depend | 12 +++++----- Projects/CodeBlocks/SleepyHead.layout | 8 +++---- src/SleepyHeadApp.cpp | 4 +--- src/SleepyHeadMain.cpp | 26 ++++++++++++++++---- src/SleepyHeadMain.h | 2 ++ src/graphs/graph.cpp | 34 ++++++++++++++++++++++++--- src/graphs/graph.h | 2 ++ src/version.h | 12 +++++----- 8 files changed, 73 insertions(+), 27 deletions(-) diff --git a/Projects/CodeBlocks/SleepyHead.depend b/Projects/CodeBlocks/SleepyHead.depend index 6f896798..8d0c65d3 100644 --- a/Projects/CodeBlocks/SleepyHead.depend +++ b/Projects/CodeBlocks/SleepyHead.depend @@ -8231,7 +8231,7 @@ -1307418393 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadApp.cpp +1307436744 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadApp.cpp "wx_pch.h" @@ -8249,7 +8249,7 @@ 1307418393 /home/mark/projects/git/sleepyhead/src/SleepyHeadApp.h -1307418393 /home/mark/projects/git/sleepyhead/src/SleepyHeadMain.h +1307436654 /home/mark/projects/git/sleepyhead/src/SleepyHeadMain.h "SleepyHeadApp.h" @@ -8291,11 +8291,11 @@ "tinyxml/tinyxml.h" -1307418393 /home/mark/projects/git/sleepyhead/src/graphs/graph.h +1307436543 /home/mark/projects/git/sleepyhead/src/graphs/graph.h -1307429469 /home/mark/projects/git/sleepyhead/src/version.h +1307438188 /home/mark/projects/git/sleepyhead/src/version.h 1307418393 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/prs1_loader.h "machine.h" @@ -8312,7 +8312,7 @@ "preferences.h" "tinyxml/tinyxml.h" -1307429469 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp +1307437773 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" -1307419324 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp +1307436574 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp diff --git a/Projects/CodeBlocks/SleepyHead.layout b/Projects/CodeBlocks/SleepyHead.layout index 51a7323e..40c8ff12 100644 --- a/Projects/CodeBlocks/SleepyHead.layout +++ b/Projects/CodeBlocks/SleepyHead.layout @@ -7,14 +7,14 @@ - - + + - - + + diff --git a/src/SleepyHeadApp.cpp b/src/SleepyHeadApp.cpp index 743cc59b..38fc7042 100644 --- a/src/SleepyHeadApp.cpp +++ b/src/SleepyHeadApp.cpp @@ -47,10 +47,8 @@ bool SleepyHeadApp::OnInit() wxLogDebug( wxVERSION_STRING ); wxLogDebug( wxT("Application Initialze...") ); - - // wxFileSystem::AddHandler(new wxMemoryFSHandler); - wxInitAllImageHandlers(); + wxFileSystem::AddHandler(new wxMemoryFSHandler); // This is damn handy.. //wxDateTime::SetCountry(wxDateTime::USA); SetAppName(_("SleepyHead")); diff --git a/src/SleepyHeadMain.cpp b/src/SleepyHeadMain.cpp index c1b1c543..38d14b5e 100644 --- a/src/SleepyHeadMain.cpp +++ b/src/SleepyHeadMain.cpp @@ -546,7 +546,7 @@ void Summary::OnClose(wxCloseEvent &event) Daily::Daily(wxWindow *win,Profile *p) :DailyPanel(win),profile(p) { - + ahi_bmp=NULL; HTMLInfo=new wxHtmlWindow(this); EventTree=new wxTreeCtrl(this); @@ -569,8 +569,8 @@ Daily::Daily(wxWindow *win,Profile *p) TAP_EAP->SetMargins(20,15,5,50); TAP_EAP->AddLayer(new gCandleStick(tap_eap)); - G_AHI=new gGraphWindow(ScrolledWindow,-1,wxT("Event Breakdown"),wxPoint(0,0), wxSize(600,60), wxNO_BORDER); - G_AHI->SetMargins(20,15,5,50); + G_AHI=new gGraphWindow(ScrolledWindow,-1,wxT(""),wxPoint(0,0), wxSize(600,60), wxNO_BORDER); //Event Breakdown") + G_AHI->SetMargins(0,2,0,2); AddCPAPData(g_ahi=new AHIData()); gCandleStick *l=new gCandleStick(g_ahi); l->AddName(wxT("H")); @@ -681,7 +681,7 @@ Daily::Daily(wxWindow *win,Profile *p) fgSizer->Add(LEAK,1,wxEXPAND); fgSizer->Add(PULSE,1,wxEXPAND); fgSizer->Add(SPO2,1,wxEXPAND); - fgSizer->Add(G_AHI,1,wxEXPAND); + //fgSizer->Add(G_AHI,1,wxEXPAND); fgSizer->Add(TAP,1,wxEXPAND); fgSizer->Add(TAP_IAP,1,wxEXPAND); fgSizer->Add(TAP_EAP,1,wxEXPAND); @@ -691,6 +691,11 @@ Daily::Daily(wxWindow *win,Profile *p) } Daily::~Daily() { + if (ahi_bmp) { + wxMemoryFSHandler::RemoveFile(_T("ahi.png")); + delete ahi_bmp; + } + this->Disconnect(wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( Daily::OnEventTreeSelection), NULL, this); } void Daily::OnClose(wxCloseEvent &event) @@ -741,7 +746,7 @@ void Daily::RefreshData() if (cpap) UpdateCPAPGraphs(cpap); if (oxi) UpdateOXIGraphs(oxi); - wxString html=wxT("\n"); + wxString html=wxT("
\n"); CPAPMode mode; if (cpap) { @@ -784,6 +789,15 @@ void Daily::RefreshData() EventTree->SortChildren(root); EventTree->Expand(root); + //Logo.LoadFile(wxT("./pic.png")); + if (ahi_bmp) { + wxMemoryFSHandler::RemoveFile(_T("ahi.png")); + delete ahi_bmp; + } + ahi_bmp=G_AHI->RenderBitmap(180,40); + //delete ahi_bmp; + wxMemoryFSHandler::AddFile(_T("ahi.png"), *ahi_bmp, wxBITMAP_TYPE_PNG); + PRTypes pr=(PRTypes)cpap->summary_max(CPAP_PressureReliefType); wxString epr=PressureReliefNames[pr]+wxString::Format(wxT(" x%i"),(int)cpap->summary_max(CPAP_PressureReliefSetting)); @@ -817,6 +831,8 @@ void Daily::RefreshData() html=html+wxT("\n"); html=html+wxT("\n"); html=html+wxT("\n"); + html=html+wxT("\n"); + html=html+wxT("\n"); html=html+wxT("\n"); html=html+wxT("\n"); html=html+wxT("\n"); diff --git a/src/SleepyHeadMain.h b/src/SleepyHeadMain.h index 10b81b08..035a41ce 100644 --- a/src/SleepyHeadMain.h +++ b/src/SleepyHeadMain.h @@ -83,6 +83,8 @@ protected: wxHtmlWindow *HTMLInfo; wxTreeCtrl *EventTree; + wxBitmap *ahi_bmp; + }; const wxEventType wxEVT_DO_SCREENSHOT = wxNewEventType(); diff --git a/src/graphs/graph.cpp b/src/graphs/graph.cpp index c3277f5f..25ea7f90 100644 --- a/src/graphs/graph.cpp +++ b/src/graphs/graph.cpp @@ -375,14 +375,42 @@ void gGraphWindow::SetMargins(int top, int right, int bottom, int left) m_marginRight=right; } +wxBitmap * gGraphWindow::RenderBitmap(int width,int height) +{ + wxMemoryDC dc; + m_scrX=width; + m_scrY=height; + + wxBitmap *bmp=new wxBitmap(width, height,-1); + dc.SelectObject(*bmp); + + dc.SetPen( *wxTRANSPARENT_PEN ); + + dc.SetTextForeground(m_fgColour); + + wxRect r=wxRect(0,0,width,height); + +// dc.GradientFillLinear(r,*gradient_start_color,*gradient_end_color,gradient_direction); + wxBrush brush( GetBackgroundColour() ); + dc.SetBrush( brush ); + dc.DrawRectangle(r); + for (list::iterator l=layers.begin();l!=layers.end();l++) { + (*l)->Plot(dc,*this); + } + + dc.SelectObject(wxNullBitmap); + return bmp; +} void gGraphWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) { - #if defined(__WXMSW__) +#if defined(__WXMSW__) wxAutoBufferedPaintDC dc(this); - #else +#elif defined (__WXMAC__) + wxGCDC(this); +#else wxPaintDC dc(this); - #endif +#endif GetClientSize(&m_scrX, &m_scrY); dc.SetPen( *wxTRANSPARENT_PEN ); diff --git a/src/graphs/graph.h b/src/graphs/graph.h index d0581c5d..9c7c5849 100644 --- a/src/graphs/graph.h +++ b/src/graphs/graph.h @@ -124,6 +124,8 @@ class gGraphWindow:public wxWindow // rename to gGraphWindow gGraphWindow() {}; gGraphWindow(wxWindow *parent, wxWindowID id,const wxString & title=wxT("Graph"),const wxPoint &pos = wxDefaultPosition,const wxSize &size = wxDefaultSize,long flags = 0); + wxBitmap * RenderBitmap(int width,int height); + virtual ~gGraphWindow(); virtual void OnPaint(wxPaintEvent & event); virtual void OnSize(wxSizeEvent & event); diff --git a/src/version.h b/src/version.h index 4e09afeb..f8421391 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 = 3371; - static const long REVISION = 1550; + static const long BUILD = 3410; + static const long REVISION = 1760; //Miscellaneous Version Types - static const long BUILDS_COUNT = 592; - #define RC_FILEVERSION 0,7,3371,1550 - #define RC_FILEVERSION_STRING "0, 7, 3371, 1550\0" - static const char FULLVERSION_STRING[] = "0.7.3371.1550"; + static const long BUILDS_COUNT = 696; + #define RC_FILEVERSION 0,7,3410,1760 + #define RC_FILEVERSION_STRING "0, 7, 3410, 1760\0" + static const char FULLVERSION_STRING[] = "0.7.3410.1760"; //These values are to keep track of your versioning state, don't modify them. static const long BUILD_HISTORY = 0;
")+_("Wake")+wxT("")+cpap->last().Format(wxT("%H:%M"))+wxT("
")+_("Total Time")+wxT("")+cpap->total_time().Format(wxT("%H:%M hours"))+wxT("
  
")+_("Event Breakdown")+wxT("
")+_("Indices")+wxT("
")+_("AHI")+wxT("")+wxString::Format(wxT("%0.2f"),ahi)+wxT("
")+_("Obstructive")+wxT("")+wxString::Format(wxT("%0.2f"),oai)+wxT("