Commit graph

8251 commits

Author SHA1 Message Date
Dirk Hohndel
b1538c809d Code cleanup
Make precedence of && over || explicit.
Explicitly convert between char * and unsigned char *.
Don't assign potentially negative return code to an unsigend variable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 13:59:14 -07:00
Dirk Hohndel
e76675d4df Whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 13:58:12 -07:00
Salvador Cuñat
1197be235b OSTCTools - Add unsigned char variable
In commit 22bfc49 an explicit cast to (char *) was introduced to silence
some compiler warnings, but an (unsigned char *) is needed if related
values are expected to be greater than 127 or we will get the usual
weirdnesses.

Just introduce such variable and use it where needed.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 13:15:29 -07:00
Tomaz Canabrava
e6ae371673 Removed unused icons
While looking for the icons so luisa could create svg
versions of them, I found out a few things that are not
used anymore.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 12:49:52 -07:00
Dirk Hohndel
cf047466b5 Cmake: make Facebook support an actual option
This way we can selectively turn off Facebook support.

And turning off both Facebook support and support for the user manual
allows us to not rely on QWebKit which once again allows debugging
Subsurface with valgrind on Arch Linux.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 12:11:07 -07:00
Dirk Hohndel
6ebeba3c7c Be more careful freeing taxonomy data
We want to only access data that we consider valid. And we need to clear
out pointers to freed memory.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 12:09:20 -07:00
Robert C. Helling
56913191af Fix typo in test and some numbers
With these values I reproduce the runtimes from the UI.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 08:56:48 -07:00
Claudiu Olteanu
14e071e8d8 Add extra logs for custom serial Bluetooth implementation
This patch increases the verbosity level for QtBluetooth API
and add some extra logs for custom serial Bluetooth open method.

The scope of this patch is only for testing.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 08:38:12 -07:00
Claudiu Olteanu
198cc41959 Implement the custom Bluetooth serial communication and use it
Create a custom Bluetooth serial communication using the QTBluetooth
API and use it when the Bluetooth download mode is enabled.
First try to connect on RFCOMM channel 1 because this is the default
RFCOMM channel of SPP service for most devices. If this doesn't work
try again on RFCOMM channel number 5 because it could be a Petrel2 device.

Add a fake open function for the custom implementation. This is
used when the selected device is HW OSTC 2N and the Bluetooth
mode is activated, then fake the open call of the serial device.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 08:37:42 -07:00
Claudiu Olteanu
dff4e5f33e Add a dialog for remote Bluetooth devices selection
Implement a dialog which can be used for remote Bluetooth devices
selection and to control the local Bluetooth device.
Functionalities of the widget:
 - expose information about the local BT device
 - scan for remote BT devices
 - pair/unpair with a remote BT device
 - turn on/off the local BT device
 - logging
 - save the selected BT device

The selection dialog is created when the bluetoothMode checkbox
is enabled.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 08:36:42 -07:00
Claudiu Olteanu
b4c4d95ea4 Add a checkbox and a button for Bluetooth download mode
The checkbox will be used to enable the Bluetooth
downloading mode. The button will be used to create
a dialog selection where the user will be able to
scan and select remote devices.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 08:34:39 -07:00
Dirk Hohndel
5766d1894c Adapt the test to the API change
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 22:30:02 -07:00
Dirk Hohndel
35b4af913b Cmake: only build print related files if NO_PRINTING isn't set
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 16:33:07 -07:00
Grace Karanja
db3a9abac9 Correctly include QtQuick when building for mobile
The changed introduced in d880040d breaks mobile builds by not correctly
linking with QtQuick. This change fixes that by fixing the incorrect line
in CMakeLists.txt so that the correct QtQuick headers will be found.

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 16:01:54 -07:00
Robert C. Helling
e864c365c7 Correct logic
At least my compiler warns about ! binding stronger than == and
thus comparing a bool to an int. I guess this is what was meant.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 15:54:20 -07:00
Robert C. Helling
a7d18a9fa6 Round MOD of gas rather than truncate
For the proper calculation, we need to take salinity and surface pressure
into account (rather than depth = bar * 10 - 10)

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 15:53:49 -07:00
Dirk Hohndel
9c6a3a7ff3 Merge branch 'custom-print' of github.com:neolit123/subsurface 2015-07-05 12:01:43 -07:00
Gehad elrobey
cc53dc7acf Printing: implement QPlainTextEdit in TemplateEdit
This is the main area to edit the templates inside Subsurface.
Whenever the user edits a template the edited template is saved in
custom.html and custom.html is considered the selected printing
template.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:03:12 +03:00
Gehad elrobey
c44496e23d Printing: move template_options to print_options.h
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:03:04 +03:00
Gehad elrobey
a70cea95e8 Printing: refactor the print options class
-Remove unneeded parameter to member variable
-Check if template_options struct is valid

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:02:49 +03:00
Gehad elrobey
605e1e2d93 Printing: add functions that read/write a template
Read/write templates from files.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:02:40 +03:00
Gehad elrobey
c35092f5c9 Printing: add custom options to the PrintDialog
Add:
-custom.html template
-custom template to print_options struct
-options to the options dialog

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:02:09 +03:00
Gehad elrobey
815072d2ae Printing: retrieve number of dives per page from the template file
Add special data attribute 'data-numberofdives' in the template <body> with
the number of dives per page.
This is standard HTML5 specification so it won't corrupt the template file.
Any template that will be used for printing must contain this attribute to
assure correct output.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:01:53 +03:00
Gehad elrobey
6446b75b9e Printing: edit templates to show template options dynamically
Template styles must refere to Grantlee fields to be replaced with
user selected settings.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:01:31 +03:00
Gehad elrobey
4a98d92489 Printing: export template_options struct to Grantlee engine
Add template_options to Grantlee lookup section and export the struct
fields.

-font: is the font type used, must be selcted from 5 different types.

-font-size: is a user selection from 9 - 18 then it is scaled to a range
from 1 to 2 of the displaying view port.

-color-palette: is the colors used in the template, all used colors must be
referenced from here.(not yet implemented)

-line-spacing: is the distance between two consecutive lines in the dive
notes text.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:01:01 +03:00
Gehad elrobey
bc80fc8849 Printing: pass the template_options struct to TemplateLayout
The template_options struct needs to be passed to TemplateLayout
constructor.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:00:40 +03:00
Gehad elrobey
71561e720d Printing: add QSettings for TemplateEdit class
TemplateOptions struct must be saved to QSettings after the window
is closed, also it must be recalled when initializing the window.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:00:28 +03:00
Gehad elrobey
a600ea5201 Printing: add template_options struct that contains template
The template_options struct holds the settings variables in the code.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:00:25 +03:00
Gehad elrobey
ff594c65e3 Printing: call TemplateEdit when edit is triggered
Edit button should open TemplateEdit dialog.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 21:00:20 +03:00
Gehad elrobey
963e09ad7b Printing: add TemplateEdit form to source tree
The TemplateEdit class works to customize the tempalate before printing,
User can select the font-size, font-type, color-palette, linespacing
and editing the template HTML code.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 20:59:55 +03:00
Gehad elrobey
ce3d2abd83 Printing: show warning message for WIP features
Show warning message before proceeding to print 'Table' or
'Statistics' print layout. This should be used during the
development phase only.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 20:59:34 +03:00
Gehad elrobey
3d5caabe4a Printing: fix two dives per page borders and text font
As we use a responsive layout, every UI element must be relative
to its parent and its size must be a ratio of the view port to
prevent them from displaying outside their containing parents.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 20:58:47 +03:00
Gehad elrobey
fcde03e849 Printing: choose printing color mode 'color/greyscale'
We can have color printouts only if the printer supports color
prints, the user selected 'print in colors' from the print dialog and
the default printer settings (Operating system wise) is to print in
colors, Otherwise the prints will be in greyscale.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 20:58:33 +03:00
Gehad elrobey
5981cf170f Printing: make dive profile scale dependant on the page size and DPI
Use setFontPrintScale() to change the font scale of the dive profile as a ratio of
the full resolution, font = (pageWidth * dpi) / fontvalue

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 20:58:29 +03:00
Gehad elrobey
1faa198020 Printing: print all dives if 'print selected' is unchecked
User can choose either to print all dives or print selected dives only.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 20:58:24 +03:00
Gehad elrobey
bc0b443afd Printing: add QPrintPreviewDialog to main dialog
Add preview dialog that shows the printer contents before printing.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-07-05 20:58:16 +03:00
Dirk Hohndel
35dc814105 Add simple test for the dive planner
This sets up a standard dive scenario (30 minutes at 260ft/79m, EAN36 and
Oxygen as deco gases, last stop at 20ft/6m) and calls the planner to set
up a dive plan given certain standard gases.

Instead of trying to verify the complete plans it checks that we switch to
the deco gases at the right depth and the complete duration of the dive
matches our expectation.

The test intentionally fails right now for imperial as we have the wrong
switch depth for Oxygen. See how useful tests are?

On the downside, the test does NOT produce the same plan as Subsurface
when I try to create a consistent setup for both - and I have not been
able to figure out why. There must be some other parameters that I'm not
setting, but I haven't identified them, yet. It's very small differences,
for example in the metric case the stops at 21m, 9m, and 6m are each one
minute shorter in the test than it what Subsurface calculates.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 09:42:38 -07:00
Rick Walsh
17ef6774e0 Planner deco stops are at 10ft increments when measured in feet
When using feet as depth unit, deco stop levels should be at 10 ft rather
than 3 m increments.

For shallow stops, rounding means the difference is not apparent. However,
with stops deeper than 30 feet, using 3 m increments leads stops at 39ft,
49ft, ..., 98ft, etc.

Apart from making plans look messy, the old behaviour makes it harder to
benchmark the planner against published profiles in imperial units.

This revised patch uses the help macro M_OR_FT(6, 20) to set the last stop
at the correct depth.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 06:50:48 -07:00
Rick Walsh
8c4e1e6bfa Read planner preferences when we use them
Read and use the last_stop preference in the plan function.
Read the plan notes preferences and set variables (plan_verbatim,
plan_display_runtime, plan_display_duration, and plan_display_transitions)
in the add_plan_to_notes function. Don't read the preferences and set
variables otherwise. Both plan and add_plan_to_notes functions are called
on data change.

Previous behaviour was:
- Set variables on declaration
- Reset variables in plan function (even variables that only relate to
  planner notes output)
- Changing a preference triggered set_xxx function which sets variable,
  then plan function, which sets variable again.

Apart from being inefficient, the previous behaviour made it difficult to
track down where and when variables were set.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 06:37:01 -07:00
Dirk Hohndel
896b7a5e74 Merge branch 'new-vpm' of https://github.com/Slagvi/subsurface 2015-07-05 06:32:23 -07:00
Dirk Hohndel
74e2956986 INSTALL file: a few more changes
- Qt4 is no longer supported
- Make the Kubuntu comments more generic
- Mention command to add user to dialout group

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-04 09:20:36 -07:00
Pedro Neves
54af724f17 INSTALL file: add notes for Ubuntu/Kubuntu 15.04
Update the install instructions when compiling Subsurface from source on
Ubuntu/Kubuntu machines.

Signed-off-by: Pedro Neves <nevesdiver@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-04 09:20:08 -07:00
Jan Darowski
ddfd046c8d VPM-B: add CVA to the deco planner.
Added keeping bottom dive state and every deco's time, so we can
run multiple deco simulations with different gradients until they
converge to some optimal value.

Some improvements on the deco time calculation may be needed.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-04 00:13:34 +02:00
Jan Darowski
bfb9f19080 VPM-B: add next gradient calculation.
It improves (increases) gradients for all the compartments,
so more free gas can be created in the divers body. Next gradients
will converge, so the volume won't exceed the safe limit, indicated
by the crit_volume_lambda parameter.

Function takes time of the last deco in seconds.
Requires vpmb_start_gradient() to be run before.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:59:22 +02:00
Jan Darowski
02f1339917 VPM-B: vpm without CVA working.
Add call of initial calculation of critical radius and start gradient,
so the VPM could work.
Currently without CVA, so the gradient isn't improved.
Only one iteration is run.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:54:57 +02:00
Jan Darowski
e7aa686f16 VPM-B: add vpm-b based deco checking.
Check during the trial_ascent() if existing pressure gradient is
smaller than previously calculated max gradient. If not, ascent
is impossible from the vpm-b's point of view.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:24:20 +02:00
Jan Darowski
fad592e43a VPM-B: add initial gradient calculation.
Calculate the max difference between tissue saturation and ambient
pressure that can be accepted during the ascent.
Partial results are kept for later improving in next CVA iterations

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:19:57 +02:00
Jan Darowski
500fbe4994 VPM-B: add deco choice to the ui.
Removed recreational mode from ui and pref and replaced it with
new deco_mode enum.
Added radio button ui selection.
Set default deco_mode to Buehlmann algorithm.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 23:07:58 +02:00
Jan Darowski
2435d79c0e VPM-B: add nuclei size calculation and nuclear regeneration.
This function calculates the size of nuclei at the end of deco,
then simulates their regeneration, to the moment before the deco.
This is redundant as nuclear regeneration is a very slow process.

Function should be called with time in seconds, just before the ascent.

Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 22:45:29 +02:00
Robert C. Helling
0180d2eb1e VPM-B: use an analytic solution for nucleon inner pressure instead of binary root search
According to mathematica

In[4]:= f[x_] := x^3 - b x^2 - c

In[18]:= Solve[f[x] == 0, x]

Out[18]= {{x ->
   1/3 (b + (
      2^(1/3) b^2)/(2 b^3 + 27 c + 3 Sqrt[3] Sqrt[4 b^3 c + 27 c^2])^(
      1/3) + (2 b^3 + 27 c + 3 Sqrt[3] Sqrt[4 b^3 c + 27 c^2])^(1/3)/
      2^(1/3))}, {x ->
   b/3 - ((1 + I Sqrt[3]) b^2)/(
    3 2^(2/3) (2 b^3 + 27 c + 3 Sqrt[3] Sqrt[4 b^3 c + 27 c^2])^(
     1/3)) - ((1 - I Sqrt[3]) (2 b^3 + 27 c +
       3 Sqrt[3] Sqrt[4 b^3 c + 27 c^2])^(1/3))/(6 2^(1/3))}, {x ->
   b/3 - ((1 - I Sqrt[3]) b^2)/(
    3 2^(2/3) (2 b^3 + 27 c + 3 Sqrt[3] Sqrt[4 b^3 c + 27 c^2])^(
     1/3)) - ((1 + I Sqrt[3]) (2 b^3 + 27 c +
       3 Sqrt[3] Sqrt[4 b^3 c + 27 c^2])^(1/3))/(6 2^(1/3))}}

For the values of b and c encounterd in the algorithm, the first solution is in fact the
only real one that we are after. So we can use this solution instead of doing a binary
search for the root of the cubic.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
2015-07-03 22:36:59 +02:00