mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-16 18:50:46 +00:00
Fixed vertarray buffer overrun (forgot to allocate the extra bit)
This commit is contained in:
parent
bf4fafb862
commit
2c0069d46a
@ -28,6 +28,7 @@ class gBarChart:public gLayer
|
|||||||
virtual const QString & FormatY(double v) { static QString t; t.sprintf("%.1f",v); return t; }
|
virtual const QString & FormatY(double v) { static QString t; t.sprintf("%.1f",v); return t; }
|
||||||
|
|
||||||
gXAxis *Xaxis;
|
gXAxis *Xaxis;
|
||||||
|
QVector<QColor> color;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GBARCHART_H
|
#endif // GBARCHART_H
|
||||||
|
@ -67,11 +67,9 @@ void gFlagsGroup::Plot(gGraphWindow &w, float scrx, float scry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gFlagsLine::gFlagsLine(ChannelID code,QColor col,QString label,bool always_visible,FlagType flt)
|
gFlagsLine::gFlagsLine(ChannelID code,QColor flag_color,QString label,bool always_visible,FlagType flt)
|
||||||
:gLayer(code),m_label(label),m_always_visible(always_visible),m_flt(flt)
|
:gLayer(code),m_label(label),m_always_visible(always_visible),m_flt(flt),m_flag_color(flag_color)
|
||||||
{
|
{
|
||||||
color.clear();
|
|
||||||
color.push_back(col);
|
|
||||||
}
|
}
|
||||||
gFlagsLine::~gFlagsLine()
|
gFlagsLine::~gFlagsLine()
|
||||||
{
|
{
|
||||||
@ -111,16 +109,18 @@ void gFlagsLine::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
float line_top=(start_py+height-line_h)-line_num*line_h;
|
float line_top=(start_py+height-line_h)-line_num*line_h;
|
||||||
|
|
||||||
// Alternating box color
|
// Alternating box color
|
||||||
QColor *barcol=&col2;
|
QColor * barcol=&col2;
|
||||||
if (line_num & 1)
|
if (line_num & 1)
|
||||||
barcol=&col1;
|
barcol=&col1;
|
||||||
|
|
||||||
|
int qo=0;
|
||||||
|
//if (evil_intel_graphics_card) qo=1;
|
||||||
|
|
||||||
// Filled rectangle
|
// Filled rectangle
|
||||||
glColor4ub(barcol->red(),barcol->green(),barcol->blue(),barcol->alpha());
|
w.qglColor(*barcol);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex2f(start_px+1, line_top);
|
glVertex2f(start_px+qo, line_top);
|
||||||
glVertex2f(start_px+1, line_top+line_h);
|
glVertex2f(start_px+qo, line_top+line_h);
|
||||||
glVertex2f(start_px+width-1, line_top+line_h);
|
glVertex2f(start_px+width-1, line_top+line_h);
|
||||||
glVertex2f(start_px+width-1, line_top);
|
glVertex2f(start_px+width-1, line_top);
|
||||||
glEnd();
|
glEnd();
|
||||||
@ -140,8 +140,6 @@ void gFlagsLine::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
DrawText(w,m_label,start_px-x-10,(scry-line_top)-(line_h/2)+(y/2));
|
DrawText(w,m_label,start_px-x-10,(scry-line_top)-(line_h/2)+(y/2));
|
||||||
float x1,x2;
|
float x1,x2;
|
||||||
|
|
||||||
QColor & col=color[0];
|
|
||||||
|
|
||||||
float top=floor(line_top)+2;
|
float top=floor(line_top)+2;
|
||||||
float bottom=top+floor(line_h)-3;
|
float bottom=top+floor(line_h)-3;
|
||||||
|
|
||||||
@ -176,7 +174,6 @@ void gFlagsLine::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glColor4ub(col.red(),col.green(),col.blue(),col.alpha());
|
|
||||||
glScissor(w.GetLeftMargin(),w.GetBottomMargin(),width,height);
|
glScissor(w.GetLeftMargin(),w.GetBottomMargin(),width,height);
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
@ -190,6 +187,7 @@ void gFlagsLine::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
} else glLineWidth (1);
|
} else glLineWidth (1);
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
w.qglColor(m_flag_color);
|
||||||
if (quadcnt>0) {
|
if (quadcnt>0) {
|
||||||
glVertexPointer(2, GL_SHORT, 0, quadarray);
|
glVertexPointer(2, GL_SHORT, 0, quadarray);
|
||||||
glDrawArrays(GL_QUADS, 0, quadcnt>>1);
|
glDrawArrays(GL_QUADS, 0, quadcnt>>1);
|
||||||
|
@ -30,6 +30,7 @@ class gFlagsLine:public gLayer
|
|||||||
bool m_always_visible;
|
bool m_always_visible;
|
||||||
int total_lines,line_num;
|
int total_lines,line_num;
|
||||||
FlagType m_flt;
|
FlagType m_flt;
|
||||||
|
QColor m_flag_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
class gFlagsGroup:public gLayerGroup
|
class gFlagsGroup:public gLayerGroup
|
||||||
|
@ -6,12 +6,9 @@
|
|||||||
|
|
||||||
#include "gFooBar.h"
|
#include "gFooBar.h"
|
||||||
|
|
||||||
gFooBar::gFooBar(int offset,QColor col1,QColor col2,bool funkbar)
|
gFooBar::gFooBar(int offset,QColor handle_color,QColor line_color,bool shadow,QColor shadow_color)
|
||||||
:gLayer(EmptyChannel),m_funkbar(funkbar),m_offset(offset)
|
:gLayer(EmptyChannel),m_offset(offset),m_shadow(shadow),m_handle_color(handle_color),m_line_color(line_color),m_shadow_color(shadow_color)
|
||||||
{
|
{
|
||||||
color.clear();
|
|
||||||
color.push_back(col2);
|
|
||||||
color.push_back(col1);
|
|
||||||
}
|
}
|
||||||
gFooBar::~gFooBar()
|
gFooBar::~gFooBar()
|
||||||
{
|
{
|
||||||
@ -30,15 +27,12 @@ void gFooBar::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
int height=scry - (w.GetTopMargin() + w.GetBottomMargin());
|
int height=scry - (w.GetTopMargin() + w.GetBottomMargin());
|
||||||
int end_px=scrx-w.GetRightMargin();
|
int end_px=scrx-w.GetRightMargin();
|
||||||
|
|
||||||
QColor & col1=color[0];
|
|
||||||
QColor & col2=color[1];
|
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
float h=m_offset;
|
float h=m_offset;
|
||||||
glColor4ub(col1.red(),col1.green(),col1.blue(),col1.alpha());
|
|
||||||
|
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
w.qglColor(m_line_color);
|
||||||
glVertex2f(start_px, h);
|
glVertex2f(start_px, h);
|
||||||
glVertex2f(start_px+width, h);
|
glVertex2f(start_px+width, h);
|
||||||
glEnd();
|
glEnd();
|
||||||
@ -47,30 +41,27 @@ void gFooBar::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
double px=((1/rmx)*(w.min_x-w.rmin_x))*width;
|
double px=((1/rmx)*(w.min_x-w.rmin_x))*width;
|
||||||
double py=((1/rmx)*(w.max_x-w.rmin_x))*width;
|
double py=((1/rmx)*(w.max_x-w.rmin_x))*width;
|
||||||
|
|
||||||
glColor4ub(col2.red(),col2.green(),col2.blue(),col2.alpha());
|
|
||||||
glLineWidth(4);
|
glLineWidth(4);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
w.qglColor(m_handle_color);
|
||||||
glVertex2f(start_px+px-4,h);
|
glVertex2f(start_px+px-4,h);
|
||||||
glVertex2f(start_px+py+4,h);
|
glVertex2f(start_px+py+4,h);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
|
|
||||||
if ((m_funkbar)) { // && ((w.min_x>w.rmin_x) || (w.max_x<w.rmax_x))) {
|
if ((m_shadow)) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
glColor4f(.2,.2,.2,.2);
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
w.qglColor(m_shadow_color);
|
||||||
|
|
||||||
glVertex2f(start_px, w.GetBottomMargin());
|
glVertex2f(start_px, w.GetBottomMargin());
|
||||||
glVertex2f(start_px, w.GetBottomMargin()+height);
|
glVertex2f(start_px, w.GetBottomMargin()+height);
|
||||||
glVertex2f(start_px+px, w.GetBottomMargin()+height);
|
glVertex2f(start_px+px, w.GetBottomMargin()+height);
|
||||||
glVertex2f(start_px+px, w.GetBottomMargin());
|
glVertex2f(start_px+px, w.GetBottomMargin());
|
||||||
//glEnd();
|
|
||||||
//glDisable(GL_BLEND);
|
|
||||||
|
|
||||||
//glColor4f(.2,.2,.2,.3);
|
|
||||||
//glBegin(GL_QUADS);
|
|
||||||
glVertex2f(start_px+py, w.GetBottomMargin());
|
glVertex2f(start_px+py, w.GetBottomMargin());
|
||||||
glVertex2f(start_px+py, w.GetBottomMargin()+height);
|
glVertex2f(start_px+py, w.GetBottomMargin()+height);
|
||||||
glVertex2f(end_px, w.GetBottomMargin()+height);
|
glVertex2f(end_px, w.GetBottomMargin()+height);
|
||||||
|
@ -12,13 +12,16 @@
|
|||||||
class gFooBar:public gLayer
|
class gFooBar:public gLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
gFooBar(int offset=10,QColor color1=QColor("orange"),QColor color2=QColor("dark grey"),bool funkbar=false);
|
gFooBar(int offset=10,QColor handle_color=QColor("orange"),QColor line_color=QColor("dark grey"),bool shadow=false,QColor shadow_color=QColor(40,40,40,40));
|
||||||
virtual ~gFooBar();
|
virtual ~gFooBar();
|
||||||
virtual void Plot(gGraphWindow & w,float scrx,float scry);
|
virtual void Plot(gGraphWindow & w,float scrx,float scry);
|
||||||
static const int Margin=15;
|
static const int Margin=15;
|
||||||
protected:
|
protected:
|
||||||
bool m_funkbar;
|
|
||||||
int m_offset;
|
int m_offset;
|
||||||
|
QColor m_line_color;
|
||||||
|
QColor m_handle_color;
|
||||||
|
QColor m_shadow_color;
|
||||||
|
bool m_shadow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GFOOBAR_H
|
#endif // GFOOBAR_H
|
||||||
|
@ -11,8 +11,7 @@
|
|||||||
gLineOverlayBar::gLineOverlayBar(ChannelID code,QColor col,QString label,FlagType flt)
|
gLineOverlayBar::gLineOverlayBar(ChannelID code,QColor col,QString label,FlagType flt)
|
||||||
:gLayer(code),m_label(label),m_flt(flt)
|
:gLayer(code),m_label(label),m_flt(flt)
|
||||||
{
|
{
|
||||||
color.clear();
|
m_flag_color=col;
|
||||||
color.push_back(col);
|
|
||||||
}
|
}
|
||||||
gLineOverlayBar::~gLineOverlayBar()
|
gLineOverlayBar::~gLineOverlayBar()
|
||||||
{
|
{
|
||||||
@ -51,7 +50,6 @@ void gLineOverlayBar::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
float bottom=start_py+25, top=start_py+height-25;
|
float bottom=start_py+25, top=start_py+height-25;
|
||||||
QColor & col=color[0];
|
|
||||||
|
|
||||||
double X;
|
double X;
|
||||||
double Y;
|
double Y;
|
||||||
@ -141,7 +139,7 @@ void gLineOverlayBar::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
} else glLineWidth (1);
|
} else glLineWidth (1);
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glColor4ub(col.red(),col.green(),col.blue(),col.alpha());
|
w.qglColor(m_flag_color);
|
||||||
if (quadcnt>0) {
|
if (quadcnt>0) {
|
||||||
//glEnableClientState(GL_VERTEX_ARRAY);
|
//glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glVertexPointer(2, GL_SHORT, 0, quadarray);
|
glVertexPointer(2, GL_SHORT, 0, quadarray);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
class gLineOverlayBar:public gLayer
|
class gLineOverlayBar:public gLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
gLineOverlayBar(ChannelID code,QColor col=QColor("black"),QString _label="",FlagType _flt=FT_Bar);
|
gLineOverlayBar(ChannelID code,QColor col,QString _label="",FlagType _flt=FT_Bar);
|
||||||
virtual ~gLineOverlayBar();
|
virtual ~gLineOverlayBar();
|
||||||
|
|
||||||
virtual void Plot(gGraphWindow & w,float scrx,float scry);
|
virtual void Plot(gGraphWindow & w,float scrx,float scry);
|
||||||
@ -20,6 +20,7 @@ class gLineOverlayBar:public gLayer
|
|||||||
virtual EventDataType Maxy() { return 0; }
|
virtual EventDataType Maxy() { return 0; }
|
||||||
virtual bool isEmpty() { return true; }
|
virtual bool isEmpty() { return true; }
|
||||||
protected:
|
protected:
|
||||||
|
QColor m_flag_color;
|
||||||
QString m_label;
|
QString m_label;
|
||||||
FlagType m_flt;
|
FlagType m_flt;
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,7 @@ class gSessionTime:public gLayer
|
|||||||
virtual const QString & FormatY(double v) { static QString t; t.sprintf("%.1f",v); return t; }
|
virtual const QString & FormatY(double v) { static QString t; t.sprintf("%.1f",v); return t; }
|
||||||
|
|
||||||
gXAxis *Xaxis;
|
gXAxis *Xaxis;
|
||||||
|
QVector<QColor> color;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GSESSIONTIME_H
|
#endif // GSESSIONTIME_H
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/********************************************************************
|
/*
|
||||||
gXAxis Implementation
|
gXAxis Implementation
|
||||||
Copyright (c)2011 Mark Watkins <jedimark@users.sourceforge.net>
|
Copyright (c)2011 Mark Watkins <jedimark@users.sourceforge.net>
|
||||||
License: GPL
|
License: GPL
|
||||||
*********************************************************************/
|
*/
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -11,8 +11,10 @@
|
|||||||
gXAxis::gXAxis(QColor col)
|
gXAxis::gXAxis(QColor col)
|
||||||
:gLayer(EmptyChannel)
|
:gLayer(EmptyChannel)
|
||||||
{
|
{
|
||||||
color.clear();
|
m_line_color=col;
|
||||||
color.push_back(col);
|
m_text_color=col;
|
||||||
|
m_major_color=Qt::darkGray;
|
||||||
|
m_minor_color=Qt::lightGray;
|
||||||
m_show_major_lines=false;
|
m_show_major_lines=false;
|
||||||
m_show_minor_lines=false;
|
m_show_minor_lines=false;
|
||||||
m_show_minor_ticks=true;
|
m_show_minor_ticks=true;
|
||||||
|
@ -31,5 +31,10 @@ class gXAxis:public gLayer
|
|||||||
bool m_show_minor_ticks;
|
bool m_show_minor_ticks;
|
||||||
bool m_show_major_ticks;
|
bool m_show_major_ticks;
|
||||||
|
|
||||||
|
QColor m_line_color;
|
||||||
|
QColor m_text_color;
|
||||||
|
QColor m_major_color;
|
||||||
|
QColor m_minor_color;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // GXAXIS_H
|
#endif // GXAXIS_H
|
||||||
|
@ -11,8 +11,10 @@
|
|||||||
gYAxis::gYAxis(QColor col)
|
gYAxis::gYAxis(QColor col)
|
||||||
:gLayer(EmptyChannel)
|
:gLayer(EmptyChannel)
|
||||||
{
|
{
|
||||||
color.clear();
|
m_line_color=col;
|
||||||
color.push_back(col);
|
m_text_color=col;
|
||||||
|
m_major_color=Qt::darkGray;
|
||||||
|
m_minor_color=Qt::lightGray;
|
||||||
|
|
||||||
m_show_major_lines=true;
|
m_show_major_lines=true;
|
||||||
m_show_minor_lines=true;
|
m_show_minor_lines=true;
|
||||||
@ -23,8 +25,6 @@ gYAxis::~gYAxis()
|
|||||||
}
|
}
|
||||||
void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
|
void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
|
||||||
{
|
{
|
||||||
static QColor DARK_GREY(0xc0,0xc0,0xc0,0x80);
|
|
||||||
static QColor LIGHT_GREY(0xd8,0xd8,0xd8,0x80);
|
|
||||||
float x,y;
|
float x,y;
|
||||||
int labelW=0;
|
int labelW=0;
|
||||||
|
|
||||||
@ -79,9 +79,6 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
|
|||||||
int height=scry-(topm+start_py);
|
int height=scry-(topm+start_py);
|
||||||
if (height<0) return;
|
if (height<0) return;
|
||||||
|
|
||||||
const QColor & linecol1=LIGHT_GREY;
|
|
||||||
const QColor & linecol2=DARK_GREY;
|
|
||||||
|
|
||||||
QString fd="0";
|
QString fd="0";
|
||||||
GetTextExtent(fd,x,y);
|
GetTextExtent(fd,x,y);
|
||||||
|
|
||||||
@ -102,14 +99,17 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
|
|||||||
float ty,h;
|
float ty,h;
|
||||||
|
|
||||||
qint32 vertcnt=0;
|
qint32 vertcnt=0;
|
||||||
GLshort * vertarray=vertex_array[0];
|
GLshort * vertarray=(GLshort *)vertex_array[0];
|
||||||
if (vertarray==NULL) {
|
qint32 minorvertcnt=0;
|
||||||
qWarning() << "VertArray==NULL";
|
GLshort * minorvertarray=(GLshort *)vertex_array[1];
|
||||||
|
qint32 majorvertcnt=0;
|
||||||
|
GLshort * majorvertarray=(GLshort *)vertex_array[2];
|
||||||
|
|
||||||
|
if ((vertarray==NULL) || (minorvertarray==NULL) || (majorvertarray==NULL)) {
|
||||||
|
qWarning() << "gYAxis::Plot() VertArray==NULL";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glColor4ub(linecol1.red(),linecol1.green(),linecol1.blue(),linecol1.alpha());
|
|
||||||
glLineWidth(1);
|
|
||||||
if (min_ytick<=0) {
|
if (min_ytick<=0) {
|
||||||
qDebug() << "min_ytick error in gYAxis::Plot()";
|
qDebug() << "min_ytick error in gYAxis::Plot()";
|
||||||
return;
|
return;
|
||||||
@ -127,14 +127,14 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
|
|||||||
vertarray[vertcnt++]=start_px;
|
vertarray[vertcnt++]=start_px;
|
||||||
vertarray[vertcnt++]=h;
|
vertarray[vertcnt++]=h;
|
||||||
if (m_show_minor_lines && (i > miny)) {
|
if (m_show_minor_lines && (i > miny)) {
|
||||||
glBegin(GL_LINES);
|
minorvertarray[minorvertcnt++]=start_px+1;
|
||||||
glVertex2f(start_px+1, h);
|
minorvertarray[minorvertcnt++]=h;
|
||||||
glVertex2f(start_px+width, h);
|
minorvertarray[minorvertcnt++]=start_px+width;
|
||||||
glEnd();
|
minorvertarray[minorvertcnt++]=h;
|
||||||
}
|
}
|
||||||
if (vertcnt>maxverts) {
|
if (vertcnt>maxverts) {
|
||||||
qWarning() << "vertarray bounds exceeded in gYAxis for " << w.Title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick;
|
qWarning() << "vertarray bounds exceeded in gYAxis for " << w.Title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick;
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
|
|||||||
GetTextExtent(fd,x,y);
|
GetTextExtent(fd,x,y);
|
||||||
if (x>labelW) labelW=x;
|
if (x>labelW) labelW=x;
|
||||||
h=start_py+ty;
|
h=start_py+ty;
|
||||||
DrawText(w,fd,start_px-12-x,scry-(h-(y/2.0)),0);
|
DrawText(w,fd,start_px-12-x,scry-(h-(y/2.0)),0,m_text_color);
|
||||||
|
|
||||||
vertarray[vertcnt++]=start_px-4;
|
vertarray[vertcnt++]=start_px-4;
|
||||||
vertarray[vertcnt++]=h;
|
vertarray[vertcnt++]=h;
|
||||||
@ -156,11 +156,10 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_show_major_lines && (i > miny)) {
|
if (m_show_major_lines && (i > miny)) {
|
||||||
glColor4ub(linecol2.red(),linecol2.green(),linecol2.blue(),linecol2.alpha());
|
majorvertarray[majorvertcnt++]=start_px+1;
|
||||||
glBegin(GL_LINES);
|
majorvertarray[majorvertcnt++]=h;
|
||||||
glVertex2f(start_px+1, h);
|
majorvertarray[majorvertcnt++]=start_px+width;
|
||||||
glVertex2f(start_px+width, h);
|
majorvertarray[majorvertcnt++]=h;
|
||||||
glEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vertcnt>=maxverts) {
|
if (vertcnt>=maxverts) {
|
||||||
@ -168,12 +167,19 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the little ticks.
|
// Draw the lines & ticks
|
||||||
|
// Turn on blending??
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glColor3f(0,0,0);
|
w.qglColor(m_line_color);
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glVertexPointer(2, GL_SHORT, 0, vertarray);
|
glVertexPointer(2, GL_SHORT, 0, vertarray);
|
||||||
glDrawArrays(GL_LINES, 0, vertcnt>>1);
|
glDrawArrays(GL_LINES, 0, vertcnt>>1);
|
||||||
|
w.qglColor(m_minor_color);
|
||||||
|
glVertexPointer(2, GL_SHORT, 0, minorvertarray);
|
||||||
|
glDrawArrays(GL_LINES, 0, minorvertcnt>>1);
|
||||||
|
w.qglColor(m_major_color);
|
||||||
|
glVertexPointer(2, GL_SHORT, 0, majorvertarray);
|
||||||
|
glDrawArrays(GL_LINES, 0, majorvertcnt>>1);
|
||||||
glDisableClientState(GL_VERTEX_ARRAY); // deactivate vertex arrays after drawing
|
glDisableClientState(GL_VERTEX_ARRAY); // deactivate vertex arrays after drawing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/********************************************************************
|
/*
|
||||||
gYAxis Header
|
gYAxis Header
|
||||||
Copyright (c)2011 Mark Watkins <jedimark@users.sourceforge.net>
|
Copyright (c)2011 Mark Watkins <jedimark@users.sourceforge.net>
|
||||||
License: GPL
|
License: GPL
|
||||||
*********************************************************************/
|
*/
|
||||||
|
|
||||||
#ifndef GYAXIS_H
|
#ifndef GYAXIS_H
|
||||||
#define GYAXIS_H
|
#define GYAXIS_H
|
||||||
@ -34,6 +34,12 @@ class gYAxis:public gLayer
|
|||||||
bool m_show_minor_ticks;
|
bool m_show_minor_ticks;
|
||||||
bool m_show_major_ticks;
|
bool m_show_major_ticks;
|
||||||
float m_yaxis_scale;
|
float m_yaxis_scale;
|
||||||
|
|
||||||
|
QColor m_line_color;
|
||||||
|
QColor m_text_color;
|
||||||
|
QColor m_major_color;
|
||||||
|
QColor m_minor_color;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GYAXIS_H
|
#endif // GYAXIS_H
|
||||||
|
@ -19,19 +19,19 @@ QFont * defaultfont=NULL;
|
|||||||
QFont * mediumfont=NULL;
|
QFont * mediumfont=NULL;
|
||||||
QFont * bigfont=NULL;
|
QFont * bigfont=NULL;
|
||||||
|
|
||||||
GLshort *vertex_array[num_vert_arrays]={NULL};
|
GLshort * vertex_array[num_vert_arrays]={0};
|
||||||
bool evil_intel_graphics_chip=false;
|
bool evil_intel_graphics_chip=false;
|
||||||
|
|
||||||
// Must be called from a thread inside the application.
|
// Must be called from a thread inside the application.
|
||||||
void InitGraphs()
|
void InitGraphs()
|
||||||
{
|
{
|
||||||
if (!_graph_init) {
|
if (!_graph_init) {
|
||||||
|
|
||||||
defaultfont=new QFont("FreeSans",10);
|
defaultfont=new QFont("FreeSans",10);
|
||||||
bigfont=new QFont("FreeSans",35);
|
bigfont=new QFont("FreeSans",35);
|
||||||
mediumfont=new QFont("FreeSans",18);
|
mediumfont=new QFont("FreeSans",18);
|
||||||
for (int i=0;i<num_vert_arrays;i++) {
|
for (int i=0;i<num_vert_arrays;i++) {
|
||||||
vertex_array[i]=new GLshort[maxverts];
|
GLshort *a=(GLshort *)calloc(maxverts+8,sizeof(GLshort));
|
||||||
|
vertex_array[i]=a;
|
||||||
}
|
}
|
||||||
_graph_init=true;
|
_graph_init=true;
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ void DoneGraphs()
|
|||||||
delete bigfont;
|
delete bigfont;
|
||||||
delete mediumfont;
|
delete mediumfont;
|
||||||
for (int i=0;i<num_vert_arrays;i++) {
|
for (int i=0;i<num_vert_arrays;i++) {
|
||||||
delete [] vertex_array[i];
|
free(vertex_array[i]);
|
||||||
}
|
}
|
||||||
_graph_init=false;
|
_graph_init=false;
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ gLayer::gLayer(ChannelID code,QString title)
|
|||||||
{
|
{
|
||||||
m_visible = true;
|
m_visible = true;
|
||||||
m_movable = false;
|
m_movable = false;
|
||||||
color.push_back(QColor("red"));
|
//color.push_back(QColor("red"));
|
||||||
color.push_back(QColor("green"));
|
//color.push_back(QColor("green"));
|
||||||
m_day=NULL;
|
m_day=NULL;
|
||||||
m_miny=m_maxy=0;
|
m_miny=m_maxy=0;
|
||||||
m_minx=m_maxx=0;
|
m_minx=m_maxx=0;
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
gLayer(ChannelID code=EmptyChannel,QString title="");
|
gLayer(ChannelID code=EmptyChannel,QString title="");
|
||||||
virtual ~gLayer();
|
virtual ~gLayer();
|
||||||
virtual void Plot(gGraphWindow & w,float scrx,float scry)=0;
|
virtual void Plot(gGraphWindow & w,float scrx,float scry)=0;
|
||||||
QVector<QColor> color;
|
//QVector<QColor> color;
|
||||||
|
|
||||||
virtual void SetDay(Day * d);
|
virtual void SetDay(Day * d);
|
||||||
virtual void SetCode(ChannelID c) { m_code=c; }
|
virtual void SetCode(ChannelID c) { m_code=c; }
|
||||||
@ -42,8 +42,8 @@ protected:
|
|||||||
bool m_movable;
|
bool m_movable;
|
||||||
qint64 m_minx,m_maxx;
|
qint64 m_minx,m_maxx;
|
||||||
EventDataType m_miny,m_maxy;
|
EventDataType m_miny,m_maxy;
|
||||||
QString m_title;
|
|
||||||
ChannelID m_code;
|
ChannelID m_code;
|
||||||
|
QString m_title;
|
||||||
};
|
};
|
||||||
|
|
||||||
class gLayerGroup:public gLayer
|
class gLayerGroup:public gLayer
|
||||||
|
@ -45,6 +45,7 @@ gGraphWindow::gGraphWindow(QWidget *parent, const QString & title, QGLWidget * s
|
|||||||
min_x=max_x=0;
|
min_x=max_x=0;
|
||||||
rmin_y=rmax_y=0;
|
rmin_y=rmax_y=0;
|
||||||
min_y=max_y=0;
|
min_y=max_y=0;
|
||||||
|
InitGraphs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*gGraphWindow::gGraphWindow(QWidget *parent, const QString & title, QGLContext * context,Qt::WindowFlags f)
|
/*gGraphWindow::gGraphWindow(QWidget *parent, const QString & title, QGLContext * context,Qt::WindowFlags f)
|
||||||
@ -862,7 +863,6 @@ void gGraphWindow::paintGL()
|
|||||||
if (m_scrX<=0) return;
|
if (m_scrX<=0) return;
|
||||||
if (m_scrY<=0) return;
|
if (m_scrY<=0) return;
|
||||||
|
|
||||||
InitGraphs();
|
|
||||||
//glDisable(GL_DEPTH_TEST);
|
//glDisable(GL_DEPTH_TEST);
|
||||||
Render(m_scrX,m_scrY);
|
Render(m_scrX,m_scrY);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user