mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-07 19:33:24 +00:00
profile: make DiveCartesian axis grayscale aware
I doubt that this is necessary, but since most of the rest of the profile code passes "isGrayscale" to "getColor()", do the same here for consistency. To avoid storing the isGrayscale flag, just create the pens at construction time and store those. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2615ba02bb
commit
a031f3444c
3 changed files with 33 additions and 32 deletions
|
@ -11,18 +11,6 @@
|
||||||
static const double labelSpaceHorizontal = 2.0; // space between label and ticks
|
static const double labelSpaceHorizontal = 2.0; // space between label and ticks
|
||||||
static const double labelSpaceVertical = 2.0; // space between label and ticks
|
static const double labelSpaceVertical = 2.0; // space between label and ticks
|
||||||
|
|
||||||
QPen DiveCartesianAxis::gridPen() const
|
|
||||||
{
|
|
||||||
QPen pen;
|
|
||||||
pen.setColor(getColor(TIME_GRID));
|
|
||||||
/* cosmetic width() == 0 for lines in printMode
|
|
||||||
* having setCosmetic(true) and width() > 0 does not work when
|
|
||||||
* printing on OSX and Linux */
|
|
||||||
pen.setWidth(DiveCartesianAxis::printMode ? 0 : 2);
|
|
||||||
pen.setCosmetic(true);
|
|
||||||
return pen;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiveCartesianAxis::setFontLabelScale(qreal scale)
|
void DiveCartesianAxis::setFontLabelScale(qreal scale)
|
||||||
{
|
{
|
||||||
labelScale = scale;
|
labelScale = scale;
|
||||||
|
@ -45,7 +33,8 @@ void DiveCartesianAxis::setMinimum(double minimum)
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiveCartesianAxis::DiveCartesianAxis(Position position, color_index_t gridColor, double dpr, bool printMode, ProfileScene &scene) :
|
DiveCartesianAxis::DiveCartesianAxis(Position position, color_index_t gridColor, double dpr,
|
||||||
|
bool printMode, bool isGrayscale, ProfileScene &scene) :
|
||||||
printMode(printMode),
|
printMode(printMode),
|
||||||
position(position),
|
position(position),
|
||||||
gridColor(gridColor),
|
gridColor(gridColor),
|
||||||
|
@ -60,7 +49,17 @@ DiveCartesianAxis::DiveCartesianAxis(Position position, color_index_t gridColor,
|
||||||
changed(true),
|
changed(true),
|
||||||
dpr(dpr)
|
dpr(dpr)
|
||||||
{
|
{
|
||||||
setPen(gridPen());
|
QPen pen;
|
||||||
|
pen.setColor(getColor(TIME_GRID, isGrayscale));
|
||||||
|
/* cosmetic width() == 0 for lines in printMode
|
||||||
|
* having setCosmetic(true) and width() > 0 does not work when
|
||||||
|
* printing on OSX and Linux */
|
||||||
|
pen.setWidth(DiveCartesianAxis::printMode ? 0 : 2);
|
||||||
|
pen.setCosmetic(true);
|
||||||
|
setPen(pen);
|
||||||
|
|
||||||
|
pen.setBrush(getColor(gridColor, isGrayscale));
|
||||||
|
gridPen = pen;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiveCartesianAxis::~DiveCartesianAxis()
|
DiveCartesianAxis::~DiveCartesianAxis()
|
||||||
|
@ -241,9 +240,7 @@ void DiveCartesianAxis::updateTicks(int animSpeed)
|
||||||
childPos = begin - i * stepSize;
|
childPos = begin - i * stepSize;
|
||||||
}
|
}
|
||||||
DiveLineItem *line = new DiveLineItem(this);
|
DiveLineItem *line = new DiveLineItem(this);
|
||||||
QPen pen = gridPen();
|
line->setPen(gridPen);
|
||||||
pen.setBrush(getColor(gridColor));
|
|
||||||
line->setPen(pen);
|
|
||||||
line->setZValue(0);
|
line->setZValue(0);
|
||||||
lines.push_back(line);
|
lines.push_back(line);
|
||||||
if (position == Position::Bottom) {
|
if (position == Position::Bottom) {
|
||||||
|
@ -372,8 +369,9 @@ QColor DepthAxis::colorForValue(double) const
|
||||||
return QColor(Qt::red);
|
return QColor(Qt::red);
|
||||||
}
|
}
|
||||||
|
|
||||||
DepthAxis::DepthAxis(Position position, color_index_t gridColor, double dpr, bool printMode, ProfileScene &scene) :
|
DepthAxis::DepthAxis(Position position, color_index_t gridColor, double dpr,
|
||||||
DiveCartesianAxis(position, gridColor, dpr, printMode, scene)
|
bool printMode, bool isGrayscale, ProfileScene &scene) :
|
||||||
|
DiveCartesianAxis(position, gridColor, dpr, printMode, isGrayscale, scene)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
@ -408,8 +406,8 @@ QString TemperatureAxis::textForValue(double value) const
|
||||||
}
|
}
|
||||||
|
|
||||||
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, Position position, color_index_t gridColor,
|
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, Position position, color_index_t gridColor,
|
||||||
double dpr, bool printMode, ProfileScene &scene) :
|
double dpr, bool printMode, bool isGrayscale, ProfileScene &scene) :
|
||||||
DiveCartesianAxis(position, gridColor, dpr, printMode, scene),
|
DiveCartesianAxis(position, gridColor, dpr, printMode, isGrayscale, scene),
|
||||||
model(model)
|
model(model)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QGraphicsLineItem>
|
#include <QGraphicsLineItem>
|
||||||
|
#include <QPen>
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
#include "core/units.h"
|
#include "core/units.h"
|
||||||
|
|
||||||
|
@ -21,7 +22,6 @@ class DiveCartesianAxis : public QObject, public QGraphicsLineItem {
|
||||||
Q_PROPERTY(qreal y WRITE setY READ y)
|
Q_PROPERTY(qreal y WRITE setY READ y)
|
||||||
private:
|
private:
|
||||||
bool printMode;
|
bool printMode;
|
||||||
QPen gridPen() const;
|
|
||||||
public:
|
public:
|
||||||
enum Orientation {
|
enum Orientation {
|
||||||
TopToBottom,
|
TopToBottom,
|
||||||
|
@ -32,7 +32,8 @@ public:
|
||||||
enum class Position {
|
enum class Position {
|
||||||
Left, Right, Bottom
|
Left, Right, Bottom
|
||||||
};
|
};
|
||||||
DiveCartesianAxis(Position position, color_index_t gridColor, double dpr, bool printMode, ProfileScene &scene);
|
DiveCartesianAxis(Position position, color_index_t gridColor, double dpr,
|
||||||
|
bool printMode, bool isGrayscale, ProfileScene &scene);
|
||||||
~DiveCartesianAxis();
|
~DiveCartesianAxis();
|
||||||
void setMinimum(double minimum);
|
void setMinimum(double minimum);
|
||||||
void setMaximum(double maximum);
|
void setMaximum(double maximum);
|
||||||
|
@ -58,6 +59,7 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
Position position;
|
Position position;
|
||||||
QRectF rect; // Rectangle to fill with grid lines
|
QRectF rect; // Rectangle to fill with grid lines
|
||||||
|
QPen gridPen;
|
||||||
color_index_t gridColor;
|
color_index_t gridColor;
|
||||||
ProfileScene &scene;
|
ProfileScene &scene;
|
||||||
virtual QString textForValue(double value) const;
|
virtual QString textForValue(double value) const;
|
||||||
|
@ -79,7 +81,8 @@ protected:
|
||||||
class DepthAxis : public DiveCartesianAxis {
|
class DepthAxis : public DiveCartesianAxis {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DepthAxis(Position position, color_index_t gridColor, double dpr, bool printMode, ProfileScene &scene);
|
DepthAxis(Position position, color_index_t gridColor, double dpr,
|
||||||
|
bool printMode, bool isGrayscale, 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;
|
||||||
|
@ -107,7 +110,7 @@ class PartialGasPressureAxis : public DiveCartesianAxis {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
PartialGasPressureAxis(const DivePlotDataModel &model, Position position, color_index_t gridColor,
|
PartialGasPressureAxis(const DivePlotDataModel &model, Position position, color_index_t gridColor,
|
||||||
double dpr, bool printMode, ProfileScene &scene);
|
double dpr, bool printMode, bool isGrayscale, ProfileScene &scene);
|
||||||
void update(int animSpeed);
|
void update(int animSpeed);
|
||||||
double width() const;
|
double width() const;
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -47,13 +47,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(DiveCartesianAxis::Position::Left, TIME_GRID, dpr, printMode, *this)),
|
profileYAxis(new DepthAxis(DiveCartesianAxis::Position::Left, TIME_GRID, dpr, printMode, isGrayscale, *this)),
|
||||||
gasYAxis(new PartialGasPressureAxis(*dataModel, DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, *this)),
|
gasYAxis(new PartialGasPressureAxis(*dataModel, DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, isGrayscale, *this)),
|
||||||
temperatureAxis(new TemperatureAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, *this)),
|
temperatureAxis(new TemperatureAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, isGrayscale, *this)),
|
||||||
timeAxis(new TimeAxis(DiveCartesianAxis::Position::Bottom, TIME_GRID, dpr, printMode, *this)),
|
timeAxis(new TimeAxis(DiveCartesianAxis::Position::Bottom, TIME_GRID, dpr, printMode, isGrayscale, *this)),
|
||||||
cylinderPressureAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, *this)),
|
cylinderPressureAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, isGrayscale, *this)),
|
||||||
heartBeatAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Left, HR_AXIS, dpr, printMode, *this)),
|
heartBeatAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Left, HR_AXIS, dpr, printMode, isGrayscale, *this)),
|
||||||
percentageAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, printMode, *this)),
|
percentageAxis(new DiveCartesianAxis(DiveCartesianAxis::Position::Right, TIME_GRID, dpr, 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)),
|
||||||
meanDepthItem(createItem<DiveMeanDepthItem>(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, 1, dpr)),
|
meanDepthItem(createItem<DiveMeanDepthItem>(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, 1, dpr)),
|
||||||
|
|
Loading…
Add table
Reference in a new issue