profile: pass position and gridColor on construction of axes

This is less hassle, than passing these around as parameters.
Note: The values are stored but not yet used ("position" has
not use yet and gridColor is still passed as parameter).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-08-28 20:12:36 +02:00 committed by Dirk Hohndel
parent 766546fc19
commit 277b9234ab
3 changed files with 21 additions and 14 deletions

View file

@ -50,8 +50,10 @@ void DiveCartesianAxis::setTextColor(const QColor &color)
textColor = color; textColor = color;
} }
DiveCartesianAxis::DiveCartesianAxis(double dpr, bool printMode, ProfileScene &scene) : DiveCartesianAxis::DiveCartesianAxis(Position position, color_index_t gridColor, double dpr, bool printMode, ProfileScene &scene) :
printMode(printMode), printMode(printMode),
position(position),
gridColor(gridColor),
scene(scene), scene(scene),
orientation(LeftToRight), orientation(LeftToRight),
min(0), min(0),
@ -359,7 +361,8 @@ QColor DepthAxis::colorForValue(double) const
return QColor(Qt::red); return QColor(Qt::red);
} }
DepthAxis::DepthAxis(double dpr, bool printMode, ProfileScene &scene) : DiveCartesianAxis(dpr, printMode, scene) DepthAxis::DepthAxis(Position position, color_index_t gridColor, double dpr, bool printMode, ProfileScene &scene) :
DiveCartesianAxis(position, gridColor, dpr, printMode, scene)
{ {
changed = true; changed = true;
} }
@ -392,8 +395,9 @@ QString TemperatureAxis::textForValue(double value) const
return QString::number(mkelvin_to_C((int)value)); return QString::number(mkelvin_to_C((int)value));
} }
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, double dpr, bool printMode, ProfileScene &scene) : PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, Position position, color_index_t gridColor,
DiveCartesianAxis(dpr, printMode, scene), double dpr, bool printMode, ProfileScene &scene) :
DiveCartesianAxis(position, gridColor, dpr, printMode, scene),
model(model) model(model)
{ {
} }

View file

@ -32,7 +32,7 @@ public:
enum class Position { enum class Position {
Left, Right, Bottom Left, Right, Bottom
}; };
DiveCartesianAxis(double dpr, bool printMode, ProfileScene &scene); DiveCartesianAxis(Position position, color_index_t gridColor, double dpr, bool printMode, ProfileScene &scene);
~DiveCartesianAxis(); ~DiveCartesianAxis();
void setMinimum(double minimum); void setMinimum(double minimum);
void setMaximum(double maximum); void setMaximum(double maximum);
@ -59,6 +59,8 @@ signals:
void sizeChanged(); void sizeChanged();
protected: protected:
Position position;
color_index_t gridColor;
ProfileScene &scene; ProfileScene &scene;
virtual QString textForValue(double value) const; virtual QString textForValue(double value) const;
virtual QColor colorForValue(double value) const; virtual QColor colorForValue(double value) const;
@ -82,7 +84,7 @@ protected:
class DepthAxis : public DiveCartesianAxis { class DepthAxis : public DiveCartesianAxis {
Q_OBJECT Q_OBJECT
public: public:
DepthAxis(double dpr, bool printMode, ProfileScene &scene); DepthAxis(Position position, color_index_t gridColor, double dpr, bool printMode, ProfileScene &scene);
private: private:
QString textForValue(double value) const override; QString textForValue(double value) const override;
QColor colorForValue(double value) const override; QColor colorForValue(double value) const override;
@ -109,7 +111,8 @@ private:
class PartialGasPressureAxis : public DiveCartesianAxis { class PartialGasPressureAxis : public DiveCartesianAxis {
Q_OBJECT Q_OBJECT
public: public:
PartialGasPressureAxis(const DivePlotDataModel &model, double dpr, bool printMode, ProfileScene &scene); PartialGasPressureAxis(const DivePlotDataModel &model, Position position, color_index_t gridColor,
double dpr, bool printMode, ProfileScene &scene);
void update(int animSpeed); void update(int animSpeed);
double width() const; double width() const;
private: private:

View file

@ -70,13 +70,13 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
maxtime(-1), maxtime(-1),
maxdepth(-1), maxdepth(-1),
dataModel(new DivePlotDataModel(this)), dataModel(new DivePlotDataModel(this)),
profileYAxis(new DepthAxis(dpr, printMode, *this)), profileYAxis(new DepthAxis(DiveCartesianAxis::Position::Left, TIME_GRID, dpr, printMode, *this)),
gasYAxis(new PartialGasPressureAxis(*dataModel, dpr, printMode, *this)), gasYAxis(new PartialGasPressureAxis(*dataModel, DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, *this)),
temperatureAxis(new TemperatureAxis(dpr, printMode, *this)), temperatureAxis(new TemperatureAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, *this)),
timeAxis(new TimeAxis(dpr, printMode, *this)), timeAxis(new TimeAxis(DiveCartesianAxis::Position::Bottom, TIME_GRID, dpr, printMode, *this)),
cylinderPressureAxis(new DiveCartesianAxis(dpr, printMode, *this)), cylinderPressureAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, *this)),
heartBeatAxis(new DiveCartesianAxis(dpr, printMode, *this)), heartBeatAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Left, HR_AXIS, dpr, printMode, *this)),
percentageAxis(new DiveCartesianAxis(dpr, printMode, *this)), percentageAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, *this)),
diveProfileItem(createItem<DiveProfileItem>(*profileYAxis, DivePlotDataModel::DEPTH, 0, dpr)), diveProfileItem(createItem<DiveProfileItem>(*profileYAxis, DivePlotDataModel::DEPTH, 0, dpr)),
temperatureItem(createItem<DiveTemperatureItem>(*temperatureAxis, DivePlotDataModel::TEMPERATURE, 1, dpr)), temperatureItem(createItem<DiveTemperatureItem>(*temperatureAxis, DivePlotDataModel::TEMPERATURE, 1, dpr)),
meanDepthItem(createItem<DiveMeanDepthItem>(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, 1, dpr)), meanDepthItem(createItem<DiveMeanDepthItem>(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, 1, dpr)),