Merge branch 'master' of ssh://git.code.sf.net/p/sleepyhead/code

This commit is contained in:
Mark Watkins 2014-04-15 13:20:05 +10:00
commit a1991e658a
4 changed files with 437 additions and 388 deletions

View File

@ -22,15 +22,11 @@
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
# include <QWindow> # include <QWindow>
#endif #endif
#include "mainwindow.h"
#include "Graphs/gYAxis.h" #include "Graphs/gYAxis.h"
#include "Graphs/gFlagsLine.h" #include "Graphs/gFlagsLine.h"
#include "gLineChart.h" #include "gLineChart.h"
extern MainWindow *mainwin;
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
# define USE_RENDERTEXT # define USE_RENDERTEXT
# include "OpenGL/glu.h" # include "OpenGL/glu.h"
@ -43,6 +39,9 @@ extern MainWindow *mainwin;
# include <QElapsedTimer> # include <QElapsedTimer>
#endif #endif
#include "mainwindow.h"
extern MainWindow *mainwin;
// for profiling purposes, a count of lines drawn in a single frame // for profiling purposes, a count of lines drawn in a single frame
int lines_drawn_this_frame=0; int lines_drawn_this_frame=0;
@ -70,7 +69,8 @@ QHash<QString, QImage *> images;
// Must be called from a thread inside the application. // Must be called from a thread inside the application.
void InitGraphs() void InitGraphs()
{ {
if (!_graph_init) { if (_graph_init)
return;
if (!PREF.contains("Fonts_Graph_Name")) { if (!PREF.contains("Fonts_Graph_Name")) {
PREF["Fonts_Graph_Name"] = "Sans Serif"; PREF["Fonts_Graph_Name"] = "Sans Serif";
@ -123,25 +123,30 @@ void InitGraphs()
_graph_init=true; _graph_init=true;
} }
}
void DoneGraphs() void DoneGraphs()
{ {
if (_graph_init) { if (!_graph_init)
return;
delete defaultfont; delete defaultfont;
delete bigfont; delete bigfont;
delete mediumfont; delete mediumfont;
for (QHash<QString,QImage *>::iterator i=images.begin();i!=images.end();i++) {
for (QHash<QString,QImage *>::iterator i = images.begin(); i != images.end(); i++)
delete i.value(); delete i.value();
}
if (fbo) { // Clear the frame buffer object // Clear the frame buffer object.
if (fbo->isBound()) fbo->release(); if (fbo) {
if (fbo->isBound())
fbo->release();
delete fbo; delete fbo;
fbo = NULL; fbo = NULL;
fbo_unsupported = true; // just in case shutdown order gets messed up fbo_unsupported = true; // just in case shutdown order gets messed up
} }
_graph_init=false; _graph_init=false;
} }
}
void GetTextExtent(QString text, int & width, int & height, QFont *font) void GetTextExtent(QString text, int & width, int & height, QFont *font)
{ {
@ -176,18 +181,6 @@ inline quint32 swaporder(quint32 color)
((color & 0xFF) << 16)); ((color & 0xFF) << 16));
} }
gVertexBuffer::gVertexBuffer(int max,int type)
:m_max(max), m_type(type), m_cnt(0), m_size(1), m_scissor(false), m_stippled(false), m_stipple(0xffff)
{
buffer=(gVertex *)calloc(max,sizeof(gVertex));
m_blendfunc1=GL_SRC_ALPHA;
m_blendfunc2=GL_ONE_MINUS_SRC_ALPHA;
m_antialias=m_forceantialias=false;
}
gVertexBuffer::~gVertexBuffer()
{
free(buffer);
}
void gVertexBuffer::setColor(QColor col) void gVertexBuffer::setColor(QColor col)
{ {
m_color=swaporder(col.rgba()); m_color=swaporder(col.rgba());
@ -456,24 +449,6 @@ void gVertexBuffer::unsafe_add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, G
m_cnt+=4; m_cnt+=4;
} }
GLBuffer::GLBuffer(int max,int type, bool stippled)
:m_max(max), m_type(type), m_stippled(stippled)
{
m_scissor=false;
m_antialias=true;
m_forceantialias=false;
m_cnt=0;
m_colcnt=0;
m_size=1;
m_blendfunc1=GL_SRC_ALPHA;
m_blendfunc2=GL_ONE_MINUS_SRC_ALPHA;
}
GLBuffer::~GLBuffer()
{
}
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// GLFloatBuffer // GLFloatBuffer
@ -828,29 +803,13 @@ void gToolTip::paint() //actually paints it.
painter.end(); painter.end();
} }
void gToolTip::timerDone() void gToolTip::timerDone()
{ {
m_visible=false; m_visible=false;
m_graphview->redraw(); m_graphview->redraw();
} }
Layer::Layer(ChannelID code)
{
m_code = code;
m_visible = true;
m_movable = false;
m_day=NULL;
m_miny=m_maxy=0;
m_minx=m_maxx=0;
m_physminy=m_physmaxy=0;
m_order=0;
m_width=m_height=0;
m_X=m_Y=0;
m_position=LayerCenter;
m_refcount=0;
}
Layer::~Layer() Layer::~Layer()
{ {
for (int i=0;i<mgl_buffers.size();i++) { for (int i=0;i<mgl_buffers.size();i++) {
@ -919,10 +878,6 @@ void Layer::setLayout(LayerPosition position, short width, short height, short o
m_order=order; m_order=order;
} }
LayerGroup::LayerGroup() :
Layer(NoChannel)
{
}
LayerGroup::~LayerGroup() LayerGroup::~LayerGroup()
{ {
for (int i=0;i<layers.size();i++) for (int i=0;i<layers.size();i++)
@ -4272,16 +4227,6 @@ void gGraphView::deselect()
} }
} }
MyScrollBar::MyScrollBar(QWidget * parent)
:QScrollBar(parent)
{
}
void MyScrollBar::SendWheelEvent(QWheelEvent * e)
{
wheelEvent(e);
}
const quint32 gvmagic=0x41756728; const quint32 gvmagic=0x41756728;
const quint16 gvversion=2; const quint16 gvversion=2;

View File

@ -15,23 +15,21 @@
#include <QGLWidget> #include <QGLWidget>
#include <QScrollBar> #include <QScrollBar>
#include <QResizeEvent> #include <QResizeEvent>
#include <SleepLib/day.h>
#include <QThread> #include <QThread>
#include <QMutex> #include <QMutex>
#include <QSemaphore> #include <QSemaphore>
#include <QWaitCondition> #include <QWaitCondition>
#include <QPixmap> #include <QPixmap>
#include <Graphs/glcommon.h>
#include <QRect> #include <QRect>
#include <Graphs/glcommon.h>
#include <SleepLib/day.h>
#define MIN(a,b) (((a)<(b)) ? (a) : (b)); #define MIN(a,b) (((a)<(b)) ? (a) : (b));
#define MAX(a,b) (((a)<(b)) ? (b) : (a)); #define MAX(a,b) (((a)<(b)) ? (b) : (a));
enum FlagType { FT_Bar, FT_Dot, FT_Span }; enum FlagType { FT_Bar, FT_Dot, FT_Span };
//const int default_height=160;
//! \brief Initialize the Graph Fonts //! \brief Initialize the Graph Fonts
void InitGraphs(); void InitGraphs();
//! \brief Destroy the Graph Fonts //! \brief Destroy the Graph Fonts
@ -88,40 +86,66 @@ __attribute__((packed))
class gVertexBuffer class gVertexBuffer
{ {
public: public:
gVertexBuffer(int max=2048,int type=GL_LINES); gVertexBuffer(int max = 2048, int type = GL_LINES)
~gVertexBuffer(); : m_max(max), m_type(type), m_cnt(0), m_size(1),
m_scissor(false), m_antialias(false), m_forceantialias(false), m_stippled(false),
buffer(NULL),
s_x(0), s_y(0), s_width(0), s_height(0),
m_color(0),
m_stipple(0xffff),
m_blendfunc1(GL_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)
free(buffer);
}
void add(GLshort x1, GLshort y1, RGBA color); void add(GLshort x1, GLshort y1, RGBA color);
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, RGBA color); void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, RGBA color);
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3, GLshort x4, GLshort y4, RGBA color); void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3, GLshort x4, GLshort y4, RGBA color, RGBA color2); GLshort x3, GLshort y3, GLshort x4, GLshort y4, RGBA color);
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,
GLshort x3, GLshort y3, GLshort x4, GLshort y4, RGBA color, RGBA color2);
void add(GLshort x1, GLshort y1); void add(GLshort x1, GLshort y1);
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2); void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3, GLshort x4, GLshort y4); void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,
GLshort x3, GLshort y3, GLshort x4, GLshort y4);
void unsafe_add(GLshort x1, GLshort y1); void unsafe_add(GLshort x1, GLshort y1);
void unsafe_add(GLshort x1, GLshort y1, GLshort x2, GLshort y2); void unsafe_add(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
void unsafe_add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3, GLshort x4, GLshort y4); void unsafe_add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,
GLshort x3, GLshort y3, GLshort x4, GLshort y4);
void draw(); void draw();
void scissor(GLshort x, GLshort y, GLshort width, GLshort height) { s_x=x; s_y=y; s_width=width; s_height=height; m_scissor=true; } void scissor(GLshort x, GLshort y, GLshort width, GLshort height) {
s_x = x;
s_y = y;
s_width = width;
s_height = height;
m_scissor = true;
}
int Max() const { return m_max; }
int cnt() const { return m_cnt; }
GLuint type() const { return m_type; }
float size() const { return m_size; }
bool full() const { return m_cnt >= m_max; }
void reset() { m_cnt = 0; } void reset() { m_cnt = 0; }
int Max() { return m_max; }
int cnt() { return m_cnt; }
GLuint type() { return m_type; }
float size() { return m_size; }
bool full() { return m_cnt>=m_max; }
void forceAntiAlias(bool b) { m_forceantialias = b; } void forceAntiAlias(bool b) { m_forceantialias = b; }
void setSize(float f) { m_size = f; } void setSize(float f) { m_size = f; }
void setAntiAlias(bool b) { m_antialias = b; } void setAntiAlias(bool b) { m_antialias = b; }
void setStipple(GLshort stipple) { m_stipple = stipple; } void setStipple(GLshort stipple) { m_stipple = stipple; }
void setStippleOn(bool b) { m_stippled = b; } void setStippleOn(bool b) { m_stippled = b; }
void setColor(QColor col);
void setBlendFunc(GLuint b1, GLuint b2) { m_blendfunc1 = b1; m_blendfunc2 = b2; } void setBlendFunc(GLuint b1, GLuint b2) { m_blendfunc1 = b1; m_blendfunc2 = b2; }
void setColor(QColor col);
protected: protected:
//! \brief Maximum number of gVertex points contained in buffer //! \brief Maximum number of gVertex points contained in buffer
@ -158,21 +182,41 @@ protected:
class GLBuffer class GLBuffer
{ {
public: public:
GLBuffer(int max=2048,int type=GL_LINES,bool stippled=false); GLBuffer(int max = 2048, int type = GL_LINES, bool stippled = false)
virtual ~GLBuffer(); : m_max(max), m_type(type), m_cnt(0), m_colcnt(0), m_size(1),
void scissor(GLshort x1, GLshort y1, GLshort x2, GLshort y2) { s1=x1; s2=y1; s3=x2; s4=y2; m_scissor=true; } s1(0), s2(0), s3(0), s4(0),
virtual void draw(){} m_scissor(false),
m_antialias(true),
m_forceantialias(false),
m_stippled(stippled),
m_blendfunc1(GL_SRC_ALPHA),
m_blendfunc2(GL_ONE_MINUS_SRC_ALPHA)
{ }
virtual ~GLBuffer() {}
void scissor(GLshort x1, GLshort y1, GLshort x2, GLshort y2) {
s1 = x1;
s2 = y1;
s3 = x2;
s4 = y2;
m_scissor=true;
}
int Max() const { return m_max; }
int cnt() const { return m_cnt; }
bool full() const { return m_cnt >= m_max; }
float size() const { return m_size; }
int type() const { return m_type; }
void reset() { m_cnt = 0; } void reset() { m_cnt = 0; }
int Max() { return m_max; }
int cnt() { return m_cnt; }
bool full() { return m_cnt>=m_max; }
float size() { return m_size; }
int type() { return m_type; }
void setSize(float f) { m_size = f; } void setSize(float f) { m_size = f; }
void setAntiAlias(bool b) { m_antialias = b; } void setAntiAlias(bool b) { m_antialias = b; }
void forceAntiAlias(bool b) { m_forceantialias = b; } void forceAntiAlias(bool b) { m_forceantialias = b; }
void setColor(QColor col) { m_color = col; } void setColor(QColor col) { m_color = col; }
void setBlendFunc(GLuint b1, GLuint b2) { m_blendfunc1 = b1; m_blendfunc2 = b2; } void setBlendFunc(GLuint b1, GLuint b2) { m_blendfunc1 = b1; m_blendfunc2 = b2; }
virtual void draw(){}
protected: protected:
int m_max; int m_max;
int m_type; // type (GL_LINES, GL_QUADS, etc) int m_type; // type (GL_LINES, GL_QUADS, etc)
@ -226,13 +270,18 @@ public:
GLFloatBuffer(int max = 2048, int type = GL_LINES, bool stippled = false); GLFloatBuffer(int max = 2048, int type = GL_LINES, bool stippled = false);
virtual ~GLFloatBuffer(); virtual ~GLFloatBuffer();
void add(GLfloat x, GLfloat y,QColor & col); // add with vertex color // Add with vertex color(s).
void add(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,QColor & col); // add with vertex colors void add(GLfloat x, GLfloat y, QColor &col);
void add(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4,QColor & col); // add with vertex colors void add(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, QColor &col);
void quadGrTB(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4,QColor & col,QColor & col2); // add with vertex colors void add(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
void quadGrLR(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4,QColor & col,QColor & col2); // add with vertex colors GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4, QColor &col);
void quadGrTB(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4, QColor &col, QColor &col2);
void quadGrLR(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4, QColor &col, QColor &col2);
virtual void draw(); virtual void draw();
protected: protected:
GLfloat *buffer; GLfloat *buffer;
GLubyte *colors; GLubyte *colors;
@ -265,8 +314,13 @@ struct TextQue
class MyScrollBar : public QScrollBar class MyScrollBar : public QScrollBar
{ {
public: public:
MyScrollBar(QWidget * parent=0); MyScrollBar(QWidget *parent = NULL)
void SendWheelEvent(QWheelEvent * e); : QScrollBar(parent)
{ }
void SendWheelEvent(QWheelEvent * e) {
wheelEvent(e);
}
}; };
enum LayerPosition { LayerLeft, LayerRight, LayerTop, LayerBottom, LayerCenter, LayerOverlay }; enum LayerPosition { LayerLeft, LayerRight, LayerTop, LayerBottom, LayerCenter, LayerOverlay };
@ -278,8 +332,23 @@ class Layer
{ {
friend class gGraph; friend class gGraph;
friend class LayerGroup; friend class LayerGroup;
public: public:
Layer(ChannelID code); Layer(ChannelID code)
: m_refcount(0),
m_day(NULL),
m_visible(true),
m_movable(false),
m_minx(0), m_maxx(0),
m_miny(0), m_maxy(0),
m_physminy(0), m_physmaxy(0),
m_code(code),
m_width(0), m_height(0),
m_X(0), m_Y(0),
m_order(0),
m_position(LayerCenter)
{ }
virtual ~Layer(); virtual ~Layer();
//! \brief This gets called on day selection, allowing this layer to precalculate any drawing data //! \brief This gets called on day selection, allowing this layer to precalculate any drawing data
@ -300,10 +369,10 @@ public:
virtual void deselect() { } virtual void deselect() { }
//! \brief Return this layers physical minimum date boundary //! \brief Return this layers physical minimum date boundary
virtual qint64 Minx() { if (m_day) return m_day->first(); return m_minx; } virtual qint64 Minx() { return m_day ? m_day->first() : m_minx; }
//! \brief Return this layers physical maximum date boundary //! \brief Return this layers physical maximum date boundary
virtual qint64 Maxx() { if (m_day) return m_day->last(); return m_maxx; } virtual qint64 Maxx() { return m_day ? m_day->last() : m_maxx; }
//! \brief Return this layers physical minimum Yaxis value //! \brief Return this layers physical minimum Yaxis value
virtual EventDataType Miny() { return m_miny; } virtual EventDataType Miny() { return m_miny; }
@ -333,13 +402,13 @@ public:
void setVisible(bool b) { m_visible = b; } void setVisible(bool b) { m_visible = b; }
//! \brief Return this layers Visibility status //! \brief Return this layers Visibility status
bool visible() { return m_visible; } bool visible() const { return m_visible; }
//! \brief Set this layers Moveability status (not really used yet) //! \brief Set this layers Moveability status (not really used yet)
void setMovable(bool b) { m_movable = b; } void setMovable(bool b) { m_movable = b; }
//! \brief Return this layers Moveability status (not really used yet) //! \brief Return this layers Moveability status (not really used yet)
bool movable() { return m_movable; } bool movable() const { return m_movable; }
/*! \brief Override this for the drawing code, using GLBuffer components for drawing /*! \brief Override this for the drawing code, using GLBuffer components for drawing
\param gGraph & gv Graph Object that holds this layer \param gGraph & gv Graph Object that holds this layer
@ -350,7 +419,6 @@ public:
*/ */
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. //! \brief Set the layout position and order for this layer.
void setLayout(LayerPosition position, short width, short height, short order); void setLayout(LayerPosition position, short width, short height, short order);
@ -364,20 +432,22 @@ public:
//void X() { return m_X; } //void X() { return m_X; }
//void Y() { return m_Y; } //void Y() { return m_Y; }
//! \brief Draw all this layers custom GLBuffers (ie. the actual OpenGL Vertices) //! \brief Draw all this layers custom GLBuffers (ie. the actual OpenGL Vertices)
virtual void drawGLBuf(float linesize); virtual void drawGLBuf(float linesize);
//! \brief not sure why I needed the reference counting stuff. //! \brief not sure why I needed the reference counting stuff.
short m_refcount; short m_refcount;
void addref() { m_refcount++; } void addref() { m_refcount++; }
bool unref() { m_refcount--; if (m_refcount<=0) return true; return false; } bool unref() {
m_refcount--;
return (m_refcount <= 0);
}
protected: protected:
//! \brief Add a GLBuffer (vertex) object customized to this layer //! \brief Add a GLBuffer (vertex) object customized to this layer
void addGLBuf(GLBuffer *buf) { mgl_buffers.push_back(buf); } void addGLBuf(GLBuffer *buf) { mgl_buffers.push_back(buf); }
void addVertexBuffer(gVertexBuffer *buf) { mv_buffers.push_back(buf); } void addVertexBuffer(gVertexBuffer *buf) { mv_buffers.push_back(buf); }
//QRect bounds; // bounds, relative to top of individual graph. //QRect bounds; // bounds, relative to top of individual graph.
Day *m_day; Day *m_day;
bool m_visible; bool m_visible;
@ -399,17 +469,29 @@ protected:
QVector<gVertexBuffer *> mv_buffers; QVector<gVertexBuffer *> mv_buffers;
//! \brief Mouse wheel moved somewhere over this layer //! \brief Mouse wheel moved somewhere over this layer
virtual bool wheelEvent(QWheelEvent * event, gGraph * graph) { Q_UNUSED(event); Q_UNUSED(graph); return false; } virtual bool wheelEvent(QWheelEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
}
//! \brief Mouse moved somewhere over this layer //! \brief Mouse moved somewhere over this layer
virtual bool mouseMoveEvent(QMouseEvent * event, gGraph * graph) { Q_UNUSED(event); Q_UNUSED(graph); return false; } virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
}
//! \brief Mouse left or right button pressed somewhere on this layer //! \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; } virtual bool mousePressEvent(QMouseEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
}
//! \brief Mouse button released that was originally pressed somewhere on this layer //! \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; } virtual bool mouseReleaseEvent(QMouseEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
}
//! \brief Mouse button double clicked somewhere on this layer //! \brief Mouse button double clicked somewhere on this layer
virtual bool mouseDoubleClickEvent(QMouseEvent * event, gGraph * graph) { Q_UNUSED(event); Q_UNUSED(graph); return false; } virtual bool mouseDoubleClickEvent(QMouseEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
}
//! \brief A key was pressed on the keyboard while the graph area was focused. //! \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; } virtual bool keyPressEvent(QKeyEvent *event, gGraph *graph) {
Q_UNUSED(event); Q_UNUSED(graph); return false;
}
}; };
/*! \class LayerGroup /*! \class LayerGroup
@ -418,7 +500,10 @@ protected:
class LayerGroup : public Layer class LayerGroup : public Layer
{ {
public: public:
LayerGroup(); LayerGroup()
: Layer(NoChannel)
{ }
virtual ~LayerGroup(); virtual ~LayerGroup();
//! \brief Add Layer to this Layer Group //! \brief Add Layer to this Layer Group
@ -490,6 +575,7 @@ public:
//! \brief Kill thread process //! \brief Kill thread process
void die() { m_running = false; } void die() { m_running = false; }
QMutex mutex; QMutex mutex;
protected: protected:
gGraphView *graphview; gGraphView *graphview;
volatile bool m_running; volatile bool m_running;
@ -519,6 +605,7 @@ public:
//! \brief Returns true if the tooltip is currently visible //! \brief Returns true if the tooltip is currently visible
bool visible() { return m_visible; } bool visible() { return m_visible; }
protected: protected:
gGraphView *m_graphview; gGraphView *m_graphview;
QTimer *timer; QTimer *timer;
@ -552,7 +639,8 @@ public:
\param int height containing the opening height for this graph \param int height containing the opening height for this graph
\param short group containing which graph-link group this graph belongs to \param short group containing which graph-link group this graph belongs to
*/ */
gGraph(gGraphView * graphview=NULL, QString title="", QString units="", int height=100,short group=0); gGraph(gGraphView *graphview = NULL, QString title = "", QString units = "",
int height = 100, short group = 0);
virtual ~gGraph(); virtual ~gGraph();
//! \brief Tells all Layers to deselect any highlighting //! \brief Tells all Layers to deselect any highlighting
@ -608,16 +696,21 @@ public:
//! \brief Returns true if none of the included layers have data attached //! \brief Returns true if none of the included layers have data attached
bool isEmpty(); bool isEmpty();
//! \brief Add Layer l to graph object, allowing you to specify position, margin sizes, order, movability status and offsets //! \brief Add Layer l to graph object, allowing you to specify position,
void AddLayer(Layer * l,LayerPosition position=LayerCenter, short pixelsX=0, short pixelsY=0, short order=0, bool movable=false, short x=0, short y=0); // margin sizes, order, movability status and offsets
void AddLayer(Layer *l, LayerPosition position = LayerCenter,
short pixelsX = 0, short pixelsY = 0, short order = 0,
bool movable = false, short x = 0, short y = 0);
void qglColor(QColor col); void qglColor(QColor col);
//! \brief Queues text for gGraphView object to draw it. //! \brief Queues text for gGraphView object to draw it.
void renderText(QString text, int x,int y, float angle=0.0, QColor color=Qt::black, QFont *font=defaultfont,bool antialias=true); void renderText(QString text, int x, int y, float angle = 0.0,
QColor color = Qt::black, QFont *font = defaultfont, bool antialias = true);
//! \brief Rounds Y scale values to make them look nice.. Applies the Graph Preference min/max settings. //! \brief Rounds Y scale values to make them look nice..
// Applies the Graph Preference min/max settings.
void roundY(EventDataType &miny, EventDataType &maxy); void roundY(EventDataType &miny, EventDataType &maxy);
//! \brief Process all Layers GLBuffer (Vertex) objects, drawing the actual OpenGL stuff. //! \brief Process all Layers GLBuffer (Vertex) objects, drawing the actual OpenGL stuff.
@ -661,7 +754,6 @@ public:
//! \brief Returns the physical Maximum Y scale value for all layers contained //! \brief Returns the physical Maximum Y scale value for all layers contained
virtual EventDataType physMaxY(); virtual EventDataType physMaxY();
//! \brief Sets the physical start of this graphs time range (in milliseconds since epoch) //! \brief Sets the physical start of this graphs time range (in milliseconds since epoch)
virtual void SetMinX(qint64 v); virtual void SetMinX(qint64 v);
@ -683,14 +775,18 @@ public:
virtual EventDataType forceMinY() { return rec_miny; } virtual EventDataType forceMinY() { return rec_miny; }
virtual EventDataType forceMaxY() { return rec_maxy; } virtual EventDataType forceMaxY() { return rec_maxy; }
//! \brief Set recommended Y minimum.. It won't go under this unless the data does. It won't go above this. //! \brief Set recommended Y minimum.. It won't go under this unless the data does.
// It won't go above this.
virtual void setRecMinY(EventDataType v) { rec_miny = v; } virtual void setRecMinY(EventDataType v) { rec_miny = v; }
//! \brief Set recommended Y minimum.. It won't go above this unless the data does. It won't go under this. //! \brief Set recommended Y minimum.. It won't go above this unless the data does.
// It won't go under this.
virtual void setRecMaxY(EventDataType v) { rec_maxy = v; } virtual void setRecMaxY(EventDataType v) { rec_maxy = v; }
//! \brief Returns the recommended Y minimum.. It won't go under this unless the data does. It won't go above this. //! \brief Returns the recommended Y minimum.. It won't go under this unless the data does.
// It won't go above this.
virtual EventDataType RecMinY() { return rec_miny; } virtual EventDataType RecMinY() { return rec_miny; }
//! \brief Returns the recommended Y maximum.. It won't go under this unless the data does. It won't go above this. //! \brief Returns the recommended Y maximum.. It won't go under this unless the data does.
// It won't go above this.
virtual EventDataType RecMaxY() { return rec_maxy; } virtual EventDataType RecMaxY() { return rec_maxy; }
//! \brief Called when main graph area is resized //! \brief Called when main graph area is resized
@ -763,7 +859,7 @@ public:
//! \brief Returns the main gGraphView objects gVertexBuffer quads list. //! \brief Returns the main gGraphView objects gVertexBuffer quads list.
gVertexBuffer *quads(); gVertexBuffer *quads();
const inline QRect & rect() { return m_rect; } const inline QRect &rect() const { return m_rect; }
bool isPinned() { return m_pinned; } bool isPinned() { return m_pinned; }
void setPinned(bool b) { m_pinned=b; } void setPinned(bool b) { m_pinned=b; }
@ -792,6 +888,7 @@ public:
void setZoomY(short zoom); void setZoomY(short zoom);
static const short maxZoomY = 2; static const short maxZoomY = 2;
protected: protected:
//void invalidate(); //void invalidate();
@ -816,7 +913,8 @@ protected:
//! \brief Change the current selected time boundaries by mult, from origin position origin_px //! \brief Change the current selected time boundaries by mult, from origin position origin_px
void ZoomX(double mult, int origin_px); void ZoomX(double mult, int origin_px);
//! \brief The Main gGraphView object holding this graph (this can be pinched temporarily by print code) //! \brief The Main gGraphView object holding this graph
// (this can be pinched temporarily by print code)
gGraphView *m_graphview; gGraphView *m_graphview;
QString m_title; QString m_title;
QString m_units; QString m_units;
@ -840,11 +938,8 @@ protected:
bool m_showTitle; bool m_showTitle;
bool m_printing; bool m_printing;
bool m_pinned; bool m_pinned;
short m_zoomY; short m_zoomY;
QRect m_rect; QRect m_rect;
signals:
protected slots: protected slots:
//! \brief Deselects any highlights, and schedules a main gGraphView redraw //! \brief Deselects any highlights, and schedules a main gGraphView redraw
@ -862,7 +957,6 @@ struct myPixmapCache
GLuint textureID; GLuint textureID;
}; };
/*! \class gGraphView /*! \class gGraphView
\brief Main OpenGL Graph Area, derived from QGLWidget \brief Main OpenGL Graph Area, derived from QGLWidget
@ -915,7 +1009,7 @@ public:
void GetRXBounds(qint64 &st, qint64 &et); void GetRXBounds(qint64 &st, qint64 &et);
//! \brief Resets the time range to default for this day. Refreshing the display if refresh==true. //! \brief Resets the time range to default for this day. Refreshing the display if refresh==true.
void ResetBounds(bool refresh=true); //short group=0); void ResetBounds(bool refresh = true);
//! \brief Supplies time range to all graph objects in linked group, refreshing if requested //! \brief Supplies time range to all graph objects in linked group, refreshing if requested
void SetXBounds(qint64 minx, qint64 maxx, short group = 0, bool refresh = true); void SetXBounds(qint64 minx, qint64 maxx, short group = 0, bool refresh = true);
@ -929,8 +1023,8 @@ public:
//! \brief Returns the graph object matching the supplied name, NULL if it does not exist. //! \brief Returns the graph object matching the supplied name, NULL if it does not exist.
gGraph *findGraph(QString name); gGraph *findGraph(QString name);
inline float printScaleX() { return print_scaleX; } inline float printScaleX() const { return print_scaleX; }
inline float printScaleY() { return print_scaleY; } inline float printScaleY() const { return print_scaleY; }
inline void setPrintScaleX(float x) { print_scaleX = x; } inline void setPrintScaleX(float x) { print_scaleX = x; }
inline void setPrintScaleY(float y) { print_scaleY = y; } inline void setPrintScaleY(float y) { print_scaleY = y; }
@ -940,7 +1034,7 @@ public:
//! \brief Tell all graphs to deslect any highlighted areas //! \brief Tell all graphs to deslect any highlighted areas
void deselect(); void deselect();
QPoint pointClicked() { return m_point_clicked; } QPoint pointClicked() const { return m_point_clicked; }
void setPointClicked(QPoint p) { m_point_clicked = p; } void setPointClicked(QPoint p) { m_point_clicked = p; }
//! \brief Set a redraw timer for ms milliseconds, clearing any previous redraw timer. //! \brief Set a redraw timer for ms milliseconds, clearing any previous redraw timer.
@ -963,7 +1057,8 @@ public:
void selectionTime(); void selectionTime();
//! \brief Add the Text information to the Text Drawing Queue (called by gGraphs renderText method) //! \brief Add the Text information to the Text Drawing Queue (called by gGraphs renderText method)
void AddTextQue(QString & text, short x, short y, float angle=0.0, QColor color=Qt::black, QFont * font=defaultfont, bool antialias=true); void AddTextQue(QString &text, short x, short y, float angle = 0.0,
QColor color = Qt::black, QFont *font = defaultfont, bool antialias = true);
//! \brief Draw all Text in the text drawing queue //! \brief Draw all Text in the text drawing queue
void DrawTextQue(); void DrawTextQue();
@ -971,15 +1066,15 @@ public:
//! \brief Draw all text components using QPainter object painter //! \brief Draw all text components using QPainter object painter
void DrawTextQue(QPainter &painter); void DrawTextQue(QPainter &painter);
//! \brief Returns number of graphs contained (whether they are visible or not) //! \brief Returns number of graphs contained (whether they are visible or not)
int size() { return m_graphs.size(); } int size() const { return m_graphs.size(); }
//! \brief Return individual graph by index value //! \brief Return individual graph by index value
gGraph *operator[](int i) { return m_graphs[i]; } gGraph *operator[](int i) { return m_graphs[i]; }
//! \brief Returns the custom scrollbar object linked to this gGraphArea //! \brief Returns the custom scrollbar object linked to this gGraphArea
MyScrollBar * scrollBar() { return m_scrollbar; } MyScrollBar *scrollBar() const { return m_scrollbar; }
//! \brief Sets the custom scrollbar object linked to this gGraphArea //! \brief Sets the custom scrollbar object linked to this gGraphArea
void setScrollBar(MyScrollBar *sb); void setScrollBar(MyScrollBar *sb);
@ -996,7 +1091,7 @@ public:
int visibleGraphs(); int visibleGraphs();
//! \brief Returns the horizontal travel of the mouse, for use in Mouse Handling code. //! \brief Returns the horizontal travel of the mouse, for use in Mouse Handling code.
int horizTravel() { return m_horiz_travel; } int horizTravel() const { return m_horiz_travel; }
//! \brief Sets the message displayed when there are no graphs to draw //! \brief Sets the message displayed when there are no graphs to draw
void setEmptyText(QString s) { m_emptytext = s; } void setEmptyText(QString s) { m_emptytext = s; }
@ -1006,7 +1101,6 @@ public:
inline const float & devicePixelRatio() { return m_dpr; } inline const float & devicePixelRatio() { return m_dpr; }
void setDevicePixelRatio(float dpr) { m_dpr=dpr; } void setDevicePixelRatio(float dpr) { m_dpr=dpr; }
// Cube fun // Cube fun
QVector<QImage *> cubeimg; QVector<QImage *> cubeimg;
GLuint cubetex; GLuint cubetex;
@ -1021,8 +1115,6 @@ public:
QMutex dl_mutex; QMutex dl_mutex;
#endif #endif
//! \brief Sends day object to be distributed to all Graphs Layers objects //! \brief Sends day object to be distributed to all Graphs Layers objects
void setDay(Day * day); void setDay(Day * day);
@ -1062,21 +1154,15 @@ protected:
//! \brief The heart of the OpenGL drawing code //! \brief The heart of the OpenGL drawing code
virtual void paintGL(); virtual void paintGL();
Day * m_day;
//! \brief Calculates the sum of all graph heights //! \brief Calculates the sum of all graph heights
float totalHeight(); float totalHeight();
//! \brief Calculates the sum of all graph heights, taking scaling into consideration //! \brief Calculates the sum of all graph heights, taking scaling into consideration
float scaleHeight(); float scaleHeight();
//! \brief Graph drawing routines, returns true if there weren't any graphs to draw //! \brief Graph drawing routines, returns true if there weren't any graphs to draw
bool renderGraphs(); bool renderGraphs();
//! \brief Update the OpenGL area when the screen is resized //! \brief Update the OpenGL area when the screen is resized
virtual void resizeEvent(QResizeEvent *); virtual void resizeEvent(QResizeEvent *);
@ -1102,6 +1188,10 @@ protected:
//! \brief Add Graph to drawing queue, mainly for the benefit of multithreaded drawing code //! \brief Add Graph to drawing queue, mainly for the benefit of multithreaded drawing code
void queGraph(gGraph *, int originX, int originY, int width, int height); void queGraph(gGraph *, int originX, int originY, int width, int height);
void renderSomethingFun(float alpha = 1);
Day *m_day;
//! \brief the list of graphs to draw this frame //! \brief the list of graphs to draw this frame
QList<gGraph *> m_drawlist; QList<gGraph *> m_drawlist;
@ -1122,8 +1212,6 @@ protected:
float m_scaleY; float m_scaleY;
float m_dpr; float m_dpr;
void renderSomethingFun(float alpha=1);
bool m_sizer_dragging; bool m_sizer_dragging;
int m_sizer_index; int m_sizer_index;
@ -1171,18 +1259,12 @@ protected:
QTime horizScrollTime, vertScrollTime; QTime horizScrollTime, vertScrollTime;
//QVector<GLuint> texid;
signals:
public slots: public slots:
//! \brief Callback from the ScrollBar, to change scroll position //! \brief Callback from the ScrollBar, to change scroll position
void scrollbarValueChanged(int val); void scrollbarValueChanged(int val);
//! \brief Simply refreshes the GL view, called when timeout expires. //! \brief Simply refreshes the GL view, called when timeout expires.
void refreshTimeout(); void refreshTimeout();
}; };
#endif // GGRAPHVIEW_H #endif // GGRAPHVIEW_H

View File

@ -230,7 +230,15 @@ MainWindow::~MainWindow()
void MainWindow::Notify(QString s, QString title, int ms) void MainWindow::Notify(QString s, QString title, int ms)
{ {
if (systray) { if (systray) {
systray->showMessage(title,s,QSystemTrayIcon::Information,ms); // GNOME3's systray hides the last line of the displayed Qt message.
// As a workaround, add an extra line to bump the message back
// into the visible area.
QString msg = s;
char *desktop = getenv("DESKTOP_SESSION");
if (desktop && !strncmp(desktop, "gnome", 5))
msg += "\n";
systray->showMessage(title, msg, QSystemTrayIcon::Information, ms);
} else { } else {
ui->statusbar->showMessage(s, ms); ui->statusbar->showMessage(s, ms);
} }

View File

@ -31,6 +31,9 @@ extern QFont * mediumfont;
extern QFont * bigfont; extern QFont * bigfont;
extern MainWindow * mainwin; extern MainWindow * mainwin;
typedef QMessageBox::StandardButton StandardButton;
typedef QMessageBox::StandardButtons StandardButtons;
MaskProfile masks[]={ MaskProfile masks[]={
{Mask_Unknown,QObject::tr("Unspecified"),{{4,25},{8,25},{12,25},{16,25},{20,25}}}, {Mask_Unknown,QObject::tr("Unspecified"),{{4,25},{8,25},{12,25},{16,25},{20,25}}},
{Mask_NasalPillows,QObject::tr("Nasal Pillows"),{{4,20},{8,29},{12,37},{16,43},{20,49}}}, {Mask_NasalPillows,QObject::tr("Nasal Pillows"),{{4,20},{8,29},{12,37},{16,43},{20,49}}},
@ -781,34 +784,45 @@ void PreferencesDialog::resetGraphModel()
void PreferencesDialog::on_resetGraphButton_clicked() void PreferencesDialog::on_resetGraphButton_clicked()
{ {
if (QMessageBox::question(this,tr("Confirmation"),tr("Are you sure you want to reset your graph preferences to the defaults?"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) { QString title = tr("Confirmation");
gGraphView *gv[3]; QString text = tr("Are you sure you want to reset your graph preferences to the defaults?");
gv[0]=mainwin->getDaily()->graphView(); StandardButtons buttons = QMessageBox::Yes | QMessageBox::No;
gv[1]=mainwin->getOverview()->graphView(); StandardButton defaultButton = QMessageBox::No;
gv[2]=mainwin->getOximetry()->graphView();
for (int j=0;j<3;j++) { // Display confirmation dialog.
if (gv[j]!=NULL) { StandardButton choice = QMessageBox::question(this, title, text, buttons, defaultButton);
for (int i=0;i<gv[j]->size();i++) { if (choice == QMessageBox::No)
gGraph *g=(*(gv[j]))[i]; return;
g->setRecMaxY(0);
gGraphView *views[3];
views[0] = mainwin->getDaily()->graphView();
views[1] = mainwin->getOverview()->graphView();
views[2] = mainwin->getOximetry()->graphView();
// Iterate over all graph containers.
for (unsigned j = 0; j < 3; j++) {
gGraphView *view = views[j];
if (!view)
continue;
// Iterate over all contained graphs.
for (unsigned i = 0; i < view->size(); i++) {
gGraph *g = (*view)[i];
g->setRecMaxY(0); // FIXME: should be g->reset(), but need other patches to land.
g->setRecMinY(0); g->setRecMinY(0);
g->setVisible(true); g->setVisible(true);
} }
gv[j]->updateScale(); view->updateScale();
}
} }
resetGraphModel(); resetGraphModel();
ui->graphView->update(); ui->graphView->update();
} }
}
/*void PreferencesDialog::on_genOpWidget_itemActivated(QListWidgetItem *item) /*void PreferencesDialog::on_genOpWidget_itemActivated(QListWidgetItem *item)
{ {
item->setCheckState(item->checkState()==Qt::Checked ? Qt::Unchecked : Qt::Checked); item->setCheckState(item->checkState()==Qt::Checked ? Qt::Unchecked : Qt::Checked);
} */ } */
void PreferencesDialog::on_maskTypeCombo_activated(int index) void PreferencesDialog::on_maskTypeCombo_activated(int index)
{ {
if (index<num_masks) { if (index<num_masks) {