2011-06-26 08:30:44 +00:00
|
|
|
/********************************************************************
|
|
|
|
gFooBar Implementation
|
|
|
|
Copyright (c)2011 Mark Watkins <jedimark@users.sourceforge.net>
|
|
|
|
License: GPL
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#include "gFooBar.h"
|
|
|
|
|
2011-08-02 04:20:26 +00:00
|
|
|
gFooBar::gFooBar(int offset,QColor handle_color,QColor line_color,bool shadow,QColor shadow_color)
|
|
|
|
:gLayer(EmptyChannel),m_offset(offset),m_shadow(shadow),m_handle_color(handle_color),m_line_color(line_color),m_shadow_color(shadow_color)
|
2011-06-26 08:30:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
gFooBar::~gFooBar()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void gFooBar::Plot(gGraphWindow & w,float scrx,float scry)
|
|
|
|
{
|
|
|
|
if (!m_visible) return;
|
|
|
|
|
|
|
|
double xx=w.max_x-w.min_x;
|
|
|
|
|
|
|
|
if (xx==0)
|
|
|
|
return;
|
|
|
|
|
2011-06-27 07:45:59 +00:00
|
|
|
int start_px=w.GetLeftMargin()-1;
|
2011-06-26 08:30:44 +00:00
|
|
|
int width=scrx - (w.GetLeftMargin() + w.GetRightMargin());
|
|
|
|
int height=scry - (w.GetTopMargin() + w.GetBottomMargin());
|
2011-07-18 00:47:21 +00:00
|
|
|
int end_px=scrx-w.GetRightMargin();
|
2011-06-26 08:30:44 +00:00
|
|
|
|
2011-06-28 09:19:35 +00:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
2011-06-26 08:30:44 +00:00
|
|
|
float h=m_offset;
|
|
|
|
|
|
|
|
glLineWidth(1);
|
|
|
|
glBegin(GL_LINES);
|
2011-08-02 04:20:26 +00:00
|
|
|
w.qglColor(m_line_color);
|
2011-06-26 08:30:44 +00:00
|
|
|
glVertex2f(start_px, h);
|
|
|
|
glVertex2f(start_px+width, h);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
double rmx=w.rmax_x-w.rmin_x;
|
|
|
|
double px=((1/rmx)*(w.min_x-w.rmin_x))*width;
|
|
|
|
double py=((1/rmx)*(w.max_x-w.rmin_x))*width;
|
|
|
|
|
|
|
|
glLineWidth(4);
|
|
|
|
glBegin(GL_LINES);
|
2011-08-02 04:20:26 +00:00
|
|
|
w.qglColor(m_handle_color);
|
2011-06-26 08:30:44 +00:00
|
|
|
glVertex2f(start_px+px-4,h);
|
|
|
|
glVertex2f(start_px+py+4,h);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glLineWidth(1);
|
|
|
|
|
2011-08-02 04:20:26 +00:00
|
|
|
if ((m_shadow)) {
|
2011-06-26 08:30:44 +00:00
|
|
|
glEnable(GL_BLEND);
|
2011-06-27 07:45:59 +00:00
|
|
|
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
|
|
glBegin(GL_QUADS);
|
2011-08-02 04:20:26 +00:00
|
|
|
w.qglColor(m_shadow_color);
|
|
|
|
|
2011-07-18 00:47:21 +00:00
|
|
|
glVertex2f(start_px, w.GetBottomMargin());
|
|
|
|
glVertex2f(start_px, w.GetBottomMargin()+height);
|
2011-06-26 08:30:44 +00:00
|
|
|
glVertex2f(start_px+px, w.GetBottomMargin()+height);
|
2011-07-18 00:47:21 +00:00
|
|
|
glVertex2f(start_px+px, w.GetBottomMargin());
|
|
|
|
|
2011-06-26 08:30:44 +00:00
|
|
|
glVertex2f(start_px+py, w.GetBottomMargin());
|
2011-07-18 00:47:21 +00:00
|
|
|
glVertex2f(start_px+py, w.GetBottomMargin()+height);
|
|
|
|
glVertex2f(end_px, w.GetBottomMargin()+height);
|
|
|
|
glVertex2f(end_px, w.GetBottomMargin());
|
2011-06-26 08:30:44 +00:00
|
|
|
glEnd();
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|