Commit graph

70 commits

Author SHA1 Message Date
Dirk Hohndel
1f785111f7 Whitespace, whitespace, whitespace
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 14:30:36 -08:00
Tomaz Canabrava
bd96036892 Better use of the preferences changed signal.
When the preferences changed signal is fired, the items that can change
their visual based on the preferences now have to reimplement the
preferencesChanged method, so they know if they need to be replotted on
screen. I already implemented that for two of the items ( ProfileDepth and
Ceiling ) but others might need that too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 14:25:34 -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
8831bf6350 If we draw ceilings in red do not dig a hole on the profile.
This is an attempt to speed up painting a bit. Since we will draw the red
ceiling on top of the profile, I don't see a reason to dig a hole in it,
creating an more complex shape to be passed to the painter. Easier shapes
are easier to draw. ( I think )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 14:24:08 -08:00
Tomaz Canabrava
58d9282955 Show dive computer ceiling
This patch adds dive computer calculated ceiling on the profile graph as a
'hole' on it. There's an item that paints it in red - maybe we shouldn't
offer an option here and show that only in red?

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 14:23:33 -08:00
Robert C. Helling
2f822ec0dc Prevent potential math overflow in new profile
Test for max_temp == min_temp to prevent math overflow when calculating
temperature axis in new profile

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 14:07:10 -08:00
Tomaz Canabrava
4159faa950 Remember to clean the tissues when changing dives.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 11:35:36 -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
b1df7aeb4e Plot gas value function ported to the new canvas.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 11:35:04 -08:00
Tomaz Canabrava
9d33640bea Add the gas presssure profile texts.
This just adds the texts for the gas profile. I've also added a method on
the dataModel() to return the diveId of the last used dive in a way that
the other methods can use it.

This code is almost 1-to-1 with the old one, a bit of thinkering can be
used to merge this loop with the upper one.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 09:39:42 -08:00
Tomaz Canabrava
21d34db3a9 Simplfy the code for the cylinder pressure.
Instead of asking the data as we do on the generic models, use the
internal knowledge of the class.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 09:39:21 -08:00
Tomaz Canabrava
0a4e21a168 Add the depth text.
Depth text got added to the new profile.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21 09:39: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
Tomaz Canabrava
63c1a1b3e9 Plot the events on top of the profile.
Changes the ZValue of the event items so they are plotted
on top of the profile, instead of being hidden on some.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-19 21:38:14 -08:00
Tomaz Canabrava
edad8712b9 Make the colors of the texts be prettier.
Just fixes some colors of the texts on the canvas.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-19 21:38:10 -08:00
Tomaz Canabrava
cd3867d46a Remove the ticks on the Axis, we never used them on the old profile.
This patch just cleans a bit the Cartesian Axis, we never used
ticks on it, just the grid lines ( that I need to animate a bit. )

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-19 21:37:48 -08:00
Tomaz Canabrava
592ee31326 Fixed Temperature Text
This fixes temperature text replacing the old code
with the new DiveTextItem.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-19 21:37:32 -08:00
Tomaz Canabrava
9d2344d01b Fix the positioning of the Labels using the new DiveTextItem
This uses a combination of items on the canvas which makes it easier to
position it where I want.

This also broke the other texts because I forgot about them. I will
fix that on the next commit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-19 21:36:55 -08:00
Tomaz Canabrava
72b5bbce6e Remove the plotText function, standardize with the TextItem.
Removed the plotText function and replaced it with the
DiveTextItem class - this way there's just one way to add
text on screen, and it also makes it easy to fix positioning
of stuff there. Which is what I'll try to fix on the next commit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-19 21:36:08 -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
Dirk Hohndel
2c6830c399 Fix maxdepth in new profile
get_maxdepth() already gives you the correctly rounded maximum depth.
Don't mess with it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-18 14:33:12 -08:00
Michael Andreen
b3179380cf Fix crash in new profile
The gasPressureItem needs to be initialized to null in the constructor.

Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-18 07:22:23 -08:00
Tomaz Canabrava
35979537d9 Plot the Temperature Text.
I Moved the 'plot text' method of the Old Graphics to the new
layout - this one was mostly unchanged as it was already good
as is.

And used the TemperatureProfileItem to also display texts.
This was the first implementation of the new system that uses
*less* code than the original one, wich makes me happy.

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
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
779c1b6738 Create a version of create_graph_info that doesn't depend on GC.
This version of the create plot info is the same as before, with the
difference that it doesn't depends on the gc.
Also fixed a crash.

The Pressure Index, Information and interpolated seems wrong,
I'm getting only zeroes.

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
0787347691 Add Information about the Pressure to the Model.
Added missing information about the pressure to the model; this shows that
I didn't do something right, as the model has 0 pressure information. Need
to fix that on the next commit.

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
e23841dd7f Remove warning about a null pixmap.
Since I didn't add a pixmap to be the background of the new profile, yet,
things got wrong on mac and crashed. This should fix it.

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
470de7ee07 Remove warning about item not on the scene.
This patch fixes a warning about the QGraphicsItems not being on the
QGraphicsScene, and thus, cannot be removed from it.

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
c88ccfae99 Fix a crash.
I forgot to initialize a variable, sorry.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 08:32:32 -08:00
Dirk Hohndel
09d08ddc1c Fix compile time warnings
Plus some small whitespace fixes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 06:39:24 +07:00
Tomaz Canabrava
2e4dcba009 Do not display the Time Axis
The old graph didn't display the time axis, so this will
also not display it. By not calling updateTicks the labels
and ticks of the Axis are not created.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 06:19:26 +07:00
Tomaz Canabrava
f9784d876e Made the Axis be aware of Direction.
Now we can create an axis that's topToBottom, BottomToTop, LeftToRight and
RightToLeft.

This was needed for the Temperature Plot, because it should be inverted
(starting on the bottom).

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 06:18:56 +07: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
254beef5d4 Transform the DiveProfileItem to an Abstract Generalization
The DiveProfileItem contained much of the complexity and
algorithms for almost all line-based items on the canvas,
so I transformed that to a general abstraction and implemented
a new DiveProfileItem that uses it. this should reduce a
bit of code since the implementation of the PP Graphs, Temperature
Cylinder Pressure and maybe a few others will only need to
reimplement the paint() and the modelDataChanged() methods.
The rest is ready.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 06:18:00 +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
6f5974f3e8 Use the same methods as the old profile to discover the boundaries.
This method gathers information about the max and minimum sizes of
the cartesian axis that we should plot. It's still a bit cumberstone
for my taste, but this shouldn't be a problem. I think we need to
rework the 'Zoomed' version of it, since zoom or without zoom,
we should be good to go using the QGraphicsView.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 06:16:07 +07:00
Dirk Hohndel
2e08f75618 Get rid of build warnings
This is just to make it more obvious when new issues get introduced. The
build should always be free of warnings...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 12:44:18 +07:00
Dirk Hohndel
49a4a11a44 Fix compile error when not building with CONFIG+=debug
There are still some warnings left, but at least it compiles now.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 12:28:33 +07:00
Dirk Hohndel
a27f67c026 Whitespace and coding style updates
Another futile attempt to cleanup the code and make coding style and
whitespace consistent. I tried to add a file that describes the key points
of our coding style. I have no illusions that this will help the least
bit...

This commit should ONLY change whitespace

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 11:50:56 +07:00
Tomaz Canabrava
dd64f1792d Reworked the calculate_max_limits and plotted the dive.
Created a new version of calculate_max_limits that doesn't have a
graphics_context and returns a plot_info. The code is basically the same
as the old calculate_max_limits, so there's not much to talk about.

The rest of the code is just boilerplate to plug the Profile
code with the axis and model stuff, to be plotted on screen.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:31 +07:00
Tomaz Canabrava
52064d9e02 Added debug code to help understand the Profile
This commit adds a QTableView if built in debug mode. This is very userful
to understand the Profile that will be drawn by the graphics classes and
fix the possible errors.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:31 +07:00
Tomaz Canabrava
7affccdf5b Importantly, I had forgotten to start the state machine
The state machine needs to be started before it works; now the animations
are working. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:31 +07:00
Tomaz Canabrava
7ba4fe885e Added names to the states, so it's easier to debug.
There's a Qt visual debug / helper tool made by KDAB named GammaRay that
uses QObject instrospection to understand what's happening on a QProject.
This tool uses the Object Name to display the items on a list, so I've
added the QState's names to their objects, which greatly helps debugging
with Gamma Ray the states of the StateMachine.

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
6f7967e0e0 Added a Context menu so we can test the state switching.
The context menu added here should only be temporary, it's an easy and
simple way to test the transitions of the items on screen.
They seem a bit broken atm, I'll try to fix that. :)

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
c301367259 Added the Animations for the transitions of the States.
This code creates the animations that will be triggered when an state
changes. Things like hiding items and such should be handled this way.

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
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