Auto-convert the Graphs/ subdirectory with astyle.

Signed-off-by: Mark Watkins <jedimark@users.sourceforge.net>
This commit is contained in:
Sean Stangl 2014-04-16 22:55:38 -07:00 committed by Mark Watkins
parent 012e9fd314
commit b5d5b82b59
23 changed files with 2974 additions and 2350 deletions

View File

@ -15,27 +15,29 @@
#include "gFlagsLine.h"
#include "gYAxis.h"
gFlagsLabelArea::gFlagsLabelArea(gFlagsGroup * group)
:gSpacer(20)
gFlagsLabelArea::gFlagsLabelArea(gFlagsGroup *group)
: gSpacer(20)
{
m_group=group;
m_group = group;
}
bool gFlagsLabelArea::mouseMoveEvent(QMouseEvent * event,gGraph * graph)
bool gFlagsLabelArea::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
{
if (m_group)
return m_group->mouseMoveEvent(event,graph);
if (m_group) {
return m_group->mouseMoveEvent(event, graph);
}
return false;
}
gFlagsGroup::gFlagsGroup()
{
addVertexBuffer(quads=new gVertexBuffer(512,GL_QUADS));
addVertexBuffer(lines=new gVertexBuffer(20,GL_LINE_LOOP));
addVertexBuffer(quads = new gVertexBuffer(512, GL_QUADS));
addVertexBuffer(lines = new gVertexBuffer(20, GL_LINE_LOOP));
quads->setAntiAlias(true);
lines->setAntiAlias(false);
m_barh=0;
m_empty=true;
m_barh = 0;
m_empty = true;
}
gFlagsGroup::~gFlagsGroup()
{
@ -45,6 +47,7 @@ qint64 gFlagsGroup::Minx()
if (m_day) {
return m_day->first();
}
return 0;
}
qint64 gFlagsGroup::Maxx()
@ -52,94 +55,114 @@ qint64 gFlagsGroup::Maxx()
if (m_day) {
return m_day->last();
}
return 0;
}
void gFlagsGroup::SetDay(Day * d)
void gFlagsGroup::SetDay(Day *d)
{
LayerGroup::SetDay(d);
lvisible.clear();
int cnt=0;
for (int i=0;i<layers.size();i++) {
gFlagsLine *f=dynamic_cast<gFlagsLine *>(layers[i]);
if (!f) continue;
int cnt = 0;
for (int i = 0; i < layers.size(); i++) {
gFlagsLine *f = dynamic_cast<gFlagsLine *>(layers[i]);
if (!f) { continue; }
bool e = f->isEmpty();
bool e=f->isEmpty();
if (!e || f->isAlwaysVisible()) {
lvisible.push_back(f);
if (!e)
if (!e) {
cnt++;
}
}
m_empty=(cnt==0);
}
m_empty = (cnt == 0);
if (m_empty) {
if (d) {
m_empty=!d->channelExists(CPAP_Pressure);
m_empty = !d->channelExists(CPAP_Pressure);
}
}
m_barh=0;
m_barh = 0;
}
void gFlagsGroup::paint(gGraph &g, int left, int top, int width, int height)
{
if (!m_visible) return;
if (!m_day) return;
if (!m_visible) { return; }
int vis=lvisible.size();
m_barh=float(height)/float(vis);
float linetop=top;
if (!m_day) { return; }
int vis = lvisible.size();
m_barh = float(height) / float(vis);
float linetop = top;
QColor barcol;
for (int i=0;i<lvisible.size();i++) {
for (int i = 0; i < lvisible.size(); i++) {
// Alternating box color
if (i & 1) barcol=COLOR_ALT_BG1; else barcol=COLOR_ALT_BG2;
quads->add(left, linetop, left, linetop+m_barh, left+width-1, linetop+m_barh, left+width-1, linetop, barcol.rgba());
if (i & 1) { barcol = COLOR_ALT_BG1; }
else { barcol = COLOR_ALT_BG2; }
quads->add(left, linetop, left, linetop + m_barh, left + width - 1, linetop + m_barh,
left + width - 1, linetop, barcol.rgba());
// Paint the actual flags
lvisible[i]->m_rect=QRect(left,linetop,width,m_barh);
lvisible[i]->paint(g,left,linetop,width,m_barh);
linetop+=m_barh;
lvisible[i]->m_rect = QRect(left, linetop, width, m_barh);
lvisible[i]->paint(g, left, linetop, width, m_barh);
linetop += m_barh;
}
gVertexBuffer *outlines=g.lines();
outlines->add(left-1, top, left-1, top+height, COLOR_Outline.rgba());
outlines->add(left-1, top+height, left+width,top+height, COLOR_Outline.rgba());
outlines->add(left+width,top+height, left+width, top,COLOR_Outline.rgba());
outlines->add(left+width, top, left-1, top, COLOR_Outline.rgba());
gVertexBuffer *outlines = g.lines();
outlines->add(left - 1, top, left - 1, top + height, COLOR_Outline.rgba());
outlines->add(left - 1, top + height, left + width, top + height, COLOR_Outline.rgba());
outlines->add(left + width, top + height, left + width, top, COLOR_Outline.rgba());
outlines->add(left + width, top, left - 1, top, COLOR_Outline.rgba());
//lines->add(left-1, top, left-1, top+height);
//lines->add(left+width, top+height, left+width, top);
}
bool gFlagsGroup::mouseMoveEvent(QMouseEvent * event,gGraph * graph)
bool gFlagsGroup::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
{
if (!p_profile->appearance->graphTooltips())
if (!p_profile->appearance->graphTooltips()) {
return false;
}
for (int i=0;i<lvisible.size();i++) {
gFlagsLine *fl=lvisible[i];
if (fl->m_rect.contains(event->x(),event->y())) {
if (fl->mouseMoveEvent(event,graph)) return true;
for (int i = 0; i < lvisible.size(); i++) {
gFlagsLine *fl = lvisible[i];
if (fl->m_rect.contains(event->x(), event->y())) {
if (fl->mouseMoveEvent(event, graph)) { return true; }
} else {
// Inside main graph area?
if ((event->y() > fl->m_rect.y()) && (event->y()) < (fl->m_rect.y()+fl->m_rect.height())) {
if ((event->y() > fl->m_rect.y()) && (event->y()) < (fl->m_rect.y() + fl->m_rect.height())) {
if (event->x() < lvisible[i]->m_rect.x()) {
// Display tooltip
QString ttip=schema::channel[fl->code()].fullname()+"\n"+schema::channel[fl->code()].description();
graph->ToolTip(ttip,event->x(),event->y()-15);
QString ttip = schema::channel[fl->code()].fullname() + "\n" +
schema::channel[fl->code()].description();
graph->ToolTip(ttip, event->x(), event->y() - 15);
graph->redraw();
}
}
}
}
return false;
}
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)
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)
{
addVertexBuffer(quads=new gVertexBuffer(2048,GL_QUADS));
addVertexBuffer(quads = new gVertexBuffer(2048, GL_QUADS));
//addGLBuf(lines=new GLBuffer(flag_color,1024,GL_LINES));
quads->setAntiAlias(true);
//lines->setAntiAlias(true);
@ -151,80 +174,94 @@ gFlagsLine::~gFlagsLine()
//delete lines;
//delete quads;
}
void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height)
void gFlagsLine::paint(gGraph &w, int left, int top, int width, int height)
{
if (!m_visible) return;
if (!m_day) return;
lines=w.lines();
if (!m_visible) { return; }
if (!m_day) { return; }
lines = w.lines();
double minx;
double maxx;
if (w.blockZoom()) {
minx=w.rmin_x;
maxx=w.rmax_x;
minx = w.rmin_x;
maxx = w.rmax_x;
} else {
minx=w.min_x;
maxx=w.max_x;
minx = w.min_x;
maxx = w.max_x;
}
double xx=maxx-minx;
if (xx<=0) return;
double xx = maxx - minx;
double xmult=width/xx;
if (xx <= 0) { return; }
GetTextExtent(m_label,m_lx,m_ly);
double xmult = width / xx;
GetTextExtent(m_label, m_lx, m_ly);
// Draw text label
w.renderText(m_label,left-m_lx-10,top+(height/2)+(m_ly/2));
w.renderText(m_label, left - m_lx - 10, top + (height / 2) + (m_ly / 2));
float x1,x2;
float x1, x2;
float bartop=top+2;
float bottom=top+height-2;
bool verts_exceeded=false;
qint64 X,X2,L;
float bartop = top + 2;
float bottom = top + height - 2;
bool verts_exceeded = false;
qint64 X, X2, L;
lines->setColor(schema::channel[m_code].defaultColor());
qint64 start;
quint32 * tptr;
quint32 *tptr;
EventStoreType *dptr, * eptr;
int idx;
QHash<ChannelID,QVector<EventList *> >::iterator cei;
QHash<ChannelID, QVector<EventList *> >::iterator cei;
qint64 clockdrift=qint64(PROFILE.cpap->clockDrift()) * 1000L;
qint64 drift=0;
qint64 clockdrift = qint64(PROFILE.cpap->clockDrift()) * 1000L;
qint64 drift = 0;
for (QList<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) {
if (!(*s)->enabled())
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); s++) {
if (!(*s)->enabled()) {
continue;
drift=((*s)->machine()->GetType()==MT_CPAP) ? clockdrift : 0;
}
cei=(*s)->eventlist.find(m_code);
if (cei==(*s)->eventlist.end())
drift = ((*s)->machine()->GetType() == MT_CPAP) ? clockdrift : 0;
cei = (*s)->eventlist.find(m_code);
if (cei == (*s)->eventlist.end()) {
continue;
}
QVector<EventList *> & evlist=cei.value();
for (int k=0;k<evlist.size();k++) {
EventList & el=*(evlist[k]);
start=el.first() + drift;
tptr=el.rawTime();
dptr=el.rawData();
int np=el.count();
eptr=dptr+np;
QVector<EventList *> &evlist = cei.value();
for (idx=0;dptr < eptr; dptr++, tptr++, idx++) {
X=start + *tptr;
L=*dptr * 1000;
if (X >= minx)
for (int k = 0; k < evlist.size(); k++) {
EventList &el = *(evlist[k]);
start = el.first() + drift;
tptr = el.rawTime();
dptr = el.rawData();
int np = el.count();
eptr = dptr + np;
for (idx = 0; dptr < eptr; dptr++, tptr++, idx++) {
X = start + *tptr;
L = *dptr * 1000;
if (X >= minx) {
break;
X2=X-L;
if (X2 >= minx)
}
X2 = X - L;
if (X2 >= minx) {
break;
}
}
np-=idx;
if (m_flt==FT_Bar) {
np -= idx;
if (m_flt == FT_Bar) {
///////////////////////////////////////////////////////////////////////////
// Draw Event Flag Bars
///////////////////////////////////////////////////////////////////////////
@ -232,64 +269,70 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height)
// Check bounds outside of loop is faster..
// This will have to be reverted if multithreaded drawing is ever brought back
int rem=lines->Max() - lines->cnt();
if ((np<<1) > rem) {
int rem = lines->Max() - lines->cnt();
if ((np << 1) > rem) {
qDebug() << "gFlagsLine would overfill lines for" << schema::channel[m_code].label();
np=rem >> 1;
verts_exceeded=true;
np = rem >> 1;
verts_exceeded = true;
}
for (int i=0;i<np;i++) {
X=start + *tptr++;
for (int i = 0; i < np; i++) {
X = start + *tptr++;
if (X > maxx)
if (X > maxx) {
break;
}
x1=(X - minx) * xmult + left;
lines->add(x1,bartop,x1,bottom);
x1 = (X - minx) * xmult + left;
lines->add(x1, bartop, x1, bottom);
//if (lines->full()) { verts_exceeded=true; break; }
}
} else if (m_flt==FT_Span) {
} else if (m_flt == FT_Span) {
///////////////////////////////////////////////////////////////////////////
// Draw Event Flag Spans
///////////////////////////////////////////////////////////////////////////
quads->setColor(m_flag_color);
int rem=quads->Max() - quads->cnt();
int rem = quads->Max() - quads->cnt();
if ((np<<2) > rem) {
if ((np << 2) > rem) {
qDebug() << "gFlagsLine would overfill quads for" << schema::channel[m_code].label();
np=rem >> 2;
verts_exceeded=true;
np = rem >> 2;
verts_exceeded = true;
}
for (; dptr < eptr; dptr++) {
X=start + * tptr++;
X = start + * tptr++;
if (X > maxx)
if (X > maxx) {
break;
}
L=*dptr * 1000L;
X2=X-L;
L = *dptr * 1000L;
X2 = X - L;
x1=double(X - minx) * xmult + left;
x2=double(X2 - minx) * xmult + left;
x1 = double(X - minx) * xmult + left;
x2 = double(X2 - minx) * xmult + left;
quads->add(x2,bartop,x1,bartop, x1,bottom,x2,bottom);
quads->add(x2, bartop, x1, bartop, x1, bottom, x2, bottom);
//if (quads->full()) { verts_exceeded=true; break; }
}
}
if (verts_exceeded) break;
if (verts_exceeded) { break; }
}
if (verts_exceeded) break;
if (verts_exceeded) { break; }
}
if (verts_exceeded) {
qWarning() << "maxverts exceeded in gFlagsLine::plot()";
}
}
bool gFlagsLine::mouseMoveEvent(QMouseEvent * event,gGraph * graph)
bool gFlagsLine::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
{
Q_UNUSED(event)
Q_UNUSED(graph)

View File

@ -20,20 +20,20 @@ class gFlagsGroup;
/*! \class gYSpacer
\brief A dummy vertical spacer object
*/
class gFlagsLabelArea:public gSpacer
class gFlagsLabelArea: public gSpacer
{
public:
gFlagsLabelArea(gFlagsGroup * group);
virtual void paint(gGraph & w,int left,int top, int width, int height) {
gFlagsLabelArea(gFlagsGroup *group);
virtual void paint(gGraph &w, int left, int top, int width, int height) {
Q_UNUSED(w)
Q_UNUSED(left)
Q_UNUSED(top)
Q_UNUSED(width)
Q_UNUSED(height)
}
protected:
gFlagsGroup * m_group;
virtual bool mouseMoveEvent(QMouseEvent * event,gGraph * graph);
protected:
gFlagsGroup *m_group;
virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph);
};
@ -42,7 +42,7 @@ protected:
/*! \class gFlagsLine
\brief One single line of event flags in the Event Flags chart
*/
class gFlagsLine:public Layer
class gFlagsLine: public Layer
{
friend class gFlagsGroup;
public:
@ -53,32 +53,33 @@ class gFlagsLine:public Layer
\param always_visible Whether to always show this line, even if empty
\param Type of Flag, either FT_Bar, or FT_Span
*/
gFlagsLine(ChannelID code,QColor col=Qt::black,QString label="",bool always_visible=false,FlagType flt=FT_Bar);
gFlagsLine(ChannelID code, QColor col = Qt::black, QString label = "", bool always_visible = false,
FlagType flt = FT_Bar);
virtual ~gFlagsLine();
//! \brief Drawing code to add the flags and span markers to the Vertex buffers.
virtual void paint(gGraph & w,int left, int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
//! \brief Returns true if should always show this flag, even if it's empty
bool isAlwaysVisible() { return m_always_visible; }
//! \brief Set this to true to make a flag line always visible
void setAlwaysVisible(bool b) { m_always_visible=b; }
void setAlwaysVisible(bool b) { m_always_visible = b; }
//! \brief Returns the label for this individual Event Flags line
QString label() { return m_label; }
//! \brief Sets the label for this individual Event Flags line
void setLabel(QString s) { m_label=s; }
void setLabel(QString s) { m_label = s; }
void setTotalLines(int i) { total_lines=i; }
void setLineNum(int i) { line_num=i; }
void setTotalLines(int i) { total_lines = i; }
void setLineNum(int i) { line_num = i; }
protected:
virtual bool mouseMoveEvent(QMouseEvent * event,gGraph * graph);
virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph);
QString m_label;
bool m_always_visible;
int total_lines,line_num;
int total_lines, line_num;
FlagType m_flt;
QColor m_flag_color;
gVertexBuffer *quads;
@ -89,16 +90,16 @@ class gFlagsLine:public Layer
/*! \class gFlagsGroup
\brief Contains multiple gFlagsLine entries for the Events Flag graph
*/
class gFlagsGroup:public LayerGroup
class gFlagsGroup: public LayerGroup
{
friend class gFlagsLabelArea;
public:
public:
gFlagsGroup();
virtual ~gFlagsGroup();
//! Draw filled rectangles behind Event Flag's, and an outlines around them all, Calls the individual paint for each gFlagLine
virtual void paint(gGraph & w,int left, int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
//! Returns the first time represented by all gFlagLine layers, in milliseconds since epoch
virtual qint64 Minx();
@ -118,10 +119,10 @@ public:
int barHeight() { return m_barh; }
//! Returns a list of Visible gFlagsLine layers to draw
QVector<gFlagsLine *> & visibleLayers() { return lvisible; }
QVector<gFlagsLine *> &visibleLayers() { return lvisible; }
protected:
virtual bool mouseMoveEvent(QMouseEvent * event,gGraph * graph);
protected:
virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph);
gVertexBuffer *quads, *lines;
QVector<gFlagsLine *> lvisible;

View File

@ -13,11 +13,11 @@
#include "gFooBar.h"
#include "gYAxis.h"
gShadowArea::gShadowArea(QColor shadow_color,QColor line_color)
:Layer(NoChannel),m_shadow_color(shadow_color),m_line_color(line_color)
gShadowArea::gShadowArea(QColor shadow_color, QColor line_color)
: Layer(NoChannel), m_shadow_color(shadow_color), m_line_color(line_color)
{
addVertexBuffer(quads=new gVertexBuffer(20,GL_QUADS));
addVertexBuffer(lines=new gVertexBuffer(20,GL_LINES));
addVertexBuffer(quads = new gVertexBuffer(20, GL_QUADS));
addVertexBuffer(lines = new gVertexBuffer(20, GL_LINES));
quads->forceAntiAlias(true);
lines->setAntiAlias(true);
lines->setSize(2);
@ -25,49 +25,55 @@ gShadowArea::gShadowArea(QColor shadow_color,QColor line_color)
gShadowArea::~gShadowArea()
{
}
void gShadowArea::paint(gGraph & w,int left, int top, int width, int height)
void gShadowArea::paint(gGraph &w, int left, int top, int width, int height)
{
if (!m_visible) return;
double xx=w.max_x-w.min_x;
if (!m_visible) { return; }
if (xx==0)
double xx = w.max_x - w.min_x;
if (xx == 0) {
return;
}
int start_px=left-1;
int end_px=left+width;
int start_px = left - 1;
int end_px = left + width;
//float h=top;
double rmx=w.rmax_x-w.rmin_x;
double px=((1.0/rmx)*(w.min_x-w.rmin_x))*width;
double py=((1.0/rmx)*(w.max_x-w.rmin_x))*width;
double rmx = w.rmax_x - w.rmin_x;
double px = ((1.0 / rmx) * (w.min_x - w.rmin_x)) * width;
double py = ((1.0 / rmx) * (w.max_x - w.rmin_x)) * width;
quads->add(start_px,top,start_px,top+height,start_px+px, top+height, start_px+px, top,m_shadow_color.rgba());
quads->add(start_px+py, top, start_px+py, top+height,end_px, top+height, end_px, top,m_shadow_color.rgba());
quads->add(start_px, top, start_px, top + height, start_px + px, top + height, start_px + px, top,
m_shadow_color.rgba());
quads->add(start_px + py, top, start_px + py, top + height, end_px, top + height, end_px, top,
m_shadow_color.rgba());
lines->add(start_px+px, top, start_px+py, top,m_line_color.rgba());
lines->add(start_px+px, top+height+1, start_px+py, top+height+1,m_line_color.rgba());
lines->add(start_px + px, top, start_px + py, top, m_line_color.rgba());
lines->add(start_px + px, top + height + 1, start_px + py, top + height + 1, m_line_color.rgba());
}
gFooBar::gFooBar(int offset,QColor handle_color,QColor line_color)
:Layer(NoChannel),m_offset(offset),m_handle_color(handle_color),m_line_color(line_color)
gFooBar::gFooBar(int offset, QColor handle_color, QColor line_color)
: Layer(NoChannel), m_offset(offset), m_handle_color(handle_color), m_line_color(line_color)
{
}
gFooBar::~gFooBar()
{
}
void gFooBar::paint(gGraph & w,int left, int top, int width, int height)
void gFooBar::paint(gGraph &w, int left, int top, int width, int height)
{
Q_UNUSED(top);
Q_UNUSED(left);
Q_UNUSED(width);
Q_UNUSED(height);
if (!m_visible) return;
double xx=w.max_x-w.min_x;
if (!m_visible) { return; }
if (xx==0)
double xx = w.max_x - w.min_x;
if (xx == 0) {
return;
}
//int start_px=left;
//int end_px=left+width;
@ -100,12 +106,12 @@ void gFooBar::paint(gGraph & w,int left, int top, int width, int height)
glColor4ub(255,255,255,128);
glVertex2f(start_px+py+extra,top-hh/2.0);
glVertex2f(start_px+px-extra,top-hh/2.0);
// glColor4ub(255,255,255,128);
// glColor4ub(255,255,255,128);
glColor4ub(255,255,255,128);
glVertex2f(start_px+px-extra,top-hh/2.0);
glVertex2f(start_px+py+extra,top-hh/2.0);
w.qglColor(m_handle_color);
// glColor4ub(192,192,192,128);
// glColor4ub(192,192,192,128);
glVertex2f(start_px+py+extra,h);
glVertex2f(start_px+px-extra,h);
glEnd();

View File

@ -17,12 +17,12 @@
/*! \class gShadowArea
\brief Displays a Shadow for all graph areas not highlighted (used in Event Flags)
*/
class gShadowArea:public Layer
class gShadowArea: public Layer
{
public:
gShadowArea(QColor shadow_color=QColor(40,40,40,40),QColor line_color=Qt::blue);
gShadowArea(QColor shadow_color = QColor(40, 40, 40, 40), QColor line_color = Qt::blue);
virtual ~gShadowArea();
virtual void paint(gGraph & w,int left, int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
protected:
QColor m_shadow_color;
QColor m_line_color;
@ -34,13 +34,14 @@ class gShadowArea:public Layer
\brief Was a kind of scrollbar thingy that used to be used for representing the overall graph areas.
Currently Unused and empty.
*/
class gFooBar:public Layer
class gFooBar: public Layer
{
public:
gFooBar(int offset=10,QColor handle_color=QColor("orange"),QColor line_color=QColor("dark grey"));
gFooBar(int offset = 10, QColor handle_color = QColor("orange"),
QColor line_color = QColor("dark grey"));
virtual ~gFooBar();
virtual void paint(gGraph & w,int left, int top, int width, int height);
static const int Margin=15;
virtual void paint(gGraph &w, int left, int top, int width, int height);
static const int Margin = 15;
protected:
int m_offset;
QColor m_handle_color;

View File

@ -55,7 +55,7 @@ int GetXHeight(QFont *font = defaultfont);
class gGraphView;
class gGraph;
const int textque_max=512;
const int textque_max = 512;
typedef quint32 RGBA;
/*union RGBA {
@ -71,9 +71,8 @@ typedef quint32 RGBA;
#ifdef BUILD_WITH_MSVC
__declspec(align(1))
#endif
struct gVertex
{
gVertex(GLshort _x, GLshort _y, GLuint _c) { x=_x; y=_y; color=_c; }
struct gVertex {
gVertex(GLshort _x, GLshort _y, GLuint _c) { x = _x; y = _y; color = _c; }
GLshort x;
GLshort y;
RGBA color;
@ -94,16 +93,16 @@ class gVertexBuffer
m_color(0),
m_stipple(0xffff),
m_blendfunc1(GL_SRC_ALPHA),
m_blendfunc2(GL_ONE_MINUS_SRC_ALPHA)
{
m_blendfunc2(GL_ONE_MINUS_SRC_ALPHA) {
// FIXME: Really should not allocate in constructor.
buffer = (gVertex *)calloc(max, sizeof(gVertex));
}
~gVertexBuffer() {
if (buffer)
if (buffer) {
free(buffer);
}
}
void add(GLshort x1, GLshort y1, RGBA color);
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, RGBA color);
@ -199,7 +198,7 @@ class GLBuffer
s2 = y1;
s3 = x2;
s4 = y2;
m_scissor=true;
m_scissor = true;
}
int Max() const { return m_max; }
@ -215,7 +214,7 @@ class GLBuffer
void setColor(QColor col) { m_color = col; }
void setBlendFunc(GLuint b1, GLuint b2) { m_blendfunc1 = b1; m_blendfunc2 = b2; }
virtual void draw(){}
virtual void draw() {}
protected:
int m_max;
@ -290,8 +289,7 @@ class GLFloatBuffer : public GLBuffer
/*! \struct TextQue
\brief Holds a single item of text for the drawing queue
*/
struct TextQue
{
struct TextQue {
//! \variable contains the x axis screen position to draw the text
short x;
//! \variable contains the y axis screen position to draw the text
@ -318,7 +316,7 @@ class MyScrollBar : public QScrollBar
: QScrollBar(parent)
{ }
void SendWheelEvent(QWheelEvent * e) {
void SendWheelEvent(QWheelEvent *e) {
wheelEvent(e);
}
};
@ -352,12 +350,12 @@ class Layer
virtual ~Layer();
//! \brief This gets called on day selection, allowing this layer to precalculate any drawing data
virtual void SetDay(Day * d);
virtual void SetDay(Day *d);
//! \brief Set the ChannelID used in this layer
virtual void SetCode(ChannelID c) { m_code = c; }
//! \brief Return the ChannelID used in this layer
const ChannelID & code() { return m_code; }
const ChannelID &code() { return m_code; }
//! \brief returns true if this layer contains no data.
virtual bool isEmpty();
@ -417,7 +415,7 @@ class Layer
\param int width
\param int height
*/
virtual void paint(gGraph & gv,int left,int top,int width, int height) = 0;
virtual void paint(gGraph &gv, int left, int top, int width, int height) = 0;
//! \brief Set the layout position and order for this layer.
void setLayout(LayerPosition position, short width, short height, short order);
@ -470,27 +468,39 @@ class Layer
//! \brief Mouse wheel moved somewhere over this layer
virtual bool wheelEvent(QWheelEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
Q_UNUSED(event);
Q_UNUSED(graph);
return false;
}
//! \brief Mouse moved somewhere over this layer
virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
Q_UNUSED(event);
Q_UNUSED(graph);
return false;
}
//! \brief Mouse left or right button pressed somewhere on this layer
virtual bool mousePressEvent(QMouseEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
Q_UNUSED(event);
Q_UNUSED(graph);
return false;
}
//! \brief Mouse button released that was originally pressed somewhere on this layer
virtual bool mouseReleaseEvent(QMouseEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
Q_UNUSED(event);
Q_UNUSED(graph);
return false;
}
//! \brief Mouse button double clicked somewhere on this layer
virtual bool mouseDoubleClickEvent(QMouseEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
Q_UNUSED(event);
Q_UNUSED(graph);
return false;
}
//! \brief A key was pressed on the keyboard while the graph area was focused.
virtual bool keyPressEvent(QKeyEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
Q_UNUSED(event);
Q_UNUSED(graph);
return false;
}
};
@ -533,27 +543,27 @@ class LayerGroup : public Layer
//! \brief Return the list of Layers this object holds
QVector<Layer *> &getLayers() { return layers; }
protected:
protected:
//! \brief Contains all Layer objects in this group
QVector<Layer *> layers;
//! \brief Mouse wheel moved somewhere over this LayerGroup
virtual bool wheelEvent(QWheelEvent * event, gGraph * graph);
virtual bool wheelEvent(QWheelEvent *event, gGraph *graph);
//! \brief Mouse moved somewhere over this LayerGroup
virtual bool mouseMoveEvent(QMouseEvent * event, gGraph * graph);
virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph);
//! \brief Mouse left or right button pressed somewhere on this LayerGroup
virtual bool mousePressEvent(QMouseEvent * event, gGraph * graph);
virtual bool mousePressEvent(QMouseEvent *event, gGraph *graph);
//! \brief Mouse button released that was originally pressed somewhere on this LayerGroup
virtual bool mouseReleaseEvent(QMouseEvent * event, gGraph * graph);
virtual bool mouseReleaseEvent(QMouseEvent *event, gGraph *graph);
//! \brief Mouse button double clicked somewhere on this layerGroup
virtual bool mouseDoubleClickEvent(QMouseEvent * event, gGraph * graph);
virtual bool mouseDoubleClickEvent(QMouseEvent *event, gGraph *graph);
//! \brief A key was pressed on the keyboard while the graph area was focused.
virtual bool keyPressEvent(QKeyEvent * event, gGraph * graph);
virtual bool keyPressEvent(QKeyEvent *event, gGraph *graph);
};
class gGraph;
@ -720,13 +730,13 @@ class gGraph : public QObject
QString title() { return m_title; }
//! \brief Sets the Graph's (vertical) title
void setTitle(const QString title) { m_title=title; }
void setTitle(const QString title) { m_title = title; }
//! \brief Returns the measurement Units the Y scale is referring to
QString units() { return m_units; }
//! \brief Sets the measurement Units the Y scale is referring to
void setUnits(const QString units) { m_units=units; }
void setUnits(const QString units) { m_units = units; }
//virtual void repaint(); // Repaint individual graph..
@ -821,7 +831,7 @@ class gGraph : public QObject
void setDay(Day *day);
//! \brief Returns the current day object
Day * day() { return m_day; }
Day *day() { return m_day; }
//! \brief The Layer, layout and title drawing code
virtual void paint(int originX, int originY, int width, int height);
@ -837,8 +847,10 @@ class gGraph : public QObject
//! \brief Sets the margins for the four sides of this graph.
void setMargins(short left, short right, short top, short bottom) {
m_marginleft = left; m_marginright = right;
m_margintop = top; m_marginbottom = bottom;
m_marginleft = left;
m_marginright = right;
m_margintop = top;
m_marginbottom = bottom;
}
//! \brief Returns this graphs left margin
@ -862,7 +874,7 @@ class gGraph : public QObject
const inline QRect &rect() const { return m_rect; }
bool isPinned() { return m_pinned; }
void setPinned(bool b) { m_pinned=b; }
void setPinned(bool b) { m_pinned = b; }
// //! \brief Returns the main gGraphView objects gVertexBuffer stippled line list.
//GLShortBuffer * stippled();
@ -921,7 +933,7 @@ class gGraph : public QObject
//! \brief Vector containing all this graphs Layers
QVector<Layer *> m_layers;
float m_height,m_width;
float m_height, m_width;
int m_min_height;
int m_max_height;
@ -950,8 +962,7 @@ class gGraph : public QObject
\brief My version of Pixmap cache with texture binding support
*/
struct myPixmapCache
{
struct myPixmapCache {
quint64 last_used;
QImage image;
GLuint textureID;
@ -1098,8 +1109,8 @@ class gGraphView : public QGLWidget
void setCubeImage(QImage *);
inline const float & devicePixelRatio() { return m_dpr; }
void setDevicePixelRatio(float dpr) { m_dpr=dpr; }
inline const float &devicePixelRatio() { return m_dpr; }
void setDevicePixelRatio(float dpr) { m_dpr = dpr; }
// Cube fun
QVector<QImage *> cubeimg;
@ -1108,15 +1119,15 @@ class gGraphView : public QGLWidget
#ifdef ENABLE_THREADED_DRAWING
QMutex text_mutex;
QMutex gl_mutex;
QSemaphore * masterlock;
bool useThreads() { return m_idealthreads>1; }
QSemaphore *masterlock;
bool useThreads() { return m_idealthreads > 1; }
QVector<gThread *> m_threads;
int m_idealthreads;
QMutex dl_mutex;
#endif
//! \brief Sends day object to be distributed to all Graphs Layers objects
void setDay(Day * day);
void setDay(Day *day);
gVertexBuffer *lines, *backlines, *quads, *frontlines;
@ -1144,7 +1155,7 @@ class gGraphView : public QGLWidget
//! \brief Return whether or not the Pixmap Cache for text rendering is being used.
bool usePixmapCache();
protected:
protected:
//! \brief Set up the OpenGL basics for the QGLWidget underneath
virtual void initializeGL();
@ -1202,7 +1213,7 @@ protected:
QVector<gGraph *> m_graphs;
//! \brief List of all graphs contained, indexed by title
QHash<QString,gGraph*> m_graphsbytitle;
QHash<QString, gGraph *> m_graphsbytitle;
//! \variable Vertical scroll offset (adjusted when scrollbar gets moved)
int m_offsetY;
@ -1221,7 +1232,7 @@ protected:
QPoint m_sizer_point;
int m_horiz_travel;
MyScrollBar * m_scrollbar;
MyScrollBar *m_scrollbar;
QTimer *redrawtimer;
bool m_graph_dragging;
@ -1231,13 +1242,13 @@ protected:
TextQue m_textque[textque_max];
int m_textque_items;
int m_lastxpos,m_lastypos;
int m_lastxpos, m_lastypos;
QString m_emptytext;
bool m_showsplitter;
qint64 m_minx,m_maxx;
float print_scaleX,print_scaleY;
qint64 m_minx, m_maxx;
float print_scaleX, print_scaleY;
QPixmap previous_day_snapshot;
QPixmap current_day_snapshot;
@ -1253,13 +1264,13 @@ protected:
QTime m_animationStarted;
// turn this into a struct later..
QHash<QString,myPixmapCache *> pixmap_cache;
QHash<QString, myPixmapCache *> pixmap_cache;
qint32 pixmap_cache_size;
bool use_pixmap_cache;
QTime horizScrollTime, vertScrollTime;
public slots:
public slots:
//! \brief Callback from the ScrollBar, to change scroll position
void scrollbarValueChanged(int val);

File diff suppressed because it is too large Load Diff

View File

@ -21,15 +21,15 @@
/*! \class AHIChart
\brief Another graph calculating the AHI/hour, this one looks at all the sessions for a day. Currently Unused.
*/
class AHIChart:public Layer
class AHIChart: public Layer
{
public:
public:
//! \brief Constructs an AHIChart object, with QColor col for the line plots.
AHIChart(QColor col=QColor("black"));
AHIChart(QColor col = QColor("black"));
~AHIChart();
//! \brief Draws the precalculated data to the Vertex buffers
virtual void paint(gGraph & w,int left, int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
//! \brief AHI/hr Calculations are done for this day here.
//! This also uses the sliding window method
@ -42,9 +42,9 @@ public:
virtual EventDataType Maxy() { return m_maxy; }
//! \brief Returns true if no data was available
virtual bool isEmpty() { return m_data.size()==0; }
virtual bool isEmpty() { return m_data.size() == 0; }
protected:
protected:
//! \brief Contains the plot data (Y-axis) generated for this day
QVector<EventDataType> m_data;
@ -54,13 +54,13 @@ protected:
EventDataType m_miny;
EventDataType m_maxy;
QColor m_color;
gVertexBuffer * lines;
gVertexBuffer *lines;
};
/*! \class gLineChart
\brief Draws a 2D linechart from all Session data in a day. EVL_Waveforms typed EventLists are accelerated.
*/
class gLineChart:public Layer
class gLineChart: public Layer
{
public:
/*! \brief Creates a new 2D gLineChart Layer
@ -69,27 +69,28 @@ class gLineChart:public Layer
\param square_plot Whether or not to use square plots (only effective for EVL_Event typed EventList data)
\param disable_accel Whether or not to disable acceleration for EVL_Waveform typed EventList data
*/
gLineChart(ChannelID code,const QColor col=QColor("black"), bool square_plot=false,bool disable_accel=false);
gLineChart(ChannelID code, const QColor col = QColor("black"), bool square_plot = false,
bool disable_accel = false);
virtual ~gLineChart();
//! \brief The drawing code that fills the vertex buffers
virtual void paint(gGraph & w,int left, int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
//! \brief Set Use Square plots for non EVL_Waveform data
void SetSquarePlot(bool b) { m_square_plot=b; }
void SetSquarePlot(bool b) { m_square_plot = b; }
//! \brief Returns true if using Square plots for non EVL_Waveform data
bool GetSquarePlot() { return m_square_plot; }
//! \brief Set this if you want this layer to draw it's empty data message
//! They don't show anymore due to the changes in gGraphView. Should modify isEmpty if this still gets to live
void ReportEmpty(bool b) { m_report_empty=b; }
void ReportEmpty(bool b) { m_report_empty = b; }
//! \brief Returns whether or not to show the empty text message
bool GetReportEmpty() { return m_report_empty; }
//! \brief Sets the ability to Disable waveform plot acceleration (which hides unseen data)
void setDisableAccel(bool b) { m_disable_accel=b; }
void setDisableAccel(bool b) { m_disable_accel = b; }
//! \brief Returns true if waveform plot acceleration is disabled
bool disableAccel() { return m_disable_accel; }
@ -107,26 +108,26 @@ class gLineChart:public Layer
virtual bool isEmpty();
//! \brief Add Subplot 'code'. Note the first one is added in the constructor.
void addPlot(ChannelID code, QColor color, bool square) { m_codes.push_back(code); m_colors.push_back(color); m_enabled[code]=true; m_square.push_back(square); }
void addPlot(ChannelID code, QColor color, bool square) { m_codes.push_back(code); m_colors.push_back(color); m_enabled[code] = true; m_square.push_back(square); }
//! \brief Returns true of the subplot 'code' is enabled.
bool plotEnabled(ChannelID code) { if ((m_enabled.contains(code)) && m_enabled[code]) return true; else return false; }
bool plotEnabled(ChannelID code) { if ((m_enabled.contains(code)) && m_enabled[code]) { return true; } else { return false; } }
//! \brief Enable or Disable the subplot identified by code.
void setPlotEnabled(ChannelID code, bool b) { m_enabled[code]=b; }
void setPlotEnabled(ChannelID code, bool b) { m_enabled[code] = b; }
protected:
protected:
bool m_report_empty;
bool m_square_plot;
bool m_disable_accel;
QColor m_line_color;
gVertexBuffer * lines;
gVertexBuffer *lines;
//GLShortBuffer * lines;
//GLShortBuffer * outlines;
//! \brief Used by accelerated waveform plots. Must be >= Screen Resolution (or at least graph width)
static const int max_drawlist_size=10000;
static const int max_drawlist_size = 10000;
//! \brief The list of screen points used for accelerated waveform plots..
QPoint m_drawlist[max_drawlist_size];
@ -136,7 +137,7 @@ protected:
QVector<ChannelID> m_codes;
QVector<QColor> m_colors;
QVector<bool> m_square;
QHash<ChannelID,bool> m_enabled;
QHash<ChannelID, bool> m_enabled;
};
#endif // GLINECHART_H

View File

@ -13,13 +13,13 @@
#include "SleepLib/profiles.h"
#include "gLineOverlay.h"
gLineOverlayBar::gLineOverlayBar(ChannelID code,QColor color,QString label,FlagType flt)
:Layer(code),m_flag_color(color),m_label(label),m_flt(flt)
gLineOverlayBar::gLineOverlayBar(ChannelID code, QColor color, QString label, FlagType flt)
: Layer(code), m_flag_color(color), m_label(label), m_flt(flt)
{
addVertexBuffer(points=new gVertexBuffer(2048,GL_POINTS));
addVertexBuffer(points = new gVertexBuffer(2048, GL_POINTS));
points->setSize(4);
points->setColor(m_flag_color);
addVertexBuffer(quads=new gVertexBuffer(2048,GL_QUADS));
addVertexBuffer(quads = new gVertexBuffer(2048, GL_QUADS));
//addGLBuf(lines=new GLBuffer(color,1024,GL_LINES));
points->setAntiAlias(true);
quads->setAntiAlias(true);
@ -33,186 +33,225 @@ gLineOverlayBar::~gLineOverlayBar()
//delete points;
}
void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int height)
void gLineOverlayBar::paint(gGraph &w, int left, int topp, int width, int height)
{
if (!m_visible) return;
if (!m_day) return;
if (!m_visible) { return; }
gVertexBuffer * lines=w.lines();
int start_py=topp;
if (!m_day) { return; }
double xx=w.max_x-w.min_x;
double yy=w.max_y-w.min_y;
if (xx<=0) return;
gVertexBuffer *lines = w.lines();
int start_py = topp;
float x1,x2;
double xx = w.max_x - w.min_x;
double yy = w.max_y - w.min_y;
int x,y;
if (xx <= 0) { return; }
float bottom=start_py+height-25*w.printScaleY(), top=start_py+25*w.printScaleY();
float x1, x2;
int x, y;
float bottom = start_py + height - 25 * w.printScaleY(), top = start_py + 25 * w.printScaleY();
double X;
double Y;
bool verts_exceeded=false;
bool verts_exceeded = false;
m_count=0;
m_sum=0;
m_flag_color=schema::channel[m_code].defaultColor();
m_count = 0;
m_sum = 0;
m_flag_color = schema::channel[m_code].defaultColor();
lines->setColor(m_flag_color);
points->setColor(m_flag_color);
if (m_flt==FT_Span) {
if (m_flt == FT_Span) {
m_flag_color.setAlpha(128);
}
EventStoreType raw;
quint32 * tptr;
EventStoreType * dptr, *eptr;
quint32 *tptr;
EventStoreType *dptr, *eptr;
qint64 stime;
OverlayDisplayType odt=PROFILE.appearance->overlayType();
QHash<ChannelID,QVector<EventList *> >::iterator cei;
OverlayDisplayType odt = PROFILE.appearance->overlayType();
QHash<ChannelID, QVector<EventList *> >::iterator cei;
int count;
qint64 clockdrift=qint64(PROFILE.cpap->clockDrift()) * 1000L;
qint64 drift=0;
qint64 clockdrift = qint64(PROFILE.cpap->clockDrift()) * 1000L;
qint64 drift = 0;
// For each session, process it's eventlist
for (QList<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) {
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); s++) {
if (!(*s)->enabled()) continue;
cei=(*s)->eventlist.find(m_code);
if (cei==(*s)->eventlist.end()) continue;
QVector<EventList *> & evlist=cei.value();
if (evlist.size()==0) continue;
drift=((*s)->machine()->GetType()==MT_CPAP) ? clockdrift : 0;
if (!(*s)->enabled()) { continue; }
cei = (*s)->eventlist.find(m_code);
if (cei == (*s)->eventlist.end()) { continue; }
QVector<EventList *> &evlist = cei.value();
if (evlist.size() == 0) { continue; }
drift = ((*s)->machine()->GetType() == MT_CPAP) ? clockdrift : 0;
// Could loop through here, but nowhere uses more than one yet..
for (int k=0;k<evlist.size();k++) {
EventList & el=*(evlist[k]);
count=el.count();
stime=el.first() + drift;
dptr=el.rawData();
eptr=dptr+count;
tptr=el.rawTime();
for (int k = 0; k < evlist.size(); k++) {
EventList &el = *(evlist[k]);
count = el.count();
stime = el.first() + drift;
dptr = el.rawData();
eptr = dptr + count;
tptr = el.rawTime();
////////////////////////////////////////////////////////////////////////////
// Skip data previous to minx bounds
////////////////////////////////////////////////////////////////////////////
for (; dptr < eptr; dptr++) {
X=stime + *tptr;
if (X >= w.min_x)
X = stime + *tptr;
if (X >= w.min_x) {
break;
}
tptr++;
}
if (m_flt==FT_Span) {
if (m_flt == FT_Span) {
////////////////////////////////////////////////////////////////////////////
// FT_Span
////////////////////////////////////////////////////////////////////////////
for (;dptr < eptr; dptr++) {
X=stime + *tptr++;
raw=*dptr;
Y=X-(qint64(raw)*1000.0L); // duration
if (Y > w.max_x)
for (; dptr < eptr; dptr++) {
X = stime + *tptr++;
raw = *dptr;
Y = X - (qint64(raw) * 1000.0L); // duration
if (Y > w.max_x) {
break;
x1=double(width)/double(xx)*double(X-w.min_x)+left;
}
x1 = double(width) / double(xx) * double(X - w.min_x) + left;
m_count++;
m_sum+=raw;
x2=double(width)/double(xx)*double(Y-w.min_x)+left;
m_sum += raw;
x2 = double(width) / double(xx) * double(Y - w.min_x) + left;
if (int(x1)==int(x2))
x2+=1;
if (x2<left)
x2=left;
if (x1>width+left)
x1=width+left;
if (int(x1) == int(x2)) {
x2 += 1;
}
if (x2 < left) {
x2 = left;
}
if (x1 > width + left) {
x1 = width + left;
}
quads->add(x2, start_py, x1, start_py, x1, start_py + height, x2, start_py + height,
m_flag_color.rgba());
quads->add(x2,start_py, x1,start_py, x1,start_py+height, x2,start_py+height,m_flag_color.rgba());
if (quads->full()) {
verts_exceeded=true;
verts_exceeded = true;
break;
}
}
} else if (m_flt==FT_Dot) {
} else if (m_flt == FT_Dot) {
////////////////////////////////////////////////////////////////////////////
// FT_Dot
////////////////////////////////////////////////////////////////////////////
for (; dptr < eptr; dptr++) {
X=stime + *tptr++; //el.time(i);
raw=*dptr; //el.data(i);
if (X > w.max_x)
X = stime + *tptr++; //el.time(i);
raw = *dptr; //el.data(i);
if (X > w.max_x) {
break;
x1=double(width)/double(xx)*double(X-w.min_x)+left;
}
x1 = double(width) / double(xx) * double(X - w.min_x) + left;
m_count++;
m_sum+=raw;
if ((odt==ODT_Bars) || (xx<3600000)) {
m_sum += raw;
if ((odt == ODT_Bars) || (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);
if (points->full()) {
verts_exceeded=true;
verts_exceeded = true;
break;
}
} else {
// thin lines down the bottom
lines->add(x1,start_py+1,x1,start_py+1+12);
lines->add(x1, start_py + 1, x1, start_py + 1 + 12);
if (lines->full()) {
verts_exceeded=true;
verts_exceeded = true;
break;
}
}
}
} else if (m_flt==FT_Bar) {
} else if (m_flt == FT_Bar) {
////////////////////////////////////////////////////////////////////////////
// FT_Bar
////////////////////////////////////////////////////////////////////////////
for (; dptr < eptr; dptr++) {
X=stime + *tptr++;
raw=*dptr;
if (X > w.max_x)
break;
x1=double(width)/double(xx)*double(X-w.min_x)+left;
m_count++;
m_sum+=raw;
int z=start_py+height;
if ((odt==ODT_Bars) || (xx<3600000)) {
z=top;
X = stime + *tptr++;
raw = *dptr;
if (X > w.max_x) {
break;
}
x1 = double(width) / double(xx) * double(X - w.min_x) + left;
m_count++;
m_sum += raw;
int z = start_py + height;
if ((odt == ODT_Bars) || (xx < 3600000)) {
z = top;
points->add(x1, top);
lines->add(x1, top, x1, bottom);
points->add(x1,top);
lines->add(x1,top,x1,bottom);
if (points->full()) {
verts_exceeded=true;
verts_exceeded = true;
break;
}
} else {
lines->add(x1,z,x1,z-12);
lines->add(x1, z, x1, z - 12);
}
if (lines->full()) {
verts_exceeded=true;
verts_exceeded = true;
break;
}
if (xx<(1800000)) {
GetTextExtent(m_label,x,y);
w.renderText(m_label,x1-(x/2),top-y+(3*w.printScaleY()));
if (xx < (1800000)) {
GetTextExtent(m_label, x, y);
w.renderText(m_label, x1 - (x / 2), top - y + (3 * w.printScaleY()));
}
}
}
if (verts_exceeded)
if (verts_exceeded) {
break;
}
if (verts_exceeded)
}
if (verts_exceeded) {
break;
}
}
if (verts_exceeded) {
qWarning() << "exceeded maxverts in gLineOverlay::Plot()";
}
}
gLineOverlaySummary::gLineOverlaySummary(QString text, int x, int y)
:Layer(CPAP_Obstructive),m_text(text),m_x(x),m_y(y) // The Layer code is a dummy here.
: Layer(CPAP_Obstructive), m_text(text), m_x(x), m_y(y) // The Layer code is a dummy here.
{
}
@ -220,67 +259,84 @@ gLineOverlaySummary::~gLineOverlaySummary()
{
}
void gLineOverlaySummary::paint(gGraph & w,int left, int top, int width, int height)
void gLineOverlaySummary::paint(gGraph &w, int left, int top, int width, int height)
{
if (!m_visible) return;
if (!m_day) return;
if (!m_visible) { return; }
if (!m_day) { return; }
Q_UNUSED(width);
Q_UNUSED(height);
float cnt=0;
double sum=0;
bool isSpan=false;
for (int i=0;i<m_overlays.size();i++) {
cnt+=m_overlays[i]->count();
sum+=m_overlays[i]->sum();
if (m_overlays[i]->flagtype()==FT_Span) isSpan=true;
float cnt = 0;
double sum = 0;
bool isSpan = false;
for (int i = 0; i < m_overlays.size(); i++) {
cnt += m_overlays[i]->count();
sum += m_overlays[i]->sum();
if (m_overlays[i]->flagtype() == FT_Span) { isSpan = true; }
}
double val,first,last;
double time=0;
double val, first, last;
double time = 0;
// Calculate the session time.
for (QList<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) {
if (!(*s)->enabled()) continue;
first=(*s)->first();
last=(*s)->last();
if (last < w.min_x) continue;
if (first > w.max_x) continue;
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); s++) {
if (!(*s)->enabled()) { continue; }
if (first < w.min_x)
first=w.min_x;
if (last > w.max_x)
last=w.max_x;
first = (*s)->first();
last = (*s)->last();
time+=last-first;
if (last < w.min_x) { continue; }
if (first > w.max_x) { continue; }
if (first < w.min_x) {
first = w.min_x;
}
val=0;
if (last > w.max_x) {
last = w.max_x;
}
time/=1000;
int h=time/3600;
int m=int(time/60) % 60;
int s=int(time) % 60;
time += last - first;
}
val = 0;
time /= 1000;
int h = time / 3600;
int m = int(time / 60) % 60;
int s = int(time) % 60;
time/=3600;
time /= 3600;
//if (time<1) time=1;
if (time>0) val=cnt/time;
if (time > 0) { val = cnt / time; }
QString a=QObject::tr("Events")+"="+QString::number(cnt)+" "+QObject::tr("Duration")+" "+QString().sprintf("%02i:%02i:%02i",h,m,s)+", "+m_text+"="+QString::number(val,'f',2);
QString a = QObject::tr("Events") + "=" + QString::number(cnt) + " " + QObject::tr("Duration") +
" " + QString().sprintf("%02i:%02i:%02i", h, m, s) + ", " + m_text + "=" + QString::number(val,
'f', 2);
if (isSpan) {
float sph;
if (!time) sph=0; else {
sph=(100.0/float(time))*(sum/3600.0);
if (sph>100) sph=100;
if (!time) { sph = 0; }
else {
sph = (100.0 / float(time)) * (sum / 3600.0);
if (sph > 100) { sph = 100; }
}
a+=" "+QObject::tr("(\%%1 in events)").arg(sph,0,'f',2); // eg: %num of time in a span, like Periodic Breathing
a += " " + QObject::tr("(\%%1 in events)").arg(sph, 0, 'f',
2); // eg: %num of time in a span, like Periodic Breathing
}
w.renderText(a,left+m_x,top+m_y);
w.renderText(a, left + m_x, top + m_y);
}

View File

@ -17,16 +17,16 @@
/*! \class gLineOverlayBar
\brief Shows a flag line, a dot, or a span over the top of a 2D line chart.
*/
class gLineOverlayBar:public Layer
class gLineOverlayBar: public Layer
{
public:
//! \brief Constructs a gLineOverlayBar object of type code, setting the flag/span color, the label to show when zoomed
//! in, and the display method requested, of either FT_Bar, FT_Span, or FT_Dot
gLineOverlayBar(ChannelID code,QColor col,QString _label="",FlagType _flt=FT_Bar);
gLineOverlayBar(ChannelID code, QColor col, QString _label = "", FlagType _flt = FT_Bar);
virtual ~gLineOverlayBar();
//! \brief The drawing code that fills the OpenGL vertex GLBuffers
virtual void paint(gGraph & w,int left, int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
virtual EventDataType Miny() { return 0; }
virtual EventDataType Maxy() { return 0; }
@ -52,13 +52,13 @@ class gLineOverlayBar:public Layer
/*! \class gLineOverlaySummary
\brief A container class to hold a group of gLineOverlayBar's, and shows the "Section AHI" over the Flow Rate waveform.
*/
class gLineOverlaySummary:public Layer
class gLineOverlaySummary: public Layer
{
public:
gLineOverlaySummary(QString text, int x, int y);
virtual ~gLineOverlaySummary();
virtual void paint(gGraph & w,int left, int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
virtual EventDataType Miny() { return 0; }
virtual EventDataType Maxy() { return 0; }
@ -70,8 +70,8 @@ class gLineOverlaySummary:public Layer
protected:
QVector<gLineOverlayBar *> m_overlays;
QString m_text;
int m_x,m_y;
};
int m_x, m_y;
};
#endif // GLINEOVERLAY_H

View File

@ -12,12 +12,13 @@
#include <cmath>
#include "gSegmentChart.h"
gSegmentChart::gSegmentChart(GraphSegmentType type,QColor gradient_color,QColor outline_color)
:Layer(NoChannel),m_graph_type(type),m_gradient_color(gradient_color),m_outline_color(outline_color)
gSegmentChart::gSegmentChart(GraphSegmentType type, QColor gradient_color, QColor outline_color)
: Layer(NoChannel), m_graph_type(type), m_gradient_color(gradient_color),
m_outline_color(outline_color)
{
m_empty=true;
addGLBuf(poly=new GLFloatBuffer(4000,GL_POLYGON));
addGLBuf(lines=new GLFloatBuffer(4000,GL_LINE_LOOP));
m_empty = true;
addGLBuf(poly = new GLFloatBuffer(4000, GL_POLYGON));
addGLBuf(lines = new GLFloatBuffer(4000, GL_LINE_LOOP));
lines->setSize(1);
poly->forceAntiAlias(false);
lines->forceAntiAlias(true);
@ -26,33 +27,38 @@ gSegmentChart::gSegmentChart(GraphSegmentType type,QColor gradient_color,QColor
gSegmentChart::~gSegmentChart()
{
}
void gSegmentChart::AddSlice(ChannelID code,QColor color,QString name)
void gSegmentChart::AddSlice(ChannelID code, QColor color, QString name)
{
m_codes.push_back(code);
m_values.push_back(0);
m_colors.push_back(color);
m_names.push_back(name);
m_total=0;
m_total = 0;
}
void gSegmentChart::SetDay(Day *d)
{
Layer::SetDay(d);
m_total=0;
if (!m_day) return;
for (int c=0;c<m_codes.size();c++) {
m_values[c]=0;
for (QList<Session *>::iterator s=m_day->begin();s!=m_day->end();++s) {
if (!(*s)->enabled()) continue;
m_total = 0;
int cnt=(*s)->count(m_codes[c]);
m_values[c]+=cnt;
m_total+=cnt;
if (!m_day) { return; }
for (int c = 0; c < m_codes.size(); c++) {
m_values[c] = 0;
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); ++s) {
if (!(*s)->enabled()) { continue; }
int cnt = (*s)->count(m_codes[c]);
m_values[c] += cnt;
m_total += cnt;
}
}
m_empty=true;
for (int i=0;i<m_codes.size();i++) {
if (m_day->count(m_codes[i])>0) {
m_empty=false;
m_empty = true;
for (int i = 0; i < m_codes.size(); i++) {
if (m_day->count(m_codes[i]) > 0) {
m_empty = false;
break;
}
}
@ -63,139 +69,153 @@ bool gSegmentChart::isEmpty()
return m_empty;
}
void gSegmentChart::paint(gGraph & w,int left, int top, int width, int height)
void gSegmentChart::paint(gGraph &w, int left, int top, int width, int height)
{
if (!m_visible) return;
if (!m_day) return;
int start_px=left;
int start_py=top;
if (!m_visible) { return; }
if (!m_day) { return; }
int start_px = left;
int start_py = top;
width--;
float diameter=MIN(width,height);
diameter-=8;
float radius=diameter/2.0;
float diameter = MIN(width, height);
diameter -= 8;
float radius = diameter / 2.0;
float j=0.0;
float sum=0.0;
float step=1.0/720.0;
float px,py;
float j = 0.0;
float sum = 0.0;
float step = 1.0 / 720.0;
float px, py;
float q;
float xmult=float(width)/float(m_total);
float ymult=float(height)/float(m_total);
float xmult = float(width) / float(m_total);
float ymult = float(height) / float(m_total);
float xp=left;
float xp = left;
int xoffset=width/2;
int yoffset=height/2;
if (m_total==0) {
QColor col=Qt::green;
QString a=":-)";
int x,y;
GetTextExtent(a,x,y,bigfont);
int xoffset = width / 2;
int yoffset = height / 2;
w.renderText(a,start_px+xoffset-x/2, (start_py+yoffset+y/2),0,col,bigfont);
if (m_total == 0) {
QColor col = Qt::green;
QString a = ":-)";
int x, y;
GetTextExtent(a, x, y, bigfont);
w.renderText(a, start_px + xoffset - x / 2, (start_py + yoffset + y / 2), 0, col, bigfont);
return;
}
int data;
unsigned size=m_values.size();
float line_step=float(width)/float(size-1);
bool line_first=true;
unsigned size = m_values.size();
float line_step = float(width) / float(size - 1);
bool line_first = true;
int line_last;
gVertexBuffer *quads=w.quads();
gVertexBuffer *lines2=w.lines();
for (unsigned m=0;m<size;m++) {
data=m_values[m];
gVertexBuffer *quads = w.quads();
gVertexBuffer *lines2 = w.lines();
if (data==0) continue;
/////////////////////////////////////////////////////////////////////////////////////
// Pie Chart
/////////////////////////////////////////////////////////////////////////////////////
if (m_graph_type==GST_Pie) {
QColor & col=schema::channel[m_codes[m % m_colors.size()]].defaultColor();
j=float(data)/float(m_total); // ratio of this pie slice
for (unsigned m = 0; m < size; m++) {
data = m_values[m];
if (data == 0) { continue; }
/////////////////////////////////////////////////////////////////////////////////////
// Pie Chart
/////////////////////////////////////////////////////////////////////////////////////
if (m_graph_type == GST_Pie) {
QColor &col = schema::channel[m_codes[m % m_colors.size()]].defaultColor();
j = float(data) / float(m_total); // ratio of this pie slice
// Draw Filling
poly->add(start_px+xoffset, start_py+height-yoffset,m_gradient_color);
for (q=sum;q<sum+j;q+=step) {
px=start_px+xoffset+sin(q*2*M_PI)*radius;
py=start_py+height-(yoffset+cos(q*2*M_PI)*radius);
poly->add(px,py,col);
}
q=sum+j;
px=start_px+xoffset+sin(q*2*M_PI)*radius;
py=start_py+height-(yoffset+cos(q*2*M_PI)*radius);
poly->add(px,py,col);
poly->add(start_px + xoffset, start_py + height - yoffset, m_gradient_color);
if (m_total!=data) {
for (q = sum; q < sum + j; q += step) {
px = start_px + xoffset + sin(q * 2 * M_PI) * radius;
py = start_py + height - (yoffset + cos(q * 2 * M_PI) * radius);
poly->add(px, py, col);
}
q = sum + j;
px = start_px + xoffset + sin(q * 2 * M_PI) * radius;
py = start_py + height - (yoffset + cos(q * 2 * M_PI) * radius);
poly->add(px, py, col);
if (m_total != data) {
// Draw the center point first
lines->add(start_px+xoffset, start_py+height-yoffset,m_outline_color);
}
for (q=sum;q<sum+j;q+=step) {
px=start_px+xoffset+sin(q*2*M_PI)*radius;
py=start_py+height-(yoffset+cos(q*2*M_PI)*radius);
lines->add(px,py,m_outline_color);
}
double tpx=start_px+xoffset+sin((sum+(j/2.0))*2*M_PI)*(radius/1.7);
double tpy=start_py+height-(yoffset+cos((sum+(j/2.0))*2*M_PI)*(radius/1.7));
q=sum+j;
px=start_px+xoffset+sin(q*2*M_PI)*radius;
py=start_py+height-(yoffset+cos(q*2*M_PI)*radius);
lines->add(px,py,m_outline_color);
if (j>.09) {
QString a=m_names[m]; //QString::number(floor(100.0/m_total*data),'f',0)+"%";
int x,y;
GetTextExtent(a,x,y);
w.renderText(a,tpx-(x/2.0),(tpy+y/2.0),0,Qt::black,defaultfont,false); // antialiasing looks like crap here..
lines->add(start_px + xoffset, start_py + height - yoffset, m_outline_color);
}
sum=q;
for (q = sum; q < sum + j; q += step) {
px = start_px + xoffset + sin(q * 2 * M_PI) * radius;
py = start_py + height - (yoffset + cos(q * 2 * M_PI) * radius);
lines->add(px, py, m_outline_color);
}
/////////////////////////////////////////////////////////////////////////////////////
// CandleStick Chart
/////////////////////////////////////////////////////////////////////////////////////
} else if (m_graph_type==GST_CandleStick) {
QColor & col=m_colors[m % m_colors.size()];
float bw=xmult*float(data);
double tpx = start_px + xoffset + sin((sum + (j / 2.0)) * 2 * M_PI) * (radius / 1.7);
double tpy = start_py + height - (yoffset + cos((sum + (j / 2.0)) * 2 * M_PI) * (radius / 1.7));
q = sum + j;
px = start_px + xoffset + sin(q * 2 * M_PI) * radius;
py = start_py + height - (yoffset + cos(q * 2 * M_PI) * radius);
lines->add(px, py, m_outline_color);
quads->add(xp,start_py,xp+bw,start_py,m_gradient_color.rgba());
quads->add(xp+bw,start_py+height,xp,start_py+height,col.rgba());
if (j > .09) {
QString a = m_names[m]; //QString::number(floor(100.0/m_total*data),'f',0)+"%";
int x, y;
GetTextExtent(a, x, y);
w.renderText(a, tpx - (x / 2.0), (tpy + y / 2.0), 0, Qt::black, defaultfont,
false); // antialiasing looks like crap here..
}
lines2->add(xp,start_py,xp+bw,start_py,m_outline_color.rgba());
lines2->add(xp+bw,start_py+height,xp,start_py+height,m_outline_color.rgba());
sum = q;
/////////////////////////////////////////////////////////////////////////////////////
// CandleStick Chart
/////////////////////////////////////////////////////////////////////////////////////
} else if (m_graph_type == GST_CandleStick) {
QColor &col = m_colors[m % m_colors.size()];
float bw = xmult * float(data);
quads->add(xp, start_py, xp + bw, start_py, m_gradient_color.rgba());
quads->add(xp + bw, start_py + height, xp, start_py + height, col.rgba());
lines2->add(xp, start_py, xp + bw, start_py, m_outline_color.rgba());
lines2->add(xp + bw, start_py + height, xp, start_py + height, m_outline_color.rgba());
if (!m_names[m].isEmpty()) {
int px,py;
GetTextExtent(m_names[m],px,py);
if (px+5<bw) {
w.renderText(m_names[m],(xp+bw/2)-(px/2),top+((height/2)-(py/2)),0,Qt::black);
int px, py;
GetTextExtent(m_names[m], px, py);
if (px + 5 < bw) {
w.renderText(m_names[m], (xp + bw / 2) - (px / 2), top + ((height / 2) - (py / 2)), 0, Qt::black);
}
}
xp+=bw;
/////////////////////////////////////////////////////////////////////////////////////
// Line Chart
/////////////////////////////////////////////////////////////////////////////////////
} else if (m_graph_type==GST_Line) {
QColor col=Qt::black; //m_colors[m % m_colors.size()];
float h=(top+height)-(float(data)*ymult);
xp += bw;
/////////////////////////////////////////////////////////////////////////////////////
// Line Chart
/////////////////////////////////////////////////////////////////////////////////////
} else if (m_graph_type == GST_Line) {
QColor col = Qt::black; //m_colors[m % m_colors.size()];
float h = (top + height) - (float(data) * ymult);
if (line_first) {
line_first=false;
line_first = false;
} else {
lines->add(xp,line_last,xp+line_step,h,col);
xp+=line_step;
lines->add(xp, line_last, xp + line_step, h, col);
xp += line_step;
}
line_last=h;
line_last = h;
}
}
}
gTAPGraph::gTAPGraph(ChannelID code,GraphSegmentType gt, QColor gradient_color,QColor outline_color)
:gSegmentChart(gt,gradient_color,outline_color),m_code(code)
gTAPGraph::gTAPGraph(ChannelID code, GraphSegmentType gt, QColor gradient_color,
QColor outline_color)
: gSegmentChart(gt, gradient_color, outline_color), m_code(code)
{
m_colors.push_back(Qt::red);
m_colors.push_back(Qt::green);
@ -206,68 +226,81 @@ gTAPGraph::~gTAPGraph()
void gTAPGraph::SetDay(Day *d)
{
Layer::SetDay(d);
m_total=0;
if (!m_day) return;
QMap<EventStoreType,qint64> tap;
m_total = 0;
EventStoreType data=0,lastval=0;
qint64 time=0,lasttime=0;
if (!m_day) { return; }
QMap<EventStoreType, qint64> tap;
EventStoreType data = 0, lastval = 0;
qint64 time = 0, lasttime = 0;
//bool first;
bool rfirst=true;
bool rfirst = true;
//bool changed;
EventDataType gain=1,offset=0;
QHash<ChannelID,QVector<EventList *> >::iterator ei;
for (QList<Session *>::iterator s=m_day->begin();s!=m_day->end();++s) {
if (!(*s)->enabled()) continue;
EventDataType gain = 1, offset = 0;
QHash<ChannelID, QVector<EventList *> >::iterator ei;
for (QList<Session *>::iterator s = m_day->begin(); s != m_day->end(); ++s) {
if (!(*s)->enabled()) { continue; }
if ((ei = (*s)->eventlist.find(m_code)) == (*s)->eventlist.end()) { continue; }
for (int q = 0; q < ei.value().size(); q++) {
EventList &el = *(ei.value()[q]);
lasttime = el.time(0);
lastval = el.raw(0);
if ((ei=(*s)->eventlist.find(m_code))==(*s)->eventlist.end()) continue;
for (int q=0;q<ei.value().size();q++) {
EventList &el=*(ei.value()[q]);
lasttime=el.time(0);
lastval=el.raw(0);
if (rfirst) {
gain=el.gain();
offset=el.offset();
rfirst=false;
gain = el.gain();
offset = el.offset();
rfirst = false;
}
//first=true;
//changed=false;
for (quint32 i=1;i<el.count();i++) {
data=el.raw(i);
time=el.time(i);
if (lastval!=data) {
qint64 v=(time-lasttime);
if (tap.find(lastval)!=tap.end()) {
tap[lastval]+=v;
for (quint32 i = 1; i < el.count(); i++) {
data = el.raw(i);
time = el.time(i);
if (lastval != data) {
qint64 v = (time - lasttime);
if (tap.find(lastval) != tap.end()) {
tap[lastval] += v;
} else {
tap[lastval]=v;
tap[lastval] = v;
}
//changed=true;
lasttime=time;
lastval=data;
lasttime = time;
lastval = data;
}
}
if (time!=lasttime) {
qint64 v=(time-lasttime);
if (tap.find(lastval)!=tap.end()) {
tap[data]+=v;
if (time != lasttime) {
qint64 v = (time - lasttime);
if (tap.find(lastval) != tap.end()) {
tap[data] += v;
} else {
tap[data]=v;
tap[data] = v;
}
}
}
}
m_values.clear();
m_names.clear();
m_total=0;
m_total = 0;
EventDataType val;
for (QMap<EventStoreType,qint64>::iterator i=tap.begin();i!=tap.end();i++) {
val=float(i.key())*gain+offset;
for (QMap<EventStoreType, qint64>::iterator i = tap.begin(); i != tap.end(); i++) {
val = float(i.key()) * gain + offset;
m_values.push_back(i.value()/1000L);
m_total+=i.value()/1000L;
m_names.push_back(QString::number(val,'f',2));
m_values.push_back(i.value() / 1000L);
m_total += i.value() / 1000L;
m_names.push_back(QString::number(val, 'f', 2));
}
m_empty=m_values.size()==0;
m_empty = m_values.size() == 0;
}

View File

@ -21,12 +21,13 @@ enum GraphSegmentType { GST_Pie, GST_CandleStick, GST_Line };
*/
class gSegmentChart : public Layer
{
public:
gSegmentChart(GraphSegmentType gt=GST_Pie, QColor gradient_color=Qt::white,QColor outline_color=Qt::black);
public:
gSegmentChart(GraphSegmentType gt = GST_Pie, QColor gradient_color = Qt::white,
QColor outline_color = Qt::black);
virtual ~gSegmentChart();
//! \brief The drawing code that fills the Vertex buffers
virtual void paint(gGraph & w,int left, int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
//! \brief Pre-fills a buffer with the data needed to draw
virtual void SetDay(Day *d);
@ -35,17 +36,17 @@ public:
virtual bool isEmpty();
//! \brief Adds a channel slice, and sets the color and label
void AddSlice(ChannelID code,QColor col,QString name="");
void AddSlice(ChannelID code, QColor col, QString name = "");
//! \brief Sets the fade-out color to make the graphs look more attractive
void setGradientColor(QColor & color) { m_gradient_color=color; }
void setGradientColor(QColor &color) { m_gradient_color = color; }
//! \brief Sets the outline color for the edges drawn around the Pie slices
void setOutlineColor(QColor & color) { m_outline_color=color; }
const GraphSegmentType & graphType() { return m_graph_type; }
void setGraphType(GraphSegmentType type) { m_graph_type=type; }
void setOutlineColor(QColor &color) { m_outline_color = color; }
const GraphSegmentType &graphType() { return m_graph_type; }
void setGraphType(GraphSegmentType type) { m_graph_type = type; }
protected:
protected:
QVector<ChannelID> m_codes;
QVector<QString> m_names;
QVector<int> m_values;
@ -58,20 +59,21 @@ protected:
bool m_empty;
// gah.. can't convert these
GLFloatBuffer *poly,*lines;
GLFloatBuffer *poly, *lines;
};
/*! \class gTAPGraph
\brief Time at Pressure chart, derived from gSegmentChart
\notes Currently unused
*/
class gTAPGraph:public gSegmentChart
class gTAPGraph: public gSegmentChart
{
public:
gTAPGraph(ChannelID code,GraphSegmentType gt=GST_CandleStick, QColor gradient_color=Qt::lightGray,QColor outline_color=Qt::black);
public:
gTAPGraph(ChannelID code, GraphSegmentType gt = GST_CandleStick,
QColor gradient_color = Qt::lightGray, QColor outline_color = Qt::black);
virtual ~gTAPGraph();
virtual void SetDay(Day *d);
protected:
protected:
ChannelID m_code;
};

View File

@ -13,36 +13,37 @@
#include "gYAxis.h"
#include "gStatsLine.h"
gStatsLine::gStatsLine(ChannelID code,QString label,QColor textcolor)
:Layer(code),m_label(label),m_textcolor(textcolor)
gStatsLine::gStatsLine(ChannelID code, QString label, QColor textcolor)
: Layer(code), m_label(label), m_textcolor(textcolor)
{
}
void gStatsLine::paint(gGraph & w, int left, int top, int width, int height)
void gStatsLine::paint(gGraph &w, int left, int top, int width, int height)
{
if (!m_visible) return;
if (!m_visible) { return; }
//if (m_empty) return;
Q_UNUSED(height);
int z=(width+gYAxis::Margin)/5;
int p=left-gYAxis::Margin;
int z = (width + gYAxis::Margin) / 5;
int p = left - gYAxis::Margin;
top+=4;
w.renderText(m_label,p,top);
top += 4;
w.renderText(m_label, p, top);
//w.renderText(m_text,p,top,0,m_textcolor);
p+=z;
w.renderText(st_min,p,top);
p += z;
w.renderText(st_min, p, top);
p+=z;
w.renderText(st_avg,p,top);
p += z;
w.renderText(st_avg, p, top);
p+=z;
w.renderText(st_p90,p,top);
p += z;
w.renderText(st_p90, p, top);
p+=z;
w.renderText(st_max,p,top);
p += z;
w.renderText(st_max, p, top);
}
@ -50,15 +51,17 @@ void gStatsLine::paint(gGraph & w, int left, int top, int width, int height)
void gStatsLine::SetDay(Day *d)
{
Layer::SetDay(d);
if (!m_day) return;
m_min=d->Min(m_code);
m_max=d->Max(m_code);
m_avg=d->wavg(m_code);
m_p90=d->p90(m_code);
st_min="Min="+QString::number(m_min,'f',2);
st_max="Max="+QString::number(m_max,'f',2);
st_avg="Avg="+QString::number(m_avg,'f',2);
st_p90="90%="+QString::number(m_p90,'f',2);
if (!m_day) { return; }
m_min = d->Min(m_code);
m_max = d->Max(m_code);
m_avg = d->wavg(m_code);
m_p90 = d->p90(m_code);
st_min = "Min=" + QString::number(m_min, 'f', 2);
st_max = "Max=" + QString::number(m_max, 'f', 2);
st_avg = "Avg=" + QString::number(m_avg, 'f', 2);
st_p90 = "90%=" + QString::number(m_p90, 'f', 2);
}

View File

@ -20,17 +20,17 @@
*/
class gStatsLine : public Layer
{
public:
gStatsLine(ChannelID code,QString label="",QColor textcolor=Qt::black);
virtual void paint(gGraph & w, int left, int top, int width, int height);
public:
gStatsLine(ChannelID code, QString label = "", QColor textcolor = Qt::black);
virtual void paint(gGraph &w, int left, int top, int width, int height);
void SetDay(Day *d);
protected:
protected:
QString m_label;
QColor m_textcolor;
EventDataType m_min,m_max,m_avg,m_p90;
QString st_min,st_max,st_avg,st_p90;
float m_tx,m_ty;
EventDataType m_min, m_max, m_avg, m_p90;
QString st_min, st_max, st_avg, st_p90;
float m_tx, m_ty;
};
#endif // GSTATSLINE_H

File diff suppressed because it is too large Load Diff

View File

@ -26,25 +26,24 @@ enum GraphType { GT_BAR, GT_LINE, GT_POINTS, GT_SESSIONS };
/*! \class SummaryChart
\brief The main overall chart type layer used in Overview page
*/
class SummaryChart:public Layer
class SummaryChart: public Layer
{
public:
//! \brief Constructs a SummaryChart with QString label, of GraphType type
SummaryChart(QString label, GraphType type=GT_BAR);
SummaryChart(QString label, GraphType type = GT_BAR);
virtual ~SummaryChart();
//! \brief Drawing code that fills the Vertex buffers
virtual void paint(gGraph & w,int left, int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
//! \brief Precalculation code prior to drawing. Day object is not needed here, it's just here for Layer compatability.
virtual void SetDay(Day * day=NULL);
virtual void SetDay(Day *day = NULL);
//! \brief Returns true if no data was found for this day during SetDay
virtual bool isEmpty() { return m_empty; }
//! \brief Adds a layer to the summaryChart (When in Bar mode, it becomes culminative, eg, the AHI chart)
void addSlice(ChannelID code, QColor color, SummaryType type, EventDataType tval=0.00f)
{
void addSlice(ChannelID code, QColor color, SummaryType type, EventDataType tval = 0.00f) {
m_codes.push_back(code);
m_colors.push_back(color);
m_type.push_back(type);
@ -54,15 +53,15 @@ class SummaryChart:public Layer
//! \brief Deselect highlighting (the gold bar)
virtual void deselect() {
hl_day=-1;
hl_day = -1;
}
//! \brief Returns true if currently selected..
virtual bool isSelected() { return hl_day>=0; }
virtual bool isSelected() { return hl_day >= 0; }
//! \brief Sets the MachineType this SummaryChart is interested in
void setMachineType(MachineType type) { m_machinetype=type; }
void setMachineType(MachineType type) { m_machinetype = type; }
//! \brief Returns the MachineType this SummaryChart is interested in
MachineType machineType() { return m_machinetype; }
@ -75,10 +74,10 @@ class SummaryChart:public Layer
//QVector<bool> m_zeros;
QVector<SummaryType> m_type;
QVector<EventDataType> m_typeval;
QHash<int,QHash<short,EventDataType> > m_values;
QHash<int,QHash<short,EventDataType> > m_times;
QHash<int,EventDataType> m_hours;
QHash<int,Day *> m_days;
QHash<int, QHash<short, EventDataType> > m_values;
QHash<int, QHash<short, EventDataType> > m_times;
QHash<int, EventDataType> m_hours;
QHash<int, Day *> m_days;
gVertexBuffer *quads;
gVertexBuffer *lines;
@ -91,27 +90,27 @@ class SummaryChart:public Layer
float barw; // bar width from last draw
qint64 l_offset; // last offset
float offset; // in pixels;
int l_left,l_top,l_width,l_height;
int l_left, l_top, l_width, l_height;
int rtop;
qint64 l_minx,l_maxx;
qint64 l_minx, l_maxx;
int hl_day;
gGraph * graph;
gGraph *graph;
GraphType m_graphtype;
MachineType m_machinetype;
int tz_offset;
float tz_hours;
//! \brief Key was pressed that effects this layer
virtual bool keyPressEvent(QKeyEvent * event,gGraph * graph);
virtual bool keyPressEvent(QKeyEvent *event, gGraph *graph);
//! \brief Mouse moved over this layers area (shows the hover-over tooltips here)
virtual bool mouseMoveEvent(QMouseEvent * event,gGraph * graph);
virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph);
//! \brief Mouse Button was pressed over this area
virtual bool mousePressEvent(QMouseEvent * event,gGraph * graph);
virtual bool mousePressEvent(QMouseEvent *event, gGraph *graph);
//! \brief Mouse Button was released over this area. (jumps to daily view here)
virtual bool mouseReleaseEvent(QMouseEvent * event,gGraph * graph);
virtual bool mouseReleaseEvent(QMouseEvent *event, gGraph *graph);
};

View File

@ -14,48 +14,48 @@
#include "gXAxis.h"
const quint64 divisors[]={
const quint64 divisors[] = {
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
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
};
const int divcnt=sizeof(divisors)/sizeof(quint64);
const int divcnt = sizeof(divisors) / sizeof(quint64);
gXAxis::gXAxis(QColor col,bool fadeout)
:Layer(NoChannel)
gXAxis::gXAxis(QColor col, bool fadeout)
: Layer(NoChannel)
{
m_line_color=col;
m_text_color=col;
m_major_color=Qt::darkGray;
m_minor_color=Qt::lightGray;
m_show_major_lines=false;
m_show_minor_lines=false;
m_show_minor_ticks=true;
m_show_major_ticks=true;
m_utcfix=false;
m_fadeout=fadeout;
m_textureID=0;
// QDateTime d=QDateTime::currentDateTime();
// QTime t1=d.time();
// QTime t2=d.toUTC().time();
m_line_color = col;
m_text_color = col;
m_major_color = Qt::darkGray;
m_minor_color = Qt::lightGray;
m_show_major_lines = false;
m_show_minor_lines = false;
m_show_minor_ticks = true;
m_show_major_ticks = true;
m_utcfix = false;
m_fadeout = fadeout;
m_textureID = 0;
// QDateTime d=QDateTime::currentDateTime();
// QTime t1=d.time();
// QTime t2=d.toUTC().time();
// tz_offset=t2.secsTo(t1);
// tz_hours=tz_offset/3600.0;
// tz_offset*=1000L;
// tz_offset=t2.secsTo(t1);
// tz_hours=tz_offset/3600.0;
// tz_offset*=1000L;
tz_offset=timezoneOffset();
tz_hours=tz_offset/3600000.0;
tz_offset = timezoneOffset();
tz_hours = tz_offset / 3600000.0;
}
gXAxis::~gXAxis()
{
}
void gXAxis::paint(gGraph & w,int left,int top, int width, int height)
void gXAxis::paint(gGraph &w, int left, int top, int width, int height)
{
Q_UNUSED(height)
QString months[]={
QString months[] = {
QObject::tr("Jan"), QObject::tr("Feb"), QObject::tr("Mar"), QObject::tr("Apr"), QObject::tr("May"), QObject::tr("Jun"),
QObject::tr("Jul"), QObject::tr("Aug"), QObject::tr("Sep"), QObject::tr("Oct"), QObject::tr("Nov"),QObject::tr("Dec")
QObject::tr("Jul"), QObject::tr("Aug"), QObject::tr("Sep"), QObject::tr("Oct"), QObject::tr("Nov"), QObject::tr("Dec")
};
//static QString dow[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
@ -65,110 +65,124 @@ void gXAxis::paint(gGraph & w,int left,int top, int width, int height)
// pixmap caching screws font size when printing
bool usepixmap=w.graphView()->usePixmapCache(); // Whether or not to use pixmap caching
bool usepixmap = w.graphView()->usePixmapCache(); // Whether or not to use pixmap caching
if (!usepixmap || (usepixmap && w.invalidate_xAxisImage)) {
if (usepixmap) {
// Unbind any previous texture
if (m_textureID) w.graphView()->deleteTexture(m_textureID);
if (m_textureID) { w.graphView()->deleteTexture(m_textureID); }
m_image=QImage(width+22,height+4,QImage::Format_ARGB32_Premultiplied);
m_image = QImage(width + 22, height + 4, QImage::Format_ARGB32_Premultiplied);
m_image.fill(Qt::transparent);
painter.begin(&m_image);
painter.setPen(Qt::black);
painter.setFont(*defaultfont);
}
double px,py;
int start_px=left;
double px, py;
int start_px = left;
//int start_py=top;
//int width=scrx-(w.GetLeftMargin()+w.GetRightMargin());
// float height=scry-(w.GetTopMargin()+w.GetBottomMargin());
if (width<40)
if (width < 40) {
return;
}
qint64 minx;
qint64 maxx;
if (w.blockZoom()) {
minx=w.rmin_x;
maxx=w.rmax_x;
minx = w.rmin_x;
maxx = w.rmax_x;
} else {
minx=w.min_x;
maxx=w.max_x;
minx = w.min_x;
maxx = w.max_x;
}
qint64 xx=maxx-minx;
if (xx<=0) return;
qint64 xx = maxx - minx;
if (xx <= 0) { return; }
//Most of this could be precalculated when min/max is set..
QString fd,tmpstr;
int divmax,dividx;
QString fd, tmpstr;
int divmax, dividx;
int fitmode;
if (xx>=86400000L) { // Day
fd="Mjj 00";
dividx=0;
divmax=10;
fitmode=0;
} else if (xx>600000) { // Minutes
fd=" j0:00";
dividx=10;
divmax=27;
fitmode=1;
} else if (xx>5000) { // Seconds
fd=" j0:00:00";
dividx=16;
divmax=27;
fitmode=2;
if (xx >= 86400000L) { // Day
fd = "Mjj 00";
dividx = 0;
divmax = 10;
fitmode = 0;
} else if (xx > 600000) { // Minutes
fd = " j0:00";
dividx = 10;
divmax = 27;
fitmode = 1;
} else if (xx > 5000) { // Seconds
fd = " j0:00:00";
dividx = 16;
divmax = 27;
fitmode = 2;
} else { // Microseconds
fd="j0:00:00:000";
dividx=28;
divmax=divcnt;
fitmode=3;
fd = "j0:00:00:000";
dividx = 28;
divmax = divcnt;
fitmode = 3;
}
//if (divmax>divcnt) divmax=divcnt;
int x,y;
GetTextExtent(fd,x,y);
int x, y;
GetTextExtent(fd, x, y);
if (x<=0) {
if (x <= 0) {
qWarning() << "gXAxis::Plot() x<=0 font size bug";
return;
}
int max_ticks=width/(x+15); // Max number of ticks that will fit
int max_ticks = width / (x + 15); // Max number of ticks that will fit
int fit_ticks=0;
int div=-1;
qint64 closest=0,tmp,tmpft;
for (int i=dividx;i<divmax;i++){
tmpft=xx/divisors[i];
tmp=max_ticks-tmpft;
if (tmp<0) continue;
if (tmpft>closest) { // Find the closest scale to the number
closest=tmpft; // that will fit
div=i;
fit_ticks=tmpft;
int fit_ticks = 0;
int div = -1;
qint64 closest = 0, tmp, tmpft;
for (int i = dividx; i < divmax; i++) {
tmpft = xx / divisors[i];
tmp = max_ticks - tmpft;
if (tmp < 0) { continue; }
if (tmpft > closest) { // Find the closest scale to the number
closest = tmpft; // that will fit
div = i;
fit_ticks = tmpft;
}
}
if (fit_ticks==0) {
if (fit_ticks == 0) {
qDebug() << "gXAxis::Plot() Couldn't fit ticks.. Too short?" << minx << maxx << xx;
return;
}
if ((div<0) || (div>divcnt)) {
if ((div < 0) || (div > divcnt)) {
qDebug() << "gXAxis::Plot() div out of bounds";
return;
}
qint64 step=divisors[div];
qint64 step = divisors[div];
//Align left minimum to divisor by losing precision
qint64 aligned_start=minx/step;
aligned_start*=step;
qint64 aligned_start = minx / step;
aligned_start *= step;
while (aligned_start<minx) {
aligned_start+=step;
while (aligned_start < minx) {
aligned_start += step;
}
gVertexBuffer *lines=w.backlines();
gVertexBuffer *lines = w.backlines();
lines->setColor(Qt::black);
@ -177,85 +191,104 @@ void gXAxis::paint(gGraph & w,int left,int top, int width, int height)
//utcoff=0;
int num_minor_ticks;
if (step>=86400000) {
qint64 i=step/86400000L; // number of days
if (i>14) i/=2;
if (i<0) i=1;
num_minor_ticks=i;
} else num_minor_ticks=10;
if (step >= 86400000) {
qint64 i = step / 86400000L; // number of days
float xmult=double(width)/double(xx);
float step_pixels=double(step/float(num_minor_ticks))*xmult;
if (i > 14) { i /= 2; }
py=left+float(aligned_start-minx)*xmult;
if (i < 0) { i = 1; }
num_minor_ticks = i;
} else { num_minor_ticks = 10; }
float xmult = double(width) / double(xx);
float step_pixels = double(step / float(num_minor_ticks)) * xmult;
py = left + float(aligned_start - minx) * xmult;
//py+=usepixmap ? 20 : left;
int mintop=top+4.0*(float(y)/10.0);
int majtop=top+6.0*(float(y)/10.0);
int texttop=majtop+y; // 18*w.printScaleY();
int mintop = top + 4.0 * (float(y) / 10.0);
int majtop = top + 6.0 * (float(y) / 10.0);
int texttop = majtop + y; // 18*w.printScaleY();
// Fill in the minor tick marks up to the first major alignment tick
for (int i=0;i<num_minor_ticks;i++) {
py-=step_pixels;
if (py<start_px) continue;
if (usepixmap)
painter.drawLine(py-left+20,0,py-left+20,mintop-top);
else
lines->add(py,top,py,mintop);
for (int i = 0; i < num_minor_ticks; i++) {
py -= step_pixels;
if (py < start_px) { continue; }
if (usepixmap) {
painter.drawLine(py - left + 20, 0, py - left + 20, mintop - top);
} else {
lines->add(py, top, py, mintop);
}
}
int ms,m,h,s,d;
int ms, m, h, s, d;
qint64 j;
for (qint64 i=aligned_start;i<maxx;i+=step) {
px=(i-minx)*xmult;
px+=left;
for (qint64 i = aligned_start; i < maxx; i += step) {
px = (i - minx) * xmult;
px += left;
if (usepixmap) {
painter.drawLine(px-left+20,0,px-left+20,majtop-top);
} else lines->add(px,top,px,majtop);
j=i;
if (!m_utcfix) j+=tz_offset;
ms=j % 1000;
m=(j/60000L) % 60L;
h=(j/3600000L) % 24L;
s=(j/1000L) % 60L;
painter.drawLine(px - left + 20, 0, px - left + 20, majtop - top);
} else { lines->add(px, top, px, majtop); }
j = i;
if (!m_utcfix) { j += tz_offset; }
ms = j % 1000;
m = (j / 60000L) % 60L;
h = (j / 3600000L) % 24L;
s = (j / 1000L) % 60L;
//int d=(j/86400000) % 7;
if (fitmode==0) {
d=(j/1000);
QDateTime dt=QDateTime::fromTime_t(d).toUTC();
QDate date=dt.date();
if (fitmode == 0) {
d = (j / 1000);
QDateTime dt = QDateTime::fromTime_t(d).toUTC();
QDate date = dt.date();
// SLOW SLOW SLOW!!! On Mac especially, this function is pathetically slow.
//dt.toString("MMM dd");
// Doing it this way instead because it's MUUUUUUCH faster
tmpstr=QString("%1 %2").arg(months[date.month()-1]).arg(date.day());
tmpstr = QString("%1 %2").arg(months[date.month() - 1]).arg(date.day());
//} else if (fitmode==0) {
// tmpstr=QString("%1 %2:%3").arg(dow[d]).arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0'));
} else if (fitmode==1) { // minute
tmpstr=QString("%1:%2").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0'));
} else if (fitmode==2) { // second
tmpstr=QString("%1:%2:%3").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0')).arg(s,2,10,QChar('0'));
} else if (fitmode==3) { // milli
tmpstr=QString("%1:%2:%3:%4").arg(h,2,10,QChar('0')).arg(m,2,10,QChar('0')).arg(s,2,10,QChar('0')).arg(ms,3,10,QChar('0'));
} else if (fitmode == 1) { // minute
tmpstr = QString("%1:%2").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0'));
} else if (fitmode == 2) { // second
tmpstr = QString("%1:%2:%3").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0')).arg(s, 2, 10,
QChar('0'));
} else if (fitmode == 3) { // milli
tmpstr = QString("%1:%2:%3:%4").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0')).arg(s, 2, 10,
QChar('0')).arg(ms, 3, 10, QChar('0'));
}
int tx=px-x/2.0;
int tx = px - x / 2.0;
if (m_utcfix)
tx+=step_pixels/2.0;
if ((tx+x)<(left+width)) {
if (!usepixmap) w.renderText(tmpstr,tx,texttop,0,Qt::black,defaultfont);
else painter.drawText(tx-left+20,texttop-top,tmpstr);
if (m_utcfix) {
tx += step_pixels / 2.0;
}
py=px;
for (int j=1;j<num_minor_ticks;j++) {
py+=step_pixels;
if (py>=left+width) break;
if ((tx + x) < (left + width)) {
if (!usepixmap) { w.renderText(tmpstr, tx, texttop, 0, Qt::black, defaultfont); }
else { painter.drawText(tx - left + 20, texttop - top, tmpstr); }
}
py = px;
for (int j = 1; j < num_minor_ticks; j++) {
py += step_pixels;
if (py >= left + width) { break; }
if (usepixmap) {
painter.drawLine(py-left+20,0,py-left+20,mintop-top);
} else lines->add(py,top,py,mintop);
painter.drawLine(py - left + 20, 0, py - left + 20, mintop - top);
} else { lines->add(py, top, py, mintop); }
}
if (lines->full()) {
@ -266,18 +299,20 @@ void gXAxis::paint(gGraph & w,int left,int top, int width, int height)
if (usepixmap) {
painter.end();
m_image=QGLWidget::convertToGLFormat(m_image);
m_textureID=w.graphView()->bindTexture(m_image,GL_TEXTURE_2D,GL_RGBA,QGLContext::NoBindOption);
m_image = QGLWidget::convertToGLFormat(m_image);
m_textureID = w.graphView()->bindTexture(m_image, GL_TEXTURE_2D, GL_RGBA,
QGLContext::NoBindOption);
}
w.invalidate_xAxisImage=false;
w.invalidate_xAxisImage = false;
}
if (usepixmap && !m_image.isNull()) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
w.graphView()->drawTexture(QPoint(left-20,(top+height)-m_image.height()+4),m_textureID);
w.graphView()->drawTexture(QPoint(left - 20, (top + height) - m_image.height() + 4), m_textureID);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
}

View File

@ -15,25 +15,25 @@
/*! \class gXAxis
\brief Draws the XTicker timescales underneath graphs */
class gXAxis:public Layer
class gXAxis: public Layer
{
public:
gXAxis(QColor col=Qt::black,bool fadeout=true);
gXAxis(QColor col = Qt::black, bool fadeout = true);
virtual ~gXAxis();
virtual void paint(gGraph & w,int left,int top, int width, int height);
static const int Margin=20; // How much room does this take up. (Bottom margin)
void SetShowMinorLines(bool b) { m_show_minor_lines=b; }
void SetShowMajorLines(bool b) { m_show_major_lines=b; }
virtual void paint(gGraph &w, int left, int top, int width, int height);
static const int Margin = 20; // How much room does this take up. (Bottom margin)
void SetShowMinorLines(bool b) { m_show_minor_lines = b; }
void SetShowMajorLines(bool b) { m_show_major_lines = b; }
bool ShowMinorLines() { return m_show_minor_lines; }
bool ShowMajorLines() { return m_show_major_lines; }
void SetShowMinorTicks(bool b) { m_show_minor_ticks=b; }
void SetShowMajorTicks(bool b) { m_show_major_ticks=b; }
void SetShowMinorTicks(bool b) { m_show_minor_ticks = b; }
void SetShowMajorTicks(bool b) { m_show_major_ticks = b; }
bool ShowMinorTicks() { return m_show_minor_ticks; }
bool ShowMajorTicks() { return m_show_major_ticks; }
void setUtcFix(bool b) { m_utcfix=b; }
void setUtcFix(bool b) { m_utcfix = b; }
protected:
// virtual const wxString & Format(double v) { static wxString t; wxDateTime d; d.Set(v); t=d.Format(wxT("%H:%M")); return t; };
// virtual const wxString & Format(double v) { static wxString t; wxDateTime d; d.Set(v); t=d.Format(wxT("%H:%M")); return t; };
bool m_show_major_lines;
bool m_show_minor_lines;
bool m_show_minor_ticks;

View File

@ -15,114 +15,130 @@
#include "SleepLib/profiles.h"
gXGrid::gXGrid(QColor col)
:Layer(NoChannel)
: Layer(NoChannel)
{
Q_UNUSED(col)
m_major_color=QColor(180,180,180,64);
m_major_color = QColor(180, 180, 180, 64);
//m_major_color=QColor(180,180,180,92);
m_minor_color=QColor(230,230,230,64);
m_show_major_lines=true;
m_show_minor_lines=true;
m_minor_color = QColor(230, 230, 230, 64);
m_show_major_lines = true;
m_show_minor_lines = true;
}
gXGrid::~gXGrid()
{
}
void gXGrid::paint(gGraph & w,int left,int top, int width, int height)
void gXGrid::paint(gGraph &w, int left, int top, int width, int height)
{
int x,y;
int x, y;
gVertexBuffer * stippled, * lines;
gVertexBuffer *stippled, * lines;
EventDataType miny,maxy;
EventDataType miny, maxy;
if (w.zoomY()==0 && PROFILE.appearance->allowYAxisScaling()) {
miny=w.physMinY();
maxy=w.physMaxY();
if (w.zoomY() == 0 && PROFILE.appearance->allowYAxisScaling()) {
miny = w.physMinY();
maxy = w.physMaxY();
} else {
miny=w.min_y;
maxy=w.max_y;
miny = w.min_y;
maxy = w.max_y;
if (miny<0) { // even it up if it's starts negative
miny=-MAX(fabs(miny),fabs(maxy));
if (miny < 0) { // even it up if it's starts negative
miny = -MAX(fabs(miny), fabs(maxy));
}
}
w.roundY(miny,maxy);
w.roundY(miny, maxy);
//EventDataType dy=maxy-miny;
if (height<0) return;
if (height < 0) { return; }
static QString fd="0";
GetTextExtent(fd,x,y);
static QString fd = "0";
GetTextExtent(fd, x, y);
double max_yticks=round(height / (y+14.0)); // plus spacing between lines
double max_yticks = round(height / (y + 14.0)); // plus spacing between lines
//double yt=1/max_yticks;
double mxy=MAX(fabs(maxy),fabs(miny));
double mny=miny;
if (miny<0) {
mny=-mxy;
double mxy = MAX(fabs(maxy), fabs(miny));
double mny = miny;
if (miny < 0) {
mny = -mxy;
}
double rxy=mxy-mny;
double rxy = mxy - mny;
int myt;
bool fnd=false;
for (myt=max_yticks;myt>=1;myt--) {
float v=rxy/float(myt);
if (float(v)==int(v)) {
fnd=true;
bool fnd = false;
for (myt = max_yticks; myt >= 1; myt--) {
float v = rxy / float(myt);
if (float(v) == int(v)) {
fnd = true;
break;
}
}
if (fnd) max_yticks=myt;
if (fnd) { max_yticks = myt; }
else {
max_yticks=2;
max_yticks = 2;
}
double yt=1/max_yticks;
double ymult=height/rxy;
double yt = 1 / max_yticks;
double min_ytick=rxy*yt;
double ymult = height / rxy;
float ty,h;
double min_ytick = rxy * yt;
if (min_ytick<=0) {
float ty, h;
if (min_ytick <= 0) {
qDebug() << "min_ytick error in gXGrid::paint() in" << w.title();
return;
}
if (min_ytick>=1000000) {
min_ytick=100;
if (min_ytick >= 1000000) {
min_ytick = 100;
}
stippled=w.backlines();
lines=w.backlines();
for (double i=miny; i<=maxy+min_ytick-0.00001; i+=min_ytick) {
ty=(i - miny) * ymult;
h=top+height-ty;
stippled = w.backlines();
lines = w.backlines();
for (double i = miny; i <= maxy + min_ytick - 0.00001; i += min_ytick) {
ty = (i - miny) * ymult;
h = top + height - ty;
if (m_show_major_lines && (i > miny)) {
stippled->add(left,h,left+width,h,m_major_color.rgba());
stippled->add(left, h, left + width, h, m_major_color.rgba());
}
double z=(min_ytick/4)*ymult;
double g=h;
for (int i=0;i<3;i++) {
g+=z;
if (g>top+height) break;
double z = (min_ytick / 4) * ymult;
double g = h;
for (int i = 0; i < 3; i++) {
g += z;
if (g > top + height) { break; }
//if (vertcnt>=maxverts) {
// qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick;
// break;
// break;
// }
if (m_show_minor_lines) {// && (i > miny)) {
stippled->add(left,g,left+width,g,m_minor_color.rgba());
stippled->add(left, g, left + width, g, m_minor_color.rgba());
}
if (stippled->full()) {
break;
}
}
if (lines->full() || stippled->full()) {
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;
break;
}
}
@ -131,26 +147,26 @@ void gXGrid::paint(gGraph & w,int left,int top, int width, int height)
gYAxis::gYAxis(QColor col)
:Layer(NoChannel)
: Layer(NoChannel)
{
m_line_color=col;
m_text_color=col;
m_textureID=0;
m_line_color = col;
m_text_color = col;
m_textureID = 0;
m_yaxis_scale=1;
m_yaxis_scale = 1;
}
gYAxis::~gYAxis()
{
}
void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
void gYAxis::paint(gGraph &w, int left, int top, int width, int height)
{
int x,y;//,yh=0;
int x, y; //,yh=0;
//Todo: clean this up as there is a lot of duplicate code between the sections
if (0) {//w.graphView()->usePixmapCache()) {
/* if (w.invalidate_yAxisImage) {
/* if (w.invalidate_yAxisImage) {
if (!m_image.isNull()) {
w.graphView()->deleteTexture(m_textureID);
@ -269,59 +285,67 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
}
*/
*/
} else {
if (height<0) return;
if (height>2000) return;
int labelW=0;
if (height < 0) { return; }
if (height > 2000) { return; }
int labelW = 0;
EventDataType miny;
EventDataType maxy;
if (w.zoomY()==0 && PROFILE.appearance->allowYAxisScaling()) {
miny=w.physMinY();
maxy=w.physMaxY();
if (w.zoomY() == 0 && PROFILE.appearance->allowYAxisScaling()) {
miny = w.physMinY();
maxy = w.physMaxY();
} else {
miny=w.min_y;
maxy=w.max_y;
miny = w.min_y;
maxy = w.max_y;
if (miny<0) { // even it up if it's starts negative
miny=-MAX(fabs(miny),fabs(maxy));
if (miny < 0) { // even it up if it's starts negative
miny = -MAX(fabs(miny), fabs(maxy));
}
}
w.roundY(miny,maxy);
EventDataType dy=maxy-miny;
w.roundY(miny, maxy);
static QString fd="0";
GetTextExtent(fd,x,y);
EventDataType dy = maxy - miny;
double max_yticks=round(height / (y+14.0)); // plus spacing between lines
static QString fd = "0";
GetTextExtent(fd, x, y);
double mxy=MAX(fabs(maxy),fabs(miny));
double mny=miny;
if (miny<0) {
mny=-mxy;
double max_yticks = round(height / (y + 14.0)); // plus spacing between lines
double mxy = MAX(fabs(maxy), fabs(miny));
double mny = miny;
if (miny < 0) {
mny = -mxy;
}
double rxy=mxy-mny;
double rxy = mxy - mny;
int myt;
bool fnd=false;
for (myt=max_yticks;myt>2;myt--) {
float v=rxy/float(myt);
if (v==int(v)) {
fnd=true;
bool fnd = false;
for (myt = max_yticks; myt > 2; myt--) {
float v = rxy / float(myt);
if (v == int(v)) {
fnd = true;
break;
}
}
if (fnd) max_yticks=myt;
double yt=1/max_yticks;
double ymult=height/rxy;
if (fnd) { max_yticks = myt; }
double min_ytick=rxy*yt;
double yt = 1 / max_yticks;
double ymult = height / rxy;
double min_ytick = rxy * yt;
//if (dy>5) {
@ -330,106 +354,128 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
//}
float ty,h;
float ty, h;
if (min_ytick<=0) {
if (min_ytick <= 0) {
qDebug() << "min_ytick error in gYAxis::paint() in" << w.title();
return;
}
if (min_ytick>=1000000) {
min_ytick=100;
}
lines=w.backlines();
GLuint line_color=m_line_color.rgba();
for (double i=miny; i<=maxy+min_ytick-0.00001; i+=min_ytick) {
ty=(i - miny) * ymult;
if (dy<5) {
fd=Format(i*m_yaxis_scale,2);
if (min_ytick >= 1000000) {
min_ytick = 100;
}
lines = w.backlines();
GLuint line_color = m_line_color.rgba();
for (double i = miny; i <= maxy + min_ytick - 0.00001; i += min_ytick) {
ty = (i - miny) * ymult;
if (dy < 5) {
fd = Format(i * m_yaxis_scale, 2);
} else {
fd=Format(i*m_yaxis_scale,1);
fd = Format(i * m_yaxis_scale, 1);
}
GetTextExtent(fd,x,y); // performance bottleneck..
GetTextExtent(fd, x, y); // performance bottleneck..
if (x>labelW) labelW=x;
h=top+height-ty;
if (h<top) continue;
w.renderText(fd,left+width-8-x,(h+(y/2.0)),0,m_text_color,defaultfont);
if (x > labelW) { labelW = x; }
lines->add(left+width-4,h,left+width,h,line_color);
h = top + height - ty;
if (h < top) { continue; }
w.renderText(fd, left + width - 8 - x, (h + (y / 2.0)), 0, m_text_color, defaultfont);
lines->add(left + width - 4, h, left + width, h, line_color);
double z = (min_ytick / 4) * ymult;
double g = h;
for (int i = 0; i < 3; i++) {
g += z;
if (g > top + height) { break; }
lines->add(left + width - 3, g, left + width, g, line_color);
double z=(min_ytick/4)*ymult;
double g=h;
for (int i=0;i<3;i++) {
g+=z;
if (g>top+height) break;
lines->add(left+width-3,g,left+width,g,line_color);
if (lines->full()) {
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;
break;
}
}
if (lines->full()) {
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;
break;
}
}
}
}
const QString gYAxis::Format(EventDataType v, int dp) {
return QString::number(v,'f',dp);
}
bool gYAxis::mouseMoveEvent(QMouseEvent * event, gGraph * graph)
const QString gYAxis::Format(EventDataType v, int dp)
{
if (!p_profile->appearance->graphTooltips())
return false;
return QString::number(v, 'f', dp);
}
bool gYAxis::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
{
if (!p_profile->appearance->graphTooltips()) {
return false;
}
int x = event->x();
int y = event->y();
int x=event->x();
int y=event->y();
if (!graph->units().isEmpty()) {
graph->ToolTip(graph->units(),x,y-20,0);
graph->ToolTip(graph->units(), x, y - 20, 0);
// graph->redraw();
}
return true;
}
bool gYAxis::mouseDoubleClickEvent(QMouseEvent * event, gGraph * graph)
bool gYAxis::mouseDoubleClickEvent(QMouseEvent *event, gGraph *graph)
{
if (graph) {
// int x=event->x();
// int y=event->y();
short z=(graph->zoomY()+1) % gGraph::maxZoomY;
// int x=event->x();
// int y=event->y();
short z = (graph->zoomY() + 1) % gGraph::maxZoomY;
graph->setZoomY(z);
qDebug() << "Mouse double clicked for" << graph->title() << z;
}
Q_UNUSED(event);
return false;
}
const QString gYAxisTime::Format(EventDataType v, int dp)
{
int h=int(v) % 24;
int m=int(v*60) % 60;
int s=int(v*3600) % 60;
int h = int(v) % 24;
int m = int(v * 60) % 60;
int s = int(v * 3600) % 60;
char pm[3]={"am"};
char pm[3] = {"am"};
if (show_12hr) {
h>=12 ? pm[0]='p' : pm[0]='a';
h >= 12 ? pm[0] = 'p' : pm[0] = 'a';
h %= 12;
if (h==0) h=12;
if (h == 0) { h = 12; }
} else {
pm[0]=0;
pm[0] = 0;
}
if (dp>2) return QString().sprintf("%02i:%02i:%02i%s",h,m,s,pm);
return QString().sprintf("%i:%02i%s",h,m,pm);
if (dp > 2) { return QString().sprintf("%02i:%02i:%02i%s", h, m, s, pm); }
return QString().sprintf("%i:%02i%s", h, m, pm);
}
const QString gYAxisWeight::Format(EventDataType v, int dp)
{
Q_UNUSED(dp)
return weightString(v,m_unitsystem);
return weightString(v, m_unitsystem);
}

View File

@ -18,28 +18,28 @@
/*! \class gXGrid
\brief Draws the horizintal major/minor grids over graphs
*/
class gXGrid:public Layer
class gXGrid: public Layer
{
public:
public:
//! \brief Constructs an gXGrid object with default settings, and col for line colour.
gXGrid(QColor col=QColor("black"));
gXGrid(QColor col = QColor("black"));
virtual ~gXGrid();
//! \brief Draw the horizontal lines by adding the to the Vertex GLbuffers
virtual void paint(gGraph & w,int left,int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
//! \brief set the visibility status of Major lines
void setShowMinorLines(bool b) { m_show_minor_lines=b; }
void setShowMinorLines(bool b) { m_show_minor_lines = b; }
//! \brief set the visibility status of Minor lines
void setShowMajorLines(bool b) { m_show_major_lines=b; }
void setShowMajorLines(bool b) { m_show_major_lines = b; }
//! \brief Returns the visibility status of minor lines
bool showMinorLines() { return m_show_minor_lines; }
//! \brief Returns the visibility status of Major lines
bool showMajorLines() { return m_show_major_lines; }
protected:
protected:
bool m_show_major_lines;
bool m_show_minor_lines;
QColor m_major_color;
@ -49,26 +49,26 @@ protected:
/*! \class gYAxis
\brief Draws the YAxis tick markers, and numeric labels
*/
class gYAxis:public Layer
class gYAxis: public Layer
{
public:
//! \brief Construct a gYAxis object, with QColor col for tickers & text
gYAxis(QColor col=Qt::black);
gYAxis(QColor col = Qt::black);
virtual ~gYAxis();
//! \brief Draw the horizontal tickers display
virtual void paint(gGraph & w,int left,int top, int width, int height);
virtual void paint(gGraph &w, int left, int top, int width, int height);
// void SetShowMinorLines(bool b) { m_show_minor_lines=b; }
// void SetShowMajorLines(bool b) { m_show_major_lines=b; }
// bool ShowMinorLines() { return m_show_minor_lines; }
// bool ShowMajorLines() { return m_show_major_lines; }
// void SetShowMinorLines(bool b) { m_show_minor_lines=b; }
// void SetShowMajorLines(bool b) { m_show_major_lines=b; }
// bool ShowMinorLines() { return m_show_minor_lines; }
// bool ShowMajorLines() { return m_show_major_lines; }
//! \brief Sets the visibility status of minor ticks
void SetShowMinorTicks(bool b) { m_show_minor_ticks=b; }
void SetShowMinorTicks(bool b) { m_show_minor_ticks = b; }
//! \brief Sets the visibility status of Major ticks
void SetShowMajorTicks(bool b) { m_show_major_ticks=b; }
void SetShowMajorTicks(bool b) { m_show_major_ticks = b; }
//! \brief Returns the visibility status of Minor ticks
bool ShowMinorTicks() { return m_show_minor_ticks; }
@ -80,10 +80,10 @@ class gYAxis:public Layer
virtual const QString Format(EventDataType v, int dp);
//! \brief Left Margin space in pixels
static const int Margin=60;
static const int Margin = 60;
//! \brief Set the scale of the Y axis values.. Values can be multiplied by this to convert formats
void SetScale(float f) { m_yaxis_scale=f; }
void SetScale(float f) { m_yaxis_scale = f; }
//! \brief Returns the scale of the Y axis values.. Values can be multiplied by this to convert formats
float Scale() { return m_yaxis_scale; }
@ -97,9 +97,9 @@ class gYAxis:public Layer
QColor m_line_color;
QColor m_text_color;
gVertexBuffer * lines;
virtual bool mouseMoveEvent(QMouseEvent * event,gGraph * graph);
virtual bool mouseDoubleClickEvent(QMouseEvent * event, gGraph * graph);
gVertexBuffer *lines;
virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph);
virtual bool mouseDoubleClickEvent(QMouseEvent *event, gGraph *graph);
QImage m_image;
GLuint m_textureID;
@ -109,13 +109,13 @@ class gYAxis:public Layer
/*! \class gYAxisTime
\brief Draws the YAxis tick markers, and labels in time format
*/
class gYAxisTime:public gYAxis
class gYAxisTime: public gYAxis
{
public:
public:
//! \brief Construct a gYAxisTime object, with QColor col for tickers & times
gYAxisTime(bool hr12=true, QColor col=Qt::black) : gYAxis(col), show_12hr(hr12) {}
gYAxisTime(bool hr12 = true, QColor col = Qt::black) : gYAxis(col), show_12hr(hr12) {}
virtual ~gYAxisTime() {}
protected:
protected:
//! \brief Overrides gYAxis Format to display Time format
virtual const QString Format(EventDataType v, int dp);
@ -127,19 +127,19 @@ protected:
/*! \class gYAxisWeight
\brief Draws the YAxis tick markers, and labels in weight format
*/
class gYAxisWeight:public gYAxis
class gYAxisWeight: public gYAxis
{
public:
public:
//! \brief Construct a gYAxisWeight object, with QColor col for tickers & weight values
gYAxisWeight(UnitSystem us=US_Metric, QColor col=Qt::black) :gYAxis(col), m_unitsystem(us) {}
gYAxisWeight(UnitSystem us = US_Metric, QColor col = Qt::black) : gYAxis(col), m_unitsystem(us) {}
virtual ~gYAxisWeight() {}
//! \brief Returns the current UnitSystem displayed (eg, US_Metric (the rest of the world), US_Archiac (American) )
UnitSystem unitSystem() { return m_unitsystem; }
//! \brief Set the unit system displayed by this YTicker
void setUnitSystem(UnitSystem us) { m_unitsystem=us; }
protected:
void setUnitSystem(UnitSystem us) { m_unitsystem = us; }
protected:
//! \brief Overrides gYAxis Format to display Time format
virtual const QString Format(EventDataType v, int dp);
UnitSystem m_unitsystem;

View File

@ -15,59 +15,80 @@
#ifdef BUILD_WITH_MSVC
double round(double number)
{
return number < 0.0 ? ceil(number - 0.5) : floor(number+0.5);
return number < 0.0 ? ceil(number - 0.5) : floor(number + 0.5);
}
#endif
void RoundedRectangle(int x,int y,int w,int h,int radius,const QColor color)
void RoundedRectangle(int x, int y, int w, int h, int radius, const QColor color)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glColor4ub(color.red(),color.green(),color.blue(),color.alpha());
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4ub(color.red(), color.green(), color.blue(), color.alpha());
glBegin(GL_POLYGON);
glVertex2i(x+radius,y);
glVertex2i(x+w-radius,y);
for(float i=(float)M_PI*1.5f;i<M_PI*2;i+=0.1f)
glVertex2f(x+w-radius+cos(i)*radius,y+radius+sin(i)*radius);
glVertex2i(x+w,y+radius);
glVertex2i(x+w,y+h-radius);
for(float i=0;i<(float)M_PI*0.5f;i+=0.1f)
glVertex2f(x+w-radius+cos(i)*radius,y+h-radius+sin(i)*radius);
glVertex2i(x+w-radius,y+h);
glVertex2i(x+radius,y+h);
for(float i=(float)M_PI*0.5f;i<M_PI;i+=0.1f)
glVertex2f(x+radius+cos(i)*radius,y+h-radius+sin(i)*radius);
glVertex2i(x,y+h-radius);
glVertex2i(x,y+radius);
for(float i=(float)M_PI;i<M_PI*1.5f;i+=0.1f)
glVertex2f(x+radius+cos(i)*radius,y+radius+sin(i)*radius);
glVertex2i(x + radius, y);
glVertex2i(x + w - radius, y);
for (float i = (float)M_PI * 1.5f; i < M_PI * 2; i += 0.1f) {
glVertex2f(x + w - radius + cos(i)*radius, y + radius + sin(i)*radius);
}
glVertex2i(x + w, y + radius);
glVertex2i(x + w, y + h - radius);
for (float i = 0; i < (float)M_PI * 0.5f; i += 0.1f) {
glVertex2f(x + w - radius + cos(i)*radius, y + h - radius + sin(i)*radius);
}
glVertex2i(x + w - radius, y + h);
glVertex2i(x + radius, y + h);
for (float i = (float)M_PI * 0.5f; i < M_PI; i += 0.1f) {
glVertex2f(x + radius + cos(i)*radius, y + h - radius + sin(i)*radius);
}
glVertex2i(x, y + h - radius);
glVertex2i(x, y + radius);
for (float i = (float)M_PI; i < M_PI * 1.5f; i += 0.1f) {
glVertex2f(x + radius + cos(i)*radius, y + radius + sin(i)*radius);
}
glEnd();
glDisable(GL_BLEND);
}
void LinedRoundedRectangle(int x,int y,int w,int h,int radius,int lw,QColor color)
void LinedRoundedRectangle(int x, int y, int w, int h, int radius, int lw, QColor color)
{
//glDisable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glColor4ub(color.red(),color.green(),color.blue(),color.alpha());
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4ub(color.red(), color.green(), color.blue(), color.alpha());
glLineWidth((GLfloat)lw);
glBegin(GL_LINE_STRIP);
for(float i=(float)M_PI;i<=1.5f*M_PI;i+=0.1f)
glVertex2f(radius*cos(i)+x+radius,radius*sin(i)+y+radius);
for(float i=1.5f*(float)M_PI;i<=2*M_PI; i+=0.1f)
glVertex2f(radius*cos(i)+x+w-radius,radius*sin(i)+y+radius);
for(float i=0;i<=0.5f*M_PI; i+=0.1f)
glVertex2f(radius*cos(i)+x+w-radius,radius*sin(i)+y+h-radius);
for(float i=0.5f*(float)M_PI;i<=M_PI;i+=0.1f)
glVertex2f(radius*cos(i)+x+radius,radius*sin(i)+y+h-radius);
glVertex2i(x,y+radius);
for (float i = (float)M_PI; i <= 1.5f * M_PI; i += 0.1f) {
glVertex2f(radius * cos(i) + x + radius, radius * sin(i) + y + radius);
}
for (float i = 1.5f * (float)M_PI; i <= 2 * M_PI; i += 0.1f) {
glVertex2f(radius * cos(i) + x + w - radius, radius * sin(i) + y + radius);
}
for (float i = 0; i <= 0.5f * M_PI; i += 0.1f) {
glVertex2f(radius * cos(i) + x + w - radius, radius * sin(i) + y + h - radius);
}
for (float i = 0.5f * (float)M_PI; i <= M_PI; i += 0.1f) {
glVertex2f(radius * cos(i) + x + radius, radius * sin(i) + y + h - radius);
}
glVertex2i(x, y + radius);
glEnd();
//glEnable(GL_TEXTURE_2D);

View File

@ -15,37 +15,39 @@
#include <QtOpenGL/qgl.h>
#include <QColor>
const QColor COLOR_Black=Qt::black;
const QColor COLOR_LightGreen=QColor("light green");
const QColor COLOR_DarkGreen=Qt::darkGreen;
const QColor COLOR_Purple=QColor("purple");
const QColor COLOR_Aqua=QColor("#40c0ff");
const QColor COLOR_Magenta=Qt::magenta;
const QColor COLOR_Blue=Qt::blue;
const QColor COLOR_LightBlue=QColor("light blue");
const QColor COLOR_Gray=Qt::gray;
const QColor COLOR_LightGray=Qt::lightGray;
const QColor COLOR_DarkGray=Qt::darkGray;
const QColor COLOR_Cyan=Qt::cyan;
const QColor COLOR_DarkCyan=Qt::darkCyan;
const QColor COLOR_DarkBlue=Qt::darkBlue;
const QColor COLOR_DarkMagenta=Qt::darkMagenta;
const QColor COLOR_Gold=QColor("gold");
const QColor COLOR_White=Qt::white;
const QColor COLOR_Red=Qt::red;
const QColor COLOR_Pink=QColor("pink");
const QColor COLOR_DarkRed=Qt::darkRed;
const QColor COLOR_Yellow=Qt::yellow;
const QColor COLOR_DarkYellow=Qt::darkYellow;
const QColor COLOR_Orange=QColor("orange");
const QColor COLOR_Green=Qt::green;
const QColor COLOR_Brown=QColor("brown");
const QColor COLOR_Black = Qt::black;
const QColor COLOR_LightGreen = QColor("light green");
const QColor COLOR_DarkGreen = Qt::darkGreen;
const QColor COLOR_Purple = QColor("purple");
const QColor COLOR_Aqua = QColor("#40c0ff");
const QColor COLOR_Magenta = Qt::magenta;
const QColor COLOR_Blue = Qt::blue;
const QColor COLOR_LightBlue = QColor("light blue");
const QColor COLOR_Gray = Qt::gray;
const QColor COLOR_LightGray = Qt::lightGray;
const QColor COLOR_DarkGray = Qt::darkGray;
const QColor COLOR_Cyan = Qt::cyan;
const QColor COLOR_DarkCyan = Qt::darkCyan;
const QColor COLOR_DarkBlue = Qt::darkBlue;
const QColor COLOR_DarkMagenta = Qt::darkMagenta;
const QColor COLOR_Gold = QColor("gold");
const QColor COLOR_White = Qt::white;
const QColor COLOR_Red = Qt::red;
const QColor COLOR_Pink = QColor("pink");
const QColor COLOR_DarkRed = Qt::darkRed;
const QColor COLOR_Yellow = Qt::yellow;
const QColor COLOR_DarkYellow = Qt::darkYellow;
const QColor COLOR_Orange = QColor("orange");
const QColor COLOR_Green = Qt::green;
const QColor COLOR_Brown = QColor("brown");
const QColor COLOR_Text=Qt::black;
const QColor COLOR_Outline=Qt::black;
const QColor COLOR_Text = Qt::black;
const QColor COLOR_Outline = Qt::black;
const QColor COLOR_ALT_BG1=QColor(0xd8,0xff,0xd8,0xff); // Alternating Background Color 1 (Event Flags)
const QColor COLOR_ALT_BG2=COLOR_White; // Alternating Background Color 2 (Event Flags)
const QColor COLOR_ALT_BG1 = QColor(0xd8, 0xff, 0xd8,
0xff); // Alternating Background Color 1 (Event Flags)
const QColor COLOR_ALT_BG2 =
COLOR_White; // Alternating Background Color 2 (Event Flags)
/*! \brief Draw an outline of a rounded rectangle
@ -53,17 +55,17 @@ const QColor COLOR_ALT_BG2=COLOR_White; // Alternating Backgroun
\param lw Line Width
\param color Color of drawn lines
*/
void LinedRoundedRectangle(int x,int y,int w,int h,int radius,int lw,QColor color);
void LinedRoundedRectangle(int x, int y, int w, int h, int radius, int lw, QColor color);
/*! \brief Draws a filled rounded rectangle
\param radius Radius of corner rounding
\param color Color of entire rectangle
*/
void RoundedRectangle(int x,int y,int w,int h,int radius,const QColor color);
void RoundedRectangle(int x, int y, int w, int h, int radius, const QColor color);
#ifdef BUILD_WITH_MSVC
// Visual C++ doesn't have either of these in it's maths header.. I'm not surprised at Microsofts maths abilities..
const double M_PI=3.141592653589793;
const double M_PI = 3.141592653589793;
double round(double number);
#endif

View File

@ -12,7 +12,7 @@
#include "gspacer.h"
gSpacer::gSpacer(int space)
:Layer(NoChannel)
: Layer(NoChannel)
{
m_space=space;
m_space = space;
}

View File

@ -18,11 +18,11 @@
/*! \class gSpacer
\brief A dummy graph spacer layer object
*/
class gSpacer:public Layer
class gSpacer: public Layer
{
public:
gSpacer(int space=20); // orientation?
virtual void paint(gGraph & g,int left,int top, int width, int height) {
gSpacer(int space = 20); // orientation?
virtual void paint(gGraph &g, int left, int top, int width, int height) {
Q_UNUSED(g)
Q_UNUSED(left)
Q_UNUSED(top)
@ -31,7 +31,7 @@ class gSpacer:public Layer
}
int space() { return m_space; }
protected:
protected:
int m_space;
};