mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
A little optimisation, and ditch that debug/release folder thing
This commit is contained in:
parent
4b604533ac
commit
614e04ab77
@ -1190,7 +1190,7 @@ void gGraph::ZoomX(double mult, int origin_px)
|
||||
|
||||
void gGraph::DrawTextQue(QPainter &painter)
|
||||
{
|
||||
m_graphview->DrawTextQue(painter);
|
||||
AppSetting->usePixmapCaching() ? m_graphview->DrawTextQueCached(painter) : m_graphview->DrawTextQue(painter);
|
||||
}
|
||||
|
||||
// margin recalcs..
|
||||
|
@ -741,99 +741,86 @@ void gGraphView::dumpInfo()
|
||||
// }
|
||||
}
|
||||
|
||||
bool gGraphView::usePixmapCache()
|
||||
{
|
||||
//use_pixmap_cache is an overide setting
|
||||
return AppSetting->usePixmapCaching();
|
||||
}
|
||||
|
||||
#define CACHE_DRAWTEXT
|
||||
#ifndef CACHE_DRAWTEXT
|
||||
// Render all qued text via QPainter method
|
||||
// Render graphs with QPainter or pixmap caching, depending on preferences
|
||||
void gGraphView::DrawTextQue(QPainter &painter)
|
||||
{
|
||||
int w, h;
|
||||
// process the text drawing queue
|
||||
int h,w;
|
||||
|
||||
// not sure if global antialiasing would be better..
|
||||
//painter.setRenderHint(QPainter::TextAntialiasing, AppSetting->antiAliasing());
|
||||
int items = m_textque.size();
|
||||
for (int i = 0; i < items; ++i) {
|
||||
TextQue &q = m_textque[i];
|
||||
painter.setPen(q.color);
|
||||
painter.setRenderHint(QPainter::TextAntialiasing, q.antialias);
|
||||
QFont font = *q.font;
|
||||
painter.setFont(font);
|
||||
strings_drawn_this_frame += m_textque.size() + m_textqueRect.size();;
|
||||
|
||||
if (q.angle == 0) { // normal text
|
||||
for (const TextQue & q : m_textque) {
|
||||
// can do antialiased text via texture cache fine on mac
|
||||
// Just draw the fonts..
|
||||
painter.setPen(QColor(q.color));
|
||||
painter.setFont(*q.font);
|
||||
|
||||
if (q.angle == 0) {
|
||||
painter.drawText(q.x, q.y, q.text);
|
||||
} else { // rotated text
|
||||
} else {
|
||||
w = painter.fontMetrics().width(q.text);
|
||||
h = painter.fontMetrics().xHeight() + 2;
|
||||
|
||||
painter.translate(q.x, q.y);
|
||||
painter.rotate(-q.angle);
|
||||
painter.drawText(floor(-w / 2.0), floor(-h / 2.0), q.text);
|
||||
painter.drawText(floor(-w / 2.0)-6, floor(-h / 2.0), q.text);
|
||||
painter.rotate(+q.angle);
|
||||
painter.translate(-q.x, -q.y);
|
||||
}
|
||||
strings_drawn_this_frame++;
|
||||
q.text.clear();
|
||||
}
|
||||
|
||||
m_textque.clear();
|
||||
|
||||
items = m_textqueRect.size();
|
||||
for (int i=0; i< items; ++i) {
|
||||
TextQueRect &q = m_textqueRect[i];
|
||||
painter.setPen(q.color);
|
||||
painter.setRenderHint(QPainter::TextAntialiasing, q.antialias);
|
||||
QFont font = *q.font;
|
||||
painter.setFont(font);
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Text Rectangle Queues..
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (q.angle == 0) { // normal text
|
||||
for (const TextQueRect & q : m_textqueRect) {
|
||||
// Just draw the fonts..
|
||||
|
||||
painter.setPen(QColor(q.color));
|
||||
painter.setFont(*q.font);
|
||||
|
||||
if (q.angle == 0) {
|
||||
painter.drawText(q.rect, q.flags, q.text);
|
||||
} else { // rotated text
|
||||
|
||||
int x = q.rect.x();
|
||||
int y = q.rect.y();
|
||||
} else {
|
||||
w = painter.fontMetrics().width(q.text);
|
||||
h = painter.fontMetrics().xHeight() + 2;
|
||||
|
||||
painter.translate(x, y);
|
||||
painter.translate(q.rect.x(), q.rect.y());
|
||||
painter.rotate(-q.angle);
|
||||
painter.drawText(floor(-w / 2.0), floor(-h / 2.0), q.text);
|
||||
painter.rotate(+q.angle);
|
||||
painter.translate(-x, -y);
|
||||
}
|
||||
strings_drawn_this_frame++;
|
||||
q.text.clear();
|
||||
|
||||
painter.translate(-q.rect.x(), -q.rect.y());
|
||||
}
|
||||
|
||||
}
|
||||
m_textqueRect.clear();
|
||||
}
|
||||
|
||||
#else
|
||||
// Render graphs with QPainter or pixmap caching, depending on preferences
|
||||
void gGraphView::DrawTextQue(QPainter &painter)
|
||||
|
||||
const QString z__cacheStr = "%1:%2:%3";
|
||||
|
||||
void gGraphView::DrawTextQueCached(QPainter &painter)
|
||||
{
|
||||
{
|
||||
// process the text drawing queue
|
||||
int h,w;
|
||||
|
||||
for (const auto & q : m_textque) {
|
||||
// can do antialiased text via texture cache fine on mac
|
||||
if (usePixmapCache()) {
|
||||
// Generate the pixmap cache "key"
|
||||
QString hstr = QString("%1:%2:%3").
|
||||
arg(q.text).
|
||||
arg(q.color.name()).
|
||||
arg(q.font->pointSize());
|
||||
|
||||
QString hstr;
|
||||
QPixmap pm;
|
||||
float ww, hh, xxx, yyy;
|
||||
const int buf = 8;
|
||||
int fonta = defaultfont->pointSize();
|
||||
int fontb = mediumfont->pointSize();
|
||||
int fontc = bigfont->pointSize();
|
||||
int size;
|
||||
|
||||
|
||||
for (const TextQue & q : m_textque) {
|
||||
// can do antialiased text via texture cache fine on mac
|
||||
// Generate the pixmap cache "key"
|
||||
size = (q.font == defaultfont) ? fonta : (q.font==mediumfont) ? fontb : (q.font == bigfont) ? fontc : q.font->pointSize();
|
||||
|
||||
hstr = z__cacheStr.arg(q.text).arg(q.color.name()).arg(size);
|
||||
|
||||
if (!QPixmapCache::find(hstr, &pm)) {
|
||||
|
||||
QFontMetrics fm(*q.font);
|
||||
@ -841,7 +828,7 @@ void gGraphView::DrawTextQue(QPainter &painter)
|
||||
w = fm.width(q.text);
|
||||
h = fm.height()+buf;
|
||||
|
||||
pm=QPixmap(w, h);
|
||||
pm = QPixmap(w, h);
|
||||
pm.fill(Qt::transparent);
|
||||
|
||||
QPainter imgpainter(&pm);
|
||||
@ -855,20 +842,16 @@ void gGraphView::DrawTextQue(QPainter &painter)
|
||||
imgpainter.end();
|
||||
|
||||
QPixmapCache::insert(hstr, pm);
|
||||
strings_drawn_this_frame++;
|
||||
} else {
|
||||
//cached
|
||||
strings_cached_this_frame++;
|
||||
}
|
||||
|
||||
h = pm.height();
|
||||
w = pm.width();
|
||||
if (q.angle != 0) {
|
||||
float xxx = q.x - h - (h / 2);
|
||||
float yyy = q.y + w / 2; // + buf / 2;
|
||||
xxx = q.x - h - (h / 2);
|
||||
yyy = q.y + w / 2; // + buf / 2;
|
||||
|
||||
xxx+=4;
|
||||
yyy+=4;
|
||||
xxx += 4;
|
||||
yyy += 4;
|
||||
|
||||
painter.translate(xxx, yyy);
|
||||
painter.rotate(-q.angle);
|
||||
@ -879,132 +862,62 @@ void gGraphView::DrawTextQue(QPainter &painter)
|
||||
QRect r1(q.x - buf / 2 + 4, q.y - h + buf, w, h);
|
||||
painter.drawPixmap(r1, pm);
|
||||
}
|
||||
} else {
|
||||
// Just draw the fonts..
|
||||
painter.setPen(QColor(q.color));
|
||||
painter.setFont(*q.font);
|
||||
|
||||
if (q.angle == 0) {
|
||||
painter.drawText(q.x, q.y, q.text);
|
||||
} else {
|
||||
painter.setFont(*q.font);
|
||||
|
||||
w = painter.fontMetrics().width(q.text);
|
||||
h = painter.fontMetrics().xHeight() + 2;
|
||||
|
||||
painter.translate(q.x, q.y);
|
||||
painter.rotate(-q.angle);
|
||||
painter.drawText(floor(-w / 2.0)-6, floor(-h / 2.0), q.text);
|
||||
painter.rotate(+q.angle);
|
||||
painter.translate(-q.x, -q.y);
|
||||
}
|
||||
strings_drawn_this_frame++;
|
||||
|
||||
}
|
||||
|
||||
//q.text.clear();
|
||||
//q.text.squeeze();
|
||||
}
|
||||
|
||||
m_textque.clear();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Text Rectangle Queues..
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float ww, hh;
|
||||
for (const auto & q : m_textqueRect) {
|
||||
for (const TextQueRect & q : m_textqueRect) {
|
||||
// can do antialiased text via texture cache fine on mac
|
||||
if (usePixmapCache()) {
|
||||
// Generate the pixmap cache "key"
|
||||
QString hstr = QString("%1:%2:%3").
|
||||
arg(q.text).
|
||||
arg(q.color.name()).
|
||||
arg(q.font->pointSize());
|
||||
|
||||
QPixmap pm;
|
||||
size = (q.font == defaultfont) ? fonta : (q.font==mediumfont) ? fontb : (q.font == bigfont) ? fontc : q.font->pointSize();
|
||||
|
||||
hstr = z__cacheStr.arg(q.text).arg(q.color.name()).arg(size);
|
||||
|
||||
if (!QPixmapCache::find(hstr, &pm)) {
|
||||
|
||||
ww = q.rect.width();
|
||||
hh = q.rect.height();
|
||||
w = q.rect.width();
|
||||
h = q.rect.height();
|
||||
|
||||
pm=QPixmap(ww, hh);
|
||||
pm = QPixmap(w, h);
|
||||
|
||||
//int aaw1 = pm.width();
|
||||
pm.fill(Qt::transparent);
|
||||
|
||||
QPainter imgpainter(&pm);
|
||||
|
||||
//int aaw2 = pm.width();
|
||||
imgpainter.setPen(q.color);
|
||||
|
||||
imgpainter.setFont(*q.font);
|
||||
|
||||
imgpainter.setRenderHint(QPainter::Antialiasing, true);
|
||||
imgpainter.setRenderHint(QPainter::TextAntialiasing, true);
|
||||
QRectF rect(0,0, ww, hh);
|
||||
imgpainter.drawText(rect, q.flags, q.text);
|
||||
//int aaw3 = pm.width();
|
||||
imgpainter.drawText(QRect(0,0, w, h), q.flags, q.text);
|
||||
imgpainter.end();
|
||||
|
||||
QPixmapCache::insert(hstr, pm);
|
||||
//int aaw4 = pm.width();
|
||||
strings_drawn_this_frame++;
|
||||
} else {
|
||||
//cached
|
||||
strings_cached_this_frame++;
|
||||
}
|
||||
|
||||
hh = pm.height();
|
||||
ww = pm.width();
|
||||
}
|
||||
if (q.angle != 0) {
|
||||
float xxx = q.rect.x() - hh - (hh / 2);
|
||||
float yyy = q.rect.y() + ww / 2; // + buf / 2;
|
||||
xxx = q.rect.x() - h - (h / 2);
|
||||
yyy = q.rect.y() + w / 2;
|
||||
|
||||
xxx+=4;
|
||||
yyy+=4;
|
||||
xxx += 4;
|
||||
yyy += 4;
|
||||
|
||||
painter.translate(xxx, yyy);
|
||||
painter.rotate(-q.angle);
|
||||
painter.drawPixmap(QRect(0, hh / 2, ww, hh), pm);
|
||||
painter.drawPixmap(QRect(0, hh / 2, w, h), pm);
|
||||
painter.rotate(+q.angle);
|
||||
painter.translate(-xxx, -yyy);
|
||||
} else {
|
||||
//painter.drawPixmap(QPoint(q.rect.x(), q.rect.y()), pm);
|
||||
painter.drawPixmap(q.rect,pm, QRect(0,0,ww,hh));
|
||||
painter.drawPixmap(q.rect,pm, QRect(0,0,w,h));
|
||||
}
|
||||
} else {
|
||||
// Just draw the fonts..
|
||||
|
||||
painter.setPen(QColor(q.color));
|
||||
painter.setFont(*q.font);
|
||||
|
||||
if (q.angle == 0) {
|
||||
painter.drawText(q.rect, q.flags, q.text);
|
||||
} else {
|
||||
painter.setFont(*q.font);
|
||||
|
||||
ww = painter.fontMetrics().width(q.text);
|
||||
hh = painter.fontMetrics().xHeight() + 2;
|
||||
|
||||
painter.translate(q.rect.x(), q.rect.y());
|
||||
painter.rotate(-q.angle);
|
||||
painter.drawText(floor(-ww / 2.0), floor(-hh / 2.0), q.text);
|
||||
painter.rotate(+q.angle);
|
||||
painter.translate(-q.rect.x(), -q.rect.y());
|
||||
}
|
||||
strings_drawn_this_frame++;
|
||||
|
||||
}
|
||||
|
||||
//q.text.clear();
|
||||
//q.text.squeeze();
|
||||
}
|
||||
|
||||
strings_drawn_this_frame += m_textque.size() + m_textqueRect.size();;
|
||||
m_textque.clear();
|
||||
m_textqueRect.clear();
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void gGraphView::AddTextQue(const QString &text, QRectF rect, quint32 flags, float angle, QColor color, QFont *font, bool antialias)
|
||||
{
|
||||
@ -1351,7 +1264,7 @@ bool gGraphView::renderGraphs(QPainter &painter)
|
||||
m_drawlist.clear();
|
||||
|
||||
if (m_graphs.size() > 1) {
|
||||
DrawTextQue(painter);
|
||||
AppSetting->usePixmapCaching() ? DrawTextQueCached(painter) :DrawTextQue(painter);
|
||||
|
||||
// Draw a gradient behind pinned graphs
|
||||
QLinearGradient linearGrad(QPointF(100, 100), QPointF(width() / 2, 100));
|
||||
@ -1426,7 +1339,7 @@ bool gGraphView::renderGraphs(QPainter &painter)
|
||||
|
||||
// lines->setSize(linesize);
|
||||
|
||||
DrawTextQue(painter);
|
||||
AppSetting->usePixmapCaching() ? DrawTextQueCached(painter) :DrawTextQue(painter);
|
||||
//glDisable(GL_TEXTURE_2D);
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
|
||||
@ -1518,7 +1431,7 @@ void gGraphView::paintGL()
|
||||
} else {
|
||||
emit updateRange(graphs_drawn ? m_minx : 0.0F, m_maxx);
|
||||
}
|
||||
DrawTextQue(painter);
|
||||
AppSetting->usePixmapCaching() ? DrawTextQueCached(painter) :DrawTextQue(painter);
|
||||
|
||||
m_tooltip->paint(painter);
|
||||
|
||||
@ -1559,7 +1472,7 @@ void gGraphView::paintGL()
|
||||
// if (usePixmapCache()) xx+=4; else xx-=3;
|
||||
#endif
|
||||
AddTextQue(ss, width(), w / 2, 90, QColor(Qt::black), defaultfont);
|
||||
DrawTextQue(painter);
|
||||
AppSetting->usePixmapCaching() ? DrawTextQueCached(painter) :DrawTextQue(painter);
|
||||
}
|
||||
// painter.setPen(Qt::lightGray);
|
||||
// painter.drawLine(0, 0, 0, height());
|
||||
|
@ -428,6 +428,9 @@ class gGraphView
|
||||
//! \brief Draw all text components using QPainter object painter
|
||||
void DrawTextQue(QPainter &painter);
|
||||
|
||||
//! \brief Draw all text components using QPainter object painter using Pixmapcache
|
||||
void DrawTextQueCached(QPainter &painter);
|
||||
|
||||
//! \brief Returns number of graphs contained (whether they are visible or not)
|
||||
int size() const { return m_graphs.size(); }
|
||||
|
||||
@ -492,9 +495,6 @@ class gGraphView
|
||||
//! \brief Enable or disable the Text Pixmap Caching system preference overide
|
||||
void setUsePixmapCache(bool b) { use_pixmap_cache = b; }
|
||||
|
||||
//! \brief Return whether or not the Pixmap Cache for text rendering is being used.
|
||||
bool usePixmapCache();
|
||||
|
||||
//! \brief Graph drawing routines, returns true if there weren't any graphs to draw
|
||||
bool renderGraphs(QPainter &painter);
|
||||
|
||||
|
@ -477,8 +477,8 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
}
|
||||
}
|
||||
|
||||
EventDataType lastpx, lastpy;
|
||||
EventDataType px, py;
|
||||
double lastpx, lastpy;
|
||||
double px, py;
|
||||
int idx;
|
||||
bool done;
|
||||
double x0, xL;
|
||||
@ -736,8 +736,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
for (int i = idx; i <= siz; i += sam, ptr += sam) {
|
||||
time += rate;
|
||||
// This is much faster than QVector access.
|
||||
data = *ptr + el.offset();
|
||||
data *= gain;
|
||||
data = *ptr * gain;
|
||||
|
||||
// Scale the time scale X to pixel scale X
|
||||
px = ((time - minx) * xmult);
|
||||
@ -747,7 +746,8 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
|
||||
// In accel mode, each pixel has a min/max Y value.
|
||||
// m_drawlist's index is the pixel index for the X pixel axis.
|
||||
int z = round(px); // Hmmm... round may screw this up.
|
||||
//int z = round(px); // Hmmm... round may screw this up.
|
||||
int z = (px>=0.5)?(int(px)+1):int(px);
|
||||
|
||||
if (z < minz) {
|
||||
minz = z; // minz=First pixel
|
||||
@ -790,7 +790,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
}
|
||||
|
||||
float ax1, ay1;
|
||||
QPoint *drl = m_drawlist + minz;
|
||||
QPointF *drl = m_drawlist + minz;
|
||||
// Don't need to cap VertexBuffer here, as it's limited to max_drawlist_size anyway
|
||||
|
||||
|
||||
|
@ -166,7 +166,7 @@ class gLineChart: public Layer
|
||||
static const int max_drawlist_size = 10000;
|
||||
|
||||
//! \brief The list of screen points used for accelerated waveform plots..
|
||||
QPoint m_drawlist[max_drawlist_size];
|
||||
QPointF m_drawlist[max_drawlist_size];
|
||||
|
||||
int subtract_offset;
|
||||
|
||||
|
@ -31,7 +31,7 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
|
||||
int left = region.boundingRect().left();
|
||||
int topp = region.boundingRect().top(); // FIXME: Misspelling intentional.
|
||||
int width = region.boundingRect().width();
|
||||
double width = region.boundingRect().width();
|
||||
int height = region.boundingRect().height();
|
||||
|
||||
if (!m_visible) { return; }
|
||||
@ -42,7 +42,7 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
|
||||
double xx = w.max_x - w.min_x;
|
||||
//double yy = w.max_y - w.min_y;
|
||||
double jj = double(width) / double(xx);
|
||||
double jj = width / xx;
|
||||
|
||||
|
||||
if (xx <= 0) { return; }
|
||||
@ -53,8 +53,8 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
|
||||
float bottom = start_py + height - 25 * w.printScaleY(), top = start_py + 25 * w.printScaleY();
|
||||
|
||||
double X;
|
||||
double Y;
|
||||
qint64 X;
|
||||
qint64 Y;
|
||||
|
||||
QPoint mouse=w.graphView()->currentMousePos();
|
||||
|
||||
@ -108,22 +108,22 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Skip data previous to minx bounds
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
for (; dptr < eptr; dptr++) {
|
||||
X = stime + *tptr;
|
||||
|
||||
if (X >= w.min_x) {
|
||||
for (; dptr < eptr; ++dptr) {
|
||||
|
||||
if ((stime + *tptr) >= w.min_x) {
|
||||
break;
|
||||
}
|
||||
|
||||
tptr++;
|
||||
++tptr;
|
||||
}
|
||||
|
||||
if (m_flt == FT_Span) {
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// FT_Span
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
QBrush brush(m_flag_color);
|
||||
for (; dptr < eptr; dptr++) {
|
||||
//hover = false;
|
||||
|
||||
X = stime + *tptr++;
|
||||
raw = *dptr;
|
||||
@ -132,31 +132,18 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
if (Y > w.max_x) {
|
||||
break;
|
||||
}
|
||||
|
||||
x1 = jj * double(X - w.min_x) + left;
|
||||
m_count++;
|
||||
m_sum += raw;
|
||||
x2 = jj * double(Y - w.min_x) + left;
|
||||
++m_count;
|
||||
|
||||
if (int(x1) == int(x2)) {
|
||||
x2 += 1;
|
||||
}
|
||||
x1 = jj * double(X - w.min_x);
|
||||
x2 = jj * double(Y - w.min_x);
|
||||
|
||||
if (x2 < left) {
|
||||
x2 = left;
|
||||
}
|
||||
x2 += (int(x1)==int(x2)) ? 1 : 0;
|
||||
|
||||
if (x1 > width + left) {
|
||||
x1 = width + left;
|
||||
}
|
||||
x2 = qMax(0.0, x2)+left;
|
||||
x1 = qMin(width, x1)+left;
|
||||
|
||||
QRect rect(x2, start_py, x1-x2, height);
|
||||
QColor col = m_flag_color;
|
||||
// if (rect.contains(mouse)) {
|
||||
// hover = true;
|
||||
// }
|
||||
|
||||
painter.fillRect(rect, QBrush(col));
|
||||
painter.fillRect(QRect(x2, start_py, x1-x2, height), brush);
|
||||
}
|
||||
}/* else if (m_flt == FT_Dot) {
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@ -192,6 +179,13 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// FT_Bar
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
QColor col = m_flag_color;
|
||||
|
||||
QString lab = QString("%1").arg(m_label);
|
||||
GetTextExtent(lab, x, y);
|
||||
|
||||
//int lx,ly;
|
||||
|
||||
for (; dptr < eptr; dptr++) {
|
||||
// hover = false;
|
||||
X = stime + *tptr++;
|
||||
@ -201,7 +195,7 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
break;
|
||||
}
|
||||
|
||||
x1 = jj * (double(X) - double(w.min_x)) + left;
|
||||
x1 = jj * double(X - w.min_x) + left;
|
||||
m_count++;
|
||||
m_sum += raw;
|
||||
int z = start_py + height;
|
||||
@ -209,10 +203,8 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
double d1 = jj * double(raw) * 1000.0;
|
||||
|
||||
|
||||
if ((m_flt == FT_Bar) && (odt == ODT_Bars)) { // || (xx < 3600000)) {
|
||||
if ((m_flt == FT_Bar) && (odt == ODT_Bars)) {
|
||||
QRect rect(x1-d1, top, d1+4, height);
|
||||
QColor col = m_flag_color;
|
||||
|
||||
|
||||
painter.setPen(QPen(col,4));
|
||||
painter.drawPoint(x1, top);
|
||||
@ -220,7 +212,6 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
if (!w.selectingArea() && !m_blockhover && rect.contains(mouse) && !m_hover) {
|
||||
m_hover = true;
|
||||
|
||||
|
||||
QColor col2(230,230,230,128);
|
||||
QRect rect((x1-d1), start_py+2, d1, height-2);
|
||||
if (rect.x() < left) {
|
||||
@ -231,31 +222,16 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
painter.setPen(col);
|
||||
painter.drawRect(rect);
|
||||
|
||||
// Draw text label
|
||||
QString lab = QString("%1 (%2)").arg(schema::channel[m_code].fullname()).arg(raw);
|
||||
GetTextExtent(lab, x, y);
|
||||
// Queue tooltip
|
||||
QString lab2 = QString("%1 (%2)").arg(schema::channel[m_code].fullname()).arg(raw);
|
||||
w.ToolTip(lab2, x1 - 10, start_py + 24 + (3 * w.printScaleY()), TT_AlignRight, AppSetting->tooltipTimeout());
|
||||
|
||||
w.ToolTip(lab, x1 - 10, start_py + 24 + (3 * w.printScaleY()), TT_AlignRight, AppSetting->tooltipTimeout());
|
||||
|
||||
//painter.fillRect(x1 - (x / 2) - x, start_py + 14 + (3 * w.printScaleY()), x+4,y+4, QBrush(QColor(255,255,255,245)));
|
||||
// painter.setPen(QPen(Qt::gray,1));
|
||||
// painter.drawRect(x1 - (x / 2) - x, start_py + 14 + (3 * w.printScaleY()), x+4,y+4);
|
||||
// w.renderText(lab, x1 - (x / 2)+2 - x, start_py + 14 + y + (3 * w.printScaleY()),0);
|
||||
|
||||
// painter.drawLine(rect.x(), top, rect.x()+d1, top);
|
||||
// painter.drawLine(rect.x(), bottom, rect.x()+d1, bottom);
|
||||
// painter.drawLine(rect.x(), top, rect.x(), bottom);
|
||||
|
||||
// col = COLOR_Gold;
|
||||
// hover = true;
|
||||
painter.setPen(QPen(col,3));
|
||||
} else {
|
||||
painter.setPen(QPen(col,1));
|
||||
}
|
||||
painter.drawLine(x1, top, x1, bottom);
|
||||
if (xx < (3600000)) {
|
||||
QString lab = QString("%1").arg(m_label);
|
||||
GetTextExtent(lab, x, y);
|
||||
w.renderText(lab, x1 - (x / 2), top - y + (5 * w.printScaleY()),0);
|
||||
}
|
||||
|
||||
@ -268,7 +244,6 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
if (!w.selectingArea() && !m_blockhover && QRect(x1-2, topp, 6, height).contains(mouse) && !m_hover) {
|
||||
// only want to draw the highlight/label once per frame
|
||||
m_hover = true;
|
||||
//b = true;
|
||||
|
||||
// Draw text label
|
||||
QString lab = QString("%1 (%2)").arg(schema::channel[m_code].fullname()).arg(raw);
|
||||
@ -276,12 +251,6 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
|
||||
w.ToolTip(lab, x1 - 10, start_py + 24 + (3 * w.printScaleY()), TT_AlignRight, tooltipTimeout);
|
||||
|
||||
// painter.fillRect(x1 - (x / 2) - x, start_py + 14 + (3 * w.printScaleY()), x+4,y+4, QBrush(QColor(255,255,255,245)));
|
||||
// painter.setPen(QPen(Qt::gray,1));
|
||||
// painter.drawRect(x1 - (x / 2) - x, start_py + 14 + (3 * w.printScaleY()), x+4,y+4);
|
||||
// w.renderText(lab, x1 - (x / 2)+2 - x, start_py + 14 + y + (3 * w.printScaleY()),0);
|
||||
|
||||
//x1-=1;
|
||||
QColor col = m_flag_color;
|
||||
col.setAlpha(60);
|
||||
painter.setPen(QPen(col, 4));
|
||||
@ -297,17 +266,12 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
painter.setPen(QPen(col,1));
|
||||
painter.drawLine(x1, start_py+14, x1, z);
|
||||
painter.setPen(QPen(m_flag_color,1));
|
||||
// painter.drawLine(x1, z, x1, z - 12);
|
||||
painter.drawLine(x1, start_py+2, x1, start_py + 14);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
bool gLineOverlayBar::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
|
||||
|
@ -85,7 +85,7 @@ void gXAxis::paint(QPainter &painter, gGraph &w, const QRegion ®ion)
|
||||
|
||||
QFontMetrics fm(*defaultfont);
|
||||
|
||||
bool usepixmap = w.graphView()->usePixmapCache(); // Whether or not to use pixmap caching
|
||||
bool usepixmap = AppSetting->usePixmapCaching(); // Whether or not to use pixmap caching
|
||||
|
||||
if (!usepixmap || (usepixmap && w.invalidate_xAxisImage)) {
|
||||
// Redraw graph xaxis labels and ticks either to pixmap or directly to screen
|
||||
|
@ -67,25 +67,25 @@ public:
|
||||
AppWideSetting(Preferences *pref)
|
||||
: PrefSettings(pref)
|
||||
{
|
||||
initPref(STR_IS_Multithreading, idealThreads() > 1);
|
||||
m_multithreading = initPref(STR_IS_Multithreading, idealThreads() > 1).toBool();
|
||||
initPref(STR_US_ShowPerformance, false);
|
||||
initPref(STR_US_ShowDebug, false);
|
||||
initPref(STR_AS_CalendarVisible, true);
|
||||
initPref(STR_US_ScrollDampening, (int)50);
|
||||
initPref(STR_US_TooltipTimeout, (int)2500);
|
||||
initPref(STR_AS_GraphHeight, 180.0);
|
||||
m_scrollDampening = initPref(STR_US_ScrollDampening, (int)50).toInt();
|
||||
m_tooltipTimeout = initPref(STR_US_TooltipTimeout, (int)2500).toInt();
|
||||
m_graphHeight=initPref(STR_AS_GraphHeight, 180).toInt();
|
||||
initPref(STR_AS_DailyPanelWidth, 350.0);
|
||||
initPref(STR_AS_RightPanelWidth, 230.0);
|
||||
initPref(STR_AS_AntiAliasing, true);
|
||||
m_antiAliasing=initPref(STR_AS_AntiAliasing, true).toBool();
|
||||
initPref(STR_AS_GraphSnapshots, true);
|
||||
initPref(STR_AS_Animations, true);
|
||||
initPref(STR_AS_SquareWave, false);
|
||||
m_squareWavePlots = initPref(STR_AS_SquareWave, false).toBool();
|
||||
initPref(STR_AS_AllowYAxisScaling, true);
|
||||
initPref(STR_AS_GraphTooltips, true);
|
||||
initPref(STR_AS_UsePixmapCaching, false);
|
||||
m_usePixmapCaching = initPref(STR_AS_UsePixmapCaching, false).toBool();
|
||||
initPref(STR_AS_OverlayType, ODT_Bars);
|
||||
initPref(STR_AS_OverviewLinechartMode, OLC_Bartop);
|
||||
initPref(STR_AS_LineThickness, 1.0);
|
||||
m_lineThickness=initPref(STR_AS_LineThickness, 1.0).toFloat();
|
||||
initPref(STR_AS_LineCursorMode, true);
|
||||
initPref(STR_AS_RightSidebarVisible, true);
|
||||
initPref(STR_CS_UserEventPieChart, false);
|
||||
@ -107,6 +107,11 @@ public:
|
||||
initPref(STR_GEN_ShowAboutDialog, 0); // default to about screen, set to -1 afterwards
|
||||
}
|
||||
|
||||
bool m_usePixmapCaching, m_antiAliasing, m_squareWavePlots;
|
||||
int m_tooltipTimeout, m_graphHeight, m_scrollDampening;
|
||||
bool m_multithreading;
|
||||
float m_lineThickness;
|
||||
|
||||
QString versionString() const { return getPref(STR_PREF_VersionString).toString(); }
|
||||
bool updatesAutoCheck() const { return getPref(STR_GEN_UpdatesAutoCheck).toBool(); }
|
||||
bool allowEarlyUpdates() const { return getPref(STR_PREF_AllowEarlyUpdates).toBool(); }
|
||||
@ -118,35 +123,35 @@ public:
|
||||
QString profileName() const { return getPref(STR_GEN_Profile).toString(); }
|
||||
bool autoLaunchImport() const { return getPref(STR_US_AutoLaunchImport).toBool(); }
|
||||
bool cacheSessions() const { return getPref(STR_IS_CacheSessions).toBool(); }
|
||||
bool multithreading() const { return getPref(STR_IS_Multithreading).toBool(); }
|
||||
bool multithreading() const { return m_multithreading; }
|
||||
bool showDebug() const { return getPref(STR_US_ShowDebug).toBool(); }
|
||||
bool showPerformance() const { return getPref(STR_US_ShowPerformance).toBool(); }
|
||||
//! \brief Whether to show the calendar
|
||||
bool calendarVisible() const { return getPref(STR_AS_CalendarVisible).toBool(); }
|
||||
int scrollDampening() const { return getPref(STR_US_ScrollDampening).toInt(); }
|
||||
int tooltipTimeout() const { return getPref(STR_US_TooltipTimeout).toInt(); }
|
||||
int scrollDampening() const { return m_scrollDampening; }
|
||||
int tooltipTimeout() const { return m_tooltipTimeout; }
|
||||
//! \brief Returns the normal (unscaled) height of a graph
|
||||
int graphHeight() const { return getPref(STR_AS_GraphHeight).toInt(); }
|
||||
int graphHeight() const { return m_graphHeight; }
|
||||
//! \brief Returns the normal (unscaled) height of a graph
|
||||
int dailyPanelWidth() const { return getPref(STR_AS_DailyPanelWidth).toInt(); }
|
||||
//! \brief Returns the normal (unscaled) height of a graph
|
||||
int rightPanelWidth() const { return getPref(STR_AS_RightPanelWidth).toInt(); }
|
||||
//! \brief Returns true if AntiAliasing (the graphical smoothing method) is enabled
|
||||
bool antiAliasing() const { return getPref(STR_AS_AntiAliasing).toBool(); }
|
||||
bool antiAliasing() const { return m_antiAliasing; }
|
||||
//! \brief Returns true if renderPixmap function is in use, which takes snapshots of graphs
|
||||
bool graphSnapshots() const { return getPref(STR_AS_GraphSnapshots).toBool(); }
|
||||
//! \brief Returns true if Graphical animations & Transitions will be drawn
|
||||
bool animations() const { return getPref(STR_AS_Animations).toBool(); }
|
||||
//! \brief Returns true if PixmapCaching acceleration will be used
|
||||
bool usePixmapCaching() const { return getPref(STR_AS_UsePixmapCaching).toBool(); }
|
||||
inline const bool & usePixmapCaching() const { return m_usePixmapCaching; }
|
||||
//! \brief Returns true if Square Wave plots are preferred (where possible)
|
||||
bool squareWavePlots() const { return getPref(STR_AS_SquareWave).toBool(); }
|
||||
bool squareWavePlots() const { return m_squareWavePlots; }
|
||||
//! \brief Whether to allow double clicking on Y-Axis labels to change vertical scaling mode
|
||||
bool allowYAxisScaling() const { return getPref(STR_AS_AllowYAxisScaling).toBool(); }
|
||||
//! \brief Whether to show graph tooltips
|
||||
bool graphTooltips() const { return getPref(STR_AS_GraphTooltips).toBool(); }
|
||||
//! \brief Pen width of line plots
|
||||
float lineThickness() const { return getPref(STR_AS_LineThickness).toFloat(); }
|
||||
float lineThickness() const { return m_lineThickness; }
|
||||
//! \brief Whether to show line cursor
|
||||
bool lineCursorMode() const { return getPref(STR_AS_LineCursorMode).toBool(); }
|
||||
//! \brief Whether to show the right sidebar
|
||||
@ -170,29 +175,29 @@ public:
|
||||
void setProfileName(QString name) { setPref(STR_GEN_Profile, name); }
|
||||
void setAutoLaunchImport(bool b) { setPref(STR_US_AutoLaunchImport, b); }
|
||||
void setCacheSessions(bool c) { setPref(STR_IS_CacheSessions, c); }
|
||||
void setMultithreading(bool enabled) { setPref(STR_IS_Multithreading, enabled); }
|
||||
void setMultithreading(bool b) { setPref(STR_IS_Multithreading, m_multithreading = b); }
|
||||
void setShowDebug(bool b) { setPref(STR_US_ShowDebug, b); }
|
||||
void setShowPerformance(bool b) { setPref(STR_US_ShowPerformance, b); }
|
||||
//! \brief Sets whether to display the (Daily View) Calendar
|
||||
void setCalendarVisible(bool b) { setPref(STR_AS_CalendarVisible, b); }
|
||||
void setScrollDampening(int i) { setPref(STR_US_ScrollDampening, i); }
|
||||
void setTooltipTimeout(int i) { setPref(STR_US_TooltipTimeout, i); }
|
||||
void setScrollDampening(int i) { setPref(STR_US_ScrollDampening, m_scrollDampening=i); }
|
||||
void setTooltipTimeout(int i) { setPref(STR_US_TooltipTimeout, m_tooltipTimeout=i); }
|
||||
//! \brief Set the normal (unscaled) height of a graph.
|
||||
void setGraphHeight(int height) { setPref(STR_AS_GraphHeight, height); }
|
||||
void setGraphHeight(int height) { setPref(STR_AS_GraphHeight, m_graphHeight=height); }
|
||||
//! \brief Set the normal (unscaled) height of a graph.
|
||||
void setDailyPanelWidth(int width) { setPref(STR_AS_DailyPanelWidth, width); }
|
||||
//! \brief Set the normal (unscaled) height of a graph.
|
||||
void setRightPanelWidth(int width) { setPref(STR_AS_RightPanelWidth, width); }
|
||||
//! \brief Set to true to turn on AntiAliasing (the graphical smoothing method)
|
||||
void setAntiAliasing(bool aa) { setPref(STR_AS_AntiAliasing, aa); }
|
||||
void setAntiAliasing(bool aa) { setPref(STR_AS_AntiAliasing, m_antiAliasing=aa); }
|
||||
//! \brief Set to true if renderPixmap functions are in use, which takes snapshots of graphs.
|
||||
void setGraphSnapshots(bool gs) { setPref(STR_AS_GraphSnapshots, gs); }
|
||||
//! \brief Set to true if Graphical animations & Transitions will be drawn
|
||||
void setAnimations(bool anim) { setPref(STR_AS_Animations, anim); }
|
||||
//! \brief Set to true to use Pixmap Caching of Text and other graphics caching speedup techniques
|
||||
void setUsePixmapCaching(bool b) { setPref(STR_AS_UsePixmapCaching, b); }
|
||||
void setUsePixmapCaching(bool b) { setPref(STR_AS_UsePixmapCaching, m_usePixmapCaching=b); }
|
||||
//! \brief Set whether or not to useSquare Wave plots (where possible)
|
||||
void setSquareWavePlots(bool sw) { setPref(STR_AS_SquareWave, sw); }
|
||||
void setSquareWavePlots(bool sw) { setPref(STR_AS_SquareWave, m_squareWavePlots=sw); }
|
||||
//! \brief Sets the type of overlay flags (which are displayed over the Flow Waveform)
|
||||
void setOverlayType(OverlayDisplayType od) { setPref(STR_AS_OverlayType, (int)od); }
|
||||
//! \brief Sets whether to allow double clicking on Y-Axis labels to change vertical scaling mode
|
||||
@ -204,7 +209,7 @@ public:
|
||||
setPref(STR_AS_OverviewLinechartMode, (int)od);
|
||||
}
|
||||
//! \brief Set the pen width of line plots.
|
||||
void setLineThickness(float size) { setPref(STR_AS_LineThickness, size); }
|
||||
void setLineThickness(float size) { setPref(STR_AS_LineThickness, m_lineThickness=size); }
|
||||
//! \brief Sets whether to display Line Cursor
|
||||
void setLineCursorMode(bool b) { setPref(STR_AS_LineCursorMode, b); }
|
||||
//! \brief Sets whether to display the right sidebar
|
||||
|
@ -60,10 +60,12 @@ class Preferences
|
||||
}
|
||||
|
||||
//! \brief Create a preference and set the default if it doesn't exists
|
||||
void init(QString name, QVariant value) {
|
||||
if (!contains(name)) {
|
||||
p_preferences[name] = value;
|
||||
QVariant & init(QString name, QVariant value) {
|
||||
auto it = p_preferences.find(name);
|
||||
if (it == p_preferences.end()) {
|
||||
return p_preferences[name] = value;
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
//! \brief Returns true if preference 'name' exists, and contains a boolean true value
|
||||
@ -142,11 +144,11 @@ class PrefSettings
|
||||
(*m_pref)[name] = value;
|
||||
}
|
||||
|
||||
inline void initPref(QString name, QVariant value) {
|
||||
m_pref->init(name, value);
|
||||
inline QVariant & initPref(QString name, QVariant value) {
|
||||
return m_pref->init(name, value);
|
||||
}
|
||||
|
||||
inline QVariant getPref(QString name) const {
|
||||
inline QVariant & getPref(QString name) const {
|
||||
return (*m_pref)[name];
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ DEFINES += LOCK_RESMED_SESSIONS
|
||||
|
||||
CONFIG += c++11
|
||||
CONFIG += rtti
|
||||
CONFIG-=debug_and_release
|
||||
|
||||
#static {
|
||||
# CONFIG += static
|
||||
@ -116,14 +117,9 @@ macx {
|
||||
QMAKE_BUNDLE_DATA += HelpFiles
|
||||
message("Setting up Translations & Help Transfers")
|
||||
} else {
|
||||
CONFIG(debug, debug|release) {
|
||||
DDIR = $$OUT_PWD/debug/Translations
|
||||
HELPDIR = $$OUT_PWD/debug/Help
|
||||
}
|
||||
CONFIG(release, debug|release) {
|
||||
DDIR = $$OUT_PWD/release/Translations
|
||||
HELPDIR = $$OUT_PWD/release/Help
|
||||
}
|
||||
DDIR = $$OUT_PWD/Translations
|
||||
HELPDIR = $$OUT_PWD/Help
|
||||
|
||||
TRANS_FILES += $$PWD/../Translations/*.qm
|
||||
HELP_FILES += $$PWD/help/*.qch
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user