Commit graph

39 commits

Author SHA1 Message Date
Tomaz Canabrava
ac9a23ef3b Remove the old profile from the main screen of Subsurface
This patch partially removes the code for the old profile from
Subsurface. It removes the use of the old profile on the mainwindow,
but keeping the code in the tree for now.

A bit of code-cleanup also entered this commit because I had to change
every instance of the code that used the old profile.

Now to the real code-cleanup

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07 08:54:20 -08:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 20:09:57 -08:00
Tomaz Canabrava
35e102b176 New profile: add the RulerItem
This patch adds the RulerItem inside of the new profile, and already takes
settings into consideration.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 10:48:47 -08:00
Tomaz Canabrava
1695894130 New profile: connect the scale action
Just quick'n dirty glue code so that when the user clicks on the 'scale'
toolbar item, the new profile graphic is scaled.

Lovely thing: Animations for free. <3

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 10:48:47 -08:00
Dirk Hohndel
b5a02e50aa New profile: create new class for DiveHeartrateItem
This allows us to give it a different color (red) and make it a smaller
size.

While implementing this I also fixed the size of the temperature text in
the new profile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-23 15:28:31 -08:00
Dirk Hohndel
fd1a62568b New profile: partial addition of heartrate
This was done during an IRC hacking session with Tomaz.
It compiles, it shows something but not the right graph.
Committed here so Tomaz and I can continue to work on it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-19 17:19:57 -08:00
Tomaz Canabrava
31ee4dac65 Make part of the context menu work (gas change event)
The code of the context menu and the gas change event callback is mostly
the same as the old profile, with minimum modifications, as this changes
the order of the code on the callback to make it a bit saner (declare
variables first, call code later).

