From f19ab2e4fdd42528601b81a293f9f74ca2374225 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 11 Sep 2021 22:14:45 +0200 Subject: [PATCH] profile: set DiveCartesianAxis::fontLabelScale in constructor This never changes, no need for the complexities of a setter function. Signed-off-by: Berthold Stoeger --- profile-widget/divecartesianaxis.cpp | 14 ++++---------- profile-widget/divecartesianaxis.h | 5 ++--- profile-widget/profilescene.cpp | 17 +++++++---------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp index 6d47acf5e..f90c0b039 100644 --- a/profile-widget/divecartesianaxis.cpp +++ b/profile-widget/divecartesianaxis.cpp @@ -11,12 +11,6 @@ static const double labelSpaceHorizontal = 2.0; // space between label and ticks static const double labelSpaceVertical = 2.0; // space between label and ticks -void DiveCartesianAxis::setFontLabelScale(qreal scale) -{ - labelScale = scale; - changed = true; -} - void DiveCartesianAxis::setBounds(double minimum, double maximum) { changed = !IS_FP_SAME(max, maximum) || !IS_FP_SAME(min, minimum); @@ -25,7 +19,7 @@ void DiveCartesianAxis::setBounds(double minimum, double maximum) } DiveCartesianAxis::DiveCartesianAxis(Position position, color_index_t gridColor, double dpr, - bool printMode, bool isGrayscale, ProfileScene &scene) : + double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene) : printMode(printMode), position(position), gridColor(gridColor), @@ -36,7 +30,7 @@ DiveCartesianAxis::DiveCartesianAxis(Position position, color_index_t gridColor, interval(1), textVisibility(true), lineVisibility(true), - labelScale(1.0), + labelScale(labelScale), changed(true), dpr(dpr) { @@ -390,8 +384,8 @@ QString TemperatureAxis::textForValue(double value) const } PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, Position position, color_index_t gridColor, - double dpr, bool printMode, bool isGrayscale, ProfileScene &scene) : - DiveCartesianAxis(position, gridColor, dpr, printMode, isGrayscale, scene), + double dpr, double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene) : + DiveCartesianAxis(position, gridColor, dpr, labelScale, printMode, isGrayscale, scene), model(model) { } diff --git a/profile-widget/divecartesianaxis.h b/profile-widget/divecartesianaxis.h index 36c6db87e..adfdd16a2 100644 --- a/profile-widget/divecartesianaxis.h +++ b/profile-widget/divecartesianaxis.h @@ -33,12 +33,11 @@ public: Left, Right, Bottom }; DiveCartesianAxis(Position position, color_index_t gridColor, double dpr, - bool printMode, bool isGrayscale, ProfileScene &scene); + double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene); ~DiveCartesianAxis(); void setBounds(double min, double max); void setTickInterval(double interval); void setOrientation(Orientation orientation); - void setFontLabelScale(qreal scale); double minimum() const; double maximum() const; std::pair screenMinMax() const; @@ -108,7 +107,7 @@ class PartialGasPressureAxis : public DiveCartesianAxis { Q_OBJECT public: PartialGasPressureAxis(const DivePlotDataModel &model, Position position, color_index_t gridColor, - double dpr, bool printMode, bool isGrayscale, ProfileScene &scene); + double dpr, double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene); void update(int animSpeed); double width() const; private: diff --git a/profile-widget/profilescene.cpp b/profile-widget/profilescene.cpp index 522541b0c..779514a14 100644 --- a/profile-widget/profilescene.cpp +++ b/profile-widget/profilescene.cpp @@ -47,13 +47,13 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) : maxtime(-1), maxdepth(-1), dataModel(new DivePlotDataModel(this)), - profileYAxis(new DepthAxis(DiveCartesianAxis::Position::Left, TIME_GRID, dpr, printMode, isGrayscale, *this)), - gasYAxis(new PartialGasPressureAxis(*dataModel, DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, isGrayscale, *this)), - temperatureAxis(new TemperatureAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, isGrayscale, *this)), - timeAxis(new TimeAxis(DiveCartesianAxis::Position::Bottom, TIME_GRID, dpr, printMode, isGrayscale, *this)), - cylinderPressureAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, isGrayscale, *this)), - heartBeatAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Left, HR_AXIS, dpr, printMode, isGrayscale, *this)), - percentageAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, isGrayscale, *this)), + profileYAxis(new DepthAxis(DiveCartesianAxis::Position::Left, TIME_GRID, dpr, 1.0, printMode, isGrayscale, *this)), + gasYAxis(new PartialGasPressureAxis(*dataModel, DiveCartesianAxis::Position::Right, TIME_GRID, dpr, 0.7, printMode, isGrayscale, *this)), + temperatureAxis(new TemperatureAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, 1.0, printMode, isGrayscale, *this)), + timeAxis(new TimeAxis(DiveCartesianAxis::Position::Bottom, TIME_GRID, dpr, 1.0, printMode, isGrayscale, *this)), + cylinderPressureAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, 1.0, printMode, isGrayscale, *this)), + heartBeatAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Left, HR_AXIS, dpr, 0.7, printMode, isGrayscale, *this)), + percentageAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, 0.7, printMode, isGrayscale, *this)), diveProfileItem(createItem(*profileYAxis, DivePlotDataModel::DEPTH, 0, dpr)), temperatureItem(createItem(*temperatureAxis, DivePlotDataModel::TEMPERATURE, 1, dpr)), meanDepthItem(createItem(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, 1, dpr)), @@ -86,16 +86,13 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) : gasYAxis->setOrientation(DiveCartesianAxis::BottomToTop); gasYAxis->setTickInterval(1); - gasYAxis->setFontLabelScale(0.7); #ifndef SUBSURFACE_MOBILE heartBeatAxis->setOrientation(DiveCartesianAxis::BottomToTop); heartBeatAxis->setTickInterval(10); - heartBeatAxis->setFontLabelScale(0.7); percentageAxis->setOrientation(DiveCartesianAxis::BottomToTop); percentageAxis->setTickInterval(10); - percentageAxis->setFontLabelScale(0.7); #endif temperatureAxis->setOrientation(DiveCartesianAxis::BottomToTop);