Commit graph

45 commits

Author SHA1 Message Date
Tomaz Canabrava
67fec4da70 Added the possibility to choose gases in the planner.
Added the possibility to choose gases in the planner,
now the user should click on the name of the gas, a
popup window will appear, asking the user to choose
what gas he wants for that ascent / descent.

now we need to hook that up with the createDecoStops
method that calculates the decompression.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 13:54:21 -03:00
Tomaz Canabrava
3e3d8b2210 Good code cleanup.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 12:56:21 -03:00
Tomaz Canabrava
9dde9b3d4c Added the current gas used on the planner
Added the current gas used on the planner, now it's a matter
of choosing the new gas, that will be done in the next commit.e

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 12:12:31 -03:00
Tomaz Canabrava
b36dfc7c4f Removed unused code.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 10:03:04 -03:00
Tomaz Canabrava
a6025c8efd Added button to reduce dive time on the planner.
Added a button and a method to reduce time on the dive
planner. The dive planner will not reduce below deco-time
and it will also not reduce below TIME_INITIAL_MAX.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 09:44:52 -03:00
Tomaz Canabrava
29cb15950e Added ( finally ) the code to reduce depth on the planner
Added the code to reduce depth on the planner. Depth
cannot be lower than 40m and it also won't let the
user reduce if there's any point on the 'reduced' area.
the icon is ugly - we need an artist.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 09:27:04 -03:00
Tomaz Canabrava
bb33be4117 Added the left / right shortcuts for moving the handlers around in time.
Added the left / right shortcuts for moving the handlers around in time,
this also made me wonder why we have the 'previous dc' on the menu, it
got actually to broke my code on the shortcuts for the planner because
they are active everytime - should they be active only when the profile's
visible or they serve any other purpose?

If they serve only for the profile, I'll get them out of the  menu and
put them in their proper place - the profile view.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 12:30:05 -03:00
Tomaz Canabrava
52fd769efb Added 'up' and 'down' actions on the dive planner.
Added 'up' and 'down' keyboard actions on the dive planner,
you need to select the handlers with ctrl + click, then
press up to make the handler go 1m up, or down, to make the
handler go 1m down.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 11:28:39 -03:00
Tomaz Canabrava
932ee3da94 Added a 'delete' action, with the keyboard.
Added a delete action from the keyboard, there's also
a possibility to add the same action from the menu, but
I frankly don't like much the idea. so, to delete a handler
now, you need to select it ( ctrl + click ) then press
the delete button. Multiple delection is also possible.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 11:16:42 -03:00
Tomaz Canabrava
c23dd354b9 Added a shortcut to 'esc', so it clears the selection or cancels the plan.
Added a shortcut to the esc key, so it clears the selection,
if there's no selection, it acts just like clicking on the 'cancel'
button. Next: delete selected handlers.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 11:06:28 -03:00
Tomaz Canabrava
f457415f7a Make possible to 'select' an handler by ctrl+click
Make possible to select an handler by ctrl+click on it,
this will be used in the future for the shortcut actions,
like delete, arrow keys, and such.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 11:01:59 -03:00
Tomaz Canabrava
20ec98f2a5 Make it possible to drag a handle between handlers
Make it possible to drag a handle between handlers,
this way the configuration of the dive is more acurate
and easyer to make. I'v discovered a problem where it's
a bit hard to 'grab' the handler, investigating it now.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 10:29:28 -03:00
Tomaz Canabrava
7c8bdf70d5 Make the increase time button to work.
Makes the increase time button to work, it will
increase the minimum time, not the correct time of the
dive. the total time is calculated by the deco, and
does not come from this, unless the deco is smaller
than the minimum time.

This patch also fixes the problem where a button
would only click once - I was holding the first
clicked button as the 'mouse grabber', bad tomaz.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 14:36:52 -03:00
Tomaz Canabrava
effb7e2fac Change the color of the DepthString based on it's deepness
Change the color of the DepthString based on it's deepness
on the profile planner. The new color of the profileString
( the string that follows the mouse stating how deep you are)
is now interpolated from SAMPLE_SHALLOW and SAMPLE_DEEP -
but since those two colors were the same and I had to change
it so that could work, I want somebody to check if my choose
of colors were ok.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 13:31:25 -03:00
Tomaz Canabrava
23b29bd3cd Use the same profile colors on the planer for the Time and Depth
Use the same profile colors on the planner for the Time and Depth
rulers. this needed a new method on the rulers - setColor, that
will call the setPen method and make everything behave properly.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 12:01:47 -03:00
Tomaz Canabrava
6115dc1f12 Change the rules so they work with percentages.
Changed the ruler so that they work with percentages,
also added a new method to the rules to set the size of the
ticks.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 11:12:15 -03:00
Tomaz Canabrava
c98894fd52 Added a method and a simple stub to position things using percentage.
Added a method and a simple stub to position things on the canvas
using percentage - this way I have a proper control on where I want
to put things on screen and it will make simpler for future changes,
even if the amount of code written is a bit bigger.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 10:53:08 -03:00
Tomaz Canabrava
233e245b78 Make planner prettier. but still ugly.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-27 19:52:58 -03:00
Tomaz Canabrava
19fbc108c3 Removed memleak created by the diveplan calculations
Removed a small memleak created by the diveplan calculations.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-27 17:31:10 -03:00
Tomaz Canabrava
c7c5ca7c3e Added the Ok / Cancel buttons on the dive planner canvas.
Added the ok / cancel buttons on the dive planner canvas.
I still need to hook the esc button to cancel it too, but
since I removed the 'floating dialog' option and merged it
into the mainwindow, it's necessary.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-27 16:45:58 -03:00
Tomaz Canabrava
1244438b01 Moved the DivePlanner to the MainWindow.
Now, activating the dive planner will hide the profile
and show the planner on the same place. we still need
a way to 'cancel' or 'accept' the profile created.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-27 14:48:03 -03:00
Dirk Hohndel
3cdf8dc4c1 Correctly prevent time travel in planner
Prior to this change the visual feedback (the handle that is drawn when
the user moves the mouse while pressing the left mouse button) would not
move to an illegal position (one that is impossible without time
travel), but it the user moved the mouse to such an illegal position and
then released the mouse button, we still added that illegal position to
the plan.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 21:38:12 +08:00
Tomaz Canabrava
03572e233d Remove the bogus time/depth, and fix the positioning of the Handler after updateTicks.
Remove the bogus time/depth that was duplicated in the
Handler - dirk didn't realized that I already created the
same data that he put on it later, but mine was double and
his his was int, I choosed his implementation since he knows
a bit more than I do about subsurface internals.

Besides that, I worked a bit on the logic that called update ticks,
because it was calling it for every mouseMoveEvent, it created
sooooo many ticks that it made the app unusable ( and slow. )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-26 19:14:55 -03:00
Dirk Hohndel
596095389b Start hooking in the deco calculations
I expanded the DiveHandler to include the actual time / depth of each
node on the graph - this way things will stay consistent if we need to
rescale the graph.

One thing that this makes obvious is that the whole design for the
planner so far assumes metric data. We need to make sure this works well
with feet instead of meters as well (and that it uses the information in
the units settings).

With this change we actually create a dive based on the plan input and
add the deco stops (if needed) to it - but we don't do anything with the
results of those calculations, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-23 20:32:32 -07:00
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
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
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
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
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
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