mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
profile: pass fontPrintScale at construction time
Instead of intializing the text fields and then changing the font scale via signal-rigmarole, pass down the font-scale at construction time. Since the fontPrintScale is only set in print mode, we also can access it directly instead of testing for printMode. Since the DiveTextItem is not updated using signals anymore, the connected flag can be removed. The commit is larger than I had hoped for, but this makes things ultimately less brittle. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
7744fec0bf
commit
01983c65c3
9 changed files with 88 additions and 98 deletions
|
@ -60,7 +60,7 @@ void DiveCartesianAxis::setTextColor(const QColor &color)
|
|||
textColor = color;
|
||||
}
|
||||
|
||||
DiveCartesianAxis::DiveCartesianAxis(ProfileWidget2 *widget) : QObject(),
|
||||
DiveCartesianAxis::DiveCartesianAxis(double fontPrintScale, ProfileWidget2 *widget) : QObject(),
|
||||
QGraphicsLineItem(),
|
||||
printMode(false),
|
||||
profileWidget(widget),
|
||||
|
@ -73,7 +73,8 @@ DiveCartesianAxis::DiveCartesianAxis(ProfileWidget2 *widget) : QObject(),
|
|||
lineVisibility(true),
|
||||
labelScale(1.0),
|
||||
line_size(1),
|
||||
changed(true)
|
||||
changed(true),
|
||||
fontPrintScale(fontPrintScale)
|
||||
{
|
||||
setPen(gridPen());
|
||||
}
|
||||
|
@ -199,7 +200,7 @@ void DiveCartesianAxis::updateTicks(color_index_t color)
|
|||
} else {
|
||||
childPos = begin - i * stepSize;
|
||||
}
|
||||
DiveTextItem *label = new DiveTextItem(this);
|
||||
DiveTextItem *label = new DiveTextItem(fontPrintScale, this);
|
||||
label->setText(textForValue(currValueText));
|
||||
label->setBrush(colorForValue(currValueText));
|
||||
label->setScale(labelScale);
|
||||
|
@ -354,7 +355,7 @@ QColor DepthAxis::colorForValue(double) const
|
|||
return QColor(Qt::red);
|
||||
}
|
||||
|
||||
DepthAxis::DepthAxis(ProfileWidget2 *widget) : DiveCartesianAxis(widget),
|
||||
DepthAxis::DepthAxis(double fontPrintScale, ProfileWidget2 *widget) : DiveCartesianAxis(fontPrintScale, widget),
|
||||
unitSystem(prefs.units.length)
|
||||
{
|
||||
connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DepthAxis::settingsChanged);
|
||||
|
@ -398,8 +399,8 @@ QString TemperatureAxis::textForValue(double value) const
|
|||
return QString::number(mkelvin_to_C((int)value));
|
||||
}
|
||||
|
||||
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, ProfileWidget2 *widget) :
|
||||
DiveCartesianAxis(widget),
|
||||
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, double fontPrintScale, ProfileWidget2 *widget) :
|
||||
DiveCartesianAxis(fontPrintScale, widget),
|
||||
model(model)
|
||||
{
|
||||
connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &PartialGasPressureAxis::update);
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
LeftToRight,
|
||||
RightToLeft
|
||||
};
|
||||
DiveCartesianAxis(ProfileWidget2 *widget);
|
||||
DiveCartesianAxis(double fontPrintScale, ProfileWidget2 *widget);
|
||||
~DiveCartesianAxis();
|
||||
void setPrintMode(bool mode);
|
||||
void setMinimum(double minimum);
|
||||
|
@ -70,12 +70,13 @@ protected:
|
|||
double labelScale;
|
||||
qreal line_size;
|
||||
bool changed;
|
||||
double fontPrintScale;
|
||||
};
|
||||
|
||||
class DepthAxis : public DiveCartesianAxis {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DepthAxis(ProfileWidget2 *widget);
|
||||
DepthAxis(double fontPrintScale, ProfileWidget2 *widget);
|
||||
private:
|
||||
QString textForValue(double value) const override;
|
||||
QColor colorForValue(double value) const override;
|
||||
|
@ -106,7 +107,7 @@ private:
|
|||
class PartialGasPressureAxis : public DiveCartesianAxis {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PartialGasPressureAxis(const DivePlotDataModel &model, ProfileWidget2 *widget);
|
||||
PartialGasPressureAxis(const DivePlotDataModel &model, double fontPrintScale, ProfileWidget2 *widget);
|
||||
public
|
||||
slots:
|
||||
void update();
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "profile-widget/profilewidget2.h"
|
||||
|
||||
AbstractProfilePolygonItem::AbstractProfilePolygonItem(const DivePlotDataModel &model, const DiveCartesianAxis &horizontal, int hColumn,
|
||||
const DiveCartesianAxis &vertical, int vColumn) :
|
||||
hAxis(horizontal), vAxis(vertical), dataModel(model), hDataColumn(hColumn), vDataColumn(vColumn)
|
||||
const DiveCartesianAxis &vertical, int vColumn, double fontPrintScale) :
|
||||
hAxis(horizontal), vAxis(vertical), dataModel(model), hDataColumn(hColumn), vDataColumn(vColumn), fontPrintScale(fontPrintScale)
|
||||
{
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
}
|
||||
|
@ -46,8 +46,9 @@ void AbstractProfilePolygonItem::replot(const dive *, bool)
|
|||
texts.clear();
|
||||
}
|
||||
|
||||
DiveProfileItem::DiveProfileItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn),
|
||||
DiveProfileItem::DiveProfileItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale),
|
||||
show_reported_ceiling(0), reported_ceiling_in_red(0)
|
||||
{
|
||||
}
|
||||
|
@ -141,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(this);
|
||||
DiveTextItem *item = new DiveTextItem(fontPrintScale, this);
|
||||
item->setPos(hAxis.posAtValue(entry->sec), vAxis.posAtValue(entry->depth));
|
||||
item->setText(get_depth_string(entry->depth, true));
|
||||
item->setAlignment(flags);
|
||||
|
@ -149,8 +150,9 @@ void DiveProfileItem::plot_depth_sample(struct plot_data *entry, QFlags<Qt::Alig
|
|||
texts.append(item);
|
||||
}
|
||||
|
||||
DiveHeartrateItem::DiveHeartrateItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn)
|
||||
DiveHeartrateItem::DiveHeartrateItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
{
|
||||
QPen pen;
|
||||
pen.setBrush(QBrush(getColor(::HR_PLOT)));
|
||||
|
@ -212,7 +214,7 @@ void DiveHeartrateItem::replot(const dive *, bool)
|
|||
|
||||
void DiveHeartrateItem::createTextItem(int sec, int hr)
|
||||
{
|
||||
DiveTextItem *text = new DiveTextItem(this);
|
||||
DiveTextItem *text = new DiveTextItem(fontPrintScale, this);
|
||||
text->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
||||
text->setBrush(getColor(HR_TEXT));
|
||||
text->setPos(QPointF(hAxis.posAtValue(sec), vAxis.posAtValue(hr)));
|
||||
|
@ -231,8 +233,9 @@ void DiveHeartrateItem::paint(QPainter *painter, const QStyleOptionGraphicsItem*
|
|||
painter->restore();
|
||||
}
|
||||
|
||||
DivePercentageItem::DivePercentageItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, int i) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn),
|
||||
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),
|
||||
tissueIndex(i)
|
||||
{
|
||||
}
|
||||
|
@ -301,8 +304,9 @@ void DivePercentageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||
painter->restore();
|
||||
}
|
||||
|
||||
DiveTemperatureItem::DiveTemperatureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn)
|
||||
DiveTemperatureItem::DiveTemperatureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
{
|
||||
QPen pen;
|
||||
pen.setBrush(QBrush(getColor(::TEMP_PLOT)));
|
||||
|
@ -359,7 +363,7 @@ void DiveTemperatureItem::createTextItem(int sec, int mkelvin)
|
|||
temperature_t temp;
|
||||
temp.mkelvin = mkelvin;
|
||||
|
||||
DiveTextItem *text = new DiveTextItem(this);
|
||||
DiveTextItem *text = new DiveTextItem(fontPrintScale, this);
|
||||
text->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
||||
text->setBrush(getColor(TEMP_TEXT));
|
||||
text->setPos(QPointF(hAxis.posAtValue(sec), vAxis.posAtValue(mkelvin)));
|
||||
|
@ -378,8 +382,9 @@ void DiveTemperatureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
|||
painter->restore();
|
||||
}
|
||||
|
||||
DiveMeanDepthItem::DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn)
|
||||
DiveMeanDepthItem::DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
{
|
||||
QPen pen;
|
||||
pen.setBrush(QBrush(getColor(::HR_AXIS)));
|
||||
|
@ -426,7 +431,7 @@ void DiveMeanDepthItem::createTextItem()
|
|||
int sec = entry[dataModel.rowCount()-1].sec;
|
||||
qDeleteAll(texts);
|
||||
texts.clear();
|
||||
DiveTextItem *text = new DiveTextItem(this);
|
||||
DiveTextItem *text = new DiveTextItem(fontPrintScale, this);
|
||||
text->setAlignment(Qt::AlignRight | Qt::AlignTop);
|
||||
text->setBrush(getColor(TEMP_TEXT));
|
||||
text->setPos(QPointF(hAxis.posAtValue(sec) + 1, vAxis.posAtValue(lastRunningSum)));
|
||||
|
@ -564,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(this);
|
||||
DiveTextItem *text = new DiveTextItem(fontPrintScale, this);
|
||||
text->setPos(hAxis.posAtValue(sec), vAxis.posAtValue(mbar) + pressure_offset );
|
||||
text->setText(QString("%1%2").arg(pressure).arg(unit));
|
||||
text->setAlignment(align);
|
||||
|
@ -575,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(this);
|
||||
DiveTextItem *text = new DiveTextItem(fontPrintScale, this);
|
||||
text->setPos(hAxis.posAtValue(sec), vAxis.posAtValue(mbar) + gasname_offset );
|
||||
text->setText(gas);
|
||||
text->setAlignment(align);
|
||||
|
@ -601,8 +606,9 @@ void DiveGasPressureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
|||
painter->restore();
|
||||
}
|
||||
|
||||
DiveCalculatedCeiling::DiveCalculatedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn)
|
||||
DiveCalculatedCeiling::DiveCalculatedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -634,13 +640,15 @@ void DiveCalculatedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsI
|
|||
QGraphicsPolygonItem::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
DiveCalculatedTissue::DiveCalculatedTissue(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn) :
|
||||
DiveCalculatedCeiling(model, hAxis, hColumn, vAxis, vColumn)
|
||||
DiveCalculatedTissue::DiveCalculatedTissue(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
DiveCalculatedCeiling(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
{
|
||||
}
|
||||
|
||||
DiveReportedCeiling::DiveReportedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn)
|
||||
DiveReportedCeiling::DiveReportedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -743,8 +751,9 @@ void PartialPressureGasItem::setThresholdSettingsKey(const double *prefPointerMi
|
|||
thresholdPtrMax = prefPointerMax;
|
||||
}
|
||||
|
||||
PartialPressureGasItem::PartialPressureGasItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn),
|
||||
PartialPressureGasItem::PartialPressureGasItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale) :
|
||||
AbstractProfilePolygonItem(model, hAxis, hColumn, vAxis, vColumn, fontPrintScale),
|
||||
thresholdPtrMin(NULL),
|
||||
thresholdPtrMax(NULL)
|
||||
{
|
||||
|
|
|
@ -35,7 +35,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);
|
||||
AbstractProfilePolygonItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
|
||||
void clear();
|
||||
virtual void replot(const dive *d, bool in_planner);
|
||||
|
@ -46,6 +46,7 @@ protected:
|
|||
const DivePlotDataModel &dataModel;
|
||||
int hDataColumn;
|
||||
int vDataColumn;
|
||||
double fontPrintScale;
|
||||
QList<DiveTextItem *> texts;
|
||||
};
|
||||
|
||||
|
@ -53,7 +54,7 @@ class DiveProfileItem : public AbstractProfilePolygonItem {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DiveProfileItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||
DiveProfileItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
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);
|
||||
|
@ -68,7 +69,7 @@ private:
|
|||
class DiveMeanDepthItem : public AbstractProfilePolygonItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||
DiveMeanDepthItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
|
||||
|
@ -81,7 +82,7 @@ private:
|
|||
class DiveTemperatureItem : public AbstractProfilePolygonItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiveTemperatureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||
DiveTemperatureItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
|
||||
|
@ -92,7 +93,7 @@ private:
|
|||
class DiveHeartrateItem : public AbstractProfilePolygonItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DiveHeartrateItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||
DiveHeartrateItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
|
||||
|
@ -104,7 +105,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);
|
||||
DivePercentageItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, int i, double fontPrintScale);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
|
||||
|
@ -139,7 +140,7 @@ class DiveCalculatedCeiling : public AbstractProfilePolygonItem {
|
|||
|
||||
public:
|
||||
DiveCalculatedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn);
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
};
|
||||
|
@ -148,7 +149,7 @@ class DiveReportedCeiling : public AbstractProfilePolygonItem {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DiveReportedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||
DiveReportedCeiling(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
void replot(const dive *d, bool in_planner) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
|
||||
};
|
||||
|
@ -157,13 +158,13 @@ class DiveCalculatedTissue : public DiveCalculatedCeiling {
|
|||
Q_OBJECT
|
||||
public:
|
||||
DiveCalculatedTissue(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn,
|
||||
const DiveCartesianAxis &vAxis, int vColumn);
|
||||
const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
};
|
||||
|
||||
class PartialPressureGasItem : public AbstractProfilePolygonItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PartialPressureGasItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||
PartialPressureGasItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn, double fontPrintScale);
|
||||
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,13 +8,12 @@
|
|||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
|
||||
DiveTextItem::DiveTextItem(QGraphicsItem *parent) : QGraphicsItemGroup(parent),
|
||||
DiveTextItem::DiveTextItem(double printScale, QGraphicsItem *parent) : QGraphicsItemGroup(parent),
|
||||
internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter),
|
||||
textBackgroundItem(new QGraphicsPathItem(this)),
|
||||
textItem(new QGraphicsPathItem(this)),
|
||||
printScale(1.0),
|
||||
scale(1.0),
|
||||
connected(false)
|
||||
printScale(printScale),
|
||||
scale(1.0)
|
||||
{
|
||||
setFlag(ItemIgnoresTransformations);
|
||||
textBackgroundItem->setBrush(QBrush(getColor(TEXT_BACKGROUND)));
|
||||
|
@ -28,11 +27,6 @@ void DiveTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||
QGraphicsItemGroup::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
void DiveTextItem::fontPrintScaleUpdate(double scale)
|
||||
{
|
||||
printScale = scale;
|
||||
}
|
||||
|
||||
void DiveTextItem::setAlignment(int alignFlags)
|
||||
{
|
||||
if (alignFlags != internalAlignFlags) {
|
||||
|
@ -55,19 +49,6 @@ void DiveTextItem::setScale(double newscale)
|
|||
void DiveTextItem::setText(const QString &t)
|
||||
{
|
||||
if (internalText != t) {
|
||||
if (!connected) {
|
||||
if (scene()) {
|
||||
// by now we should be on a scene. grab the profile widget from it and setup our printScale
|
||||
// and connect to the signal that makes sure we keep track if that changes
|
||||
ProfileWidget2 *profile = qobject_cast<ProfileWidget2 *>(scene()->views().first());
|
||||
connect(profile, SIGNAL(fontPrintScaleChanged(double)), this, SLOT(fontPrintScaleUpdate(double)), Qt::UniqueConnection);
|
||||
fontPrintScaleUpdate(profile->getFontPrintScale());
|
||||
connected = true;
|
||||
} else {
|
||||
if (verbose)
|
||||
qDebug() << "called before scene was set up" << t;
|
||||
}
|
||||
}
|
||||
internalText = t;
|
||||
updateText();
|
||||
}
|
||||
|
|
|
@ -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(QGraphicsItem *parent = 0);
|
||||
DiveTextItem(double printScale, QGraphicsItem *parent = 0);
|
||||
void setText(const QString &text);
|
||||
void setAlignment(int alignFlags);
|
||||
void setScale(double newscale);
|
||||
|
@ -21,10 +21,6 @@ public:
|
|||
const QString &text();
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
private
|
||||
slots:
|
||||
void fontPrintScaleUpdate(double scale);
|
||||
|
||||
private:
|
||||
void updateText();
|
||||
int internalAlignFlags;
|
||||
|
@ -33,7 +29,6 @@ private:
|
|||
QString internalText;
|
||||
double printScale;
|
||||
double scale;
|
||||
bool connected;
|
||||
};
|
||||
|
||||
#endif // DIVETEXTITEM_H
|
||||
|
|
|
@ -108,17 +108,17 @@ ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, double fo
|
|||
#ifndef SUBSURFACE_MOBILE
|
||||
toolTipItem(new ToolTipItem()),
|
||||
#endif
|
||||
profileYAxis(new DepthAxis(this)),
|
||||
gasYAxis(new PartialGasPressureAxis(*dataModel, this)),
|
||||
temperatureAxis(new TemperatureAxis(this)),
|
||||
timeAxis(new TimeAxis(this)),
|
||||
diveProfileItem(createItem<DiveProfileItem>(*profileYAxis, DivePlotDataModel::DEPTH, 0)),
|
||||
temperatureItem(createItem<DiveTemperatureItem>(*temperatureAxis, DivePlotDataModel::TEMPERATURE, 1)),
|
||||
meanDepthItem(createItem<DiveMeanDepthItem>(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, 1)),
|
||||
cylinderPressureAxis(new DiveCartesianAxis(this)),
|
||||
gasPressureItem(createItem<DiveGasPressureItem>(*cylinderPressureAxis, DivePlotDataModel::TEMPERATURE, 1)),
|
||||
diveComputerText(new DiveTextItem()),
|
||||
reportedCeiling(createItem<DiveReportedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, 1)),
|
||||
profileYAxis(new DepthAxis(fontPrintScale, this)),
|
||||
gasYAxis(new PartialGasPressureAxis(*dataModel, fontPrintScale, this)),
|
||||
temperatureAxis(new TemperatureAxis(fontPrintScale, this)),
|
||||
timeAxis(new TimeAxis(fontPrintScale, 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)),
|
||||
cylinderPressureAxis(new DiveCartesianAxis(fontPrintScale, this)),
|
||||
gasPressureItem(createItem<DiveGasPressureItem>(*cylinderPressureAxis, DivePlotDataModel::TEMPERATURE, 1, fontPrintScale)),
|
||||
diveComputerText(new DiveTextItem(fontPrintScale)),
|
||||
reportedCeiling(createItem<DiveReportedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, 1, fontPrintScale)),
|
||||
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)),
|
||||
|
@ -127,17 +127,17 @@ ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, double fo
|
|||
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)),
|
||||
decoModelParameters(new DiveTextItem()),
|
||||
diveCeiling(createItem<DiveCalculatedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, 1, fontPrintScale)),
|
||||
decoModelParameters(new DiveTextItem(fontPrintScale)),
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
heartBeatAxis(new DiveCartesianAxis(this)),
|
||||
heartBeatItem(createItem<DiveHeartrateItem>(*heartBeatAxis, DivePlotDataModel::HEARTBEAT, 1)),
|
||||
percentageAxis(new DiveCartesianAxis(this)),
|
||||
heartBeatAxis(new DiveCartesianAxis(fontPrintScale, this)),
|
||||
heartBeatItem(createItem<DiveHeartrateItem>(*heartBeatAxis, DivePlotDataModel::HEARTBEAT, 1, fontPrintScale)),
|
||||
percentageAxis(new DiveCartesianAxis(fontPrintScale, this)),
|
||||
mouseFollowerVertical(new DiveLineItem()),
|
||||
mouseFollowerHorizontal(new DiveLineItem()),
|
||||
rulerItem(new RulerItem2()),
|
||||
#endif
|
||||
tankItem(new TankItem(*timeAxis)),
|
||||
tankItem(new TankItem(*timeAxis, fontPrintScale)),
|
||||
shouldCalculateMax(true),
|
||||
fontPrintScale(fontPrintScale)
|
||||
{
|
||||
|
@ -305,9 +305,9 @@ void ProfileWidget2::setupItemOnScene()
|
|||
decoModelParameters->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
for (int i = 0; i < 16; i++) {
|
||||
DiveCalculatedTissue *tissueItem = createItem<DiveCalculatedTissue>(*profileYAxis, DivePlotDataModel::TISSUE_1 + i, i + 1);
|
||||
DiveCalculatedTissue *tissueItem = createItem<DiveCalculatedTissue>(*profileYAxis, DivePlotDataModel::TISSUE_1 + i, i + 1, fontPrintScale);
|
||||
allTissues.append(tissueItem);
|
||||
DivePercentageItem *percentageItem = createItem<DivePercentageItem>(*percentageAxis, DivePlotDataModel::PERCENTAGE_1 + i, i + 1, i);
|
||||
DivePercentageItem *percentageItem = createItem<DivePercentageItem>(*percentageAxis, DivePlotDataModel::PERCENTAGE_1 + i, i + 1, i, fontPrintScale);
|
||||
allPercentages.append(percentageItem);
|
||||
}
|
||||
#endif
|
||||
|
@ -335,7 +335,7 @@ void ProfileWidget2::replot()
|
|||
PartialPressureGasItem *ProfileWidget2::createPPGas(int column, color_index_t color, color_index_t colorAlert,
|
||||
const double *thresholdSettingsMin, const double *thresholdSettingsMax)
|
||||
{
|
||||
PartialPressureGasItem *item = createItem<PartialPressureGasItem>(*gasYAxis, column, 99);
|
||||
PartialPressureGasItem *item = createItem<PartialPressureGasItem>(*gasYAxis, column, 99, fontPrintScale);
|
||||
item->setThresholdSettingsKey(thresholdSettingsMin, thresholdSettingsMax);
|
||||
item->setColors(getColor(color, isGrayscale), getColor(colorAlert, isGrayscale));
|
||||
return item;
|
||||
|
@ -709,7 +709,7 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool doClearPict
|
|||
// printMode is always selected for SUBSURFACE_MOBILE due to font problems
|
||||
// BUT events are wanted.
|
||||
#endif
|
||||
DiveEventItem *item = new DiveEventItem(d, event, lastgasmix, dataModel, timeAxis, profileYAxis, animSpeed, getFontPrintScale());
|
||||
DiveEventItem *item = new DiveEventItem(d, event, lastgasmix, dataModel, timeAxis, profileYAxis, animSpeed, fontPrintScale);
|
||||
item->setZValue(2);
|
||||
scene()->addItem(item);
|
||||
eventItems.push_back(item);
|
||||
|
|
|
@ -9,9 +9,10 @@
|
|||
|
||||
static const qreal height = 3.0;
|
||||
|
||||
TankItem::TankItem(const DiveCartesianAxis &axis) :
|
||||
TankItem::TankItem(const DiveCartesianAxis &axis, double fontPrintScale) :
|
||||
hAxis(axis),
|
||||
plotEndTime(-1)
|
||||
plotEndTime(-1),
|
||||
fontPrintScale(fontPrintScale)
|
||||
{
|
||||
QColor red(PERSIANRED1);
|
||||
QColor blue(AIR_BLUE);
|
||||
|
@ -50,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(rect);
|
||||
DiveTextItem *label = new DiveTextItem(fontPrintScale, rect);
|
||||
label->setText(gasname(gas));
|
||||
label->setBrush(Qt::black);
|
||||
label->setPos(x + 1, 0);
|
||||
|
|
|
@ -13,13 +13,14 @@ class DiveCartesianAxis;
|
|||
class TankItem : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
explicit TankItem(const DiveCartesianAxis &axis);
|
||||
explicit TankItem(const DiveCartesianAxis &axis, double fontPrintScale);
|
||||
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;
|
||||
QBrush air, nitrox, oxygen, trimix;
|
||||
QList<QGraphicsRectItem *> rects;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue