This patch makes the Tissues be used as a 'cache', it will not
be deleted untill the program closes, but whenever a new dive is
selected, the old drawings of the tissues will be regenerated,
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
This way we will always have this object on screen, and as soon as the
model changes, it's contents will change.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The reported ceiling now behaves better by not being deleted / recreated,
instead it uses the same object and connects to the model to know when to
regenerate its plot.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch makes the cartesian axis of the profile depth shrink and
(together with it) the Profile Depth and the grid lines. There will
probabla bey a lot of things that didn't have their correct position
fixed, so I'll fix them in the later commits.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Almost all of the items on the new profile were being painted
on the same ZLevel, so the level of awesomeness was a bit random.
This puts things on the correct spots, events on top of everything,
profile at the bottom, things in the middle.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This code adds all state transitions for the items on screen; they do not
animate yet, but already move to the correct location (the location seems
wrong on the screen, because I'v not correctly zoomed out the canvas yet).
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Those constants will be used later on to setup all transitions of
the Graphics Items on the canvas. They are the correct positions
of each item inside and outside of the scene, in a way that the
state machine can animate them smootly.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a start of the work on the States for the Profile. All setup is
done, all connections are done. Maybe there's something missing because I
never worked with QStateMachine before, but it seems to work correctly.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The background should be a Pixmap and thus it cannot zoom in or
out; this keeps it the same size always, the full height of the
scene.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Setup the default item sizes and locations inside of the QGraphicsScene.
Also added every item to the scene so that it's correctly displayed on
screen.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
Created a Time Axis based on the CartesianAxis that knows
how to plot the minutes. This is needed because the CartesianAxis
donesn't knows about minutes at all, and would plot the
seconds instead.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The CartesianAxis used a simple method to put things on screen
which is wrong for almost any case besides the 'current value here'
since we store things in milimeters on the axis, we need to convert those
to meters before showing on the profile.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I've used the paint() method on it ( even if it's not necessary
on a QGraphicsView ) to reduce absurdely the number of items that are
inserted on the QGraphicsScene ( each small line of the profile should
be an item if it was not for this, it's like that on the old profile. )
and thus reducing the memory consumption, speed and so on.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This model encapsulates the plot_info struct and provides
a consistent way to show it using the Qt Model view system
in the C++ and QML way. For a QGraphicsItem that should show
a Profile, this is the start.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When we prepare the axis to show something on the Profile
we need to add the remaining ticks to show on screen,
Since this method tries to animately move / remove things
before calling this.
This has no animations yet - will have in the future.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the size of the Axis changed, this should move them smootly to their
place.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch makes the updateTicks method not remove / readd everything
when it's triggered, but to only remove the ticks / labels that
are no longer needed on the current display.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is the same class as the Ruler, but uses the DiveLineItem
and DiveTextItem classes created to make it animateable. The next
few commits will work on that part. The Ruler was a very bad
name for a class that's actually an Axis, that's why I depreceated
the later.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since the animation methods are fairly the same for any QGraphicsItem,
I created a new namespace named 'Animations' that should handle all
of the specific Animation Functions there, and the programmer has to
call those functions from the objects. Good thing is that this reduces
boilerplate code.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit adds a class based on QGraphicsSimpleTextItem that
handls animations via animatedHide() animatedMoveTo() and a few
other QPropertyes. This is to be used in conjunction with the
DiveLineItem added in the past commit on the Coordinate Axis.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This class has animatedHide, animatedMoveTo and QProperty
animations. it's very userful for the future creation of the
Cartesian Axis that will have the ticks 'flowing' around when
it's needed.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This class is useful for adding / removing icons on the future profile in
a way that they are smoothly added to / removed from the canvas.
It uses the QProperty System to deal with animations.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This class extends the QGraphicsRectItem with the ability
to use the Qt Property System - and thus, we can animate
the properties. Initially I put only the rectangle, the
position and the x and y positions indidually for testing.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>