mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Plot mean depth data
As we already have running depth sum values for each sample why don't just plot running average depth graph. Signed-off-by: Krzysztof Arentowicz <k.arentowicz@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ee1ef52330
commit
e3378e299a
4 changed files with 69 additions and 1 deletions
|
@ -568,6 +568,53 @@ void DiveTemperatureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiveMeanDepthItem::DiveMeanDepthItem()
|
||||||
|
{
|
||||||
|
QPen pen;
|
||||||
|
pen.setBrush(QBrush(getColor(::MEAN_DEPTH)));
|
||||||
|
pen.setCosmetic(true);
|
||||||
|
pen.setWidth(2);
|
||||||
|
setPen(pen);
|
||||||
|
settingsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiveMeanDepthItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||||
|
{
|
||||||
|
double meandepthvalue;
|
||||||
|
// We don't have enougth data to calculate things, quit.
|
||||||
|
if (!shouldCalculateStuff(topLeft, bottomRight))
|
||||||
|
return;
|
||||||
|
|
||||||
|
QPolygonF poly;
|
||||||
|
plot_data *entry = dataModel->data().entry;
|
||||||
|
for (int i = 0, modelDataCount = dataModel->rowCount(); i < modelDataCount; i++, entry++) {
|
||||||
|
// Ignore empty values
|
||||||
|
if (entry->running_sum == 0 || entry->sec == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
meandepthvalue = entry->running_sum / entry->sec ;
|
||||||
|
QPointF point(hAxis->posAtValue(entry->sec), vAxis->posAtValue(meandepthvalue));
|
||||||
|
poly.append(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
setPolygon(poly);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DiveMeanDepthItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
if (polygon().isEmpty())
|
||||||
|
return;
|
||||||
|
painter->save();
|
||||||
|
painter->setPen(pen());
|
||||||
|
painter->drawPolyline(polygon());
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiveMeanDepthItem::settingsChanged()
|
||||||
|
{
|
||||||
|
setVisible(prefs.show_average_depth);
|
||||||
|
}
|
||||||
void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||||
{
|
{
|
||||||
// We don't have enougth data to calculate things, quit.
|
// We don't have enougth data to calculate things, quit.
|
||||||
|
|
|
@ -84,6 +84,18 @@ private:
|
||||||
QColor profileColor;
|
QColor profileColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DiveMeanDepthItem : public AbstractProfilePolygonItem {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
DiveMeanDepthItem();
|
||||||
|
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
||||||
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||||
|
virtual void settingsChanged();
|
||||||
|
private:
|
||||||
|
QString visibilityKey;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class DiveTemperatureItem : public AbstractProfilePolygonItem {
|
class DiveTemperatureItem : public AbstractProfilePolygonItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -86,7 +86,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
|
||||||
temperatureItem(new DiveTemperatureItem()),
|
temperatureItem(new DiveTemperatureItem()),
|
||||||
cylinderPressureAxis(new DiveCartesianAxis()),
|
cylinderPressureAxis(new DiveCartesianAxis()),
|
||||||
gasPressureItem(new DiveGasPressureItem()),
|
gasPressureItem(new DiveGasPressureItem()),
|
||||||
meanDepth(new MeanDepthLine()),
|
meanDepth(new MeanDepthLine()),
|
||||||
|
meanDepthItem(new DiveMeanDepthItem()),
|
||||||
diveComputerText(new DiveTextItem()),
|
diveComputerText(new DiveTextItem()),
|
||||||
diveCeiling(new DiveCalculatedCeiling()),
|
diveCeiling(new DiveCalculatedCeiling()),
|
||||||
reportedCeiling(new DiveReportedCeiling()),
|
reportedCeiling(new DiveReportedCeiling()),
|
||||||
|
@ -153,6 +154,7 @@ ProfileWidget2::~ProfileWidget2()
|
||||||
delete timeAxis;
|
delete timeAxis;
|
||||||
delete diveProfileItem;
|
delete diveProfileItem;
|
||||||
delete temperatureItem;
|
delete temperatureItem;
|
||||||
|
delete meanDepthItem;
|
||||||
delete cylinderPressureAxis;
|
delete cylinderPressureAxis;
|
||||||
delete gasPressureItem;
|
delete gasPressureItem;
|
||||||
delete meanDepth;
|
delete meanDepth;
|
||||||
|
@ -188,6 +190,7 @@ void ProfileWidget2::addItemsToScene()
|
||||||
scene()->addItem(diveProfileItem);
|
scene()->addItem(diveProfileItem);
|
||||||
scene()->addItem(cylinderPressureAxis);
|
scene()->addItem(cylinderPressureAxis);
|
||||||
scene()->addItem(temperatureItem);
|
scene()->addItem(temperatureItem);
|
||||||
|
scene()->addItem(meanDepthItem);
|
||||||
scene()->addItem(gasPressureItem);
|
scene()->addItem(gasPressureItem);
|
||||||
scene()->addItem(meanDepth);
|
scene()->addItem(meanDepth);
|
||||||
// I cannot seem to figure out if an object that I find with itemAt() on the scene
|
// I cannot seem to figure out if an object that I find with itemAt() on the scene
|
||||||
|
@ -304,6 +307,9 @@ void ProfileWidget2::setupItemOnScene()
|
||||||
setupItem(ambPressureItem, timeAxis, percentageAxis, dataModel, DivePlotDataModel::AMBPRESSURE, DivePlotDataModel::TIME, 1);
|
setupItem(ambPressureItem, timeAxis, percentageAxis, dataModel, DivePlotDataModel::AMBPRESSURE, DivePlotDataModel::TIME, 1);
|
||||||
setupItem(gflineItem, timeAxis, percentageAxis, dataModel, DivePlotDataModel::GFLINE, DivePlotDataModel::TIME, 1);
|
setupItem(gflineItem, timeAxis, percentageAxis, dataModel, DivePlotDataModel::GFLINE, DivePlotDataModel::TIME, 1);
|
||||||
setupItem(diveProfileItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0);
|
setupItem(diveProfileItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0);
|
||||||
|
setupItem(meanDepthItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::INSTANT_MEANDEPTH, DivePlotDataModel::TIME, 1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS, VISIBILITY_SETTINGS) \
|
#define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS, VISIBILITY_SETTINGS) \
|
||||||
setupItem(ITEM, timeAxis, gasYAxis, dataModel, DivePlotDataModel::VERTICAL_COLUMN, DivePlotDataModel::TIME, 0); \
|
setupItem(ITEM, timeAxis, gasYAxis, dataModel, DivePlotDataModel::VERTICAL_COLUMN, DivePlotDataModel::TIME, 0); \
|
||||||
|
@ -1002,6 +1008,7 @@ void ProfileWidget2::setProfileState()
|
||||||
cylinderPressureAxis->setPos(itemPos.cylinder.pos.on);
|
cylinderPressureAxis->setPos(itemPos.cylinder.pos.on);
|
||||||
heartBeatItem->setVisible(prefs.hrgraph);
|
heartBeatItem->setVisible(prefs.hrgraph);
|
||||||
meanDepth->setVisible(true);
|
meanDepth->setVisible(true);
|
||||||
|
meanDepthItem->setVisible(prefs.show_average_depth);
|
||||||
|
|
||||||
diveComputerText->setVisible(true);
|
diveComputerText->setVisible(true);
|
||||||
diveComputerText->setPos(itemPos.dcLabel.on);
|
diveComputerText->setPos(itemPos.dcLabel.on);
|
||||||
|
|
|
@ -23,6 +23,7 @@ struct dive;
|
||||||
struct plot_info;
|
struct plot_info;
|
||||||
class ToolTipItem;
|
class ToolTipItem;
|
||||||
class MeanDepthLine;
|
class MeanDepthLine;
|
||||||
|
class DiveMeanDepth;
|
||||||
class DiveReportedCeiling;
|
class DiveReportedCeiling;
|
||||||
class DiveTextItem;
|
class DiveTextItem;
|
||||||
class TemperatureAxis;
|
class TemperatureAxis;
|
||||||
|
@ -161,6 +162,7 @@ private:
|
||||||
TimeAxis *timeAxis;
|
TimeAxis *timeAxis;
|
||||||
DiveProfileItem *diveProfileItem;
|
DiveProfileItem *diveProfileItem;
|
||||||
DiveTemperatureItem *temperatureItem;
|
DiveTemperatureItem *temperatureItem;
|
||||||
|
DiveMeanDepthItem *meanDepthItem;
|
||||||
DiveCartesianAxis *cylinderPressureAxis;
|
DiveCartesianAxis *cylinderPressureAxis;
|
||||||
DiveGasPressureItem *gasPressureItem;
|
DiveGasPressureItem *gasPressureItem;
|
||||||
MeanDepthLine *meanDepth;
|
MeanDepthLine *meanDepth;
|
||||||
|
|
Loading…
Add table
Reference in a new issue