aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profilegraphics.cpp
AgeCommit message (Collapse)Author
2013-10-07Remove even more code and declarationsGravatar Dirk Hohndel
There's lots more stuff that can go. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03Lookup gas via the plot_data, not the eventGravatar Anton Lundin
When straight decoding the event, it failed to handle older SAMPLE_EVENT_GASCHANGE(11), the ones without he-part correctly. This was shown clearly when it printed the 21/35 in dives/test20.xml as air. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03Profile: use a 10px font when printing profile textGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-27correct the placement of pressure markersGravatar Maximilian Güntner
Adding +30 (seconds) to the position works fine for long dives but when zoomed in on short dives, 30 seconds are a lot. This commit sets the offset to +10 px regardless of the scaling. Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2013-09-27Added a toolbar to the profileGravatar Maximilian Güntner
The toolbar adds two buttons to the profile. The user can now toggle the scaling (zoomed to dive/round up to 30 mins) and adding /removing ruler to/from the profile using this toolbar. Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2013-09-27Added a ruler which can be dragged along the profileGravatar Maximilian Güntner
This patch adds a ruler QGraphicsItem which can be dragged along the profile. The ruler displays minimum, maximum and average for depth and speed (ascent/descent rate). Also, all used gas will be displayed. This also adds a new attribute to struct plot_data to store the speed (not just as velocity_t). Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2013-09-27plot seconds with a fixed width of 2Gravatar Maximilian Güntner
before: 0:50 1:0 1:10 after: 0:50 1:00 1:10 Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
2013-09-23Remove o2/he from plot_data and fix gas plot textGravatar Anton Lundin
plot_data.o2 and plot_data.he was wrong for all dives, due to that cylinderindex was set right first in populate_pressure_information, and thus those two contained bogus information. This makes the plot-text use cylinderindex-lookup as everything else. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-17Bugfix plot of ceiling violationGravatar Anton Lundin
Due to a bug in how the entry-list was handled, a point on the polygon was introduced at 0,0 that made a weird pink triangle across the whole profile. This was quite clearly seen in dives/test15.xml Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-08Use maxx from graphics context for time calculation.Gravatar Michael Andreen
Fixes #128. Signed-off-by: Michael Andreen <harv@ruin.nu> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-05Fix " begin" and " end" for events in plot.Gravatar Michael Andreen
QObject::tr() has source string as first argument and disambiguation as second argument. Currently the events shows "Starts with space!" instead of " begin" or " end" after the event name. Signed-off-by: Michael Andreen <harv@ruin.nu> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-05Support more than one event of the same type in Qt tooltip.Gravatar Michael Andreen
Since the tooltip text was used as key in the map, two events of the same type, close to eachother, would cause one of them to not be removed. Since ToolTip::removeToolTip() isn't used, we don't need a QMap and can use a QList instead, so all tooltips are properly cleared. Signed-off-by: Michael Andreen <harv@ruin.nu> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-18Profile: support grayscale plottingGravatar Lubomir I. Ivanov
This patch adds the getColor() helper function to ProfileGraphicsView and EventItem so that retrieving a certain color can depend on a 'isGrayscale' flag. This flag is private and only set by ProfileGraphicsView::setPrintMode() at this point. EventItem also now accepts 'grayscale' as a constructor argument. A couple of side modifications are: - move setBackgroundBrush() to ProfileGraphicsView::plot() - set the same pen color as brush color for the dot in the '!' symbol inside EventItem::EventItem(). TODO: look for color issues when printing using the custom grayscale table Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18Profile: add the isGrayscale flagGravatar Lubomir I. Ivanov
setPrintMode() can now be used to set the profile to be plotted in grayscale. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-18Profile: use a printMode flag in ProfileGraphicsViewGravatar Lubomir I. Ivanov
When printing the profile there are certain features which we want different (or disabled). This includes font scale ignoring and showing a toolip. To achieve that we check for a printMode flag in ProfileGraphicsView which can be set using setPrintMode(bool). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-07-05Profile: prevent a bug when switching viewsGravatar Lubomir I. Ivanov
While in zoomed mode and when resizing the splitters or switching views the profile tooltip can end up being at the wrong location and also the zoom state becomes corrupt, so perhaps the entire transformation needs to be reset. To prevent the bug we listen for relevent to the profile splitter resize event, view changes and clear()/plot() the entire profile graphics. This is an slow/expensive solution and perhaps there are cheaper alternatives e.g. updating only the scene rectangle and tooltip, somehow. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05Profile: improve tooltip animationGravatar Lubomir I. Ivanov
Remove a couple of expand() calls(?). Also store the last expanded rectangle size in the private variable nextRectangle and use that in collapse() animation. Patch prevents a small jump/resize glitch if the user quickly hovers over and out of the profile while the tooltip is still resizing. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05Profile: small tweak for tooltip separator lineGravatar Lubomir I. Ivanov
Add 3px of a initial horizontal offset. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-05Profile: collapse tooltip back to original heightGravatar Lubomir I. Ivanov
When collapsing the tooltip we want it's border to become the same height as when no tooltip info was visible - i.e. post creation. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04Profile: attempt on better zoom and pan logicGravatar Lubomir I. Ivanov
QGraphicsView::AnchorUnderMouse does not work for Qt 4.8.1 on Ubuntu 12.04 and if the mouseMoveEvent overload is disabled it practically can be seen that the anchor point is [0, 0] instead of the mouse location. After a suggestion found on the web this patch attempts to use the hidden scroll bars to calculate reposition on pan and zoom *near the mouse cursor. On the other hand QAbstactSlider (QScrollBar) class strangly uses negative offsets for minimum scroll position, which makes the implementation even more ugly. [*near] because it's not that accurate! Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04Profile: use more levels of zoomGravatar Lubomir I. Ivanov
Makes it easier to see colored lines - e.g. velocity with 20 levels of zoom. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-04Profile: prevent a zoom glitch at maximum zoom levelGravatar Lubomir I. Ivanov
The 'else if' condition in ProfileGraphicsView::wheelEvent() is causing a zoom-in / zoom-out loop at zoomLevel = 10. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02Profile: add white outline to all textGravatar Lubomir I. Ivanov
To draw the white outline around profile text we trace a text path using QPainterPath::addText() and then create a couple of QGraphicsPathItem objects. One of the objects is outlined using QPainterPathStroker and is placed at the bottom of a QGraphicsItemGroup with a white brush. The other object holds the standard colored text and is placed on top. Notes: - possibly quite expensive on older machines - ProfileGraphicsView::plot_text() now returns a QGraphicsItemGroup - QGraphicsSimpleTextItem uses a top-left baseline anchor while QPainterPath::addText() uses a bottom-left baseline which is a bit mysterious, requires the -3 offset for a match and is possibly non-portable across fonts and sizes. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02Revert "Profile: add white outline to all text"Gravatar Dirk Hohndel
This reverts commit 44c33742c26dcf9387b5c837c161e33ddc5eb060. I mistakenly applied the wrong version of the patch. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02Silence some warningsGravatar Dirk Hohndel
One of them actually looks like it was a bug... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-07-02Merge branch 'nitpicks' of github.com:tcanabrava/subsurfaceGravatar Dirk Hohndel
2013-07-02Shared background for profile and planner.Gravatar Tomaz Canabrava
Share the background for profile and planner. Those are not the same class, but they should behave somwheat the same. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-02Added 2 new files to handle the common stuff for graphics.Gravatar Tomaz Canabrava
Added 2 new files, graphicsview-common.h/cpp, that should have the common stuff shared between the dive profile viewer and the dive planner. the amount of duplicated code would be huge if we go the road of two different classes for each one, but since the planner took a more 'Qtish' way of behavior, in comparisson to the profile - that's most a Cairo-To-Qt literal translation, we cant easily merge the code without a complete ( and unwanted ) reestruturation of the profile code, thus, this new files will serve as a bridge between them. Initially I put there only the colors - since that's wat most easilyy shareable. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-29Profile: add white outline to all textGravatar Lubomir I. Ivanov
Goal: no blending between profile text and graph lines Qt doesn't seem to provide an easy-to-go solution in terms of styling the z-order of the pen and brush layers of a QAbstractGraphicsShapeItem (or alternatively pen offset), which is needed if for example one likes the pen not to cover the text fill. Calling QGraphicsSimpleTextItem->setPen() on small text can cover bigger portions of the text, as the pen ends on top of the fill and given the pen stroke path ends up scaling exactly at the fill path border but not on the outside, for example. Since we don't get quick control over that (and to avoid the issue in a naive way), we set the text as bold and the white outline lands over the "bold-ed" area of glyphs. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-28Profile: move the bounding box below plot dataGravatar Lubomir I. Ivanov
In certain conditions a number such as '51' could end up being partially hidden under the white bounding box in such a way that the digit '1' is barely visible. Putting the bounding box bellow all plot data solves the issue. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-18Converting the device_info list into a Qt data structureGravatar Dirk Hohndel
This data structure was quite fragile and made 'undo' when editing rather hard to implement. So instead I decided to turn this into a QMultiMap which seemed like the ideal data structure for it. This map holds all the dive computer related data indexed by the model. As QMultiMap it allows multiple entries per key (model string) and disambiguates between them with the deviceId. This commit turned out much larger than I wanted. But I didn't manage to find a clean way to break it up and make the pieces make sense. So this brings back the Ok / Cancel button for the dive computer edit dialog. And it makes those two buttons actually do the right thing (which is what started this whole process). For this to work we simply copy the map to a working copy and do all edits on that one - and then copy that over the 'real' map when we accept the changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-14Plot cleanupGravatar Dirk Hohndel
Use a helper to make things easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-13Merge branch 'linusDiveList' of https://github.com/tcanabrava/subsurfaceGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-12Do not plot on showEvent if dive is already plotted.Gravatar Tomaz Canabrava
We do a force-plot on showEvent because the user can have asked to open a dive file via command line, so the app needs to open already with a profile plotted. if the user opens the program, loads a map, hides the profile by hitting ctrl + 1, then shows the profile again by hitting ctrl + 2, we do not want to do all the math to show the profile again, because we already have it in memory. this also fixes dirk's strange behavior of funky profile. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10Added a slot to set the full time of the dive planGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10Added a simple "TextEditor" in the graph, for a plan mode.Gravatar Tomaz Canabrava
Added a simple TextEditor in the graph for the 'Dive Plan' mode, this text editor is very simple, so the user can double click on 'depth' or 'duration' to set the depth or duration of the dive. Since this was a test, only 'duration' was done, and I'll add duration on the next commit. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10Added a 'Plan' mode and a 'Dive' mode on the profile.Gravatar Tomaz Canabrava
Added a 'Plan' mode and a 'Dive' mode on the profile. Those modes tell the application what can be done: Plan - the dive's dinamyc and can be changed, 'Dive', the dive is fixed ( most probably downloaded from a dive computer and it's readonly. ) - now I need to properly populate stuff. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10Implemented the movement of the ToolTip by Hand.Gravatar Tomaz Canabrava
Reimplement the movement of the tooltip by hand, we were adding / removing childs of the tooltip quite often, wich broke the movement of the item using the default behavior, aparently Qt uses a cache of the transformation of the item, assuming that the bounding box of it will not get modified while dragging. wich in our particular case, is a falacy. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10Save / Restore toolTip information position on the Profile when switching dives.Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10Fix memory leakGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-10Moved the 'create fake dc' to it's own function in device.cGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-07Hide/Show tooltip on mouse over view widgetGravatar Helio Chissini de Castro
Proper hide/show tooltip under ProfileGraphicsView. Events are not properly handled and no custom tolltip status was stored. Text are properly hidden now when tooltip is collapsed. Reported-by: Tomaz Canabrava Signed-off-by: Helio Chissini de Castro <helio@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-06Fix movement of the tooltip overlayGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-31Show the gas with the pressure diagramGravatar Dirk Hohndel
This is a feature that had been requested a few times in the past and when debugging my "show only used gases" commit I realized that this would have been extremely useful to have... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31Show GF for calculated ceiling above the graphGravatar Dirk Hohndel
The hardcoded position we previously had would make the text invisible if a ceiling was drawn during the middle of the dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31Cleanup minor issues with ceilings for individualy tissuesGravatar Dirk Hohndel
In commit b8d31d8534b ("Show ceilings for individual tissues") Robert inadvertently broke the connection from dc_ceilings to red_ceilings and also didn't correctly enable the checkbox for all_tissues when calc_ceilings was already set in the preferences before the dialog was created (and therefore the connection in the .ui file isn't run). There's also a simplification / cleanup to the code deciding whether to show all the tissues. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31Show ceilings for individual tissuesGravatar Robert Helling
I think that displaying tissue loadings either as pressure or as percentages is not very intuitive but that it makes much more sense when translated to ceiling depths. This change enables just that for the 16 tissues in our calculated ceiling and visualizes this in the profile graph. There is a checkbox in the preferences to turn this on. If enabled, all tissues having non-trivial ceilings are also shown in the info box. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29Correct the ceiling preference handlingGravatar Dirk Hohndel
Added the red dc ceiling as preference option. Hooked them all up together so the sub-preferences are enabled when the master preference is set (for 3m and red ceiling). Use the options in the profile plotting functions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-29Connect preferences to the rest of the codeGravatar Dirk Hohndel
The biggest problem here was that bool has different sizes in C and C++ code. So using this in a structure shared between the two sides wasn't a smart idea. Instead I went with 'short', but that caused problems with Qt being to smart for its own good and not doing the right thing when dealing with 'boolean' settings and a short value. This may be something in the way I implemented things (as I doubt that something this fundamental would be broken) but the workaround implemented here (explicitly using 0 or 1 depending on the value of the boolean) seems to work. I also decided to get rid of the confusion of where gflow/gfhigh are floating point (0..1) and when they are integers (0..100). We now use integers anywhere outside of deco.c. I also applied some serious spelling corrections to the preferences dialog's ui file. Finally, this enables the code that selects which partial pressure graph to show. Still to do: font size, metric/imperial logic Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-28Fix the positioning of text in the dive profileGravatar Dirk Hohndel
This had been bugging me for a while - the label texts were all not quite where I expected them to be. I think this looks much better now. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>