Implemented GL Float Buffer to improve pie chart appearance

This commit is contained in:
Mark Watkins 2011-09-28 21:46:32 +10:00
parent 26e96a3166
commit aa43837d52
16 changed files with 344 additions and 140 deletions

View File

@ -12,15 +12,11 @@
gFlagsGroup::gFlagsGroup()
{
static QColor col1=QColor(0xd0,0xff,0xd0,0xff);
static QColor col2=QColor(0xff,0xff,0xff,0xff);
static QColor col=Qt::black;
addGLBuf(quad1=new GLBuffer(col1,512,GL_QUADS));
addGLBuf(quad2=new GLBuffer(col2,512,GL_QUADS));
addGLBuf(lines=new GLBuffer(col,20,GL_LINE_LOOP));
quad1->setAntiAlias(true);
quad2->setAntiAlias(true);
addGLBuf(quads=new GLShortBuffer(512,GL_QUADS));
addGLBuf(lines=new GLShortBuffer(20,GL_LINE_LOOP));
quads->setAntiAlias(true);
lines->setAntiAlias(false);
}
gFlagsGroup::~gFlagsGroup()
@ -64,23 +60,20 @@ void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height)
float barh=float(height)/float(vis);
float linetop=top;
static QColor col1=QColor(0xd0,0xff,0xd0,0xff);
static QColor col2=QColor(0xff,0xff,0xff,0xff);
QColor * barcol;
for (int i=0;i<lvisible.size();i++) {
// Alternating box color
//QColor * barcol=&col2;
if (i & 1) {
quad1->add(left,linetop,left,linetop+barh);
quad1->add(left+width-1,linetop+barh,left+width-1,linetop);
} else {
quad2->add(left,linetop,left,linetop+barh);
quad2->add(left+width-1,linetop+barh,left+width-1,linetop);
}
if (i & 1) barcol=&col1; else barcol=&col2;
quads->add(left,linetop,left,linetop+barh,left+width-1,linetop+barh,left+width-1,linetop,*barcol);
// Paint the actual flags
lvisible[i]->paint(w,left,linetop,width,barh);
linetop+=barh;
}
GLBuffer *outlines=w.lines();
GLShortBuffer *outlines=w.lines();
QColor blk=Qt::black;
outlines->add(left-1, top, left-1, top+height, blk);
outlines->add(left-1, top+height, left+width,top+height, blk);
@ -94,7 +87,7 @@ void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height)
gFlagsLine::gFlagsLine(ChannelID code,QColor flag_color,QString label,bool always_visible,FlagType flt)
:Layer(code),m_label(label),m_always_visible(always_visible),m_flt(flt),m_flag_color(flag_color)
{
addGLBuf(quads=new GLBuffer(flag_color,2048,GL_QUADS));
addGLBuf(quads=new GLShortBuffer(2048,GL_QUADS));
//addGLBuf(lines=new GLBuffer(flag_color,1024,GL_LINES));
quads->setAntiAlias(true);
//lines->setAntiAlias(true);

View File

@ -31,7 +31,7 @@ class gFlagsLine:public Layer
int total_lines,line_num;
FlagType m_flt;
QColor m_flag_color;
GLBuffer *quads, *lines;
GLShortBuffer *quads, *lines;
int m_lx, m_ly;
};
@ -46,7 +46,7 @@ public:
virtual qint64 Maxx();
virtual void SetDay(Day *);
protected:
GLBuffer *quad1, *quad2, *lines;
GLShortBuffer *quads, *lines;
QVector<gFlagsLine *> lvisible;
};

View File

@ -6,12 +6,11 @@
#include <cmath>
#include "gFooBar.h"
gShadowArea::gShadowArea(QColor shadow_color)
:Layer(""),m_shadow_color(shadow_color)
gShadowArea::gShadowArea(QColor shadow_color,QColor line_color)
:Layer(""),m_shadow_color(shadow_color),m_line_color(line_color)
{
QColor col=Qt::blue;
addGLBuf(quads=new GLBuffer(shadow_color,20,GL_QUADS));
addGLBuf(lines=new GLBuffer(col,20,GL_LINES));
addGLBuf(quads=new GLShortBuffer(20,GL_QUADS));
addGLBuf(lines=new GLShortBuffer(20,GL_LINES));
quads->forceAntiAlias(true);
lines->setAntiAlias(true);
lines->setSize(2);
@ -36,13 +35,11 @@ void gShadowArea::paint(gGraph & w,int left, int top, int width, int height)
double px=((1/rmx)*(w.min_x-w.rmin_x))*width;
double py=((1/rmx)*(w.max_x-w.rmin_x))*width;
quads->add(start_px,top,start_px,top+height);
quads->add(start_px+px, top+height, start_px+px, top);
quads->add(start_px+py, top, start_px+py, top+height);
quads->add(end_px, top+height, end_px, top);
quads->add(start_px,top,start_px,top+height,start_px+px, top+height, start_px+px, top,m_shadow_color);
quads->add(start_px+py, top, start_px+py, top+height,end_px, top+height, end_px, top,m_shadow_color);
lines->add(start_px+px, top, start_px+py, top);
lines->add(start_px+px, top+height+1, start_px+py, top+height+1);
lines->add(start_px+px, top, start_px+py, top,m_line_color);
lines->add(start_px+px, top+height+1, start_px+py, top+height+1,m_line_color);
}
gFooBar::gFooBar(int offset,QColor handle_color,QColor line_color)

View File

@ -12,13 +12,14 @@
class gShadowArea:public Layer
{
public:
gShadowArea(QColor shadow_color=QColor(40,40,40,40));
gShadowArea(QColor shadow_color=QColor(40,40,40,40),QColor line_color=QColor("blue"));
virtual ~gShadowArea();
virtual void paint(gGraph & w,int left, int top, int width, int height);
protected:
QColor m_shadow_color;
GLBuffer *quads;
GLBuffer *lines;
QColor m_line_color;
GLShortBuffer *quads;
GLShortBuffer *lines;
};
class gFooBar:public Layer

View File

@ -52,55 +52,34 @@ void GetTextExtent(QString text, int & width, int & height, QFont *font)
mut.unlock();
}
GLBuffer::GLBuffer(QColor color,int max,int type)
:m_color(color), m_max(max), m_type(type)
GLBuffer::GLBuffer(int max,int type)
:m_max(max), m_type(type)
{
m_scissor=false;
m_antialias=true;
m_forceantialias=false;
buffer=new GLshort [max+8];
//if (m_type==GL_LINES) {
colors=new GLubyte[max*4+(8*4)];
//} else colors=NULL;
m_cnt=0;
m_colcnt=0;
m_size=1;
}
GLBuffer::~GLBuffer()
{
}
///////
GLShortBuffer::GLShortBuffer(int max,int type)
:GLBuffer(max,type)
{
buffer=new GLshort [max+8];
colors=new GLubyte[max*4+(8*4)];
}
GLShortBuffer::~GLShortBuffer()
{
if (colors) delete [] colors;
if (buffer) delete [] buffer;
}
void GLBuffer::add(GLshort s)
{
if (m_cnt<m_max) {
buffer[m_cnt++]=s;
} else {
qDebug() << "GLBuffer overflow";
}
}
void GLBuffer::add(GLshort x, GLshort y)
{
if (m_cnt<m_max+2) {
buffer[m_cnt++]=x;
buffer[m_cnt++]=y;
} else {
qDebug() << "GLBuffer overflow";
}
}
void GLBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
{
if (m_cnt<m_max+4) {
buffer[m_cnt++]=x1;
buffer[m_cnt++]=y1;
buffer[m_cnt++]=x2;
buffer[m_cnt++]=y2;
} else {
qDebug() << "GLBuffer overflow";
}
}
void GLBuffer::add(GLshort x, GLshort y,QColor & color)
void GLShortBuffer::add(GLshort x, GLshort y,QColor & color)
{
if (m_cnt<m_max+2) {
mutex.lock();
@ -115,7 +94,7 @@ void GLBuffer::add(GLshort x, GLshort y,QColor & color)
qDebug() << "GLBuffer overflow";
}
}
void GLBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,QColor & color)
void GLShortBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,QColor & color)
{
if (m_cnt<m_max+4) {
mutex.lock();
@ -136,7 +115,7 @@ void GLBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,QColor & color
qDebug() << "GLBuffer overflow";
}
}
void GLBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,GLshort x3, GLshort y3, GLshort x4, GLshort y4,QColor & color) // add with vertex colors
void GLShortBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,GLshort x3, GLshort y3, GLshort x4, GLshort y4,QColor & color) // add with vertex colors
{
if (m_cnt<m_max+8) {
mutex.lock();
@ -170,7 +149,7 @@ if (m_cnt<m_max+8) {
qDebug() << "GLBuffer overflow";
}
}
void GLBuffer::draw()
void GLShortBuffer::draw()
{
if (m_cnt>0) {
bool antialias=m_forceantialias || (pref["UseAntiAliasing"].toBool() && m_antialias);
@ -201,21 +180,12 @@ void GLBuffer::draw()
glVertexPointer(2, GL_SHORT, 0, buffer);
if (m_colcnt<=0) {
glColor4ub(m_color.red(),m_color.green(),m_color.blue(),m_color.alpha());
} else {
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
}
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
glEnableClientState(GL_VERTEX_ARRAY);
if (m_colcnt>0) {
glEnableClientState(GL_COLOR_ARRAY);
}
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(m_type, 0, m_cnt >> 1);
if (m_colcnt>0) {
glDisableClientState(GL_COLOR_ARRAY);
}
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
@ -240,6 +210,225 @@ void GLBuffer::draw()
}
}
/////////////////////////////////////////////////////////////////////
// GLFloatBuffer
GLFloatBuffer::GLFloatBuffer(int max,int type)
:GLBuffer(max,type)
{
buffer=new GLfloat [max+8];
colors=new GLubyte[max*4+(8*4)];
}
GLFloatBuffer::~GLFloatBuffer()
{
if (colors) delete [] colors;
if (buffer) delete [] buffer;
}
void GLFloatBuffer::add(GLfloat x, GLfloat y,QColor & color)
{
if (m_cnt<m_max+2) {
mutex.lock();
buffer[m_cnt++]=x;
buffer[m_cnt++]=y;
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
mutex.unlock();
} else {
qDebug() << "GLBuffer overflow";
}
}
void GLFloatBuffer::add(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,QColor & color)
{
if (m_cnt<m_max+4) {
qDebug() << "GLFloatBuffer overflow";
return;
}
mutex.lock();
buffer[m_cnt++]=x1;
buffer[m_cnt++]=y1;
buffer[m_cnt++]=x2;
buffer[m_cnt++]=y2;
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
mutex.unlock();
}
void GLFloatBuffer::add(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4,QColor & color) // add with vertex colors
{
if (m_cnt>=m_max+8) {
qDebug() << "GLFloatBuffer overflow";
return;
}
mutex.lock();
buffer[m_cnt++]=x1;
buffer[m_cnt++]=y1;
buffer[m_cnt++]=x2;
buffer[m_cnt++]=y2;
buffer[m_cnt++]=x3;
buffer[m_cnt++]=y3;
buffer[m_cnt++]=x4;
buffer[m_cnt++]=y4;
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
mutex.unlock();
}
void GLFloatBuffer::quadGrLR(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4,QColor & color, QColor & color2) // add with vertex colors
{
if (m_cnt>=m_max+8) {
qDebug() << "GLFloatBuffer overflow";
return;
}
mutex.lock();
buffer[m_cnt++]=x1;
buffer[m_cnt++]=y1;
buffer[m_cnt++]=x2;
buffer[m_cnt++]=y2;
buffer[m_cnt++]=x3;
buffer[m_cnt++]=y3;
buffer[m_cnt++]=x4;
buffer[m_cnt++]=y4;
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
colors[m_colcnt++]=color2.red();
colors[m_colcnt++]=color2.green();
colors[m_colcnt++]=color2.blue();
colors[m_colcnt++]=color2.alpha();
colors[m_colcnt++]=color2.red();
colors[m_colcnt++]=color2.green();
colors[m_colcnt++]=color2.blue();
colors[m_colcnt++]=color2.alpha();
mutex.unlock();
}
void GLFloatBuffer::quadGrTB(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4,QColor & color, QColor & color2)
{
if (m_cnt>=m_max+8) {
qDebug() << "GLFloatBuffer overflow";
return;
}
mutex.lock();
buffer[m_cnt++]=x1;
buffer[m_cnt++]=y1;
buffer[m_cnt++]=x3;
buffer[m_cnt++]=y3;
buffer[m_cnt++]=x2;
buffer[m_cnt++]=y2;
buffer[m_cnt++]=x4;
buffer[m_cnt++]=y4;
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
colors[m_colcnt++]=color.red();
colors[m_colcnt++]=color.green();
colors[m_colcnt++]=color.blue();
colors[m_colcnt++]=color.alpha();
colors[m_colcnt++]=color2.red();
colors[m_colcnt++]=color2.green();
colors[m_colcnt++]=color2.blue();
colors[m_colcnt++]=color2.alpha();
colors[m_colcnt++]=color2.red();
colors[m_colcnt++]=color2.green();
colors[m_colcnt++]=color2.blue();
colors[m_colcnt++]=color2.alpha();
mutex.unlock();
}
void GLFloatBuffer::draw()
{
if (m_cnt<=0) return;
bool antialias=m_forceantialias || (pref["UseAntiAliasing"].toBool() && m_antialias);
float size=m_size;
if (antialias) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
size+=0.5;
} else if (m_type==GL_POLYGON) {
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
}
}
if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
glLineWidth(size);
} else if (m_type==GL_POINTS) {
glPointSize(size);
} else if (m_type==GL_POLYGON) {
glPolygonMode(GL_BACK,GL_FILL);
}
if (m_scissor) {
glScissor(s1,s2,s3,s4);
glEnable(GL_SCISSOR_TEST);
}
glVertexPointer(2, GL_FLOAT, 0, buffer);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
//glColor4ub(200,128,95,200);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(m_type, 0, m_cnt >> 1);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
//qDebug() << "I Drawed" << m_cnt << "vertices";
m_cnt=0;
m_colcnt=0;
if (m_scissor) {
glDisable(GL_SCISSOR_TEST);
m_scissor=false;
}
if (m_type==GL_POLYGON) {
glPolygonMode(GL_BACK,GL_FILL);
}
if (antialias) {
if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
glDisable(GL_LINE_SMOOTH);
} else if (m_type==GL_POLYGON) {
glDisable(GL_POLYGON_SMOOTH);
}
glDisable(GL_BLEND);
}
}
//////////////////////////////////////////////////////////////////////////////
// gToolTip implementation
gToolTip::gToolTip(gGraphView * graphview)
:m_graphview(graphview)
{
@ -562,7 +751,7 @@ gGraph::gGraph(gGraphView *graphview,QString title,int height,short group) :
m_selecting_area=m_blockzoom=false;
m_lastx23=0;
m_quad=new GLBuffer(QColor(128,128,255,128),64,GL_QUADS);
m_quad=new GLShortBuffer(64,GL_QUADS);
m_quad->forceAntiAlias(true);
f_miny=f_maxy=0;
m_forceMinY=m_forceMaxY=false;
@ -1198,15 +1387,15 @@ void gGraph::SetMaxY(EventDataType v)
{
rmax_y=max_y=v;
}
GLBuffer * gGraph::lines()
GLShortBuffer * gGraph::lines()
{
return m_graphview->lines;
}
GLBuffer * gGraph::backlines()
GLShortBuffer * gGraph::backlines()
{
return m_graphview->backlines;
}
GLBuffer * gGraph::quads()
GLShortBuffer * gGraph::quads()
{
return m_graphview->quads;
}
@ -1308,9 +1497,9 @@ gGraphView::gGraphView(QWidget *parent, gGraphView * shared) :
//gt->start();
}*/
lines=new GLBuffer(QColor(0,0,0,0),100000,GL_LINES); // big fat shared line list
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
lines=new GLShortBuffer(100000,GL_LINES); // big fat shared line list
backlines=new GLShortBuffer(10000,GL_LINES); // big fat shared line list
quads=new GLShortBuffer(1024,GL_QUADS); // big fat shared line list
quads->forceAntiAlias(true);
setFocusPolicy(Qt::StrongFocus);
m_showsplitter=true;

View File

@ -31,22 +31,14 @@ class gGraphView;
class gGraph;
const int textque_max=512;
class GLBuffer
{
public:
GLBuffer(QColor color,int max=2048,int type=GL_LINES);
~GLBuffer();
void add(GLshort s);
void add(GLshort x, GLshort y);
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
void add(GLshort x, GLshort y,QColor & col); // add with vertex color
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,QColor & col); // add with vertex colors
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,GLshort x3, GLshort y3, GLshort x4, GLshort y4,QColor & col); // add with vertex colors
GLBuffer(int max=2048,int type=GL_LINES);
virtual ~GLBuffer();
void scissor(GLshort x1, GLshort y1, GLshort x2, GLshort y2) { s1=x1; s2=y1; s3=x2; s4=y2; m_scissor=true; }
void draw();
inline GLshort & operator [](int i) { return buffer[i]; }
virtual void draw(){}
void reset() { m_cnt=0; }
int max() { return m_max; }
int cnt() { return m_cnt; }
@ -54,11 +46,7 @@ public:
void setSize(float f) { m_size=f; }
void setAntiAlias(bool b) { m_antialias=b; }
void forceAntiAlias(bool b) { m_forceantialias=b; }
void setColor(QColor color) { m_color=color; }
protected:
QColor m_color;
GLshort * buffer;
GLubyte * colors;
int m_max;
int m_type; // type (GL_LINES, GL_QUADS, etc)
int m_cnt; // cnt
@ -71,6 +59,45 @@ protected:
QMutex mutex;
};
class GLShortBuffer:public GLBuffer
{
public:
GLShortBuffer(int max=2048,int type=GL_LINES);
virtual ~GLShortBuffer();
//void add(GLshort s);
//void add(GLshort x, GLshort y);
//void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
void add(GLshort x, GLshort y,QColor & col); // add with vertex color
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,QColor & col); // add with vertex colors
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,GLshort x3, GLshort y3, GLshort x4, GLshort y4,QColor & col); // add with vertex colors
virtual void draw();
//inline GLshort & operator [](int i) { return buffer[i]; }
protected:
GLshort * buffer;
GLubyte * colors;
};
class GLFloatBuffer:public GLBuffer
{
public:
GLFloatBuffer(int max=2048,int type=GL_LINES);
virtual ~GLFloatBuffer();
void add(GLfloat x, GLfloat y,QColor & col); // add with vertex color
void add(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,QColor & col); // add with vertex colors
void add(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4,QColor & col); // add with vertex colors
void quadGrTB(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4,QColor & col,QColor & col2); // add with vertex colors
void quadGrLR(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4,QColor & col,QColor & col2); // add with vertex colors
virtual void draw();
protected:
GLfloat * buffer;
GLubyte * colors;
};
struct TextQue
{
short x,y;
@ -288,9 +315,9 @@ public:
m_margintop=top; m_marginbottom=bottom;
}
GLBuffer * lines();
GLBuffer * backlines();
GLBuffer * quads();
GLShortBuffer * lines();
GLShortBuffer * backlines();
GLShortBuffer * quads();
short m_marginleft, m_marginright, m_margintop, m_marginbottom;
short left,right,top,bottom; // dirty magin hacks..
@ -375,7 +402,7 @@ public:
void setDay(Day * day);
QSemaphore * masterlock;
bool useThreads() { return m_idealthreads>1; }
GLBuffer * lines, * backlines, *quads;
GLShortBuffer * lines, * backlines, *quads;
void TrashGraphs();
gGraph * popGraph();

View File

@ -16,7 +16,7 @@ gLineChart::gLineChart(ChannelID code,QColor col,bool square_plot, bool disable_
{
m_line_color=col;
m_report_empty=false;
addGLBuf(lines=new GLBuffer(col,100000,GL_LINES));
addGLBuf(lines=new GLShortBuffer(100000,GL_LINES));
lines->setAntiAlias(true);
}
@ -107,7 +107,7 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
int minz,maxz;
// Draw bounding box
GLBuffer *outlines=w.lines();
GLShortBuffer *outlines=w.lines();
QColor blk=Qt::black;
outlines->add(left, top, left, top+height, blk);
outlines->add(left, top+height, left+width,top+height, blk);

View File

@ -36,8 +36,8 @@ protected:
bool m_square_plot;
bool m_disable_accel;
QColor m_line_color;
GLBuffer * lines;
GLBuffer * outlines;
GLShortBuffer * lines;
GLShortBuffer * outlines;
static const int max_drawlist_size=4096;
QPoint m_drawlist[max_drawlist_size];
int subtract_offset;

View File

@ -11,9 +11,9 @@
gLineOverlayBar::gLineOverlayBar(ChannelID code,QColor color,QString label,FlagType flt)
:Layer(code),m_flag_color(color),m_label(label),m_flt(flt)
{
addGLBuf(points=new GLBuffer(color,1024,GL_POINTS));
addGLBuf(points=new GLShortBuffer(1024,GL_POINTS));
points->setSize(4);
addGLBuf(quads=new GLBuffer(color,2048,GL_QUADS));
addGLBuf(quads=new GLShortBuffer(2048,GL_QUADS));
//addGLBuf(lines=new GLBuffer(color,1024,GL_LINES));
points->setAntiAlias(true);
quads->setAntiAlias(true);
@ -83,7 +83,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
} else if (m_flt==FT_Dot) {
if ((pref["AlwaysShowOverlayBars"].toInt()==0) || (xx<3600000)) {
// show the fat dots in the middle
points->add(x1,double(height)/double(yy)*double(-20-w.min_y)+topp);
points->add(x1,double(height)/double(yy)*double(-20-w.min_y)+topp,m_flag_color);
if (points->full()) { verts_exceeded=true; break; }
} else {
// thin lines down the bottom
@ -96,7 +96,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
if ((pref["AlwaysShowOverlayBars"].toInt()==0) || (xx<3600000)) {
z=top;
points->add(x1,top);
points->add(x1,top,m_flag_color);
lines->add(x1,top,x1,bottom,m_flag_color);
if (points->full()) { verts_exceeded=true; break; }
} else {

View File

@ -24,7 +24,7 @@ class gLineOverlayBar:public Layer
QString m_label;
FlagType m_flt;
GLBuffer *points,*quads, *lines;
GLShortBuffer *points,*quads, *lines;
};
#endif // GLINEOVERLAY_H

View File

@ -11,11 +11,10 @@
gSegmentChart::gSegmentChart(GraphSegmentType type,QColor gradient_color,QColor outline_color)
:Layer("EmptyChannel"),m_graph_type(type),m_gradient_color(gradient_color),m_outline_color(outline_color)
{
// m_gradient_color=QColor(200,200,200);
m_empty=true;
addGLBuf(poly=new GLBuffer(gradient_color,4000,GL_POLYGON));
addGLBuf(lines=new GLBuffer(outline_color,4000,GL_LINE_LOOP));
lines->setSize(1.5);
addGLBuf(poly=new GLFloatBuffer(4000,GL_POLYGON));
addGLBuf(lines=new GLFloatBuffer(4000,GL_LINE_LOOP));
lines->setSize(1);
poly->forceAntiAlias(false);
lines->forceAntiAlias(true);
lines->setAntiAlias(true);
@ -99,8 +98,8 @@ void gSegmentChart::paint(gGraph & w,int left, int top, int width, int height)
bool line_first=true;
int line_last;
GLBuffer *quads=w.quads();
GLBuffer *lines2=w.lines();
GLShortBuffer *quads=w.quads();
GLShortBuffer *lines2=w.lines();
for (unsigned m=0;m<size;m++) {
data=m_values[m];
QColor & col=schema::channel[m_codes[m % m_colors.size()]].defaultColor();
@ -158,8 +157,8 @@ void gSegmentChart::paint(gGraph & w,int left, int top, int width, int height)
quads->add(xp,start_py,xp+bw,start_py,m_gradient_color);
quads->add(xp+bw,start_py+height,xp,start_py+height,col);
lines->add(xp,start_py,xp+bw,start_py,m_outline_color);
lines->add(xp+bw,start_py+height,xp,start_py+height,m_outline_color);
lines2->add(xp,start_py,xp+bw,start_py,m_outline_color);
lines2->add(xp+bw,start_py+height,xp,start_py+height,m_outline_color);
if (!m_names[m].isEmpty()) {
int px,py;

View File

@ -32,7 +32,7 @@ protected:
QColor m_gradient_color;
QColor m_outline_color;
bool m_empty;
GLBuffer *poly,*lines;
GLFloatBuffer *poly,*lines;
};
class gTAPGraph:public gSegmentChart

View File

@ -15,8 +15,8 @@ SummaryChart::SummaryChart(Profile *p,QString label,GraphType type)
:Layer(""),m_profile(p),m_label(label),m_graphtype(type)
{
QColor color=Qt::black;
addGLBuf(quads=new GLBuffer(color,20000,GL_QUADS));
addGLBuf(lines=new GLBuffer(color,20000,GL_LINES));
addGLBuf(quads=new GLShortBuffer(20000,GL_QUADS));
addGLBuf(lines=new GLShortBuffer(20000,GL_LINES));
quads->forceAntiAlias(true);
lines->setSize(2);
lines->forceAntiAlias(false);
@ -152,7 +152,7 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
if (!m_visible) return;
rtop=top;
GLBuffer *outlines=w.lines();
GLShortBuffer *outlines=w.lines();
QColor blk=Qt::black;
outlines->add(left, top, left, top+height, blk);
outlines->add(left, top+height, left+width,top+height, blk);
@ -294,10 +294,8 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
if (m_graphtype==GT_BAR) {
QColor col2=brighten(col);
quads->add(x1,py,col);
quads->add(x1,py-h,col);
quads->add(x2,py-h,col2);
quads->add(x2,py,col2);
quads->add(x1,py,x1,py-h,col);
quads->add(x2,py-h,x2,py,col2);
if (barw>2) {
outlines->add(x1,py,x1,py-h,blk);
outlines->add(x1,py-h,x2,py-h,blk);

View File

@ -35,7 +35,7 @@ class SummaryChart:public Layer
QHash<int,Day *> m_days;
Profile * m_profile;
GLBuffer *quads,*lines;
GLShortBuffer *quads,*lines;
bool m_empty;
int m_fday;
QString m_label;

View File

@ -9,7 +9,7 @@
#include "gXAxis.h"
const quint64 divisors[]={
15552000000LL, 7776000000LL, 5184000000LL, 2419200000L, 1814400000L, 1209600000L, 604800000L, 259200000L,
15552000000ULL, 7776000000ULL, 5184000000ULL, 2419200000ULL, 1814400000ULL, 1209600000L, 604800000L, 259200000L,
172800000L, 86400000,2880000,14400000,7200000,3600000,2700000,
1800000,1200000,900000,600000,300000,120000,60000,45000,30000,
20000,15000,10000,5000,2000,1000,100,50,10
@ -133,7 +133,7 @@ void gXAxis::paint(gGraph & w,int left,int top, int width, int height)
}
QColor linecol=Qt::black;
GLBuffer *lines=w.backlines();
GLShortBuffer *lines=w.backlines();
int utcoff=m_utcfix ? tz_hours : 0;

View File

@ -33,7 +33,7 @@ protected:
bool m_show_minor_lines;
QColor m_major_color;
QColor m_minor_color;
GLBuffer * lines;
GLShortBuffer * lines;
};
class gYAxis:public Layer
@ -65,7 +65,7 @@ class gYAxis:public Layer
QColor m_line_color;
QColor m_text_color;
GLBuffer * lines;
GLShortBuffer * lines;
virtual bool mouseMoveEvent(QMouseEvent * event);
};