From 3a7a32ea60a070e3e1e351d91ab80a0d197d08a6 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Fri, 27 May 2011 20:53:00 +1000 Subject: [PATCH] Linked Graph Experiments --- SleepyHead.depend | 10 +++---- SleepyHeadMain.cpp | 10 +++++++ SleepyHeadMain.h | 3 +- graphs/graph.cpp | 69 ++++++++++++++++++++++++++++++++++------------ graphs/graph.h | 17 ++++++++++-- version.h | 12 ++++---- 6 files changed, 88 insertions(+), 33 deletions(-) diff --git a/SleepyHead.depend b/SleepyHead.depend index 95950987..84cc28fa 100644 --- a/SleepyHead.depend +++ b/SleepyHead.depend @@ -7826,7 +7826,7 @@ 1305881106 /home/mark/projects/git/sleepyhead/SleepyHeadApp.h -1306489831 /home/mark/projects/git/sleepyhead/SleepyHeadMain.h +1306490414 /home/mark/projects/git/sleepyhead/SleepyHeadMain.h "SleepyHeadApp.h" "GUIFrame.h" "sleeplib/machine.h" @@ -7866,11 +7866,11 @@ "tinyxml/tinyxml.h" -1306414968 /home/mark/projects/git/sleepyhead/graphs/graph.h +1306493511 /home/mark/projects/git/sleepyhead/graphs/graph.h -1306489908 /home/mark/projects/git/sleepyhead/version.h +1306493512 /home/mark/projects/git/sleepyhead/version.h 1306415077 /home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.h "machine.h" @@ -7887,7 +7887,7 @@ "preferences.h" "tinyxml/tinyxml.h" -1306488246 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp +1306492903 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp "wx_pch.h" "version.h" @@ -7901,7 +7901,7 @@ "SleepyHeadMain.h" "sleeplib/profiles.h" -1306476745 source:/home/mark/projects/git/sleepyhead/graphs/graph.cpp +1306493295 source:/home/mark/projects/git/sleepyhead/graphs/graph.cpp diff --git a/SleepyHeadMain.cpp b/SleepyHeadMain.cpp index 8c6805ea..2aff430c 100644 --- a/SleepyHeadMain.cpp +++ b/SleepyHeadMain.cpp @@ -334,9 +334,11 @@ Daily::Daily(wxWindow *win) AddData(flags[6]=new FlagData(CPAP_RERA,1)); AddData(flags[7]=new FlagData(PRS1_PressurePulse,1)); AddData(flags[8]=new FlagData(PRS1_VSnore2,1)); + AddData(flags[9]=new FlagData(PRS1_Unknown0E,1)); FRW->AddLayer(new gLineChart(frw,wxBLACK,200000,true)); FRW->AddLayer(new gLineOverlayBar(flags[6],wxYELLOW,wxT("RE"))); + FRW->AddLayer(new gLineOverlayBar(flags[9],wxDARK_GREEN,wxT("U0E"))); 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"))); @@ -347,6 +349,14 @@ Daily::Daily(wxWindow *win) SF=new gGraphWindow(ScrolledWindow,-1,wxT("Sleep Flags"),wxPoint(0,0), wxSize(600,150), wxNO_BORDER); SF->SetMargins(10,15,20,80); + SF->LinkZoom(FRW); + SF->LinkZoom(PRD); + SF->LinkZoom(LEAK); + + const int sfc=9; + + + SF->AddLayer(new gFlagsLine(flags[9],wxDARK_GREEN,wxT("U0E"),8,sfc)); 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)); diff --git a/SleepyHeadMain.h b/SleepyHeadMain.h index 7c2d3265..2d140773 100644 --- a/SleepyHeadMain.h +++ b/SleepyHeadMain.h @@ -33,7 +33,6 @@ public: }; -const int sfc=8; class Daily:public DailyPanel { @@ -51,7 +50,7 @@ protected: bool foobar_datehack; gPointData *tap,*g_ahi,*frw,*prd,*leakdata,*pressure_iap,*pressure_eap; - gPointData *flags[9]; + gPointData *flags[10]; gGraphWindow *PRD,*FRW,*G_AHI,*TAP,*LEAK,*SF; diff --git a/graphs/graph.cpp b/graphs/graph.cpp index cde9a84d..88ff58d3 100644 --- a/graphs/graph.cpp +++ b/graphs/graph.cpp @@ -140,6 +140,20 @@ void gGraphWindow::SetXBounds(double minx, double maxx) Refresh(false); } void gGraphWindow::ZoomXPixels(int x1, int x2) +{ + double rx1=0,rx2=0; + ZoomXPixels(x1,x2,rx1,rx2); + for (auto g=link_zoom.begin();g!=link_zoom.end();g++) { + (*g)->SetXBounds(rx1,rx2); + } + + if (m_block_zoom) { + RefreshRect(m_mouseRBrect,false); + } else { + SetXBounds(rx1,rx2); + } +} +void gGraphWindow::ZoomXPixels(int x1,int x2,double &rx1,double &rx2) { x1-=GetLeftMargin(); x2-=GetLeftMargin(); @@ -151,33 +165,41 @@ void gGraphWindow::ZoomXPixels(int x1, int x2) double min=min_x; double max=max_x; double q=max-min; - double rx1=min+(double(x1)/Width()) * q; - double rx2=min+(double(x2)/Width()) * q; - SetXBounds(rx1,rx2); + rx1=min+(double(x1)/Width()) * q; + rx2=min+(double(x2)/Width()) * q; } // Move x-axis by the amount of space represented by integer i Pixels (negative values moves backwards) -void gGraphWindow::MoveX(int i) +void gGraphWindow::MoveX(int i,double &min, double & max) { //if (i==0) return; - double mx=min_x; - double Mx=max_x; - double q=Mx-mx; + min=min_x; + max=max_x; + double q=max-min; double rx1=(double(i)/Width()) * q; - mx-=rx1; - Mx-=rx1; + min-=rx1; + max-=rx1; // Keep bounds when hitting hard edges - if (mxrmax_x) { - Mx=rmax_x; - mx=Mx-q; + if (max>rmax_x) { + max=rmax_x; + min=max-q; } +} - SetXBounds(mx,Mx); +void gGraphWindow::MoveX(int i) +{ + double min,max; + MoveX(i,min,max); + + for (auto g=link_zoom.begin();g!=link_zoom.end();g++) { + (*g)->SetXBounds(min,max); + } + if (!m_block_zoom) SetXBounds(min,max); } void gGraphWindow::ZoomX(double mult,int origin_px) { @@ -251,7 +273,13 @@ void gGraphWindow::OnMouseRightDown(wxMouseEvent &event) void gGraphWindow::OnMouseRightRelease(wxMouseEvent &event) { if (abs(event.GetX()-m_mouseRClick_start.x)<3 && abs(event.GetY()-m_mouseRClick_start.y)<3) { - ZoomX(2,0); //event.GetX()); // adds origin to zoom out.. Doesn't look that cool. + for (auto g=link_zoom.begin();g!=link_zoom.end();g++) { + (*g)->ZoomX(2,0); + } + if (m_block_zoom) { + } else { + ZoomX(2,0); //event.GetX()); // adds origin to zoom out.. Doesn't look that cool. + } } m_mouseRDown=false; @@ -276,11 +304,13 @@ void gGraphWindow::OnMouseLeftRelease(wxMouseEvent &event) int t1=MIN(x1,x2); int t2=MAX(x1,x2); + wxRect r; if (t1 != t2) { ZoomXPixels(t1,t2); } + r=wxRect(0, 0, 0, 0); + - wxRect r(0, 0, 0, 0); m_mouseRBrect=r; event.Skip(); } @@ -296,6 +326,9 @@ gGraphWindow::gGraphWindow(wxWindow *parent, wxWindowID id,const wxString & titl m_bgColour = *wxWHITE; m_fgColour = *wxBLACK; SetMargins(10, 15, 30, 80); + m_block_move=false; + m_block_zoom=false; + } gGraphWindow::~gGraphWindow() diff --git a/graphs/graph.h b/graphs/graph.h index 0bde04a9..358620eb 100644 --- a/graphs/graph.h +++ b/graphs/graph.h @@ -141,6 +141,9 @@ class gGraphWindow:public wxWindow // rename to gGraphWindow inline int Width() { return m_scrX-m_marginLeft-m_marginRight; }; inline int Height() { return m_scrY-m_marginTop-m_marginBottom; }; + void LinkZoom(gGraphWindow *g) { link_zoom.push_back(g); }; // Linking graphs changes zoom behaviour.. + void LinkMove(gGraphWindow *g) { link_move.push_back(g); }; // Linking graphs changes zoom behaviour.. + virtual double MinX(); virtual double MaxX(); virtual double MinY(); @@ -159,7 +162,10 @@ class gGraphWindow:public wxWindow // rename to gGraphWindow virtual void SetXBounds(double minx, double maxx); virtual void ZoomX(double mult,int origin_px); virtual void ZoomXPixels(int x1, int x2); // Zoom between two selected points on screen + virtual void ZoomXPixels(int x1,int x2,double &rx1,double &rx2); + virtual void MoveX(int i); // Move x bounds by i Pixels + virtual void MoveX(int i,double &min, double & max); inline int x2p(double x) { double xx=max_x-min_x; @@ -188,13 +194,20 @@ class gGraphWindow:public wxWindow // rename to gGraphWindow //virtual void Update(); void AddLayer(gLayer *l); - void DataChanged(gLayer *layer); + virtual void DataChanged(gLayer *layer); double max_x,min_x,max_y,min_y; double rmax_x,rmin_x,rmax_y,rmin_y; - protected: + void SetBlockZoom(bool b) { m_block_zoom=b; }; + void SetBlockMove(bool b) { m_block_move=b; }; + protected: + listlink_zoom; + listlink_move; + + bool m_block_move; + bool m_block_zoom; std::list layers; wxColour m_bgColour; //!< Background Colour wxColour m_fgColour; //!< Foreground Colour diff --git a/version.h b/version.h index a434e0ec..0bc1c733 100644 --- a/version.h +++ b/version.h @@ -16,14 +16,14 @@ namespace AutoVersion{ //Standard Version Type static const long MAJOR = 0; static const long MINOR = 7; - static const long BUILD = 1304; - static const long REVISION = 1611; + static const long BUILD = 1330; + static const long REVISION = 1746; //Miscellaneous Version Types - static const long BUILDS_COUNT = 4921; - #define RC_FILEVERSION 0,7,1304,1611 - #define RC_FILEVERSION_STRING "0, 7, 1304, 1611\0" - static const char FULLVERSION_STRING[] = "0.7.1304.1611"; + static const long BUILDS_COUNT = 4980; + #define RC_FILEVERSION 0,7,1330,1746 + #define RC_FILEVERSION_STRING "0, 7, 1330, 1746\0" + static const char FULLVERSION_STRING[] = "0.7.1330.1746"; //These values are to keep track of your versioning state, don't modify them. static const long BUILD_HISTORY = 62;