profile: add width() function to DiveCartesian axis

To properly layout the profile we need to know the expected space
required by the vertical axes. In the general case, format the
the text "999". For the partial-pressure-axis, use "0.99".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-08-11 10:57:42 +02:00 committed by Dirk Hohndel
parent f713858ba4
commit 7dd9b65df0
4 changed files with 36 additions and 7 deletions

View file

@ -49,6 +49,7 @@ public:
void setLineSize(qreal lineSize);
void setLine(const QLineF& line);
virtual void updateTicks(int animSpeed, color_index_t color = TIME_GRID);
double width() const;
signals:
void sizeChanged();
@ -57,6 +58,7 @@ protected:
ProfileScene &scene;
virtual QString textForValue(double value) const;
virtual QColor colorForValue(double value) const;
double textWidth(const QString &s) const;
Orientation orientation;
QList<DiveTextItem *> labels;
QList<DiveLineItem *> lines;
@ -105,6 +107,7 @@ class PartialGasPressureAxis : public DiveCartesianAxis {
public:
PartialGasPressureAxis(const DivePlotDataModel &model, double dpr, bool printMode, ProfileScene &scene);
void update(int animSpeed);
double width() const;
private:
const DivePlotDataModel &model;
};