Commit graph

382 commits

Author SHA1 Message Date
Dirk Hohndel
8ae8c81d3d Fix various issues with the dive add / edit manual dive code
- get_gas_from_events does NOT always set o2/he. It only updates them IFF
  a matching event is found; so we need to make sure we start out with a
  valid gas mix
- the way we tried to restore the edited dive in case of an edit to a
  manually added that is cancelled was completely bogus. Way too complex
  when we can simply and reliably simply store the dive and then copy it
  back

Fixes #270

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 11:55:56 -08:00
Dirk Hohndel
3801b765ff Don't add spurious 5m/15ft node at 10 minutes when canceling edit
When cancelling the edit of a manually added dive, we should send the
sample with timestamp 0 to addStop - that's a magic value and causes us to
add a node at 5m/15ft and 10 minutes instead. Since the dive always starts
at the surface, calling addStop is redundant, anyway, so let's just not do
that.

See #270

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 10:46:01 -08:00
Tomaz Canabrava
5945c18c8a Removed the ugly icons on the visual profile editor
Removed the ugly icons on the visual profile editor and replaced them with
the much better looking ones that Luisa designed.  This was not a simple
search and replace since Luisa's design was a bit more sophisticated.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-17 15:38:48 -08:00
Dirk Hohndel
962abba1f7 Remove ununsed variables
The warnings are distracting - and the variables are truly obsolete by
now.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-17 14:36:37 -08:00
Dirk Hohndel
3b9c28bce7 Don't create stop at time zero when re-editing manually added dive
To our addStop method time = 0 & depth = 0 are a magic flag. And since we
always start at the surface, that is assumed, anyway. So let's just not
add a stop for that when re-creating a plan from a dive.

Fixes #254

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 12:42:21 -08:00
Dirk Hohndel
66f5f32f11 Once again remove debug output.
Oops again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 13:17:38 +09:00
Tomaz Canabrava
cec30c27d9 Enable a context menu to remove dive handlers.
This commit enables a context menu to remove dive handlers,
because it was hard to find that ctrl+click selected it,
then a delete button press removed it. it's better now. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 13:15:35 +09:00
Dirk Hohndel
c0a6c136f0 Fix dive planner widget
In commit 0f50b73f9e ("Fix planner / add dive handling of DiveHandler
Points") some issues were introduced. While it is fine to remove the
artificial first point at the surface, the commit broke the special
handling for o2 == -1, i.e., the usual case where a default gas needs to
be picked.

This generalizes the algorithm previously used to also look to the right,
now that we are no longer guaranteed that there is a first point to our
left.

This also cleans up some whitespace damage introduced in the same commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 11:54:13 +09:00
Tomaz Canabrava
0f50b73f9e Fix planner / add dive handling of DiveHandler Points
Dirk, is this really necessary or it's just something that you forgot
to remove? this is adding a bit of pain to fix some issues on the planner,
so I'm commenting this out untill you have a bit of time to look at it.
It looks like this was added to handle the gas in the pos-1, but you reverted
if so, this completely reverts it, and things works as expected again.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:27:41 +09:00
Tomaz Canabrava
1ee08005b2 Adds the first DiveNode at 5meters / 10minutes when clicking on plus
Adds the first DiveNode at 5m / 10 minutes when clicking on the plus
button on the DiveNotes Table.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:27:13 +09:00
Tomaz Canabrava
2235da57a7 Fix adding DivePoints on the planner via the table.
Somewhere we broke this, most probably in the code that activated the
planner to be used together as an 'add dive'. This commit makes the code
workable again.

There's one thing, though. if the model is empty, this will add something
in the first point - it's behaving strangely. I'll try to fix this in a
way that's invisible to the user, but overall, why are we inserting
something in the first(0,0) time and depth?

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:21:50 +09:00
Tomaz Canabrava
96d5687ab8 Correctly handle changes on the CylinderModel to update the AirModel.
What happened before was that the AirTypes model was only being updated
when the user requested to change the air by clicking directly
on the Air, in the planner ( but not on the Air Table. ).

This fixes it by calling 'repopulate' whenever the cylinder model
changes ( by adding, removing and changing something.)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:19:14 +09:00
Tomaz Canabrava
b77d990ed6 Close the Air list when clicking outside of it.
This patch closes the air list when clicing outside of it,
making the use of the planner more pleasant.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 09:16:22 +09:00
Anton Lundin
419e425030 Remove some unneeded member functions
We can wire qt to call the right functions directly, so we don't need
these members.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 08:59:46 +09:00
Anton Lundin
83426c59e1 Planner: Default to GF from prefs.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 08:59:01 +09:00
Anton Lundin
bc6a1a4c53 Planner: use a QSpinBox for GFLow/GFHigh
Switch to using a QSpinBox instead of a QLineEdit. This makes it a bit
more intuitive and now you can see how the deco plan changes based on
the GF's.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 08:58:35 +09:00
Dirk Hohndel
8d284b0e24 Hook up the tank change and tank update for the planner
This failed spectacularly when I first tried it, so I put it on the back
burner. And it appears that with all my recent fixes for "add dive" as a
side effect this is working, too.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 21:58:04 +09:00
Dirk Hohndel
9c90d6790a Fix some random compiler warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 21:06:31 +09:00
Dirk Hohndel
f6eb26dbae Handle tank data correctly in profile editing mode for manually added dive
This is subtle. Normally you would expect someone to edit the tank data by
simply clicking on it in the equipment tab. But a user could conceivably
edit the tank data after clicking on the profile editing button instead.
This works now as well.

This also addresses the issue that start and end pressure were not shown
in profile editing mode.

Fixes #235

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 18:36:21 +09:00
Dirk Hohndel
98322a976c Correctly convert an existing dive into a plan
I missed this one spot when converting back to the different semantics for
divedatapoints.

With this change add dive appears to work correctly (fingers crossed).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 22:39:53 +09:00
Dirk Hohndel
bb041069a3 Fix addGas to look at the correct cylinder
That was a stupid bug. You have to actually update the variable to look at
the right cylinder. Duh.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 22:38:14 +09:00
Dirk Hohndel
1a3ea5636a Don't change gas used in segments if there is still a cylinder with that gas
Otherwise adding a second cylinder (to the default one cylinder of air)
and subsequently changing the gas of that cylinder will illogically change
the gas used in all the segments.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 21:56:51 +09:00
Dirk Hohndel
d7fb6853a3 Connect changes in the tanks with the dive that is being added
- you can no longer delete a tank when its gas is in use
- therefore you can no longer delete the last tank
- when you change the gas mix of a tank, the corresponding segments in the
  dive change as well
- when changing gas for a segment the correct available gases are offered

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 21:56:22 +09:00
Dirk Hohndel
aa76d35923 Instead of a "Cylinder for planning" use a default cylinder
Right now hardcoded to AL80. This way in the future we'll have a volume of
gas that's available. And this makes much more sense then a random string
in the description field.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 21:45:24 +09:00
Tomaz Canabrava
b98157a519 Partially revert d72c69db7a and fix its errors
In the offending commit a QWidget was changed to QTableView, but
only in the header - and thus making avaliable all method calls,
but the initialization of the widgets was still a QWidget, and
nothing of QTableView was used besides an incorrect call to
setColumnHidden.

This commit fixes that by using the view() method provided by the
TableView implementation which returns the true QTableView that should be
used for specific nitpicking, like hidding columns. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 11:58:47 +09:00
Dirk Hohndel
a683a217b9 First steps to make add dive work with the correct infrastructure
This just makes sure that we do the right thing with the staging drive,
that we don't mess up the selection, the we are smart about using our
helper functions, etc.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 14:21:50 +09:00
Dirk Hohndel
94222fbe49 Remove some debug output
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 11:20:23 +09:00
Dirk Hohndel
ad4812c22e Make planner work again
This partially reverts changes in commit 1b655d5c806b ("Correctly track
gases when manually adding and then editing dives") as it turns out this
did NOT help us correctly track gases (which is ironic, given the title of
that commit). I didn't actually want to revert that commit as
infrastructure has changed since then and this made the patches look even
more incomprehensible.

So we are back to tracking the "gas on which we arrive at this spot" in
each dive plan node as this makes the rest of our planning so much easier
- I had forgotten about the reasons why we did things this way when I made
the above mentioned commit.

Instead we now make sure that our available tanks are added the correct
way, that such entries are ignored when planning and when drawing the
editable profile, and that at the end it all gets assembled correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 11:19:04 +09:00
Dirk Hohndel
d72c69db7a Add depth colum to cylinder model
To make the planner work this adds a new column to the Cylinder widget
(depth - for the depth at which we want to change to a certain gas
during deco).

This also tries to hide that column in the equipment view and hide the
start/end pressure columns in the planner view. Oddly that fails :-(

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 11:17:40 +09:00
Dirk Hohndel
cd1149e57f When entering a new point, pick the previous gas by default
This is much more useful than always picking air.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-11 18:13:55 +09:00
Dirk Hohndel
0a8892379d Connect cylinders entered in planner with the gases available
Now the gases for which we have cylinders are offered in the gas selection
list and correctly recognized and added for the plan.

Still tons of work to be done to make this work the way it is designed,
but we are getting closer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-11 17:09:19 +09:00
Dirk Hohndel
e5098c443f Hook up delegate to enable cylinder autocompletion in planner
That was easy

Hand-holding-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-11 05:51:39 +09:00
Dirk Hohndel
55c127f7c3 Enable adding cylinders in the dive planner
This is in preparation of using those to define the gases available for
planning.

Right now this doesn't seem to work quite right - I don't get the
auto-completions for the cylinders that I was hoping for...

This commit also corrects the tooltip for addint dive data points.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-10 21:02:53 +09:00
Dirk Hohndel
aa4931e8c6 Show a cylinder widget in the dive planner
This is intended to allow the user to provide the gases / cylinders that
she will be diving with. With that information the planner can warn the
user about insufficient gases, but more importantly it can show relevant
gases in the gas select drop down.

Right now the add cylinder button doesn't add a cylinder - that's a
problem.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-10 07:07:59 +09:00
Dirk Hohndel
44c9316f14 Honor "last stop at 6m" in dive planner
And recalculate the dive when it changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-10 06:08:42 +09:00
Dirk Hohndel
2a0f1fcf4e Remove left over qDebug() call
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09 20:41:28 +09:00
Dirk Hohndel
487efb1ee9 Merge branch 'addDiveGasFix' 2013-11-09 20:35:09 +09:00
Dirk Hohndel
6d5b2d7592 Adjust planner to work with the new semantic
Insert the dive data point at 0,0 manually at the beginning of the plan.
Now everything should work. We still can't edit a plan created like this,
but at least we can once again plan things.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09 20:33:33 +09:00
Dirk Hohndel
5dce73f62b Fix position of depth reading when entering dives
At 5% it would overlap the scale - now it's much easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09 20:10:49 +09:00
Tomaz Canabrava
8a970c64c2 Removed inconsistency when user tried to add dive while planning.
The user could add a dive, and in the middle click on the 'plan'
button. Since we didn't cared about that on the widget, a lot of
inconsistencies could occour. this fixes that by setting a flag
on the Planner, that has now three modes: nothing, plan and add.
(maybe in the future an edit mode will be valid too.)

If in 'NOTHING' mode, user can enter the addition, edition and
planning. If in any other mode, user can't do a thing. The mode
gets back to NOTHING when user accepts or cancels a plan / add
/ edition.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09 15:35:29 +09:00
Tomaz Canabrava
f850a0817c Fixes garbage left behind when canceling edit dive.
Garbage was left behind when canceling edit dive, and thus when the user
set his dive to be editted, after a first canceled edition, all points of
the first edition got messed up and showing on the second dive too. if the
user clicked 'ok', he got a really bad surprise.

Fixes #226

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-11-09 15:34:39 +09:00
Dirk Hohndel
8941e8677e Correctly track gases when manually adding and then editing dives
The code had quite a few odd special cases that may have been left-overs
from the old Gtk algorithm. With this the gas is actually in the dive plan
node where it's use starts. And we maintain the gas correctly between
multiple edit sessions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-08 21:22:59 +09:00
Dirk Hohndel
1578c1edb2 Be consistent when passing around gas data in the planner
We need to make sure that the correct segment has the correct gas assigned
to it - and that those gases are correctly tracked when editing a manually
added dive as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-08 18:15:04 +09:00
Dirk Hohndel
bf0bd88226 Correctly identify air
Because of rounding issues we need to use our macro to test for air
(especially since the events store gas percentages and not gas permille).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-08 18:12:26 +09:00
Dirk Hohndel
460aa4c1bd Include the cylinder information in a dive added with "Add Dive"
We only copied the samples, but not the related cylinder data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-07 18:07:10 +09:00
Tomaz Canabrava
0e96c9f62e Enable undo for the Edit mode on Added Dives.
This enables undo for the edit mode on added dives, it uses the
premade backup to fill the old dive with data. :)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
2013-11-01 14:06:03 -04:00
Tomaz Canabrava
23a193b0d1 Changed the backup implementation of the samples on EditDive.
Changed the backup implementation of the samples on EditDive,
it's way cleaner now what's happening, and it's also better for
the cancel edit.

Next: The Cancel Edit.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
2013-11-01 13:45:14 -04:00
Tomaz Canabrava
f7cd3e780c Enable editing a dive that was manually entered.
This patch enables editing a dive that was manually entered,
it doesn't cover dive plans yet because on the plan I need to
figure out what are the 'user-entered' points, and what are
the algorithm point. and I feel lazy. =p

One last thing that's missing is to revert the dive to the
previous condition if the user cancels the edition, currently
canceling and applying ok is the same thing.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
2013-11-01 11:48:34 -04:00
Linus Torvalds
58b668c714 Fix dive planner sidebar depth units
The dive planner always showed the depth in our internal units, ie
millimeter, in the sidebar that showed the plan points.

That made little sense in metric mode, and none at all in imperial. The
_graph_ showed things in meter and feet.

So make the DivePlannerPointsModel always convert things to and from the
user units.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-11 20:26:28 -07:00
Tomaz Canabrava
1b9a4f2bf8 Good deal of whitespace fixes and code cleanup.
I just went thru all of subsurface code removing
some whitespaces issues and trying to make the
code prettyer, I also removed a few QString issues.d

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-11 10:21:04 -03:00
Dirk Hohndel
b3490213f4 Merge branch 'glib-removal-hack'
Fix obvious merge issue in Rules.mk

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:57:16 -07:00
Dirk Hohndel
4d3e74a236 Trying to switch to Qt translation
This compiles and looks about right, but it doesn't appear to work, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:42:32 -07:00
Robert C. Helling
05eabae62a Modify the dialog text for the question to make more sense.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-05 19:48:39 -07:00
Thiago Macieira
ad52301ca7 Turn off Qt including the C++ Standard Library headers
We don't use any of the Standard Library features or classes in
Subsurface, except for three uses of std::sort, for which I added the
necessary #include.

It's always a good idea to include directly the headers you want,
without relying on indirect inclusion

On my machine, the build time dropped from 16.96s to 13.38s or a 12%
improvement.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 13:47:24 -07:00
Thiago Macieira
8e81d3f100 Make the classes generated by uic be real members of our classes
This means we don't have to new/delete them, which is a waste of
overhead.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 12:13:48 -07:00
Thiago Macieira
f0f76056ac Include the ui_*.h headers in the main headers.
This means we can also remove the forward declarations.

This is the first step in removing the memory allocation for the ui
sub-classes. Without the second step, this commit is just making the
compilation time increase for no good reason :-)

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 12:13:15 -07:00
Tomaz Canabrava
098aa6343b Fixed the display of Subsurface in Smaller Screens
This patch fixes the display of subsurface in smaller
screens by creating ScrollArea containers that are
now englobbing each of the Tab-pages and the Planner
Widget. Some of those widgets were pretty big by the
amount of things on it and it was too big for small
( 14" and 15" ) screens.

This seems to fix it, and looks good both on Gtk+ and
Oxygen styles.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-26 18:14:09 -03:00
Dirk Hohndel
6ce5704435 Support imperial measurements in dive planner / add dive
This was not as hard as I assumed it would be. I may still change the
horizontal dimension to be the more logical seconds instead of minutes,
but for now this achieves the main goal.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-22 12:37:49 -07:00
Dirk Hohndel
ff58fd7dca Whitespace fixes in dive planner
I know this may seem anal retentive... but it's driving me insane.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-22 12:34:50 -07:00
Dirk Hohndel
9ba7b12767 Prevent nodes in planner / dive add profile edit to run past each other
I always disliked the fact that when you moved the handlers around you
could just 'run over' the neighbors. This also (as a somewhat intended
side effect) prevents vertical descents and ascents).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-22 11:01:18 -07:00
Dirk Hohndel
799b56a1f3 Don't exit profile editor when hitting ESC in dive add mode
I'm sure there are more issues like this where we need to handle things
differently depending on whether we are planning a dive or adding a dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-22 08:45:14 -07:00
Dirk Hohndel
b1a3c1047a Simplify the default dive profile given in add dive
Suggested-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-21 08:56:19 -07:00
Dirk Hohndel
5e6ed53e40 In planner / add dive use 'ESC' to hide the gas selection popup
Not sure if there are other keys we should support.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-21 08:50:09 -07:00
Dirk Hohndel
a8888eaf26 Allow editing of date & time and air & water temperatures
Add two more rows to the widget - this is getting quite busy.
There still is some weirdness where the focus isn't returned where it
should be and a few other details, but overall getting there.

Added helper functions to parse a temperature and to deal with the
timezone offset - with that latter one I also fixed the time offset bug in
the planner.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-21 08:30:32 -07:00
Dirk Hohndel
5f4aec867e When manually adding a dive, start with a simple dive
This is much friendlier than just showing an empty profile. I picked a
nice and simple three level dive. 25 minutes at 18m, 15 minutes at 9m, and
a safety stop.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-20 07:38:15 -05:00
Dirk Hohndel
46c23c53a1 Merge branch 'addDive'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-19 23:05:17 -05:00
Dirk Hohndel
46b125782e Hook up adding a dive
This gets things mostly right.

It creates a dive and uses the planner widget to create samples which are
copied into the dive. It fills in some reasonable defaults (DC model,
timestamp), but doesn't allow editing the timestamp (or the temperatures
and air pressure).

On accept the planner gets reset and the dive appears correctly in the
dive list.

Cancel still needs to be handled.

And I bet there are many subtle bugs lurking here and there. But it's a
start.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-19 22:54:00 -05:00
Robert Helling
fc3b68bc19 Continous update of planner
Make the planner update its display continuously upon moving points
including deco. This appears fast enough on typical PCs. If this ends up
being to slow on some systems we may have to make it configurable.

[Dirk Hohndel: cleaned up the two patches and turned into one commit]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-19 09:13:53 -05:00
Dirk Hohndel
64b014aefb Don't show the planner widget when adding a dive
This looks like it might work, but since we keep recreating the dive, the
info entered in the info pane is actually lost. But it's a step in the
right direction.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-18 23:02:53 -05:00
Dirk Hohndel
56535e4b3b Only calculate deco stops in planner mode
In add dive mode simply bring the diver safely back to the surface
(currently with a fixed ascent rate of 30ft/min (or 9m/min)).

We should make that rate configurable (for the planner as well as the dive
add function). Also, the dive add function should offer to automatically
include a safety stop.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-18 22:40:34 -05:00
Dirk Hohndel
4141c68450 Rename createDecostops to drawProfile
After all, that's what the function does.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-18 22:19:49 -05:00
Dirk Hohndel
882b2c146b Use Planner dialog to add dive
Right now this is just calling the same code and setting a flag whether we
are planning or adding a dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-18 22:18:10 -05:00
Dirk Hohndel
88b7ac3d08 Planner: start time is relative
This almost fixes it, but the offset from UTC isn't calculated correctly
it seems. Committing and hoping that a Qt expert can help.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-16 23:17:24 -04:00
Tomaz Canabrava
242ef056f6 Plotted the Scale on the Ruler ( depth / time ) on the planner
Plotted the Scale on the Ruler in the planner.
There's a tiny bit issue - mostly noticiable while resizing,
but it's not a killer.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-16 20:10:12 -03:00
Tomaz Canabrava
493f366765 Use the same line dimensions as the profile, on the planner.
The Planner should be 'almost' like the profile, with the possibility
to use the mouse and keyboard to input a new plan, so this is a bit
of 'getting there.' I don't like too much code duplication but since
the current Profile Graphics is a crude cut-and-paste from the old
Cairo backend, it's easyer to start from scratch and have it well
organized as Qt code.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-16 19:21:13 -03:00
Tomaz Canabrava
f74799d581 Ok on the planner now correctly creates a Dive.
Ok on the planner now correctly creates a dive,
a few remarks, tougth:

1 - the number of the added dive is always 0
( but I may be testing it wrong )

2 - the information pane is working only when
the mouse is clicked, this is a regression and
it will be fixed. ;)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-16 12:30:58 -03:00
Tomaz Canabrava
fad55b3047 Move the creation of the dive plan to the model
The dive plan was bein created on the Profile, this
While this worked out, it created a bit of spaggethi
code, so now the model will take control of *everything*
on the planner.

I tested it quite a bit and doesn't seems to have appeared
a regression, wich is good.

Now that a dive plan is bein created, I can just save it. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-16 12:11:06 -03:00
Tomaz Canabrava
bfe1ea0cb2 Plug the Cancel action on the Dive Planner Table and start the 'ok' code.
Plug the cancel action on the dive planner ( before that, only by
hitting the 'ESC' button things worked, so now you can also click
on the Cancel box that's on the right of the planner profile window.

Also, the beginning of the 'ok' code is also at place.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-16 11:38:41 -03:00
Tomaz Canabrava
4e06c52f68 Position the X and Y labels of the Rulers
Position the X and Y labels of the rulers, this way
it's a bit more clear the deepness and the length
of the trip. It's still not the best approach, but
I'm getting close.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-16 11:09:54 -03:00
Tomaz Canabrava
923b4cd9b1 Make the Plus Button on the planner work.
Clicking on the plus button now adds a new stop on the planner.
The depth is always 10m and the time is 10 minutes after the
last stop. can be changed by double clicking or dragging the
balls around the canvas.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-09 22:57:22 +00:00
Tomaz Canabrava
813722633d Last gas used will be used on new dive planner point.
This patch makes the last gas used on the planner the
default.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-09 20:45:03 +00:00
Tomaz Canabrava
b4a609f46f Signal that the model changed when editing plan specific information.
Signal that the model changed when editing plan specific information,
when you changes the ATM pressure or any other information, the
graphic of the plan will be generated again to mirror your actual dive.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-09 07:27:46 -03:00
Tomaz Canabrava
545c76992a Plug most of the dive planner - non - model stuff.
Plug most of the dive planner controls that weren't
plugged yet - StartTime, ATMPressure, BottomSAC,
DecoStopSAC, LowGF and highGF are being used by
the calculations now.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-09 07:18:22 -03:00
Tomaz Canabrava
64864fea9c Enable the CC SetPoint on the planner, also input bug fix.
Enabled the CC SetPoint settings on the table, changing
it will automatically reflect the canvas. Also fixed a bug
that prevented the 'Air' handling on the diveplanner
table to show the list of options using arrow up and down.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-09 06:48:03 -03:00
Tomaz Canabrava
c029cb0a07 Fixed a incorrect signal that shouldn't be there.
Fixed a incorrect signal-connection call that should'nt
be there anymore because the TableView now correctly
knows what to do with models.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-03 13:59:20 -03:00
Tomaz Canabrava
5666f6573e Code Cleanup: Merged the three TableViews shared code
Merged the shared code for the three table views into
one code, this way less code is needed if we need to
construct another tableview in the future.
I still need to clean some of the models too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-09-02 16:21:08 -03:00
Tomaz Canabrava
9bc7d8f514 More Code Cleanup
The code now seems to be mostly working. There is unfortunately
a QAction shortcut conflict between the implementation and the
MainWindow. - I'm gonna fix that in the next commit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 16:43:10 -03:00
Tomaz Canabrava
aef0dd0fa0 More Code Cleanup.
Just a bit of code cleanup so that I don't bloat the software
too much. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 16:33:54 -03:00
Tomaz Canabrava
959bdbbca7 Fix '+' sign for time on the planer, plus code cleanup.
The plus sign for time was in a very strange position,
this puts it back to where it belongs, plus a bit of
code cleanup since the planner was in heavily modifications,
this will be needed quite a bit. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 16:21:55 -03:00
Tomaz Canabrava
72807017ae Make planned points deletion works on the Table too.
Now the planner deletes points by clicking on the
trash icon on the table. The dive planner is almost
finished. <3

next: add a point from the table.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 16:08:55 -03:00
Tomaz Canabrava
d37213a413 Moves deletion logic of divepoints to the Model.
Deletes the logic of divepoints to the model, this
makes automatic updates on the table on deletions.
( remember, to select dive points, ctrl+click on it.
) if you want to delete it, press 'delete', it will
be removed from the graphics part and also from the
table.

Next: delete point by clicking on the table trash-
icon.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 15:53:10 -03:00
Tomaz Canabrava
5e722a93e4 Gas choices working, both directions ( Planner and Table )
The gas choice now works and correctly ( I hope ) calculates
the gas choosen to show on the planner. User can choose the
gas from the list on the visual planner, and also on the table.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 15:06:26 -03:00
Tomaz Canabrava
2d0e877bb2 Added support for changing Depth and Time on the Table.
Added support for changing depth and time on the table.
It now works both ways, one can edit the planner via the
table for a fine tuning. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 13:27:15 -03:00
Tomaz Canabrava
69903903d2 Started the work of Editable Model for the Planner
This commit is the start of the Editable Model work
for the planner, it creates a new delegate and shares
the code for the model that creates the gas types, so
we only need to change in one place to add new gases.

The table is already edition-enabled, but the outcome
is still undone, next commit - put all together.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 07:14:30 -03:00
Tomaz Canabrava
6c56f07959 Code Cleanup - Remove temporaries.
Just code cleanup, removing temporaries.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 06:54:41 -03:00
Tomaz Canabrava
2921f4c825 Code cleanup - Dead Code.
Just removing an #if 0

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 06:52:58 -03:00
Tomaz Canabrava
bb59202812 Made the TableViews share a bit of code, code cleanup.
Made the tableviews share a bit of code, and code cleanup.
The tableviews for Cylinders, Weigth and Dive Planner Points
now shares the CSS and I also implemented the save / load
methods for the dive planner points, so the functionality
is mostly done on the vieualization side. - since we are
now using three tables maybe it's a better idea to create
one class SubSurfaceTable that knows how to handle saving
/ loading of the columns... TODO for the future. ;)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-28 07:48:46 -03:00
Tomaz Canabrava
cfd17116eb Added a 'remove' icon on the dive planner table.
Added a 'remove' icon on the dive planner table,
this makes the ui more consistent between the other
tables that also manages addition and removal of data.

