mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Paint the dive red if the user is breaking ceiling on the planner.
This patch paints the dive red if the user is breaking ceiling on the planner - it's quite fast, it analizes the depth over the max(tissue_1 .. tissue_16) and changes the color of the profile. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d9abf885c2
commit
4e3793c053
3 changed files with 27 additions and 4 deletions
|
@ -678,8 +678,6 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b
|
|||
/* We will break out when we hit the surface */
|
||||
do {
|
||||
/* Ascend to next stop depth */
|
||||
if (deco_allowed_depth(tissue_tolerance, diveplan->surface_pressure / 1000.0, dive, 1) > depth)
|
||||
fprintf(stderr, "user provided way point above ceiling\n");
|
||||
int deltad = ascend_velocity(depth, avg_depth, bottom_time) * TIMESTEP;
|
||||
if (ascend_velocity(depth, avg_depth, bottom_time) != last_ascend_rate) {
|
||||
plan_add_segment(diveplan, clock - previous_point_time, depth, o2, he, po2, false);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "divecartesianaxis.h"
|
||||
#include "graphicsview-common.h"
|
||||
#include "divetextitem.h"
|
||||
#include "profilewidget2.h"
|
||||
#include "profile.h"
|
||||
#include "dive.h"
|
||||
#include "preferences.h"
|
||||
|
@ -136,6 +137,17 @@ void DiveProfileItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
|||
}
|
||||
}
|
||||
|
||||
int DiveProfileItem::maxCeiling(int row)
|
||||
{
|
||||
int max = -1;
|
||||
plot_data *entry = dataModel->data().entry + row;
|
||||
for (int tissue = 0; tissue < 16; tissue++) {
|
||||
if (max < entry->ceilings[tissue])
|
||||
max = entry->ceilings[tissue];
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||
{
|
||||
if (!shouldCalculateStuff(topLeft, bottomRight))
|
||||
|
@ -147,6 +159,18 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI
|
|||
|
||||
show_reported_ceiling = prefs.dcceiling;
|
||||
reported_ceiling_in_red = prefs.redceiling;
|
||||
profileColor = getColor(DEPTH_BOTTOM);
|
||||
|
||||
int currState = qobject_cast<ProfileWidget2 *>(scene()->views().first())->currentState;
|
||||
if (currState == ProfileWidget2::PLAN) {
|
||||
plot_data *entry = dataModel->data().entry + dataModel->rowCount() - 1;
|
||||
for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) {
|
||||
int max = maxCeiling(i);
|
||||
if (entry->depth < max) {
|
||||
profileColor = QColor(Qt::red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Show any ceiling we may have encountered */
|
||||
if (prefs.dcceiling && !prefs.redceiling) {
|
||||
|
@ -166,7 +190,7 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI
|
|||
// This is the blueish gradient that the Depth Profile should have.
|
||||
// It's a simple QLinearGradient with 2 stops, starting from top to bottom.
|
||||
QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
|
||||
pat.setColorAt(1, getColor(DEPTH_BOTTOM));
|
||||
pat.setColorAt(1, profileColor);
|
||||
pat.setColorAt(0, getColor(DEPTH_TOP));
|
||||
setBrush(QBrush(pat));
|
||||
|
||||
|
|
|
@ -77,10 +77,11 @@ public:
|
|||
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
||||
virtual void settingsChanged();
|
||||
void plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color);
|
||||
|
||||
int maxCeiling(int row);
|
||||
private:
|
||||
unsigned int show_reported_ceiling;
|
||||
unsigned int reported_ceiling_in_red;
|
||||
QColor profileColor;
|
||||
};
|
||||
|
||||
class DiveTemperatureItem : public AbstractProfilePolygonItem {
|
||||
|
|
Loading…
Add table
Reference in a new issue