Commit graph

484 commits

Author SHA1 Message Date
Dirk Hohndel
02d8dd5d13 Clean up the header files
Lots and lots and lots of header files were being included without being
needed. This attempts to clean some of that crud up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 23:00:43 +13:00
Tomaz Canabrava
e0280048bc Cache the complex items to give us a boost of speed
This cache give us a huge gain in performance, going from
17% moving the mouse frenetically to 9%, wich is quite acceptable.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 10:41:18 +13:00
Tomaz Canabrava
c9499baf22 Fix memleak of QGraphicsRectItem
We used to create a new QGraphicsRectItem everytime a Pixmap
changed. Since I'm pretty sure I deleted every bit of the
PictureItem before setting a new one, no leak was due, but this
version is safer.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 10:41:07 +13:00
Tomaz Canabrava
947010991d Only update text if something changed
We were calling this even if we didn't really change anything
and paths are expensive to paint.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:54:11 +13:00
Tomaz Canabrava
d2c5770ae1 Fix the colors - brush wasn't being set anymore.
Also a bit of code cleanup.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:54:00 +13:00
Tomaz Canabrava
a6e95511a6 Reduce the amount of new/delete when setting a new text on DiveTextItem
We were recreating the PathItems (one for the outline, other for the real
text) for every call to setText. This was a very un-smart move.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:53:26 +13:00
Tomaz Canabrava
ac40c458fa Reduce the refresh rate of the toolTipItem to 25fps.
This reduces a lot of CPU time and makes the overall use of the tooltip a
breeze.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:07:14 +13:00
Tomaz Canabrava
67865a86be Honor prefs.anim_speed on the ToolTip animations
The tooltip animation had a fixed animation speed, this patch
honors the anim_speed on the preferences, and also disables
the animation completely if the speed == 0.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:06:33 +13:00
Tomaz Canabrava
85909ca28d Reduce the number of calls to boundingRect
There are a few calculations that go on boundingRect that can be avoided
if we simply store the result.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:05:48 +13:00
Tomaz Canabrava
85a3cbf8af Fix the colors of the rectangle
Correct pen and brush set. the ToolTip now is correctly rounded,
translucent and happy.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:05:01 +13:00
Tomaz Canabrava
12dd46c140 Implement the paint method to draw the rounded rectangle.
The rectangle is now correct, but the collors are still
wrong. I'm tracking that down - most probably I've set
the wrong pen or brush  ( or both ) somewhere.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:04:37 +13:00
Tomaz Canabrava
48a23b9b3c Remove the background and the separator
Those items were used to fake the background of the path item
but since the rectangle can be painted with a border and a
fill, this is uneeded.

The rect is still ugly.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:04:08 +13:00
Tomaz Canabrava
deafa40d34 Inherit from QGraphicsRectItem instead of QGraphicsShapeItem
a rectangle is *much* faster to paint than a simple ShapeItem,
so this is a safer choice. We still need to create the paint
method so we can use the correct roundness for the rectangle.
Currently it's white with a 1px solid line - terrible. :)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:03:18 +13:00
Tomaz Canabrava
054521d3a1 Reduce the amount of calls to create the background on the ToolTip
We were deleting / recreating the graphics background item for *every*
mouse movement. Now we are just creating the painter path; no more
allocations / desalocations, adding, removing from the scene. This should
make things a tiny bit faster.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 14:47:44 +13:00
Tomaz Canabrava
6a1a6c82bf Reuse the entry tooltip item and do fewer calls for each mouse move
While analizing the code for the mouse movement I've discovered that
we did a lot of uneeded things: Set the color, the pen, the size
of a fixed-colored line, twice.

We also deleted-newed the same Pixmap / Text for every mouse movement
so now we reuse the 'entryToolTip' that consists of a huge line and
a pixmap, and after that we add the other tooltips that are not static

Also, reduced a lot the number of calls to expand() (that did a lot of
math).

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 14:46:57 +13:00
Tomaz Canabrava
3169ec8dc9 Do not set the rectangle if it's the same
Strangelly, this method was being called even if the rectangle was the
same, so we deleted everything and recreated everything again. tsc tsc.

Some more improvement is needed but we are getting there.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 14:28:25 +13:00
Tomaz Canabrava
806d984107 Only update the rectangle if it changed
Very often the rectangle of the ToolTip doesn't need to change but we were
calling and firing an animation for it for *every* mouse movement, even
when we didn't really needed it.
Now it will only fire something if the rectangles are indeed different.

From my tests we reduced the number of calls to the animatior by about 20%
using a real divelog as test.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 14:26:35 +13:00
Tomaz Canabrava
54898b15ff Do not free the membuffer, reuse it
This is an attempt to make fewer calls to alloc functions when the mouse
is moving.

We were creating a membuffer, filling it (malloc / realloc), then freeing
it just after use. but we could simply hold that allocated area and reuse
it again.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 14:23:46 +13:00
Tomaz Canabrava
501f72c697 Speed Improvemens: fewer calls to mapFromScene / mapToScene
We did three cals to mapToScene / mapFromScene on the mouse moveEvent at
the ProfileWidget2 where we only needed to call one in the common case and
two in the worst case.

This doesn't really help in terms of speed (unless you have a really old
cpu) but since it's code that gets called *very* often, it seemed a
reasonable thing to do.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 07:24:13 +13:00
Tomaz Canabrava
db4ffd0b70 Fix memory leak
The QPainter and the QPixmap were being created but never freed. A QPixmap
and a QPainter don't need to be created by new, they can be safely created
on the stack.

So, create them on the stack, pass them via const-reference
and use them correctly.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 07:23:48 +13:00
Tomaz Canabrava
633dd64d2f Major speedup when moving the mouse in the profile
After looking with great care at the result of the mouse movement
on the profile, and also playing a bit with callgrind I've found
out that one thing that we were doing wrong was the way we looked at the
items in the scene, by calling scene()->items with
Qt::ItemIntersectsShape, our shapes are very complex curves
with thousends of points and we have lots of them. and it usually
doesn't matter because *most* of the time we are getting the
tooltip information from 'get_plot_details_new', so no accessing
to items was necessary.

By changing the access from Qt::ItemIntersectsShape to
Qt::IntersectsItemBoundingRect we had a speedup of almost 500x in a
section of code that's very important, and the good thing, nothing bad
happened because one of the only things that we are using this code is to
get information from the events, not the curves.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 07:20:35 +13:00
Cristine Guadelupe
2b19341609 Remove instantMeanDepthLine
Take instantMeanDepthLine out of the code. We have the moving average line
plus the exact data in the information overlay.

Signed-off-by: Cristine Guadelupe <cristineguadelupe@me.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-14 12:24:57 +13:00
Robert C. Helling
e219bc70f8 Refactor dctype -> divemode
... and repair a failed rebase (sorry).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:25 -08:00
Willem Ferguson
d45e870289 Repair minor bug in CCR setpoint graph
Correct minor malfunction with CCR setpoint display. It was showing even
when the po2 display was turned off. This patch ensures that the setpoint
graph only shows when the po2 toolbar button is activated (and in addition
the appropriate checkbox in the Preferences).

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 09:16:29 -08:00
Lubomir I. Ivanov
2b311b1c2c profile: don't show instantMeanDepth for printMode
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-07 12:29:59 -08:00
Dirk Hohndel
925bb019c7 Fix potential crash
Commits 0de3bc8452 ("Display CCR setpoint values on the po2 graph") and
65eed80e37 ("Don't always show the setpoint graph") didn't take into
account that current_dive could be NULL and therefore accessing current_dc
could crash.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-06 20:35:57 -08:00
Joakim Bygdell
4b98d17800 Give oxygen a proper colour in the tankbar
Oxygen should be representad by its own solid green colour not the yellow/green of nitrox.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-05 13:30:47 -08:00
Dirk Hohndel
65eed80e37 Don't always show the setpoint graph
We need to use the same conditional here as we do earlier in the code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-05 11:14:59 -08:00
Willem Ferguson
0de3bc8452 Display CCR setpoint values on the po2 graph
When a CCR dive is viewed and the toolbar button for PO2 is activated,
both the PO2 (green line) and the O2 setpoint (red line) are shown.
This allows evaluation of the PO2 in the CCR loop with respect to the
pre-configured O2 setpoint.

The setpoint graph can be disabled from the Preferences/Graphs tab
by checking the appropriate checkbox.

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-05 09:18:06 -08:00
Joseph W. Joshua
a409c73195 Various capitalization fixes
Fix various discrepancies in the capitalization format, as we are using
'down format' for titles and actions.

Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-05 09:06:35 -08:00
Anton Lundin
6b17f20081 Close two compiler warnings about reordering
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-04 17:52:21 -08:00
Linus Torvalds
08d2ceb66b Extend SAMPLE_EVENT_GASCHANGE2 to have cylinder index in 'flags' field
A value of zero (which is the normal legacy one) remains "unknown", but
the divecomputer backend can now give both gasmix and cylinder number
this way.

Currently only the EON Steel backend does that, but it should be easy
enough to extend others too.

Also, fix the user-visible cylinder numbering in the cylinder change
tooltip to use a human-friendlier one-based numbering (ie first cylinder
is "cyl 1", not "cyl 0")

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-03 21:36:51 -08:00
Linus Torvalds
9a4cafd0f1 Fix gaschange tooltip information
The code tried to look up the cylinder index from the Qt data models,
which was not only horribly confusing, but was also buggy.  I think the
index ends up being off by one when the first cylinder change is hidden
(because it's at the beginning of the dive), but I can't make heads or
tails of that crazy code, so there might be something else going on.

Just remove all the crazy code, and use the event data directly.  Which
gas the gasmix and the (potential) explicit cylinder index already.
It's much more straightforward, and it just automatically gets the right
end result whether some other event is hidden or not.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-02 22:43:21 -08:00
Dirk Hohndel
4c4bc71803 Make the moving mean depth line a less obnoxious color
The red made it stand out way too much.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-01 16:43:30 -08:00
Dirk Hohndel
c4954d90a1 Whitespace cleanup
Quite a bit of wild white space going on...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-01 16:28:37 -08:00
Krzysztof Arentowicz
b6f47883c3 Get rid of mean depth line
Flat mean depth line (whole dive, not the instant one) is redundant as we now
 have a much more useful mean depth graph.

Signed-off-by: Krzysztof Arentowicz <k.arentowicz@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-01 16:28:20 -08:00
Krzysztof Arentowicz
e3378e299a Plot mean depth data
As we already have running depth sum values for each sample
why don't just plot running average depth graph.

Signed-off-by: Krzysztof Arentowicz <k.arentowicz@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-01 16:23:22 -08:00
Krzysztof Arentowicz
ee1ef52330 Avoid divide by 0 error
Avoid crash when moving mouse to left side of the plot when showing
mean depth

Signed-off-by: Krzysztof Arentowicz <k.arentowicz@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-01 16:14:01 -08:00
Tomaz Canabrava
b3e3947b79 Make the moving mean depth line work
It's a bit jumpy, but works.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-30 16:14:53 -08:00
Tomaz Canabrava
d6fddcaadc Add a new signal to send the current time/depth of the mouse pos
As the explanation says. :)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-30 16:14:40 -08:00
Tomaz Canabrava
3e239c7e3e Add the instantMeanDepth on Scene
But nothing is hoocked yet.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-30 16:13:41 -08:00
Tomaz Canabrava
4f4857f19f Move stuff to protected on DepthLine
I wanna use some of it on the InstantMeanDepthLine

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-30 16:13:09 -08:00
Tomaz Canabrava
c7a5d81683 Set data model for the MeanDepth line
This way we can poke around data for the mean depth line.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-30 16:12:49 -08:00
Tomaz Canabrava
146030f805 Add skeleton for the instant mean depth line
This class will hold the visible line of the mean depth for the time 'now'

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-30 16:12:28 -08:00
Tomaz Canabrava
2839aed8f2 Add the runnimg_sum data to the data model to be displayed on the profile
Without this nothing would be displayed.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-30 16:12:15 -08:00
Tomaz Canabrava
d4d71bd6d3 Add the gradient factor on the table
It was impossible to guess what this column was just by looking at it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-30 16:12:04 -08:00
Tomaz Canabrava
fed79490bf Add text for the heart beat data on the table
This was missing on the UI and it was really hard to guess what it was.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-30 16:11:14 -08:00
Anton Lundin
1a4380c8c1 Connect QGraphicsScene to its parrent
This is to prevent a leak of QGraphicsScene.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-18 08:34:00 -08:00
Anton Lundin
f14ef84c9a Free descriptions copied for TankItem
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-18 08:34:00 -08:00
Anton Lundin
8571268d21 Have ProfileWidget2 delete its allocated data
This creates a destructor for ProfileWidget2 that deletetes its new'ed
objects on exit.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-18 07:22:39 -08:00