Commit graph

4091 commits

Author SHA1 Message Date
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
793879b6fa The plot-profile method was being called too many times.
There was a bug in the old implementation where we needed to
trigger a repaint of the profile almost everywhere. this isn't
needed anymore on the new one, so do not use the same method
that will be killed when I finish this.e

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 06:16:35 +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
Miika Turkia
e9f3d652e8 Treat Sensus CSV import specially on GUI
As Sensus import needs a specific XSLT and user specified parameters are
not used nor needed, tune the GUI accordingly (disable options and add
Sensus in the list of known imports).

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 05:57:45 +07:00
Miika Turkia
2167088f1c Add Sensus XSLT as a resource and enable it
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 05:57:42 +07:00
Miika Turkia
ef54cb427e Support for XSLT template for CSV import
This will allow one to give CSV tag as parameter when importing CSV
files. On normal case one will use csv, but when special handling is
needed we can give a specific XSLT file instead.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 05:57:40 +07:00
Miika Turkia
209a793acf XSLT for parsing Sensus Ultra CSV export
Sensus divides temperature in one or two fields (depending on locale),
so it cannot be parsed with our generic CSV import XSLT. And e.g. depth
is in millimeters.

This supports only importing of single dive at a time. Multiple dives
would be in same file with first column being dive number.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 05:57:37 +07:00
Miika Turkia
6e9f32604b Sample log from Sensus Ultra, exported in CSV
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 05:57:29 +07:00
Sergey Starosek
d9c23bb622 Remove duplicate method call
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 05:56:45 +07:00
Anton Lundin
6014461181 Don't include stdbool.h when included from C++
As noted by Thiago Macieira, we shouldn't include stdbool.h when were
included from a C++-file such as main.cpp

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 05:55:01 +07:00
Dirk Hohndel
2c8e8f8cec Add switch statement to CodingStyle
Requested-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 12:58:06 +07:00
Linus Torvalds
96a4fd1bb2 Save XML files into a memory buffer rather than directly into a file
This introduces a "struct membuffer" abstraction that you can write
things into, and makes the XML saving code write to the memory buffer
rather than a file.

The UDDF export already really wanted this: it used to write to a file,
only to then read that file back into memory, delete the file, and then
*rewrite* the file after doing the magic xslt transform.

But the longer-term reason for this is that I want to try to write other
formats, and I want to try to share most helpers.  And those other
formats will need this memory buffer model.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 12:51:23 +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
Boris Barbulovski
6cc65f5e1c Fix some memory leaks.
Memory leaks were caused by broken parent/child relations.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 12:15:47 +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
Dirk Hohndel
3387ccc6f6 Show old profile when starting Subsurface
Tomaz code had us start on the depth model tab (when built in debug mode).
It seems to make much more sense to still show the fully featured profile
by default.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:21:50 +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
Tomaz Canabrava
816f6db356 Added all the state transitions for each state.
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
0703706600 Added Constants to the code, to ease the setup of the transitions.
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
02e3021333 Started the work on the States for the Profile.
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
cdb447434d Added the flag to ignore item transformations on the background.
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
93d464fcb7 Setup the default icon sizes and locations.
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>
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
8773b4f9f0 Create a Time Axis that knows how to plot the minutes.
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
67f2c0bcaa Added a 'Depth' Axis that knows how to add its strings on screen.
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
90fc7a23f2 Pass the current selected dive to the new Profile Widget.
This call just passes the selected dive to the new profile widget. No
drawing is performed, I still have to setup the constructors and the rest
of the initialization of the new Profile.

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
581faa598e Added the DiveProfileItem that uses the DiveProfileModel to diplay data.
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
7d5cf32501 Added a Model that should handle the Dive Profile
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
215e22481a Added the remaining of the ticks to their correct position.
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
36475c1ee5 Moves the remaining ticks of the Axis to their correct position on update.
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
ca979044d0 Remove only the Uneeded Ticks / Labels when a update is requested.
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>
2014-01-16 10:12:30 +07:00
Tomaz Canabrava
49f4052c67 Cartesian Axis, based on the Ruler class on the Dive Planner.
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>
2014-01-16 10:12:29 +07:00
Tomaz Canabrava
ca07f45561 Added a new Namespace to deal with Animations and related functions.
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>
2014-01-16 10:12:29 +07:00
Tomaz Canabrava
408b7dd5e5 Add a class based on QGraphicsSimpleTextItem that handles animations.
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>
2014-01-16 10:12:29 +07:00
Tomaz Canabrava
d47456b4e8 Added a class based on QGraphicsLineItem that can be animated.
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>
2014-01-16 10:12:29 +07:00
Tomaz Canabrava
639123a1e8 Added a QGraphicsPixmapItem subclass that handles Animations.
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>
2014-01-16 10:12:29 +07:00
Tomaz Canabrava
81e9fcc6e8 Added a new class based on QGraphicsRectItem that can be animated.
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>
2014-01-16 10:12:20 +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
Rodrigo Severo
c79473df60 Remove old message directing users to use "Import CSV files" menu option
As importing files is now done through "Import Log Files" menu option for all
file types, the message directing users to use the specific "Import CSV Log Files"
non-existent menu entry should not be presented any more.

Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 09:37:46 +07:00
Miika Turkia
dd3261f232 Grab also the last column in CSV when requested
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 09:37:28 +07:00