Commit graph

2780 commits

Author SHA1 Message Date
Dirk Hohndel
106775b196 Clean up coding style
Just to keep me sane.

The code still shows compile time warnings which are the areas where we
need to complete things to actually do the deco calculations, etc. But now
seemed a good time to merge it into master as hopefully more people can
contribute.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-23 13:14:31 -07:00
Dirk Hohndel
31449dca22 Merge branch 'divePlannerTry3' of github.com:tcanabrava/subsurface 2013-06-22 15:57:26 -07:00
Tomaz Canabrava
880b98ed35 Added the skeleton implementation of the increaseTime and depth
Added the skeleton implementation of the increaseTime and
increaseDepth methods - they will increase the time / depth by
10 units ( feets / minutes ) each time they are clicked.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-21 16:51:13 -03:00
Tomaz Canabrava
28f48227f7 Added a new class to handle the pseudo-buttons on the canvas.
Added a new class, named Button, that has a clicked() signal,
and can be connected to the view to emulate buttons. While
I know that Qt supports widgets on canvas - I think it's too
nineties to have such square controls on something that can have
rounded borders.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-21 16:44:38 -03:00
Tomaz Canabrava
01d1a49d94 Make the plot and handle movement stick to an 'Grid'
Make the plot and the handle stick to a grid, the
grid is defined by the integers in the rulers, so
a time of 10,2 is converted to 10, and will put the
point at 10.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-21 16:28:17 -03:00
Tomaz Canabrava
c9159da43a Depth doesn't suppose to show broken numbers.
This patch makes the depth to show only integers, as
dirk asked. I'v also added a 'm' at the end, I know that
this will need to be taken from the settings  but
i feel lazy today =p

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-21 16:14:22 -03:00
Tomaz Canabrava
43657d9944 Makes the first and last line of the plot inside of the boundingrect
This patch makes the first line and the last line of the plot
inside of the boundingRect defined by the timeLine and depthLine

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-21 16:12:04 -03:00
Tomaz Canabrava
1e4d360d0c Do not plot dive handlers outside of the Plane area.
This patch makes the behavior of inserting new hanflers
correct. it can only be inserted now inside of the plane
defined by the Depth ruler and Time ruler.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-21 16:07:44 -03:00
Tomaz Canabrava
397a94fcd1 Created the posAtValue method for the ruler
Created the posAtValue method for the ruler, you enter
a value, and it will return the coordinates in double
( coordinate system of a QGraphicsScene is double based )
this is not the best name for the function, but I couldn't
find any better suitable name.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-21 15:53:20 -03:00
Anton Lundin
81858167ac Round up times instead of down
When seeing that you have 0 min left, it looks kinda wierd, so rather
round up instead of down.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-21 08:10:18 -07:00
Anton Lundin
03657ce6a9 Use the gasmix straight off
In calculate_deco_information we compute the ppo2 so we can graph it,
but if we send that ppo2 on to add_segment it will just reverse the
computation and introduce errors.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-21 08:09:52 -07:00
Tomaz Canabrava
062515ba6f Added back the menu entry 'Dive Planner'
Added back the menu entry Dive Planner, and removed the
calee code from the Print action.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 18:48:21 -03:00
Tomaz Canabrava
fdd8a4811b Added a new class to handle the DivePlanner dialog
Added a new class named DivePlanner that is a QDialog,
and renamed the old DivePlanner class to DivePlannerGraphics.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 18:40:59 -03:00
Tomaz Canabrava
8fcd465a65 Make skeleton of 'create_deco_stop'.
This is a skeleton of 'create_deco_stop' plus a bit of
code cleanup. I'v commented the create_deco_stop so that
the other developers can help me a bit here - since I don't
know too well the internals of subsurface. In the original
GTK code - a new dive was created every time a user changed
something on the dive, I don't know if this will be needed,
I jusst need two things: the correct time of dive calculated
by the app, and the points to put the decompression lines.

The usability of the widget right now is 'ok', nothing to
be proud of, it's ugly as hell too, and the Rules are in
the wrong position ( they are 'inside' the area where
the lines are being drawn, but htis is easily fixable. )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 18:25:03 -03:00
Tomaz Canabrava
0539a5fab6 Restore the original color of the Handler as soon as mouseRelease.
Restore the original color of the handler as soon as mouseRelease,
also a bit of code cleanup.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 18:02:01 -03:00
Tomaz Canabrava
cbdd78c0fc Added text to the rules so the user knows what's happening at that point.
Added text to the rules, so the user knows what's happening at that point
The text will move left / right ( for time ) and up / down ( for depth )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 17:54:36 -03:00
Tomaz Canabrava
2d683b66a8 Added the code to set the Depth / Time on the user Handlers.
Added the code to set the Depth / Time on the user handlers,
I think this finishes the difficult part. ( well, not really )
the depth and time is being set when handler is added or moved,
but as soon as the deco calculations enters on the code, the
handlers will need to be repositioned - and this code is not ready
yet.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 17:34:42 -03:00
Tomaz Canabrava
f129024fc7 Added a 2 Ruler Items, Time and Depth.
The ruler items are needed so I can get the correct
coordinates of the planned dive. This is a very
rudimentary ruler and it needs a bit of love, but
it already gives me something to work on.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 16:48:24 -03:00
Tomaz Canabrava
636550d413 Added the skeleton for the Ruler Item,
The ruler will deliver the Time and the Depth, later.
it should be vertical or horizontal, and will have
ticks

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 15:52:27 -03:00
Tomaz Canabrava
52a0e6c82d Make the plan handlers to not move across other handlers.
This patch disables the hability to move handlers across
the others, making a 'zigzag' in the time line.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 15:15:10 -03:00
Tomaz Canabrava
607f82ade3 Added drag and drop code to the dive plan
Added drag and drop code to the dive plan, it can move the user-
inputted data, but will not touch the computer generated ones.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 14:46:40 -03:00
Tomaz Canabrava
021a6a076e Created a class DiveHandle to make drag drop work.
Create d a class DiveHandle to make drag drop works,
it has a from and to Lines, and it will move them
around.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 14:29:32 -03:00
Tomaz Canabrava
1fb023d3c6 Make the cross red when you cant plot a dive stop
Make the cross red when you cant plot a dive stop,
also make impossible to put a dive stop before the last one.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 14:20:45 -03:00
Tomaz Canabrava
46483a096f Better defaults for placement of dive stops.
This patch makes it impossible to create a dive stop
outside of the scene - this, messing the complete
planning system.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 13:56:28 -03:00
Tomaz Canabrava
88e7aa36be Created a cross that follows the mouse on the dive planner.
Created a cross that follows the mouse on the dive planner,
this will help the user to know where it is placing the stop.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 13:53:12 -03:00
Tomaz Canabrava
b1c526ddb4 Fix creation of the poligon-based lines for the dive planner
This fixes the creation of the poligon-based lines
next thing to do is to forbit creation of the next point
before the last one.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 13:39:41 -03:00
Tomaz Canabrava
364254ed36 Better handling of the scene size for the dive Plan
Better handling of the scene size for the dive plan,
The scene can be resized and a transform will be applied,
the handles will not resize however - they are 10x10px
and that's it.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 13:28:04 -03:00
Tomaz Canabrava
ab6aea73c1 Plots Lines and handles on the Planner
This is still a bit bugged - the lines are going to the wrong
end - most probaly I messed something on the math. I'll now fix
the sizing issue then I'll try to make it behave in the proper
way.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 13:20:41 -03:00
Tomaz Canabrava
0d45c77572 Make double click work to put new items on the canvas.
Make double click work to put new items on the canvas.
Those items right now are QGraphicsEllipseItems, but
it will change to 'draggable' items.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 12:37:41 -03:00
Tomaz Canabrava
beadeffaf5 Added the first scope of the visual dive planner.
Added the first files and skeleton code for the visual
dive planner. now I need to fill things. The code is
using the print action borrowed, this will need to move
to a better choice in the future.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-20 12:33:26 -03:00
Linus Torvalds
09ee8ece5c Show sample pressures in the cylinder equipment page
If we don't have any manually set pressure data, show the data from the
samples instead.  It uses an italic font for this case, mainly because I
couldn't figure out how to gray things out.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 21:53:34 -07:00
Linus Torvalds
bc24b9320f Don't show '0.0%' gas percentages
It's just distracting.  Leave it empty.  No helium should be visually
very different from actual trimix, and for oxygen, zero means something
different anyway (it's air).  In neither case is '0.0%' a good string to
show, just show it as empty.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 21:52:58 -07:00
Linus Torvalds
45d9ca09de Fix the imperial cylinder size calculations in equipment handling
This makes us use the same linear calculations as we did in the Gtk
branch.  We don't take compressibility into account, since tank
manufacturers don't seem to either.  A Luxfer AL80 is 11.1 liters, and
with the standard (non-compressibility) calculations, 80 cuft of air at
3000 psi is 11.094 liter, so that is the right model to use.

Also, stop with the horrible "units in edited numbers" stuff.  It uses
up precious space, and doesn't look any better.  If the user asked for
cuft, give him cuft without making a big deal about it.

Oh, and if the working pressure doesn't exist, sizes are always in
liters.  That's what we did in the Gtk branch, that's what we do here.
Again, no reason to even bother stating units, it's not helping.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 21:40:38 -07:00
Linus Torvalds
02f2768148 O2/He percentages aren't integral
We do gas mixes in permille, not in percent.  Some people really like
using the value they got from the analyzer, which is generally something
like 29.4% or whatever.  So don't truncate percentages to integers.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 21:39:12 -07:00
Dirk Hohndel
d126977e16 More logical layout for the Dive Info tab
Up until now the tiles seemed to be arranged rather randomly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 15:28:40 -07:00
Dirk Hohndel
77725ecfe9 Replace wet_volume calculation with straight forward pressure formula
Since no one else approximates gas volumes at higher pressures, we
shouldn't do that either when converting imperial tank names (cuft @
working pressure) into wet volumes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 14:36:48 -07:00
Dirk Hohndel
88f0f60439 Fix cylinder data O2/He percentage entry braindamage
I can't even begin to explain what got me to write this in the first
place. It makes no sense from any angle I look at it...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 13:46:00 -07:00
Henrik Brautaset Aronsen
4a1b8f8de5 Remove unused QMap include
This sneaked into commit 9364436264.
It shouldn't be there.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 10:59:56 -07:00
Dirk Hohndel
106327af43 Better minimum width for yearly statistics window
The Qt default was way too small.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 10:59:48 -07:00
Dirk Hohndel
138a00bd10 Improve readability of yearly statistics
Make the entries for years bold, keep the months non-bold.
It's still a sea of data, but this is an improvement.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-19 10:31:01 -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
0a92052765 Fix yearly statistics
This commit fixes two issues. One is that there were situations where
the code would read an uninitialized parent pointer, the second was that
instead of the monthly statistics the tree view would show the yearly
statistics again under the yearly entries.

I assume that the second part of the fix (initializing the parent
pointers) actually takes care of both of them (that patch was suggested
by Tomaz), but the first part that just makes sure the pointer is at
least initialized to NULL seems to be at least not harmful, so I kept it
as well.

With this the yearly / monthly statistics seem to be pretty much at
feature parity.

Fixes: #115

Suggested-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 13:31:12 -07:00
Dirk Hohndel
370673cc99 Improve display of yearly statistics
Display the units in the header, make the header more consistent
looking, convert the values into the right units with appropriate
precision.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 10:48:46 -07:00
Dirk Hohndel
dda28c76aa Reduce the bleeding in my eyes
This is all just coding style and white space cleanup.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 09:27:34 -07:00
Dirk Hohndel
f780a56847 Clean up the last merge
While the code is correct, splitting the class like this is silly and will
confuse me later.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 09:25:24 -07:00
Binoj D
7e64e9a3a9 Typo in README.
Signed-off-by: Binoj D <dbinoj@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 07:17:18 -07:00
Henrik Brautaset Aronsen
9364436264 Fix compilation error in DiveComputerList destructor on MacOSX
The compiler on MacOSX seems stricter than others:

qthelper.cpp: In destructor ‘DiveComputerList::~DiveComputerList()’:
qthelper.cpp:10: error: expected class-name before ‘(’ token

Fixed with help from http://stackoverflow.com/a/14777627/13365

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 07:12:40 -07:00
Dirk Hohndel
0773172f66 Merge branch 'qtHelper'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18 00:33:03 -07: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
Tomaz Canabrava
87e380c7a2 Yearly stats are being displayed.
Yearly stats are being displayed. the code is similar to the GTK one,
but I advise the reader that it's a bit risky  ( I got an unreproducible
crash but it seems to be fixed now. ). The selection behavior is *weird*
and I have no idea why, but I'm very sleepy - will try to look at
it again tomorrow.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-17 21:05:17 -03:00