Commit graph

25 commits

Author SHA1 Message Date
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
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
Anton Lundin
bdea7dd0d6 Prevent leak by connecting object to its parrent
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-18 07:22:24 -08:00
Giuseppe Bilotta
32ab2b34d3 Unify icon metrics
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-18 15:16:15 -07:00
Giuseppe Bilotta
72b256de62 actually use defaultIconSize()
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-18 15:16:11 -07:00
Giuseppe Bilotta
d8f756fe14 Dynamic ToolTipItem metrics
Instead of hard-coding the icon sizes and spacing, compute them from the
font sizes, that Qt auto-computes from the displya DPI.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-18 15:15:53 -07:00
Tomaz Canabrava
2b760bdd39 Fix crash when moving the mouse over the profile when no dive is shown
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-20 18:35:08 -07:00
Robert C. Helling
15a99f8789 Add tissue saturation plot to tooltip
This adds a graphical representation of tissue loadings at the current moment during the dive
to the tooltip box. The layout is inspired by the Sherwater Petrel.Add tissue saturation plot to tooltip

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-19 21:48:05 -07:00
Robert C. Helling
d6abb739d9 Helper function for partial pressure calculation
This patch introduces a new structure holding partial pressures (doubles in bar) for
all three gases and a helper function to compute them from gasmix (which holds fractions)
and ambient pressure. Currentlty this works for OC and CCR, to be extended later to PSCR.

Currently the dive_comp_type argument is unused.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-09-18 06:20:25 -07:00
Tomaz Canabrava
d993684fec Do not create a backup for Q_FOREACH container
Q_FOREACH will expand and already creates a copy of the
contained container, so this is just a waste of cpu cycles
and also increases a tiny bit the memory consumption.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15 16:55:10 -07:00
Tomaz Canabrava
963178d3d4 Fixe movement of DiveHandlers when moving the NotificationArea
The QGraphicsView system moves every selected item when the user
clicks and drags one. This patch makes a cache of all selected
items and removes the selection on them. When the user stops dragging
the Notification, the selection is restored.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-24 07:30:36 -07:00
Dirk Hohndel
5ba573240f Gratuitous whitespace changes
I keep trying to get to consistenct.
Completely hopeless.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 11:40:22 -07:00
Dirk Hohndel
ae2f18678d New profile: fix Information overlay location
By simply storing the coordinates based on the scene (instead of trying to
map them to real coordinates) the overlay position is correctly restored.

Also remove the redundant positioning before readPos is called.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-13 10:28:15 -07:00
Tomaz Canabrava
00c97e710f Remove a Lot of Dead Code.
This is just removal of dead code from the old profile, probably there's
still a bit more to remove, but this is a very good cleanup already.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07 08:56:06 -08:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 20:09:57 -08:00
Dirk Hohndel
21ed18816a New profile: fix tooltip display for events
We need to use the transform() of the view, not the tooltip.

Suggested-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-25 13:58:57 -08:00
Dirk Hohndel
08490785b2 Only recalculate the tooltip if time has changed
Small optimization, but seems to make sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-19 16:06:16 -08:00
Linus Torvalds
50424df653 Use 'struct membuffer' for profile info string generation
The profile info was generated using nasty string concatenation that the
membuffers are much better at anyway.  And membuffers don't need those
arbitrarily sized fixed buffers (500 bytes? Why 500 bytes?).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 07:03:27 -08:00
Boris Barbulovski
8bb5cd6012 ToolTipItem class improvements
* Initialize every ToolTipItem variable member in initialize list.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:07 -08:00
Tomaz Canabrava
151a90bec0 Big improvement in speed ( callgrind )
This patch makes use of a cache variable instead of creating / accessing a
new one via operator[], because for some reason QGraphicsPolygonItem
doesn't return a reference for polygon and a copy is always made.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:31:11 -08:00
Tomaz Canabrava
ed230f8aac Make the Tooltip Item work on the new profile.
Just refresh the tooltip item.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:29:55 -08:00
Tomaz Canabrava
40cb57b202 Adapt the ToolTip to work on the new profile
With this patch the tooltip is ready to work on the new profile, we just
need to actually use it.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:29:19 -08:00
Tomaz Canabrava
c1ed9babc7 Move the divetooltipitem to its own file.
This is needed so we can share the dive tooltip item with the
new and old profile at the same time. Next few commits will be
setting the functionality of the tooltip item on the new one.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:26:50 -08:00