mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
TankBar: use the itemPos as intended
Which actually makes the code much clearer as now the object is at the correct spot on the canvas and the positions inside are relative to that. No more magic gradiants starting at "92" Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5b14ed16ac
commit
e71119b40b
2 changed files with 10 additions and 5 deletions
|
@ -53,6 +53,7 @@ static struct _ItemPos {
|
|||
};
|
||||
_Pos background;
|
||||
_Pos dcLabel;
|
||||
_Pos tankBar;
|
||||
_Axis depth;
|
||||
_Axis partialPressure;
|
||||
_Axis time;
|
||||
|
@ -336,6 +337,9 @@ void ProfileWidget2::setupItemSizes()
|
|||
itemPos.dcLabel.on.setY(100);
|
||||
itemPos.dcLabel.off.setX(-10);
|
||||
itemPos.dcLabel.off.setY(100);
|
||||
|
||||
itemPos.tankBar.on.setX(0);
|
||||
itemPos.tankBar.on.setY(92);
|
||||
}
|
||||
|
||||
void ProfileWidget2::setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis,
|
||||
|
@ -818,6 +822,8 @@ void ProfileWidget2::setProfileState()
|
|||
}
|
||||
rulerItem->setVisible(prefs.rulergraph);
|
||||
tankItem->setVisible(true);
|
||||
tankItem->setPos(itemPos.tankBar.on);
|
||||
|
||||
#define HIDE_ALL(TYPE, CONTAINER) \
|
||||
Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false);
|
||||
HIDE_ALL(DiveHandler, handles);
|
||||
|
|
|
@ -11,19 +11,18 @@ 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));
|
||||
QLinearGradient nitroxGradient(QPointF(0, 0), QPointF(0, 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));
|
||||
QLinearGradient trimixGradient(QPointF(0, 0), QPointF(0, height));
|
||||
trimixGradient.setColorAt(0.0, green);
|
||||
trimixGradient.setColorAt(0.49, green);
|
||||
trimixGradient.setColorAt(0.5, red);
|
||||
|
@ -44,7 +43,7 @@ void TankItem::setData(DivePlotDataModel *model, struct plot_info *plotInfo, str
|
|||
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);
|
||||
QGraphicsRectItem *rect = new QGraphicsRectItem(x, 0, w, height, this);
|
||||
if (gasmix_is_air(gas))
|
||||
rect->setBrush(air);
|
||||
else if (gas->he.permille)
|
||||
|
@ -55,7 +54,7 @@ void TankItem::createBar(qreal x, qreal w, struct gasmix *gas)
|
|||
DiveTextItem *label = new DiveTextItem(rect);
|
||||
label->setText(gasname(gas));
|
||||
label->setBrush(Qt::black);
|
||||
label->setPos(x, yPos);
|
||||
label->setPos(x + 1, 0);
|
||||
label->setAlignment(Qt::AlignBottom | Qt::AlignRight);
|
||||
label->setZValue(101);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue