mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: set textColor in constructor of DiveCartesianAxis
There were virtual functions to calculate the label colors based on the value of the label. However, these functions only returned constant values. Therefore, just set these in the constructors. Thuse, a few virtual functions and derived classes can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
ea59e5cf7a
commit
3a79f3e78a
4 changed files with 16 additions and 57 deletions
|
@ -19,11 +19,12 @@ void DiveCartesianAxis::setBounds(double minimum, double maximum)
|
||||||
}
|
}
|
||||||
|
|
||||||
DiveCartesianAxis::DiveCartesianAxis(Position position, int integralDigits, int fractionalDigits, color_index_t gridColor,
|
DiveCartesianAxis::DiveCartesianAxis(Position position, int integralDigits, int fractionalDigits, color_index_t gridColor,
|
||||||
bool textVisible, bool linesVisible,
|
QColor textColor, bool textVisible, bool linesVisible,
|
||||||
double dpr, double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene) :
|
double dpr, double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene) :
|
||||||
printMode(printMode),
|
printMode(printMode),
|
||||||
position(position),
|
position(position),
|
||||||
fractionalDigits(fractionalDigits),
|
fractionalDigits(fractionalDigits),
|
||||||
|
textColor(textColor),
|
||||||
scene(scene),
|
scene(scene),
|
||||||
orientation(LeftToRight),
|
orientation(LeftToRight),
|
||||||
min(0),
|
min(0),
|
||||||
|
@ -85,11 +86,6 @@ void DiveCartesianAxis::setTransform(double a, double b)
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor DiveCartesianAxis::colorForValue(double) const
|
|
||||||
{
|
|
||||||
return QColor(Qt::black);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void emptyList(QList<T *> &list, int steps, int speed)
|
void emptyList(QList<T *> &list, int steps, int speed)
|
||||||
{
|
{
|
||||||
|
@ -218,7 +214,7 @@ void DiveCartesianAxis::updateLabels(int numTicks, double firstPosScreen, double
|
||||||
firstPosScreen + i * stepScreen :
|
firstPosScreen + i * stepScreen :
|
||||||
firstPosScreen - i * stepScreen;
|
firstPosScreen - i * stepScreen;
|
||||||
|
|
||||||
labels[i]->set(textForValue(firstValue), colorForValue(firstValue));
|
labels[i]->set(textForValue(firstValue), textColor);
|
||||||
switch (position) {
|
switch (position) {
|
||||||
default:
|
default:
|
||||||
case Position::Bottom:
|
case Position::Bottom:
|
||||||
|
@ -245,7 +241,7 @@ void DiveCartesianAxis::updateLabels(int numTicks, double firstPosScreen, double
|
||||||
position == Position::Left ? Qt::AlignVCenter | Qt::AlignLeft:
|
position == Position::Left ? Qt::AlignVCenter | Qt::AlignLeft:
|
||||||
Qt::AlignVCenter | Qt::AlignRight;
|
Qt::AlignVCenter | Qt::AlignRight;
|
||||||
DiveTextItem *label = new DiveTextItem(dpr, labelScale, alignFlags, this);
|
DiveTextItem *label = new DiveTextItem(dpr, labelScale, alignFlags, this);
|
||||||
label->set(textForValue(firstValue), colorForValue(firstValue));
|
label->set(textForValue(firstValue), textColor);
|
||||||
label->setZValue(1);
|
label->setZValue(1);
|
||||||
labels.push_back(label);
|
labels.push_back(label);
|
||||||
switch (position) {
|
switch (position) {
|
||||||
|
@ -411,13 +407,3 @@ std::pair<double, double> DiveCartesianAxis::screenMinMax() const
|
||||||
return position == Position::Bottom ? std::make_pair(rect.left(), rect.right())
|
return position == Position::Bottom ? std::make_pair(rect.left(), rect.right())
|
||||||
: std::make_pair(rect.top(), rect.bottom());
|
: std::make_pair(rect.top(), rect.bottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor DepthAxis::colorForValue(double) const
|
|
||||||
{
|
|
||||||
return QColor(Qt::red);
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor TimeAxis::colorForValue(double) const
|
|
||||||
{
|
|
||||||
return QColor(Qt::blue);
|
|
||||||
}
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
DiveCartesianAxis(Position position, int integralDigits, int fractionalDigits, color_index_t gridColor,
|
DiveCartesianAxis(Position position, int integralDigits, int fractionalDigits, color_index_t gridColor,
|
||||||
bool textVisible, bool linesVisible,
|
QColor textColor, bool textVisible, bool linesVisible,
|
||||||
double dpr, double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene);
|
double dpr, double labelScale, bool printMode, bool isGrayscale, ProfileScene &scene);
|
||||||
~DiveCartesianAxis();
|
~DiveCartesianAxis();
|
||||||
void setBounds(double min, double max);
|
void setBounds(double min, double max);
|
||||||
|
@ -57,9 +57,9 @@ private:
|
||||||
int fractionalDigits;
|
int fractionalDigits;
|
||||||
QRectF rect; // Rectangle to fill with grid lines
|
QRectF rect; // Rectangle to fill with grid lines
|
||||||
QPen gridPen;
|
QPen gridPen;
|
||||||
|
QColor textColor;
|
||||||
ProfileScene &scene;
|
ProfileScene &scene;
|
||||||
QString textForValue(double value) const;
|
QString textForValue(double value) const;
|
||||||
virtual QColor colorForValue(double value) const;
|
|
||||||
Orientation orientation;
|
Orientation orientation;
|
||||||
QList<DiveTextItem *> labels;
|
QList<DiveTextItem *> labels;
|
||||||
QList<DiveLineItem *> lines;
|
QList<DiveLineItem *> lines;
|
||||||
|
@ -86,26 +86,4 @@ private:
|
||||||
void updateLines(int numTicks, double firstPosScreen, double stepScreen, int animSpeed);
|
void updateLines(int numTicks, double firstPosScreen, double stepScreen, int animSpeed);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DepthAxis : public DiveCartesianAxis {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
using DiveCartesianAxis::DiveCartesianAxis;
|
|
||||||
private:
|
|
||||||
QColor colorForValue(double value) const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TimeAxis : public DiveCartesianAxis {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
using DiveCartesianAxis::DiveCartesianAxis;
|
|
||||||
private:
|
|
||||||
QColor colorForValue(double value) const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TemperatureAxis : public DiveCartesianAxis {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
using DiveCartesianAxis::DiveCartesianAxis;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIVECARTESIANAXIS_H
|
#endif // DIVECARTESIANAXIS_H
|
||||||
|
|
|
@ -47,19 +47,19 @@ 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(DiveCartesianAxis::Position::Left, 3, 0, TIME_GRID, true, true,
|
profileYAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Left, 3, 0, TIME_GRID, Qt::red, true, true,
|
||||||
dpr, 1.0, printMode, isGrayscale, *this)),
|
dpr, 1.0, printMode, isGrayscale, *this)),
|
||||||
gasYAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, 1, 2, TIME_GRID, true, true,
|
gasYAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, 1, 2, TIME_GRID, Qt::black, true, true,
|
||||||
dpr, 0.7, printMode, isGrayscale, *this)),
|
dpr, 0.7, printMode, isGrayscale, *this)),
|
||||||
temperatureAxis(new TemperatureAxis(DiveCartesianAxis::Position::Right, 3, 0, TIME_GRID, false, false,
|
temperatureAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, 3, 0, TIME_GRID, Qt::black, false, false,
|
||||||
dpr, 1.0, printMode, isGrayscale, *this)),
|
dpr, 1.0, printMode, isGrayscale, *this)),
|
||||||
timeAxis(new TimeAxis(DiveCartesianAxis::Position::Bottom, 2, 2, TIME_GRID, true, true,
|
timeAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Bottom, 2, 2, TIME_GRID, Qt::blue, true, true,
|
||||||
dpr, 1.0, printMode, isGrayscale, *this)),
|
dpr, 1.0, printMode, isGrayscale, *this)),
|
||||||
cylinderPressureAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, 4, 0, TIME_GRID, false, false,
|
cylinderPressureAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, 4, 0, TIME_GRID, Qt::black, false, false,
|
||||||
dpr, 1.0, printMode, isGrayscale, *this)),
|
dpr, 1.0, printMode, isGrayscale, *this)),
|
||||||
heartBeatAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Left, 3, 0, HR_AXIS, true, true,
|
heartBeatAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Left, 3, 0, HR_AXIS, Qt::black, true, true,
|
||||||
dpr, 0.7, printMode, isGrayscale, *this)),
|
dpr, 0.7, printMode, isGrayscale, *this)),
|
||||||
percentageAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, 2, 0, TIME_GRID, false, false,
|
percentageAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, 2, 0, TIME_GRID, Qt::black, false, false,
|
||||||
dpr, 0.7, printMode, isGrayscale, *this)),
|
dpr, 0.7, printMode, isGrayscale, *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)),
|
||||||
|
|
|
@ -15,8 +15,6 @@ class DivePlannerPointsModel;
|
||||||
class DivePlotDataModel;
|
class DivePlotDataModel;
|
||||||
|
|
||||||
class AbstractProfilePolygonItem;
|
class AbstractProfilePolygonItem;
|
||||||
class DepthAxis;
|
|
||||||
class DiveCartesianAxis;
|
|
||||||
class DiveCalculatedCeiling;
|
class DiveCalculatedCeiling;
|
||||||
class DiveCalculatedTissue;
|
class DiveCalculatedTissue;
|
||||||
class DiveCartesianAxis;
|
class DiveCartesianAxis;
|
||||||
|
@ -30,11 +28,8 @@ class DiveProfileItem;
|
||||||
class DiveReportedCeiling;
|
class DiveReportedCeiling;
|
||||||
class DiveTemperatureItem;
|
class DiveTemperatureItem;
|
||||||
class DiveTextItem;
|
class DiveTextItem;
|
||||||
class PartialGasPressureAxis;
|
|
||||||
class PartialPressureGasItem;
|
class PartialPressureGasItem;
|
||||||
class TankItem;
|
class TankItem;
|
||||||
class TemperatureAxis;
|
|
||||||
class TimeAxis;
|
|
||||||
|
|
||||||
class ProfileScene : public QGraphicsScene {
|
class ProfileScene : public QGraphicsScene {
|
||||||
public:
|
public:
|
||||||
|
@ -71,10 +66,10 @@ private:
|
||||||
|
|
||||||
DivePlotDataModel *dataModel;
|
DivePlotDataModel *dataModel;
|
||||||
struct plot_info plotInfo;
|
struct plot_info plotInfo;
|
||||||
DepthAxis *profileYAxis;
|
DiveCartesianAxis *profileYAxis;
|
||||||
DiveCartesianAxis *gasYAxis;
|
DiveCartesianAxis *gasYAxis;
|
||||||
TemperatureAxis *temperatureAxis;
|
DiveCartesianAxis *temperatureAxis;
|
||||||
TimeAxis *timeAxis;
|
DiveCartesianAxis *timeAxis;
|
||||||
DiveCartesianAxis *cylinderPressureAxis;
|
DiveCartesianAxis *cylinderPressureAxis;
|
||||||
DiveCartesianAxis *heartBeatAxis;
|
DiveCartesianAxis *heartBeatAxis;
|
||||||
DiveCartesianAxis *percentageAxis;
|
DiveCartesianAxis *percentageAxis;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue