Commit graph

161 commits

Author SHA1 Message Date
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
Dirk Hohndel
32941cb84f Don't print temperatures that are below 200K
That threshold is of course ridiculous and arbitrary - but it seems like a
good assumption to make that anything below that is DEFINITELY not valid
data.

Because of the way the scene grows automatically in Qt, printing these
texts would squish the profile into one thin line.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-12 06:36:55 -07:00
Dirk Hohndel
d62d1124cf Fix crash if we have no divecomputer information
The string we print is lame, but it keeps things consistent (and prevents
us from dereferencing functions in uninitialized objects).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-12 06:36:41 -07:00
Dirk Hohndel
06d296a17d Improve the text labels in the profile
Only 1 decimal, please.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-10 21:07:49 -07:00
Amit Chaudhuri
97a044d41f Tweaks to maintab
Align statistics tab labels as per infotab.

Amend helper function to show degree symbol for temp measurements.

Change order of member initialisation list to match order of decl
(ProfileGraphicsView::ProfileGraphicsView)

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-10 16:01:17 -07:00
Dirk Hohndel
1245c232db Merge branch 'fixCrash' of https://github.com/tcanabrava/subsurface into Qt 2013-05-10 11:59:17 -07:00
Tomaz Canabrava
ad8f96cd6e Crash fixed on clicking on the canvas while no dive is loaded.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-10 15:52:06 -03: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
Dirk Hohndel
bfef1d0219 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 08:59:09 -07:00
Tomaz Canabrava
9a40333067 Fix showing the stuff on the canvas in the right positions.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-10 08:19:38 -07: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
93d3af768b Uses the correct rectangle to englobe the profile grid.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-10 10:30:24 -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
5978afbcd8 Use a Default pen to make the configuration easier.
Created a default pen that has 'cosmetic' enabled,
A cosmetic line doesn't change it's width no matter
what zoom level we apply.

Also , changed everything that used a line to have
that as default pen instead.

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
17c6db6a5b Shows the correct color for the CylinderPressure
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
d120fed211 Add bounding box to profile
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-08 16:53:00 -07:00
Dirk Hohndel
880870b46c Show the dive computer name in the profile window
And clean up some obsolete Gtk related stuff that is no longer relevant
for the Qt port.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-08 16:30:38 -07:00
Dirk Hohndel
656b58f205 Add tooltip data and cleanup size calculations
Tomaz' code had a fixed height per tooltip item and some rather suspicious
logic how to position them (and how to size the surrounding box), based on
a fixed height in pixels per item - which of course fails if you use
larger fonts or multi line items.

This uses the bounding rects to correctly calculate the sizes and populates
the tooltip with the other dive data that we already had in a helper
function.

This also fixes a small formatting issue for gas change events.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-08 15:46:16 -07: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
688276b6f2 Fix moving the ToolTip box with the mouse.
When I changed the way that the tooltip box behaved,
I accidentaly 'ate' the mouseMoveEvent, it was being
used only to show tooltips instead of everything
that it should have. this simple patch fixes it.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-08 14:20:15 -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
1a8239a240 Finish the plotting of the events
Beautification of the triangles done, Tooltips are also displaying
Some rework on the code - don't know if dirk will accept, I'v changed
an if-else-if-else by a ternary operator, since it improves legibility
a little bit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-06 20:30:29 -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
55f31dc011 Make the text ignores transformations on the scene
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-06 13:55:18 -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
8e35868b9b Fixed some bad drawings
Removed the lines of the graphs that doesn't supposed to have lines.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-05 19:30:54 -03:00
Tomaz Canabrava
be0f2e0e8d Enabled some Render Hints for Antialiasing
Enabled some Render Hints for Antialiasing and
smooth transformations.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-05 09:55:56 -07:00
Dirk Hohndel
1238fde17c Merge branch 'PlotsV2' of https://github.com/tcanabrava/subsurface into Qt
Minor conflicts based on my cleanup of Tomaz' earlier commits.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-05 09:50:11 -07:00
Tomaz Canabrava
c72609046a Finished the port of the plot_profile code.
There are a few regressions, mostly because the text
is not being plotted yet and the background of some
of the curves are not being applied.
This is because QGrapdien is based on the coordinates
of the items that I wanna paint, but I'v setted a
QGradient that's global and doesn't take this into
consideration.

all curves are being plotted. in Small resolutions
they plot bad. but it's just a matter of redrawing
in the correct resolution.

the Line widths are being hardcoded now, on the cairo
version they weren't, this will need a bit of porting
too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-05 13:42:33 -03: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
f269f86496 Plot of the Mean Deph
The mean depth now is plotted correctly.
I wanted to do more stuff on this commit, but since
it required that a few things on profile.c got moved
to profile.h, commited to not have a huge blob for review.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-04 19:55:16 -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
fa82ba6079 Moved the plot from the cairo version to the Qt version
Started working on the Qt version of the Plot, initially
nothing is printed - but this is not a bad thing,
the program doesn't explodes too. :)

some work had to be done about the 'bool/gboolean' stuff
so I removed all gbooleans in the code that I'v encountered.

A new file was created ( profile.h ) so I could put the
signatures of helper methods that cairo used to call.

till now the code computes the max limits.
Next patch the first drawing will be made.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-04 19:51:33 -07:00
Tomaz Canabrava
ec4d4566ad Converted the Colors.h code to Qt
The colors on colors.h were done to fill a special
struct by Subsurface - I removed that structure and
replaced the code that generated the map of colors
to a QMap. I know that this changes are not very
'welcomed', but C++ has issues on creating & initializing
complex static members, this was the best way that I could
think of.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-04 19:51:29 -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
Tomaz Canabrava
926224122e 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>
2013-05-04 20:18:16 -03:00
Tomaz Canabrava
09597cd2d8 Plot of the Mean Deph
The mean depth now is plotted correctly.
I wanted to do more stuff on this commit, but since
it required that a few things on profile.c got moved
to profile.h, commited to not have a huge blob for review.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-04 19:36:40 -03:00
Tomaz Canabrava
1b1ea35fac 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>
2013-05-04 19:20:49 -03:00
Tomaz Canabrava
c74dc11167 Moved the plot from the cairo version to the Qt version
Started working on the Qt version of the Plot, initially
nothing is printed - but this is not a bad thing,
the program doesn't explodes too. :)

some work had to be done about the 'bool/gboolean' stuff
so I removed all gbooleans in the code that I'v encountered.

A new file was created ( profile.h ) so I could put the
signatures of helper methods that cairo used to call.

till now the code computes the max limits.
Next patch the first drawing will be made.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-04 18:43:42 -03:00
Tomaz Canabrava
a58412cb31 Converted the Colors.h code to Qt
The colors on colors.h were done to fill a special
struct by Subsurface - I removed that structure and
replaced the code that generated the map of colors
to a QMap. I know that this changes are not very
'welcomed', but C++ has issues on creating & initializing
complex static members, this was the best way that I could
think of.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-04 16:41:49 -03:00
Tomaz Canabrava
243016633d 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>
2013-05-04 16:12:43 -03:00