Now with colors. :)
On Mon, Jan 27, 2014 at 3:14 PM, Tomaz Canabrava <[email protected]> wrote: > the new profile is starting to get userful. >
From eeaf7168399ec3478c6368d9362e1065ecc5e2cb Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 27 Jan 2014 16:13:44 -0200 Subject: [PATCH 2/2] Move the 'getSacColor' out of old profile and use it. This patch makes the colour of the Cylinder Pressure use the Sac Colors. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/graphicsview-common.cpp | 13 +++++++++++++ qt-ui/graphicsview-common.h | 2 +- qt-ui/profile/diveprofileitem.cpp | 6 ++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/qt-ui/graphicsview-common.cpp b/qt-ui/graphicsview-common.cpp index 5415cfe..4d96aa8 100644 --- a/qt-ui/graphicsview-common.cpp +++ b/qt-ui/graphicsview-common.cpp @@ -62,3 +62,16 @@ QColor getColor(const color_indice_t i, bool isGrayscale = false) return profile_color[i].at((isGrayscale) ? 1 : 0); return QColor(Qt::black); } + +QColor getSacColor(int sac, int avg_sac) +{ + int sac_index = 0; + int delta = sac - avg_sac + 7000; + + sac_index = delta / 2000; + if (sac_index < 0) + sac_index = 0; + if (sac_index > SAC_COLORS - 1) + sac_index = SAC_COLORS - 1; + return getColor((color_indice_t)(SAC_COLORS_START_IDX + sac_index), false); +} \ No newline at end of file diff --git a/qt-ui/graphicsview-common.h b/qt-ui/graphicsview-common.h index c00b2d6..5f9dd19 100644 --- a/qt-ui/graphicsview-common.h +++ b/qt-ui/graphicsview-common.h @@ -35,7 +35,7 @@ typedef enum { extern QMap<color_indice_t, QVector<QColor> > profile_color; void fill_profile_color(); QColor getColor(const color_indice_t i); - +QColor getSacColor(int sac, int diveSac); struct text_render_options { double size; color_indice_t color; diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 916bcfa..9d7d841 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -359,9 +359,11 @@ void DiveGasPressureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte QPen pen; pen.setCosmetic(true); pen.setWidth(2); + struct dive *d = getDiveById(dataModel->id()); + struct plot_data *entry = dataModel->data(); Q_FOREACH(const QPolygonF& poly, polygons) { - for (int i = 1, count = poly.count(); i < count; i++) { - pen.setBrush(QBrush(Qt::red)); // TODO: Fix the color. + for (int i = 1, count = poly.count(); i < count; i++, entry++) { + pen.setBrush(getSacColor(entry->sac, d->sac)); painter->setPen(pen); painter->drawLine(poly[i-1],poly[i]); } -- 1.8.5.3
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
