profile: set visibility of text and lines in constructor

The visibility of axis text / lines is never changed, so set
in axis constructor.

Moreover, instead of rendering the lines/text and then setting
them invisible, do not render them if invisible.

The whole thing appears superfluous, since the proper way to
not show lines/text is to just not call updateTicks on the
axis. But in the future we might want to have axes with text
but no lines, so keep for now.

Since this means breaking out the text / line rendering
into their own function, we might rename some variables to
make them (at least somewhat) more clear.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-10-03 21:51:56 +02:00 committed by Dirk Hohndel
parent a7a7bd182e
commit 7bc90b6dfe
3 changed files with 83 additions and 95 deletions

View file

@ -33,8 +33,9 @@ public:
Left, Right, Bottom
};
DiveCartesianAxis(Position position, int integralDigits, int fractionalDigits, color_index_t gridColor, double dpr,
double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene);
DiveCartesianAxis(Position position, int integralDigits, int fractionalDigits, color_index_t gridColor,
bool textVisible, bool linesVisible,
double dpr, double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene);
~DiveCartesianAxis();
void setBounds(double min, double max);
void setTransform(double a, double b = 0.0);
@ -51,7 +52,7 @@ public:
double width() const; // only for vertical axes
double height() const; // only for horizontal axes
protected:
private:
Position position;
int fractionalDigits;
QRectF rect; // Rectangle to fill with grid lines
@ -81,6 +82,9 @@ protected:
double to(double x) const;
double from(double y) const;
} transform;
void updateLabels(int numTicks, double firstPosScreen, double firstValue, double stepScreen, double stepValue, int animSpeed);
void updateLines(int numTicks, double firstPosScreen, double stepScreen, int animSpeed);
};
class DepthAxis : public DiveCartesianAxis {