the delete method is still unimplemented.
next - css.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-28 07:27:59 -03:00
Tomaz Canabrava
65ab236948 Fixed moving a dive point between dive points
Fixed moving a dive point between dive points.
this fixes mostly everything that I have broked
by using a Qt Model instead of a linked list -
but a model is better to make everything updated
and only poke in one place. sharing code++. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 17:15:48 -03:00
Tomaz Canabrava
3323fecea8 Made possible to add a divepoint between two others.
Made possible to add a divepoint between two others,
this also implemented the last patch in the correct way.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 17:02:34 -03:00
Tomaz Canabrava
760c14ac0c Fixed entering a dive stop before another dive stop.
Fixed entering a dive stop before another dive stop,
the correct way is to fix the position of them but
this is easyer - I'll update the correct one in
a couple of patches.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 16:55:30 -03:00
Tomaz Canabrava
9d90034109 Fixed invalid values on the TableView
The values of the dive points on the tableview were
too big, I'm now dividing time by 60 and depth by 1000
to get the correct results.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 16:38:12 -03:00
Tomaz Canabrava
5ad4cfe8e2 Fixed a bug where moving a handler would mess the planner
Fixed a bug where moving a handler would mess the planner
by calculating invalid values to the planner on the model
side.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 16:36:30 -03:00
Tomaz Canabrava
367fc6e1c3 Moved a lot of code to the Model, cleaning the interface.
Moved a lot of code that handled the positioning of the
DiveHandles on the interface to the model. there are a
few bugs left ( regressions ) that I will fix in the
next commits. With this commit an edition of the points
on the widget will trigger a repaint of the planner profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 16:34:06 -03:00
Tomaz Canabrava
de2f5d9e60 Moving Handler on Graphics Updates the Model on the Planner
Moving the handler on the graphics updates the model on the planner
Unfortunately, the graphics will move back to it's original
position because of the legacy code used to calculate the
dive plan. Next: fix the legacy code used to calculate the dive plan.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 14:54:07 -03:00
Tomaz Canabrava
bc71f9a916 Moved the creation of the data plan point to the model.
Moved the creation of the data plan point to the model,
this way when the user creates a data point on the
graphical planner, or when the user creates the point
on the QWidget based view, both of them will be updated.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 14:17:39 -03:00
Tomaz Canabrava
024dd80664 First implementation of the Shared Model for the Planner
This implementation of the shared model already shares
some, but not all data between the two views, but it's
already a huge improvement. When the user clicks on the
visual planner, it will update the view on the qt-widget
based view. The editing of the view is still not allowed,
and removing nodes is not allowed too ( yet. )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 13:18:21 -03:00
Tomaz Canabrava
9856aaaa86 Started the Model to handle the DivePoints
Started the model to handle the divepoints between the
Qt Widget interface and the QGraphicsView one. good thing
is that we share code. Bad is that a model is harder to
work, but doable. :)

With this finished ( in a couple of commits ) one can
insert a point on the Qt widget or on the graphics view
and it will be 'mirrored' to both interfaces.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 09:14:19 -03:00
Tomaz Canabrava
aceb002a33 Changed the WindowHint of the planner popup to 'Popup'
Changed the Window Hint of the planner popup to 'Popup'
this removes ghost items from the task bar.

Hint By: Danilo Cesar
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 08:49:28 -03:00
Tomaz Canabrava
6cb1f1a250 Code Cleanup: Buttons on Graphical Planner
Removed a bunch of non-used graphics buttons,
since the new widget now contains everything
needed for the creation / cancelation of the
dive plan.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 08:47:45 -03:00
Tomaz Canabrava
0a043528f7 Added a new widget to control the Planner
Added a new widget to control the DivePlanner, now we
have two widgets, a graphics one and a qt sidget based one.
the Technical divers will most likely use the QtWidget one
while the hobbists will most likely use the QGraphicsView
one. there's not a option to choose one, they both will
appear at the same time.

Next step: make the screens to work.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-26 08:43:37 -03:00
Robert C. Helling
7293885178 Delte the temporary dive from the divelist after calculating deco.
This bug manifested itself as too long deco obligation when moving
waypoints to later and then back to earlier times as all intermedite
versions were created as dives in the divelist (and the saturation of
these "previous dives" was taken into account.

It is not entirely clear to me how the dive will be permanently added to
the divelist once ok is pressed: One could in createDecoStops allocate
struct dive from the heap rather than from the stack and return a pointer
to it and which is then added to the dive list upon pressing ok.

[Dirk Hohndel: add include file to make this compile]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-05 16:59:29 +02:00
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
83c73168b0 Added a missing #UNDEF
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-21 13:01:33 -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
249a1ac170 Added a messageBox when the planner quits with a working plan.
Added a messageBox to warn the user that he quit with a working
plan, to reduce the risk of unwanted loss of work.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 12:58:11 -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
ae08a81739 Fixed the 'hard to grab' Handler, Dive Planner now is very smooth.
So, it was on the docs, but I didn't read it before, if the
scene has items that ignores transformations, we need to
pass the view transform to the method that gets the items
in the scene. I also used IntersectsItemBoundingRect instead
of IntersectsItemsShape because it's faster, and our items
are small, so we don't need an very accurate but slower method.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 10:34:30 -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
603d2f5cb3 Make it possible to add a handler between others
Make it possible to add a handler between others,
someone asked why I didn't make like this from the
beginning, the answer is that I wanted to have something
stable before messing a bit more with the planner, but
since the planer is almost-stable, I added. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 10:06:52 -03:00
Tomaz Canabrava
55f8979160 Better positioning of buttons on dive planner
Better positioning of buttons on the dive planner. The ok / cancel
buttons are in the correct place, and the '+' sign for time will not
overlap the time string anymore.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04 09:45:25 -03:00
Dirk Hohndel
6b08a6d428 Silence some warnings
One of them actually looks like it was a bug...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02 13:58:03 -07: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
6e6a1c08c3 Make the 'increase depth' button to work.
Make the increase depth button to work, it also adds
a 'safety' stop at 150m, I know that this is deep, and
maybe we need to adjust this to a better safety stop.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 14:14:09 -03:00
Tomaz Canabrava
a7506848b3 Removed user-entered lines on the plan, keeping only deco.
Removed the user-entered lines on the plan, keeping only deco,
This way the graph looks way prettier and we don't loose any
functionality.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 13:39:54 -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
43664d7cd5 Fixed positioning of the dive Handlers.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 11:47:26 -03:00
Tomaz Canabrava
94c2e5dc18 Correct collors for the DivePlanner background.
Use the correct colors for the Background on the Dive Plan,
same as on the Profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 11:21:28 -03:00
Tomaz Canabrava
b07429ff8b Added the last 'tick' to the rulers
The last tick to the rulers were missing, this was making
them to look odd, this make the rulers better looking,
but it caused the other-non-ported-yet-to-percent stuff
to behave in a not so good way, most visible one is the
handlers, gonna update them next.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02 11:18:31 -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
ca517f1bf8 Shared background for profile and planner.
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>
2013-07-02 10:13:06 -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
de7506b44d Somewhat saner behavior for rescaling the planner time axis
We always resize if the dive is longer than the current scale allows, but
we don't shrink it overly aggressively and we never shrink it below the
initial size.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 22:10:03 +08: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
Dirk Hohndel
937fef819a Remove unused code
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 20:55:36 +08:00
Dirk Hohndel
3fa3f55163 Remove incorrect logic for first line in planner
This greatly simplifies the code.
Similar to (but not based on) code submitted by Robert Helling.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 20:54:17 +08:00
Robert Helling
8eb2dc3d65 Removes circle in plan
Remove circle in plan by starting the first line at the first point
rather than the last.

In addition marks all entered points as entered and not just the first and
sets line color accordingly.

Makes plan_add_segment return the added data point.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 19:51:04 +08:00
Tomaz Canabrava
7a840d2668 Fixes most of the issues with the dive planner.
Fixes most of the issues with the dive planner,
The lines are removed when the drag starts, and
it's repopulated after. The time ruler updates
itself with the biggest time in the dive (I'll
add later the code to keep a minimum of 60 minutes,
and increase by 15 to 15 minutes, but for now
this will work ), Removed the code to do
line manipulation while we are moving handlers
around ( because it could trigger ruler-expansion,
that woul'd move everything, and that's not nice.

This showed that something bogus is going on with
the decompression algorithm - I don't know if it's
on the data or on the algorithm itself, but it's
creating a ring with the lines on the canvas
I painted all decompression-algorithm based lines
red so it's easier to spot where the hell things
got wrong.

midnight, sleepy.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-26 20:41:39 -03: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
ef0272f5ef Perform deco calculation for plan
This uses a bunch of default values that we eventually need to get from
the UI, but it's a first step towards a working dive planner.

This exhibits some graphical artifacts when running, but other than that
appears to be mostly correct.

Things go far worse if I enable the changing of the scale once the deco
makes the dive longer than the displayed time window. Things quickly
spiral out of control.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-23 21:36:50 -07: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
4a184a60fc Print the rounded values for time and depth in planner
This looks much more natural than truncating the values. Now the displayed
numbers correspond to the "snap" behavior of the handles.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-23 17:32:23 -07:00
Tomaz Canabrava
a0e5244ffe Fix updateTicks
This is the correct way to add the ticks (and gets rid of two warnings).

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-23 13:21:01 -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
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
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