Return of the Cursor Keys

This commit is contained in:
Mark Watkins 2011-09-05 23:26:10 +10:00
parent 8fe70da1d0
commit dfdba127c9
5 changed files with 56 additions and 5 deletions

View File

@ -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;

View File

@ -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;i<m_graphs.size();i++) {
if (m_graphs[i]->group()==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_x<g->rmin_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)
{

View File

@ -9,7 +9,7 @@
#include "gSessionTime.h"
gTimeYAxis::gTimeYAxis(QColor col)
:gYAxis(col)
:gYAxis(EmptyChannel,col)
{
}
gTimeYAxis::~gTimeYAxis()

View File

@ -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;
}

View File

@ -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