Code cleanup, plus Summary date range fixes

This commit is contained in:
Mark Watkins 2011-06-04 13:44:30 +10:00
parent 8b09043387
commit 38820caa1a
6 changed files with 23 additions and 155 deletions

View File

@ -7877,7 +7877,7 @@
<sleeplib/machine.h>
<list>
1307157388 /home/mark/projects/git/sleepyhead/version.h
1307158621 /home/mark/projects/git/sleepyhead/version.h
1306724655 /home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.h
"machine.h"
@ -7894,7 +7894,7 @@
"preferences.h"
"tinyxml/tinyxml.h"
1307157388 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp
1307158620 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp
"wx_pch.h"
"version.h"
<wx/app.h>
@ -7913,7 +7913,7 @@
"sleeplib/profiles.h"
"sleeplib/machine_loader.h"
1307157064 source:/home/mark/projects/git/sleepyhead/graphs/graph.cpp
1307157722 source:/home/mark/projects/git/sleepyhead/graphs/graph.cpp
<wx/settings.h>
<wx/dcbuffer.h>
<wx/log.h>

View File

@ -82,15 +82,14 @@ SleepyHeadFrame::SleepyHeadFrame(wxFrame *frame)
if (pref.Exists("ShowSerialNumbers")) ViewMenuSerial->Check(pref["ShowSerialNumbers"]);
// wxDisableAsserts();
// wxDisableAsserts();
// Create AUINotebook Tabs
wxCommandEvent dummy;
OnViewMenuSummary(dummy); // Summary Page
OnViewMenuDaily(dummy); // Daily Page
this->Connect(wxID_ANY, wxEVT_DO_SCREENSHOT, wxCommandEventHandler(SleepyHeadFrame::DoScreenshot));
//this->Connect(wxID_ANY, wxEVT_MACHINE_SELECTED, wxCommandEventHandler(SleepyHeadFrame::OnMachineSelected));
//this->Connect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SleepyHeadFrame::DoScreenshot));
#if wxUSE_STATUSBAR
//statusBar->SetStatusText(_("Hello!"), 0);
@ -100,15 +99,9 @@ SleepyHeadFrame::SleepyHeadFrame(wxFrame *frame)
SleepyHeadFrame::~SleepyHeadFrame()
{
//delete summary;
//DestroyLoaders();
}
void SleepyHeadFrame::UpdateProfiles()
{
// cpap_machines=profile->GetMachines(MT_CPAP);
wxMenuItemList z=ProfileMenu->GetMenuItems();
int i=ProfileMenuID;
@ -199,8 +192,8 @@ void SleepyHeadFrame::OnScreenshot(wxCommandEvent& event)
ToolsMenu->UpdateUI();
//wxWindow::DoUpdateWindowUI();
wxWindow::UpdateWindowUI();
//Refresh(true); // Make sure the menu is closed.. (It pushes the Update event in front of the manual event we push next)
//Update(true);
// TODO: Make sure the menu is closed.. (It pushes the Update event in front of the manual event we push next)
wxCommandEvent MyEvent( wxEVT_DO_SCREENSHOT);
wxPostEvent(this, MyEvent);
@ -343,9 +336,6 @@ Summary::Summary(wxWindow *win,Profile *_profile)
PRESSURE=new gGraphWindow(ScrolledWindow,-1,wxT("Pressure"),wxPoint(0,0), wxSize(400,180), wxNO_BORDER);
PRESSURE->SetMargins(10,15,65,80);
//PRESSURE->AddLayer(new gBarChart(pressure,wxBLUE));
//PRESSURE->AddLayer(new gLineChart(pressure_eap,wxRED,6192,false,true));
//PRESSURE->AddLayer(new gLineChart(pressure_iap,wxBLUE,6192,false,true));
PRESSURE->AddLayer(new gYAxis(wxBLACK));
PRESSURE->AddLayer(new gXAxis(wxBLACK));
PRESSURE->AddLayer(prmax=new gLineChart(pressure_max,wxBLUE,6192,false,true,true));
@ -512,33 +502,28 @@ void Summary::OnRBSelect( wxCommandEvent& event )
EnableDatePickers(false);
}
EndDatePicker->SetRange(start,profile->LastDay()+wxTimeSpan::Day());
StartDatePicker->SetRange(profile->FirstDay()+wxTimeSpan::Day(),end);
StartDatePicker->SetValue(start);
EndDatePicker->SetValue(end);
RefreshData();
/*for (list<HistoryData *>::iterator h=Data.begin();h!=Data.end();h++) {
(*h)->SetDateRange(start-wxTimeSpan::Day(),end);
} */
}
void Summary::OnStartDateChanged( wxDateEvent& event )
{
wxDateTime st=StartDatePicker->GetValue();
EndDatePicker->SetRange(st,profile->LastDay()+wxTimeSpan::Day());
RefreshData();
/*
wxDateTime start=StartDatePicker->GetValue()-wxTimeSpan::Days(2);
wxDateTime end=EndDatePicker->GetValue()-wxTimeSpan::Day();
for (list<HistoryData *>::iterator h=Data.begin();h!=Data.end();h++) {
(*h)->SetDateRange(start,end);
} */
}
void Summary::OnEndDateChanged( wxDateEvent& event )
{
wxDateTime et=EndDatePicker->GetValue();
StartDatePicker->SetRange(profile->FirstDay()+wxTimeSpan::Day(),et);
RefreshData();
/*wxDateTime start=StartDatePicker->GetValue()-wxTimeSpan::Days(2);
wxDateTime end=EndDatePicker->GetValue()-wxTimeSpan::Day();
for (list<HistoryData *>::iterator h=Data.begin();h!=Data.end();h++) {
(*h)->SetDateRange(start,end);
} */
}
void Summary::OnClose(wxCloseEvent &event)
{
@ -546,38 +531,13 @@ void Summary::OnClose(wxCloseEvent &event)
}
/*
MyListBox::MyListBox(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name)
:wxListBox(parent,id,pos,size,n,choices,style,validator,name)
{
InvalidateBestSize();
Clear();
}
wxSize MyListBox::DoGetBestSize() const
{
wxSize best(200, 50);
// CacheBestSize(best);
return best;
}
*/
Daily::Daily(wxWindow *win,Profile *p)
:DailyPanel(win),profile(p)
{
//SessionList=new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
//SessionList->SetMinSize(wxSize(200,50));
//SessionList->SetMaxSize(wxSize(200,50));
//m_mgr.AddPane(SessionList,wxLEFT,wxT("Sessions"));
HTMLInfo=new wxHtmlWindow(this);
EventTree=new wxTreeCtrl(this);
//Connect(wxID_ANY,EventTree
this->Connect(wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( Daily::OnEventTreeSelection), NULL, this);
Notebook->AddPage(HTMLInfo,wxT("Details"),false,NULL);
Notebook->AddPage(EventTree,wxT("Events"),false,NULL);
@ -699,7 +659,6 @@ Daily::Daily(wxWindow *win,Profile *p)
Daily::~Daily()
{
this->Disconnect(wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( Daily::OnEventTreeSelection), NULL, this);
// delete SessionList;
}
void Daily::OnClose(wxCloseEvent &event)
{
@ -854,9 +813,6 @@ void Daily::RefreshData()
html=html+wxT("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n");
html=html+wxT("<tr><td colspan=2 align=center><i>")+_("Other Information")+wxT("</i></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>Session Informaton</i></td></tr>\n");
html=html+wxT("<tr><td><b>")+_("Mode")+wxT("</b></td><td>")+modestr+wxT("</td></tr>\n");
html=html+wxT("<tr><td><b>")+_("Relief")+wxT("</b></td><td>")+epr+wxT("</td></tr>\n");
if (mode==MODE_CPAP) {
@ -918,57 +874,17 @@ void Daily::RefreshData()
html=html+wxT("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n");
html=html+wxT("<tr><td colspan=2 align=center><i>")+_("Session Files")+wxT("</i></td></tr>\n");
//SessionList->Clear();
for (vector<Session *>::iterator i=d->begin();i!=d->end();i++) {
//wxString a=wxString::Format(wxT("Session %i"),(*i)->session());
//SessionList->Append(a);
html=html+wxT("<tr><td colspan=2 align=center>")+(*i)->first().Format(wxT("%d-%m-%Y %H:%M:%S"))+wxT(" ")+wxString::Format(wxT("%05i"),(*i)->session())+wxT("</td></tr>\n");
html=html+wxT("<tr><td colspan=2 align=center>")+(*i)->last().Format(wxT("%d-%m-%Y %H:%M:%S"))+wxT(" ")+wxString::Format(wxT("%05i"),(*i)->session())+wxT("</td></tr>\n");
}
//SessionList->SetSelection(0);
html=html+wxT("</table>");
html+=wxT("</body></html>");
HTMLInfo->SetPage(html);
/*
if (d->size()>1) {
if (!SessionList->IsShown()) {
SessionList->Show(true);
SessionList->SetMinSize(wxSize(200,45));
SessionList->SetMaxSize(wxSize(200,45));
m_mgr.AddPane(SessionList,wxLEFT,wxEmptyString);
m_mgr.GetPane(SessionList).MinSize(200,45);
m_mgr.GetPane(SessionList).MaxSize(200,45);
m_mgr.GetPane(SessionList).CaptionVisible(false);
m_mgr.GetPane(Calendar).Position(0);
m_mgr.GetPane(SessionList).Position(1);
m_mgr.GetPane(HTMLInfo).Position(2);
m_mgr.Update();
//Refresh();
}
} else {
if (SessionList->IsShown()) {
m_mgr.DetachPane(SessionList);
SessionList->Hide();
m_mgr.Update();
//Refresh();
}
//m_mgr.Update();
}
*/
} else {
HTMLInfo->SetPage(_("<i>No data available for this day</i>"));
/*if (SessionList->IsShown()) {
m_mgr.DetachPane(SessionList);
SessionList->Hide();
m_mgr.Update();
//Refresh();
}*/
}
}

View File

@ -18,9 +18,6 @@
#include "GUIFrame.h"
#include "sleeplib/machine.h"
#include "graphs/graph.h"
//#include "graphs/sleepflagsgraph.h"
//#include "graphs/cpap_wavegraph.h"
//#include "graphs/cpap_pressure.h"
class Summary:public SummaryPanel
{
@ -31,8 +28,6 @@ public:
void ResetProfile(Profile *p);
void AddData(HistoryData *d) { Data.push_back(d); };
// void SetProfile(Profile *p);
HistoryData *ahidata,*pressure,*leak,*usage,*bedtime,*waketime,*pressure_iap,*pressure_eap;
HistoryData *pressure_min,*pressure_max;
@ -56,14 +51,6 @@ protected:
};
/*class MyListBox:public wxListBox
{
public:
// DECLARE_DYNAMIC_CLASS(MyListBox)
MyListBox(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n = 0, const wxString choices[] = NULL, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxT("listBox"));
virtual wxSize DoGetBestSize() const;
}; */
class Daily:public DailyPanel
{
public:
@ -92,7 +79,6 @@ protected:
wxHtmlWindow *HTMLInfo;
wxTreeCtrl *EventTree;
//wxListBox *SessionList;
};
const wxEventType wxEVT_DO_SCREENSHOT = wxNewEventType();

View File

@ -12,7 +12,6 @@ extern wxProgressDialog *loader_progress;
map<MachineType,ChannelCode> MachLastCode;
/* ChannelCode RegisterChannel(MachineType type)
{
if (MachLastCode.find(type)==MachLastCode.end()) {
@ -309,10 +308,6 @@ bool Machine::Load()
for (s=sessfiles.begin(); s!=sessfiles.end(); s++) {
Session *sess=new Session(this,s->first);
if (sess->LoadSummary(s->second[0])) {
//sess->SetEventFile(sessfiles[sess->id()][1]);
//sess->SetWaveformFile(sessfiles[sess->id()][1]);
//wxString sx=sess->first().Format()+wxT(" ")+sess->last().Format();
// wxPrintf(s+wxT(" O=%i H=%i CA=%i \n"),sess->summary[CPAP_Obstructive].GetLong(),sess->summary[CPAP_Hypopnea].GetLong(),sess->summary[CPAP_ClearAirway].GetLong());
// sess->LoadEvents(s->second[1]);
// sess->LoadWaveforms(s->second[2]);
sess->SetEventFile(s->second[1]);
@ -951,8 +946,6 @@ void Session::AddWaveform(Waveform *w)
//wxLogMessage(w->start().Format(wxT("%Y-%m-%d %H:%M:%S"))+wxT(" ")+w->end().Format(wxT("%Y-%m-%d %H:%M:%S"))+wxString::Format(wxT(" %i %.1f"),w->samples(), w->duration()));
// Could parse the flow data for Breaths per minute info here..
}
void Session::TrashEvents()
// Trash this sessions Events and release memory.
@ -1001,26 +994,6 @@ int pack(char * buf,T * var)
return s;
}
/*bool Session::Load(wxString path) // Not Used..
// Load Session Data from our format
// {DataDir}/{MachineID}/{SessionID}.{ext}
{
path=path+wxFileName::GetPathSeparator()+s_machine->hexid();
wxString base;
base.Printf(wxT("%08x"),s_session);
base=path+wxFileName::GetPathSeparator()+base;
wxPuts(wxT("Loading Session: ")+base);
bool a,b,c;
summary.clear();
TrashEvents();
TrashWaveforms();
//try...
a=LoadSummary(base+wxT(".000"));
b=LoadEvents(base+wxT(".001"));
c=LoadWaveforms(base+wxT(".002"));
return a;
}*/
bool Session::Store(wxString path)
// Storing Session Data in our format
// {DataDir}/{MachineID}/{SessionID}.{ext}

View File

@ -183,14 +183,10 @@ public:
const wxDateTime & FirstDay() { return firstday; };
const wxDateTime & LastDay() { return lastday; };
// const wxDateTime & MinTime(const wxDateTime & date);
// const wxDateTime & MaxTime(const wxDateTime & date);
protected:
wxDateTime firstday,lastday;
MachineID m_id;
//wxString m_filename;
wxString m_class;
MachineType m_type;
wxString m_path;
@ -381,7 +377,6 @@ class CPAP:public Machine
public:
CPAP(Profile *p,MachineID id=0);
virtual ~CPAP();
// virtual bool Open(wxString path);
map<MachineCode,wxColour> FlagColours;
map<MachineCode,FlagType> FlagTypes;
list<MachineCode> SleepFlags;
@ -392,7 +387,6 @@ class Oximeter:public Machine
public:
Oximeter(Profile *p,MachineID id=0);
virtual ~Oximeter();
// virtual bool Open(wxString path){};
protected:
};
@ -401,7 +395,6 @@ class SleepStage:public Machine
public:
SleepStage(Profile *p,MachineID id=0);
virtual ~SleepStage();
// virtual bool Open(wxString path){};
protected:
};

View File

@ -16,14 +16,14 @@ namespace AutoVersion{
//Standard Version Type
static const long MAJOR = 0;
static const long MINOR = 7;
static const long BUILD = 3059;
static const long REVISION = 11307;
static const long BUILD = 3066;
static const long REVISION = 11342;
//Miscellaneous Version Types
static const long BUILDS_COUNT = 8974;
#define RC_FILEVERSION 0,7,3059,11307
#define RC_FILEVERSION_STRING "0, 7, 3059, 11307\0"
static const char FULLVERSION_STRING[] = "0.7.3059.11307";
static const long BUILDS_COUNT = 8995;
#define RC_FILEVERSION 0,7,3066,11342
#define RC_FILEVERSION_STRING "0, 7, 3066, 11342\0"
static const char FULLVERSION_STRING[] = "0.7.3066.11342";
//These values are to keep track of your versioning state, don't modify them.
static const long BUILD_HISTORY = 62;