FooBars are Fun. Try one today.

This commit is contained in:
Mark Watkins 2011-06-08 23:54:27 +10:00
parent c457d47ebe
commit eaaae3cda8
5 changed files with 166 additions and 57 deletions

View File

@ -8300,11 +8300,11 @@
<map>
"tinyxml/tinyxml.h"
1307436543 /home/mark/projects/git/sleepyhead/src/graphs/graph.h
1307539764 /home/mark/projects/git/sleepyhead/src/graphs/graph.h
<sleeplib/machine.h>
<list>
1307533474 /home/mark/projects/git/sleepyhead/src/version.h
1307541070 /home/mark/projects/git/sleepyhead/src/version.h
1307418393 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/prs1_loader.h
"machine.h"
@ -8321,7 +8321,7 @@
"preferences.h"
"tinyxml/tinyxml.h"
1307528781 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp
1307541070 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp
"wx_pch.h"
"version.h"
<wx/app.h>
@ -8341,7 +8341,7 @@
"sleeplib/profiles.h"
"sleeplib/machine_loader.h"
1307533395 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp
1307540973 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp
<wx/settings.h>
<wx/dcbuffer.h>
<wx/log.h>

View File

@ -674,8 +674,12 @@ Daily::Daily(wxWindow *win,Profile *p)
SF->LinkZoom(FRW);
FRW->LinkZoom(SF);
#if defined(__UNIX__)
FRW->LinkZoom(PRD);
FRW->LinkZoom(LEAK);
FRW->LinkZoom(SNORE);
SF->LinkZoom(PRD); // Uncomment to link in more graphs.. Too slow on windows.
SF->LinkZoom(LEAK);
SF->LinkZoom(SNORE);
#endif
const int sfc=9;

View File

@ -139,7 +139,7 @@ gGraphWindow::gGraphWindow(wxWindow *parent, wxWindowID id,const wxString & titl
SetMargins(10, 15, 46, 80);
m_block_move=false;
m_block_zoom=false;
m_drag_foobar=false;
}
gGraphWindow::~gGraphWindow()
@ -272,6 +272,43 @@ void gGraphWindow::OnMouseMove(wxMouseEvent &event)
{
// static bool first=true;
static wxRect last;
if (m_drag_foobar) {
int y=event.GetY();
int x=event.GetX();
if (x<GetLeftMargin()) return;
int x1=x-GetLeftMargin();
int width=m_scrX-GetRightMargin()-GetLeftMargin();
int height=m_scrY-GetBottomMargin()-GetTopMargin();
if (x>m_scrX-GetRightMargin()) return;
double mx=double(x1)/double(width);
double rminx=RealMinX();
double rmaxx=RealMaxX();
double rx=rmaxx-rminx;
double qx=rx*mx;
qx+=rminx;
// qx is centerpoint of new zoom area.
double dx=MaxX()-MinX(); // zoom rect width;
double gx=dx/2.0;
qx-=gx;
if (qx<rminx) qx=rminx;
double ex=qx+dx;
if ((qx+dx)>rmaxx) {
ex=rmaxx;
qx=ex-dx;
}
SetXBounds(qx,ex);
} else
if (event.m_rightDown) {
MoveX(event.GetX() - m_mouseRClick.x);
m_mouseRClick.x=event.GetX();
@ -297,31 +334,45 @@ void gGraphWindow::OnMouseMove(wxMouseEvent &event)
}
void gGraphWindow::OnMouseRightDown(wxMouseEvent &event)
{
if ( (event.GetY()>=GetTopMargin()) && (event.GetY()<=m_scrY-GetBottomMargin())) {
m_mouseRClick.x = event.GetX();
m_mouseRClick.y = event.GetY();
if (event.GetY()<GetTopMargin()) // before top margin
return;
//else if (event.GetY()>m_scrY-GetBottomMargin()) { // after top margin
// return;
//}
m_mouseRClick_start=m_mouseRClick;
m_mouseRDown=true;
}
// inside the margin area..
m_mouseRClick.x = event.GetX();
m_mouseRClick.y = event.GetY();
m_mouseRClick_start=m_mouseRClick;
m_mouseRDown=true;
event.Skip();
}
//voiid ZoomX
void gGraphWindow::OnMouseRightRelease(wxMouseEvent &event)
{
// Do this properly with real hotspots later..
double zoom_fact=2;
if ( (event.GetY()>=GetTopMargin()) && (event.GetY()<=m_scrY-GetBottomMargin())) {
if (event.ControlDown()) zoom_fact=5.0;
if (abs(event.GetX()-m_mouseRClick_start.x)<3 && abs(event.GetY()-m_mouseRClick_start.y)<3) {
for (list<gGraphWindow *>::iterator g=link_zoom.begin();g!=link_zoom.end();g++) {
(*g)->ZoomX(zoom_fact,0);
}
if (!m_block_zoom) {
ZoomX(zoom_fact,0); //event.GetX()); // adds origin to zoom out.. Doesn't look that cool.
}
if (event.GetY()<GetTopMargin())
return;
//else if (event.GetY()>m_scrY-GetBottomMargin()) {
// return;
//}
if (event.ControlDown()) zoom_fact=5.0;
if (abs(event.GetX()-m_mouseRClick_start.x)<3 && abs(event.GetY()-m_mouseRClick_start.y)<3) {
for (list<gGraphWindow *>::iterator g=link_zoom.begin();g!=link_zoom.end();g++) {
(*g)->ZoomX(zoom_fact,0);
}
if (!m_block_zoom) {
ZoomX(zoom_fact,0); //event.GetX()); // adds origin to zoom out.. Doesn't look that cool.
}
}
m_mouseRDown=false;
event.Skip();
@ -329,48 +380,101 @@ void gGraphWindow::OnMouseRightRelease(wxMouseEvent &event)
void gGraphWindow::OnMouseLeftDown(wxMouseEvent &event)
{
int y=event.GetY();
int top=GetTopMargin();
if ((y>=top) && (y<=m_scrY-GetBottomMargin())) {
m_mouseLClick.x = event.GetX();
m_mouseLClick.y = y;
int x=event.GetX();
int width=m_scrX-GetRightMargin()-GetLeftMargin();
int height=m_scrY-GetBottomMargin()-GetTopMargin();
wxRect hot1(GetLeftMargin(),GetTopMargin(),width,height); // Graph data area.
// if (HasFoobar()) {
if (hot1.Contains(x,y)) {
m_mouseLClick.x = x;
m_mouseLClick.y = y;
m_mouseLDown=true;
event.Skip();
} else if ((y>(m_scrY-GetBottomMargin())+5) && (y<(m_scrY-GetBottomMargin())+15)) {
double rx=RealMaxX()-RealMinX();
double qx=double(width)/rx;
double minx=MinX()-RealMinX();
double maxx=MaxX()-RealMinX();;
int x1=(qx*minx);
int x2=(qx*maxx); // length in pixels
x1+=GetLeftMargin();
x2+=GetLeftMargin();
if ((x>x1) && (x<x2)) {
m_drag_foobar=true;
// wxLogMessage("Foobar Area Pushed");
}
}
event.Skip();
}
void gGraphWindow::OnMouseLeftRelease(wxMouseEvent &event)
{
if ( (event.GetY()<GetTopMargin()) || (event.GetY()>m_scrY-GetBottomMargin())) {
return;
}
int y=event.GetY();
int x=event.GetX();
int width=m_scrX-GetRightMargin()-GetLeftMargin();
int height=m_scrY-GetBottomMargin()-GetTopMargin();
wxRect hot1(GetLeftMargin(),GetTopMargin(),width,height); // Graph data area.
wxPoint release(event.GetX(), m_scrY-m_marginBottom);
wxPoint press(m_mouseLClick.x, m_marginTop);
m_mouseLDown=false;
wxDateTime a,b;
int x1=m_mouseRBrect.x;
int x2=x1+m_mouseRBrect.width;
int t1=MIN(x1,x2);
int t2=MAX(x1,x2);
if (!hot1.Contains(x,y)) {
double rx=RealMaxX()-RealMinX();
double qx=double(width)/rx;
wxRect r;
if ((t2-t1)>3) {
ZoomXPixels(t1,t2);
double minx=MinX()-RealMinX();
double maxx=MaxX()-RealMinX();;
int x1=(qx*minx);
int x2=(qx*maxx); // length in pixels
x1+=GetLeftMargin();
x2+=GetLeftMargin();
if ((x>x1) && (x<x2)) {
// wxLogMessage("Foobar Area Pushed");
}
} else {
double zoom_fact=0.5;
if (event.ControlDown()) zoom_fact=0.25;
for (list<gGraphWindow *>::iterator g=link_zoom.begin();g!=link_zoom.end();g++) {
(*g)->ZoomX(zoom_fact,event.GetX());
}
if (!m_block_zoom) {
ZoomX(zoom_fact,event.GetX()); //event.GetX()); // adds origin to zoom out.. Doesn't look that cool.
wxPoint release(event.GetX(), m_scrY-m_marginBottom);
wxPoint press(m_mouseLClick.x, m_marginTop);
m_mouseLDown=false;
wxDateTime a,b;
int x1=m_mouseRBrect.x;
int x2=x1+m_mouseRBrect.width;
int t1=MIN(x1,x2);
int t2=MAX(x1,x2);
wxRect r;
if ((t2-t1)>3) {
ZoomXPixels(t1,t2);
} else {
double zoom_fact=0.5;
if (event.ControlDown()) zoom_fact=0.25;
for (list<gGraphWindow *>::iterator g=link_zoom.begin();g!=link_zoom.end();g++) {
(*g)->ZoomX(zoom_fact,event.GetX());
}
if (!m_block_zoom) {
ZoomX(zoom_fact,event.GetX()); //event.GetX()); // adds origin to zoom out.. Doesn't look that cool.
}
}
r=wxRect(0, 0, 0, 0);
m_mouseRBrect=r;
}
if (m_drag_foobar) {
// wxLogMessage("Foobar Released");
double min=MinX();
double max=MaxX();
for (list<gGraphWindow *>::iterator g=link_zoom.begin();g!=link_zoom.end();g++) {
(*g)->SetXBounds(min,max);
}
r=wxRect(0, 0, 0, 0);
m_mouseRBrect=r;
}
m_drag_foobar=false;
event.Skip();
}

View File

@ -217,6 +217,7 @@ class gGraphWindow:public wxWindow // rename to gGraphWindow
bool m_block_move;
bool m_block_zoom;
bool m_drag_foobar;
std::list<gLayer *> layers;
wxColour m_bgColour; //!< Background Colour
wxColour m_fgColour; //!< Foreground Colour

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 = 3756;
static const long REVISION = 3731;
static const long BUILD = 3796;
static const long REVISION = 3929;
//Miscellaneous Version Types
static const long BUILDS_COUNT = 1659;
#define RC_FILEVERSION 0,7,3756,3731
#define RC_FILEVERSION_STRING "0, 7, 3756, 3731\0"
static const char FULLVERSION_STRING[] = "0.7.3756.3731";
static const long BUILDS_COUNT = 1734;
#define RC_FILEVERSION 0,7,3796,3929
#define RC_FILEVERSION_STRING "0, 7, 3796, 3929\0"
static const char FULLVERSION_STRING[] = "0.7.3796.3929";
//These values are to keep track of your versioning state, don't modify them.
static const long BUILD_HISTORY = 0;