slow day today.
From f59bd425908d65c9c59286988bfba9a10e47df25 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tcanabr...@kde.org>
Date: Wed, 22 Jan 2014 15:08:19 -0200
Subject: [PATCH 1/3] Added a MeanDepthItem that has 2 strings.

The dirk's implementation of the MeanDepth item was correct,
but in order to add the 2 strings to it ( one at the begin,
one at the end ) I'd had to put more stuff inside the ProfileWidget
that's already packed with graphics items.

So I created a new class MeanDepthItem that contains this 2 strings
and will get updated whenever the value changes.

I also fixed a math inconsistency where I changed RIGHT to LEFt.
(wich fixed a few text-placements, and broke others.)

Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org>
---
 qt-ui/profile/diveprofileitem.cpp | 26 +++++++++++++++++++++++++-
 qt-ui/profile/diveprofileitem.h   | 14 ++++++++++++++
 qt-ui/profile/divetextitem.cpp    |  4 ++--
 qt-ui/profile/profilewidget2.cpp  |  3 ++-
 qt-ui/profile/profilewidget2.h    |  3 ++-
 5 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 9fda214..d0c3fb8 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -7,6 +7,7 @@
 #include "dive.h"
 #include "profilegraphics.h"
 #include "preferences.h"
+#include "helpers.h"
 
 #include <QPen>
 #include <QPainter>
@@ -384,7 +385,6 @@ void DiveCalculatedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsI
 	QGraphicsPolygonItem::paint(painter, option, widget);
 }
 
-
 void DiveReportedCeiling::modelDataChanged()
 {
 	if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1)
@@ -425,3 +425,27 @@ void DiveReportedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsIte
 {
 	QGraphicsPolygonItem::paint(painter, option, widget);
 }
+
+MeanDepthLine::MeanDepthLine()
+{
+	leftText = new DiveTextItem(this);
+	leftText->setAlignment(Qt::AlignRight | Qt::AlignBottom);
+	leftText->setBrush(getColor(MEAN_DEPTH));
+	rightText = new DiveTextItem(this);
+	rightText->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
+	rightText->setBrush(getColor(MEAN_DEPTH));
+	leftText->setPos(0, 0);
+	rightText->setPos(line().length(), 0);
+}
+
+void MeanDepthLine::setLine(qreal x1, qreal y1, qreal x2, qreal y2){
+	QGraphicsLineItem::setLine(x1, y1, x2, y2);
+	leftText->setPos(x1, 0);
+	rightText->setPos(x2, 0);
+}
+
+void MeanDepthLine::setMeanDepth(int value)
+{
+	leftText->setText(get_depth_string(value, false, false));
+	rightText->setText(get_depth_string(value, false, false));
+}
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index 57b1e70..792f08a 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -4,6 +4,8 @@
 #include <QObject>
 #include <QGraphicsPolygonItem>
 #include "graphicsview-common.h"
+#include "divelineitem.h"
+
 /* This is the Profile Item, it should be used for quite a lot of things
  on the profile view. The usage should be pretty simple:
 
@@ -100,4 +102,16 @@ public:
 	virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
 	virtual void preferencesChanged();
 };
+
+class MeanDepthLine : public DiveLineItem{
+	Q_OBJECT
+public:
+	MeanDepthLine();
+	void setMeanDepth(int value);
+	void setLine(qreal x1, qreal y1, qreal x2, qreal y2);
+private:
+	int meanDepth;
+	DiveTextItem *leftText;
+	DiveTextItem *rightText;
+};
 #endif
\ No newline at end of file
diff --git a/qt-ui/profile/divetextitem.cpp b/qt-ui/profile/divetextitem.cpp
index 0bf0710..163bb64 100644
--- a/qt-ui/profile/divetextitem.cpp
+++ b/qt-ui/profile/divetextitem.cpp
@@ -59,9 +59,9 @@ void DiveTextItem::updateText()
 			(internalAlignFlags & Qt::AlignBottom) ? +rect.height() :
 	/*(internalAlignFlags & Qt::AlignVCenter  ? */ +rect.height() / 4;
 
-	xPos = (internalAlignFlags & Qt::AlignLeft ) ? +rect.width() :
+	xPos = (internalAlignFlags & Qt::AlignLeft ) ? -rect.width() :
 		(internalAlignFlags & Qt::AlignHCenter) ?  -rect.width()/2 :
-	 /* (internalAlignFlags & Qt::AlignRight) */ -rect.width();
+	 /* (internalAlignFlags & Qt::AlignRight) */ 0;
 
 	textPath.addText( xPos, yPos, fnt, internalText);
 	QPainterPathStroker stroker;
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index b5610e4..4b19af1 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -37,7 +37,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
 	temperatureItem(NULL),
 	gasPressureItem(NULL),
 	cartesianPlane(new DiveCartesianPlane()),
-	meanDepth(new DiveLineItem()),
+	meanDepth(new MeanDepthLine()),
 	diveComputerText(new DiveTextItem()),
 	diveCeiling(NULL),
 	reportedCeiling(NULL)
@@ -304,6 +304,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 	timeAxis->updateTicks();
 	cylinderPressureAxis->setMinimum(pInfo.minpressure);
 	cylinderPressureAxis->setMaximum(pInfo.maxpressure);
+	meanDepth->setMeanDepth(pInfo.meandepth);
 	meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth));
 	dataModel->setDive(current_dive, pInfo);
 
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index 3699419..780a9b2 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -16,6 +16,7 @@
 #include "graphicsview-common.h"
 #include "divelineitem.h"
 
+class MeanDepthLine;
 class DiveReportedCeiling;
 class DiveTextItem;
 class TemperatureAxis;
@@ -83,7 +84,7 @@ private:
 	DiveTemperatureItem *temperatureItem;
 	DiveCartesianAxis *cylinderPressureAxis;
 	DiveGasPressureItem *gasPressureItem;
-	DiveLineItem *meanDepth;
+	MeanDepthLine *meanDepth;
 	QList<DiveEventItem*> eventItems;
 	DiveTextItem *diveComputerText;
 	DiveCalculatedCeiling *diveCeiling;
-- 
1.8.5.3

From 2e42c979627cdefadf8170081b258d66bb8dc87b Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tcanabr...@kde.org>
Date: Wed, 22 Jan 2014 15:29:25 -0200
Subject: [PATCH 2/3] Fix the ZLevel value of some items.

Almost all of the items on the new profile were being painted
on the same ZLevel, so the level of awesomeness were a bit random.
this puts things on the correct spots, events on top of everything,
profile at the bottom, things on the middle.

Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org>
---
 qt-ui/profile/profilewidget2.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 4b19af1..fa41da9 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -90,6 +90,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
 	meanDepth->setLine(0,0,96,0);
 	meanDepth->setX(3);
 	meanDepth->setPen(QPen(QBrush(Qt::red), 0, Qt::SolidLine));
+	meanDepth->setZValue(1);
 
 	cartesianPlane->setBottomAxis(timeAxis);
 	cartesianPlane->setLeftAxis(profileYAxis);
@@ -319,6 +320,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 	diveProfileItem->setModel(dataModel);
 	diveProfileItem->setVerticalDataColumn(DivePlotDataModel::DEPTH);
 	diveProfileItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
+	diveProfileItem->setZValue(0);
 	scene()->addItem(diveProfileItem);
 
 	qDeleteAll(eventItems);
@@ -347,6 +349,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 	temperatureItem->setModel(dataModel);
 	temperatureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE);
 	temperatureItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
+	temperatureItem->setZValue(1);
 	scene()->addItem(temperatureItem);
 
 	if(gasPressureItem){
@@ -359,6 +362,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 	gasPressureItem->setModel(dataModel);
 	gasPressureItem->setVerticalDataColumn(DivePlotDataModel::TEMPERATURE);
 	gasPressureItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
+	gasPressureItem->setZValue(1);
 	scene()->addItem(gasPressureItem);
 
 	if(diveCeiling){
@@ -371,6 +375,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 	diveCeiling->setModel(dataModel);
 	diveCeiling->setVerticalDataColumn(DivePlotDataModel::CEILING);
 	diveCeiling->setHorizontalDataColumn(DivePlotDataModel::TIME);
+	diveCeiling->setZValue(1);
 	scene()->addItem(diveCeiling);
 
 	diveComputerText->setText(currentdc->model);
@@ -385,6 +390,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 		tissueItem->setModel(dataModel);
 		tissueItem->setVerticalDataColumn(DivePlotDataModel::TISSUE_1 + i);
 		tissueItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
+		tissueItem->setZValue(1);
 		allTissues.append(tissueItem);
 		scene()->addItem(tissueItem);
 	}
@@ -399,6 +405,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 	reportedCeiling->setModel(dataModel);
 	reportedCeiling->setVerticalDataColumn(DivePlotDataModel::CEILING);
 	reportedCeiling->setHorizontalDataColumn(DivePlotDataModel::TIME);
+	reportedCeiling->setZValue(1);
 	scene()->addItem(reportedCeiling);
 	emit startProfileState();
 }
-- 
1.8.5.3

From bcf7437a30b5aded47663ec06426f7ca21923e2a Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tcanabr...@kde.org>
Date: Wed, 22 Jan 2014 17:10:18 -0200
Subject: [PATCH 3/3] Prepared terrain for the Profile Partial Pressures

This patch makes the Cartesian Axis of the Profile Depth
shrinks, and together with it, the Profile Depth and the
grid lines. There will be probably a lot of things that didn't
had it's correct position fixed, so I'll fix them in the later commits.

Signed-off-by: Tomaz Canabrava <tcanabr...@kde.org>
---
 qt-ui/profile/divecartesianaxis.cpp | 29 +++++++++++++++++++++++++++--
 qt-ui/profile/divecartesianaxis.h   | 13 +++++++++++--
 qt-ui/profile/diveprofileitem.cpp   |  1 -
 qt-ui/profile/profilewidget2.cpp    |  3 +--
 4 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index 505b60d..c1c2b6b 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -2,13 +2,13 @@
 #include "divelineitem.h"
 #include "divetextitem.h"
 #include "helpers.h"
