aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profilegraphics.cpp
AgeCommit message (Collapse)Author
2013-11-16Fix showing the tooltips on the profile.Gravatar Tomaz Canabrava
We incorrectly mapped the profile's widget tooltip based on the global screen coordinates. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-16Fix a crash with trying to show the tooltip on the profile.Gravatar Tomaz Canabrava
Fixed a crash with trying to show the tooltip on the profile, with an empty profile. Since the widgets are not created yet, we got a crash trying to access the toolBarProxy. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15Make tooltips work in the profile toolbarGravatar Taiane Ramos
This patch enables tooltips on the profile toolbar. Tooltips were being treated as text to be shown at notification area. Now it is verified if the cursor was positioned over the toolbar when it activated the event. If so, tooltip is shown normally. Fixes #238 Signed-off-by: exhora <exhora.tat@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-07Don't translate the fake DC modelsGravatar Dirk Hohndel
Since the model name is written into the XML file it has to be a literal string that isn't translated. Otherwise a datafile written in one locale behaves differently when opened by Subsurface under a different locale. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-01Added a new option to edit the dives.Gravatar Tomaz Canabrava
Added a new option to edit the dive in the profile view. The option will only be visible if the dive was manually entered or if the dive is a plan. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
2013-10-17Move sac-calculation to profile.cGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15Fixed the moving around of the InfoPanel on non KDE enviroments.Gravatar Tomaz Canabrava
This patch restores the ability to move the info-overlay panel on the profile. For some reason the eventFilter wasn't working (and actually, looking at the code, it really shouldn't, because I didn't see where I set it to work, maybe someone (me) broke it a long time ago) well, it seems fixed now at least. :) Tested on XFCE, Gnome and KDE, with three different window managers. [Dirk Hohndel: removed debug output] Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15profilegraphics.cpp: Use text sizes in plot_text()Gravatar Lubomir I. Ivanov
Make the active font (fnt) use the 'size' member of the received text_render_options_t. This allows changing the size of certain text elements. For the moment most text elements are set to 12px. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-14Fix the DC ceiling in the profile.Gravatar Patrick Valsecchi
entry->ndl is computed and therefore should not be used for showing the DC's ceiling. That made the DC ceiling jump to 0m when the computed celing was at 0. Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-11Remove unused arg in plot_cylinder_pressureGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-11Good deal of whitespace fixes and code cleanup.Gravatar Tomaz Canabrava
I just went thru all of subsurface code removing some whitespaces issues and trying to make the code prettyer, I also removed a few QString issues.d Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-09Fix potential uninitialized variableGravatar Dirk Hohndel
Most of the "possibly unitialized" warnings are bogus, but this one is a potential real bug. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-07Compile without depending on the global MAX macroGravatar Thiago Macieira
There's a C++ way for it. And, for some reason, it wasn't defined on my MinGW build: qt-ui/profilegraphics.cpp:1006:57: error: 'MAX' was not declared in this sscope Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>