From 74ce4850a94a76f46eea39b5960fb88a0757f70d Mon Sep 17 00:00:00 2001
From: Mark Watkins <jedimark@users.sourceforge.net>
Date: Sat, 4 Jun 2011 12:38:18 +1000
Subject: [PATCH] Added Events View Tree

---
 GUIFrame.cpp              |   7 +-
 GUIFrame.h                |   4 +-
 SleepyHead.depend         |  63 +++++++++++---
 SleepyHead.layout         |  14 +--
 SleepyHeadMain.cpp        |  62 ++++++++++++--
 SleepyHeadMain.h          |   7 +-
 WxWizFrame.fbp            | 173 ++++++++++++++++++++------------------
 graphs/graph.cpp          |   7 +-
 libs/sleeplib/machine.cpp |  33 ++++++--
 libs/sleeplib/machine.h   |   1 +
 version.h                 |  14 +--
 11 files changed, 255 insertions(+), 130 deletions(-)

diff --git a/GUIFrame.cpp b/GUIFrame.cpp
index 9a922610..c9a5eb1c 100644
--- a/GUIFrame.cpp
+++ b/GUIFrame.cpp
@@ -132,9 +132,6 @@ DailyPanel::DailyPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, con
 	Calendar = new wxCalendarCtrl( this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxCAL_MONDAY_FIRST|wxCAL_SEQUENTIAL_MONTH_SELECTION|wxCAL_SHOW_SURROUNDING_WEEKS );
 	m_mgr.AddPane( Calendar, wxAuiPaneInfo() .Left() .Caption( wxT("Selected Day") ).CloseButton( false ).MaximizeButton( false ).MinimizeButton( false ).PinButton( true ).PaneBorder( false ).Dock().Fixed().BottomDockable( false ).TopDockable( false ) );
 	
-	HTMLInfo = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
-	m_mgr.AddPane( HTMLInfo, wxAuiPaneInfo() .Left() .Caption( wxT("Day Summary") ).CloseButton( false ).MaximizeButton( false ).MinimizeButton( false ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( 208,424 ) ).DockFixed( false ).Row( 0 ).Position( 1 ).MinSize( wxSize( 200,400 ) ).Layer( 0 ) );
-	
 	ScrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
 	ScrolledWindow->SetScrollRate( 5, 5 );
 	m_mgr.AddPane( ScrolledWindow, wxAuiPaneInfo() .Center() .Caption( wxT("Daily Information") ).CloseButton( false ).MaximizeButton( false ).MinimizeButton( false ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( -1,-1 ) ).Row( 0 ).Layer( 1 ).CentrePane() );
@@ -147,6 +144,10 @@ DailyPanel::DailyPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, con
 	ScrolledWindow->SetSizer( fgSizer );
 	ScrolledWindow->Layout();
 	fgSizer->Fit( ScrolledWindow );
+	Notebook = new wxAuiNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT );
+	m_mgr.AddPane( Notebook, wxAuiPaneInfo() .Left() .CaptionVisible( false ).CloseButton( false ).MaximizeButton( false ).MinimizeButton( false ).PinButton( false ).PaneBorder( false ).Dock().Resizable().FloatingSize( wxDefaultSize ).DockFixed( false ).Position( 1 ).MinSize( wxSize( 220,-1 ) ) );
+	
+	
 	
 	m_mgr.Update();
 	
diff --git a/GUIFrame.h b/GUIFrame.h
index fc2fd8c0..82d484ca 100644
--- a/GUIFrame.h
+++ b/GUIFrame.h
@@ -24,10 +24,10 @@
 #include <wx/frame.h>
 #include <wx/aui/aui.h>
 #include <wx/calctrl.h>
-#include <wx/html/htmlwin.h>
 #include <wx/sizer.h>
 #include <wx/scrolwin.h>
 #include <wx/panel.h>
+#include <wx/html/htmlwin.h>
 #include <wx/radiobut.h>
 #include <wx/stattext.h>
 #include <wx/datectrl.h>
@@ -86,9 +86,9 @@ class DailyPanel : public wxPanel
 	
 	protected:
 		wxCalendarCtrl* Calendar;