This also fixes a bug on the model that was not cleaning itself in the
correct way after a call to clear.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 14:50:14 -08:00
Tomaz Canabrava
fc55b2abfe Remove the class 'CartesianPlane'
This class was pratically a re-do of the axis, I'll do the axis to plot
the lines when it feels like it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:16:02 -08:00
Boris Barbulovski
ccb1c33d02 Put include guard to every header
* ensure include guard to every header
* comment endif guard block

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:37:01 -08:00
Dirk Hohndel
d49acdb3c0 Clean up include files
They should have a newline at the end.
Forward declarations of classes should be 'class'.
Function / method definitions don't end on a ';'
Remove obsolete QStateMachine forward reference.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 12:34:34 -08:00
Boris Barbulovski
1d871eb749 ProfileWidget2 class improvements
* Reorder ProfileWidget2 class constructor initialize list.
* Initialize(lazy) ProfileWidget2::plotInfo structure.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09 14:42:07 -08:00
Tomaz Canabrava
d66e4b5236 Fix the 'Empty' profile state that was broken for ages.
Show a nice poster that Luisa did for Subsurface ( we have a few other
options that I'm waiting her to send. )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:18:40 -08:00
Tomaz Canabrava
86bc3bd58f Start to make things sane again...
Change the 'namespace ItemPos' declared on the commit before this one to a
struct that will have all the 'on canvas' and 'off canvas' positions and
representations of all items, so we know where to change.

Also remove the remaining stuff from planer that was going to exist on
this profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:18:12 -08:00
Tomaz Canabrava
9cf6b2be6b Break everything to make it correct next time.
This commit breaks the whole new profile. <3
The problem with the old code is that I was using the QStateMachine
and I just got tired of it. I will implement a much-simpler state
machine to do what I want instead of hitting my head on the wall
to understand how that was supposed to work.

This commit also adds a few helper methods to simplify the understanding
of the constructor and tries to make the logic a bit better. No graphics
are being show right now. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:16:16 -08:00
Tomaz Canabrava
6de9b329d1 Huge code cleanup.
This patch starts the cleanup that will take a few iterations to finish.
The current profile code uses QStateMachine, and it's much too verbose
for something we can do with less than a third of its lines of code.

I also added on the beginning of the redesign of the profile code for
planner, edit and a few other things that are going to be ported to
the new profile in the future, but not currently - I just lack the time
to make that work for the next release.

This commit basically:
 - moves all 'new' calls to the initializer-list
 - create a new 'setupItem' private method to concentrate the calls
   that any item will do

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-08 07:14:50 -08:00
Tomaz Canabrava
49f8456ce8 Remove a lot of unused code.
This will probably be added back in the future, but for now
they have no use and it was making me nauseaus.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 11:32:32 -08:00
Tomaz Canabrava
2a9289ac99 Add an event filter to hide normal tooltips
This patch adds an event filter to hide normal tooltips on the new
profile. All tooltips should be displayed in the Notification Area.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:31:55 -08:00
Tomaz Canabrava
19585d9a13 Add the tooltip item to the new profile.
The functionality is not there yet - just the item hovering
the screen.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:28:21 -08:00
Tomaz Canabrava
a649bcc7bc Added Mouse based Zoom / Movement.
This patch uses the same code that lubomir used on the
old profile. It strangely didn't worked - most probably
because the scene has a fixed width() and height() of
100. the zoom works, and the movement works, but only
on the 100 first pixels of the profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-05 06:30:33 -08:00
Tomaz Canabrava
c99089e1fa Add settings awareness for the PP graph
This commit is rather big, and I forgot to cut it in pieces.
The first part creates a new 'calculate_gas_information' that will not
fill the profile_info->maxpp member ( that should be removed from it as
soon as the new dialog is finished ). The reason for that is that all of
the profile data will be calculated and the graph needs to update
dynamically, so whenever the settings changes, I ask for the model which
is the biggest graph and replot only the ones we need.

The second part adds a new animation function 'animdelete' to fade-out and
delete the item when it's done. the old function 'hide' did just that but
a hide shouldn't delete anything.

The third part is preferenes awareness for the PP graphs. I created two
new functions that receive the settings key for visibility and use the
QSettings to show / hide them. This also works quite well for the axis;
if no graph is visible, the axis will also hide itself.

The fourth part is colors. The pp graphs now have the correct colors.

And a bit of code cleanup too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-27 09:15:28 -08:00
Tomaz Canabrava
b5e8ef160a Added the Po2 Partial Pressure Graph.
Important to note that no Partial Pressure Graph handles
settings yet.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:15 -08:00
Tomaz Canabrava
1cae362c16 Added the code for the PHE gas pressure.
Using the PartialPressureGasItem the addition of a new partial plot
is very easy.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:15 -08:00
Tomaz Canabrava
caa45a1539 Added the first Partial Gas Pressure: PN2
This makes the beginning of the partial gas pressures, there's
two more. but this code uses a good part of the Model View system,
and it's way clearer than the old one. Luckly the other 2
missing items will be even more clear ( the diffs ) to do,
because I just need to create a new PartialPressureGasItem and
set the properties. <3

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23 21:11:15 -08:00
Tomaz Canabrava
cde9bc0de9 Make the tissues be preferences-aware.
This patch adds a new class DiveCalculatedTissue that's preferences aware.
It knows when to show or hide itself.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-22 13:28:25 -08:00
Tomaz Canabrava
2e2a87e619 Add a MeanDepthItem that has 2 strings.
Dirk's implementation of the MeanDepth item was correct, but in order to
add the 2 strings to it ( one at the begin, one at the end ) I had to put
more stuff inside the ProfileWidget that's already packed with graphics
items.

So I created a new class MeanDepthItem that contains these 2 strings and
will get updated whenever the value changes.

I also fixed a math inconsistency where I changed RIGHT to LEFT.
(wich fixed a few text-placements, and broke others.)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-22 12:29:41 -08:00
Tomaz Canabrava
b08da94007 Draw the Ceiling in red if preferences are marked for that.
This code actually uses the preferences for something. It will show and
hide the calculated ceiling in red if the prefrerences are changed for
that. One bad thing that I did in this commit ( so it was easy to try ) is
that a preference change will redraw the whole graph - not optimized. I'll
make this better in a later commit so that only the affected items will be
redrawn.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 14:25:09 -08:00
Tomaz Canabrava
ce7c3f8314 Add the tissues to the profile graph
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 11:35:24 -08:00
Tomaz Canabrava
8065374793 Add the DiveCalculatedCeiling item.
This item plots the DiveCalculatedCeiling over the profile. I still need
to add the Calc All Tissues version.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 11:35:09 -08:00
Tomaz Canabrava
caba6500d6 Add the dive computer text.
Added the dive computer text on the bottom left side of the new Profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 09:38:46 -08:00
Dirk Hohndel
3bbc4ecd0b Add mean depth to new profile
With massive hand-holding by Tomaz.
Writing for the new profile code is slightly different. You don't draw
anything, you just tell the widget where things are supposed to end up and
how they are supposed to look. Really nice.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-18 14:38:21 -08:00
Tomaz Canabrava
4ff73cf537 Add the gas pressure plot.
Added the Gas Pressure Graph with the related Model Changes
to access the cylinder index, pressure, interpolated pressure
and SAC.

The plot does not correctly plot its color right now but it's not hard to
do.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 14:04:47 -08:00
Tomaz Canabrava
e3ec5ef290 Added the Cylinder Pressure Axis
The cylinder pressure axis is the 'Y' axis for the Cylinder plot.
I positioned it in around 20% to 60% of the screen state.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 14:04:47 -08:00
Tomaz Canabrava
58aeb6ce40 Added the Temperature Graph.
Added the Temperature Graph with its related classes. A Temperature Axis
is also created so the item is plotted on the right place.
Currently the Temperature Axis is just like the depth axis - top is
zero, wich means that the graph is inverted.

Also, the Temperature axis is being displayed as this helps debugging.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 06:18:25 +07:00
Tomaz Canabrava
1f80788286 Added a DiveEventItem that knows how to handle itself.
Simply pass a event to the item and it will know what
to do. The sad part is that this isn't true yet - there's
quite a bit of boilerplate that a lot of the items are needing,
but the good part is that the boolerplate is the same in
all of the items, which means that I can create a tiny bit
of abstraction to encapsulate it and the code will be
way smaller to setup the items on the canvas.

Right now the items are being correctly placed on the
right places. It doesn't supports hidding / showing yet.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 06:17:09 +07:00
Tomaz Canabrava
9cb5ea45d8 Started the code for a grid that knows how to handle itself.
The code for this item is a bit too big to be just the grid
of the dives and I know that, don't bully me. :)
The main idea of this grid is that it knows when it should be
updated. this is a bit different than the old code where all
the painting happened on the same method. This is bad because
it's more code, but it's better because if I break the grid,
only the grid will be broken, and it's easyer to spot the breakage.

in the old code if I did the wrong thing with the graphics context,
the whole graph gots messed out.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 06:16:47 +07:00
Tomaz Canabrava
74cb7d6b2a Aparrently there's no need for a showEvent here.
Just removed some code that I tougth to use, but it looks
like it's just a waste of lines.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
ff49cb1929 Fix the size of the scene on screen and Background improvements.
It seems that I forgot to add the background pixmap, but this is being
done right now by luisa. This patch fixes the size of the scene by
scaling everything to the size of the viewport as soon as a resize is
done, and it also fixes the size of the - to be included - background
pixmap.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
b50ae87007 Initializing the new Profile Class.
Beginning of the code for the constructor, just constructing
some of the items and preparing for the State Machine to come.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
946e3855b2 Add the skeleton for the New Profile System.
The idea of this widget is to display and edit the profile.

It has:
 1 - ToolTip / Legend item, displays every information of the current
     mouse position on it, plus the legend for the maps.
 2 - ToolBox, displays the QActions that are used to do special stuff
     on the profile ( like activating the plugins. )
 3 - Cartesian Axis for depth ( y )
 4 - Cartesian Axis for Gases ( y )
 5 - Cartesian Axis for Time  ( x )

It needs to be dynamic, things should *flow* on it, not just appear / disappear.
It's the last attempt to create a QGraphicsView based Profile System,
as the next will most probably be written in QML.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 09:45:42 +07:00