Deivide can say that he loves me one more time.
From 6b1a4d743f81ea5c8835eb7c4e428f75912a6fcf Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 30 Dec 2014 21:57:12 -0200
Subject: [PATCH 9/9] Make the Mean Depth Instant Line Works.

It's a bit jumpy, but works.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/diveprofileitem.cpp | 15 +++++++++++++--
 qt-ui/profile/diveprofileitem.h   |  2 ++
 qt-ui/profile/profilewidget2.cpp  |  4 +++-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 1d930ad..03a2451 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -812,7 +812,7 @@ void DiveReportedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsIte
 	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->setBrush(getColor(MEAN_DEPTH));
@@ -930,12 +930,23 @@ void PartialPressureGasItem::setColors(const QColor &normal, const QColor &alert
 	alertColor = alert;
 }
 
-InstantMeanDepthLine::InstantMeanDepthLine()
+InstantMeanDepthLine::InstantMeanDepthLine(): vAxis(NULL), hAxis(NULL)
 {
 
 }
 
 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));
+		}
+	}
 }
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index 68a6deb..4963103 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -209,6 +209,8 @@ protected:
 class InstantMeanDepthLine : public MeanDepthLine {
 	Q_OBJECT
 public:
+	DiveCartesianAxis *hAxis;
+	DiveCartesianAxis *vAxis;
 	InstantMeanDepthLine();
 public slots:
 	void mouseMoved(int time, int depth);
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 979e9c2..b241325 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -117,7 +117,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
 	addItemsToScene();
 	scene()->installEventFilter(this);
 	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
-
+	connect(this, SIGNAL(mouseMoved(int,int)), instantMeanDepth, SLOT(mouseMoved(int,int)));
 	QAction *action = NULL;
 #define ADD_ACTION(SHORTCUT, Slot)                                  \
 	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);
 	Animations::moveTo(meanDepth,3, profileYAxis->posAtValue(plotInfo.meandepth));
 
+	instantMeanDepth->vAxis = profileYAxis;
+	instantMeanDepth->hAxis = timeAxis;
 	instantMeanDepth->setVisible(prefs.show_average_depth);
 	instantMeanDepth->setModel(dataModel);
 
-- 
2.2.1

From 30e749b8af2887996c896b57f54081b8771a8838 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 30 Dec 2014 21:30:13 -0200
Subject: [PATCH 8/9] Added a new signal to send the current Time/Depth of the
 mouse pos

As the explanation says. :)

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/profilewidget2.cpp | 5 +++++
 qt-ui/profile/profilewidget2.h   | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 12b04f4..979e9c2 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -848,6 +848,11 @@ void ProfileWidget2::mouseMoveEvent(QMouseEvent *event)
 		&& timeAxis->minimum() <= hValue){
 		mouseFollowerVertical->setPos(pos.x(), profileYAxis->line().y1());
 	}
+	if ( timeAxis->maximum() >= hValue
+	     && timeAxis->minimum() <= hValue
+	     && profileYAxis->maximum() >= vValue
+	     && profileYAxis->minimum() <= vValue )
+		emit mouseMoved(hValue, vValue);
 }
 
 bool ProfileWidget2::eventFilter(QObject *object, QEvent *event)
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index f35d071..51acef9 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -84,6 +84,9 @@ public:
 	void clearHandlers();
 	State currentState;
 
+signals:
+	void mouseMoved(int time, int depth);
+
 public
 slots: // Necessary to call from QAction's signals.
 	void settingsChanged();
-- 
2.2.1

From c6506e9ddcccf5dc02b59ef1ce475df5dd934df8 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 30 Dec 2014 21:25:23 -0200
Subject: [PATCH 7/9] Add the instantMeanDepth on Scene

But nothing is hoocked yet.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/profilewidget2.cpp | 12 ++++++++++++
 qt-ui/profile/profilewidget2.h   |  1 +
 2 files changed, 13 insertions(+)

diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index ba71a9f..12b04f4 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -102,6 +102,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
 	mouseFollowerHorizontal(new DiveLineItem()),
 	rulerItem(new RulerItem2()),
 	tankItem(new TankItem()),
+	instantMeanDepth(new InstantMeanDepthLine()),
 	isGrayscale(false),
 	printMode(false),
 	shouldCalculateMaxTime(true),
@@ -170,6 +171,7 @@ ProfileWidget2::~ProfileWidget2()
 	delete mouseFollowerHorizontal;
 	delete rulerItem;
 	delete tankItem;
+	delete instantMeanDepth;
 }
 
 #define SUBSURFACE_OBJ_DATA 1
@@ -208,6 +210,7 @@ void ProfileWidget2::addItemsToScene()
 	scene()->addItem(tankItem);
 	scene()->addItem(mouseFollowerHorizontal);
 	scene()->addItem(mouseFollowerVertical);
+	scene()->addItem(instantMeanDepth);
 	QPen pen(QColor(Qt::red).lighter());
 	pen.setWidth(0);
 	mouseFollowerHorizontal->setPen(pen);
@@ -273,6 +276,12 @@ void ProfileWidget2::setupItemOnScene()
 	meanDepth->setZValue(1);
 	meanDepth->setAxis(profileYAxis);
 
+	instantMeanDepth->setLine(0, 0, 96, 0);
+	instantMeanDepth->setX(3);
+	instantMeanDepth->setPen(QPen(QBrush(Qt::red), 0, Qt::SolidLine));
+	instantMeanDepth->setZValue(1);
+	instantMeanDepth->setAxis(profileYAxis);
+
 	diveComputerText->setAlignment(Qt::AlignRight | Qt::AlignTop);
 	diveComputerText->setBrush(getColor(TIME_TEXT, isGrayscale));
 
@@ -597,6 +606,9 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
 	meanDepth->setLine(0, 0, timeAxis->posAtValue(currentdc->duration.seconds), 0);
 	Animations::moveTo(meanDepth,3, profileYAxis->posAtValue(plotInfo.meandepth));
 
+	instantMeanDepth->setVisible(prefs.show_average_depth);
+	instantMeanDepth->setModel(dataModel);
+
 	dataModel->emitDataChanged();
 	// The event items are a bit special since we don't know how many events are going to
 	// exist on a dive, so I cant create cache items for that. that's why they are here
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index 5a612d9..f35d071 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -179,6 +179,7 @@ private:
 	DiveLineItem *mouseFollowerHorizontal;
 	RulerItem2 *rulerItem;
 	TankItem *tankItem;
+	InstantMeanDepthLine *instantMeanDepth;
 	bool isGrayscale;
 	bool printMode;
 
-- 
2.2.1

From dda04748ebd978f93bedec4ec7ee965de1cef529 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 30 Dec 2014 21:19:15 -0200
Subject: [PATCH 6/9] Move stuff to protected on DepthLine

I wanna use some of it on the InstantMeanDepthLine

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/diveprofileitem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index d7e3814..68a6deb 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -199,7 +199,7 @@ public
 slots:
 	void axisLineChanged();
 
-private:
+protected:
 	int meanDepth;
 	DiveTextItem *leftText;
 	DiveTextItem *rightText;
-- 
2.2.1

From 207b14da19022d5d9e01478f801adb5c09a25b0f Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 30 Dec 2014 21:13:50 -0200
Subject: [PATCH 5/9] Set Data Model on the MeanDepth line

this way we can poke around data for the mean depth line.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/diveprofileitem.cpp | 4 ++++
 qt-ui/profile/diveprofileitem.h   | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index d960591..1d930ad 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -822,6 +822,10 @@ MeanDepthLine::MeanDepthLine() : meanDepth(0), leftText(new DiveTextItem(this)),
 	rightText->setPos(line().length(), 0);
 }
 
+void MeanDepthLine::setModel(DivePlotDataModel *m){
+	model = m;
+}
+
 void MeanDepthLine::setLine(qreal x1, qreal y1, qreal x2, qreal y2)
 {
 	QGraphicsLineItem::setLine(x1, y1, x2, y2);
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index 7f375f1..d7e3814 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -194,6 +194,7 @@ public:
 	void setMeanDepth(int value);
 	void setLine(qreal x1, qreal y1, qreal x2, qreal y2);
 	void setAxis(DiveCartesianAxis *a);
+	void setModel(DivePlotDataModel *m);
 public
 slots:
 	void axisLineChanged();
@@ -202,6 +203,7 @@ private:
 	int meanDepth;
 	DiveTextItem *leftText;
 	DiveTextItem *rightText;
+	DivePlotDataModel *model;
 };
 
 class InstantMeanDepthLine : public MeanDepthLine {
-- 
2.2.1

From cd6ec97b7eabfdbb1badd957ffc024535e4fcc87 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 30 Dec 2014 21:10:21 -0200
Subject: [PATCH 4/9] Addeds skeleton for the Instant Mean Depth Line

This class will hold the visible line of the mean depth
	for the time 'now'

	Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/diveprofileitem.cpp | 10 ++++++++++
 qt-ui/profile/diveprofileitem.h   |  8 ++++++++
 qt-ui/profile/profilewidget2.cpp  |  2 --
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index e2148bf..d960591 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -925,3 +925,13 @@ void PartialPressureGasItem::setColors(const QColor &normal, const QColor &alert
 	normalColor = normal;
 	alertColor = alert;
 }
+
+InstantMeanDepthLine::InstantMeanDepthLine()
+{
+
+}
+
+void InstantMeanDepthLine::mouseMoved(int time, int depth)
+{
+
+}
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index 1bdf4b3..7f375f1 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -204,6 +204,14 @@ private:
 	DiveTextItem *rightText;
 };
 
+class InstantMeanDepthLine : public MeanDepthLine {
+	Q_OBJECT
+public:
+	InstantMeanDepthLine();
+public slots:
+	void mouseMoved(int time, int depth);
+};
+
 class PartialPressureGasItem : public AbstractProfilePolygonItem {
 	Q_OBJECT
 public:
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index d631e3c..ba71a9f 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -836,8 +836,6 @@ void ProfileWidget2::mouseMoveEvent(QMouseEvent *event)
 		&& timeAxis->minimum() <= hValue){
 		mouseFollowerVertical->setPos(pos.x(), profileYAxis->line().y1());
 	}
-
-
 }
 
 bool ProfileWidget2::eventFilter(QObject *object, QEvent *event)
-- 
2.2.1

From f6dfcc64d88282e610885b6f12b50d6e98920545 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 30 Dec 2014 20:27:39 -0200
Subject: [PATCH 3/9] Added the runnimg_sum data to the Data Model to be
 displayed on the Profile

without this nothing would be displayed.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/diveplotdatamodel.cpp | 4 ++++
 qt-ui/profile/diveplotdatamodel.h   | 1 +
 2 files changed, 5 insertions(+)

diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp
index 09ef76f..2e3f522 100644
--- a/qt-ui/profile/diveplotdatamodel.cpp
+++ b/qt-ui/profile/diveplotdatamodel.cpp
@@ -58,6 +58,8 @@ QVariant DivePlotDataModel::data(const QModelIndex &index, int role) const
 			return AMB_PERCENTAGE;
 		case GFLINE:
 			return item.gfline;
+		case INSTANT_MEANDEPTH:
+			return item.running_sum;
 		}
 	}
 
@@ -131,6 +133,8 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
 		return tr("Heart Beat");
 	case GFLINE:
 		return tr("Gradient Factor");
+	case INSTANT_MEANDEPTH:
+		return tr("Mean Depth/s");
 	}
 	if (role == Qt::DisplayRole && section >= TISSUE_1 && section <= TISSUE_16) {
 		return QString("Ceiling: %1").arg(section - TISSUE_1);
diff --git a/qt-ui/profile/diveplotdatamodel.h b/qt-ui/profile/diveplotdatamodel.h
index 416ae69..91e6a8b 100644
--- a/qt-ui/profile/diveplotdatamodel.h
+++ b/qt-ui/profile/diveplotdatamodel.h
@@ -62,6 +62,7 @@ public:
 		HEARTBEAT,
 		AMBPRESSURE,
 		GFLINE,
+		INSTANT_MEANDEPTH,
 		COLUMNS
 	};
 	explicit DivePlotDataModel(QObject *parent = 0);
-- 
2.2.1

From c1fa3f6f036ae4f2efc8aae76b18bbb6e2e9df8d Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 30 Dec 2014 20:17:23 -0200
Subject: [PATCH 2/9] Added the Gradient Factor on the Table

It was impossible to guess what this column was just by
looking at it.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/diveplotdatamodel.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp
index abffa45..09ef76f 100644
--- a/qt-ui/profile/diveplotdatamodel.cpp
+++ b/qt-ui/profile/diveplotdatamodel.cpp
@@ -129,6 +129,8 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
 		return tr("Ambient pressure");
 	case HEARTBEAT:
 		return tr("Heart Beat");
+	case GFLINE:
+		return tr("Gradient Factor");
 	}
 	if (role == Qt::DisplayRole && section >= TISSUE_1 && section <= TISSUE_16) {
 		return QString("Ceiling: %1").arg(section - TISSUE_1);
-- 
2.2.1

From c6de8037c769b8ba9b0185ea174a8b25429ce8bf Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 30 Dec 2014 20:16:25 -0200
Subject: [PATCH 1/9] Added text for the heart beat data on the table

this was missing on the ui and it was really hard
to guess what it was.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/diveplotdatamodel.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp
index 51aea1b..abffa45 100644
--- a/qt-ui/profile/diveplotdatamodel.cpp
+++ b/qt-ui/profile/diveplotdatamodel.cpp
@@ -127,6 +127,8 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
 		return tr("pO₂");
 	case AMBPRESSURE:
 		return tr("Ambient pressure");
+	case HEARTBEAT:
+		return tr("Heart Beat");
 	}
 	if (role == Qt::DisplayRole && section >= TISSUE_1 && section <= TISSUE_16) {
 		return QString("Ceiling: %1").arg(section - TISSUE_1);
-- 
2.2.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to