-
+#include "preferences.h"
 #include <QPen>
 #include <QGraphicsScene>
 #include <QDebug>
-#include <QPropertyAnimation>
 #include <QGraphicsView>
 #include <QStyleOption>
+#include <QSettings>
 
 static QPen gridPen(){
 	QPen pen;
@@ -140,6 +140,13 @@ void DiveCartesianAxis::updateTicks()
 	}
 }
 
+void DiveCartesianAxis::animateChangeLine(const QLineF& newLine)
+{
+    setLine(newLine);
+    updateTicks();
+    sizeChanged();
+}
+
 void DiveCartesianAxis::setShowText(bool show)
 {
 	showText = show;
@@ -243,6 +250,24 @@ QColor DepthAxis::colorForValue(double value)
 	return QColor(Qt::red);
 }
 
+DepthAxis::DepthAxis(){
+    connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
+    settingsChanged(); // force the correct size of the line.
+}
+
+void DepthAxis::settingsChanged()
+{
+    QSettings s;
+
+    s.beginGroup("TecDetails");
+    bool ppGraph = s.value("phegraph").toBool() || s.value("po2graph").toBool() || s.value("pn2graph").toBool();
+    if(ppGraph){
+        animateChangeLine(QLineF(0,2,0,60));
+    }else{
+        animateChangeLine(QLineF(0,2,0,98));
+    }
+}
+
 QColor TimeAxis::colorForValue(double value)
 {
 	Q_UNUSED(value);
diff --git a/qt-ui/profile/divecartesianaxis.h b/qt-ui/profile/divecartesianaxis.h
index b2aecbf..6df0486 100644
--- a/qt-ui/profile/divecartesianaxis.h
+++ b/qt-ui/profile/divecartesianaxis.h
@@ -3,6 +3,8 @@
 
 #include <QObject>
 #include <QGraphicsLineItem>
+
+class QPropertyAnimation;
 class DiveTextItem;
 class DiveLineItem;
 
@@ -21,7 +23,6 @@ public:
 	void setTickInterval(double interval);
 	void setOrientation(Orientation orientation);
 	void setTickSize(qreal size);
-	void updateTicks();
 	double minimum() const;
 	double maximum() const;
 	qreal valueAt(const QPointF& p);
@@ -31,7 +32,10 @@ public:
 	void setTextColor(const QColor& color);
 	void setShowTicks(bool show);
 	void setShowText(bool show);
+	void animateChangeLine(const QLineF& newLine);
 	int unitSystem;
+public slots:
+    void updateTicks();
 signals:
 	void sizeChanged();
 protected:
@@ -49,9 +53,14 @@ protected:
 };
 
 class DepthAxis : public DiveCartesianAxis {
+    Q_OBJECT
+public:
+    DepthAxis();
 protected:
 	QString textForValue(double value);
 	QColor colorForValue(double value);
+private slots:
+    void settingsChanged();
 };
 
 class TimeAxis : public DiveCartesianAxis {
@@ -89,4 +98,4 @@ private:
 	qreal verticalSize;
 	qreal horizontalSize;
 };
-#endif
\ No newline at end of file
+#endif
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index d0c3fb8..8314fae 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -135,7 +135,6 @@ void DiveProfileItem::modelDataChanged()
 	pat.setColorAt(1, getColor(DEPTH_BOTTOM));
 	pat.setColorAt(0, getColor(DEPTH_TOP));
 	setBrush(QBrush(pat));
-	AbstractProfilePolygonItem::preferencesChanged();
 
 	int last = -1;
 	for (int i = 0, count  = dataModel->rowCount(); i < count; i++) {
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index fa41da9..e6a60da 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -64,7 +64,6 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
 	timeAxis->setTickInterval(600); // 10 to 10 minutes?
 
 	// Default Sizes of the Items.
-	profileYAxis->setLine(0, 0, 0, 90);
 	profileYAxis->setX(2);
 	profileYAxis->setTickSize(1);
 	gasYAxis->setLine(0, 0, 0, 20);
@@ -188,7 +187,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
 	profileState->assignProperty(this, "backgroundBrush", getColor(::BACKGROUND));
 	profileState->assignProperty(background, "y",  backgroundOffCanvas);
 	profileState->assignProperty(profileYAxis, "x", profileYAxisOnCanvas);
-	profileState->assignProperty(profileYAxis, "line", profileYAxisExpanded);
+    //profileState->assignProperty(profileYAxis, "line", profileYAxisExpanded);
 	profileState->assignProperty(gasYAxis, "x", 0);
 	profileState->assignProperty(timeAxis, "y", timeAxisOnCanvas);
 	profileState->assignProperty(depthController, "y", depthControllerOffCanvas);
-- 
1.8.5.3

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

Reply via email to