Use explicit QRegion for paint().

Signed-off-by: Mark Watkins <jedimark@users.sourceforge.net>
This commit is contained in:
Sean Stangl 2014-05-13 10:47:33 -07:00 committed by Mark Watkins
parent b98d90934d
commit 87ca2ebf7e
23 changed files with 146 additions and 84 deletions

View File

@ -87,8 +87,13 @@ void gFlagsGroup::SetDay(Day *d)
m_barh = 0; m_barh = 0;
} }
void gFlagsGroup::paint(QPainter &painter, gGraph &g, int left, int top, int width, int height) void gFlagsGroup::paint(QPainter &painter, gGraph &g, const QRegion &region)
{ {
int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().height();
if (!m_visible) { return; } if (!m_visible) { return; }
if (!m_day) { return; } if (!m_day) { return; }
@ -107,8 +112,9 @@ void gFlagsGroup::paint(QPainter &painter, gGraph &g, int left, int top, int wid
painter.fillRect(left, linetop, width-1, m_barh, QBrush(barcol)); painter.fillRect(left, linetop, width-1, m_barh, QBrush(barcol));
// Paint the actual flags // Paint the actual flags
lvisible[i]->m_rect = QRect(left, linetop, width, m_barh); QRect rect(left, linetop, width, m_barh);
lvisible[i]->paint(painter, g, left, linetop, width, m_barh); lvisible[i]->m_rect = rect;
lvisible[i]->paint(painter, g, QRegion(rect));
linetop += m_barh; linetop += m_barh;
} }
@ -158,8 +164,13 @@ gFlagsLine::gFlagsLine(ChannelID code, QColor flag_color, QString label, bool al
gFlagsLine::~gFlagsLine() gFlagsLine::~gFlagsLine()
{ {
} }
void gFlagsLine::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) void gFlagsLine::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().height();
if (!m_visible) { return; } if (!m_visible) { return; }
if (!m_day) { return; } if (!m_day) { return; }

View File

@ -24,19 +24,14 @@ class gFlagsLabelArea: public gSpacer
{ {
public: public:
gFlagsLabelArea(gFlagsGroup *group); gFlagsLabelArea(gFlagsGroup *group);
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) { virtual void paint(QPainter &painter, gGraph &w, const QRegion &region) {
Q_UNUSED(w) Q_UNUSED(w);
Q_UNUSED(painter) Q_UNUSED(painter);
Q_UNUSED(left) Q_UNUSED(region);
Q_UNUSED(top)
Q_UNUSED(width)
Q_UNUSED(height)
} }
protected: protected:
gFlagsGroup *m_group; gFlagsGroup *m_group;
virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph); virtual bool mouseMoveEvent(QMouseEvent *event, gGraph *graph);
}; };
@ -59,7 +54,7 @@ class gFlagsLine: public Layer
virtual ~gFlagsLine(); virtual ~gFlagsLine();
//! \brief Drawing code to add the flags and span markers to the Vertex buffers. //! \brief Drawing code to add the flags and span markers to the Vertex buffers.
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
//! \brief Returns true if should always show this flag, even if it's empty //! \brief Returns true if should always show this flag, even if it's empty
bool isAlwaysVisible() { return m_always_visible; } bool isAlwaysVisible() { return m_always_visible; }
@ -98,7 +93,7 @@ class gFlagsGroup: public LayerGroup
virtual ~gFlagsGroup(); virtual ~gFlagsGroup();
//! Draw filled rectangles behind Event Flag's, and an outlines around them all, Calls the individual paint for each gFlagLine //! Draw filled rectangles behind Event Flag's, and an outlines around them all, Calls the individual paint for each gFlagLine
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
//! Returns the first time represented by all gFlagLine layers, in milliseconds since epoch //! Returns the first time represented by all gFlagLine layers, in milliseconds since epoch
virtual qint64 Minx(); virtual qint64 Minx();

View File

