diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-01-15 13:34:55 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-16 10:12:31 +0700 |
commit | dd64f1792d853e4d3e124ccd9b9600990880f50e (patch) | |
tree | eaa0a6ba33c8b60e7b88a90f23475a45a2b1119d /qt-ui | |
parent | 52064d9e02a6ca559beb8f8e64e28e2ef77c5e44 (diff) | |
download | subsurface-dd64f1792d853e4d3e124ccd9b9600990880f50e.tar.gz |
Reworked the calculate_max_limits and plotted the dive.
Created a new version of calculate_max_limits that doesn't have a
graphics_context and returns a plot_info. The code is basically the same
as the old calculate_max_limits, so there's not much to talk about.
The rest of the code is just boilerplate to plug the Profile
code with the axis and model stuff, to be plotted on screen.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 067fc97fb..68b42f1b9 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -5,6 +5,7 @@ #include "divecartesianaxis.h" #include "diveprofileitem.h" #include "helpers.h" +#include "profile.h" #include <QStateMachine> #include <QSignalTransition> @@ -228,7 +229,47 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : // Currently just one dive, but the plan is to enable All of the selected dives. void ProfileWidget2::plotDives(QList<dive*> dives) { + // I Know that it's a list, but currently we are + // using just the first. + struct dive *d = dives.first(); + if(!d) + return; + // Here we need to probe for the limits of the dive. + // There's already a function that does exactly that, + // but it's using the graphics context, and I need to + // replace that. + struct divecomputer *currentdc = select_dc(&d->dc); + Q_ASSERT(currentdc); + + /* This struct holds all the data that's about to be plotted. + * I'm not sure this is the best approach ( but since we are + * interpolating some points of the Dive, maybe it is... ) + * The Calculation of the points should be done per graph, + * so I'll *not* calculate everything if something is not being + * shown. + */ + struct plot_info pInfo = calculate_max_limits_new(d, currentdc); + + profileYAxis->setMaximum(pInfo.maxdepth); + profileYAxis->updateTicks(); + timeAxis->setMaximum(pInfo.maxtime); + timeAxis->updateTicks(); + dataModel->setDive(current_dive, pInfo); + + if(diveProfileItem){ + //diveProfileItem->animateDelete(); + scene()->removeItem(diveProfileItem); + delete diveProfileItem; + } + diveProfileItem = new DiveProfileItem(); + diveProfileItem->setHorizontalAxis(timeAxis); + diveProfileItem->setVerticalAxis(profileYAxis); + diveProfileItem->setModel(dataModel); + diveProfileItem->setVerticalDataColumn(DivePlotDataModel::DEPTH); + diveProfileItem->setHorizontalDataColumn(DivePlotDataModel::TIME); + scene()->addItem(diveProfileItem); + emit startProfileState(); } void ProfileWidget2::settingsChanged() |