diff --git a/Graphs/gBarChart.cpp b/Graphs/gBarChart.cpp index d776c82a..c2d01ba3 100644 --- a/Graphs/gBarChart.cpp +++ b/Graphs/gBarChart.cpp @@ -170,7 +170,7 @@ bool gBarChart::mouseMoveEvent(QMouseEvent *event) double xx=l_maxx-l_minx; double xmult=xx/double(l_width+barw); - qint64 mx=xmult*double(x-offset); + qint64 mx=ceil(xmult*double(x-offset)); mx+=l_minx; mx=mx+l_offset;//-86400000L; int zd=mx/86400000L; diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp index 25f9ff43..6db85ea7 100644 --- a/Graphs/gGraphView.cpp +++ b/Graphs/gGraphView.cpp @@ -1215,6 +1215,7 @@ gGraphView::gGraphView(QWidget *parent, gGraphView * shared) : backlines=new GLBuffer(QColor(0,0,0,0),10000,GL_LINES); // big fat shared line list quads=new GLBuffer(QColor(0,0,0,0),1024,GL_QUADS); // big fat shared line list quads->forceAntiAlias(true); + setFocusPolicy(Qt::StrongFocus); } gGraphView::~gGraphView() { @@ -1838,7 +1839,48 @@ void gGraphView::wheelEvent(QWheelEvent * event) void gGraphView::keyPressEvent(QKeyEvent * event) { + gGraph *g; + for (int i=0;igroup()==0) { + g=m_graphs[i]; + break; + } + } + if (!g) return; + if (event->key()==Qt::Key_Left) { + double xx=g->max_x-g->min_x; + double zoom=8.0; + if (event->modifiers() & Qt::ControlModifier) zoom/=4; + + g->min_x-=xx/zoom;; + g->max_x=g->min_x+xx; + if (g->min_xrmin_x) { + g->min_x=g->rmin_x; + g->max_x=g->rmin_x+xx; + } + SetXBounds(g->min_x,g->max_x); + } else if (event->key()==Qt::Key_Right) { + double xx=g->max_x-g->min_x; + double zoom=8.0; + if (event->modifiers() & Qt::ControlModifier) zoom/=4; + g->min_x+=xx/zoom; + g->max_x=g->min_x+xx; + if (g->max_x>g->rmax_x) { + g->max_x=g->rmax_x; + g->min_x=g->rmax_x-xx; + } + SetXBounds(g->min_x,g->max_x); + } else if (event->key()==Qt::Key_Up) { + float zoom=0.75; + if (event->modifiers() & Qt::ControlModifier) zoom/=1.5; + g->ZoomX(zoom,0); // zoom in. + } else if (event->key()==Qt::Key_Down) { + float zoom=1.33; + if (event->modifiers() & Qt::ControlModifier) zoom*=1.5; + g->ZoomX(zoom,0); // Zoom out + } + qDebug() << "Keypress??"; } void gGraphView::setDay(Day * day) { diff --git a/Graphs/gSessionTime.cpp b/Graphs/gSessionTime.cpp index 3353b53e..492748bd 100644 --- a/Graphs/gSessionTime.cpp +++ b/Graphs/gSessionTime.cpp @@ -9,7 +9,7 @@ #include "gSessionTime.h" gTimeYAxis::gTimeYAxis(QColor col) - :gYAxis(col) + :gYAxis(EmptyChannel,col) { } gTimeYAxis::~gTimeYAxis() diff --git a/Graphs/gYAxis.cpp b/Graphs/gYAxis.cpp index e20bbaae..c8b078ab 100644 --- a/Graphs/gYAxis.cpp +++ b/Graphs/gYAxis.cpp @@ -98,8 +98,8 @@ void gXGrid::paint(gGraph & w,int left,int top, int width, int height) -gYAxis::gYAxis(QColor col) -:Layer(EmptyChannel) +gYAxis::gYAxis(ChannelID code,QColor col) +:Layer(code) { m_line_color=col; m_text_color=col; @@ -190,3 +190,9 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height) } } +bool gYAxis::mouseMoveEvent(QMouseEvent * event) +{ + int x=event->x(); + int y=event->y(); + //qDebug() << "Hover at " << x << y; +} diff --git a/Graphs/gYAxis.h b/Graphs/gYAxis.h index 195c42be..9b38dc18 100644 --- a/Graphs/gYAxis.h +++ b/Graphs/gYAxis.h @@ -39,7 +39,7 @@ protected: class gYAxis:public Layer { public: - gYAxis(QColor col=QColor("black")); + gYAxis(ChannelID code=EmptyChannel,QColor col=QColor("black")); virtual ~gYAxis(); virtual void paint(gGraph & w,int left,int top, int width, int height); void SetShowMinorLines(bool b) { m_show_minor_lines=b; } @@ -55,6 +55,7 @@ class gYAxis:public Layer void SetScale(float f) { m_yaxis_scale=f; } // Scale yaxis ticker values (only what's displayed) float Scale() { return m_yaxis_scale; } + protected: bool m_show_major_lines; bool m_show_minor_lines; @@ -65,6 +66,8 @@ class gYAxis:public Layer QColor m_line_color; QColor m_text_color; GLBuffer * lines; + virtual bool mouseMoveEvent(QMouseEvent * event); + }; #endif // GYAXIS_H