Added RenderBitmap() to gGraphWindow, AHI experiment..

This commit is contained in:
Mark Watkins 2011-06-07 19:17:22 +10:00
parent 70831ccbe5
commit 845ddfc5d4
8 changed files with 73 additions and 27 deletions

View File

@ -8231,7 +8231,7 @@
<wx/datectrl.h> <wx/datectrl.h>
<wx/dateevt.h> <wx/dateevt.h>
1307418393 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadApp.cpp 1307436744 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadApp.cpp
"wx_pch.h" "wx_pch.h"
<iostream> <iostream>
<wx/log.h> <wx/log.h>
@ -8249,7 +8249,7 @@
1307418393 /home/mark/projects/git/sleepyhead/src/SleepyHeadApp.h 1307418393 /home/mark/projects/git/sleepyhead/src/SleepyHeadApp.h
<wx/app.h> <wx/app.h>
1307418393 /home/mark/projects/git/sleepyhead/src/SleepyHeadMain.h 1307436654 /home/mark/projects/git/sleepyhead/src/SleepyHeadMain.h
<wx/listbox.h> <wx/listbox.h>
<wx/treectrl.h> <wx/treectrl.h>
"SleepyHeadApp.h" "SleepyHeadApp.h"
@ -8291,11 +8291,11 @@
<map> <map>
"tinyxml/tinyxml.h" "tinyxml/tinyxml.h"
1307418393 /home/mark/projects/git/sleepyhead/src/graphs/graph.h 1307436543 /home/mark/projects/git/sleepyhead/src/graphs/graph.h
<sleeplib/machine.h> <sleeplib/machine.h>
<list> <list>
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 1307418393 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/prs1_loader.h
"machine.h" "machine.h"
@ -8312,7 +8312,7 @@
"preferences.h" "preferences.h"
"tinyxml/tinyxml.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" "wx_pch.h"
"version.h" "version.h"
<wx/app.h> <wx/app.h>
@ -8332,7 +8332,7 @@
"sleeplib/profiles.h" "sleeplib/profiles.h"
"sleeplib/machine_loader.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
<wx/settings.h> <wx/settings.h>
<wx/dcbuffer.h> <wx/dcbuffer.h>
<wx/log.h> <wx/log.h>

View File

@ -7,14 +7,14 @@
<File name="../../src/SleepyHeadApp.cpp" open="1" top="0" tabpos="1"> <File name="../../src/SleepyHeadApp.cpp" open="1" top="0" tabpos="1">
<Cursor position="1042" topLine="7" /> <Cursor position="1042" topLine="7" />
</File> </File>
<File name="../../src/SleepyHeadMain.cpp" open="1" top="0" tabpos="2"> <File name="../../src/SleepyHeadMain.cpp" open="1" top="1" tabpos="2">
<Cursor position="28432" topLine="739" /> <Cursor position="5636" topLine="191" />
</File> </File>
<File name="../../src/SleepyHeadMain.h" open="1" top="0" tabpos="3"> <File name="../../src/SleepyHeadMain.h" open="1" top="0" tabpos="3">
<Cursor position="546" topLine="42" /> <Cursor position="546" topLine="42" />
</File> </File>
<File name="../../src/graphs/graph.cpp" open="1" top="1" tabpos="9"> <File name="../../src/graphs/graph.cpp" open="1" top="0" tabpos="9">
<Cursor position="44361" topLine="1657" /> <Cursor position="44361" topLine="1645" />
</File> </File>
<File name="../../src/graphs/graph.h" open="1" top="0" tabpos="10"> <File name="../../src/graphs/graph.h" open="1" top="0" tabpos="10">
<Cursor position="12935" topLine="338" /> <Cursor position="12935" topLine="338" />

View File

@ -47,10 +47,8 @@ bool SleepyHeadApp::OnInit()
wxLogDebug( wxVERSION_STRING ); wxLogDebug( wxVERSION_STRING );
wxLogDebug( wxT("Application Initialze...") ); wxLogDebug( wxT("Application Initialze...") );
// wxFileSystem::AddHandler(new wxMemoryFSHandler);
wxInitAllImageHandlers(); wxInitAllImageHandlers();
wxFileSystem::AddHandler(new wxMemoryFSHandler); // This is damn handy..
//wxDateTime::SetCountry(wxDateTime::USA); //wxDateTime::SetCountry(wxDateTime::USA);
SetAppName(_("SleepyHead")); SetAppName(_("SleepyHead"));

View File

@ -546,7 +546,7 @@ void Summary::OnClose(wxCloseEvent &event)
Daily::Daily(wxWindow *win,Profile *p) Daily::Daily(wxWindow *win,Profile *p)
:DailyPanel(win),profile(p) :DailyPanel(win),profile(p)
{ {
ahi_bmp=NULL;
HTMLInfo=new wxHtmlWindow(this); HTMLInfo=new wxHtmlWindow(this);
EventTree=new wxTreeCtrl(this); EventTree=new wxTreeCtrl(this);
@ -569,8 +569,8 @@ Daily::Daily(wxWindow *win,Profile *p)
TAP_EAP->SetMargins(20,15,5,50); TAP_EAP->SetMargins(20,15,5,50);
TAP_EAP->AddLayer(new gCandleStick(tap_eap)); 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=new gGraphWindow(ScrolledWindow,-1,wxT(""),wxPoint(0,0), wxSize(600,60), wxNO_BORDER); //Event Breakdown")
G_AHI->SetMargins(20,15,5,50); G_AHI->SetMargins(0,2,0,2);
AddCPAPData(g_ahi=new AHIData()); AddCPAPData(g_ahi=new AHIData());
gCandleStick *l=new gCandleStick(g_ahi); gCandleStick *l=new gCandleStick(g_ahi);
l->AddName(wxT("H")); l->AddName(wxT("H"));
@ -681,7 +681,7 @@ Daily::Daily(wxWindow *win,Profile *p)
fgSizer->Add(LEAK,1,wxEXPAND); fgSizer->Add(LEAK,1,wxEXPAND);
fgSizer->Add(PULSE,1,wxEXPAND); fgSizer->Add(PULSE,1,wxEXPAND);
fgSizer->Add(SPO2,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,1,wxEXPAND);
fgSizer->Add(TAP_IAP,1,wxEXPAND); fgSizer->Add(TAP_IAP,1,wxEXPAND);
fgSizer->Add(TAP_EAP,1,wxEXPAND); fgSizer->Add(TAP_EAP,1,wxEXPAND);
@ -691,6 +691,11 @@ Daily::Daily(wxWindow *win,Profile *p)
} }
Daily::~Daily() 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); this->Disconnect(wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( Daily::OnEventTreeSelection), NULL, this);
} }
void Daily::OnClose(wxCloseEvent &event) void Daily::OnClose(wxCloseEvent &event)
@ -741,7 +746,7 @@ void Daily::RefreshData()
if (cpap) UpdateCPAPGraphs(cpap); if (cpap) UpdateCPAPGraphs(cpap);
if (oxi) UpdateOXIGraphs(oxi); if (oxi) UpdateOXIGraphs(oxi);
wxString html=wxT("<html><body leftmargin=0 rightmargin=0 topmargin=0 marginwidth=0 marginheight=0><table cellspacing=2 cellpadding=0 width='100%'>\n"); wxString html=wxT("<html><body leftmargin=0 rightmargin=0 topmargin=0 marginwidth=0 marginheight=0><table cellspacing=0 cellpadding=0 border=0 width='100%'>\n");
CPAPMode mode; CPAPMode mode;
if (cpap) { if (cpap) {
@ -784,6 +789,15 @@ void Daily::RefreshData()
EventTree->SortChildren(root); EventTree->SortChildren(root);
EventTree->Expand(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); PRTypes pr=(PRTypes)cpap->summary_max(CPAP_PressureReliefType);
wxString epr=PressureReliefNames[pr]+wxString::Format(wxT(" x%i"),(int)cpap->summary_max(CPAP_PressureReliefSetting)); 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("<tr><td><b>")+_("Wake")+wxT("</b></td><td>")+cpap->last().Format(wxT("%H:%M"))+wxT("</td></tr>\n"); html=html+wxT("<tr><td><b>")+_("Wake")+wxT("</b></td><td>")+cpap->last().Format(wxT("%H:%M"))+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("Total Time")+wxT("</b></td><td><i>")+cpap->total_time().Format(wxT("%H:%M&nbsp;hours"))+wxT("</i></td></tr>\n"); html=html+wxT("<tr><td><b>")+_("Total Time")+wxT("</b></td><td><i>")+cpap->total_time().Format(wxT("%H:%M&nbsp;hours"))+wxT("</i></td></tr>\n");
html=html+wxT("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n"); html=html+wxT("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n");
html=html+wxT("<tr><td colspan=2 align=center><i>")+_("Event Breakdown")+wxT("</i></td></tr>\n");
html=html+wxT("<tr><td colspan=2 align=center cellspacing=0 cellpadding=0><img src=\"memory:ahi.png\" ></td></tr>\n");
html=html+wxT("<tr><td colspan=2 align=center><i>")+_("Indices")+wxT("</i></td></tr>\n"); html=html+wxT("<tr><td colspan=2 align=center><i>")+_("Indices")+wxT("</i></td></tr>\n");
html=html+wxT("<tr><td><b>")+_("AHI")+wxT("</b></td><td>")+wxString::Format(wxT("%0.2f"),ahi)+wxT("</td></tr>\n"); html=html+wxT("<tr><td><b>")+_("AHI")+wxT("</b></td><td>")+wxString::Format(wxT("%0.2f"),ahi)+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("Obstructive")+wxT("</b></td><td>")+wxString::Format(wxT("%0.2f"),oai)+wxT("</td></tr>\n"); html=html+wxT("<tr><td><b>")+_("Obstructive")+wxT("</b></td><td>")+wxString::Format(wxT("%0.2f"),oai)+wxT("</td></tr>\n");

View File

@ -83,6 +83,8 @@ protected:
wxHtmlWindow *HTMLInfo; wxHtmlWindow *HTMLInfo;
wxTreeCtrl *EventTree; wxTreeCtrl *EventTree;
wxBitmap *ahi_bmp;
}; };
const wxEventType wxEVT_DO_SCREENSHOT = wxNewEventType(); const wxEventType wxEVT_DO_SCREENSHOT = wxNewEventType();

