mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: calculate maximum label sizes on construction
Instead of calculating the label sizes of the axes when relayouting the chart, calculate them at construction time. To do so, pass the digits before and after the decimal comma to the constructor. This is not so much an optimization thing, but rather an first stab at more general label rendering. Time, of course, will always be an exception. But hopefully the remaining values can be done more generally. Note that currently this code is a total mess. For example, the labels for the temperature axes are not converted to F if needed. And therefore also not shown. This will need some major rethinking. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f19ab2e4fd
commit
322e2baa8d
5 changed files with 44 additions and 32 deletions
|
|
@ -32,7 +32,7 @@ public:
|
|||
enum class Position {
|
||||
Left, Right, Bottom
|
||||
};
|
||||
DiveCartesianAxis(Position position, color_index_t gridColor, double dpr,
|
||||
DiveCartesianAxis(Position position, int integralDigits, int fractionalDigits, color_index_t gridColor, double dpr,
|
||||
double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene);
|
||||
~DiveCartesianAxis();
|
||||
void setBounds(double min, double max);
|
||||
|
|
@ -62,7 +62,6 @@ 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;
|
||||
|
|
@ -74,6 +73,7 @@ protected:
|
|||
double labelScale;
|
||||
bool changed;
|
||||
double dpr;
|
||||
double labelWidth, labelHeight; // maximum expected sizes of label width and height
|
||||
};
|
||||
|
||||
class DepthAxis : public DiveCartesianAxis {
|
||||
|
|
@ -106,10 +106,9 @@ private:
|
|||
class PartialGasPressureAxis : public DiveCartesianAxis {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PartialGasPressureAxis(const DivePlotDataModel &model, Position position, color_index_t gridColor,
|
||||
double dpr, double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene);
|
||||
PartialGasPressureAxis(const DivePlotDataModel &model, Position position, int integralDigits, int fractionalDigits,
|
||||
color_index_t gridColor, double dpr, double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene);
|
||||
void update(int animSpeed);
|
||||
double width() const;
|
||||
private:
|
||||
const DivePlotDataModel &model;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue