Commit graph

108 commits

Author SHA1 Message Date
Michael Andreen
16addbf373 Use maxx from graphics context for time calculation.
Fixes #128.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-08 20:00:15 +02:00
Michael Andreen
1f976371bf Fix " begin" and " end" for events in plot.
QObject::tr() has source string as first argument and disambiguation as
second argument. Currently the events shows "Starts with space!" instead
of " begin" or " end" after the event name.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-05 06:56:34 +02:00
Michael Andreen
069f588d9d Support more than one event of the same type in Qt tooltip.
Since the tooltip text was used as key in the map, two events of the
same type, close to eachother, would cause one of them to not be
removed.

Since ToolTip::removeToolTip() isn't used, we don't need a QMap and can
use a QList instead, so all tooltips are properly cleared.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-05 06:55:18 +02:00
Lubomir I. Ivanov
9de15dec60 Profile: support grayscale plotting
This patch adds the getColor() helper function to
ProfileGraphicsView and EventItem so that retrieving
a certain color can depend on a 'isGrayscale' flag.
This flag is private and only set by
ProfileGraphicsView::setPrintMode() at this point.
EventItem also now accepts 'grayscale' as a constructor
argument.

A couple of side modifications are:
- move setBackgroundBrush() to ProfileGraphicsView::plot()
- set the same pen color as brush color for the dot in the
'!' symbol inside EventItem::EventItem().

TODO: look for color issues when printing using the
custom grayscale table

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18 12:00:12 -07:00
Lubomir I. Ivanov
3076dc6d47 Profile: add the isGrayscale flag
setPrintMode() can now be used to set the
profile to be plotted in grayscale.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18 12:00:12 -07:00
Lubomir I. Ivanov
8ea849d0c2 Profile: use a printMode flag in ProfileGraphicsView
When printing the profile there are certain features which
we want different (or disabled). This includes font scale ignoring
and showing a toolip. To achieve that we check for a printMode flag
in ProfileGraphicsView which can be set using setPrintMode(bool).

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18 12:00:12 -07:00
Lubomir I. Ivanov
f3b81ab54d Profile: prevent a bug when switching views
While in zoomed mode and when resizing the splitters or
switching views the profile tooltip can end up being at the
wrong location and also the zoom state becomes corrupt,
so perhaps the entire transformation needs to be reset.
To prevent the bug we listen for relevent to the profile
splitter resize event, view changes and clear()/plot() the
entire profile graphics.

This is an slow/expensive solution and perhaps there are
cheaper alternatives e.g. updating only the scene rectangle
and tooltip, somehow.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05 07:38:29 -07:00
Lubomir I. Ivanov
2e26de5ae6 Profile: improve tooltip animation
Remove a couple of expand() calls(?). Also store the last
expanded rectangle size in the private variable nextRectangle
and use that in collapse() animation. Patch prevents a small
jump/resize glitch if the user quickly hovers over and out
of the profile while the tooltip is still resizing.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05 07:38:27 -07:00
Lubomir I. Ivanov
3b07cd204b Profile: small tweak for tooltip separator line
Add 3px of a initial horizontal offset.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05 07:38:23 -07:00
Lubomir I. Ivanov
dfb3e2cbea Profile: collapse tooltip back to original height
When collapsing the tooltip we want it's border to become
the same height as when no tooltip info was visible - i.e. post
creation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05 07:38:19 -07:00
Lubomir I. Ivanov
c7f8ada4ff Profile: attempt on better zoom and pan logic
QGraphicsView::AnchorUnderMouse does not work for
Qt 4.8.1 on Ubuntu 12.04 and if the mouseMoveEvent
overload is disabled it practically can be seen that
the anchor point is [0, 0] instead of the mouse location.

After a suggestion found on the web this patch attempts
to use the hidden scroll bars to calculate reposition
on pan and zoom *near the mouse cursor.

On the other hand QAbstactSlider (QScrollBar) class
strangly uses negative offsets for minimum scroll
position, which makes the implementation even more
ugly.