View File

@ -375,14 +375,42 @@ void gGraphWindow::SetMargins(int top, int right, int bottom, int left)
m_marginRight=right; 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<gLayer *>::iterator l=layers.begin();l!=layers.end();l++) {
(*l)->Plot(dc,*this);
}
dc.SelectObject(wxNullBitmap);
return bmp;
}
void gGraphWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) void gGraphWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
{ {
#if defined(__WXMSW__) #if defined(__WXMSW__)
wxAutoBufferedPaintDC dc(this); wxAutoBufferedPaintDC dc(this);
#else #elif defined (__WXMAC__)
wxGCDC(this);
#else
wxPaintDC dc(this); wxPaintDC dc(this);
#endif #endif
GetClientSize(&m_scrX, &m_scrY); GetClientSize(&m_scrX, &m_scrY);
dc.SetPen( *wxTRANSPARENT_PEN ); dc.SetPen( *wxTRANSPARENT_PEN );

View File

@ -124,6 +124,8 @@ class gGraphWindow:public wxWindow // rename to gGraphWindow
gGraphWindow() {}; gGraphWindow() {};
gGraphWindow(wxWindow *parent, wxWindowID id,const wxString & title=wxT("Graph"),const wxPoint &pos = wxDefaultPosition,const wxSize &size = wxDefaultSize,long flags = 0); 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 ~gGraphWindow();
virtual void OnPaint(wxPaintEvent & event); virtual void OnPaint(wxPaintEvent & event);
virtual void OnSize(wxSizeEvent & event); virtual void OnSize(wxSizeEvent & event);

View File

@ -16,14 +16,14 @@ namespace AutoVersion{
//Standard Version Type //Standard Version Type
static const long MAJOR = 0; static const long MAJOR = 0;
static const long MINOR = 7; static const long MINOR = 7;
static const long BUILD = 3371; static const long BUILD = 3410;
static const long REVISION = 1550; static const long REVISION = 1760;
//Miscellaneous Version Types //Miscellaneous Version Types
static const long BUILDS_COUNT = 592; static const long BUILDS_COUNT = 696;
#define RC_FILEVERSION 0,7,3371,1550 #define RC_FILEVERSION 0,7,3410,1760
#define RC_FILEVERSION_STRING "0, 7, 3371, 1550\0" #define RC_FILEVERSION_STRING "0, 7, 3410, 1760\0"
static const char FULLVERSION_STRING[] = "0.7.3371.1550"; static const char FULLVERSION_STRING[] = "0.7.3410.1760";
//These values are to keep track of your versioning state, don't modify them. //These values are to keep track of your versioning state, don't modify them.
static const long BUILD_HISTORY = 0; static const long BUILD_HISTORY = 0;