@ -23,8 +23,13 @@ gShadowArea::gShadowArea(QColor shadow_color, QColor line_color)
gShadowArea::~gShadowArea() gShadowArea::~gShadowArea()
{ {
} }
void gShadowArea::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) void gShadowArea::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().height();
if (!m_visible) { return; } if (!m_visible) { return; }
double xx = w.max_x - w.min_x; double xx = w.max_x - w.min_x;
@ -52,16 +57,15 @@ 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) : Layer(NoChannel), m_offset(offset), m_handle_color(handle_color), m_line_color(line_color)
{ {
} }
gFooBar::~gFooBar() gFooBar::~gFooBar()
{ {
} }
void gFooBar::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height)
void gFooBar::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
Q_UNUSED(top) Q_UNUSED(painter);
Q_UNUSED(left) Q_UNUSED(region);
Q_UNUSED(width)
Q_UNUSED(height)
Q_UNUSED(painter)
if (!m_visible) { return; } if (!m_visible) { return; }

View File

@ -22,7 +22,9 @@ class gShadowArea: public Layer
public: 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 ~gShadowArea();
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height);
virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
protected: protected:
QColor m_shadow_color; QColor m_shadow_color;
QColor m_line_color; QColor m_line_color;
@ -34,12 +36,16 @@ class gShadowArea: public Layer
*/ */
class gFooBar: public Layer class gFooBar: public Layer
{ {
public:
static const int Margin = 15;
public: public:
gFooBar(int offset = 10, QColor handle_color = QColor("orange"), gFooBar(int offset = 10, QColor handle_color = QColor("orange"),
QColor line_color = QColor("dark grey")); QColor line_color = QColor("dark grey"));
virtual ~gFooBar(); virtual ~gFooBar();
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height);
static const int Margin = 15; virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
protected: protected:
int m_offset; int m_offset;
QColor m_handle_color; QColor m_handle_color;

View File

@ -260,9 +260,13 @@ void gGraph::renderText(QString text, int x, int y, float angle, QColor color, Q
m_graphview->AddTextQue(text, x, y, angle, color, font, antialias); m_graphview->AddTextQue(text, x, y, angle, color, font, antialias);
} }
void gGraph::paint(QPainter &painter, int originX, int originY, int width, int height) void gGraph::paint(QPainter &painter, const QRegion &region)
{ {
m_rect = QRect(originX, originY, width, height); m_rect = region.boundingRect();
int originX = m_rect.left();
int originY = m_rect.top();
int width = m_rect.width();
int height = m_rect.height();
int fw, font_height; int fw, font_height;
GetTextExtent("Wg@", fw, font_height); GetTextExtent("Wg@", fw, font_height);
@ -324,8 +328,9 @@ void gGraph::paint(QPainter &painter, int originX, int originY, int width, int h
tmp = ll->Width() * m_graphview->printScaleX(); tmp = ll->Width() * m_graphview->printScaleX();
if (ll->position() == LayerLeft) { if (ll->position() == LayerLeft) {
ll->m_rect = QRect(originX + left, originY + top, tmp, height - top - bottom); QRect rect(originX + left, originY + top, tmp, height - top - bottom);
ll->paint(painter, *this, originX + left, originY + top, tmp, height - top - bottom); ll->m_rect = rect;
ll->paint(painter, *this, QRegion(rect));
left += tmp; left += tmp;
#ifdef DEBUG_LAYOUT #ifdef DEBUG_LAYOUT
QColor col = Qt::red; QColor col = Qt::red;
@ -336,8 +341,9 @@ void gGraph::paint(QPainter &painter, int originX, int originY, int width, int h
if (ll->position() == LayerRight) { if (ll->position() == LayerRight) {
right += tmp; right += tmp;
ll->m_rect = QRect(originX + width - right, originY + top, tmp, height - top - bottom); QRect rect(originX + width - right, originY + top, tmp, height - top - bottom);
ll->paint(painter, *this, originX + width - right, originY + top, tmp, height - top - bottom); ll->m_rect = rect;
ll->paint(painter, *this, QRegion(rect));
#ifdef DEBUG_LAYOUT #ifdef DEBUG_LAYOUT
QColor col = Qt::red; QColor col = Qt::red;
painter.setPen(col); painter.setPen(col);
@ -357,15 +363,17 @@ void gGraph::paint(QPainter &painter, int originX, int originY, int width, int h
tmp = ll->Height() * m_graphview->printScaleY(); tmp = ll->Height() * m_graphview->printScaleY();
if (ll->position() == LayerTop) { if (ll->position() == LayerTop) {
ll->m_rect = QRect(originX + left, originY + top, width - left - right, tmp); QRect rect(originX + left, originY + top, width - left - right, tmp);
ll->paint(painter, *this, originX + left, originY + top, width - left - right, tmp); ll->m_rect = rect;
ll->paint(painter, *this, QRegion(rect));
top += tmp; top += tmp;
} }
if (ll->position() == LayerBottom) { if (ll->position() == LayerBottom) {
bottom += tmp; bottom += tmp;
ll->m_rect = QRect(originX + left, originY + height - bottom, width - left - right, tmp); QRect rect(originX + left, originY + height - bottom, width - left - right, tmp);
ll->paint(painter, *this, originX + left, originY + height - bottom, width - left - right, tmp); ll->m_rect = rect;
ll->paint(painter, *this, QRegion(rect));
} }
} }
@ -380,8 +388,9 @@ void gGraph::paint(QPainter &painter, int originX, int originY, int width, int h
if (!ll->visible()) { continue; } if (!ll->visible()) { continue; }
if (ll->position() == LayerCenter) { if (ll->position() == LayerCenter) {
ll->m_rect = QRect(originX + left, originY + top, width - left - right, height - top - bottom); QRect rect(originX + left, originY + top, width - left - right, height - top - bottom);
ll->paint(painter, *this, originX + left, originY + top, width - left - right, height - top - bottom); ll->m_rect = rect;
ll->paint(painter, *this, QRegion(rect));
} }
} }

View File

@ -231,7 +231,7 @@ class gGraph : public QObject
Day *day() { return m_day; } Day *day() { return m_day; }
//! \brief The Layer, layout and title drawing code //! \brief The Layer, layout and title drawing code
virtual void paint(QPainter &painter, int originX, int originY, int width, int height); virtual void paint(QPainter &painter, const QRegion &region);
//! \brief Gives the supplied data to the main ToolTip object for display //! \brief Gives the supplied data to the main ToolTip object for display
void ToolTip(QString text, int x, int y, int timeout = 0); void ToolTip(QString text, int x, int y, int timeout = 0);

View File

@ -183,8 +183,7 @@ void gThread::run()
g = graphview->popGraph(); g = graphview->popGraph();
if (g) { if (g) {
g->paint(g->m_lastbounds.x(), g->m_lastbounds.y(), g->m_lastbounds.width(), g->paint(QRegion(g->m_lastbounds));
g->m_lastbounds.height());
//int i=0; //int i=0;
} else { } else {
//mutex.lock(); //mutex.lock();
@ -1077,7 +1076,7 @@ bool gGraphView::renderGraphs(QPainter &painter)
for (int i = 0; i < s; i++) { for (int i = 0; i < s; i++) {
gGraph *g = m_drawlist.at(0); gGraph *g = m_drawlist.at(0);
m_drawlist.pop_front(); m_drawlist.pop_front();
g->paint(painter, g->m_rect.x(), g->m_rect.y(), g->m_rect.width(), g->m_rect.height()); g->paint(painter, QRegion(g->m_rect));
} }
if (m_graphs.size() > 1) { if (m_graphs.size() > 1) {
@ -1148,7 +1147,7 @@ bool gGraphView::renderGraphs(QPainter &painter)
for (int i = 0; i < s; i++) { for (int i = 0; i < s; i++) {
gGraph *g = m_drawlist.at(0); gGraph *g = m_drawlist.at(0);
m_drawlist.pop_front(); m_drawlist.pop_front();
g->paint(painter, g->m_rect.x(), g->m_rect.y(), g->m_rect.width(), g->m_rect.height()); g->paint(painter, QRegion(g->m_rect));
} }
#ifdef ENABLED_THREADED_DRAWING #ifdef ENABLED_THREADED_DRAWING

View File

@ -148,8 +148,14 @@ EventDataType gLineChart::Maxy()
} }
// Time Domain Line Chart // Time Domain Line Chart
void gLineChart::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
// TODO: Just use QRect directly.
int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().height();
if (!m_visible) { if (!m_visible) {
return; return;
} }

View File

@ -12,6 +12,7 @@
#ifndef GLINECHART_H #ifndef GLINECHART_H
#define GLINECHART_H #define GLINECHART_H
#include <QPainter>
#include <QVector> #include <QVector>
#include "Graphs/layer.h" #include "Graphs/layer.h"
@ -35,7 +36,7 @@ class gLineChart: public Layer
virtual ~gLineChart(); virtual ~gLineChart();
//! \brief The drawing code that fills the vertex buffers //! \brief The drawing code that fills the vertex buffers
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
//! \brief Set Use Square plots for non EVL_Waveform data //! \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; }

View File

@ -21,8 +21,13 @@ gLineOverlayBar::~gLineOverlayBar()
{ {
} }
void gLineOverlayBar::paint(QPainter &painter, gGraph &w, int left, int topp, int width, int height) void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
int left = region.boundingRect().left();
int topp = region.boundingRect().top(); // FIXME: Misspelling intentional.
int width = region.boundingRect().width();
int height = region.boundingRect().height();
if (!m_visible) { return; } if (!m_visible) { return; }
if (!m_day) { return; } if (!m_day) { return; }
@ -214,10 +219,15 @@ gLineOverlaySummary::~gLineOverlaySummary()
{ {
} }
void gLineOverlaySummary::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) void gLineOverlaySummary::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
Q_UNUSED(painter) Q_UNUSED(painter)
int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().height();
if (!m_visible) { return; } if (!m_visible) { return; }
if (!m_day) { return; } if (!m_day) { return; }

View File

@ -26,7 +26,7 @@ class gLineOverlayBar: public Layer
virtual ~gLineOverlayBar(); virtual ~gLineOverlayBar();
//! \brief The drawing code that fills the OpenGL vertex GLBuffers //! \brief The drawing code that fills the OpenGL vertex GLBuffers
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
virtual EventDataType Miny() { return 0; } virtual EventDataType Miny() { return 0; }
virtual EventDataType Maxy() { return 0; } virtual EventDataType Maxy() { return 0; }
@ -55,7 +55,7 @@ class gLineOverlaySummary: public Layer
gLineOverlaySummary(QString text, int x, int y); gLineOverlaySummary(QString text, int x, int y);
virtual ~gLineOverlaySummary(); virtual ~gLineOverlaySummary();
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
virtual EventDataType Miny() { return 0; } virtual EventDataType Miny() { return 0; }
virtual EventDataType Maxy() { return 0; } virtual EventDataType Maxy() { return 0; }

View File

@ -63,8 +63,13 @@ bool gSegmentChart::isEmpty()
return m_empty; return m_empty;
} }
void gSegmentChart::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) void gSegmentChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().height();
if (!m_visible) { return; } if (!m_visible) { return; }
if (!m_day) { return; } if (!m_day) { return; }

View File

@ -27,7 +27,7 @@ class gSegmentChart : public Layer
virtual ~gSegmentChart(); virtual ~gSegmentChart();
//! \brief The drawing code that fills the Vertex buffers //! \brief The drawing code that fills the Vertex buffers
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
//! \brief Pre-fills a buffer with the data needed to draw //! \brief Pre-fills a buffer with the data needed to draw
virtual void SetDay(Day *d); virtual void SetDay(Day *d);

View File

@ -17,10 +17,15 @@ gStatsLine::gStatsLine(ChannelID code, QString label, QColor textcolor)
: Layer(code), m_label(label), m_textcolor(textcolor) : Layer(code), m_label(label), m_textcolor(textcolor)
{ {
} }
void gStatsLine::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) void gStatsLine::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
Q_UNUSED(painter) Q_UNUSED(painter)
int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().height();
if (!m_visible) { return; } if (!m_visible) { return; }
//if (m_empty) return; //if (m_empty) return;
@ -29,7 +34,6 @@ void gStatsLine::paint(QPainter &painter, gGraph &w, int left, int top, int widt
int z = (width + gYAxis::Margin) / 5; int z = (width + gYAxis::Margin) / 5;
int p = left - gYAxis::Margin; int p = left - gYAxis::Margin;
top += 4; top += 4;
w.renderText(m_label, p, top); w.renderText(m_label, p, top);
@ -49,7 +53,6 @@ void gStatsLine::paint(QPainter &painter, gGraph &w, int left, int top, int widt
} }
void gStatsLine::SetDay(Day *d) void gStatsLine::SetDay(Day *d)
{ {
Layer::SetDay(d); Layer::SetDay(d);

View File

@ -22,7 +22,7 @@ class gStatsLine : public Layer
{ {
public: public:
gStatsLine(ChannelID code, QString label = "", QColor textcolor = Qt::black); gStatsLine(ChannelID code, QString label = "", QColor textcolor = Qt::black);
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
void SetDay(Day *d); void SetDay(Day *d);
protected: protected:

View File

@ -378,8 +378,13 @@ QColor brighten(QColor color)
} }
void SummaryChart::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().height();
if (!m_visible) { return; } if (!m_visible) { return; }
GraphType graphtype = m_graphtype; GraphType graphtype = m_graphtype;

View File

@ -34,7 +34,7 @@ class SummaryChart: public Layer
virtual ~SummaryChart(); virtual ~SummaryChart();
//! \brief Drawing code that fills the Vertex buffers //! \brief Drawing code that fills the Vertex buffers
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
//! \brief Precalculation code prior to drawing. Day object is not needed here, it's just here for Layer compatability. //! \brief Precalculation code prior to drawing. Day object is not needed here, it's just here for Layer compatability.
virtual void SetDay(Day *day = nullptr); virtual void SetDay(Day *day = nullptr);

View File

@ -54,9 +54,13 @@ gXAxis::gXAxis(QColor col, bool fadeout)
gXAxis::~gXAxis() gXAxis::~gXAxis()
{ {
} }
void gXAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) void gXAxis::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
Q_UNUSED(height) int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().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("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")

View File

@ -20,11 +20,14 @@
\brief Draws the XTicker timescales underneath graphs */ \brief Draws the XTicker timescales underneath graphs */
class gXAxis: public Layer class gXAxis: public Layer
{ {
public:
static const int Margin = 20; // How much room does this take up. (Bottom margin)
public: public:
gXAxis(QColor col = Qt::black, bool fadeout = true); gXAxis(QColor col = Qt::black, bool fadeout = true);
virtual ~gXAxis(); virtual ~gXAxis();
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height);
static const int Margin = 20; // How much room does this take up. (Bottom margin) virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
void SetShowMinorLines(bool b) { m_show_minor_lines = b; } void SetShowMinorLines(bool b) { m_show_minor_lines = b; }
void SetShowMajorLines(bool b) { m_show_major_lines = b; } void SetShowMajorLines(bool b) { m_show_major_lines = b; }
bool ShowMinorLines() { return m_show_minor_lines; } bool ShowMinorLines() { return m_show_minor_lines; }
@ -36,7 +39,6 @@ class gXAxis: public Layer
void setUtcFix(bool b) { m_utcfix = b; } void setUtcFix(bool b) { m_utcfix = b; }
protected: protected:
// 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_major_lines;
bool m_show_minor_lines; bool m_show_minor_lines;
bool m_show_minor_ticks; bool m_show_minor_ticks;
@ -54,4 +56,5 @@ class gXAxis: public Layer
QImage m_image; QImage m_image;
}; };
#endif // GXAXIS_H #endif // GXAXIS_H

View File

@ -34,8 +34,13 @@ gXGrid::gXGrid(QColor col)
gXGrid::~gXGrid() gXGrid::~gXGrid()
{ {
} }
void gXGrid::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) void gXGrid::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().height();
int x, y; int x, y;
EventDataType miny, maxy; EventDataType miny, maxy;
@ -153,8 +158,12 @@ gYAxis::gYAxis(QColor col)
gYAxis::~gYAxis() gYAxis::~gYAxis()
{ {
} }
void gYAxis::paint(QPainter &painter, gGraph &w, int left, int top, int width, int height) void gYAxis::paint(QPainter &painter, gGraph &w, const QRegion &region)
{ {
int left = region.boundingRect().left();
int top = region.boundingRect().top();
int width = region.boundingRect().width();
int height = region.boundingRect().height();
int x, y; //,yh=0; int x, y; //,yh=0;

View File

@ -26,7 +26,7 @@ class gXGrid: public Layer
virtual ~gXGrid(); virtual ~gXGrid();
//! \brief Draw the horizontal lines by adding the to the Vertex GLbuffers //! \brief Draw the horizontal lines by adding the to the Vertex GLbuffers
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
//! \brief set the visibility status of Major lines //! \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; }
@ -51,18 +51,17 @@ class gXGrid: public Layer
*/ */
class gYAxis: public Layer class gYAxis: public Layer
{ {
public:
//! \brief Left Margin space in pixels
static const int Margin = 60;
public: public:
//! \brief Construct a gYAxis object, with QColor col for tickers & text //! \brief Construct a gYAxis object, with QColor col for tickers & text
gYAxis(QColor col = Qt::black); gYAxis(QColor col = Qt::black);
virtual ~gYAxis(); virtual ~gYAxis();
//! \brief Draw the horizontal tickers display //! \brief Draw the horizontal tickers display
virtual void paint(QPainter &painter, gGraph &w, int left, int top, int width, int height); virtual void paint(QPainter &painter, gGraph &w, const QRegion &region);
// 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 //! \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; }
@ -79,18 +78,14 @@ class gYAxis: public Layer
//! \brief Formats the ticker value.. Override to implement other types //! \brief Formats the ticker value.. Override to implement other types
virtual const QString Format(EventDataType v, int dp); virtual const QString Format(EventDataType v, int dp);
//! \brief Left Margin space in pixels
static const int Margin = 60;
//! \brief Set the scale of the Y axis values.. Values can be multiplied by this to convert formats //! \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 //! \brief Returns the scale of the Y axis values..
// Values can be multiplied by this to convert formats
float Scale() { return m_yaxis_scale; } float Scale() { return m_yaxis_scale; }
protected: protected:
//bool m_show_major_lines;
//bool m_show_minor_lines;
bool m_show_minor_ticks; bool m_show_minor_ticks;
bool m_show_major_ticks; bool m_show_major_ticks;
float m_yaxis_scale; float m_yaxis_scale;

View File

@ -22,13 +22,10 @@ class gSpacer: public Layer
{ {
public: public:
gSpacer(int space = 20); // orientation? gSpacer(int space = 20); // orientation?
virtual void paint(QPainter &painter, gGraph &g, int left, int top, int width, int height) { virtual void paint(QPainter &painter, gGraph &g, const QRegion &region) {
Q_UNUSED(g) Q_UNUSED(painter);
Q_UNUSED(painter) Q_UNUSED(g);
Q_UNUSED(left) Q_UNUSED(region);
Q_UNUSED(top)
Q_UNUSED(width)
Q_UNUSED(height)
} }
int space() { return m_space; } int space() { return m_space; }

View File

@ -117,7 +117,7 @@ class Layer
\param int width \param int width
\param int height \param int height
*/ */
virtual void paint(QPainter &painter, gGraph &gv, int left, int top, int width, int height) = 0; virtual void paint(QPainter &painter, gGraph &gv, const QRegion &region) = 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);