2011-05-26 13:59:21 +00:00
/***************************************************************
* Name : SleepyHeadMain . cpp
* Purpose : Code for Application Frame
* Author : Mark Watkins ( jedimark64 @ users . sourceforge . net )
* Created : 2011 - 05 - 20
* Copyright : Mark Watkins ( http : //sourceforge.net/projects/sleepyhead/)
* License : GPL
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# ifdef WX_PRECOMP
# include "wx_pch.h"
# endif
# ifdef __BORLANDC__
# pragma hdrstop
# endif //__BORLANDC__
# include "version.h"
# include <wx/app.h>
2011-05-30 22:53:48 +00:00
# include <wx/icon.h>
2011-06-06 06:46:05 +00:00
# include <wx/aboutdlg.h>
2011-05-26 13:59:21 +00:00
# include <wx/msgdlg.h>
# include <wx/dirdlg.h>
# include <wx/progdlg.h>
2011-05-27 04:13:16 +00:00
# include <wx/bitmap.h>
# include <wx/log.h>
# include <wx/dcscreen.h>
2011-05-28 05:38:43 +00:00
# include <wx/dcmemory.h>
# include <wx/filedlg.h>
2011-05-30 11:59:20 +00:00
# include <wx/fs_mem.h>
2011-06-01 13:08:44 +00:00
# include <wx/aui/aui.h>
2011-05-30 11:59:20 +00:00
# include "SleepyHeadMain.h"
2011-05-26 13:59:21 +00:00
# include "sleeplib/profiles.h"
2011-05-31 02:18:41 +00:00
# include "sleeplib/machine_loader.h"
2011-05-26 13:59:21 +00:00
2011-06-10 15:37:19 +00:00
// Gets rid of the GDIPLUS requirement
// But does it screw up windows drawing abilities?
//#if defined(__WXMSW__)
//extern "C" void *_GdipStringFormatCachedGenericTypographic = NULL;
//#endif
2011-05-26 13:59:21 +00:00
wxProgressDialog * loader_progress ;
//helper functions
enum wxbuildinfoformat {
short_f , long_f } ;
wxString wxbuildinfo ( wxbuildinfoformat format )
{
wxString wxbuild ( wxVERSION_STRING ) ;
if ( format = = long_f )
{
# if defined(__WXMSW__)
wxbuild < < _T ( " -Windows " ) ;
# elif defined(__WXMAC__)
wxbuild < < _T ( " -Mac " ) ;
# elif defined(__UNIX__)
wxbuild < < _T ( " -Linux " ) ;
# endif
# if wxUSE_UNICODE
wxbuild < < _T ( " -Unicode build " ) ;
# else
wxbuild < < _T ( " -ANSI build " ) ;
# endif // wxUSE_UNICODE
}
return wxbuild ;
}
2011-05-27 04:13:16 +00:00
2011-06-09 13:49:13 +00:00
const long profile_version = 0 ;
2011-05-26 13:59:21 +00:00
SleepyHeadFrame : : SleepyHeadFrame ( wxFrame * frame )
: GUIFrame ( frame )
{
2011-06-09 02:47:03 +00:00
GraphInit ( ) ;
2011-05-26 13:59:21 +00:00
wxString title = wxTheApp - > GetAppName ( ) + wxT ( " v " ) + wxString ( AutoVersion : : FULLVERSION_STRING , wxConvUTF8 ) ;
SetTitle ( title ) ;
2011-05-28 13:02:39 +00:00
profile = Profiles : : Get ( ) ;
if ( ! profile ) {
wxLogError ( wxT ( " Couldn't get active profile " ) ) ;
abort ( ) ;
}
2011-05-30 11:59:20 +00:00
UpdateProfiles ( ) ;
2011-06-07 20:40:53 +00:00
if ( ! pref . Exists ( " ShowSerialNumbers " ) ) pref [ " ShowSerialNumbers " ] = false ;
if ( ! pref . Exists ( " fruitsalad " ) ) pref [ " fruitsalad " ] = true ;
2011-06-09 13:49:13 +00:00
if ( ! pref . Exists ( " LinkGraphMovement " ) ) pref [ " LinkGraphMovement " ] = true ;
2011-06-10 12:28:20 +00:00
if ( ! pref . Exists ( " UseAntiAliasing " ) ) pref [ " UseAntiAliasing " ] = false ;
2011-06-09 13:49:13 +00:00
if ( ! pref . Exists ( " ProfileVersion " ) ) pref [ " ProfileVersion " ] = ( long ) 0 ;
if ( pref [ " ProfileVersion " ] . GetInteger ( ) < profile_version ) {
if ( wxMessageBox ( title + wxT ( " \n \n Changes have been made that require the profiles database to be recreated \n \n Would you like to do this right now? " ) , wxT ( " Profile Database Changes " ) , wxYES_NO , this ) = = wxYES ) {
// Delete all machines from memory.
pref [ " ProfileVersion " ] = profile_version ;
// assert(1==0);
}
}
2011-06-07 20:40:53 +00:00
ViewMenuSerial - > Check ( pref [ " ShowSerialNumbers " ] ) ;
ViewMenuFruitsalad - > Check ( pref [ " fruitsalad " ] ) ;
2011-06-09 13:49:13 +00:00
ViewMenuLinkGraph - > Check ( pref [ " LinkGraphMovement " ] ) ;
2011-06-10 12:28:20 +00:00
ViewMenuAntiAliasing - > Check ( pref [ " UseAntiAliasing " ] ) ;
2011-05-28 13:02:39 +00:00
2011-06-04 03:44:30 +00:00
// wxDisableAsserts();
2011-05-26 13:59:21 +00:00
// Create AUINotebook Tabs
wxCommandEvent dummy ;
2011-05-28 09:16:46 +00:00
OnViewMenuSummary ( dummy ) ; // Summary Page
2011-05-30 11:59:20 +00:00
OnViewMenuDaily ( dummy ) ; // Daily Page
2011-05-27 04:13:16 +00:00
this - > Connect ( wxID_ANY , wxEVT_DO_SCREENSHOT , wxCommandEventHandler ( SleepyHeadFrame : : DoScreenshot ) ) ;
2011-05-26 13:59:21 +00:00
# if wxUSE_STATUSBAR
//statusBar->SetStatusText(_("Hello!"), 0);
statusBar - > SetStatusText ( wxbuildinfo ( long_f ) , 1 ) ;
# endif
}
SleepyHeadFrame : : ~ SleepyHeadFrame ( )
{
2011-06-09 02:47:03 +00:00
GraphDone ( ) ;
2011-05-26 13:59:21 +00:00
}
2011-05-30 11:59:20 +00:00
void SleepyHeadFrame : : UpdateProfiles ( )
2011-05-28 13:02:39 +00:00
{
2011-05-30 11:59:20 +00:00
wxMenuItemList z = ProfileMenu - > GetMenuItems ( ) ;
2011-05-28 13:02:39 +00:00
2011-05-30 11:59:20 +00:00
int i = ProfileMenuID ;
for ( unsigned int j = 0 ; j < z . size ( ) ; j + + ) {
2011-05-29 11:11:48 +00:00
wxMenuItem * mi = z [ j ] ;
2011-05-30 11:59:20 +00:00
this - > Disconnect ( i , wxEVT_COMMAND_MENU_SELECTED , wxCommandEventHandler ( SleepyHeadFrame : : OnProfileSelected ) ) ;
ProfileMenu - > Remove ( mi ) ;
2011-05-28 13:02:39 +00:00
i + + ;
}
2011-05-30 11:59:20 +00:00
i = ProfileMenuID ;
2011-05-28 13:02:39 +00:00
2011-06-02 04:42:37 +00:00
for ( map < wxString , Profile * > : : iterator p = Profiles : : profiles . begin ( ) ; p ! = Profiles : : profiles . end ( ) ; p + + ) {
2011-05-30 11:59:20 +00:00
Profile & pro = * ( Profiles : : profiles [ p - > first ] ) ;
wxMenuItem * item = ProfileMenu - > AppendRadioItem ( i , pro [ " Realname " ] , wxEmptyString ) ;
2011-05-28 13:02:39 +00:00
2011-05-30 11:59:20 +00:00
if ( p - > first = = pref [ " Profile " ] . GetString ( ) ) {
item - > Check ( true ) ;
}
2011-05-28 13:02:39 +00:00
2011-05-30 11:59:20 +00:00
this - > Connect ( i , wxEVT_COMMAND_MENU_SELECTED , wxCommandEventHandler ( SleepyHeadFrame : : OnProfileSelected ) ) ;
i + + ;
}
2011-05-28 13:02:39 +00:00
}
2011-05-26 13:59:21 +00:00
void SleepyHeadFrame : : OnClose ( wxCloseEvent & event )
{
2011-05-31 02:18:41 +00:00
int idx = main_auinotebook - > GetPageIndex ( daily ) ;
if ( idx ! = wxNOT_FOUND ) {
daily - > Close ( ) ;
}
idx = main_auinotebook - > GetPageIndex ( summary ) ;
if ( idx ! = wxNOT_FOUND ) {
summary - > Close ( ) ;
}
//delete summary
wxMenuItemList z = ProfileMenu - > GetMenuItems ( ) ;
int i = ProfileMenuID ;
for ( unsigned int j = 0 ; j < z . size ( ) ; j + + ) {
wxMenuItem * mi = z [ j ] ;
this - > Disconnect ( i , wxEVT_COMMAND_MENU_SELECTED , wxCommandEventHandler ( SleepyHeadFrame : : OnProfileSelected ) ) ;
ProfileMenu - > Remove ( mi ) ;
i + + ;
}
this - > Disconnect ( wxID_ANY , wxEVT_DO_SCREENSHOT , wxCommandEventHandler ( SleepyHeadFrame : : DoScreenshot ) ) ;
2011-05-26 13:59:21 +00:00
Destroy ( ) ;
}
void SleepyHeadFrame : : OnQuit ( wxCommandEvent & event )
{
Destroy ( ) ;
2011-05-27 04:13:16 +00:00
}
2011-05-28 05:38:43 +00:00
void SleepyHeadFrame : : OnFullscreen ( wxCommandEvent & event )
{
if ( ! IsFullScreen ( ) ) {
ShowFullScreen ( true , wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION | wxFULLSCREEN_NOSTATUSBAR ) ;
} else {
ShowFullScreen ( false ) ;
}
}
2011-05-30 11:59:20 +00:00
void SleepyHeadFrame : : OnProfileSelected ( wxCommandEvent & event )
2011-05-28 13:02:39 +00:00
{
2011-05-30 11:59:20 +00:00
int id = event . GetId ( ) - ProfileMenuID ;
2011-05-29 11:11:48 +00:00
2011-05-30 11:59:20 +00:00
wxLogMessage ( wxT ( " Profile Selected: " ) + wxString : : Format ( wxT ( " %i " ) , id ) ) ;
/*Machine *m=cpap_machines[id];
2011-05-28 13:02:39 +00:00
if ( m ) {
pref [ wxT ( " DefaultMachine " ) ] = ( long ) id ;
}
int idx = main_auinotebook - > GetPageIndex ( daily ) ;
if ( idx ! = wxNOT_FOUND ) {
daily - > RefreshData ( m ) ;
2011-05-29 06:10:32 +00:00
daily - > Refresh ( ) ;
2011-05-28 13:02:39 +00:00
}
idx = main_auinotebook - > GetPageIndex ( summary ) ;
if ( idx ! = wxNOT_FOUND ) {
2011-05-30 11:59:20 +00:00
summary - > ResetProfile ( profile )
2011-05-29 06:10:32 +00:00
summary - > Refresh ( ) ;
2011-05-30 11:59:20 +00:00
} */
//event.Skip();
2011-05-29 06:10:32 +00:00
//Refresh();
2011-05-28 13:02:39 +00:00
}
2011-05-27 04:13:16 +00:00
void SleepyHeadFrame : : OnScreenshot ( wxCommandEvent & event )
{
2011-05-27 08:22:24 +00:00
ToolsMenu - > UpdateUI ( ) ;
//wxWindow::DoUpdateWindowUI();
wxWindow : : UpdateWindowUI ( ) ;
2011-06-04 03:44:30 +00:00
// TODO: Make sure the menu is closed.. (It pushes the Update event in front of the manual event we push next)
2011-05-27 08:22:24 +00:00
2011-05-27 04:13:16 +00:00
wxCommandEvent MyEvent ( wxEVT_DO_SCREENSHOT ) ;
wxPostEvent ( this , MyEvent ) ;
}
2011-05-29 03:27:42 +00:00
void SleepyHeadFrame : : DoScreenshot ( wxCommandEvent & event )
{
wxRect r = GetRect ( ) ;
2011-06-07 05:47:17 +00:00
# if defined(__UNIX__)
// Height of statusbar needs adding in
wxRect j = statusBar - > GetRect ( ) ;
r . height + = j . height ;
2011-05-29 03:27:42 +00:00
# endif
2011-06-07 06:53:29 +00:00
# if defined(__WXMAC__)
wxMessageBox ( wxT ( " Sorry.. Screenshots don't work on your platform. \n \n Please use your Mac's screenshot capability instead. " ) , wxT ( " Naughty Apple! " ) , wxICON_EXCLAMATION , this ) ;
# else
2011-05-29 03:27:42 +00:00
wxScreenDC sdc ;
wxMemoryDC mdc ;
wxBitmap bmp ( r . width , r . height , - 1 ) ;
//wxBitMap *bmp=wxEmptyImage(r.width,r.height);
mdc . SelectObject ( bmp ) ;
mdc . Blit ( ( wxCoord ) 0 , ( wxCoord ) 0 , ( wxCoord ) r . width , ( wxCoord ) r . height , & sdc , ( wxCoord ) r . x , ( wxCoord ) r . y ) ;
mdc . SelectObject ( wxNullBitmap ) ;
wxDateTime d = wxDateTime : : Now ( ) ;
// wxDirDialog sfs(this,_("Choose a Directory")); //,wxT(""),wxT(""),style=wxFD_OPEN);
wxString filename = wxSaveFileSelector ( _ ( " Please give a filename for the screenshot " ) , wxT ( " png " ) , wxT ( " Sleepyhead- " ) + d . Format ( wxT ( " %Y%m%d-%H%M%S " ) ) , this ) ;
if ( ! filename . IsEmpty ( ) ) {
if ( ! filename . Lower ( ) . EndsWith ( wxT ( " .png " ) ) ) filename + = wxT ( " .png " ) ;
wxImage img = bmp . ConvertToImage ( ) ;
if ( ! img . SaveFile ( filename , wxBITMAP_TYPE_PNG ) ) {
wxLogError ( wxT ( " Couldn't save screenshot " ) + filename ) ;
}
}
2011-06-07 06:53:29 +00:00
# endif
2011-05-29 03:27:42 +00:00
}
2011-06-09 13:49:13 +00:00
void SleepyHeadFrame : : OnLinkGraphs ( wxCommandEvent & event )
{
pref [ " LinkGraphMovement " ] = event . IsChecked ( ) ;
}
2011-05-30 11:59:20 +00:00
void SleepyHeadFrame : : OnShowSerial ( wxCommandEvent & event )
{
pref [ " ShowSerialNumbers " ] = event . IsChecked ( ) ;
}
2011-06-07 18:15:21 +00:00
void SleepyHeadFrame : : OnFruitsalad ( wxCommandEvent & event )
{
pref [ " fruitsalad " ] = event . IsChecked ( ) ;
2011-06-10 12:28:20 +00:00
Refresh ( ) ;
}
void SleepyHeadFrame : : OnAntiAliasing ( wxCommandEvent & event )
{
pref [ " UseAntiAliasing " ] = event . IsChecked ( ) ;
Refresh ( ) ;
2011-06-07 18:15:21 +00:00
}
2011-05-26 13:59:21 +00:00
void SleepyHeadFrame : : OnAbout ( wxCommandEvent & event )
{
2011-06-06 06:46:05 +00:00
// wxAboutBox is fairly useless.
wxString day = wxString ( AutoVersion : : DATE , wxConvUTF8 ) ;
wxString month = wxString ( AutoVersion : : MONTH , wxConvUTF8 ) ;
wxString year = wxString ( AutoVersion : : YEAR , wxConvUTF8 ) ;
wxString date = day + wxT ( " / " ) + month + wxT ( " / " ) + year ;
wxString msg = wxTheApp - > GetAppName ( ) + wxT ( " v " ) + wxString ( AutoVersion : : FULLVERSION_STRING , wxConvUTF8 ) + _ ( " alpha preview " ) + date + _ ( " \n \n " ) + wxT ( " \u00a9 " ) + _ ( " 2011 Mark Watkins & Troy Schultz \n \n " ) ;
msg + = _ ( " Website: http://sleepyhead.sourceforge.net \n \n " ) ;
msg + = _ ( " License: GNU Public License (GPL) \n \n " ) ;
msg + = _ ( " This software is under active development, and is guaranteed to break and change regularly! Use at your own risk. \n \n " ) ;
msg + = _ ( " Relying on this softwares' accuracy for making personal medical decisions is probably grounds to get you committed. Please don't do it! \n \n " ) ;
msg + = _ ( " Combinations of letters which form those of trademarks belong to those who own them. " ) ;
2011-05-26 13:59:21 +00:00
2011-06-08 10:36:52 +00:00
wxMessageBox ( msg , _ ( " Welcome to... " ) , wxOK , this ) ;
2011-05-26 13:59:21 +00:00
}
void SleepyHeadFrame : : OnImportSD ( wxCommandEvent & event )
{
wxDirDialog dd ( this , _ ( " Choose a Directory " ) ) ; //,wxT(""),wxT(""),style=wxFD_OPEN);
2011-05-28 13:02:39 +00:00
if ( dd . ShowModal ( ) ! = wxID_OK ) return ;
2011-05-31 02:18:41 +00:00
2011-06-06 06:46:05 +00:00
loader_progress = new wxProgressDialog ( _ ( " SleepyHead " ) , _ ( " Please Wait... " ) , 100 , this , wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_SMOOTH ) ;
2011-05-31 02:18:41 +00:00
loader_progress - > Hide ( ) ;
2011-05-28 13:02:39 +00:00
wxString path = dd . GetPath ( ) ;
loader_progress - > Update ( 0 ) ;
loader_progress - > Show ( ) ;
profile - > Import ( path ) ;
loader_progress - > Update ( 100 ) ;
loader_progress - > Show ( false ) ;
2011-05-31 02:18:41 +00:00
loader_progress - > Destroy ( ) ;
loader_progress = NULL ;
2011-05-28 13:02:39 +00:00
2011-05-26 13:59:21 +00:00
int idx = main_auinotebook - > GetPageIndex ( daily ) ;
if ( idx ! = wxNOT_FOUND ) {
2011-05-30 11:59:20 +00:00
daily - > ResetDate ( ) ;
daily - > RefreshData ( ) ;
2011-05-29 07:00:13 +00:00
daily - > Refresh ( ) ;
2011-05-26 13:59:21 +00:00
}
idx = main_auinotebook - > GetPageIndex ( summary ) ;
if ( idx ! = wxNOT_FOUND ) {
2011-05-30 11:59:20 +00:00
summary - > ResetProfile ( profile ) ; // resets the date ranges..
summary - > RefreshData ( ) ;
2011-05-29 07:00:13 +00:00
summary - > Refresh ( ) ;
2011-05-26 13:59:21 +00:00
}
2011-05-28 13:02:39 +00:00
2011-05-26 13:59:21 +00:00
}
void SleepyHeadFrame : : OnViewMenuDaily ( wxCommandEvent & event )
{
int idx = main_auinotebook - > GetPageIndex ( daily ) ;
if ( idx = = wxNOT_FOUND ) {
2011-05-30 11:59:20 +00:00
daily = new Daily ( this , profile ) ;
2011-06-08 09:14:55 +00:00
main_auinotebook - > AddPage ( daily , _ ( " Daily " ) , true , wxNullBitmap ) ;
2011-05-30 11:59:20 +00:00
daily - > RefreshData ( ) ;
2011-05-29 06:10:32 +00:00
daily - > Refresh ( ) ;
2011-05-26 13:59:21 +00:00
} else {
main_auinotebook - > SetSelection ( idx ) ;
}
2011-05-29 06:10:32 +00:00
2011-05-26 13:59:21 +00:00
}
void SleepyHeadFrame : : OnViewMenuSummary ( wxCommandEvent & event )
{
2011-05-29 06:10:32 +00:00
2011-06-04 02:38:18 +00:00
int idx = main_auinotebook - > GetPageIndex ( summary ) ;
2011-05-26 13:59:21 +00:00
if ( idx = = wxNOT_FOUND ) {
2011-05-30 11:59:20 +00:00
summary = new Summary ( this , profile ) ;
2011-06-08 09:14:55 +00:00
main_auinotebook - > AddPage ( summary , _ ( " Summary " ) , true , wxNullBitmap ) ;
2011-05-30 11:59:20 +00:00
summary - > ResetProfile ( profile ) ;
summary - > RefreshData ( ) ;
2011-05-29 06:10:32 +00:00
summary - > Refresh ( ) ;
2011-05-26 13:59:21 +00:00
} else {
main_auinotebook - > SetSelection ( idx ) ;
}
}
2011-05-30 11:59:20 +00:00
Summary : : Summary ( wxWindow * win , Profile * _profile )
: SummaryPanel ( win ) , profile ( _profile )
2011-05-26 13:59:21 +00:00
{
2011-05-30 11:59:20 +00:00
AddData ( ahidata = new HistoryData ( profile ) ) ;
AddData ( pressure = new HistoryCodeData ( profile , CPAP_PressureAverage ) ) ;
2011-06-03 07:06:18 +00:00
AddData ( pressure_min = new HistoryCodeData ( profile , CPAP_PressureMin ) ) ;
AddData ( pressure_max = new HistoryCodeData ( profile , CPAP_PressureMax ) ) ;
2011-06-01 13:08:44 +00:00
2011-06-03 07:06:18 +00:00
AddData ( pressure_eap = new HistoryCodeData ( profile , BIPAP_EAPAverage ) ) ;
AddData ( pressure_iap = new HistoryCodeData ( profile , BIPAP_IAPAverage ) ) ;
2011-05-28 09:16:46 +00:00
2011-06-03 07:06:18 +00:00
// pressure->ForceMinY(3);
// pressure->ForceMaxY(12);
2011-05-30 11:59:20 +00:00
AddData ( leak = new HistoryCodeData ( profile , CPAP_LeakMedian ) ) ;
AddData ( usage = new UsageHistoryData ( profile , UHD_Hours ) ) ;
AddData ( waketime = new UsageHistoryData ( profile , UHD_Waketime ) ) ;
AddData ( bedtime = new UsageHistoryData ( profile , UHD_Bedtime ) ) ;
2011-05-28 09:16:46 +00:00
2011-06-03 07:06:18 +00:00
AHI = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " AHI " ) , wxPoint ( 0 , 0 ) , wxSize ( 400 , 180 ) , wxNO_BORDER ) ;
2011-05-31 04:28:11 +00:00
AHI - > SetMargins ( 10 , 15 , 65 , 80 ) ;
2011-06-09 02:47:03 +00:00
AHI - > AddLayer ( new gFooBar ( ) ) ;
AHI - > AddLayer ( new gYAxis ( wxBLACK ) ) ;
2011-05-26 13:59:21 +00:00
AHI - > AddLayer ( new gBarChart ( ahidata , wxRED ) ) ;
2011-05-30 22:53:48 +00:00
// AHI->AddLayer(new gXAxis(NULL,wxBLACK));
2011-05-28 09:16:46 +00:00
//AHI->AddLayer(new gLineChart(ahidata,wxRED));
2011-05-26 13:59:21 +00:00
fgSizer - > Add ( AHI , 1 , wxEXPAND ) ;
2011-06-03 07:06:18 +00:00
PRESSURE = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " Pressure " ) , wxPoint ( 0 , 0 ) , wxSize ( 400 , 180 ) , wxNO_BORDER ) ;
2011-05-31 04:28:11 +00:00
PRESSURE - > SetMargins ( 10 , 15 , 65 , 80 ) ;
2011-06-01 13:08:44 +00:00
PRESSURE - > AddLayer ( new gYAxis ( wxBLACK ) ) ;
2011-05-31 04:50:06 +00:00
PRESSURE - > AddLayer ( new gXAxis ( wxBLACK ) ) ;
2011-06-09 02:47:03 +00:00
PRESSURE - > AddLayer ( new gFooBar ( ) ) ;
2011-06-03 07:06:18 +00:00
PRESSURE - > AddLayer ( prmax = new gLineChart ( pressure_max , wxBLUE , 6192 , false , true , true ) ) ;
PRESSURE - > AddLayer ( prmin = new gLineChart ( pressure_min , wxRED , 6192 , false , true , true ) ) ;
PRESSURE - > AddLayer ( eap = new gLineChart ( pressure_eap , wxBLUE , 6192 , false , true , true ) ) ;
PRESSURE - > AddLayer ( iap = new gLineChart ( pressure_iap , wxRED , 6192 , false , true , true ) ) ;
PRESSURE - > AddLayer ( pr = new gLineChart ( pressure , wxDARK_GREEN , 6192 , false , true , true ) ) ;
2011-05-30 22:53:48 +00:00
2011-05-26 13:59:21 +00:00
fgSizer - > Add ( PRESSURE , 1 , wxEXPAND ) ;
2011-06-03 07:06:18 +00:00
LEAK = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " Mask Leak " ) , wxPoint ( 0 , 0 ) , wxSize ( 400 , 180 ) , wxNO_BORDER ) ;
2011-05-31 04:28:11 +00:00
LEAK - > SetMargins ( 10 , 15 , 65 , 80 ) ;
2011-05-28 09:16:46 +00:00
//LEAK->AddLayer(new gBarChart(leak,wxYELLOW));
2011-05-31 04:50:06 +00:00
LEAK - > AddLayer ( new gXAxis ( wxBLACK ) ) ;
2011-06-09 02:47:03 +00:00
LEAK - > AddLayer ( new gYAxis ( wxBLACK ) ) ;
LEAK - > AddLayer ( new gFooBar ( ) ) ;
2011-06-01 13:08:44 +00:00
LEAK - > AddLayer ( new gLineChart ( leak , wxPURPLE , 6192 , false , false , true ) ) ;
2011-05-26 13:59:21 +00:00
fgSizer - > Add ( LEAK , 1 , wxEXPAND ) ;
2011-05-27 14:07:35 +00:00
2011-06-03 07:06:18 +00:00
USAGE = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " Usage (Hours) " ) , wxPoint ( 0 , 0 ) , wxSize ( 400 , 180 ) , wxNO_BORDER ) ;
2011-05-31 04:28:11 +00:00
USAGE - > SetMargins ( 10 , 15 , 65 , 80 ) ;
2011-06-09 02:47:03 +00:00
USAGE - > AddLayer ( new gFooBar ( ) ) ;
USAGE - > AddLayer ( new gYAxis ( wxBLACK ) ) ;
2011-05-27 14:07:35 +00:00
USAGE - > AddLayer ( new gBarChart ( usage , wxGREEN ) ) ;
2011-05-31 04:50:06 +00:00
//USAGE->AddLayer(new gXAxis(wxBLACK));
2011-05-30 22:53:48 +00:00
2011-05-28 09:16:46 +00:00
//USAGE->AddLayer(new gLineChart(usage,wxGREEN));
2011-05-27 14:07:35 +00:00
fgSizer - > Add ( USAGE , 1 , wxEXPAND ) ;
2011-05-30 11:59:20 +00:00
// Logo.LoadFile(wxT("./pic.png"));
//wxMemoryFSHandler::AddFile(_T("test.png"), Logo, wxBITMAP_TYPE_PNG);
2011-05-28 13:02:39 +00:00
// RefreshData();
2011-06-03 07:06:18 +00:00
dummyday = new Day ( NULL ) ;
2011-05-26 13:59:21 +00:00
}
Summary : : ~ Summary ( )
{
2011-06-03 07:06:18 +00:00
delete dummyday ;
2011-05-30 13:11:29 +00:00
// wxMemoryFSHandler::RemoveFile(_T("test.png"));
2011-05-26 13:59:21 +00:00
}
2011-05-30 11:59:20 +00:00
void Summary : : ResetProfile ( Profile * p )
{
profile = p ;
2011-06-01 15:35:20 +00:00
2011-05-30 11:59:20 +00:00
if ( profile - > FirstDay ( ) . IsValid ( ) ) {
2011-06-03 08:12:00 +00:00
wxDateTime last = profile - > LastDay ( ) + wxTimeSpan : : Day ( ) ;
wxDateTime first = profile - > FirstDay ( ) + wxTimeSpan : : Day ( ) ;
wxDateTime start = last - wxTimeSpan : : Days ( 30 ) ;
StartDatePicker - > SetRange ( first , last ) ;
EndDatePicker - > SetRange ( first , last ) ;
if ( start < first ) start = first ;
StartDatePicker - > SetValue ( start ) ;
EndDatePicker - > SetValue ( last ) ;
2011-06-02 04:42:37 +00:00
for ( list < HistoryData * > : : iterator h = Data . begin ( ) ; h ! = Data . end ( ) ; h + + ) {
2011-06-01 15:35:20 +00:00
( * h ) - > SetProfile ( p ) ;
( * h ) - > ResetDateRange ( ) ;
2011-06-03 08:12:00 +00:00
( * h ) - > Reload ( NULL ) ;
2011-06-01 15:35:20 +00:00
}
2011-05-30 11:59:20 +00:00
}
2011-06-01 15:35:20 +00:00
2011-05-30 11:59:20 +00:00
}
void Summary : : RefreshData ( )
2011-05-26 13:59:21 +00:00
{
2011-06-04 03:18:11 +00:00
wxDateTime first = StartDatePicker - > GetValue ( ) - wxTimeSpan : : Day ( ) ;
2011-06-03 08:12:00 +00:00
wxDateTime last = EndDatePicker - > GetValue ( ) ;
2011-06-02 04:42:37 +00:00
for ( list < HistoryData * > : : iterator h = Data . begin ( ) ; h ! = Data . end ( ) ; h + + ) {
2011-06-03 08:12:00 +00:00
//(*h)->Update(dummyday);
( * h ) - > SetDateRange ( first , last ) ;
2011-05-27 14:07:35 +00:00
}
2011-05-26 13:59:21 +00:00
wxString submodel = _ ( " Unknown Model " ) ;
double ahi = ahidata - > GetAverage ( ) ;
double avp = pressure - > GetAverage ( ) ;
2011-06-01 13:08:44 +00:00
double apmin = pressure_min - > GetAverage ( ) ;
double apmax = pressure_max - > GetAverage ( ) ;
double aeap = pressure_eap - > GetAverage ( ) ;
double aiap = pressure_iap - > GetAverage ( ) ;
2011-05-27 14:07:35 +00:00
double bt = fmod ( bedtime - > GetAverage ( ) , 12.0 ) ;
double ua = usage - > GetAverage ( ) ;
2011-05-28 05:38:43 +00:00
double wt = waketime - > GetAverage ( ) ; //fmod(bt+ua,12.0);
2011-05-26 13:59:21 +00:00
2011-05-30 11:59:20 +00:00
wxString html = wxT ( " <html><body leftmargin=0 rightmargin=0 topmargin=0 marginwidth=0 marginheight=0> " ) ;
2011-05-26 13:59:21 +00:00
2011-05-30 11:59:20 +00:00
//html=html+wxT("<img src=\"memory:test.png\" width='180'>");
html = html + wxT ( " <table cellspacing=2 cellpadding=0> \n " ) ;
2011-06-03 08:12:00 +00:00
if ( avp > 0 ) {
2011-05-30 11:59:20 +00:00
html = html + wxT ( " <tr><td colspan=2 align=center><i> " ) + _ ( " Machine Information has been removed because this page has become machine agnostic. Not sure what to display here. " ) + wxT ( " </i></td></tr> \n " ) ;
/*if (machine->properties.find(wxT("SubModel"))!=machine->properties.end())
2011-05-26 13:59:21 +00:00
submodel = wxT ( " <br> \n " ) + machine - > properties [ wxT ( " SubModel " ) ] ;
html = html + wxT ( " <tr><td colspan=2 align=center><b> " ) + machine - > properties [ wxT ( " Brand " ) ] + wxT ( " </b> <br/> " ) + machine - > properties [ wxT ( " Model " ) ] + wxT ( " " ) + machine - > properties [ wxT ( " ModelNumber " ) ] + submodel + wxT ( " </td></tr> \n " ) ;
2011-05-30 11:59:20 +00:00
html = html + wxT ( " <tr><td colspan=2 align=center> " ) + _ ( " Firmware " ) + wxT ( " " ) + machine - > properties [ wxT ( " SoftwareVersion " ) ] + wxT ( " </td></tr> " ) ; */
2011-05-26 13:59:21 +00:00
html = html + wxT ( " <tr><td> </td><td> </td></tr> \n " ) ;
html = html + wxT ( " <tr><td colspan=2 align=left><i> " ) + _ ( " Indice Averages " ) + 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 " ) ;
2011-06-01 13:08:44 +00:00
html = html + wxT ( " <tr><td><b> " ) + _ ( " Pressure Avg " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2fcmH2O " ) , avp ) + wxT ( " </td></tr> \n " ) ;
if ( aiap > 0 ) {
html = html + wxT ( " <tr><td><b> " ) + _ ( " IPAP Avg " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2fcmH2O " ) , aiap ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td><b> " ) + _ ( " EPAP Avg " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2fcmH2O " ) , aeap ) + wxT ( " </td></tr> \n " ) ;
2011-06-03 07:06:18 +00:00
iap - > SetVisible ( true ) ;
eap - > SetVisible ( true ) ;
prmax - > SetVisible ( false ) ;
prmin - > SetVisible ( false ) ;
pr - > SetVisible ( false ) ;
2011-06-01 13:08:44 +00:00
} else {
if ( apmin ! = apmax ) {
2011-06-03 07:06:18 +00:00
prmax - > SetVisible ( true ) ;
prmin - > SetVisible ( true ) ;
pr - > SetVisible ( true ) ;
iap - > SetVisible ( false ) ;
eap - > SetVisible ( false ) ;
2011-06-01 13:08:44 +00:00
html = html + wxT ( " <tr><td><b> " ) + _ ( " Pressure Min " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2fcmH2O " ) , apmin ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td><b> " ) + _ ( " Pressure Max " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2fcmH2O " ) , apmax ) + wxT ( " </td></tr> \n " ) ;
2011-06-03 07:06:18 +00:00
} else {
pr - > SetVisible ( true ) ;
prmax - > SetVisible ( false ) ;
prmin - > SetVisible ( false ) ;
iap - > SetVisible ( false ) ;
eap - > SetVisible ( false ) ;
//prmax->SetVisible(false);
//prmin->SetVisible(false);
2011-06-01 13:08:44 +00:00
}
}
2011-05-27 14:07:35 +00:00
html = html + wxT ( " <tr><td> </td><td> </td></tr> \n " ) ;
2011-06-01 13:08:44 +00:00
html = html + wxT ( " <tr><td><b> " ) + _ ( " Mask Leaks " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2f " ) , leak - > GetAverage ( ) ) + wxT ( " </td></tr> \n " ) ;
2011-05-27 14:07:35 +00:00
2011-06-01 13:08:44 +00:00
html = html + wxT ( " <tr><td> </td><td> </td></tr> \n " ) ;
2011-05-27 14:07:35 +00:00
html = html + wxT ( " <tr><td><b> " ) + _ ( " Bedtime " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %02.0f:%02i " ) , bt , int ( bt * 60 ) % 60 ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td><b> " ) + _ ( " Waketime " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %02.0f:%02i " ) , wt , int ( wt * 60 ) % 60 ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td><b> " ) + _ ( " Hours/Night " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %02.0f:%02i " ) , ua , int ( ua * 60 ) % 60 ) + wxT ( " </td></tr> \n " ) ;
2011-05-26 13:59:21 +00:00
html = html + wxT ( " </table> " ) ;
2011-06-03 08:12:00 +00:00
} else {
html + = wxT ( " <div align=center><h1>Welcome</h1><br/> <br/><i>Please import some data</i></div> " ) ;
}
2011-05-26 13:59:21 +00:00
html + = wxT ( " </body></html> " ) ;
HTMLInfo - > SetPage ( html ) ;
2011-05-30 11:59:20 +00:00
}
void Summary : : EnableDatePickers ( bool b )
{
StartDatePicker - > Enable ( b ) ;
sdLabel - > Enable ( b ) ;
EndDatePicker - > Enable ( b ) ;
edLabel - > Enable ( b ) ;
}
void Summary : : OnRBSelect ( wxCommandEvent & event )
{
wxDateTime start = StartDatePicker - > GetValue ( ) ;
wxDateTime end = EndDatePicker - > GetValue ( ) ;
if ( rbCustomDate - > GetValue ( ) ) {
EnableDatePickers ( true ) ;
} else if ( rbAll - > GetValue ( ) ) {
2011-05-31 02:18:41 +00:00
start = profile - > FirstDay ( ) + wxTimeSpan : : Day ( ) ;
end = profile - > LastDay ( ) + wxTimeSpan : : Day ( ) ;
EnableDatePickers ( false ) ;
2011-05-30 11:59:20 +00:00
} else if ( rbLastMonth - > GetValue ( ) ) {
2011-05-31 02:18:41 +00:00
end = profile - > LastDay ( ) + wxTimeSpan : : Day ( ) ;
start = end - wxTimeSpan : : Days ( 30 - 1 ) ;
EnableDatePickers ( false ) ;
2011-05-30 11:59:20 +00:00
} else if ( rbLastWeek - > GetValue ( ) ) {
2011-05-31 02:18:41 +00:00
end = profile - > LastDay ( ) + wxTimeSpan : : Day ( ) ;
start = end - wxTimeSpan : : Days ( 7 - 1 ) ;
EnableDatePickers ( false ) ;
2011-05-30 11:59:20 +00:00
}
2011-06-04 03:44:30 +00:00
EndDatePicker - > SetRange ( start , profile - > LastDay ( ) + wxTimeSpan : : Day ( ) ) ;
StartDatePicker - > SetRange ( profile - > FirstDay ( ) + wxTimeSpan : : Day ( ) , end ) ;
2011-05-30 11:59:20 +00:00
StartDatePicker - > SetValue ( start ) ;
EndDatePicker - > SetValue ( end ) ;
2011-05-26 13:59:21 +00:00
2011-06-04 03:18:11 +00:00
RefreshData ( ) ;
2011-05-30 11:59:20 +00:00
}
void Summary : : OnStartDateChanged ( wxDateEvent & event )
{
2011-06-04 03:44:30 +00:00
wxDateTime st = StartDatePicker - > GetValue ( ) ;
EndDatePicker - > SetRange ( st , profile - > LastDay ( ) + wxTimeSpan : : Day ( ) ) ;
2011-06-04 03:18:11 +00:00
RefreshData ( ) ;
2011-05-30 11:59:20 +00:00
}
void Summary : : OnEndDateChanged ( wxDateEvent & event )
{
2011-06-04 03:44:30 +00:00
wxDateTime et = EndDatePicker - > GetValue ( ) ;
StartDatePicker - > SetRange ( profile - > FirstDay ( ) + wxTimeSpan : : Day ( ) , et ) ;
2011-06-04 03:18:11 +00:00
RefreshData ( ) ;
2011-05-26 13:59:21 +00:00
}
2011-05-31 02:18:41 +00:00
void Summary : : OnClose ( wxCloseEvent & event )
{
Destroy ( ) ;
}
2011-05-26 13:59:21 +00:00
2011-05-30 11:59:20 +00:00
Daily : : Daily ( wxWindow * win , Profile * p )
: DailyPanel ( win ) , profile ( p )
2011-05-26 13:59:21 +00:00
{
2011-06-07 11:26:10 +00:00
tiap_bmp = teap_bmp = tap_bmp = ahi_bmp = NULL ;
2011-06-04 02:38:18 +00:00
HTMLInfo = new wxHtmlWindow ( this ) ;
2011-06-07 11:26:10 +00:00
HTMLInfo - > SetBorders ( 4 ) ;
2011-06-04 02:38:18 +00:00
EventTree = new wxTreeCtrl ( this ) ;
2011-06-04 03:44:30 +00:00
2011-06-04 02:38:18 +00:00
this - > Connect ( wxEVT_COMMAND_TREE_SEL_CHANGED , wxTreeEventHandler ( Daily : : OnEventTreeSelection ) , NULL , this ) ;
2011-06-08 09:14:55 +00:00
Notebook - > AddPage ( HTMLInfo , wxT ( " Details " ) , false , wxNullBitmap ) ;
Notebook - > AddPage ( EventTree , wxT ( " Events " ) , false , wxNullBitmap ) ;
2011-06-06 03:20:20 +00:00
AddCPAPData ( tap_eap = new TAPData ( CPAP_EAP ) ) ;
AddCPAPData ( tap_iap = new TAPData ( CPAP_IAP ) ) ;
AddCPAPData ( tap = new TAPData ( CPAP_Pressure ) ) ;
2011-05-29 07:53:37 +00:00
2011-06-07 11:26:10 +00:00
TAP = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 30 ) , wxNO_BORDER ) ; //Time@Pressure
//TAP->SetMargins(20,15,5,50);
TAP - > SetMargins ( 0 , 1 , 0 , 1 ) ;
2011-05-26 13:59:21 +00:00
TAP - > AddLayer ( new gCandleStick ( tap ) ) ;
2011-06-07 11:26:10 +00:00
TAP_EAP = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 30 ) , wxNO_BORDER ) ; //Time@EPAP
TAP_EAP - > SetMargins ( 0 , 1 , 0 , 1 ) ;
2011-05-29 07:53:37 +00:00
TAP_EAP - > AddLayer ( new gCandleStick ( tap_eap ) ) ;
2011-06-08 07:46:16 +00:00
TAP_IAP = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 30 ) , wxNO_BORDER ) ; //Time@IPAP
TAP_IAP - > SetMargins ( 0 , 1 , 0 , 1 ) ;
TAP_IAP - > AddLayer ( new gCandleStick ( tap_iap ) ) ;
2011-06-07 11:26:10 +00:00
G_AHI = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 30 ) , wxNO_BORDER ) ; //Event Breakdown")
G_AHI - > SetMargins ( 0 , 1 , 0 , 1 ) ;
2011-06-06 03:20:20 +00:00
AddCPAPData ( g_ahi = new AHIData ( ) ) ;
2011-05-26 13:59:21 +00:00
gCandleStick * l = new gCandleStick ( g_ahi ) ;
l - > AddName ( wxT ( " H " ) ) ;
l - > AddName ( wxT ( " OA " ) ) ;
l - > AddName ( wxT ( " CA " ) ) ;
l - > AddName ( wxT ( " RE " ) ) ;
l - > AddName ( wxT ( " FL " ) ) ;
l - > AddName ( wxT ( " CSR " ) ) ;
l - > color . clear ( ) ;
l - > color . push_back ( wxBLUE ) ;
l - > color . push_back ( wxAQUA ) ;
l - > color . push_back ( wxPURPLE ) ;
l - > color . push_back ( wxYELLOW ) ;
l - > color . push_back ( wxBLACK ) ;
l - > color . push_back ( wxGREEN2 ) ;
G_AHI - > AddLayer ( l ) ;
2011-06-06 15:42:34 +00:00
AddOXIData ( pulse = new EventData ( OXI_Pulse , 0 , 65536 , true ) ) ;
2011-06-06 04:31:11 +00:00
//pulse->ForceMinY(40);
//pulse->ForceMaxY(120);
2011-06-06 03:20:20 +00:00
PULSE = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " Pulse " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 130 ) , wxNO_BORDER ) ;
PULSE - > AddLayer ( new gXAxis ( wxBLACK ) ) ;
2011-06-09 02:47:03 +00:00
PULSE - > AddLayer ( new gYAxis ( wxBLACK ) ) ;
PULSE - > AddLayer ( new gFooBar ( ) ) ;
PULSE - > AddLayer ( new gLineChart ( pulse , wxRED , 65536 , false , false , true ) ) ;
2011-06-06 03:20:20 +00:00
2011-06-06 15:42:34 +00:00
AddOXIData ( spo2 = new EventData ( OXI_SPO2 , 0 , 65536 , true ) ) ;
2011-06-06 04:31:11 +00:00
//spo2->ForceMinY(60);
//spo2->ForceMaxY(100);
2011-06-06 03:20:20 +00:00
SPO2 = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " SpO2 " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 130 ) , wxNO_BORDER ) ;
SPO2 - > AddLayer ( new gXAxis ( wxBLACK ) ) ;
2011-06-09 02:47:03 +00:00
SPO2 - > AddLayer ( new gYAxis ( wxBLACK ) ) ;
SPO2 - > AddLayer ( new gFooBar ( ) ) ;
SPO2 - > AddLayer ( new gLineChart ( spo2 , wxBLUE , 65536 , false , false , true ) ) ;
2011-06-06 03:20:20 +00:00
SPO2 - > LinkZoom ( PULSE ) ;
PULSE - > LinkZoom ( SPO2 ) ;
2011-06-02 16:31:36 +00:00
2011-06-07 20:48:27 +00:00
AddCPAPData ( snore = new EventData ( CPAP_SnoreGraph , 0 ) ) ;
2011-06-07 20:40:53 +00:00
//snore->ForceMinY(0);
//snore->ForceMaxY(15);
SNORE = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " Snore " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 130 ) , wxNO_BORDER ) ;
SNORE - > AddLayer ( new gXAxis ( wxBLACK ) ) ;
2011-06-09 02:47:03 +00:00
SNORE - > AddLayer ( new gYAxis ( wxBLACK ) ) ;
SNORE - > AddLayer ( new gFooBar ( ) ) ;
SNORE - > AddLayer ( new gLineChart ( snore , wxDARK_GREY , 4096 , false , false , true ) ) ;
2011-06-06 03:37:31 +00:00
2011-06-06 10:06:57 +00:00
AddCPAPData ( leakdata = new EventData ( CPAP_Leak , 0 ) ) ;
2011-06-06 03:37:31 +00:00
//leakdata->ForceMinY(0);
//leakdata->ForceMaxY(120);
2011-06-08 07:46:16 +00:00
LEAK = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " Leaks " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 130 ) , wxNO_BORDER ) ;
2011-05-31 04:50:06 +00:00
LEAK - > AddLayer ( new gXAxis ( wxBLACK ) ) ;
2011-06-09 02:47:03 +00:00
LEAK - > AddLayer ( new gYAxis ( wxBLACK ) ) ;
LEAK - > AddLayer ( new gFooBar ( ) ) ;
2011-06-10 11:21:20 +00:00
LEAK - > AddLayer ( new gLineChart ( leakdata , wxPURPLE , 4096 , false , false , false ) ) ;
2011-05-26 13:59:21 +00:00
2011-06-06 10:06:57 +00:00
AddCPAPData ( pressure_iap = new EventData ( CPAP_IAP ) ) ;
AddCPAPData ( pressure_eap = new EventData ( CPAP_EAP ) ) ;
AddCPAPData ( prd = new EventData ( CPAP_Pressure ) ) ;
2011-06-06 16:05:02 +00:00
2011-06-09 02:47:03 +00:00
PRD = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " Pressure " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 130 ) , wxNO_BORDER ) ;
PRD - > AddLayer ( new gXAxis ( wxBLACK ) ) ;
PRD - > AddLayer ( new gYAxis ( wxBLACK ) ) ;
PRD - > AddLayer ( new gFooBar ( ) ) ;
2011-06-10 11:21:20 +00:00
PRD - > AddLayer ( new gLineChart ( prd , wxDARK_GREEN , 4096 , false , false , false ) ) ;
2011-06-01 13:08:44 +00:00
PRD - > AddLayer ( new gLineChart ( pressure_iap , wxBLUE , 4096 , false , true , true ) ) ;
PRD - > AddLayer ( new gLineChart ( pressure_eap , wxRED , 4096 , false , true , true ) ) ;
2011-05-26 13:59:21 +00:00
2011-06-06 10:06:57 +00:00
AddCPAPData ( frw = new WaveData ( CPAP_FlowRate ) ) ;
2011-05-26 13:59:21 +00:00
FRW = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " Flow Rate " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 150 ) , wxNO_BORDER ) ;
2011-06-06 03:20:20 +00:00
AddCPAPData ( flags [ 0 ] = new FlagData ( CPAP_CSR , 7 , 1 , 0 ) ) ;
AddCPAPData ( flags [ 1 ] = new FlagData ( CPAP_ClearAirway , 6 ) ) ;
AddCPAPData ( flags [ 2 ] = new FlagData ( CPAP_Obstructive , 5 ) ) ;
AddCPAPData ( flags [ 3 ] = new FlagData ( CPAP_Hypopnea , 4 ) ) ;
AddCPAPData ( flags [ 4 ] = new FlagData ( CPAP_FlowLimit , 3 ) ) ;
AddCPAPData ( flags [ 5 ] = new FlagData ( CPAP_VSnore , 2 ) ) ;
AddCPAPData ( flags [ 6 ] = new FlagData ( CPAP_RERA , 1 ) ) ;
AddCPAPData ( flags [ 7 ] = new FlagData ( PRS1_PressurePulse , 1 ) ) ;
AddCPAPData ( flags [ 8 ] = new FlagData ( PRS1_VSnore2 , 1 ) ) ;
AddCPAPData ( flags [ 9 ] = new FlagData ( PRS1_Unknown0E , 1 ) ) ;
2011-05-26 13:59:21 +00:00
2011-06-06 16:05:02 +00:00
gLineChart * g ;
2011-06-09 02:47:03 +00:00
FRW - > AddLayer ( new gYAxis ( wxBLACK ) ) ;
FRW - > AddLayer ( new gXAxis ( wxBLACK ) ) ;
FRW - > AddLayer ( new gFooBar ( ) ) ;
2011-05-29 05:58:00 +00:00
FRW - > AddLayer ( new gLineOverlayBar ( flags [ 0 ] , wxGREEN2 , wxT ( " CSR " ) ) ) ;
2011-06-06 16:05:02 +00:00
FRW - > AddLayer ( g = new gLineChart ( frw , wxBLACK , 200000 , true ) ) ;
g - > ReportEmpty ( true ) ;
2011-05-27 11:35:45 +00:00
FRW - > AddLayer ( new gLineOverlayBar ( flags [ 7 ] , wxRED , wxT ( " PR " ) , LOT_Dot ) ) ;
2011-05-26 13:59:21 +00:00
FRW - > AddLayer ( new gLineOverlayBar ( flags [ 6 ] , wxYELLOW , wxT ( " RE " ) ) ) ;
2011-05-27 10:53:00 +00:00
FRW - > AddLayer ( new gLineOverlayBar ( flags [ 9 ] , wxDARK_GREEN , wxT ( " U0E " ) ) ) ;
2011-05-26 13:59:21 +00:00
FRW - > AddLayer ( new gLineOverlayBar ( flags [ 5 ] , wxRED , wxT ( " VS " ) ) ) ;
FRW - > AddLayer ( new gLineOverlayBar ( flags [ 4 ] , wxBLACK , wxT ( " FL " ) ) ) ;
FRW - > AddLayer ( new gLineOverlayBar ( flags [ 3 ] , wxBLUE , wxT ( " H " ) ) ) ;
FRW - > AddLayer ( new gLineOverlayBar ( flags [ 2 ] , wxAQUA , wxT ( " OA " ) ) ) ;
2011-05-29 05:58:00 +00:00
FRW - > AddLayer ( new gLineOverlayBar ( flags [ 1 ] , wxPURPLE , wxT ( " CA " ) ) ) ;
2011-05-26 13:59:21 +00:00
2011-05-31 04:28:11 +00:00
SF = new gGraphWindow ( ScrolledWindow , - 1 , wxT ( " Event Flags " ) , wxPoint ( 0 , 0 ) , wxSize ( 600 , 180 ) , wxNO_BORDER ) ;
2011-05-30 22:53:48 +00:00
// SF->SetMargins(10,15,20,80);
2011-05-26 13:59:21 +00:00
2011-06-09 13:49:13 +00:00
// #if defined(__UNIX__)
2011-06-10 11:21:20 +00:00
FRW - > LinkZoom ( SF ) ;
2011-06-08 13:54:27 +00:00
FRW - > LinkZoom ( PRD ) ;
FRW - > LinkZoom ( LEAK ) ;
FRW - > LinkZoom ( SNORE ) ;
2011-06-09 13:49:13 +00:00
SF - > LinkZoom ( FRW ) ;
2011-06-07 01:22:05 +00:00
SF - > LinkZoom ( PRD ) ; // Uncomment to link in more graphs.. Too slow on windows.
SF - > LinkZoom ( LEAK ) ;
2011-06-08 13:54:27 +00:00
SF - > LinkZoom ( SNORE ) ;
2011-06-09 13:49:13 +00:00
PRD - > LinkZoom ( SF ) ;
PRD - > LinkZoom ( FRW ) ;
PRD - > LinkZoom ( LEAK ) ;
PRD - > LinkZoom ( SNORE ) ;
LEAK - > LinkZoom ( SF ) ;
LEAK - > LinkZoom ( FRW ) ;
LEAK - > LinkZoom ( PRD ) ;
LEAK - > LinkZoom ( SNORE ) ;
SNORE - > LinkZoom ( SF ) ;
SNORE - > LinkZoom ( FRW ) ;
SNORE - > LinkZoom ( PRD ) ;
2011-06-10 11:21:20 +00:00
SNORE - > LinkZoom ( LEAK ) ;
2011-06-09 13:49:13 +00:00
// #endif
2011-05-27 10:53:00 +00:00
const int sfc = 9 ;
2011-06-09 10:25:26 +00:00
SF - > SetLeftMargin ( SF - > GetLeftMargin ( ) + gYAxis : : Margin ) ;
2011-05-27 10:53:00 +00:00
SF - > AddLayer ( new gFlagsLine ( flags [ 9 ] , wxDARK_GREEN , wxT ( " U0E " ) , 8 , sfc ) ) ;
2011-05-27 09:54:12 +00:00
SF - > AddLayer ( new gFlagsLine ( flags [ 8 ] , wxRED , wxT ( " VS2 " ) , 6 , sfc ) ) ;
SF - > AddLayer ( new gFlagsLine ( flags [ 6 ] , wxYELLOW , wxT ( " RE " ) , 7 , sfc ) ) ;
SF - > AddLayer ( new gFlagsLine ( flags [ 5 ] , wxRED , wxT ( " VS " ) , 5 , sfc ) ) ;
SF - > AddLayer ( new gFlagsLine ( flags [ 4 ] , wxBLACK , wxT ( " FL " ) , 4 , sfc ) ) ;
SF - > AddLayer ( new gFlagsLine ( flags [ 3 ] , wxBLUE , wxT ( " H " ) , 3 , sfc ) ) ;
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 ) ) ;
2011-05-31 04:50:06 +00:00
SF - > AddLayer ( new gXAxis ( wxBLACK ) ) ;
SF - > AddLayer ( new gFooBar ( ) ) ;
2011-05-26 13:59:21 +00:00
fgSizer - > Add ( SF , 1 , wxEXPAND ) ;
fgSizer - > Add ( FRW , 1 , wxEXPAND ) ;
fgSizer - > Add ( PRD , 1 , wxEXPAND ) ;
fgSizer - > Add ( LEAK , 1 , wxEXPAND ) ;
2011-06-07 20:40:53 +00:00
fgSizer - > Add ( SNORE , 1 , wxEXPAND ) ;
2011-06-07 01:22:05 +00:00
fgSizer - > Add ( PULSE , 1 , wxEXPAND ) ;
fgSizer - > Add ( SPO2 , 1 , wxEXPAND ) ;
2011-06-07 18:15:21 +00:00
G_AHI - > Hide ( ) ;
TAP - > Hide ( ) ;
TAP_IAP - > Hide ( ) ;
TAP_EAP - > Hide ( ) ;
2011-06-07 09:17:22 +00:00
//fgSizer->Add(G_AHI,1,wxEXPAND);
2011-06-07 11:26:10 +00:00
//fgSizer->Add(TAP,1,wxEXPAND);
//fgSizer->Add(TAP_IAP,1,wxEXPAND);
//fgSizer->Add(TAP_EAP,1,wxEXPAND);
2011-05-26 13:59:21 +00:00
2011-06-01 13:08:44 +00:00
2011-05-30 11:59:20 +00:00
ResetDate ( ) ;
2011-05-26 13:59:21 +00:00
}
Daily : : ~ Daily ( )
{
2011-06-07 09:17:22 +00:00
if ( ahi_bmp ) {
wxMemoryFSHandler : : RemoveFile ( _T ( " ahi.png " ) ) ;
delete ahi_bmp ;
}
2011-06-07 11:26:10 +00:00
if ( tap_bmp ) {
wxMemoryFSHandler : : RemoveFile ( _T ( " tap.png " ) ) ;
delete tap_bmp ;
}
if ( tiap_bmp ) {
wxMemoryFSHandler : : RemoveFile ( _T ( " tiap.png " ) ) ;
delete tiap_bmp ;
}
if ( teap_bmp ) {
wxMemoryFSHandler : : RemoveFile ( _T ( " teap.png " ) ) ;
delete teap_bmp ;
}
2011-06-07 09:17:22 +00:00
2011-06-04 02:38:18 +00:00
this - > Disconnect ( wxEVT_COMMAND_TREE_SEL_CHANGED , wxTreeEventHandler ( Daily : : OnEventTreeSelection ) , NULL , this ) ;
2011-05-26 13:59:21 +00:00
}
2011-05-31 02:18:41 +00:00
void Daily : : OnClose ( wxCloseEvent & event )
{
Destroy ( ) ;
}
2011-06-04 02:38:18 +00:00
void Daily : : OnEventTreeSelection ( wxTreeEvent & event )
{
wxTreeItemId id = event . GetItem ( ) ;
if ( ! EventTree - > ItemHasChildren ( id ) ) {
wxDateTime d ;
d . ParseFormat ( EventTree - > GetItemText ( id ) , wxT ( " %Y-%m-%d %H:%M:%S " ) ) ;
double st = ( d - wxTimeSpan : : Seconds ( 180 ) ) . GetMJD ( ) ;
double et = ( d + wxTimeSpan : : Seconds ( 180 ) ) . GetMJD ( ) ;
FRW - > SetXBounds ( st , et ) ;
2011-06-04 03:18:11 +00:00
SF - > SetXBounds ( st , et ) ;
PRD - > SetXBounds ( st , et ) ;
LEAK - > SetXBounds ( st , et ) ;
2011-06-07 20:48:27 +00:00
SNORE - > SetXBounds ( st , et ) ;
2011-06-04 02:38:18 +00:00
}
}
2011-05-31 02:18:41 +00:00
2011-05-30 11:59:20 +00:00
void Daily : : ResetDate ( )
2011-05-26 13:59:21 +00:00
{
2011-05-30 11:59:20 +00:00
foobar_datehack = false ; // this exists due to a wxGTK bug.
// RefreshData();
wxDateTime date ;
if ( profile - > LastDay ( ) . IsValid ( ) ) {
2011-05-30 13:11:29 +00:00
date = profile - > LastDay ( ) + wxTimeSpan : : Day ( ) ;
2011-05-30 11:59:20 +00:00
Calendar - > SetDate ( date ) ;
} else {
Calendar - > SetDate ( wxDateTime : : Today ( ) ) ;
}
2011-05-26 13:59:21 +00:00
wxCalendarEvent ev ;
2011-05-30 11:59:20 +00:00
ev . SetDate ( date ) ;
2011-05-26 13:59:21 +00:00
OnCalendarMonth ( ev ) ;
}
2011-05-30 11:59:20 +00:00
void Daily : : RefreshData ( )
2011-05-26 13:59:21 +00:00
{
2011-05-30 11:59:20 +00:00
wxDateTime date = Calendar - > GetDate ( ) ;
date . ResetTime ( ) ;
date . SetHour ( 0 ) ;
date - = wxTimeSpan : : Days ( 1 ) ;
2011-06-06 15:05:46 +00:00
Day * cpap = profile - > GetDay ( date , MT_CPAP ) ;
Day * oxi = profile - > GetDay ( date , MT_OXIMETER ) ;
if ( cpap ) UpdateCPAPGraphs ( cpap ) ;
if ( oxi ) UpdateOXIGraphs ( oxi ) ;
2011-05-30 11:59:20 +00:00
2011-06-07 16:16:15 +00:00
wxString html = wxT ( " <html><body leftmargin=0 rightmargin=0 topmargin=0 marginwidth=0 marginheight=0> " ) ;
html = html + wxT ( " <table cellspacing=0 cellpadding=2 border=0 width='100%'> \n " ) ;
2011-06-01 15:35:20 +00:00
2011-06-10 15:37:19 +00:00
CPAPMode mode = MODE_UNKNOWN ;
2011-06-07 16:16:15 +00:00
PRTypes pr ;
wxString epr , modestr ;
2011-06-07 16:37:17 +00:00
float iap90 , eap90 ;
2011-06-06 15:05:46 +00:00
if ( cpap ) {
mode = ( CPAPMode ) cpap - > summary_max ( CPAP_Mode ) ;
2011-05-29 10:09:24 +00:00
2011-06-04 02:38:18 +00:00
EventTree - > DeleteAllItems ( ) ;
wxTreeItemId root = EventTree - > AddRoot ( wxT ( " Events " ) ) ;
map < MachineCode , wxTreeItemId > mcroot ;
2011-06-06 15:05:46 +00:00
for ( vector < Session * > : : iterator s = cpap - > begin ( ) ; s ! = cpap - > end ( ) ; s + + ) {
2011-06-04 02:38:18 +00:00
map < MachineCode , vector < Event * > > : : iterator m ;
wxTreeItemId ti , sroot ;
for ( m = ( * s ) - > events . begin ( ) ; m ! = ( * s ) - > events . end ( ) ; m + + ) {
MachineCode code = m - > first ;
if ( code = = CPAP_Leak ) continue ;
2011-06-07 21:05:35 +00:00
if ( code = = CPAP_SnoreGraph ) continue ;
2011-06-04 02:38:18 +00:00
if ( code = = PRS1_Unknown12 ) continue ;
wxTreeItemId mcr ;
if ( mcroot . find ( code ) = = mcroot . end ( ) ) {
wxString s = DefaultMCLongNames [ m - > first ] ;
if ( s . IsEmpty ( ) ) {
s = wxString : : Format ( wxT ( " Fixme: %i " ) , code ) ;
}
mcr = mcroot [ code ] = EventTree - > AppendItem ( root , s ) ;
} else {
mcr = mcroot [ code ] ;
}
for ( vector < Event * > : : iterator e = ( * s ) - > events [ code ] . begin ( ) ; e ! = ( * s ) - > events [ code ] . end ( ) ; e + + ) {
2011-06-04 02:49:04 +00:00
wxDateTime t = ( * e ) - > time ( ) ;
if ( code = = CPAP_CSR ) {
t - = wxTimeSpan : : Seconds ( ( * ( * e ) ) [ 0 ] / 2 ) ;
}
2011-06-07 01:22:05 +00:00
EventTree - > AppendItem ( mcr , t . Format ( wxT ( " %Y-%m-%d %H:%M:%S " ) ) , - 1 , - 1 ) ;
2011-06-04 02:38:18 +00:00
}
}
}
EventTree - > SortChildren ( root ) ;
EventTree - > Expand ( root ) ;
2011-06-07 09:17:22 +00:00
//Logo.LoadFile(wxT("./pic.png"));
if ( ahi_bmp ) {
wxMemoryFSHandler : : RemoveFile ( _T ( " ahi.png " ) ) ;
delete ahi_bmp ;
}
2011-06-07 11:26:10 +00:00
if ( tap_bmp ) {
wxMemoryFSHandler : : RemoveFile ( _T ( " tap.png " ) ) ;
delete tap_bmp ;
}
if ( tiap_bmp ) {
wxMemoryFSHandler : : RemoveFile ( _T ( " tiap.png " ) ) ;
delete tiap_bmp ;
2011-06-07 11:28:35 +00:00
tiap_bmp = NULL ;
2011-06-07 11:26:10 +00:00
}
if ( teap_bmp ) {
wxMemoryFSHandler : : RemoveFile ( _T ( " teap.png " ) ) ;
delete teap_bmp ;
2011-06-07 11:28:35 +00:00
teap_bmp = NULL ;
2011-06-07 11:26:10 +00:00
}
wxRect r = HTMLInfo - > GetRect ( ) ;
2011-06-07 18:15:21 +00:00
int w = r . width - 27 ;
2011-06-07 11:26:10 +00:00
ahi_bmp = G_AHI - > RenderBitmap ( w , 25 ) ;
tap_bmp = TAP - > RenderBitmap ( w , 25 ) ;
2011-06-07 09:17:22 +00:00
wxMemoryFSHandler : : AddFile ( _T ( " ahi.png " ) , * ahi_bmp , wxBITMAP_TYPE_PNG ) ;
2011-06-07 11:26:10 +00:00
wxMemoryFSHandler : : AddFile ( _T ( " tap.png " ) , * tap_bmp , wxBITMAP_TYPE_PNG ) ;
2011-06-07 11:28:35 +00:00
if ( mode = = MODE_BIPAP ) {
teap_bmp = TAP_EAP - > RenderBitmap ( w , 25 ) ;
tiap_bmp = TAP_IAP - > RenderBitmap ( w , 25 ) ;
wxMemoryFSHandler : : AddFile ( _T ( " teap.png " ) , * teap_bmp , wxBITMAP_TYPE_PNG ) ;
2011-06-08 07:46:16 +00:00
wxMemoryFSHandler : : AddFile ( _T ( " tiap.png " ) , * tiap_bmp , wxBITMAP_TYPE_PNG ) ;
2011-06-07 11:28:35 +00:00
}
2011-06-07 16:16:15 +00:00
pr = ( PRTypes ) cpap - > summary_max ( CPAP_PressureReliefType ) ;
if ( pr = = PR_NONE )
epr = _ ( " No Pressure Relief " ) ;
else epr = PressureReliefNames [ pr ] + wxString : : Format ( wxT ( " x%i " ) , ( int ) cpap - > summary_max ( CPAP_PressureReliefSetting ) ) ;
modestr = CPAPModeNames [ mode ] ;
2011-05-26 13:59:21 +00:00
2011-06-06 15:05:46 +00:00
float ahi = ( cpap - > count ( CPAP_Obstructive ) + cpap - > count ( CPAP_Hypopnea ) + cpap - > count ( CPAP_ClearAirway ) ) / cpap - > hours ( ) ;
float csr = ( 100.0 / cpap - > hours ( ) ) * ( cpap - > sum ( CPAP_CSR ) / 3600.0 ) ;
float oai = cpap - > count ( CPAP_Obstructive ) / cpap - > hours ( ) ;
float hi = cpap - > count ( CPAP_Hypopnea ) / cpap - > hours ( ) ;
float cai = cpap - > count ( CPAP_ClearAirway ) / cpap - > hours ( ) ;
float rei = cpap - > count ( CPAP_RERA ) / cpap - > hours ( ) ;
float vsi = cpap - > count ( CPAP_VSnore ) / cpap - > hours ( ) ;
float fli = cpap - > count ( CPAP_FlowLimit ) / cpap - > hours ( ) ;
// float p90=cpap->percentile(CPAP_Pressure,0,0.9);
2011-06-07 16:37:17 +00:00
eap90 = cpap - > percentile ( CPAP_EAP , 0 , 0.9 ) ;
iap90 = cpap - > percentile ( CPAP_IAP , 0 , 0.9 ) ;
2011-05-26 13:59:21 +00:00
wxString submodel = _ ( " Unknown Model " ) ;
2011-06-06 15:05:46 +00:00
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td colspan=4 align=center><i> " ) + _ ( " Machine Information " ) + wxT ( " </i></td></tr> \n " ) ;
2011-06-06 15:05:46 +00:00
if ( cpap - > machine - > properties . find ( wxT ( " SubModel " ) ) ! = cpap - > machine - > properties . end ( ) )
submodel = wxT ( " <br> " ) + cpap - > machine - > properties [ wxT ( " SubModel " ) ] ;
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td colspan=4 align=center><b> " ) + cpap - > machine - > properties [ wxT ( " Brand " ) ] + wxT ( " </b> <br> " ) + cpap - > machine - > properties [ wxT ( " Model " ) ] + wxT ( " " ) + cpap - > machine - > properties [ wxT ( " ModelNumber " ) ] + submodel + wxT ( " </td></tr> \n " ) ;
2011-05-30 11:59:20 +00:00
if ( pref . Exists ( " ShowSerialNumbers " ) & & pref [ " ShowSerialNumbers " ] ) {
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td colspan=4 align=center> " ) + cpap - > machine - > properties [ wxT ( " Serial " ) ] + wxT ( " </td></tr> \n " ) ;
2011-05-30 11:59:20 +00:00
}
2011-06-07 16:16:15 +00:00
//html=html+wxT("<tr><td colspan=4><hr></td></tr>\n");
//html=html+wxT("<tr><td colspan=4 align=center><hr></td></tr>\n");
//html=html+wxT("<tr><td colspan=4 align=center><i>")+_("Sleep Times")+wxT("</i></td></tr>\n");
html = html + wxT ( " <tr><td align='center'><b>Date</b></td><td align='center'><b>Sleep</b></td><td align='center'><b>Wake</b></td><td align='center'><b>Hours</b></td></tr> " ) ;
//html=html+wxT("<tr><td><b>")+_("Date")+wxT("</b></td><td>")+cpap->first().Format(wxT("%x"))+wxT("</td></tr>\n");
html = html + wxT ( " <tr><td align='center'> " ) + cpap - > first ( ) . Format ( wxT ( " %x " ) ) + wxT ( " </td><td align='center'> " ) + cpap - > first ( ) . Format ( wxT ( " %H:%M " ) ) + wxT ( " </td><td align='center'> " ) + cpap - > last ( ) . Format ( wxT ( " %H:%M " ) ) + wxT ( " </td><td align='center'> " ) + cpap - > total_time ( ) . Format ( wxT ( " %H:%M " ) ) + wxT ( " </td></tr> \n " ) ;
// html=html+wxT("<tr><td><b>")+_("Sleep")+wxT("</b></td><td>")+cpap->first().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 colspan=3><i>")+cpap->total_time().Format(wxT("%H:%M hours"))+wxT("</i></td></tr>\n");
// html=html+wxT("<tr><td colspan=4> </td></tr>\n");
html = html + wxT ( " <tr><td colspan=4 align=center><hr></td></tr> \n " ) ;
2011-06-07 18:15:21 +00:00
//pref["fruitsalad"]=false;
if ( pref . Exists ( " fruitsalad " ) & & pref [ " fruitsalad " ] ) {
html = html + wxT ( " <tr><td colspan=2><table cellspacing=0 cellpadding=2 border=0 width='100%'> " ) ;
html = html + wxT ( " <tr><td align='right' bgcolor='#F88017'><b><font color='black'> " ) + _ ( " AHI " ) + wxT ( " </font></b></td><td bgcolor='#F88017'><b><font color='black'> " ) + wxString : : Format ( wxT ( " %0.2f " ) , ahi ) + wxT ( " </font></b></td></tr> \n " ) ;
html = html + wxT ( " <tr><td align='right' bgcolor='#4040ff'><b><font color='white'> " ) + _ ( " Hypopnea " ) + wxT ( " </font></b></td><td bgcolor='#4040ff'><font color='white'> " ) + wxString : : Format ( wxT ( " %0.2f " ) , hi ) + wxT ( " </font></td></tr> \n " ) ;
2011-06-08 07:46:16 +00:00
html = html + wxT ( " <tr><td align='right' bgcolor='#40afbf'><b> " ) + _ ( " Obstructive " ) + wxT ( " </b></td><td bgcolor='#40afbf'> " ) + wxString : : Format ( wxT ( " %0.2f " ) , oai ) + wxT ( " </td></tr> \n " ) ;
2011-06-07 18:15:21 +00:00
html = html + wxT ( " <tr><td align='right' bgcolor='#ff80ff'><b> " ) + _ ( " ClearAirway " ) + wxT ( " </b></td><td bgcolor='#ff80ff'> " ) + wxString : : Format ( wxT ( " %0.2f " ) , cai ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " </table></td><td colspan=2><table cellspacing=0 cellpadding=2 border=0 width='100%'> " ) ;
html = html + wxT ( " <tr><td align='right' bgcolor='#ffff80'><b> " ) + _ ( " RERA " ) + wxT ( " </b></td><td bgcolor='#ffff80'> " ) + wxString : : Format ( wxT ( " %0.2f " ) , rei ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td align='right' bgcolor='#404040'><b><font color='white'> " ) + _ ( " FlowLimit " ) + wxT ( " </font></b></td><td bgcolor='#404040'><font color='white'> " ) + wxString : : Format ( wxT ( " %0.2f " ) , fli ) + wxT ( " </font></td></tr> \n " ) ;
html = html + wxT ( " <tr><td align='right' bgcolor='#ff4040'><b> " ) + _ ( " Vsnore " ) + wxT ( " </b></td><td bgcolor='#ff4040'> " ) + wxString : : Format ( wxT ( " %0.2f " ) , vsi ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td align='right' bgcolor='#80ff80'><b> " ) + _ ( " PB/CSR " ) + wxT ( " </b></td><td bgcolor='#80ff80'> " ) + wxString : : Format ( wxT ( " %0.2f%% " ) , csr ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " </table></td></tr> " ) ;
} else {
html = html + wxT ( " <tr><td colspan=2><table cellspacing=0 cellpadding=2 border=0 width='100%'> " ) ;
html = html + wxT ( " <tr><td align='right'><b><font color='black'> " ) + _ ( " AHI " ) + wxT ( " </font></b></td><td><b><font color='black'> " ) + wxString : : Format ( wxT ( " %0.2f " ) , ahi ) + wxT ( " </font></b></td></tr> \n " ) ;
html = html + wxT ( " <tr><td align='right'><b> " ) + _ ( " Hypopnea " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2f " ) , hi ) + wxT ( " </td></tr> \n " ) ;
2011-06-08 07:46:16 +00:00
html = html + wxT ( " <tr><td align='right'><b> " ) + _ ( " Obstructive " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2f " ) , oai ) + wxT ( " </td></tr> \n " ) ;
2011-06-07 18:15:21 +00:00
html = html + wxT ( " <tr><td align='right'><b> " ) + _ ( " ClearAirway " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2f " ) , cai ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " </table></td><td colspan=2><table cellspacing=0 cellpadding=2 border=0 width='100%'> " ) ;
html = html + wxT ( " <tr><td align='right'><b> " ) + _ ( " RERA " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2f " ) , rei ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td align='right'><b> " ) + _ ( " FlowLimit " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2f " ) , fli ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td align='right'><b> " ) + _ ( " Vsnore " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2f " ) , vsi ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td align='right'><b> " ) + _ ( " PB/CSR " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %0.2f%% " ) , csr ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " </table></td></tr> " ) ;
}
2011-06-07 16:16:15 +00:00
// html=html+wxT("<tr><td colspan=4> </td></tr>\n");
//html=html+wxT("<tr><td colspan=4> </td></tr>\n");
html = html + wxT ( " <tr><td colspan=4 align=center><i> " ) + _ ( " Event Breakdown " ) + wxT ( " </i></td></tr> \n " ) ;
2011-06-07 18:15:21 +00:00
html = html + wxT ( " <tr><td colspan=4 align=center><img src= \" memory:ahi.png \" ></td></tr> \n " ) ;
2011-06-07 16:16:15 +00:00
//html=html+wxT("<tr><td colspan=4> </td></tr>\n");
//html=html+wxT("<tr><td colspan=4 align=center><i>")+_("Other Information")+wxT("</i></td></tr>\n");
2011-06-07 11:26:10 +00:00
2011-06-07 16:16:15 +00:00
html = html + wxT ( " </table> " ) ;
html = html + wxT ( " <table cellspacing=0 cellpadding=0 border=0 width='100%'> \n " ) ;
//html=html+wxT("<tr><td colspan=4> </td></tr>\n");
html = html + wxT ( " <tr height='2'><td colspan=4 height='2'><hr></td></tr> \n " ) ;
//html=html+wxT("<tr><td colspan=4 align=center><hr></td></tr>\n");
2011-06-07 11:26:10 +00:00
2011-05-26 13:59:21 +00:00
2011-06-07 16:37:17 +00:00
if ( mode = = MODE_BIPAP ) {
html = html + wxT ( " <tr><td colspan=4 align='center'><i> " ) + _ ( " 90% EPAP " ) + wxString : : Format ( wxT ( " %.1fcmH2O " ) , eap90 ) + wxT ( " </td></tr> \n " ) ;
2011-06-08 07:46:16 +00:00
html = html + wxT ( " <tr><td colspan=4 align='center'><i> " ) + _ ( " 90% IPAP " ) + wxString : : Format ( wxT ( " %.1fcmH2O " ) , iap90 ) + wxT ( " </td></tr> \n " ) ;
2011-05-26 13:59:21 +00:00
} else if ( mode = = MODE_APAP ) {
2011-06-07 16:37:17 +00:00
html = html + wxT ( " <tr><td colspan=4 align='center'><i> " ) + _ ( " 90% Pressure " ) + wxString : : Format ( wxT ( " %.2fcmH2O " ) , cpap - > summary_weighted_avg ( CPAP_PressurePercentValue ) ) + wxT ( " </i></td></tr> \n " ) ;
} else if ( mode = = MODE_CPAP ) {
html = html + wxT ( " <tr><td colspan=4 align='center'><i> " ) + _ ( " Pressure " ) + wxString : : Format ( wxT ( " %.2fcmH2O " ) , cpap - > summary_min ( CPAP_PressureMin ) ) + wxT ( " </i></td></tr> \n " ) ;
}
html = html + wxT ( " <tr><td colspan=4 align=center> </td></tr> \n " ) ;
html = html + wxT ( " <tr><td> </td><td><b>Min</b></td><td><b>Avg</b></td><td><b>Max</b></td></tr> " ) ;
if ( mode = = MODE_APAP ) {
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td>Pressure</td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_min ( CPAP_PressureMinAchieved ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_weighted_avg ( CPAP_PressureAverage ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_max ( CPAP_PressureMaxAchieved ) ) + wxT ( " </td></tr> " ) ;
2011-06-02 19:04:43 +00:00
// html=html+wxT("<tr><td><b>")+_("90% Pressure")+wxT("</b></td><td>")+wxString::Format(wxT("%.1fcmH2O"),p90)+wxT("</td></tr>\n");
2011-05-29 05:58:00 +00:00
} else if ( mode = = MODE_BIPAP ) {
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td>EPAP</td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_min ( BIPAP_EAPMin ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_weighted_avg ( BIPAP_EAPAverage ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_max ( BIPAP_EAPMax ) ) + wxT ( " </td></tr> " ) ;
2011-06-08 07:46:16 +00:00
html = html + wxT ( " <tr><td>IPAP</td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_min ( BIPAP_IAPMin ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_weighted_avg ( BIPAP_IAPAverage ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_max ( BIPAP_IAPMax ) ) + wxT ( " </td></tr> " ) ;
2011-05-26 13:59:21 +00:00
}
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td>Leak " ) ; //</td><td>")+wxString::Format(wxT("%.2f"),cpap->summary_weighted_avg(CPAP_LeakAverage))
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_min ( CPAP_LeakMinimum ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_weighted_avg ( CPAP_LeakAverage ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_max ( CPAP_LeakMaximum ) ) + wxT ( " </td><tr> " ) ;
2011-06-07 11:26:10 +00:00
2011-06-08 06:05:57 +00:00
html = html + wxT ( " <tr><td>Snore " ) ; //</td><td>")+wxString::Format(wxT("%.2f"),cpap->summary_weighted_avg(CPAP_LeakAverage))
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_min ( CPAP_SnoreMinimum ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_avg ( CPAP_SnoreAverage ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f " ) , cpap - > summary_max ( CPAP_SnoreMaximum ) ) + wxT ( " </td><tr> " ) ;
2011-06-07 16:16:15 +00:00
// html=html+wxT("<tr><td colspan=4> </td></tr>\n");
2011-06-07 11:26:10 +00:00
2011-06-07 18:15:21 +00:00
/*if (mode!=MODE_BIPAP) {
2011-06-06 15:05:46 +00:00
TAP_EAP - > Show ( false ) ;
TAP_IAP - > Show ( false ) ;
TAP - > Show ( true ) ;
2011-06-06 03:20:20 +00:00
} else {
2011-06-06 15:05:46 +00:00
TAP - > Show ( false ) ;
TAP_IAP - > Show ( true ) ;
TAP_EAP - > Show ( true ) ;
2011-06-07 18:15:21 +00:00
} */
//G_AHI->Show(true);
2011-06-06 15:05:46 +00:00
FRW - > Show ( true ) ;
PRD - > Show ( true ) ;
LEAK - > Show ( true ) ;
SF - > Show ( true ) ;
2011-06-07 20:48:27 +00:00
SNORE - > Show ( true ) ;
2011-06-06 15:05:46 +00:00
} else {
2011-06-06 15:35:54 +00:00
html + = _ ( " <tr><td colspan=2 align=center><i>No CPAP data available</i></td></tr> " ) ;
html = html + wxT ( " <tr><td> </td><td> </td></tr> \n " ) ;
2011-06-07 18:15:21 +00:00
//TAP_EAP->Show(false);
//TAP_IAP->Show(false);
//G_AHI->Show(false);
2011-06-06 15:05:46 +00:00
FRW - > Show ( false ) ;
PRD - > Show ( false ) ;
LEAK - > Show ( false ) ;
SF - > Show ( false ) ;
2011-06-07 20:48:27 +00:00
SNORE - > Show ( false ) ;
2011-06-06 15:05:46 +00:00
}
if ( oxi ) {
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td>Pulse " ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2fbpm " ) , oxi - > summary_min ( OXI_PulseMin ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2fbpm " ) , oxi - > summary_avg ( OXI_PulseAverage ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2fbpm " ) , oxi - > summary_max ( OXI_PulseMax ) ) + wxT ( " </td><tr> " ) ;
html = html + wxT ( " <tr><td>SpO2 " ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f%% " ) , oxi - > summary_min ( OXI_SPO2Min ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f%% " ) , oxi - > summary_avg ( OXI_SPO2Average ) ) ;
html = html + wxT ( " </td><td> " ) + wxString : : Format ( wxT ( " %.2f%% " ) , oxi - > summary_max ( OXI_SPO2Max ) ) + wxT ( " </td><tr> " ) ;
//html=html+wxT("<tr><td colspan=4> </td></tr>\n");
2011-06-06 15:05:46 +00:00
PULSE - > Show ( true ) ;
SPO2 - > Show ( true ) ;
} else {
PULSE - > Show ( false ) ;
SPO2 - > Show ( false ) ;
}
fgSizer - > Layout ( ) ;
ScrolledWindow - > FitInside ( ) ;
if ( cpap ) {
2011-06-07 16:16:15 +00:00
2011-06-07 16:37:17 +00:00
2011-06-07 16:16:15 +00:00
if ( mode = = MODE_BIPAP ) {
html = html + wxT ( " <tr><td colspan=4 align=center><i> " ) + _ ( " Time@EPAP " ) + wxT ( " </i></td></tr> \n " ) ;
2011-06-07 18:15:21 +00:00
html = html + wxT ( " <tr><td colspan=4 align=center><img src= \" memory:teap.png \" ></td></tr> \n " ) ;
2011-06-08 07:46:16 +00:00
html = html + wxT ( " <tr><td colspan=4 align=center><i> " ) + _ ( " Time@IPAP " ) + wxT ( " </i></td></tr> \n " ) ;
html = html + wxT ( " <tr><td colspan=4 align=center><img src= \" memory:tiap.png \" ></td></tr> \n " ) ;
2011-06-07 16:37:17 +00:00
} else if ( mode = = MODE_APAP ) {
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td colspan=4 align=center><i> " ) + _ ( " Time@Pressure " ) + wxT ( " </i></td></tr> \n " ) ;
2011-06-07 18:15:21 +00:00
html = html + wxT ( " <tr><td colspan=4 align=center><img src= \" memory:tap.png \" ></td></tr> \n " ) ;
2011-06-07 16:16:15 +00:00
}
html = html + wxT ( " </table><hr> " ) ;
html = html + wxT ( " <div align=left> " ) ;
html = html + wxT ( " <table cellspacing=0 cellpadding=0 border=0 width='100%'> \n " ) ;
2011-06-06 03:20:20 +00:00
// fgSizer->Layout();
2011-05-26 13:59:21 +00:00
2011-06-06 15:05:46 +00:00
if ( cpap - > summary_avg ( CPAP_BrokenSummary ) = = 1 ) {
2011-05-30 11:59:20 +00:00
html = html + wxT ( " <tr><td colspan=2 align=center><i> " ) + _ ( " No System Settings Recorded " ) + wxT ( " </i></td></tr> \n " ) ;
} else {
2011-06-07 16:16:15 +00:00
//html=html+wxT("<tr><td colspan=2 align=center><i>")+_("System Settings")+wxT("</i></td></tr>\n");
html = html + wxT ( " <tr><td><b>Mode</b></td><td><b> " ) + modestr + wxT ( " </b> with " ) + epr + wxT ( " </td></tr> \n " ) ;
2011-05-30 11:59:20 +00:00
if ( mode = = MODE_CPAP ) {
2011-06-06 15:05:46 +00:00
html = html + wxT ( " <tr><td><b> " ) + _ ( " Pressure " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %.1fcmH2O " ) , cpap - > summary_min ( CPAP_PressureMin ) ) + wxT ( " </td></tr> \n " ) ;
2011-05-30 11:59:20 +00:00
} else if ( mode = = MODE_APAP ) {
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td><b> " ) + _ ( " Pressure " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %.2fcmH20 Min<br> " ) , cpap - > summary_min ( CPAP_PressureMin ) ) + wxString : : Format ( wxT ( " %.2fcmH2O Max " ) , cpap - > summary_max ( CPAP_PressureMax ) ) + wxT ( " </td></tr> \n " ) ;
2011-05-30 11:59:20 +00:00
} else if ( mode = = MODE_BIPAP ) {
2011-06-08 07:46:16 +00:00
html = html + wxT ( " <tr><td><b> " ) + _ ( " Pressure " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %.2fcmH2O EPAP<br> " ) , cpap - > summary_min ( CPAP_PressureMin ) ) + wxString : : Format ( wxT ( " %.2fcmH2O IPAP " ) , cpap - > summary_max ( CPAP_PressureMax ) ) + wxT ( " </td></tr> \n " ) ;
2011-05-30 11:59:20 +00:00
}
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td><b> " ) + _ ( " Ramp " ) + wxT ( " </b></td><td> " ) + wxString : : Format ( wxT ( " %.2fcmH2O " ) , cpap - > summary_min ( CPAP_RampStartingPressure ) ) + wxString : : Format ( wxT ( " @ %imin " ) , ( int ) cpap - > summary_max ( CPAP_RampTime ) ) + wxT ( " </td></tr> \n " ) ;
2011-05-30 11:59:20 +00:00
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td colspan=4> </td></tr> \n " ) ;
2011-05-30 11:59:20 +00:00
// check HumidiferStatus..
wxString str ;
2011-06-06 15:05:46 +00:00
if ( bool ( cpap - > summary_max ( CPAP_HumidifierStatus ) ) ) {
str = wxString : : Format ( wxT ( " x%i " ) , ( int ) cpap - > summary_max ( CPAP_HumidifierSetting ) ) ;
2011-05-30 11:59:20 +00:00
} else str = wxT ( " No " ) ;
html = html + wxT ( " <tr><td><b> " ) + _ ( " Humidifier " ) + wxT ( " </b></td><td> " ) + str + wxT ( " </td></tr> \n " ) ;
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <tr><td><b> " ) + _ ( " SystemLock " ) + wxT ( " </b></td><td> " ) + ( bool ( cpap - > summary_max ( PRS1_SystemLockStatus ) ) ? _ ( " On " ) : _ ( " Off " ) ) + wxT ( " </td></tr> \n " ) ;
2011-06-06 15:05:46 +00:00
html = html + wxT ( " <tr><td><b> " ) + _ ( " Auto-Off " ) + wxT ( " </b></td><td> " ) + ( bool ( cpap - > summary_max ( PRS1_AutoOff ) ) ? _ ( " On " ) : _ ( " Off " ) ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td><b> " ) + _ ( " Mask-Alert " ) + wxT ( " </b></td><td> " ) + ( bool ( cpap - > summary_max ( PRS1_MaskAlert ) ) ? _ ( " On " ) : _ ( " Off " ) ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td><b> " ) + _ ( " Show-AHI " ) + wxT ( " </b></td><td> " ) + ( bool ( cpap - > summary_max ( PRS1_ShowAHI ) ) ? _ ( " On " ) : _ ( " Off " ) ) + wxT ( " </td></tr> \n " ) ;
html = html + wxT ( " <tr><td><b> " ) + _ ( " Hose-Size " ) + wxT ( " </b></td><td> " ) + ( bool ( cpap - > summary_max ( PRS1_HoseDiameter ) ) ? _ ( " 22mm " ) : _ ( " 15mm " ) ) + wxT ( " </td></tr> \n " ) ;
if ( bool ( cpap - > summary_max ( PRS1_SystemResistanceStatus ) ) ) {
str = wxString : : Format ( wxT ( " x%i " ) , ( int ) cpap - > summary_max ( PRS1_SystemResistanceSetting ) ) ;
2011-05-30 11:59:20 +00:00
} else str = wxT ( " No " ) ;
html = html + wxT ( " <tr><td><b> " ) + _ ( " Sys-Resist. " ) + wxT ( " </b></td><td> " ) + str + wxT ( " </td></tr> \n " ) ;
2011-05-29 05:58:00 +00:00
}
2011-06-07 18:15:21 +00:00
html = html + wxT ( " </table><hr><div align=center> " ) ;
2011-06-07 16:16:15 +00:00
html = html + wxT ( " <table cellspacing=0 cellpadding=0 border=0> \n " ) ;
//html=html+wxT("<tr><td> </td><td> </td></tr>\n");
//html=html+wxT("<tr><td colspan=2 align=center><hr></td></tr>\n");
2011-05-27 08:22:24 +00:00
html = html + wxT ( " <tr><td colspan=2 align=center><i> " ) + _ ( " Session Files " ) + wxT ( " </i></td></tr> \n " ) ;
2011-06-01 13:08:44 +00:00
2011-06-06 15:05:46 +00:00
for ( vector < Session * > : : iterator i = cpap - > begin ( ) ; i ! = cpap - > end ( ) ; i + + ) {
2011-06-08 09:14:55 +00:00
html = html + wxT ( " <tr><td colspan=2 align=left> " ) + ( * i ) - > first ( ) . Format ( wxT ( " %d-%m-%Y %H:%M " ) ) + wxT ( " " ) ;
html = html + ( * i ) - > last ( ) . Format ( wxT ( " %H:%M " ) ) + wxT ( " " ) ;
html = html + wxString : : Format ( wxT ( " #%06li " ) , ( * i ) - > session ( ) ) + wxT ( " </td></tr> \n " ) ;
2011-05-27 08:22:24 +00:00
}
2011-05-26 13:59:21 +00:00
}
2011-06-06 15:35:54 +00:00
/*if (!cpap && !oxi) {
2011-06-06 15:05:46 +00:00
html + = _ ( " <tr><td colspan=2><i>No data available for this day</i></td></tr> " ) ;
2011-06-06 15:35:54 +00:00
} */
2011-06-07 16:16:15 +00:00
html + = wxT ( " </table></div></body></html> " ) ;
2011-06-06 15:05:46 +00:00
HTMLInfo - > SetPage ( html ) ;
2011-05-26 13:59:21 +00:00
}
2011-06-01 13:08:44 +00:00
void Daily : : OnSelectSession ( wxCommandEvent & event )
{
if ( event . IsSelection ( ) ) {
int sessid = event . GetSelection ( ) ;
wxLogMessage ( wxT ( " Selected: " ) + wxString : : Format ( wxT ( " %i " ) , sessid ) ) ;
}
}
2011-05-30 11:59:20 +00:00
///usr/local/bin/upx ./bin/Windows/SleepyHead
void Daily : : OnCalendarDay ( wxCalendarEvent & event )
2011-05-26 13:59:21 +00:00
{
2011-05-30 11:59:20 +00:00
if ( foobar_datehack ) {
OnCalendarMonth ( event ) ;
foobar_datehack = false ;
2011-05-26 13:59:21 +00:00
}
2011-05-30 11:59:20 +00:00
RefreshData ( ) ;
}
2011-06-06 03:20:20 +00:00
void Daily : : UpdateCPAPGraphs ( Day * day )
2011-05-30 11:59:20 +00:00
{
//if (!day) return;
2011-06-02 03:28:11 +00:00
if ( day ) {
day - > OpenEvents ( ) ;
day - > OpenWaveforms ( ) ;
}
2011-06-06 03:20:20 +00:00
for ( list < gPointData * > : : iterator g = CPAPData . begin ( ) ; g ! = CPAPData . end ( ) ; g + + ) {
2011-05-26 13:59:21 +00:00
( * g ) - > Update ( day ) ;
}
} ;
2011-06-06 03:20:20 +00:00
void Daily : : UpdateOXIGraphs ( Day * day )
{
//if (!day) return;
if ( day ) {
day - > OpenEvents ( ) ;
day - > OpenWaveforms ( ) ;
}
for ( list < gPointData * > : : iterator g = OXIData . begin ( ) ; g ! = OXIData . end ( ) ; g + + ) {
( * g ) - > Update ( day ) ;
}
} ;
2011-05-26 13:59:21 +00:00
void Daily : : OnCalendarMonth ( wxCalendarEvent & event )
{
wxDateTime et = event . GetDate ( ) ;
if ( ! et . IsValid ( ) ) {
foobar_datehack = true ;
return ;
}
wxDateTime : : Month m = et . GetMonth ( ) ;
int y = et . GetYear ( ) ;
static wxFont f = * wxNORMAL_FONT ; //wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
f . SetWeight ( wxBOLD ) ;
2011-05-30 11:59:20 +00:00
//if (!machine) return;
2011-05-26 13:59:21 +00:00
for ( int i = 1 ; i < 31 ; i + + ) {
int j = wxDateTime : : GetNumberOfDays ( m , y ) ;
if ( i > j ) break ;
wxDateTime d ( i , m , y , 0 , 0 , 0 , 0 ) ;
d - = wxTimeSpan : : Days ( 1 ) ;
2011-05-30 11:59:20 +00:00
if ( ( profile - > daylist . find ( d ) ! = profile - > daylist . end ( ) ) ) {
2011-05-26 13:59:21 +00:00
# if wxCHECK_VERSION(2,9,0)
Calendar - > Mark ( i , true ) ;
# else
wxCalendarDateAttr * a = new wxCalendarDateAttr ( ) ;
a - > SetFont ( f ) ;
//wxNORM
Calendar - > SetAttr ( i , a ) ;
# endif
} else {
# if wxCHECK_VERSION(2,9,0)
Calendar - > Mark ( i , false ) ;
# else
Calendar - > ResetAttr ( i ) ;
# endif
// Calendar->SetAttr(i,NULL);
}
}
}