mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: set axis in constructor of TankItem
There is no point in a separate set-axis function if we never change the axis anyway. Make the axis a const-reference to show that it can never be changed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
47d673bda3
commit
7da5719cab
3 changed files with 7 additions and 15 deletions
|
@ -150,7 +150,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
|
|||
mouseFollowerHorizontal(new DiveLineItem()),
|
||||
rulerItem(new RulerItem2()),
|
||||
#endif
|
||||
tankItem(new TankItem()),
|
||||
tankItem(new TankItem(*timeAxis)),
|
||||
shouldCalculateMaxTime(true),
|
||||
shouldCalculateMaxDepth(true),
|
||||
fontPrintScale(1.0)
|
||||
|
@ -318,8 +318,6 @@ void ProfileWidget2::setupItemOnScene()
|
|||
diveComputerText->setAlignment(Qt::AlignRight | Qt::AlignTop);
|
||||
diveComputerText->setBrush(getColor(TIME_TEXT, isGrayscale));
|
||||
|
||||
tankItem->setHorizontalAxis(timeAxis);
|
||||
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
rulerItem->setAxis(timeAxis, profileYAxis);
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
|
||||
static const qreal height = 3.0;
|
||||
|
||||
TankItem::TankItem() :
|
||||
TankItem::TankItem(const DiveCartesianAxis &axis) :
|
||||
hAxis(axis),
|
||||
plotEndTime(-1)
|
||||
{
|
||||
QColor red(PERSIANRED1);
|
||||
|
@ -28,7 +29,6 @@ TankItem::TankItem() :
|
|||
trimixGradient.setColorAt(1.0, red);
|
||||
trimix = trimixGradient;
|
||||
air = blue;
|
||||
hAxis = nullptr;
|
||||
}
|
||||
|
||||
void TankItem::setData(struct plot_info *plotInfo, struct dive *d)
|
||||
|
@ -48,8 +48,8 @@ void TankItem::setData(struct plot_info *plotInfo, struct dive *d)
|
|||
|
||||
void TankItem::createBar(int startTime, int stopTime, struct gasmix gas)
|
||||
{
|
||||
qreal x = hAxis->posAtValue(startTime);
|
||||
qreal w = hAxis->posAtValue(stopTime) - hAxis->posAtValue(startTime);
|
||||
qreal x = hAxis.posAtValue(startTime);
|
||||
qreal w = hAxis.posAtValue(stopTime) - hAxis.posAtValue(startTime);
|
||||
|
||||
// pick the right gradient, size, position and text
|
||||
QGraphicsRectItem *rect = new QGraphicsRectItem(x, 0, w, height, this);
|
||||
|
@ -106,8 +106,3 @@ void TankItem::replot()
|
|||
}
|
||||
createBar(startTime, plotEndTime, gasmix);
|
||||
}
|
||||
|
||||
void TankItem::setHorizontalAxis(DiveCartesianAxis *horizontal)
|
||||
{
|
||||
hAxis = horizontal;
|
||||
}
|
||||
|
|
|
@ -11,14 +11,13 @@
|
|||
class TankItem : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
explicit TankItem();
|
||||
void setHorizontalAxis(DiveCartesianAxis *horizontal);
|
||||
explicit TankItem(const DiveCartesianAxis &axis);
|
||||
void setData(struct plot_info *plotInfo, struct dive *d);
|
||||
|
||||
private:
|
||||
void createBar(int startTime, int stopTime, struct gasmix gas);
|
||||
void replot();
|
||||
DiveCartesianAxis *hAxis;
|
||||
const DiveCartesianAxis &hAxis;
|
||||
int plotEndTime;
|
||||
QBrush air, nitrox, oxygen, trimix;
|
||||
QList<QGraphicsRectItem *> rects;
|
||||
|
|
Loading…
Add table
Reference in a new issue