Commit graph

72 commits

Author SHA1 Message Date
Rick Walsh
b1ed04a7f4 Have divedatapoint store cylinder id instead of gasmix
Determining the correct cylinder index from a known gas mix can be
complicated, but it is trivial to look up the gasmix from the cylinder_t
structure.

It makes sense to remember which cylinder is being used. This simplifies
handling changing a cylinder's gas mix, either directly by the user, or
indirectly in the planner. It also permits tracking of multiple cylinders of
the same mix, e.g. independent twins / sidemount.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09 12:07:25 -07:00
Dirk Hohndel
9aa7399c1d Now that we are building with C++11 we need override keyword
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-23 16:43:05 -07:00
Linus Torvalds
36a3f649c5 Don't show surface events at the beginning or end of the dive
That's just annoying and pointless.  So we arbitrarily say that surface
events within the first and last 30s of the dive are suppressed.

But we now do show them in the middle, in case the sampling rate is too
low, and the profile itself doesn't show that we got to the surface.

These heuristics still needs tweaking - if the profile already shows
that we're at the surface, then we should probably suppress the event
triangle.

But in the meantime this at least gets rid of the truly pointless cases.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-01 13:08:45 -07:00
Dirk Hohndel
eb07faef00 Only do 9 minute interval for min/max/avg
We don't use 3 and 6 minute values anywhere, so why calculate them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-20 15:55:51 -07:00
Linus Torvalds
e0ac1c9a26 Fix 3-, 6- and 9-minute min/max calculations
Make them use indices into the plot-info, fix calculation of average
depth, and fix and add comments.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-20 15:36:25 -07:00
Dirk Hohndel
176b92776b Silence warning
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-14 09:19:01 -07:00
Linus Torvalds
eff4059802 Start using the actual cylinder data for gas switch events
Now that gas switch events always have indices into the cylinder table,
start using that to look up the gas mix from the cylinders rather than
from the gas switch event itself.  In other words, the cylinder index is
now the primary data for gas switch events.

This means that now as you change the cylinder information, the gas
switch events will automatically update to reflect those changes.

Note that on loading data from the outside (either from a xml file, from
a git/cloud account, or from a dive computer), we may or may not
initially have an index for the gas change event.  The external data may
be from an older version of subsurface, or it may be from a
libdivecomputer download that just doesn't give index data at all.

In that case, we will do:

 - if there is no index, but there is explicit gas mix information, we
   will look up the index based on that gas mix, picking the cylinder
   that has the closest mix.

 - if there isn't even explicit gas mix data, so we only have the event
   value from libdivecomputer, we will turn that value into a gasmix,
   and use that to look up the cylinder index as above.

 - if no valid cylinder information is available at all, gas switch
   events will just be dropped.

When saving the data, we now always save the cylinder index, and the gas
mix associated with that cylinder (that gas mix will be ignored on load,
since the index is the primary, but it makes the event much easier to
read).

It is worth noting we do not modify the libdivecomputer value, even if
the gasmix has changed, so that remains as a record of the original
download.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:37:18 -07:00
Dirk Hohndel
7be962bfc2 Move subsurface-core to core and qt-mobile to mobile-widgets
Having subsurface-core as a directory name really messes with
autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an
autocomplete conflict and also was inconsistent with the desktop-widget
name for the directory containing the "other" UI.

And while cleaning up the resulting change in the path name for include
files, I decided to clean up those even more to make them consistent
overall.

This could have been handled in more commits, but since this requires a
make clean before the build, it seemed more sensible to do it all in one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:33:58 -07:00
Linus Torvalds
2d760a7bff Don't write back dive data that hasn't changed in git
This caches the git ID for the dive on load, and avoids building the
dive directory and hashing it on save as long as nothing has invalidated
the git ID cache.

That should make it much faster to write back data to the git
repository, since the dive tree structure and the divecomputer blobs in
particular are the bulk of it (due to all the sample data).  It's not
actually the git operations that are all that expensive, it's literally
generating the big blob with all the snprintf() calls for the data.

