mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Add gas text to tank bars
Also restructures the code a bit to make it a little more sane and changes the colors slightly. With these changes I think we can claim that this Fixes #557 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fa3c18d83b
commit
87ca15c5c3
4 changed files with 51 additions and 36 deletions
4
color.h
4
color.h
|
@ -20,6 +20,7 @@
|
|||
#define RIOGRANDE1 QColor::fromRgbF(0.8, 0.8, 0.0, 1)
|
||||
#define EARLSGREEN1 QColor::fromRgbF(0.8, 0.8, 0.2, 1)
|
||||
#define FORESTGREEN1 QColor::fromRgbF(0.1, 0.5, 0.1, 1)
|
||||
#define NITROX_GREEN QColor::fromRgbF(0, 0.54, 0.375, 1)
|
||||
|
||||
// Reds
|
||||
#define PERSIANRED1 QColor::fromRgbF(0.8, 0.2, 0.2, 1)
|
||||
|
@ -49,6 +50,7 @@
|
|||
#define GOVERNORBAY1_MED_TRANS QColor::fromRgbF(0.2, 0.2, 0.8, 0.5)
|
||||
#define ROYALBLUE2 QColor::fromRgbF(0.2, 0.2, 0.9, 1)
|
||||
#define ROYALBLUE2_LOW_TRANS QColor::fromRgbF(0.2, 0.2, 0.9, 0.75)
|
||||
#define AIR_BLUE QColor::fromRgbF(0.25, 0.75, 1.0, 1)
|
||||
|
||||
// Yellows / BROWNS
|
||||
#define SPRINGWOOD1 QColor::fromRgbF(0.95, 0.95, 0.9, 1)
|
||||
|
@ -56,6 +58,8 @@
|
|||
#define BROOM1_LOWER_TRANS QColor::fromRgbF(1.0, 1.0, 0.1, 0.9)
|
||||
#define PEANUT QColor::fromRgbF(0.5, 0.2, 0.1, 1.0)
|
||||
#define PEANUT_MED_TRANS QColor::fromRgbF(0.5, 0.2, 0.1, 0.5)
|
||||
#define NITROX_YELLOW QColor::fromRgbF(0.98, 0.89, 0.07, 1.0)
|
||||
|
||||
// Magentas
|
||||
#define MEDIUMREDVIOLET1_HIGHER_TRANS QColor::fromRgbF(0.7, 0.2, 0.7, 0.1)
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ void ProfileWidget2::setupItemSizes()
|
|||
itemPos.partialPressure.pos.off.setX(110);
|
||||
itemPos.partialPressure.pos.off.setY(63);
|
||||
itemPos.partialPressure.expanded.setP1(QPointF(0, 0));
|
||||
itemPos.partialPressure.expanded.setP2(QPointF(0, 30));
|
||||
itemPos.partialPressure.expanded.setP2(QPointF(0, 27));
|
||||
|
||||
// cylinder axis config
|
||||
itemPos.cylinder.pos.on.setX(3);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "tankitem.h"
|
||||
#include "diveplotdatamodel.h"
|
||||
#include "divetextitem.h"
|
||||
#include "profile.h"
|
||||
#include <QGradient>
|
||||
#include <QDebug>
|
||||
|
@ -10,6 +11,25 @@ TankItem::TankItem(QObject *parent) :
|
|||
dive(0),
|
||||
pInfo(0)
|
||||
{
|
||||
yPos = 92;
|
||||
height = 3;
|
||||
QColor red(PERSIANRED1);
|
||||
QColor blue(AIR_BLUE);
|
||||
QColor yellow(NITROX_YELLOW);
|
||||
QColor green(NITROX_GREEN);
|
||||
QLinearGradient nitroxGradient(QPointF(0, yPos), QPointF(0, yPos + height));
|
||||
nitroxGradient.setColorAt(0.0, green);
|
||||
nitroxGradient.setColorAt(0.49, green);
|
||||
nitroxGradient.setColorAt(0.5, yellow);
|
||||
nitroxGradient.setColorAt(1.0, yellow);
|
||||
nitrox = nitroxGradient;
|
||||
QLinearGradient trimixGradient(QPointF(0, yPos), QPointF(0, yPos + height));
|
||||
trimixGradient.setColorAt(0.0, green);
|
||||
trimixGradient.setColorAt(0.49, green);
|
||||
trimixGradient.setColorAt(0.5, red);
|
||||
trimixGradient.setColorAt(1.0, red);
|
||||
trimix = trimixGradient;
|
||||
air = blue;
|
||||
}
|
||||
|
||||
void TankItem::setData(DivePlotDataModel *model, struct plot_info *plotInfo, struct dive *d)
|
||||
|
@ -21,6 +41,25 @@ void TankItem::setData(DivePlotDataModel *model, struct plot_info *plotInfo, str
|
|||
modelDataChanged();
|
||||
}
|
||||
|
||||
void TankItem::createBar(qreal x, qreal w, struct gasmix *gas)
|
||||
{
|
||||
// pick the right gradient, size, position and text
|
||||
QGraphicsRectItem *rect = new QGraphicsRectItem(x, yPos, w, height, this);
|
||||
if (gasmix_is_air(gas))
|
||||
rect->setBrush(air);
|
||||
else if (gas->he.permille)
|
||||
rect->setBrush(trimix);
|
||||
else
|
||||
rect->setBrush(nitrox);
|
||||
rects.push_back(rect);
|
||||
DiveTextItem *label = new DiveTextItem(rect);
|
||||
label->setText(gasname(gas));
|
||||
label->setBrush(Qt::black);
|
||||
label->setPos(x, yPos);
|
||||
label->setAlignment(Qt::AlignBottom | Qt::AlignRight);
|
||||
label->setZValue(101);
|
||||
}
|
||||
|
||||
void TankItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||
{
|
||||
// We don't have enougth data to calculate things, quit.
|
||||
|
@ -34,59 +73,27 @@ void TankItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &b
|
|||
}
|
||||
rects.clear();
|
||||
|
||||
// define the position on the profile
|
||||
qreal width, left, yPos, height;
|
||||
yPos = 95.0;
|
||||
height = 3.0;
|
||||
|
||||
// set up the three patterns
|
||||
QLinearGradient nitrox(QPointF(0, yPos), QPointF(0, yPos + height));
|
||||
nitrox.setColorAt(0.0, Qt::green);
|
||||
nitrox.setColorAt(0.49, Qt::green);
|
||||
nitrox.setColorAt(0.5, Qt::yellow);
|
||||
nitrox.setColorAt(1.0, Qt::yellow);
|
||||
QLinearGradient trimix(QPointF(0, yPos), QPointF(0, yPos + height));
|
||||
trimix.setColorAt(0.0, Qt::green);
|
||||
trimix.setColorAt(0.49, Qt::green);
|
||||
trimix.setColorAt(0.5, Qt::red);
|
||||
trimix.setColorAt(1.0, Qt::red);
|
||||
QColor air(Qt::blue);
|
||||
air.lighter();
|
||||
|
||||
// walk the list and figure out which tanks go where
|
||||
struct plot_data *entry = pInfo->entry;
|
||||
int cylIdx = entry->cylinderindex;
|
||||
int i = -1;
|
||||
int startTime = 0;
|
||||
struct gasmix *gas = &dive->cylinder[cylIdx].gasmix;
|
||||
qreal width, left;
|
||||
while (++i < pInfo->nr) {
|
||||
entry = &pInfo->entry[i];
|
||||
if (entry->cylinderindex == cylIdx)
|
||||
continue;
|
||||
width = hAxis->posAtValue(entry->sec) - hAxis->posAtValue(startTime);
|
||||
left = hAxis->posAtValue(startTime);
|
||||
QGraphicsRectItem *rect = new QGraphicsRectItem(left, yPos, width, height, this);
|
||||
if (gasmix_is_air(gas))
|
||||
rect->setBrush(air);
|
||||
else if (gas->he.permille)
|
||||
rect->setBrush(trimix);
|
||||
else
|
||||
rect->setBrush(nitrox);
|
||||
rects << rect;
|
||||
createBar(left, width, gas);
|
||||
cylIdx = entry->cylinderindex;
|
||||
gas = &dive->cylinder[cylIdx].gasmix;
|
||||
startTime = entry->sec;
|
||||
}
|
||||
width = hAxis->posAtValue(entry->sec) - hAxis->posAtValue(startTime);
|
||||
left = hAxis->posAtValue(startTime);
|
||||
QGraphicsRectItem *rect = new QGraphicsRectItem(left, yPos, width, height, this);
|
||||
if (gasmix_is_air(gas))
|
||||
rect->setBrush(air);
|
||||
else if (gas->he.permille)
|
||||
rect->setBrush(trimix);
|
||||
else
|
||||
rect->setBrush(nitrox);
|
||||
rects << rect;
|
||||
createBar(left, width, gas);
|
||||
}
|
||||
|
||||
void TankItem::setHorizontalAxis(DiveCartesianAxis *horizontal)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QGraphicsItem>
|
||||
#include <QModelIndex>
|
||||
#include <QBrush>
|
||||
#include "divelineitem.h"
|
||||
#include "divecartesianaxis.h"
|
||||
#include "dive.h"
|
||||
|
@ -23,11 +24,14 @@ public slots:
|
|||
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
||||
|
||||
private:
|
||||
void createBar(qreal x, qreal w, struct gasmix *gas);
|
||||
DivePlotDataModel *dataModel;
|
||||
DiveCartesianAxis *hAxis;
|
||||
int hDataColumn;
|
||||
struct dive *dive;
|
||||
struct plot_info *pInfo;
|
||||
qreal yPos, height;
|
||||
QBrush air, nitrox, trimix;
|
||||
QList<QGraphicsRectItem *> rects;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue