Things are pretty pretty now. :)
can a few of you take a look and tell me what you think?
( enable / disable pp graphs, move from one dive to another )
From b9cd00b225dcb365d8520dcd82bce3fbaa523d57 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Sat, 15 Feb 2014 22:54:41 -0200
Subject: [PATCH 9/9] Make possible to hide some of the grid lines.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/divecartesianaxis.cpp | 16 ++++++++++++++--
 qt-ui/profile/divecartesianaxis.h   |  2 ++
 qt-ui/profile/profilewidget2.cpp    | 10 ++++------
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index 705e06a..bb77a34 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -101,6 +101,17 @@ void DiveCartesianAxis::setTextVisible(bool arg1)
 	}
 }
 
+void DiveCartesianAxis::setLinesVisible(bool arg1)
+{
+	if(lineVisibility == arg1){
+		return;
+	}
+	lineVisibility  = arg1;
+	Q_FOREACH(DiveLineItem *item, lines){
+		item->setVisible(lineVisibility );
+	}
+}
+
 template<typename T> void emptyList( QList<T*>& list, double steps){
 	if (!list.isEmpty() && list.size() > steps) {
 		while (list.size() > steps) {
@@ -223,9 +234,10 @@ void DiveCartesianAxis::updateTicks()
 		}
 	}
 
-	Q_FOREACH(DiveTextItem *item, labels){
+	Q_FOREACH(DiveTextItem *item, labels)
 		item->setVisible(textVisibility);
-	}
+	Q_FOREACH(DiveLineItem  *item, lines)
+		item->setVisible(lineVisibility);
 }
 
 void DiveCartesianAxis::animateChangeLine(const QLineF& newLine)
diff --git a/qt-ui/profile/divecartesianaxis.h b/qt-ui/profile/divecartesianaxis.h
index 7db47ae..1bfb4b9 100644
--- a/qt-ui/profile/divecartesianaxis.h
+++ b/qt-ui/profile/divecartesianaxis.h
@@ -37,6 +37,7 @@ public:
 	void setTextColor(const QColor& color);
 	void animateChangeLine(const QLineF& newLine);
 	void setTextVisible(bool arg1);
+	void setLinesVisible(bool arg1);
 	void setLineSize(qreal lineSize);
 	int unitSystem;
 public slots:
@@ -57,6 +58,7 @@ protected:
 	double tick_size;
 	QColor textColor;
 	bool textVisibility;
+	bool lineVisibility;
 	double labelScale;
 	qreal line_size;
 };
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index ecaa3b1..06f1f67 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -176,14 +176,12 @@ void ProfileWidget2::setupItemOnScene()
 	CREATE_PP_GAS( po2GasItem, PO2, PO2, PO2_ALERT, "po2threshold", "po2graph");
 #undef CREATE_PP_GAS
 
-#ifdef QT_NO_DEBUG // Some debug helpers.
 	temperatureAxis->setTextVisible(false);
+	temperatureAxis->setLinesVisible(false);
 	cylinderPressureAxis->setTextVisible(false);
-#else
-	temperatureAxis->setTextVisible(true);
-	cylinderPressureAxis->setTextVisible(true);
-#endif
-
+	cylinderPressureAxis->setLinesVisible(false);
+	timeAxis->setLinesVisible(true);
+	profileYAxis->setLinesVisible(true);
 }
 
 void ProfileWidget2::setupItemSizes()
-- 
1.9.0

From 8ae1d2557a3437658e06e67cb785a4e80d65b0fe Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Sat, 15 Feb 2014 22:49:30 -0200
Subject: [PATCH 8/9] Better setup of the defaults for the grid.

This patch creates better defaults for the grid lines,
size, position and z-level.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/divecartesianaxis.cpp | 2 ++
 qt-ui/profile/profilewidget2.cpp    | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index e176d4f..705e06a 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -183,6 +183,7 @@ void DiveCartesianAxis::updateTicks()
 		label->setBrush(QBrush(textColor));
 		label->setBrush(colorForValue(currValueText));
 		label->setScale(fontLabelScale());
+		label->setZValue(1);
 		labels.push_back(label);
 		if (orientation == RightToLeft || orientation == LeftToRight) {
 			label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
@@ -209,6 +210,7 @@ void DiveCartesianAxis::updateTicks()
 		pen.setCosmetic(true);
 		pen.setWidthF(2);
 		line->setPen(pen);
+		line->setZValue(0);
 		lines.push_back(line);
 		if (orientation == RightToLeft || orientation == LeftToRight) {
 			line->setLine(0,-line_size,0, 0);
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index e68b543..ecaa3b1 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -126,7 +126,7 @@ void ProfileWidget2::setupItemOnScene()
 	profileYAxis->setTickSize(1);
 	profileYAxis->setLineSize(96);
 
-	timeAxis->setLineSize(96);
+	timeAxis->setLineSize(94);
 
 	gasYAxis->setOrientation(DiveCartesianAxis::BottomToTop);
 	gasYAxis->setTickInterval(1);
-- 
1.9.0

From 8fe134c4f1fa7d0d244ebbb9b2ac371f2405d5a0 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Sat, 15 Feb 2014 22:43:27 -0200
Subject: [PATCH 7/9] Creates the grids.

Creates the grids, and the way that they move is fabulous <3

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/divecartesianaxis.cpp | 28 +++++++++++++++++++++++++++-
 qt-ui/profile/profilewidget2.cpp    |  4 ++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index c47ff4a..e176d4f 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -65,7 +65,7 @@ DiveCartesianAxis::DiveCartesianAxis() : QObject(),
 	labelScale(1.0),
 	tick_size(0),
 	textVisibility(true),
-	line_size(-1)
+	line_size(1)
 {
 	setPen(gridPen());
 }
@@ -195,6 +195,32 @@ void DiveCartesianAxis::updateTicks()
 		}
 	}
 
+	// Add's the rest of the needed Ticks / Text.
+	for (int i = lines.size(); i < steps; i++,  currValueText += interval) {
+		qreal childPos;
+		if (orientation == TopToBottom || orientation == LeftToRight) {
+		childPos = begin + i * stepSize;
+		} else {
+			childPos = begin - i * stepSize;
+		}
+		DiveLineItem *line = new DiveLineItem(this);
+		QPen pen;
+		pen.setBrush(getColor(TIME_GRID));
+		pen.setCosmetic(true);
+		pen.setWidthF(2);
+		line->setPen(pen);
+		lines.push_back(line);
+		if (orientation == RightToLeft || orientation == LeftToRight) {
+			line->setLine(0,-line_size,0, 0);
+			line->animateMoveTo(childPos, m.y1());
+		} else {
+			QPointF p1 = mapFromScene(3, 0);
+			QPointF p2 = mapFromScene(line_size, 0);
+			line->setLine(p1.x(), 0, p2.x(), 0);
+			line->animateMoveTo(m.x1(), childPos);
+		}
+	}
+
 	Q_FOREACH(DiveTextItem *item, labels){
 		item->setVisible(textVisibility);
 	}
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 088cfba..e68b543 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -124,6 +124,9 @@ void ProfileWidget2::setupItemOnScene()
 	profileYAxis->setMinimum(0);
 	profileYAxis->setTickInterval(M_OR_FT(10,30));
 	profileYAxis->setTickSize(1);
+	profileYAxis->setLineSize(96);
+
+	timeAxis->setLineSize(96);
 
 	gasYAxis->setOrientation(DiveCartesianAxis::BottomToTop);
 	gasYAxis->setTickInterval(1);
@@ -131,6 +134,7 @@ void ProfileWidget2::setupItemOnScene()
 	gasYAxis->setMinimum(0);
 	gasYAxis->setModel(dataModel);
 	gasYAxis->setFontLabelScale(0.7);
+	gasYAxis->setLineSize(96);
 
 	temperatureAxis->setOrientation(DiveCartesianAxis::BottomToTop);
 	temperatureAxis->setTickSize(2);
-- 
1.9.0

From 502308b1f2fa8f4c52dd92213c180a266200d5ba Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Sat, 15 Feb 2014 22:15:45 -0200
Subject: [PATCH 6/9] Changed a bit of the Axis update method to move the
 lines.

Changed the axis update method to move the lines alongside
the texts.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/divecartesianaxis.cpp | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index c272ffe..c47ff4a 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -118,7 +118,8 @@ void DiveCartesianAxis::updateTicks()
 	// unused so far:
 	// QGraphicsView *view = scene()->views().first();
 	double steps = (max - min) / interval;
-	double currValue = min;
+	double currValueText = min;
+	double currValueLine = min;
 
 	if (steps < 1)
 		return;
@@ -144,15 +145,12 @@ void DiveCartesianAxis::updateTicks()
 	}
 	stepSize = stepSize / steps;
 
-	for (int i = 0, count = labels.size(); i < count; i++, currValue += interval) {
-		qreal childPos;
-		if (orientation == TopToBottom || orientation == LeftToRight) {
-			childPos = begin + i * stepSize;
-		} else {
-			childPos = begin - i * stepSize;
-		}
+	for (int i = 0, count = labels.size(); i < count; i++, currValueText += interval) {
+		qreal childPos = (orientation == TopToBottom || orientation == LeftToRight) ?
+			begin + i * stepSize :
+			begin - i * stepSize;
 
-		labels[i]->setText(textForValue(currValue));
+		labels[i]->setText(textForValue(currValueText));
 		if ( orientation == LeftToRight || orientation == RightToLeft) {
 			labels[i]->animateMoveTo(childPos, m.y1() + tick_size);
 		} else {
@@ -160,8 +158,20 @@ void DiveCartesianAxis::updateTicks()
 		}
 	}
 
+	for (int i = 0, count = lines.size(); i < count; i++, currValueLine += interval) {
+		qreal childPos = (orientation == TopToBottom || orientation == LeftToRight) ?
+			begin + i * stepSize :
+			begin - i * stepSize;
+
+		if ( orientation == LeftToRight || orientation == RightToLeft) {
+			lines[i]->animateMoveTo(childPos, m.y1());
+		} else {
+			lines[i]->animateMoveTo(m.x1(), childPos);
+		}
+	}
+
 	// Add's the rest of the needed Ticks / Text.
-	for (int i = labels.size(); i < steps; i++,  currValue += interval) {
+	for (int i = labels.size(); i < steps; i++,  currValueText += interval) {
 		qreal childPos;
 		if (orientation == TopToBottom || orientation == LeftToRight) {
 		childPos = begin + i * stepSize;
@@ -169,9 +179,9 @@ void DiveCartesianAxis::updateTicks()
 			childPos = begin - i * stepSize;
 		}
 		DiveTextItem *label = new DiveTextItem(this);
-		label->setText(textForValue(currValue));
+		label->setText(textForValue(currValueText));
 		label->setBrush(QBrush(textColor));
-		label->setBrush(colorForValue(currValue));
+		label->setBrush(colorForValue(currValueText));
 		label->setScale(fontLabelScale());
 		labels.push_back(label);
 		if (orientation == RightToLeft || orientation == LeftToRight) {
-- 
1.9.0

From 035141fb3b8f87465d28c06c1aa5be706f42aaf5 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Sat, 15 Feb 2014 21:55:31 -0200
Subject: [PATCH 5/9] New template-based-function: remove the uneeded items on
 a QList.

This function is for non-duplication of code for different
QLists, since I now have Texts and Lines, I needed to make
the code in a way that it worked without dupplication.

it's a pretty standard use of templates, I think that even the
C guys will not be offended by it. :)

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/divecartesianaxis.cpp | 26 +++++++++++++++++++-------
 qt-ui/profile/divecartesianaxis.h   |  3 +++
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index dbcd823..c272ffe 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -64,7 +64,8 @@ DiveCartesianAxis::DiveCartesianAxis() : QObject(),
 	interval(1),
 	labelScale(1.0),
 	tick_size(0),
-	textVisibility(true)
+	textVisibility(true),
+	line_size(-1)
 {
 	setPen(gridPen());
 }
@@ -74,6 +75,11 @@ DiveCartesianAxis::~DiveCartesianAxis()
 
 }
 
+void DiveCartesianAxis::setLineSize(qreal lineSize)
+{
+	line_size = lineSize;
+}
+
 void DiveCartesianAxis::setOrientation(Orientation o)
 {
 	orientation = o;
@@ -95,6 +101,15 @@ void DiveCartesianAxis::setTextVisible(bool arg1)
 	}
 }
 
+template<typename T> void emptyList( QList<T*>& list, double steps){
+	if (!list.isEmpty() && list.size() > steps) {
+		while (list.size() > steps) {
+				T *removedItem = list.takeLast();
+				Animations::animDelete(removedItem);
+		}
+	}
+}
+
 void DiveCartesianAxis::updateTicks()
 {
 	if (!scene())
@@ -108,12 +123,9 @@ void DiveCartesianAxis::updateTicks()
 	if (steps < 1)
 		return;
 
-	if (!labels.isEmpty() && labels.size() > steps) {
-		while (labels.size() > steps) {
-				DiveTextItem *removedText = labels.takeLast();
-				Animations::animDelete(removedText);
-		}
-	}
+	emptyList(labels, steps);
+	emptyList(lines, steps);
+
 	// Move the remaining Ticks / Text to it's corerct position
 	// Regartind the possibly new values for the Axis
 	qreal begin, stepSize;
diff --git a/qt-ui/profile/divecartesianaxis.h b/qt-ui/profile/divecartesianaxis.h
index 58468f2..7db47ae 100644
--- a/qt-ui/profile/divecartesianaxis.h
+++ b/qt-ui/profile/divecartesianaxis.h
@@ -37,6 +37,7 @@ public:
 	void setTextColor(const QColor& color);
 	void animateChangeLine(const QLineF& newLine);
 	void setTextVisible(bool arg1);
+	void setLineSize(qreal lineSize);
 	int unitSystem;
 public slots:
 	virtual void updateTicks();
@@ -49,6 +50,7 @@ protected:
 	virtual QColor colorForValue(double value);
 	Orientation orientation;
 	QList<DiveTextItem*> labels;
+	QList<DiveLineItem*> lines;
 	double min;
 	double max;
 	double interval;
@@ -56,6 +58,7 @@ protected:
 	QColor textColor;
 	bool textVisibility;
 	double labelScale;
+	qreal line_size;
 };
 
 class DepthAxis : public DiveCartesianAxis {
-- 
1.9.0

From 85ce47352bf6575868fdb2b29d17db3afe442b96 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Sat, 15 Feb 2014 21:46:14 -0200
Subject: [PATCH 4/9] Removed the class 'CartesianPlane'

This class was pratically a re-do of the axis, I'll do the
axis to plot the lines when it feels like it.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/divecartesianaxis.cpp | 85 -------------------------------------
 qt-ui/profile/divecartesianaxis.h   | 23 ----------
 qt-ui/profile/profilewidget2.cpp    | 14 ------
 qt-ui/profile/profilewidget2.h      |  2 -
 4 files changed, 124 deletions(-)

diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index cc8901d..dbcd823 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -347,91 +347,6 @@ QString TemperatureAxis::textForValue(double value)
 	return QString::number(mkelvin_to_C( (int) value));
 }
 
-
-void DiveCartesianPlane::setLeftAxis(DiveCartesianAxis* axis)
-{
-	leftAxis = axis;
-	connect(leftAxis, SIGNAL(maxChanged()), this, SLOT(setup()));
-	if (bottomAxis)
-		setup();
-}
-
-void DiveCartesianPlane::setBottomAxis(DiveCartesianAxis* axis)
-{
-	bottomAxis = axis;
-	connect(bottomAxis, SIGNAL(maxChanged()), this, SLOT(setup()));
-	if (leftAxis)
-		setup();
-}
-
-QLineF DiveCartesianPlane::horizontalLine() const
-{
-	return (bottomAxis) ? bottomAxis->line() : QLineF();
-}
-
-void DiveCartesianPlane::setHorizontalLine(QLineF line)
-{
-	if (IS_FP_SAME(horizontalSize, line.length()))
-		return;
-	horizontalSize = line.length();
-	setup();
-}
-
-void DiveCartesianPlane::setVerticalLine(QLineF line)
-{
-	if (IS_FP_SAME(verticalSize, line.length()))
-		return;
-	verticalSize = line.length();
-	setup();
-}
-
-QLineF DiveCartesianPlane::verticalLine() const
-{
-	return (leftAxis) ? leftAxis->line() : QLineF();
-}
-
-void DiveCartesianPlane::setup()
-{
-	if (!leftAxis || !bottomAxis || !scene())
-		return;
-
-	setPen(gridPen());
-// This creates a Grid around the axis, creating the cartesian plane.
-	const int top = leftAxis->posAtValue(leftAxis->minimum());
-	// unused for now:
-	// const int bottom = leftAxis->posAtValue(leftAxis->maximum());
-	const int left = bottomAxis->posAtValue(bottomAxis->minimum());
-	// unused for now:
-	// const int right = bottomAxis->posAtValue(bottomAxis->maximum());
-
-	setRect(0, 0, horizontalSize, verticalSize);
-	setPos(left, top);
-
-	qDeleteAll(horizontalLines);
-	qDeleteAll(verticalLines);
-	horizontalLines.clear();
-	verticalLines.clear();
-
-	// DEPTH is M_OR_FEET(10,30), Minutes are 600, per line.
-	for (int i = leftAxis->minimum(), max = leftAxis->maximum(); i < max; i += M_OR_FT(10,30)) {
-		DiveLineItem *line = new DiveLineItem(this);
-		line->setLine(0, 0, horizontalSize, 0);
-		line->setPos(0,leftAxis->posAtValue(i)-top);
-		line->setZValue(-1);
-		line->setPen(gridPen());
-		horizontalLines.push_back(line);
-	}
-
-	for (int i = bottomAxis->minimum(), max = bottomAxis->maximum(); i < max; i += 600) { // increments by 10 minutes.
-		DiveLineItem *line = new DiveLineItem(this);
-		line->setLine(0, 0, 0, verticalSize);
-		line->setPos(bottomAxis->posAtValue(i)-left, 0);
-		line->setZValue(-1);
-		line->setPen(gridPen());
-		verticalLines.push_back(line);
-	}
-}
-
 PartialGasPressureAxis::PartialGasPressureAxis()
 {
 	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(preferencesChanged()));
diff --git a/qt-ui/profile/divecartesianaxis.h b/qt-ui/profile/divecartesianaxis.h
index 7c528b4..58468f2 100644
--- a/qt-ui/profile/divecartesianaxis.h
+++ b/qt-ui/profile/divecartesianaxis.h
@@ -97,27 +97,4 @@ private:
 	DivePlotDataModel *model;
 };
 
-// This is a try. Maybe the CartesianPlane should have the X and Y
-// axis and handle things internally?
-class DiveCartesianPlane :public QObject, public QGraphicsRectItem{
-	Q_OBJECT
-	Q_PROPERTY(QLineF verticalLine READ verticalLine WRITE setVerticalLine)
-	Q_PROPERTY(QLineF horizontalLine READ horizontalLine WRITE setHorizontalLine)
-public:
-	void setLeftAxis(DiveCartesianAxis *axis);
-	void setBottomAxis(DiveCartesianAxis *axis);
-	void setHorizontalLine(QLineF line);
-	void setVerticalLine(QLineF line);
-	QLineF horizontalLine() const;
-	QLineF verticalLine() const;
-public slots:
-	void setup();
-private:
-	DiveCartesianAxis *leftAxis;
-	DiveCartesianAxis *bottomAxis;
-	QList<DiveLineItem*> verticalLines;
-	QList<DiveLineItem*> horizontalLines;
-	qreal verticalSize;
-	qreal horizontalSize;
-};
 #endif // DIVECARTESIANAXIS_H
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 284a75c..088cfba 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -63,7 +63,6 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
 	temperatureAxis(new TemperatureAxis()),
 	timeAxis(new TimeAxis()),
 	diveProfileItem(new DiveProfileItem()),
-	cartesianPlane(new DiveCartesianPlane()),
 	temperatureItem(new DiveTemperatureItem()),
 	cylinderPressureAxis(new DiveCartesianAxis()),
 	gasPressureItem(new DiveGasPressureItem()),
@@ -104,7 +103,6 @@ void ProfileWidget2::addItemsToScene()
 	scene()->addItem(cylinderPressureAxis);
 	scene()->addItem(temperatureItem);
 	scene()->addItem(gasPressureItem);
-	scene()->addItem(cartesianPlane);
 	scene()->addItem(meanDepth);
 	scene()->addItem(diveComputerText);
 	scene()->addItem(diveCeiling);
@@ -148,10 +146,6 @@ void ProfileWidget2::setupItemOnScene()
 	meanDepth->setZValue(1);
 	meanDepth->setAxis(profileYAxis);
 
-	cartesianPlane->setBottomAxis(timeAxis);
-	cartesianPlane->setLeftAxis(profileYAxis);
-	cartesianPlane->setZValue(-1);
-
 	diveComputerText->setAlignment(Qt::AlignRight | Qt::AlignBottom);
 	diveComputerText->setBrush(getColor(TIME_TEXT));
 
@@ -351,7 +345,6 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 	meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth));
 
 	dataModel->emitDataChanged();
-	cartesianPlane->setup();
 	// 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
 	// while all other items are up there on the constructor.
@@ -484,7 +477,6 @@ void ProfileWidget2::setEmptyState()
 	diveComputerText->setVisible(false);
 	diveCeiling->setVisible(false);
 	reportedCeiling->setVisible(false);
-	cartesianPlane->setVisible(false);
 	Q_FOREACH(DiveCalculatedTissue *tissue, allTissues){
 		tissue->setVisible(false);
 	}
@@ -525,19 +517,13 @@ void ProfileWidget2::setProfileState()
 	timeAxis->setLine(itemPos.time.expanded);
 
 	cylinderPressureAxis->setPos(itemPos.cylinder.pos.on);
-
-
 	temperatureAxis->setPos(itemPos.temperature.pos.on);
 
-	cartesianPlane->setVisible(true);
 	meanDepth->setVisible(true);
 
 	diveComputerText->setVisible(true);
 	diveComputerText->setPos(itemPos.dcLabel.on);
 
-	cartesianPlane->setHorizontalLine( itemPos.time.expanded );
-	cartesianPlane->setVerticalLine( itemPos.depth.expanded );
-
 	diveCeiling->setVisible(s.value("calcceiling").toBool());
 	reportedCeiling->setVisible(s.value("dcceiling").toBool());
 
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index 41a5d26..b7cdbff 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -31,7 +31,6 @@ class DepthAxis;
 class DiveCartesianAxis;
 class DiveProfileItem;
 class TimeAxis;
-class DiveCartesianPlane;
 class DiveTemperatureItem;
 class DiveGasPressureItem;
 class DiveCalculatedCeiling;
@@ -84,7 +83,6 @@ private:
 	TemperatureAxis *temperatureAxis;
 	TimeAxis *timeAxis;
 	DiveProfileItem *diveProfileItem;
-	DiveCartesianPlane *cartesianPlane;
 	DiveTemperatureItem *temperatureItem;
 	DiveCartesianAxis *cylinderPressureAxis;
 	DiveGasPressureItem *gasPressureItem;
-- 
1.9.0

From d074f9d189ca3dbe614fab042b4c168b80eee92c Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Sat, 15 Feb 2014 21:05:47 -0200
Subject: [PATCH 3/9] Move the Events when a partial pressure graph is enabled
 / disabled

The events were static on the canvas even if the profile changed
it's size because of a toggle of the partial pressure gas. this
patch makes it moves animately on the canvas till it's correct
place.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/diveeventitem.cpp | 18 ++++++++++++------
 qt-ui/profile/diveeventitem.h   |  3 ++-
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
index 2250a73..e744e6a 100644
--- a/qt-ui/profile/diveeventitem.cpp
+++ b/qt-ui/profile/diveeventitem.cpp
@@ -1,6 +1,7 @@
 #include "diveeventitem.h"
 #include "diveplotdatamodel.h"
 #include "divecartesianaxis.h"
+#include "animationfunctions.h"
 #include "dive.h"
 #include <QDebug>
 
@@ -14,19 +15,20 @@ DiveEventItem::DiveEventItem(QObject* parent): DivePixmapItem(parent),
 void DiveEventItem::setHorizontalAxis(DiveCartesianAxis* axis)
 {
 	hAxis = axis;
-	recalculatePos();
+	recalculatePos(true);
 }
 
 void DiveEventItem::setModel(DivePlotDataModel* model)
 {
 	dataModel = model;
-	recalculatePos();
+	recalculatePos(true);
 }
 
 void DiveEventItem::setVerticalAxis(DiveCartesianAxis* axis)
 {
 	vAxis = axis;
-	recalculatePos();
+	recalculatePos(true);
+	connect(vAxis, SIGNAL(sizeChanged()), this, SLOT(recalculatePos()));
 }
 
 void DiveEventItem::setEvent(struct event* ev)
@@ -34,7 +36,7 @@ void DiveEventItem::setEvent(struct event* ev)
 	internalEvent = ev;
 	setupPixmap();
 	setupToolTipString();
-	recalculatePos();
+	recalculatePos(true);
 }
 
 void DiveEventItem::setupPixmap()
@@ -101,7 +103,7 @@ void DiveEventItem::eventVisibilityChanged(const QString& eventName, bool visibl
 {
 }
 
-void DiveEventItem::recalculatePos()
+void DiveEventItem::recalculatePos(bool instant)
 {
 	if (!vAxis || !hAxis || !internalEvent || !dataModel) {
 		return;
@@ -117,5 +119,9 @@ void DiveEventItem::recalculatePos()
 	int depth = dataModel->data(dataModel->index(result.first().row(), DivePlotDataModel::DEPTH)).toInt();
 	qreal x = hAxis->posAtValue(internalEvent->time.seconds);
 	qreal y = vAxis->posAtValue(depth);
-	setPos(x, y);
+	if (!instant){
+		Animations::moveTo(this, x, y, 500);
+	}else{
+		setPos(x,y);
+	}
 }
diff --git a/qt-ui/profile/diveeventitem.h b/qt-ui/profile/diveeventitem.h
index cd55f56..f43fee0 100644
--- a/qt-ui/profile/diveeventitem.h
+++ b/qt-ui/profile/diveeventitem.h
@@ -16,9 +16,10 @@ public:
 	void setVerticalAxis(DiveCartesianAxis *axis);
 	void setHorizontalAxis(DiveCartesianAxis *axis);
 	void setModel(DivePlotDataModel *model);
+public slots:
+	void recalculatePos(bool instant = false);
 private:
 	void setupToolTipString();
-	void recalculatePos();
 	void setupPixmap();
 	DiveCartesianAxis *vAxis;
 	DiveCartesianAxis *hAxis;
-- 
1.9.0

From 94b6a3996ec705756c05f6dbad482fa67afd33cc Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Sat, 15 Feb 2014 20:48:58 -0200
Subject: [PATCH 2/9] If the depth is zero, dont show it.

The first depth label of it's axis is always zero, do not
show it.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/divecartesianaxis.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index be83dcc..cc8901d 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -275,6 +275,8 @@ void DiveCartesianAxis::setColor(const QColor& color)
 
 QString DepthAxis::textForValue(double value)
 {
+	if (value == 0)
+		return QString();
 	return get_depth_string(value, false, false);
 }
 
-- 
1.9.0

From 121bb079b69d7c0eb62845bf4886398f6593c1cd Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Sat, 15 Feb 2014 20:44:49 -0200
Subject: [PATCH 1/9] Fix crash opening testdive0.xml

That particular dive didn't had a temperature, and thus
we got a crash while accessing the last temperature
text.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/diveprofileitem.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index a07132f..58dfa49 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -267,7 +267,8 @@ void DiveTemperatureItem::modelDataChanged(const QModelIndex& topLeft, const QMo
 	    ((abs(last_valid_temp - last_printed_temp) > 500) || ((double)last / (double)sec < 0.75))) {
 		createTextItem(sec, last_valid_temp);
 	}
-	texts.last()->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
+	if( texts.count())
+		texts.last()->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
 }
 
 void DiveTemperatureItem::createTextItem(int sec, int mkelvin)
-- 
1.9.0

From 9f75071c3dcd623478a91c4f832d93fbc899f88c Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Sat, 15 Feb 2014 23:01:20 -0200
Subject: [PATCH 10/10] Fix z-value of the PartialPressure gas graph over the
 timeAxis

Fiz zvalue of the partialPressure Gas Graph over the TimeAxis,
and also corrects the position of the PartialPressure gas graph,
that appeared to 'float' over the TimeAxis, now it's on the
very top of it.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/profilewidget2.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 06f1f67..422adab 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -169,7 +169,8 @@ void ProfileWidget2::setupItemOnScene()
 	ITEM->setThreshouldSettingsKey(THRESHOULD_SETTINGS); \
 	ITEM->setVisibilitySettingsKey(VISIBILITY_SETTINGS); \
 	ITEM->setColors(getColor(COLOR), getColor(COLOR_ALERT)); \
-	ITEM->preferencesChanged();
+	ITEM->preferencesChanged(); \
+	ITEM->setZValue(99);
 
 	CREATE_PP_GAS( pn2GasItem, PN2, PN2, PN2_ALERT, "pn2threshold", "pn2graph");
 	CREATE_PP_GAS( pheGasItem, PHE, PHE, PHE_ALERT, "phethreshold", "phegraph");
@@ -182,6 +183,8 @@ void ProfileWidget2::setupItemOnScene()
 	cylinderPressureAxis->setLinesVisible(false);
 	timeAxis->setLinesVisible(true);
 	profileYAxis->setLinesVisible(true);
+	gasYAxis->setZValue(timeAxis->zValue()+1);
+
 }
 
 void ProfileWidget2::setupItemSizes()
@@ -218,9 +221,9 @@ void ProfileWidget2::setupItemSizes()
 
 	// Partial Gas Axis Config
 	itemPos.partialPressure.pos.on.setX(97);
-	itemPos.partialPressure.pos.on.setY(60);
+	itemPos.partialPressure.pos.on.setY(67);
 	itemPos.partialPressure.pos.off.setX(110);
-	itemPos.partialPressure.pos.off.setY(60);
+	itemPos.partialPressure.pos.off.setY(63);
 	itemPos.partialPressure.expanded.setP1(QPointF(0,0));
 	itemPos.partialPressure.expanded.setP2(QPointF(0,30));
 
-- 
1.9.0

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to