mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
Make the moving mean depth line work
It's a bit jumpy, but works. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d6fddcaadc
commit
b3e3947b79
3 changed files with 18 additions and 3 deletions
|
@ -812,7 +812,7 @@ void DiveReportedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
||||||
QGraphicsPolygonItem::paint(painter, option, widget);
|
QGraphicsPolygonItem::paint(painter, option, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
MeanDepthLine::MeanDepthLine() : meanDepth(0), leftText(new DiveTextItem(this)), rightText(new DiveTextItem(this))
|
MeanDepthLine::MeanDepthLine() : meanDepth(0), leftText(new DiveTextItem(this)), rightText(new DiveTextItem(this)), model(NULL)
|
||||||
{
|
{
|
||||||
leftText->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
leftText->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
||||||
leftText->setBrush(getColor(MEAN_DEPTH));
|
leftText->setBrush(getColor(MEAN_DEPTH));
|
||||||
|
@ -930,12 +930,23 @@ void PartialPressureGasItem::setColors(const QColor &normal, const QColor &alert
|
||||||
alertColor = alert;
|
alertColor = alert;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstantMeanDepthLine::InstantMeanDepthLine()
|
InstantMeanDepthLine::InstantMeanDepthLine(): vAxis(NULL), hAxis(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstantMeanDepthLine::mouseMoved(int time, int depth)
|
void InstantMeanDepthLine::mouseMoved(int time, int depth)
|
||||||
{
|
{
|
||||||
|
if (model == NULL || scene() == NULL || vAxis == NULL || hAxis == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int count = model->data().nr;
|
||||||
|
for(int i = 0; i < count; i++){
|
||||||
|
struct plot_data pI = model->data().entry[i];
|
||||||
|
if (pI.sec == time) {
|
||||||
|
setMeanDepth(pI.running_sum / time);
|
||||||
|
setLine(0, 0, hAxis->posAtValue(time), 0);
|
||||||
|
setPos(pos().x(), vAxis->posAtValue(pI.running_sum / time));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,8 @@ protected:
|
||||||
class InstantMeanDepthLine : public MeanDepthLine {
|
class InstantMeanDepthLine : public MeanDepthLine {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
DiveCartesianAxis *hAxis;
|
||||||
|
DiveCartesianAxis *vAxis;
|
||||||
InstantMeanDepthLine();
|
InstantMeanDepthLine();
|
||||||
public slots:
|
public slots:
|
||||||
void mouseMoved(int time, int depth);
|
void mouseMoved(int time, int depth);
|
||||||
|
|
|
@ -117,7 +117,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
|
||||||
addItemsToScene();
|
addItemsToScene();
|
||||||
scene()->installEventFilter(this);
|
scene()->installEventFilter(this);
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
||||||
|
connect(this, SIGNAL(mouseMoved(int,int)), instantMeanDepth, SLOT(mouseMoved(int,int)));
|
||||||
QAction *action = NULL;
|
QAction *action = NULL;
|
||||||
#define ADD_ACTION(SHORTCUT, Slot) \
|
#define ADD_ACTION(SHORTCUT, Slot) \
|
||||||
action = new QAction(this); \
|
action = new QAction(this); \
|
||||||
|
@ -606,6 +606,8 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
|
||||||
meanDepth->setLine(0, 0, timeAxis->posAtValue(currentdc->duration.seconds), 0);
|
meanDepth->setLine(0, 0, timeAxis->posAtValue(currentdc->duration.seconds), 0);
|
||||||
Animations::moveTo(meanDepth,3, profileYAxis->posAtValue(plotInfo.meandepth));
|
Animations::moveTo(meanDepth,3, profileYAxis->posAtValue(plotInfo.meandepth));
|
||||||
|
|
||||||
|
instantMeanDepth->vAxis = profileYAxis;
|
||||||
|
instantMeanDepth->hAxis = timeAxis;
|
||||||
instantMeanDepth->setVisible(prefs.show_average_depth);
|
instantMeanDepth->setVisible(prefs.show_average_depth);
|
||||||
instantMeanDepth->setModel(dataModel);
|
instantMeanDepth->setModel(dataModel);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue