Commit graph

49 commits

Author SHA1 Message Date
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
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
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
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
07a16574e9 Consistently use slots / signals
We started out using Q_SLOTS and Q_SIGNALS but then changed our mind.
Let's make this consistent again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 10:20:56 -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
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
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
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
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
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
56c4cced53 Fixed loading the first dive via command line on the profile.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-10 10:49:00 -07:00
Tomaz Canabrava
1fec7d849c Fixed Zoom and Positioning of the Ruler Items
The items are still being placed far from each other when
zooming in - I need a bit of help with the math for that.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-10 10:48:37 -07:00
Dirk Hohndel
c129902793 Fix some compiler warnings
Passing the alignment as int instead of float or double was actually a bug
as CENTER is defined as (-0.5) ...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-10 10:47:37 -07:00
Tomaz Canabrava
b3b1b3f58f Change the plot text so it receives a QPointF instead of x,y, and a Parent
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-10 13:03:16 -03:00
Tomaz Canabrava
ea5353025f Only drag the tooltip panel when not zooming.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-10 08:16:00 -07:00
Tomaz Canabrava
2052e44ba1 Fix Tooltip Positions, code cleanup
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-10 11:07:44 -03:00
Tomaz Canabrava
acdb5d97eb The Zoom is working just like the GTK Version.
This code enables Zoom in / Out with the Wheel,
and it also enables panning by moving the mouse around.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
9cc089f9f6 Removed unused code that I'm sure it's safe to delete.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
cb8198b524 Plot the vertical ruler on the left of the profile.
Plot the numbers on the left of the profile.
It seems that everythign is being plotted -
But I can see that there are coordinate-errors on the
code. ( the GTK one plots some curves below of the
dive, but the Qt one is overlapping - probably the
way that I'm using the gc information)

Need to investigate a bit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
b794c23099 Plot pp Text
This patch plots the PP text, but when I plotted I realized
that the gc.pi.mapp is being calculated wrong, probably
something went wrong on the calculations - it's comming
zered always. So, only one line & text is plotted.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
25d65ab97d Plotting deco text.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
e62eb58ab5 Plotting cylinder pressure text.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
d6d1a10195 Plotting depth text.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
c62e8e5baa Plotting temperature text.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-09 17:50:06 -07:00
Tomaz Canabrava
9554cb5767 Plot of the Cylinder Pressure over time.
a few code was moved around, a macro that contained
the form of x ? : y; had to be rewritten to x ? x : y
since c++ doesn't allow ternarys without the middle operator.

The color-choosing for the Cylinder Pressure broke
on the Qt port - but it's a small issue.
I'm painting everyone as 'dark green' now, will
fix that later.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-09 00:24:03 -03:00
Dirk Hohndel
6f06c31d0b Stop passing around gc and pi
Make the graphics_context part of the ProfileGraphicsView and remember
that the plot info is already a part of the graphics_context (we kept
passing around both of them in the Gtk code... pointless but a leftover
from before adding the pi to the gc...)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-08 15:01:49 -07:00
Tomaz Canabrava
ef7ace9926 Plot the temperature Graph
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-08 14:19:10 -07:00
Tomaz Canabrava
ce8d30b938 Make tooltips works
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-08 14:18:27 -07:00
Tomaz Canabrava
2089c124a5 Work on the tooltips - WIP.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-08 14:18:27 -07:00
Tomaz Canabrava
76e1436f68 Better design for the ToolTip Handler.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-08 14:18:27 -07:00
Dirk Hohndel
df01a5d35f Added a bit of documentation on how to use the ToolTips & removed 2 bad-api methods
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-07 16:14:15 -07:00
Dirk Hohndel
d590cb9519 Adds real support for ToolTips.
This patch changes the Event drawing so it can display tooltips. It is now
the responsibility of the item to show / hide a tooltip.

A bit of code-refactoring got on here too because I was using only
QGraphicsItem calls and I wanted to use a hover in / hover out event
to show / hide the tooltip.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-07 16:14:15 -07:00
Tomaz Canabrava
c928b9cb94 Added the first overlay of the tooltips, with some test data.
The tooltips now can:
1 - be moved around the canvas
2 - dynamically expand / retreat when a new tooltip is added.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-07 16:14:11 -07:00
Tomaz Canabrava
867435442b Plotting the Events done
There are subtle differences, the Cairo version looks
prettier - but that's fixable. I did a small triangle
and a exclamation mark on it. maybe a gradient would
make a good difference there.

this item has a ItemIgnoresTransformation tag, so
scalling, rotating or zooming will not change it's
size.

The tooltips are not yet ported.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-06 20:30:22 -07:00
Tomaz Canabrava
1b392b35bc Port the plot text method to Qt, also test it by actually plotting something
The plot_text function from the cairo-methods are now ported
on the qt version. this patch moves around some code since
quite defines are already used and I didn't want to reinvent
the whell.

Original code used varargs, but I prefered to change it
, so now it receives just a reference to a QString object
and the string must be constructed before sending,
using the .arg methods.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-06 13:55:06 -07:00
Tomaz Canabrava
adcae4d913 Added the code to plot the actual Graph.
This version already plots the dive-graph, with the
gradient and all that jazz. One thing that will be
easily spotted is that the size of the line is very
thick - easily changed, I'm just using the default.
As soon as everything is plotted correctly I'll
fix the lines.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-04 19:55:46 -07:00
Tomaz Canabrava
19048b98e5 Start plotting something.
The first plotting method was removed from profile.c
to profilegraphics.cpp and some conversion ( almost 1 to 1 )
was made so that the code could work.

Since the code is big - this commit has just a part of it
working - it plots the grid. but already works for testing
the resizing of the window and Zooming ( unimplemented )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-04 19:55:12 -07:00
Tomaz Canabrava
8353d57164 Started the code for the Profile Plotting
This small patch adds a new class - ProfileGraphicsView
it's a QGraphicsView based class that will holds all
graphics-items for the plotting.

The setup is simple, just call ui->ListView->plot( dive )  ( that's
already a ProfileGraphicsView and magic will happen.

Since Im using a QGraphicsView , the size of the canvas doesn't
matter and I'm fixing it at 0,0,100,100. when a resize is done,
the resizeEvent will be called, fitting the scene's rectangle on
the view.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-04 19:49:52 -07:00