there you go
From c8d6be530fea66c07b37226a64df7fba341bf4a9 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Tue, 28 Jan 2014 20:48:41 -0200 Subject: [PATCH 1/4] Made the Calculated Ceiling be Preferences Aware
This patch only adds preference-awareness for the ceiling. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/diveprofileitem.cpp | 7 +++++++ qt-ui/profile/diveprofileitem.h | 1 + 2 files changed, 8 insertions(+) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 23c41a7..d72a838 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -438,6 +438,13 @@ void DiveReportedCeiling::modelDataChanged() setBrush(pat); } +void DiveCalculatedCeiling::preferencesChanged() +{ + QSettings s; + s.beginGroup("TecDetails"); + setVisible(s.value("calcceiling").toBool()); +} + void DiveReportedCeiling::preferencesChanged() { QSettings s; diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index 5c35bf7..41bb053 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -92,6 +92,7 @@ class DiveCalculatedCeiling : public AbstractProfilePolygonItem{ public: virtual void modelDataChanged(); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); + virtual void preferencesChanged(); }; class DiveReportedCeiling : public AbstractProfilePolygonItem{ -- 1.8.5.3
From d328ec7d11b60288c76d0c0bfea7b2eeaf4f1fcc Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Tue, 28 Jan 2014 21:11:14 -0200 Subject: [PATCH 2/4] Always calculate, independent of prefs. Always calculate the decompression information, independent of preferences. this is a better way since we can enable / disable the deco by changing the preferences later, and that will not need to recalculate everything just because a polygon was set to invisible. Signed-off-by: Tomaz Canabrava <[email protected]> --- profile.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/profile.c b/profile.c index 82aa274..66e7a13 100644 --- a/profile.c +++ b/profile.c @@ -1355,8 +1355,7 @@ struct plot_info *create_plot_info(struct dive *dive, struct divecomputer *dc, s void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi) { - if (prefs.profile_calc_ceiling) /* reset deco information to start the calculation */ - init_decompression(dive); + init_decompression(dive); if (last_pi_entry) /* Create the new plot data */ free((void *)last_pi_entry); last_pi_entry = populate_plot_entries(dive, dc, pi); @@ -1364,8 +1363,7 @@ void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plo setup_gas_sensor_pressure(dive, dc, pi); /* Try to populate our gas pressure knowledge */ populate_pressure_information(dive, dc, pi);/* .. calculate missing pressure entries */ calculate_sac(dive, pi); /* Calculate sac */ - if (prefs.profile_calc_ceiling) /* Then, calculate deco information */ - calculate_deco_information(dive, dc, pi, false); + calculate_deco_information(dive, dc, pi, false); calculate_gas_information_new(dive, pi); /* And finaly calculate gas partial pressures */ pi->meandepth = dive->dc.meandepth.mm; analyze_plot_info(pi); -- 1.8.5.3
From 9f62e90796baf490c823b18ec6a44bc6b91162d9 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 29 Jan 2014 10:53:40 -0200 Subject: [PATCH 3/4] Show Gradient Factor. The gradient factor is shown with this patch, but the correct position should still be calculated. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/diveprofileitem.cpp | 12 ++++++++++++ qt-ui/profile/diveprofileitem.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index d72a838..c3be684 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -370,6 +370,14 @@ void DiveGasPressureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte } } +DiveCalculatedCeiling::DiveCalculatedCeiling() +{ + gradientFactor = new DiveTextItem(this); + gradientFactor->setY(0); + gradientFactor->setBrush(getColor(PRESSURE_TEXT)); + gradientFactor->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); +} + void DiveCalculatedCeiling::modelDataChanged() { // We don't have enougth data to calculate things, quit. @@ -392,6 +400,10 @@ void DiveCalculatedCeiling::modelDataChanged() pat.setColorAt(1, getColor(CALC_CEILING_DEEP)); setPen(QPen(QBrush(Qt::NoBrush),0)); setBrush(pat); + + gradientFactor->setX(poly.boundingRect().width()/2); + gradientFactor->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh)); + qDebug() << gradientFactor->pos() << mapToScene(gradientFactor->pos()); } void DiveCalculatedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index 41bb053..980b992 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -90,9 +90,12 @@ class DiveCalculatedCeiling : public AbstractProfilePolygonItem{ Q_OBJECT public: + DiveCalculatedCeiling(); virtual void modelDataChanged(); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); virtual void preferencesChanged(); +private: + DiveTextItem *gradientFactor; }; class DiveReportedCeiling : public AbstractProfilePolygonItem{ -- 1.8.5.3
From 2fef90b20bfc9708d569bdcff118c30c8aa82f9c Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 29 Jan 2014 13:48:06 -0200 Subject: [PATCH 4/4] Fixed positioning of many text items. This patch fixes the positioning of many text items. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/divecartesianaxis.cpp | 2 +- qt-ui/profile/diveprofileitem.cpp | 19 ++++++++----------- qt-ui/profile/divetextitem.cpp | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index 9a3c824..7c91281 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -137,7 +137,7 @@ void DiveCartesianAxis::updateTicks() } } else { if(showText){ - label->setAlignment(Qt::AlignVCenter| Qt::AlignRight); + label->setAlignment(Qt::AlignVCenter| Qt::AlignLeft); label->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10); label->animateMoveTo(m.x1() - tickSize, childPos); } diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index c3be684..335d5ec 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -151,12 +151,12 @@ void DiveProfileItem::modelDataChanged() continue; if ((entry == entry->max[2]) && entry->depth / 100 != last) { - plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignTop, getColor(SAMPLE_DEEP)); + plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignBottom, getColor(SAMPLE_DEEP)); last = entry->depth / 100; } if ((entry == entry->min[2]) && entry->depth / 100 != last) { - plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignBottom, getColor(SAMPLE_SHALLOW)); + plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignTop, getColor(SAMPLE_SHALLOW)); last = entry->depth / 100; } @@ -288,11 +288,8 @@ void DiveGasPressureItem::modelDataChanged() polygons.last().push_back(point); // The polygon thta will be plotted. } setPolygon(boundingPoly); - - //TODO: Instead of deleting all texts, move the existing ones to it's new location. qDeleteAll(texts); texts.clear(); - int mbar, cyl; int seen_cyl[MAX_CYLINDERS] = { false, }; int last_pressure[MAX_CYLINDERS] = { 0, }; @@ -311,8 +308,8 @@ void DiveGasPressureItem::modelDataChanged() if (cyl != entry->cylinderindex) { cyl = entry->cylinderindex; if (!seen_cyl[cyl]) { - plot_pressure_value(mbar, entry->sec, Qt::AlignLeft | Qt::AlignBottom); - plot_gas_value(mbar, entry->sec, Qt::AlignLeft | Qt::AlignTop, + plot_pressure_value(mbar, entry->sec, Qt::AlignRight | Qt::AlignTop); + plot_gas_value(mbar, entry->sec, Qt::AlignRight | Qt::AlignBottom, get_o2(&dive->cylinder[cyl].gasmix), get_he(&dive->cylinder[cyl].gasmix)); seen_cyl[cyl] = true; @@ -324,7 +321,7 @@ void DiveGasPressureItem::modelDataChanged() for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { if (last_time[cyl]) { - plot_pressure_value(last_pressure[cyl], last_time[cyl], Qt::AlignHCenter | Qt::AlignTop); + plot_pressure_value(last_pressure[cyl], last_time[cyl], Qt::AlignRight | Qt::AlignTop); } } } @@ -334,7 +331,7 @@ void DiveGasPressureItem::plot_pressure_value(int mbar, int sec, QFlags<Qt::Alig const char *unit; int pressure = get_pressure_units(mbar, &unit); DiveTextItem *text = new DiveTextItem(this); - text->setPos(hAxis->posAtValue(sec), vAxis->posAtValue(mbar)); + text->setPos(hAxis->posAtValue(sec), vAxis->posAtValue(mbar)-0.5); text->setText(QString("%1 %2").arg(pressure).arg(unit)); text->setAlignment(flags); text->setBrush(getColor(PRESSURE_TEXT)); @@ -376,6 +373,7 @@ DiveCalculatedCeiling::DiveCalculatedCeiling() gradientFactor->setY(0); gradientFactor->setBrush(getColor(PRESSURE_TEXT)); gradientFactor->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); + preferencesChanged(); } void DiveCalculatedCeiling::modelDataChanged() @@ -401,9 +399,8 @@ void DiveCalculatedCeiling::modelDataChanged() setPen(QPen(QBrush(Qt::NoBrush),0)); setBrush(pat); - gradientFactor->setX(poly.boundingRect().width()/2); + gradientFactor->setX(poly.boundingRect().width()/2 + poly.boundingRect().x()); gradientFactor->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh)); - qDebug() << gradientFactor->pos() << mapToScene(gradientFactor->pos()); } void DiveCalculatedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) diff --git a/qt-ui/profile/divetextitem.cpp b/qt-ui/profile/divetextitem.cpp index 72ba480..b939c54 100644 --- a/qt-ui/profile/divetextitem.cpp +++ b/qt-ui/profile/divetextitem.cpp @@ -57,7 +57,7 @@ void DiveTextItem::updateText() qreal xPos = 0, yPos = 0; QRectF rect = fm.boundingRect(internalText); - yPos = (internalAlignFlags & Qt::AlignTop) ? -rect.height() : + yPos = (internalAlignFlags & Qt::AlignTop) ? 0 : (internalAlignFlags & Qt::AlignBottom) ? +rect.height() : /*(internalAlignFlags & Qt::AlignVCenter ? */ +rect.height() / 4; -- 1.8.5.3
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