[*near] because it's not that accurate!

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 22:59:46 -07:00
Lubomir I. Ivanov
1257adfd26 Profile: use more levels of zoom
Makes it easier to see colored lines - e.g. velocity
with 20 levels of zoom.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 22:59:14 -07:00
Lubomir I. Ivanov
87dda6661c Profile: prevent a zoom glitch at maximum zoom level
The 'else if' condition in ProfileGraphicsView::wheelEvent()
is causing a zoom-in / zoom-out loop at zoomLevel = 10.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04 22:58:56 -07:00
Lubomir I. Ivanov
b68e86a141 Profile: add white outline to all text
To draw the white outline around profile text we trace a text path
using QPainterPath::addText() and then create a couple of
QGraphicsPathItem objects. One of the objects is outlined using
QPainterPathStroker and is placed at the bottom of a QGraphicsItemGroup
with a white brush. The other object holds the standard colored text
and is placed on top.

Notes:
- possibly quite expensive on older machines
- ProfileGraphicsView::plot_text() now returns a QGraphicsItemGroup
- QGraphicsSimpleTextItem uses a top-left baseline anchor
while QPainterPath::addText() uses a bottom-left baseline
which is a bit mysterious, requires the -3 offset for a match
and is possibly non-portable across fonts and sizes.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02 15:51:10 -07:00
Dirk Hohndel
9d9d516c26 Revert "Profile: add white outline to all text"
This reverts commit 44c33742c2.

I mistakenly applied the wrong version of the patch.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02 15:50:40 -07:00
Dirk Hohndel
6b08a6d428 Silence some warnings
One of them actually looks like it was a bug...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02 13:58:03 -07:00
Dirk Hohndel
be6e6638de Merge branch 'nitpicks' of github.com:tcanabrava/subsurface 2013-07-02 13:43:48 -07:00
Tomaz Canabrava
ca517f1bf8 Shared background for profile and planner.
Share the background for profile and planner. Those are not the same
class, but they should behave somwheat the same.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 10:13:06 -03:00
Tomaz Canabrava
2df0b398f3 Added 2 new files to handle the common stuff for graphics.
Added 2 new files, graphicsview-common.h/cpp, that should have
the common stuff shared between the dive profile viewer and
the dive planner. the amount of duplicated code would be huge
if we go the road of two different classes for each one, but
since the planner took a more 'Qtish' way of behavior, in
comparisson to the profile - that's most a Cairo-To-Qt literal
translation, we cant easily merge the code without a complete
( and unwanted ) reestruturation of the profile code, thus,
this new files will serve as a bridge between them. Initially
I put there only the colors - since that's wat most easilyy
shareable.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 10:08:16 -03:00
Lubomir I. Ivanov
44c33742c2 Profile: add white outline to all text
Goal: no blending between profile text and graph lines

Qt doesn't seem to provide an easy-to-go solution in terms
of styling the z-order of the pen and brush layers of a
QAbstractGraphicsShapeItem (or alternatively pen offset),
which is needed if for example one likes the pen not
to cover the text fill.

Calling QGraphicsSimpleTextItem->setPen() on small text can
cover bigger portions of the text, as the pen ends on top of the
fill and given the pen stroke path ends up scaling exactly
at the fill path border but not on the outside, for example.

Since we don't get quick control over that (and to avoid
the issue in a naive way), we set the text as bold
and the white outline lands over the "bold-ed" area of glyphs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-29 04:24:06 +08:00
Lubomir I. Ivanov
48cf2fd6bc Profile: move the bounding box below plot data
In certain conditions a number such as '51' could end up being
partially hidden under the white bounding box in such a way
that the digit '1' is barely visible. Putting the bounding
box bellow all plot data solves the issue.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-28 20:24:20 +08:00
Dirk Hohndel
29b242c703 Converting the device_info list into a Qt data structure
This data structure was quite fragile and made 'undo' when editing
rather hard to implement. So instead I decided to turn this into a
QMultiMap which seemed like the ideal data structure for it.

This map holds all the dive computer related data indexed by the model. As
QMultiMap it allows multiple entries per key (model string) and
disambiguates between them with the deviceId.

This commit turned out much larger than I wanted. But I didn't manage to
find a clean way to break it up and make the pieces make sense.

So this brings back the Ok / Cancel button for the dive computer edit
dialog. And it makes those two buttons actually do the right thing (which
is what started this whole process). For this to work we simply copy the
map to a working copy and do all edits on that one - and then copy that
over the 'real' map when we accept the changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 00:24:28 -07:00
Dirk Hohndel
5e51d1e354 Plot cleanup
Use a helper to make things easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-14 14:34:44 +02:00
Dirk Hohndel
e34da61362 Merge branch 'linusDiveList' of https://github.com/tcanabrava/subsurface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-13 19:56:36 +02:00
Tomaz Canabrava
9993d49966 Do not plot on showEvent if dive is already plotted.
We do a force-plot on showEvent because the user can
have asked to open a dive file via command line, so
the app needs to open already with a profile plotted.

if the user opens the program, loads a map, hides
the profile by hitting ctrl + 1, then shows the
profile again by hitting ctrl + 2, we do not want
to do all the math to show the profile again, because
we already have it in memory.

this also fixes dirk's strange behavior of funky profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-12 14:28:44 -03:00
Tomaz Canabrava
72d0030509 Added a slot to set the full time of the dive plan
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 21:00:30 -07:00
Tomaz Canabrava
939246acda Added a simple "TextEditor" in the graph, for a plan mode.
Added a simple TextEditor in the graph for the 'Dive Plan' mode,
this text editor is very simple, so the user can double click on
'depth' or 'duration' to set the depth or duration of the dive.
Since this was a test, only 'duration' was done, and I'll add
duration on the next commit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 20:59:58 -07:00
Tomaz Canabrava
b4835badb6 Added a 'Plan' mode and a 'Dive' mode on the profile.
Added a 'Plan' mode and a 'Dive' mode on the profile. Those modes
tell the application what can be done: Plan - the dive's dinamyc and
can be changed, 'Dive', the dive is fixed ( most probably downloaded
from a dive computer and it's readonly. ) - now I need to properly
populate stuff.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 17:33:46 -03:00
Tomaz Canabrava
ad5c186553 Implemented the movement of the ToolTip by Hand.
Reimplement the movement of the tooltip by hand,
we were adding / removing childs of the tooltip
quite often, wich broke the movement of the item
using the default behavior, aparently Qt uses
a cache of the transformation of the item, assuming
that the bounding box of it will not get modified
while dragging. wich in our particular case, is
a falacy.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 14:48:31 -03:00
Tomaz Canabrava
34c6eec9ba Save / Restore toolTip information position on the Profile when switching dives.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 14:28:44 -03:00
Tomaz Canabrava
45f80afc1f Fix memory leak
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 13:54:17 -03:00
Tomaz Canabrava
3eac2360e7 Moved the 'create fake dc' to it's own function in device.c
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10 13:35:27 -03:00
Helio Chissini de Castro
ef873b4082 Hide/Show tooltip on mouse over view widget
Proper hide/show tooltip under ProfileGraphicsView. Events are not
properly handled and no custom tolltip status was stored.
Text are properly hidden now when tooltip is collapsed.

Reported-by: Tomaz Canabrava
Signed-off-by: Helio Chissini de Castro <helio@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-07 21:25:16 -07:00
Tomaz Canabrava
840f943acd Fix movement of the tooltip overlay
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-06 13:00:18 -03:00
Dirk Hohndel
6f7467de7a Show the gas with the pressure diagram
This is a feature that had been requested a few times in the past and when
debugging my "show only used gases" commit I realized that this would have
been extremely useful to have...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31 17:31:53 +10:00
Dirk Hohndel
abb43f0f1d Show GF for calculated ceiling above the graph
The hardcoded position we previously had would make the text invisible
if a ceiling was drawn during the middle of the dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31 13:47:34 +09:00
Dirk Hohndel
32d8051404 Cleanup minor issues with ceilings for individualy tissues
In commit b8d31d8534b ("Show ceilings for individual tissues") Robert
inadvertently broke the connection from dc_ceilings to red_ceilings and
also didn't correctly enable the checkbox for all_tissues when
calc_ceilings was already set in the preferences before the dialog was
created (and therefore the connection in the .ui file isn't run).

There's also a simplification / cleanup to the code deciding whether to
show all the tissues.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31 05:28:24 +09:00
Robert Helling
344a429e48 Show ceilings for individual tissues
I think that displaying tissue loadings either as pressure or as
percentages is not very intuitive but that it makes much more sense when
translated to ceiling depths.

This change enables just that for the 16 tissues in our calculated ceiling
and visualizes this in the profile graph.

There is a checkbox in the preferences to turn this on. If enabled, all
tissues having non-trivial ceilings are also shown in the info box.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31 05:18:25 +09:00
Dirk Hohndel
da52ff56b2 Correct the ceiling preference handling
Added the red dc ceiling as preference option.
Hooked them all up together so the sub-preferences are enabled when the
master preference is set (for 3m and red ceiling).
Use the options in the profile plotting functions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29 15:32:31 +09:00
Dirk Hohndel
4f53ad736d Connect preferences to the rest of the code
The biggest problem here was that bool has different sizes in C and C++
code. So using this in a structure shared between the two sides wasn't a
smart idea.

Instead I went with 'short', but that caused problems with Qt being to
smart for its own good and not doing the right thing when dealing with
'boolean' settings and a short value. This may be something in the way I
implemented things (as I doubt that something this fundamental would be
broken) but the workaround implemented here (explicitly using 0 or 1
depending on the value of the boolean) seems to work.

I also decided to get rid of the confusion of where gflow/gfhigh are
floating point (0..1) and when they are integers (0..100). We now use
integers anywhere outside of deco.c.

I also applied some serious spelling corrections to the preferences
dialog's ui file.

Finally, this enables the code that selects which partial pressure graph
to show.

Still to do: font size, metric/imperial logic

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29 12:59:46 +09:00
Dirk Hohndel
8394828806 Fix the positioning of text in the dive profile
This had been bugging me for a while - the label texts were all not
quite where I expected them to be. I think this looks much better now.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-28 09:57:49 -07:00
Dirk Hohndel
b947cc924f Hook up most of the Preferences dialog
The imperial/metric super setting doesn't have any effect. But changing
the individual units now works and is tracked. And causes the display to
change after clicking "OK" (but not yet when clicking "Apply").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-26 11:33:45 -07:00
Dirk Hohndel
115e5e5fbc The never ending, futile fight for whitespace consistency
I just need to write a tool that does this...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 21:31:45 -07:00
Dirk Hohndel
7757363953 Re-enable dive computer selectiom
This had been disabled by some redraw optimizations in commit
81406b80c6ec ("Fix loading a second dive, after the first file was
loaded."). We need to redraw the plot not only if the dive changed but
also if the selected divecomputer changed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-22 20:59:50 -07:00
Tomaz Canabrava
fac8868903 Fixed update the plot as we resize the view.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-22 16:21:07 -03:00
Tomaz Canabrava
2f35c94026 Fix loading a dive via command line.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-16 21:25:31 -03:00
Tomaz Canabrava
d39b1aedcd Fix loading a second dive, after the first file was loaded.
This patch fixes loading a second dive-file after the first
one had been loaded. it simply clears some information and
makes sure that the current selected dive is invalid when
the file closes. I also did a bit of code cleanup on this one
to make things simpler in the future.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-16 12:23:38 -07:00
Tomaz Canabrava
e3cb36498d Fixed the loading of some maps
On some maps, the lack of setting up the dc before plotting
the dive-computer nick caused a division by zero, breaking
the correct visualization of the dive.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-16 15:43:38 -03:00
Henrik Brautaset Aronsen
f9598f062c Clean up some typos
Cosmetic commit to clean up some of the annoying typos in qt-ui

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-14 05:24:28 -04:00
Tomaz Canabrava
61373eaccf Fix segfault on mouseOver at the Profile with an invalid dive selected ( trip )
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-13 15:28:17 -03:00