-		wxHtmlWindow* HTMLInfo;
 		wxScrolledWindow* ScrolledWindow;
 		wxFlexGridSizer* fgSizer;
+		wxAuiNotebook* Notebook;
 		
 		// Virtual event handlers, overide them in your derived class
 		virtual void OnCalendarMonth( wxCalendarEvent& event ) { event.Skip(); }
diff --git a/SleepyHead.depend b/SleepyHead.depend
index 7e4f562a..311498dd 100644
--- a/SleepyHead.depend
+++ b/SleepyHead.depend
@@ -7785,12 +7785,12 @@
 	"wx/progdlg.h"
 	"wx/dialog.h"
 
-1306939868 source:/home/mark/projects/git/sleepyhead/GUIFrame.cpp
+1307154469 source:/home/mark/projects/git/sleepyhead/GUIFrame.cpp
 	"wx/wxprec.h"
 	<wx/wx.h>
 	"GUIFrame.h"
 
-1306857828 /home/mark/projects/git/sleepyhead/GUIFrame.h
+1307154004 /home/mark/projects/git/sleepyhead/GUIFrame.h
 	<wx/intl.h>
 	<wx/string.h>
 	<wx/bitmap.h>
@@ -7806,10 +7806,10 @@
 	<wx/frame.h>
 	<wx/aui/aui.h>
 	<wx/calctrl.h>
-	<wx/html/htmlwin.h>
 	<wx/sizer.h>
 	<wx/scrolwin.h>
 	<wx/panel.h>
+	<wx/html/htmlwin.h>
 	<wx/radiobut.h>
 	<wx/stattext.h>
 	<wx/datectrl.h>
@@ -7831,14 +7831,15 @@
 1305881106 /home/mark/projects/git/sleepyhead/SleepyHeadApp.h
 	<wx/app.h>
 
-1307058662 /home/mark/projects/git/sleepyhead/SleepyHeadMain.h
-	"SleepyHeadApp.h"
+1307153810 /home/mark/projects/git/sleepyhead/SleepyHeadMain.h
 	<wx/listbox.h>
+	<wx/treectrl.h>
+	"SleepyHeadApp.h"
 	"GUIFrame.h"
 	"sleeplib/machine.h"
 	"graphs/graph.h"
 
-1307038106 /home/mark/projects/git/sleepyhead/libs/sleeplib/machine.h
+1307151648 /home/mark/projects/git/sleepyhead/libs/sleeplib/machine.h
 	<wx/string.h>
 	<wx/variant.h>
 	<wx/dir.h>
@@ -7876,7 +7877,7 @@
 	<sleeplib/machine.h>
 	<list>
 
-1307088642 /home/mark/projects/git/sleepyhead/version.h
+1307154989 /home/mark/projects/git/sleepyhead/version.h
 
 1306724655 /home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.h
 	"machine.h"
@@ -7893,7 +7894,7 @@
 	"preferences.h"
 	"tinyxml/tinyxml.h"
 
-1307088511 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp
+1307154989 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp
 	"wx_pch.h"
 	"version.h"
 	<wx/app.h>
@@ -7912,7 +7913,7 @@
 	"sleeplib/profiles.h"
 	"sleeplib/machine_loader.h"
 
-1307088318 source:/home/mark/projects/git/sleepyhead/graphs/graph.cpp
+1307151759 source:/home/mark/projects/git/sleepyhead/graphs/graph.cpp
 	<wx/settings.h>
 	<wx/dcbuffer.h>
 	<wx/log.h>
@@ -7927,7 +7928,7 @@
 	<wx/ffile.h>
 	<wx/utils.h>
 
-1307040615 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/machine.cpp
+1307153428 source:/home/mark/projects/git/sleepyhead/libs/sleeplib/machine.cpp
 	<tr1/random>
 	<wx/colour.h>
 	<wx/log.h>
@@ -8128,3 +8129,45 @@
 
 1302101440 /usr/include/wx-2.8/wx/generic/collpaneg.h
 
+1302101441 /usr/include/wx-2.8/wx/dataview.h
+	"wx/defs.h"
+	"wx/control.h"
+	"wx/textctrl.h"
+	"wx/bitmap.h"
+	"wx/variant.h"
+	"wx/generic/dataview.h"
+	"wx/gtk/dataview.h"
+	"wx/generic/dataview.h"
+
+1302101441 /usr/include/wx-2.8/wx/generic/dataview.h
+	"wx/defs.h"
+	"wx/object.h"
+	"wx/list.h"
+	"wx/control.h"
+	"wx/scrolwin.h"
+	"wx/icon.h"
+
+1302101441 /usr/include/wx-2.8/wx/treectrl.h
+	"wx/defs.h"
+	"wx/control.h"
+	"wx/treebase.h"
+	"wx/textctrl.h"
+	"wx/generic/treectlg.h"
+	"wx/palmos/treectrl.h"
+	"wx/msw/treectrl.h"
+	"wx/generic/treectlg.h"
+	"wx/generic/treectlg.h"
+	"wx/generic/treectlg.h"
+	"wx/generic/treectlg.h"
+	"wx/generic/treectlg.h"
+
+1302101441 /usr/include/wx-2.8/wx/treebase.h
+	"wx/defs.h"
+	"wx/window.h"
+	"wx/event.h"
+	"wx/dynarray.h"
+
+1302101440 /usr/include/wx-2.8/wx/generic/treectlg.h
+	"wx/scrolwin.h"
+	"wx/pen.h"
+
diff --git a/SleepyHead.layout b/SleepyHead.layout
index 160142b0..d5cbbeb9 100644
--- a/SleepyHead.layout
+++ b/SleepyHead.layout
@@ -10,14 +10,14 @@
 	<File name="SleepyHeadApp.cpp" open="1" top="0" tabpos="10">
 		<Cursor position="1061" topLine="14" />
 	</File>
-	<File name="SleepyHeadMain.cpp" open="1" top="1" tabpos="3">
-		<Cursor position="21805" topLine="553" />
+	<File name="SleepyHeadMain.cpp" open="1" top="0" tabpos="3">
+		<Cursor position="26665" topLine="735" />
 	</File>
 	<File name="SleepyHeadMain.h" open="1" top="0" tabpos="4">
-		<Cursor position="550" topLine="15" />
+		<Cursor position="2793" topLine="67" />
 	</File>
 	<File name="graphs/graph.cpp" open="1" top="0" tabpos="6">
-		<Cursor position="36899" topLine="1392" />
+		<Cursor position="27211" topLine="1036" />
 	</File>
 	<File name="graphs/graph.h" open="1" top="0" tabpos="5">
 		<Cursor position="2182" topLine="42" />
@@ -29,10 +29,10 @@
 		<Cursor position="0" topLine="0" />
 	</File>
 	<File name="libs/sleeplib/machine.cpp" open="1" top="0" tabpos="1">
-		<Cursor position="1304" topLine="19" />
+		<Cursor position="4983" topLine="84" />
 	</File>
-	<File name="libs/sleeplib/machine.h" open="1" top="0" tabpos="2">
-		<Cursor position="786" topLine="14" />
+	<File name="libs/sleeplib/machine.h" open="1" top="1" tabpos="2">
+		<Cursor position="148" topLine="0" />
 	</File>
 	<File name="libs/sleeplib/machine_loader.cpp" open="0" top="0" tabpos="8">
 		<Cursor position="0" topLine="0" />
diff --git a/SleepyHeadMain.cpp b/SleepyHeadMain.cpp
index 2dda5525..c8fbaeb5 100644
--- a/SleepyHeadMain.cpp
+++ b/SleepyHeadMain.cpp
@@ -289,7 +289,6 @@ void SleepyHeadFrame::OnImportSD(wxCommandEvent &event)
 void SleepyHeadFrame::OnViewMenuDaily( wxCommandEvent& event )
 {
     int idx=main_auinotebook->GetPageIndex(daily);
-    unsigned int id;
     if (idx==wxNOT_FOUND) {
         daily=new Daily(this,profile);
         main_auinotebook->AddPage(daily,_("Daily"),true);
@@ -305,7 +304,7 @@ void SleepyHeadFrame::OnViewMenuDaily( wxCommandEvent& event )
 void SleepyHeadFrame::OnViewMenuSummary( wxCommandEvent& event )
 {
 
-    int id,idx=main_auinotebook->GetPageIndex(summary);
+    int idx=main_auinotebook->GetPageIndex(summary);
     if (idx==wxNOT_FOUND) {
         summary=new Summary(this,profile);
         main_auinotebook->AddPage(summary,_("Summary"),true);
@@ -562,6 +561,7 @@ wxSize MyListBox::DoGetBestSize() const
 }
 */
 
+
 Daily::Daily(wxWindow *win,Profile *p)
 :DailyPanel(win),profile(p)
 {
@@ -571,6 +571,12 @@ Daily::Daily(wxWindow *win,Profile *p)
 
     //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);
     AddData(tap_eap=new TAPData(CPAP_EAP));
     AddData(tap_iap=new TAPData(CPAP_IAP));
     AddData(tap=new TAPData(CPAP_Pressure));
@@ -688,12 +694,26 @@ 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)
 {
     Destroy();
 }
+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);
+        wxLogMessage(wxT("Tree Selected:")+d.Format());
+    }
+}
 
 void Daily::ResetDate()
 {
@@ -719,7 +739,6 @@ void Daily::RefreshData()
     date-=wxTimeSpan::Days(1);
 
     Day *d=NULL;
-
     if (profile->daylist.find(date)!=profile->daylist.end()) {
         vector<Day *>::iterator di;
         for (di=profile->daylist[date].begin();di!=profile->daylist[date].end();di++) {
@@ -744,6 +763,39 @@ void Daily::RefreshData()
             TAP_EAP->Show(true);
         }
 
+        EventTree->DeleteAllItems();
+        wxTreeItemId root=EventTree->AddRoot(wxT("Events"));
+        map<MachineCode,wxTreeItemId> mcroot;
+
+        for (vector<Session *>::iterator s=d->begin();s!=d->end();s++) {
+
+            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;
+                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++) {
+                    EventTree->AppendItem(mcr,(*e)->time().Format(wxT("%Y-%m-%d %H:%M:%S")),-1,-1);
+                }
+            }
+        }
+        EventTree->SortChildren(root);
+        EventTree->Expand(root);
+
         fgSizer->Layout();
         ScrolledWindow->FitInside();
 
@@ -759,7 +811,7 @@ void Daily::RefreshData()
         float rei=d->count(CPAP_RERA)/d->hours();
         float vsi=d->count(CPAP_VSnore)/d->hours();
         float fli=d->count(CPAP_FlowLimit)/d->hours();
-        float p90=d->percentile(CPAP_Pressure,0,0.9);
+//        float p90=d->percentile(CPAP_Pressure,0,0.9);
         float eap90=d->percentile(CPAP_EAP,0,0.9);
         float iap90=d->percentile(CPAP_IAP,0,0.9);
         wxString submodel=_("Unknown Model");
@@ -898,7 +950,7 @@ void Daily::RefreshData()
         }
 */
     } else {
-        HTMLInfo->SetPage(_("<i>Please import some data</i>"));
+        HTMLInfo->SetPage(_("<i>No data available for this day</i>"));
 
         /*if (SessionList->IsShown()) {
             m_mgr.DetachPane(SessionList);
diff --git a/SleepyHeadMain.h b/SleepyHeadMain.h
index 7da89a0f..4e2d7c69 100644
--- a/SleepyHeadMain.h
+++ b/SleepyHeadMain.h
@@ -11,9 +11,10 @@
 #define SLEEPYHEADMAIN_H
 
 
+#include <wx/listbox.h>
+#include <wx/treectrl.h>
 
 #include "SleepyHeadApp.h"
-#include <wx/listbox.h>
 #include "GUIFrame.h"
 #include "sleeplib/machine.h"
 #include "graphs/graph.h"
@@ -76,6 +77,7 @@ protected:
 	virtual void OnCalendarMonth( wxCalendarEvent& event );
     virtual void OnClose(wxCloseEvent &event);
     virtual void OnSelectSession( wxCommandEvent& event );
+    virtual void OnEventTreeSelection( wxTreeEvent& event );
 
 	void AddData(gPointData *d) { Data.push_back(d);  };
 	void UpdateGraphs(Day *day);
@@ -87,6 +89,9 @@ protected:
 
     Profile *profile;
     list<gPointData *> Data;
+    wxHtmlWindow *HTMLInfo;
+    wxTreeCtrl *EventTree;
+
     //wxListBox *SessionList;
 };
 
diff --git a/WxWizFrame.fbp b/WxWizFrame.fbp
index 431ffc4b..4b7d6b0c 100644
--- a/WxWizFrame.fbp
+++ b/WxWizFrame.fbp
@@ -714,89 +714,6 @@
                 <event name="OnSize"></event>
                 <event name="OnUpdateUI"></event>
             </object>
-            <object class="wxHtmlWindow" expanded="1">
-                <property name="BottomDockable">1</property>
-                <property name="LeftDockable">1</property>
-                <property name="RightDockable">1</property>
-                <property name="TopDockable">1</property>
-                <property name="aui_name"></property>
-                <property name="best_size"></property>
-                <property name="bg"></property>
-                <property name="caption">Day Summary</property>
-                <property name="caption_visible">1</property>
-                <property name="center_pane">0</property>
-                <property name="close_button">0</property>
-                <property name="context_help"></property>
-                <property name="context_menu">1</property>
-                <property name="default_pane">0</property>
-                <property name="dock">Dock</property>
-                <property name="dock_fixed">0</property>
-                <property name="docking">Left</property>
-                <property name="enabled">1</property>
-                <property name="fg"></property>
-                <property name="floatable">1</property>
-                <property name="font"></property>
-                <property name="gripper">0</property>
-                <property name="hidden">0</property>
-                <property name="id">wxID_ANY</property>
-                <property name="layer">0</property>
-                <property name="max_size"></property>
-                <property name="maximize_button">0</property>
-                <property name="maximum_size"></property>
-                <property name="min_size">200,400</property>
-                <property name="minimize_button">0</property>
-                <property name="minimum_size"></property>
-                <property name="moveable">1</property>
-                <property name="name">HTMLInfo</property>
-                <property name="pane_border">1</property>
-                <property name="pane_position">467,397</property>
-                <property name="pane_size">208,424</property>
-                <property name="permission">protected</property>
-                <property name="pin_button">1</property>
-                <property name="pos"></property>
-                <property name="position">1</property>
-                <property name="resize">Resizable</property>
-                <property name="row">0</property>
-                <property name="show">1</property>
-                <property name="size"></property>
-                <property name="style">wxHW_SCROLLBAR_AUTO</property>
-                <property name="subclass"></property>
-                <property name="toolbar_pane">0</property>
-                <property name="tooltip"></property>
-                <property name="validator_data_type"></property>
-                <property name="validator_style">wxFILTER_NONE</property>
-                <property name="validator_type">wxDefaultValidator</property>
-                <property name="validator_variable"></property>
-                <property name="window_extra_style"></property>
-                <property name="window_name"></property>
-                <property name="window_style"></property>
-                <event name="OnChar"></event>
-                <event name="OnEnterWindow"></event>
-                <event name="OnEraseBackground"></event>
-                <event name="OnHtmlCellClicked"></event>
-                <event name="OnHtmlCellHover"></event>
-                <event name="OnHtmlLinkClicked"></event>
-                <event name="OnKeyDown"></event>
-                <event name="OnKeyUp"></event>
-                <event name="OnKillFocus"></event>
-                <event name="OnLeaveWindow"></event>
-                <event name="OnLeftDClick"></event>
-                <event name="OnLeftDown"></event>
-                <event name="OnLeftUp"></event>
-                <event name="OnMiddleDClick"></event>
-                <event name="OnMiddleDown"></event>
-                <event name="OnMiddleUp"></event>
-                <event name="OnMotion"></event>
-                <event name="OnMouseEvents"></event>
-                <event name="OnMouseWheel"></event>
-                <event name="OnPaint"></event>
-                <event name="OnRightDClick"></event>
-                <event name="OnRightDown"></event>
-                <event name="OnRightUp"></event>
-                <event name="OnSetFocus"></event>
-                <event name="OnSize"></event>
-                <event name="OnUpdateUI"></event>
-            </object>
             <object class="wxScrolledWindow" expanded="1">
                 <property name="BottomDockable">1</property>
                 <property name="LeftDockable">1</property>
@@ -891,6 +808,96 @@
                     <property name="vgap">0</property>
                 </object>
             </object>
+            <object class="wxAuiNotebook" expanded="1">
+                <property name="BottomDockable">1</property>
+                <property name="LeftDockable">1</property>
+                <property name="RightDockable">1</property>
+                <property name="TopDockable">1</property>
+                <property name="aui_name"></property>
+                <property name="best_size"></property>
+                <property name="bg"></property>
+                <property name="caption"></property>
+                <property name="caption_visible">0</property>
+                <property name="center_pane">0</property>
+                <property name="close_button">0</property>
+                <property name="context_help"></property>
+                <property name="context_menu">1</property>
+                <property name="default_pane">0</property>
+                <property name="dock">Dock</property>
+                <property name="dock_fixed">0</property>
+                <property name="docking">Left</property>
+                <property name="enabled">1</property>
+                <property name="fg"></property>
+                <property name="floatable">1</property>
+                <property name="font"></property>
+                <property name="gripper">0</property>
+                <property name="hidden">0</property>
+                <property name="id">wxID_ANY</property>
+                <property name="layer"></property>
+                <property name="max_size"></property>
+                <property name="maximize_button">0</property>
+                <property name="maximum_size"></property>
+                <property name="min_size">220,-1</property>
+                <property name="minimize_button">0</property>
+                <property name="minimum_size"></property>
+                <property name="moveable">1</property>
+                <property name="name">Notebook</property>
+                <property name="pane_border">0</property>
+                <property name="pane_position"></property>
+                <property name="pane_size"></property>
+                <property name="permission">protected</property>
+                <property name="pin_button">0</property>
+                <property name="pos"></property>
+                <property name="position">1</property>
+                <property name="resize">Resizable</property>
+                <property name="row"></property>
+                <property name="show">1</property>
+                <property name="size"></property>
+                <property name="style">wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT</property>
+                <property name="subclass"></property>
+                <property name="tab_ctrl_height">-1</property>
+                <property name="toolbar_pane">0</property>
+                <property name="tooltip"></property>
+                <property name="uniform_bitmap_size"></property>
+                <property name="validator_data_type"></property>
+                <property name="validator_style">wxFILTER_NONE</property>
+                <property name="validator_type">wxDefaultValidator</property>
+                <property name="validator_variable"></property>
+                <property name="window_extra_style"></property>
+                <property name="window_name"></property>
+                <property name="window_style"></property>
+                <event name="OnAuiNotebookAllowDND"></event>
+                <event name="OnAuiNotebookBeginDrag"></event>
+                <event name="OnAuiNotebookButton"></event>
+                <event name="OnAuiNotebookDragMotion"></event>
+                <event name="OnAuiNotebookEndDrag"></event>
+                <event name="OnAuiNotebookPageChanged"></event>
+                <event name="OnAuiNotebookPageChanging"></event>
+                <event name="OnAuiNotebookPageClose"></event>
+                <event name="OnChar"></event>
+                <event name="OnEnterWindow"></event>
+                <event name="OnEraseBackground"></event>
+                <event name="OnKeyDown"></event>
+                <event name="OnKeyUp"></event>
+                <event name="OnKillFocus"></event>
+                <event name="OnLeaveWindow"></event>
+                <event name="OnLeftDClick"></event>
+                <event name="OnLeftDown"></event>
+                <event name="OnLeftUp"></event>
+                <event name="OnMiddleDClick"></event>
+                <event name="OnMiddleDown"></event>
+                <event name="OnMiddleUp"></event>
+                <event name="OnMotion"></event>
+                <event name="OnMouseEvents"></event>
+                <event name="OnMouseWheel"></event>
+                <event name="OnPaint"></event>
+                <event name="OnRightDClick"></event>
+                <event name="OnRightDown"></event>
+                <event name="OnRightUp"></event>
+                <event name="OnSetFocus"></event>
+                <event name="OnSize"></event>
+                <event name="OnUpdateUI"></event>
+            </object>
         </object>
         <object class="Panel" expanded="1">
             <property name="BottomDockable">1</property>
diff --git a/graphs/graph.cpp b/graphs/graph.cpp
index 5ec5115a..1f5d9f78 100644
--- a/graphs/graph.cpp
+++ b/graphs/graph.cpp
@@ -998,7 +998,7 @@ void gCandleStick::Plot(wxDC & dc, gGraphWindow & w)
         dc.GradientFillLinear(rect,*color[i % color.size()],*wxLIGHT_GREY,dir);
         dc.DrawRectangle(rect);
         str=wxT("");
-        if (m_names.size()>i) {
+        if ((int)m_names.size()>i) {
             str=m_names[i]+wxT(" ");
         }
         str+=wxString::Format(wxT("%0.2f"),data->point[0][i].x);
@@ -1066,7 +1066,7 @@ void gBarChart::Plot(wxDC & dc, gGraphWindow & w)
     dc.SetPen( *wxBLACK_PEN );
 
     float barwidth,pxr;
-    float px,py;
+    float px;//,py;
 
     if (m_direction==wxVERTICAL) {
         barwidth=(height-days)/float(days);
@@ -1086,7 +1086,6 @@ void gBarChart::Plot(wxDC & dc, gGraphWindow & w)
     wxString str;
     bool draw_xticks_instead=false;
 
-    int cnt=0;
     for (int i=0;i<data->np[0];i++) {
         if (data->point[0][i].x < w.min_x) continue;
         if (data->point[0][i].x >= w.max_x) break;
@@ -1454,7 +1453,7 @@ void gFlagsLine::Plot(wxDC & dc, gGraphWindow & w)
 
 
     double line_h=(height+1)/double(total_lines);
-    int r=int(height) % total_lines;
+    //int r=int(height) % total_lines;
 
     double line_top=start_py+round(line_num*line_h)-1;
     //double line_bottom=line_top+line_h;
diff --git a/libs/sleeplib/machine.cpp b/libs/sleeplib/machine.cpp
index 2d598167..ede2df21 100644
--- a/libs/sleeplib/machine.cpp
+++ b/libs/sleeplib/machine.cpp
@@ -75,10 +75,11 @@ map<MachineCode,wxString> DefaultMCShortNames;
     {CPAP_IAP,			wxT("IAP")},
     {PRS1_VSnore2,		wxT("VS")},
     {PRS1_PressurePulse,wxT("PP")}
-};
+}; */
 
 // Master list. Look up local name table first.. then these if not found.
-map<MachineCode,wxString> DefaultMCLongNames= {
+map<MachineCode,wxString> DefaultMCLongNames;
+/*= {
     {CPAP_Obstructive,	wxT("Obstructive Apnea")},
     {CPAP_Hypopnea,		wxT("Hypopnea")},
     {CPAP_RERA,			wxT("Respiratory Effort / Arrousal")},
@@ -88,8 +89,8 @@ map<MachineCode,wxString> DefaultMCLongNames= {
     {CPAP_FlowLimit,	wxT("Flow Limitation")},
     {CPAP_Pressure,		wxT("Pressure")},
     {CPAP_Leak,			wxT("Leak Rate")},
-    {CPAP_EAP,			wxT("BIPAP Exhalation Pressure")},
-    {CPAP_IAP,			wxT("BIPAP Inhalation Pressure")},
+    {CPAP_EAP,			wxT("BIPAP EPAP")},
+    {CPAP_IAP,			wxT("BIPAP IPAP")},
     {PRS1_VSnore2,		wxT("Vibratory Snore")},
     {PRS1_PressurePulse,wxT("Pressue Pulse")}
 }; */
@@ -115,16 +116,32 @@ void InitMapsWithoutAwesomeInitializerLists()
     DefaultMCShortNames[CPAP_Hypopnea]=wxT("H");
     DefaultMCShortNames[CPAP_RERA]=wxT("RE");
     DefaultMCShortNames[CPAP_ClearAirway]=wxT("CA");
-    DefaultMCShortNames[CPAP_CSR]=wxT("CSR");
+    DefaultMCShortNames[CPAP_CSR]=wxT("CSR/PB");
     DefaultMCShortNames[CPAP_VSnore]=wxT("VS");
     DefaultMCShortNames[CPAP_FlowLimit]=wxT("FL");
     DefaultMCShortNames[CPAP_Pressure]=wxT("P");
     DefaultMCShortNames[CPAP_Leak]=wxT("LR");
-    DefaultMCShortNames[CPAP_EAP]=wxT("EAP");
-    DefaultMCShortNames[CPAP_IAP]=wxT("IAP");
-    DefaultMCShortNames[PRS1_VSnore2]=wxT("VS");
+    DefaultMCShortNames[CPAP_EAP]=wxT("EPAP");
+    DefaultMCShortNames[CPAP_IAP]=wxT("IPAP");
+    DefaultMCShortNames[PRS1_VSnore2]=wxT("VS2");
     DefaultMCShortNames[PRS1_PressurePulse]=wxT("PP");
 
+    DefaultMCLongNames[CPAP_Obstructive]=wxT("Obstructive Apnea");
+    DefaultMCLongNames[CPAP_Hypopnea]=wxT("Hypopnea");
+    DefaultMCLongNames[CPAP_RERA]=wxT("RERA");
+    DefaultMCLongNames[CPAP_ClearAirway]=wxT("Clear Airway Apnea");
+    DefaultMCLongNames[CPAP_CSR]=wxT("Periodic Breathing");
+    DefaultMCLongNames[CPAP_VSnore]=wxT("Vibratory Snore");
+    DefaultMCLongNames[CPAP_FlowLimit]=wxT("Flow Limitation");
+    DefaultMCLongNames[CPAP_Pressure]=wxT("Pressure");
+    DefaultMCLongNames[CPAP_Leak]=wxT("Leak Rate");
+    DefaultMCLongNames[CPAP_EAP]=wxT("BIPAP EPAP");
+    DefaultMCLongNames[CPAP_IAP]=wxT("BIPAP IPAP");
+    DefaultMCLongNames[PRS1_VSnore2]=wxT("Vibratory Snore 2");
+    DefaultMCLongNames[PRS1_PressurePulse]=wxT("Pressue Pulse");
+    DefaultMCLongNames[PRS1_Unknown0E]=wxT("Unknown 0E");
+
+
 }
 
 
diff --git a/libs/sleeplib/machine.h b/libs/sleeplib/machine.h
index b4967b79..b0663e70 100644
--- a/libs/sleeplib/machine.h
+++ b/libs/sleeplib/machine.h
@@ -75,6 +75,7 @@ enum PRTypes//:short
 };
 
 extern map<MachineCode,wxString> DefaultMCShortNames;
+extern map<MachineCode,wxString> DefaultMCLongNames;
 extern map<PRTypes,wxString> PressureReliefNames;
 extern map<CPAPMode,wxString> CPAPModeNames;
 
diff --git a/version.h b/version.h
index fe9abe44..10cb635b 100644
--- a/version.h
+++ b/version.h
@@ -4,7 +4,7 @@
 namespace AutoVersion{
 	
 	//Date Version Types
-	static const char DATE[] = "03";
+	static const char DATE[] = "04";
 	static const char MONTH[] = "06";
 	static const char YEAR[] = "2011";
 	static const char UBUNTU_VERSION_STYLE[] = "11.06";
@@ -16,14 +16,14 @@ namespace AutoVersion{
 	//Standard Version Type
 	static const long MAJOR = 0;
 	static const long MINOR = 7;
-	static const long BUILD = 2985;
-	static const long REVISION = 10912;
+	static const long BUILD = 3051;
+	static const long REVISION = 11257;
 	
 	//Miscellaneous Version Types
-	static const long BUILDS_COUNT = 8822;
-	#define RC_FILEVERSION 0,7,2985,10912
-	#define RC_FILEVERSION_STRING "0, 7, 2985, 10912\0"
-	static const char FULLVERSION_STRING[] = "0.7.2985.10912";
+	static const long BUILDS_COUNT = 8949;
+	#define RC_FILEVERSION 0,7,3051,11257
+	#define RC_FILEVERSION_STRING "0, 7, 3051, 11257\0"
+	static const char FULLVERSION_STRING[] = "0.7.3051.11257";
 	
 	//These values are to keep track of your versioning state, don't modify them.
 	static const long BUILD_HISTORY = 62;