The git save used to be a fairly expensive with large data sets,
especially noticeable on mobile with much weaker CPU's.  This should
speed things up by at least a factor of two.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 17:27:10 -07:00
Dirk Hohndel
dd0d88f9d7 QML UI: take device pixel ratio into account when scaling pixmaps on iOS
This way warning icons and tank change icons and other event markers are no
longer ridiculously tiny on retina screens. Oddly this doesn't appear to be
needed on Android, only on iOS.

Fixes #1033

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-28 17:05:29 -05:00
Dirk Hohndel
bff3588c25 Undo two more unsigned changes that are no longer needed
With this master should compile without signed / unsigned warning,
hopefully without any more breakage.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 10:11:39 -07:00
Rick Walsh
cbd332fbcc Profile widget: Display gradient factors used in plan
Currently, the gradient factors displayed at the top of the profile are the
gradient factors set in preferences.  This is correct for saved dives, but
when planning dives, the gradient factors displayed at the top of the profile
should be the gradient factors used in the plan.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-19 11:31:13 -07:00
Dirk Hohndel
032de3549d Clean up signedness confusion in tankitem.cpp
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:50:26 -08:00
Dirk Hohndel
28100e8b7e Clean up signedness confusion in diveprofileitem.cpp
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:50:26 -08:00
Dirk Hohndel
4156bc3651 Silence warnings in profilewidget2.cpp
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:50:23 -08:00
Tomaz Canabrava
0f386420e0 Silence warnings in divetooltipitem.cpp
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:43:53 -08:00
Tomaz Canabrava
309f0f722a Silence warnings in divepixmapitem.cpp
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 11:43:33 -08:00
Tomaz Canabrava
6f494964de Silence warnings in TankItem
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-08 20:58:13 -08:00
Tomaz Canabrava
98e8a04d01 Silence warnings in Profilewidget2
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-08 20:58:09 -08:00
Tomaz Canabrava
16320bb580 Silence warnings in DiveProfileItem
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-08 20:58:05 -08:00
Tomaz Canabrava
dc6299185b Silence warnings in DiveEventItem
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-08 20:58:02 -08:00
Tomaz Canabrava
07606160cb Silence warnings in DiveCartesianAxis
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-08 20:57:52 -08:00
Tomaz Canabrava
39313c5b33 Clean up handling of various include file
This is in the context of the iOS port and shouldn't impact any of the
other builds.

[Dirk Hohndel: refactored the iOS patches]

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-06 11:03:00 -08:00
Dirk Hohndel
38ab11a6c0 Add option to allocate the samples in fake_dc()
We (ab)use fake_dc() to create a pleasing profile for a manually added
dive. Based on it's intended use, fake_dc() simply handed back a dc
structure that pointed at staticly allocated samples - that's obviously
(now that I think about it) going to blow up in my face if I edit a
manually added dive more than once.

So now we have an option for fake_dc() to actually allocate the samples -
this way the rest of the code can treat these samples as we would treat
samples created any other way. We can free them and replace them with a
new set.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-20 09:36:14 -08:00
Dirk Hohndel
17134be96d Profile: don't compile code that isn't needed on mobile
We were creating a couple dozen objects that we never needed and because
of that triggered several dozen callbacks whenever the model data changed.
All for UI elements of the profile that are either not used in the mobile
app (like the calculated ceiling or the partial pressure / tissue
saturation graphs), or are only useful when using the profile
interactively (which we also don't do on mobile).

I don't know if this will make a significant impact on performance, but it
seems like the right thing to do either way.

A positive side effect is that the odd blue line on top of the rendered
profile is gone as well.

Fixes #1007

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-06 13:29:31 -08:00
Rick Walsh
8facdc62fd profile-widget: use smaller event icons on Subsurface-mobile
Smaller event icons fit the mobile display much nicer

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-05 22:02:24 -08:00
Dirk Hohndel
130f4cd7ac Do not run the deco calculations in the mobile app
We don't show the calculated ceilings and calculating them is compute
intensive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-05 20:45:18 -08:00
Tomaz Canabrava
411f455291 Fix bug on the visibility of the Ruler Graph
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25 13:04:39 -08:00
Tomaz Canabrava
7433396333 Fix Ceiling Graph
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25 13:04:32 -08:00
Tomaz Canabrava
49332bc635 Fix Display / Hide Calculated Ceiling
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25 13:04:24 -08:00
Tomaz Canabrava
2d3f7f0a90 More Profile Itens on the new Settings
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25 13:04:21 -08:00
Tomaz Canabrava
2d96139566 Changed quite a few shorts to bool on the c++ implementtion
The shorts where being used on the preferences since a long
while and we cannot just simply change them to bool since this
could break the preferences files, so work around that by
changing them to booleans, since it's the correct type for a
true / false answer.

Also, move some plot curves to the new settings style

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25 13:04:16 -08:00
Tomaz Canabrava
2c5fad73e8 Start to use the QSettings ObjectWrapper
start of the QSettinsg Object Wrapper usage on the code
this first patch removes two macros that generated around
200 lines in runtime for something like a quarter of it
Basically, whenever we changed anything we called the
PreferencesDialog::settingsChanged and connected everythign
to that signal, now each setting has it's own changed signal
and we can call it directly.

The best thing about this approach is that we don't trigger
repaints for things that are not directly profile related. (
actually we still do, but the plan is to remove them in due time)

this commit breaks correct atualization of the profile (because
everything was connected to PreferencesDialog::settingsChanged)
and now I need to hunt a bit for the correct connections

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25 13:04:01 -08:00
Tomaz Canabrava
219299dc01 Correctly handle SubsurfaceMobile
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08 08:04:24 -08:00
Joakim Bygdell
f747abaeb2 Small changes to the profile
Due to the small screen of mobile devices,
the positions of the temperature graph and the time axis needs to be shifted
upwards a bit to prevent them from overlapping with the dive computer name.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-05 10:58:11 -08:00
Dirk Hohndel
3a670f8c3b QML UI: don't show "1 of n" for multiple dive computers
This is actually not a change in the QML - it just conditionally compiles out
the code when building Subsurface-mobile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-27 10:06:32 -08:00
Lubomir I. Ivanov
491ef7edc8 diveprofileitem.cpp: fix unused variable warning on mobile
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-06 12:28:01 -08:00
Lubomir I. Ivanov
2aed907525 profilewidget2.cpp: hide the heartbeat graph on an empty state
Opening Subsurface for the first time with heartbeat graph visible
and then immediately doing File->New shows the logo/background in the
profile space while hiding everything except the heartbeat graph.

This patch makes sure that the graph is hidden with everything
else on an empty profile state.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-06 12:19:44 -08:00
K. \"pestophagous\" Heller
2778470b97 Prevent gaschange tank icons from using garbage coords.
Tank icons were shown at incorrect spots on the profile
when the DiveEventItem object held a pointer to a struct
event even after the struct event at that address had
been freed.  When internalEvent is a pointer to freed
memory, internalEvent->time.seconds could have all kinds
of crazy values, which get used in member function
DiveEventItem::recalculatePos to place the tank at bad
x coordinates.

The DiveEventItem(s) no longer store a pointer to memory
that they do not own.  This way, no matter how the path of
execution arrives into slot recalculatePos, we never need
fear that the DiveEventItem will dereference a garbage
pointer to a struct event.

Fixes #968

Signed-off-by: K. Heller <pestophagous@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-03 22:56:23 -08:00
Dirk Hohndel
63eff39edd QML-UI: turn of some profile features
We don't have a tooltip on the QML UI as it's rendered into a pixmal.
We also don't need the timer as we don't need the TTS calculations.
And we don't need the acrobatics to figure out if we're in the planner as
we don't support the visual planner (or any planner, at this point) with
the mobile UI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-01 15:37:28 -08:00
Dirk Hohndel
9dd26a00e8 Profile: avoid potential crash
If things go as planned, then the length of the polygon is the same as the
number of rows in the model. Turns out when running Subsurface-mobile on
Android that simple truth doesn't seem to be correct. Most of the time
the polygon seems to have twice as many elements as the model. But a few
times I ended up in here with a polygon that had fewer elements than the
model. And then things crash.

This simply avoids the crash.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-01 15:20:32 -08:00
Robert C. Helling
d8e38764fd Drag and Drop Images
Now that we have the possibility to add images without meaningful
time stamps to a dive, we should let the user provide that time
offset manually. This patch allowed pictures to be dragged from
the image list to the profile.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-24 09:22:16 -08:00
Lubomir I. Ivanov
f5dbc3b44d Planner: support profile in planner print
The "Print" button in the planner dumps the QTextEdit to
a QPrinter via ::print(). This patch renders the Profile
to a Pixmap which is inserted as Base64 stream in an <img>
tag and fed on top of the QTextEdit HTML contents.

This route preserves the planner notes as text in PDF prints.
The quick alternative is to render the QTextDocument to
a QPixmap as well, but that will not preserve the text
and pagination becomes manual.

Possibly the QTextDocument can be rendered as a QPicture
but pagination is still an issue, while so far there is exactly
one user requesting this feature!

Related small change in ProfileWidget2:
Explicitly hide the tooltip when printMode is true.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-15 21:07:27 -08:00
Sebastian Kügler
52b8cb5aa9 profilewidget2: Only add actions in desktop version
This fixes a bunch of warnings in the mobile version where these slots
are not defined (see the corresponding header's conditionals).

Signed-off-by: Sebastian Kügler <sebas@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-11 19:05:33 -08:00
Lubomir I. Ivanov
003ddc6b52 divetooltipitem.cpp: prettify the tooltip bounds and padding
When the tooltip is expanded, not enough padding is present right
from the text and bottom from it, making the tooltip border
appear very close to the text.

When the tooltip is collapsed (no time entries) it clips
the graph/pixmap which makes the graph bottom left corner appear
to be outside of the tooltip, mainly because of the white border
of the tooltip background and the background rounding.

To prevent these visual artifacts and to prettify the tooltip
this patch:
- makes the rounding 8 instead of 10 of the background rectangle
- doubles the padding left and right from the pixmap
(the above two pretty much move the pixmap bottom left corner
away from the rounded bottom left edge of the tooltip background)
- add more padding right and bottom from the text
- never reduce the height of the tooltip to be smaller than
the graph/pixmap height.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-10 09:08:57 -08:00
Lubomir I. Ivanov
e2550de5e6 profilewidget2.cpp: remove unused variables
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-11-07 22:26:32 -08:00
Dirk Hohndel
bb566f7798 Don't connect to the PreferencesDialog in Subsurface-mobile
Just more untangling from the desktop UI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-06 10:20:18 -08:00
Dirk Hohndel
7e5b66d2c4 Remove more unnecessary include file references
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-06 10:04:17 -08:00
Lubomir I. Ivanov
788b3289e9 remove some mainwindow.h includes
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-06 09:58:46 -08:00
Lubomir I. Ivanov
8e7be1b50a Untangle DiveCalculatedCeiling from MainWindow
DiveCalculatedCeiling is the last class the references
MainWindow in the profile-widget stack.

In modelDataChanged() it looks for the information()
widget and sets a slot for the dateTimeChanged() signal that
information() emits.

To solve the issue we make DiveCalculatedCeiling recieve
a ProfileWidget2 reference and make ProfileWidget2 emit
the dateTimeChangedItems() signal.

ProfileWidget2 itself listens for the dateTimeChanged()
signal that information() emits and emits dateTimeChangedItems()
to notify any possible children/item listeners in the
ProfileWidget2::dateTimeChanged() slot.

The connection between ProfileWidget2 and information()
is set in MainWindow. This makes DiveCalculatedCeiling
unaware of MainWindow and which class originally emits
the dateTimeChanged() signal to ProfileWidget2.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
--
Think delegation.

Tomaz, please take a look at this one, to double check
if i messed up.

also i have zero idea how the mobile app is setting these
connections, if it does so even.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-06 09:58:34 -08:00