When straight decoding the event, it failed to handle older
SAMPLE_EVENT_GASCHANGE(11), the ones without he-part correctly. This was
shown clearly when it printed the 21/35 in dives/test20.xml as air.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Adding +30 (seconds) to the position works fine for long dives but
when zoomed in on short dives, 30 seconds are a lot.
This commit sets the offset to +10 px regardless of the scaling.
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
The toolbar adds two buttons to the profile.
The user can now toggle the scaling (zoomed to dive/round up to 30 mins)
and adding /removing ruler to/from the profile using this toolbar.
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
This patch adds a ruler QGraphicsItem which can be dragged
along the profile. The ruler displays minimum, maximum and
average for depth and speed (ascent/descent rate). Also, all used
gas will be displayed.
This also adds a new attribute to struct plot_data to store the
speed (not just as velocity_t).
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
plot_data.o2 and plot_data.he was wrong for all dives, due to that
cylinderindex was set right first in populate_pressure_information, and
thus those two contained bogus information.
This makes the plot-text use cylinderindex-lookup as everything else.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Due to a bug in how the entry-list was handled, a point on the polygon
was introduced at 0,0 that made a weird pink triangle across the whole
profile. This was quite clearly seen in dives/test15.xml
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>