aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profile/diveprofileitem.cpp
AgeCommit message (Collapse)Author
2014-01-23Added the first Partial Gas Pressure: PN2Gravatar Tomaz Canabrava
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-23Prevent memory leak by removing the texts on the TemperatureItemGravatar Tomaz Canabrava
This patch prevents memory leak by adding the text on the list of 'delete me when model changes' items. it also makes things a bit more snappy because the scene doesn't have to deal with all of the texts bounding rectangles eveytime. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23Move profile item to be used as cache.Gravatar Tomaz Canabrava
the profile item should also use the model to know when to change something, this makes it happen. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23Moved the temperature item as a 'Cache'Gravatar Tomaz Canabrava
This patch moves the temperature item as a cache that will be updated as the model updates, instead of deleting / recreating it everytime the dive changes. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23Fix the ghost-text-on-profile regressionGravatar Tomaz Canabrava
The last patch correctly moved the GasPressure item to use a cache-based system, but ignored the fact that the Gas pressure text was not being removed from the scene. this fixed it. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-23Move the creation of the Gas Pressure item to the constructorGravatar Tomaz Canabrava
This makes the Gas Pressure Item a 'cached' item, when the dive changes, the item will regenerate the drawing based on it's model. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-22Make the tissues be preferences-aware.Gravatar Tomaz Canabrava
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-22Do not delete / new object that can be cached.Gravatar Tomaz Canabrava
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>
2014-01-22Simplify the code for the reported ceiling.Gravatar Tomaz Canabrava
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>
2014-01-22Prepare for plotting partial pressures in the new profileGravatar Tomaz Canabrava
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>
2014-01-22Add a MeanDepthItem that has 2 strings.Gravatar Tomaz Canabrava
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-21Whitespace, whitespace, whitespaceGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21Better use of the preferences changed signal.Gravatar Tomaz Canabrava
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-21Draw the Ceiling in red if preferences are marked for that.Gravatar Tomaz Canabrava
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-21If we draw ceilings in red do not dig a hole on the profile.Gravatar Tomaz Canabrava
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-21Show dive computer ceilingGravatar Tomaz Canabrava
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-21Add the DiveCalculatedCeiling item.Gravatar Tomaz Canabrava
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-21Plot gas value function ported to the new canvas.Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-21Add the gas presssure profile texts.Gravatar Tomaz Canabrava
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-21Simplfy the code for the cylinder pressure.Gravatar Tomaz Canabrava
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-21Add the depth text.Gravatar Tomaz Canabrava
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-19Fixed Temperature TextGravatar Tomaz Canabrava
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-19Remove the plotText function, standardize with the TextItem.Gravatar Tomaz Canabrava
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-17Plot the Temperature Text.Gravatar Tomaz Canabrava
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-17Add the gas pressure plot.Gravatar Tomaz Canabrava
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-17Added the Temperature Graph.Gravatar Tomaz Canabrava
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-17Transform the DiveProfileItem to an Abstract GeneralizationGravatar Tomaz Canabrava
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-16Get rid of build warningsGravatar Dirk Hohndel
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-16Whitespace and coding style updatesGravatar Dirk Hohndel
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-16Added the DiveProfileItem that uses the DiveProfileModel to diplay data.Gravatar Tomaz Canabrava
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>