aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget/diveprofileitem.h
AgeCommit message (Collapse)Author
2021-01-10profile: pass dive to plot function of profile-itemsGravatar Berthold Stoeger
Instead of accessing the global displayed_dive variable, pass the dive to the various profile items. This is a step in making the profile code reentrant. This removes the last user of the displayed_dc macro, which can now be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: remove DiveProfileItem::settingsToggledGravatar Berthold Stoeger
This was used to force a replot on preferences changes. However, the profile now does a replot in such a case by itself. This can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: move calculations out of DiveGasPressureItem::paint()Gravatar Berthold Stoeger
With the same argument as for DivePercentageItem, move access to live data out of the paint() function. Instead, calculate colors in replot(), where the other data are calculated. This is slightly more complicated than in DivePercentageItem, since there are multiple polygons. Therefore, replace QPolygonF by a vector of structures contained the position and color of the data point. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: move calculations out of DivePercentageItem::paint()Gravatar Berthold Stoeger
The DivePercentageItem is a polygon-item with a custom paint() method. Calculation of the polygon is done once in replot(), but calculation of the corresponding colors is done in every paint() call. The problem is, we have no control over paint(). It is called whenever Qt feels like. Therefore using live dive data is a dangerous proposition if we ever want to get rid of the global displayed_dive. Do all the calculations in replot(). Store the colors in an additional array of the same size as the polygon. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: remove AbstractProfilePolygonItem::modelDataChanged()Gravatar Berthold Stoeger
The old mechanism to replot the profile items was to listen to model-change signals. Then the code checked whether it actually had to update anything by looking at the changed model-indices. However, the crucial replot was always initialized with emitDataChanged(), which simple invalidated the full model and therefore shouldCalculateStuff() always returned true. Since now the replot() is called explicitly, remove the whole logic and simply rename modelDataChanged() to replot(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: explicitly clear profile itemsGravatar Berthold Stoeger
In contrast to most other items, which are cleared in the setEmptyState() function, the profile items are cleared indirectly via a signal from the model. Very hard to follow and indeed, I thought I could just remove the slot. Do this explicitly instead for deterministic code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: remove AbstractProfilePolygonItem::settingsChanged()Gravatar Berthold Stoeger
settingsChanged() is a virtual function, which is called when the preferences dialog signals changes. In most derived classes, the function does nothing. In two classes, DiveProfileItem and DiveCalculatedTissue, it replots the item respectively changes its visibility. However, these two flags are *not* controlled by the preferences dialog. Indeed, the functions are also connected to finer-grained qPref signals. Therefore, settingsChanged() can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: initialize axis of DiveProfileItems on constructionGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: set model of profile items on constructionGravatar Berthold Stoeger
The profile items had a "setModel()" function to set the DivePlotDataModel post creation. The model is never changed. It does however mean that the model might be null in a short period between construction and setting the model. To simplify reasoning about this code, set the model in the constructor. To drive the point home that the can never change and cannot be null, turn it into a reference. Yes, this is gratuitous bike-shedding, but it helps me analysis the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: remove redundant code in DiveCalculatedCeilingGravatar Berthold Stoeger
The DiveCalculatedCeiling profile-item has a recalc() function, which calls "dataModel->calculateDecompression()". This is a questionable reversal of control-flow: The profile-item should paint the model-data not change it. The code was supposed to be called under two conditions: 1) The value of the calcceiling3m preferences flag changed. This code was buggy for two reasons: Firstly, the cached value was always initialized to false, which means that sometimes the first call was missed. Secondly, the settingsChanged() functions was only called when closing the preferences window, not when changing the flag in the profile widgets. 2) The datetime of the dive changed. The whole control-flow is pretty absurd (due to "bit rot"): - The replan-dive command sends a date-time changed signal. - The main tab changes the date-time and informs the profile. - The profile sends a signal to the item. - The item instructs the model to recalculate the decompression. - The model causes the profile to be redrawn. In any case, the whole thing is moot, because the decompression is recalculated for *every* profile plot in create_plot_info_new(). Let's remove the code from the DiveCalculatedCeiling profile-item and the calculateDecompression() function, which is now not used anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13cleanup: turn protected into private membersGravatar Berthold Stoeger
Some profilewidget classes hat protected members which can be made private as there is no subclassing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-29Cleanup: reinstate override modifiersGravatar Berthold Stoeger
This reverts commit 1c4a859c8d0b37b2e938209fe9c4d99e9758327a, where the override modifiers were removed owing to the noisy "inconsistent override modifiers" which is default-on in clang. This warning was disabled in 77577f717f5aad38ea8c4c41c10c181486c4337f, so we can reinstate the overrides. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-07Cleanup: constify threshold pointers in DiveProfileItemGravatar Berthold Stoeger
These were pointers into the global prefs object. The user must not use these to modify the settings, therefore make them pointers-to-const. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-01Cleanup: remove all override modifiersGravatar Berthold Stoeger
Commit df156a56c08a56eb380711a507ef739d8150a71f replaced "virtual" by "override" where appropriate. Unfortunately, this had the unintended consequence of producing numerous clang warnings. If clang finds a override-modified function in a class definition, it warns for *all* overriden virtual functions without the override modifier. To solve this, go the easy route and remove all overrides. At least it is consistent. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-31Cleanup: replace virtual by override where appropriateGravatar Berthold Stoeger
The keyword "virtual" signalizes that the function is virtual, i.e. the function of the derived class is called, even if the call is on the parent class. It is not necessary to repeat the "virtual" keyword in derived classes. To highlight derived virtual functions, the keyword "override" should be used instead. It results in a hard compile- error, if no function is overridden, thus avoiding subtle bugs. Replace "virtual" by "override" where appropriate. Moreover, replace Q_DECL_OVERRIDE by override, since we require reasonably recent compilers anyway. Likewise, replace /* reimp */ by "override" for consistency and compiler support. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Typo: Threshould -> ThresholdGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-04-29Add SPDX header to profile widgetsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-28minimal pO2 threshold: color the p02 graph also for minumumGravatar Jan Mulder
Color the p02 graph also in red for going under the minumum p02 value as set in the Preferences. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2016-10-20Heatmap: Color undersaturated values relative to inert gas pressureGravatar Rick Walsh
Color "undersaturated" values relative to inert gas pressure of gas being breathed, rather than relative to inert gas pressure of air. Also change slightly the point at which bright green (hue = 120 deg) from 10% of M value to 0% of M value (=ambient pressure). Other than the slight shift in lower bound of the green-red scale, this does not affect the colors of the tissues with inert gas pressure greater than ambient pressure, which are relative to the Buhlmann M value. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-24Hook up the code to toggle DC reported ceiling visibilityGravatar Dirk Hohndel
This got broken a long time ago it seems and no one ever noticed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-17Separate method for heatmap color scalingGravatar Robert C. Helling
I separated out the color scaling and slightly simplified the expressions. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-17Introduce heat mapGravatar Robert C. Helling
This replaces the tissue percentage graph that probably nobody ever understood with a heat map like the one used in the discussion of bubble model deco. The information shown is the same but the saturation is now in the color while the tissue determines the y position. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25Fix Ceiling GraphGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25More Profile Itens on the new SettingsGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25Changed quite a few shorts to bool on the c++ implementtionGravatar Tomaz Canabrava
The shorts where being used on the preferences since a long while and we cannot just simply change them to bool since this could break the preferences files, so work around that by changing them to booleans, since it's the correct type for a true / false answer. Also, move some plot curves to the new settings style Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-06Untangle DiveCalculatedCeiling from MainWindowGravatar Lubomir I. Ivanov
DiveCalculatedCeiling is the last class the references MainWindow in the profile-widget stack. In modelDataChanged() it looks for the information() widget and sets a slot for the dateTimeChanged() signal that information() emits. To solve the issue we make DiveCalculatedCeiling recieve a ProfileWidget2 reference and make ProfileWidget2 emit the dateTimeChangedItems() signal. ProfileWidget2 itself listens for the dateTimeChanged() signal that information() emits and emits dateTimeChangedItems() to notify any possible children/item listeners in the ProfileWidget2::dateTimeChanged() slot. The connection between ProfileWidget2 and information() is set in MainWindow. This makes DiveCalculatedCeiling unaware of MainWindow and which class originally emits the dateTimeChanged() signal to ProfileWidget2. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> -- Think delegation. Tomaz, please take a look at this one, to double check if i messed up. also i have zero idea how the mobile app is setting these connections, if it does so even. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-30Move Profile widget out of desktop-widgetsGravatar Tomaz Canabrava
The reason for that is, even if profile widget is made with qpainter and for that reason it should be a desktop widget, it's being used on the mobile version because of a lack of QML plotting library that is fast and reliable. We discovered that it was faster just to encapsulate our Profile in a QML class and call it directly. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>