mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 17:23:23 +00:00
profile: rename printFontScale to dpr (device pixel ratio)
The printFontScale is used to scale up fonts (and icons) when rendering to high-DPI devices. With absolute scaling, this will also be used to scale the size of different chart regions, line thickness, etc. Therefore, give it an more appropriate name. "Device pixel ratio", which is a well established term, seems to appropriately describe the concept. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
d28f4d5347
commit
f713858ba4
15 changed files with 97 additions and 98 deletions
|
@ -107,10 +107,10 @@ void Printer::render(int pages)
|
|||
QWebElementCollection collection = webView->page()->mainFrame()->findAllElements(".diveprofile");
|
||||
|
||||
// A "standard" profile has about 600 pixels in height.
|
||||
// Scale the fonts in the printed profile accordingly.
|
||||
// Scale the items in the printed profile accordingly.
|
||||
// This is arbitrary, but it seems to work reasonably well.
|
||||
double printFontScale = collection.count() > 0 ? collection[0].geometry().size().height() / 600.0 : 1.0;
|
||||
auto profile = std::make_unique<ProfileScene>(printFontScale, true, !printOptions.color_selected);
|
||||
double dpr = collection.count() > 0 ? collection[0].geometry().size().height() / 600.0 : 1.0;
|
||||
auto profile = std::make_unique<ProfileScene>(dpr, true, !printOptions.color_selected);
|
||||
|
||||
// render the Qwebview
|
||||
QPainter painter;
|
||||
|
|
|
@ -47,7 +47,7 @@ void DiveCartesianAxis::setTextColor(const QColor &color)
|
|||
textColor = color;
|
||||
}
|
||||
|
||||
DiveCartesianAxis::DiveCartesianAxis(double fontPrintScale, bool printMode, ProfileScene &scene) :
|
||||
DiveCartesianAxis::DiveCartesianAxis(double dpr, bool printMode, ProfileScene &scene) :
|
||||
printMode(printMode),
|
||||
scene(scene),
|
||||
orientation(LeftToRight),
|
||||
|
@ -60,7 +60,7 @@ DiveCartesianAxis::DiveCartesianAxis(double fontPrintScale, bool printMode, Prof
|
|||
labelScale(1.0),
|
||||
line_size(1),
|
||||
changed(true),
|
||||
fontPrintScale(fontPrintScale)
|
||||
dpr(dpr)
|
||||
{
|
||||
setPen(gridPen());
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ void DiveCartesianAxis::updateTicks(int animSpeed, color_index_t color)
|
|||
} else {
|
||||
childPos = begin - i * stepSize;
|
||||
}
|
||||
DiveTextItem *label = new DiveTextItem(fontPrintScale, this);
|
||||
DiveTextItem *label = new DiveTextItem(dpr, this);
|
||||
label->setText(textForValue(currValueText));
|
||||
label->setBrush(colorForValue(currValueText));
|
||||
label->setScale(labelScale);
|
||||
|
@ -339,7 +339,7 @@ QColor DepthAxis::colorForValue(double) const
|
|||
return QColor(Qt::red);
|
||||
}
|
||||
|
||||
DepthAxis::DepthAxis(double fontPrintScale, bool printMode, ProfileScene &scene) : DiveCartesianAxis(fontPrintScale, printMode, scene)
|
||||
DepthAxis::DepthAxis(double dpr, bool printMode, ProfileScene &scene) : DiveCartesianAxis(dpr, printMode, scene)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
|
@ -372,8 +372,8 @@ QString TemperatureAxis::textForValue(double value) const
|
|||
return QString::number(mkelvin_to_C((int)value));
|
||||
}
|
||||
|
||||
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, double fontPrintScale, bool printMode, ProfileScene &scene) :
|
||||
DiveCartesianAxis(fontPrintScale, printMode, scene),
|
||||
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, double dpr, bool printMode, ProfileScene &scene) :
|
||||
DiveCartesianAxis(dpr, printMode, scene),
|
||||
model(model)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
LeftToRight,
|
||||
RightToLeft
|
||||
};
|
||||
DiveCartesianAxis(double fontPrintScale, bool printMode, ProfileScene &scene);
|
||||
DiveCartesianAxis(double dpr, bool printMode, ProfileScene &scene);
|
||||
~DiveCartesianAxis();
|
||||
void setMinimum(double minimum);
|
||||
void setMaximum(double maximum);
|
||||
|
@ -70,13 +70,13 @@ protected:
|
|||
double labelScale;
|
||||
qreal line_size;
|
||||
bool changed;
|
||||
double fontPrintScale;
|
||||
double dpr;
|
||||
};
|
||||
|
||||
class DepthAxis : public DiveCartesianAxis {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DepthAxis(double fontPrintScale, bool printMode, ProfileScene &scene);
|
||||
DepthAxis(double dpr, bool printMode, ProfileScene &scene);
|
||||
private:
|
||||
QString textForValue(double value) const override;
|
||||
QColor colorForValue(double value) const override;
|
||||
|
@ -103,7 +103,7 @@ private:
|
|||
class PartialGasPressureAxis : public DiveCartesianAxis {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PartialGasPressureAxis(const DivePlotDataModel &model, double fontPrintScale, bool printMode, ProfileScene &scene);
|
||||
PartialGasPressureAxis(const DivePlotDataModel &model, double dpr, bool printMode, ProfileScene &scene);
|
||||
void update(int animSpeed);
|
||||
private:
|
||||
const DivePlotDataModel &model;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix,
|
||||
DivePlotDataModel *model, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis,
|
||||
int speed, double fontPrintScale, QGraphicsItem *parent) : DivePixmapItem(parent),
|
||||
int speed, double dpr, QGraphicsItem *parent) : DivePixmapItem(parent),
|
||||
vAxis(vAxis),
|
||||
hAxis(hAxis),
|
||||
dataModel(model),
|
||||
|
@ -26,7 +26,7 @@ DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasm
|
|||
{
|
||||
setFlag(ItemIgnoresTransformations);
|
||||
|
||||
setupPixmap(lastgasmix, fontPrintScale);
|
||||
setupPixmap(lastgasmix, dpr);
|
||||
setupToolTipString(lastgasmix);
|
||||
recalculatePos(0);
|
||||
|
||||
|
@ -49,7 +49,7 @@ struct event *DiveEventItem::getEventMutable()
|
|||
return ev;
|
||||
}
|
||||
|
||||
void DiveEventItem::setupPixmap(struct gasmix lastgasmix, double fontPrintScale)
|
||||
void DiveEventItem::setupPixmap(struct gasmix lastgasmix, double dpr)
|
||||
{
|
||||
extern int verbose;
|
||||
const IconMetrics& metrics = defaultIconMetrics();
|
||||
|
@ -65,10 +65,10 @@ void DiveEventItem::setupPixmap(struct gasmix lastgasmix, double fontPrintScale)
|
|||
int sz_bigger = metrics.sz_big + metrics.sz_med;
|
||||
#endif
|
||||
#endif
|
||||
sz_bigger = lrint(sz_bigger * fontPrintScale);
|
||||
sz_bigger = lrint(sz_bigger * dpr);
|
||||
int sz_pix = sz_bigger/2; // ex 20px
|
||||
if (verbose)
|
||||
qDebug() << __FUNCTION__ << "fontPrintScale" << fontPrintScale << "metrics" << metrics.sz_med << metrics.sz_small << "sz_bigger" << sz_bigger;
|
||||
qDebug() << __FUNCTION__ << "DPR" << dpr << "metrics" << metrics.sz_med << metrics.sz_small << "sz_bigger" << sz_bigger;
|
||||
|
||||
#define EVENT_PIXMAP(PIX) QPixmap(QString(PIX)).scaled(sz_pix, sz_pix, Qt::KeepAspectRatio, Qt::SmoothTransformation)
|
||||
#define EVENT_PIXMAP_BIGGER(PIX) QPixmap(QString(PIX)).scaled(sz_bigger, sz_bigger, Qt::KeepAspectRatio, Qt::SmoothTransformation)
|
||||
|
|
|
@ -13,7 +13,7 @@ class DiveEventItem : public DivePixmapItem {
|
|||
public:
|
||||
DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix,
|
||||
DivePlotDataModel *model, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis,
|
||||
int speed, double fontPrintScale, QGraphicsItem *parent = nullptr);
|
||||
int speed, double dpr, QGraphicsItem *parent = nullptr);
|
||||
~DiveEventItem();
|
||||
const struct event *getEvent() const;
|
||||
struct event *getEventMutable();
|
||||
|
@ -28,7 +28,7 @@ slots:
|
|||
|
||||
private:
|
||||
void setupToolTipString(struct gasmix lastgasmix);
|
||||
void setupPixmap(struct gasmix lastgasmix, double fontPrintScale);
|
||||
void setupPixmap(struct gasmix lastgasmix, double dpr);
|
||||
int depthAtTime(int time);
|
||||
DiveCartesianAxis *vAxis;
|
||||
DiveCartesianAxis *hAxis;
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "profile-widget/profilewidget2.h"
|
||||
|
||||
AbstractProfilePolygonItem::AbstractProfilePolygonItem(const DivePlotDataModel &model, const DiveCartesianAxis &horizontal, int hColumn,
|
||||
const DiveCartesianAxis &vertical, int vColumn, double fontPrintScale) :
|
||||
hAxis(horizontal), vAxis(vertical), dataModel(model), hDataColumn(hColumn), vDataColumn(vColumn), fontPrintScale(fontPrintScale)
|
||||
const DiveCartesianAxis &vertical, int vColumn, double dpr) :
|
||||
hAxis(horizontal), vAxis(vertical), dataModel(model), hDataColumn(hColumn), vDataColumn(vColumn), dpr(dpr)
|
||||
{
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ void AbstractProfilePolygonItem::replot(const dive *, bool)
|
|||
}
|
||||
|
||||
DiveProfileItem::DiveProfileItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale),
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, dpr),
|
||||
show_reported_ceiling(0), reported_ceiling_in_red(0)
|
||||
{
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ void DiveProfileItem::replot(const dive *d, bool in_planner)
|
|||
|
||||
void DiveProfileItem::plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color)
|
||||
{
|
||||
DiveTextItem *item = new DiveTextItem(fontPrintScale, this);
|
||||
DiveTextItem *item = new DiveTextItem(dpr, this);
|
||||
item->setPos(hAxis.posAtValue(entry->sec), vAxis.posAtValue(entry->depth));
|
||||
item->setText(get_depth_string(entry->depth, true));
|
||||
item->setAlignment(flags);
|
||||
|
@ -151,8 +151,8 @@ void DiveProfileItem::plot_depth_sample(struct plot_data *entry, QFlags<Qt::Alig
|
|||
}
|
||||
|
||||
DiveHeartrateItem::DiveHeartrateItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, dpr)
|
||||
{
|
||||
QPen pen;
|
||||
pen.setBrush(QBrush(getColor(::HR_PLOT)));
|
||||
|
@ -214,7 +214,7 @@ void DiveHeartrateItem::replot(const dive *, bool)
|
|||
|
||||
void DiveHeartrateItem::createTextItem(int sec, int hr)
|
||||
{
|
||||
DiveTextItem *text = new DiveTextItem(fontPrintScale, this);
|
||||
DiveTextItem *text = new DiveTextItem(dpr, this);
|
||||
text->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
||||
text->setBrush(getColor(HR_TEXT));
|
||||
text->setPos(QPointF(hAxis.posAtValue(sec), vAxis.posAtValue(hr)));
|
||||
|
@ -234,8 +234,8 @@ void DiveHeartrateItem::paint(QPainter *painter, const QStyleOptionGraphicsItem*
|
|||
}
|
||||
|
||||
DivePercentageItem::DivePercentageItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, int i, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale),
|
||||
const DiveCartesianAxis &vAxis, int vColumn, int i, double dpr) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, dpr),
|
||||
tissueIndex(i)
|
||||
{
|
||||
}
|
||||
|
@ -305,8 +305,8 @@ void DivePercentageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||
}
|
||||
|
||||
DiveTemperatureItem::DiveTemperatureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, dpr)
|
||||
{
|
||||
QPen pen;
|
||||
pen.setBrush(QBrush(getColor(::TEMP_PLOT)));
|
||||
|
@ -363,7 +363,7 @@ void DiveTemperatureItem::createTextItem(int sec, int mkelvin)
|
|||
temperature_t temp;
|
||||
temp.mkelvin = mkelvin;
|
||||
|
||||
DiveTextItem *text = new DiveTextItem(fontPrintScale, this);
|
||||
DiveTextItem *text = new DiveTextItem(dpr, this);
|
||||
text->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
||||
text->setBrush(getColor(TEMP_TEXT));
|
||||
text->setPos(QPointF(hAxis.posAtValue(sec), vAxis.posAtValue(mkelvin)));
|
||||
|
@ -383,8 +383,8 @@ void DiveTemperatureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
|||
}
|
||||
|
||||
DiveMeanDepthItem::DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, dpr)
|
||||
{
|
||||
QPen pen;
|
||||
pen.setBrush(QBrush(getColor(::HR_AXIS)));
|
||||
|
@ -431,7 +431,7 @@ void DiveMeanDepthItem::createTextItem()
|
|||
int sec = entry[dataModel.rowCount()-1].sec;
|
||||
qDeleteAll(texts);
|
||||
texts.clear();
|
||||
DiveTextItem *text = new DiveTextItem(fontPrintScale, this);
|
||||
DiveTextItem *text = new DiveTextItem(dpr, this);
|
||||
text->setAlignment(Qt::AlignRight | Qt::AlignTop);
|
||||
text->setBrush(getColor(TEMP_TEXT));
|
||||
text->setPos(QPointF(hAxis.posAtValue(sec) + 1, vAxis.posAtValue(lastRunningSum)));
|
||||
|
@ -569,7 +569,7 @@ void DiveGasPressureItem::plotPressureValue(int mbar, int sec, QFlags<Qt::Alignm
|
|||
{
|
||||
const char *unit;
|
||||
int pressure = get_pressure_units(mbar, &unit);
|
||||
DiveTextItem *text = new DiveTextItem(fontPrintScale, this);
|
||||
DiveTextItem *text = new DiveTextItem(dpr, this);
|
||||
text->setPos(hAxis.posAtValue(sec), vAxis.posAtValue(mbar) + pressure_offset );
|
||||
text->setText(QString("%1%2").arg(pressure).arg(unit));
|
||||
text->setAlignment(align);
|
||||
|
@ -580,7 +580,7 @@ void DiveGasPressureItem::plotPressureValue(int mbar, int sec, QFlags<Qt::Alignm
|
|||
void DiveGasPressureItem::plotGasValue(int mbar, int sec, struct gasmix gasmix, QFlags<Qt::AlignmentFlag> align, double gasname_offset)
|
||||
{
|
||||
QString gas = get_gas_string(gasmix);
|
||||
DiveTextItem *text = new DiveTextItem(fontPrintScale, this);
|
||||
DiveTextItem *text = new DiveTextItem(dpr, this);
|
||||
text->setPos(hAxis.posAtValue(sec), vAxis.posAtValue(mbar) + gasname_offset );
|
||||
text->setText(gas);
|
||||
text->setAlignment(align);
|
||||
|
@ -607,8 +607,8 @@ void DiveGasPressureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
|||
}
|
||||
|
||||
DiveCalculatedCeiling::DiveCalculatedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, dpr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -641,14 +641,14 @@ void DiveCalculatedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsI
|
|||
}
|
||||
|
||||
DiveCalculatedTissue::DiveCalculatedTissue(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
DiveCalculatedCeiling(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr) :
|
||||
DiveCalculatedCeiling(model, hAxis, hColumn, vAxis, vColumn, dpr)
|
||||
{
|
||||
}
|
||||
|
||||
DiveReportedCeiling::DiveReportedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, dpr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -752,8 +752,8 @@ void PartialPressureGasItem::setThresholdSettingsKey(const double *prefPointerMi
|
|||
}
|
||||
|
||||
PartialPressureGasItem::PartialPressureGasItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale),
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, dpr),
|
||||
thresholdPtrMin(NULL),
|
||||
thresholdPtrMax(NULL)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
/* This is the Profile Item, it should be used for quite a lot of things
|
||||
on the profile view. The usage should be pretty simple:
|
||||
|
||||
DiveProfileItem *profile = new DiveProfileItem(DiveDataModel, timeAxis, DiveDataModel::TIME, DiveDataModel, DiveDataModel::DEPTH, fontPrintScale);
|
||||
DiveProfileItem *profile = new DiveProfileItem(DiveDataModel, timeAxis, DiveDataModel::TIME, DiveDataModel, DiveDataModel::DEPTH, dpr);
|
||||
scene()->addItem(profile);
|
||||
|
||||
This is a generically item and should be used as a base for others, I think...
|
||||
|
@ -30,7 +30,7 @@ class AbstractProfilePolygonItem : public QObject, public QGraphicsPolygonItem {
|
|||
Q_PROPERTY(qreal x WRITE setX READ x)
|
||||
Q_PROPERTY(qreal y WRITE setY READ y)
|
||||
public:
|
||||
AbstractProfilePolygonItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
AbstractProfilePolygonItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double dpr);
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
|
||||
void clear();
|
||||
virtual void replot(const dive *d, bool in_planner);
|
||||
|
@ -41,7 +41,7 @@ protected:
|
|||
const DivePlotDataModel &dataModel;
|
||||
int hDataColumn;
|
||||
int vDataColumn;
|
||||
double fontPrintScale;
|
||||
double dpr;
|
||||
QList<DiveTextItem *> texts;
|
||||
};
|
||||
|
||||
|
@ -49,7 +49,7 @@ class DiveProfileItem : public AbstractProfilePolygonItem {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DiveProfileItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
DiveProfileItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double dpr);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color);
|
||||
|
@ -64,7 +64,7 @@ private:
|
|||
class DiveMeanDepthItem : public AbstractProfilePolygonItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double dpr);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
|
||||
|
@ -77,7 +77,7 @@ private:
|
|||
class DiveTemperatureItem : public AbstractProfilePolygonItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiveTemperatureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
DiveTemperatureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double dpr);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
|
||||
|
@ -88,7 +88,7 @@ private:
|
|||
class DiveHeartrateItem : public AbstractProfilePolygonItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiveHeartrateItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
DiveHeartrateItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double dpr);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
|
||||
|
@ -100,7 +100,7 @@ private:
|
|||
class DivePercentageItem : public AbstractProfilePolygonItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DivePercentageItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, int i, double fontPrintScale);
|
||||
DivePercentageItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, int i, double dpr);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
|
||||
|
@ -135,7 +135,7 @@ class DiveCalculatedCeiling : public AbstractProfilePolygonItem {
|
|||
|
||||
public:
|
||||
DiveCalculatedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
};
|
||||
|
@ -144,7 +144,7 @@ class DiveReportedCeiling : public AbstractProfilePolygonItem {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DiveReportedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
DiveReportedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double dpr);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
};
|
||||
|
@ -153,13 +153,13 @@ class DiveCalculatedTissue : public DiveCalculatedCeiling {
|
|||
Q_OBJECT
|
||||
public:
|
||||
DiveCalculatedTissue(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double dpr);
|
||||
};
|
||||
|
||||
class PartialPressureGasItem : public AbstractProfilePolygonItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PartialPressureGasItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
PartialPressureGasItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double dpr);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void setThresholdSettingsKey(const double *prefPointerMin, const double *prefPointerMax);
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
|
||||
DiveTextItem::DiveTextItem(double printScale, QGraphicsItem *parent) : QGraphicsItemGroup(parent),
|
||||
DiveTextItem::DiveTextItem(double dpr, QGraphicsItem *parent) : QGraphicsItemGroup(parent),
|
||||
internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter),
|
||||
textBackgroundItem(new QGraphicsPathItem(this)),
|
||||
textItem(new QGraphicsPathItem(this)),
|
||||
printScale(printScale),
|
||||
dpr(dpr),
|
||||
scale(1.0)
|
||||
{
|
||||
setFlag(ItemIgnoresTransformations);
|
||||
|
@ -69,11 +69,11 @@ void DiveTextItem::updateText()
|
|||
QFont fnt(qApp->font());
|
||||
if ((size = fnt.pixelSize()) > 0) {
|
||||
// set in pixels - so the scale factor may not make a difference if it's too close to 1
|
||||
size *= scale * printScale;
|
||||
size *= scale * dpr;
|
||||
fnt.setPixelSize(lrint(size));
|
||||
} else {
|
||||
size = fnt.pointSizeF();
|
||||
size *= scale * printScale;
|
||||
size *= scale * dpr;
|
||||
fnt.setPointSizeF(size);
|
||||
}
|
||||
QFontMetrics fm(fnt);
|
||||
|
|
|
@ -13,7 +13,7 @@ class DiveTextItem : public QObject, public QGraphicsItemGroup {
|
|||
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
||||
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
|
||||
public:
|
||||
DiveTextItem(double printScale, QGraphicsItem *parent = 0);
|
||||
DiveTextItem(double dpr, QGraphicsItem *parent = 0);
|
||||
void setText(const QString &text);
|
||||
void setAlignment(int alignFlags);
|
||||
void setScale(double newscale);
|
||||
|
@ -27,7 +27,7 @@ private:
|
|||
QGraphicsPathItem *textBackgroundItem;
|
||||
QGraphicsPathItem *textItem;
|
||||
QString internalText;
|
||||
double printScale;
|
||||
double dpr;
|
||||
double scale;
|
||||
};
|
||||
|
||||
|
|
|
@ -55,34 +55,34 @@ T *ProfileScene::createItem(const DiveCartesianAxis &vAxis, int vColumn, int z,
|
|||
PartialPressureGasItem *ProfileScene::createPPGas(int column, color_index_t color, color_index_t colorAlert,
|
||||
const double *thresholdSettingsMin, const double *thresholdSettingsMax)
|
||||
{
|
||||
PartialPressureGasItem *item = createItem<PartialPressureGasItem>(*gasYAxis, column, 99, fontPrintScale);
|
||||
PartialPressureGasItem *item = createItem<PartialPressureGasItem>(*gasYAxis, column, 99, dpr);
|
||||
item->setThresholdSettingsKey(thresholdSettingsMin, thresholdSettingsMax);
|
||||
item->setColors(getColor(color, isGrayscale), getColor(colorAlert, isGrayscale));
|
||||
return item;
|
||||
}
|
||||
|
||||
ProfileScene::ProfileScene(double fontPrintScale, bool printMode, bool isGrayscale) :
|
||||
ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
|
||||
d(nullptr),
|
||||
dc(-1),
|
||||
fontPrintScale(fontPrintScale),
|
||||
dpr(dpr),
|
||||
printMode(printMode),
|
||||
isGrayscale(isGrayscale),
|
||||
maxtime(-1),
|
||||
maxdepth(-1),
|
||||
dataModel(new DivePlotDataModel(this)),
|
||||
profileYAxis(new DepthAxis(fontPrintScale, printMode, *this)),
|
||||
gasYAxis(new PartialGasPressureAxis(*dataModel, fontPrintScale, printMode, *this)),
|
||||
temperatureAxis(new TemperatureAxis(fontPrintScale, printMode, *this)),
|
||||
timeAxis(new TimeAxis(fontPrintScale, printMode, *this)),
|
||||
cylinderPressureAxis(new DiveCartesianAxis(fontPrintScale, printMode, *this)),
|
||||
heartBeatAxis(new DiveCartesianAxis(fontPrintScale, printMode, *this)),
|
||||
percentageAxis(new DiveCartesianAxis(fontPrintScale, printMode, *this)),
|
||||
diveProfileItem(createItem<DiveProfileItem>(*profileYAxis, DivePlotDataModel::DEPTH, 0, fontPrintScale)),
|
||||
temperatureItem(createItem<DiveTemperatureItem>(*temperatureAxis, DivePlotDataModel::TEMPERATURE, 1, fontPrintScale)),
|
||||
meanDepthItem(createItem<DiveMeanDepthItem>(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, 1, fontPrintScale)),
|
||||
gasPressureItem(createItem<DiveGasPressureItem>(*cylinderPressureAxis, DivePlotDataModel::TEMPERATURE, 1, fontPrintScale)),
|
||||
diveComputerText(new DiveTextItem(fontPrintScale)),
|
||||
reportedCeiling(createItem<DiveReportedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, 1, fontPrintScale)),
|
||||
profileYAxis(new DepthAxis(dpr, printMode, *this)),
|
||||
gasYAxis(new PartialGasPressureAxis(*dataModel, dpr, printMode, *this)),
|
||||
temperatureAxis(new TemperatureAxis(dpr, printMode, *this)),
|
||||
timeAxis(new TimeAxis(dpr, printMode, *this)),
|
||||
cylinderPressureAxis(new DiveCartesianAxis(dpr, printMode, *this)),
|
||||
heartBeatAxis(new DiveCartesianAxis(dpr, printMode, *this)),
|
||||
percentageAxis(new DiveCartesianAxis(dpr, printMode, *this)),
|
||||
diveProfileItem(createItem<DiveProfileItem>(*profileYAxis, DivePlotDataModel::DEPTH, 0, dpr)),
|
||||
temperatureItem(createItem<DiveTemperatureItem>(*temperatureAxis, DivePlotDataModel::TEMPERATURE, 1, dpr)),
|
||||
meanDepthItem(createItem<DiveMeanDepthItem>(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, 1, dpr)),
|
||||
gasPressureItem(createItem<DiveGasPressureItem>(*cylinderPressureAxis, DivePlotDataModel::TEMPERATURE, 1, dpr)),
|
||||
diveComputerText(new DiveTextItem(dpr)),
|
||||
reportedCeiling(createItem<DiveReportedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, 1, dpr)),
|
||||
pn2GasItem(createPPGas(DivePlotDataModel::PN2, PN2, PN2_ALERT, NULL, &prefs.pp_graphs.pn2_threshold)),
|
||||
pheGasItem(createPPGas(DivePlotDataModel::PHE, PHE, PHE_ALERT, NULL, &prefs.pp_graphs.phe_threshold)),
|
||||
po2GasItem(createPPGas(DivePlotDataModel::PO2, PO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)),
|
||||
|
@ -91,10 +91,10 @@ ProfileScene::ProfileScene(double fontPrintScale, bool printMode, bool isGraysca
|
|||
ccrsensor2GasItem(createPPGas(DivePlotDataModel::CCRSENSOR2, CCRSENSOR2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)),
|
||||
ccrsensor3GasItem(createPPGas(DivePlotDataModel::CCRSENSOR3, CCRSENSOR3, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)),
|
||||
ocpo2GasItem(createPPGas(DivePlotDataModel::SCR_OC_PO2, SCR_OCPO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)),
|
||||
diveCeiling(createItem<DiveCalculatedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, 1, fontPrintScale)),
|
||||
decoModelParameters(new DiveTextItem(fontPrintScale)),
|
||||
heartBeatItem(createItem<DiveHeartrateItem>(*heartBeatAxis, DivePlotDataModel::HEARTBEAT, 1, fontPrintScale)),
|
||||
tankItem(new TankItem(*timeAxis, fontPrintScale))
|
||||
diveCeiling(createItem<DiveCalculatedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, 1, dpr)),
|
||||
decoModelParameters(new DiveTextItem(dpr)),
|
||||
heartBeatItem(createItem<DiveHeartrateItem>(*heartBeatAxis, DivePlotDataModel::HEARTBEAT, 1, dpr)),
|
||||
tankItem(new TankItem(*timeAxis, dpr))
|
||||
{
|
||||
init_plot_info(&plotInfo);
|
||||
|
||||
|
@ -167,9 +167,9 @@ ProfileScene::ProfileScene(double fontPrintScale, bool printMode, bool isGraysca
|
|||
tankItem->setPos(itemPos.tankBar.on);
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
DiveCalculatedTissue *tissueItem = createItem<DiveCalculatedTissue>(*profileYAxis, DivePlotDataModel::TISSUE_1 + i, i + 1, fontPrintScale);
|
||||
DiveCalculatedTissue *tissueItem = createItem<DiveCalculatedTissue>(*profileYAxis, DivePlotDataModel::TISSUE_1 + i, i + 1, dpr);
|
||||
allTissues.append(tissueItem);
|
||||
DivePercentageItem *percentageItem = createItem<DivePercentageItem>(*percentageAxis, DivePlotDataModel::PERCENTAGE_1 + i, i + 1, i, fontPrintScale);
|
||||
DivePercentageItem *percentageItem = createItem<DivePercentageItem>(*percentageAxis, DivePlotDataModel::PERCENTAGE_1 + i, i + 1, i, dpr);
|
||||
allPercentages.append(percentageItem);
|
||||
}
|
||||
|
||||
|
@ -637,8 +637,7 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
|||
// BUT events are wanted.
|
||||
#endif
|
||||
DiveEventItem *item = new DiveEventItem(d, event, lastgasmix, dataModel,
|
||||
timeAxis, profileYAxis, animSpeed,
|
||||
fontPrintScale);
|
||||
timeAxis, profileYAxis, animSpeed, dpr);
|
||||
item->setZValue(2);
|
||||
addItem(item);
|
||||
eventItems.push_back(item);
|
||||
|
|
|
@ -36,7 +36,7 @@ class TimeAxis;
|
|||
|
||||
class ProfileScene : public QGraphicsScene {
|
||||
public:
|
||||
ProfileScene(double fontPrintScale, bool printMode, bool isGrayscale);
|
||||
ProfileScene(double dpr, bool printMode, bool isGrayscale);
|
||||
~ProfileScene();
|
||||
|
||||
void updateAxes(bool instant); // Update axes according to preferences
|
||||
|
@ -59,7 +59,7 @@ private:
|
|||
void updateVisibility(); // Update visibility of non-interactive chart features according to preferences
|
||||
|
||||
friend class ProfileWidget2; // For now, give the ProfileWidget full access to the objects on the scene
|
||||
double fontPrintScale;
|
||||
double dpr; // Device Pixel Ratio. A DPR of one corresponds to a "standard" PC screen.
|
||||
bool printMode;
|
||||
bool isGrayscale;
|
||||
int maxtime;
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
static const double thumbnailBaseZValue = 100.0;
|
||||
#endif
|
||||
|
||||
ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, double fontPrintScale, QWidget *parent) : QGraphicsView(parent),
|
||||
profileScene(new ProfileScene(fontPrintScale, false, false)),
|
||||
ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, double dpr, QWidget *parent) : QGraphicsView(parent),
|
||||
profileScene(new ProfileScene(dpr, false, false)),
|
||||
currentState(INIT),
|
||||
plannerModel(plannerModelIn),
|
||||
zoomLevel(0),
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
};
|
||||
|
||||
// Pass null as plannerModel if no support for planning required
|
||||
ProfileWidget2(DivePlannerPointsModel *plannerModel, double fontPrintScale, QWidget *parent = 0);
|
||||
ProfileWidget2(DivePlannerPointsModel *plannerModel, double dpr, QWidget *parent = 0);
|
||||
~ProfileWidget2();
|
||||
void resetZoom();
|
||||
void scale(qreal sx, qreal sy);
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
static const qreal height = 3.0;
|
||||
|
||||
TankItem::TankItem(const DiveCartesianAxis &axis, double fontPrintScale) :
|
||||
TankItem::TankItem(const DiveCartesianAxis &axis, double dpr) :
|
||||
hAxis(axis),
|
||||
plotEndTime(-1),
|
||||
fontPrintScale(fontPrintScale)
|
||||
dpr(dpr)
|
||||
{
|
||||
QColor red(PERSIANRED1);
|
||||
QColor blue(AIR_BLUE);
|
||||
|
@ -51,7 +51,7 @@ void TankItem::createBar(int startTime, int stopTime, struct gasmix gas)
|
|||
rect->setBrush(nitrox);
|
||||
rect->setPen(QPen(QBrush(), 0.0)); // get rid of the thick line around the rectangle
|
||||
rects.push_back(rect);
|
||||
DiveTextItem *label = new DiveTextItem(fontPrintScale, rect);
|
||||
DiveTextItem *label = new DiveTextItem(dpr, rect);
|
||||
label->setText(gasname(gas));
|
||||
label->setBrush(Qt::black);
|
||||
label->setPos(x + 1, 0);
|
||||
|
|
|
@ -13,14 +13,14 @@ class DiveCartesianAxis;
|
|||
class TankItem : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
explicit TankItem(const DiveCartesianAxis &axis, double fontPrintScale);
|
||||
explicit TankItem(const DiveCartesianAxis &axis, double dpr);
|
||||
void setData(const struct plot_info *plotInfo, const struct dive *d);
|
||||
|
||||
private:
|
||||
void createBar(int startTime, int stopTime, struct gasmix gas);
|
||||
const DiveCartesianAxis &hAxis;
|
||||
int plotEndTime;
|
||||
double fontPrintScale;
|
||||
double dpr;
|
||||
QBrush air, nitrox, oxygen, trimix;
|
||||
QList<QGraphicsRectItem *> rects;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue