mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: access profile data directly
The profile was using a Qt-model to access its data. This means routing everything through Qt's QVariants and lead to verbose code such as double prev_y = dataModel.index(i-1, vDataColumn).data().toReal(); Instead of storing a data-column and do access via a template, simply store accessor functions. The code from above now reads as double prev_y = accessor(data[i-1]); This should also be distinctly faster for the ns-optimizers among us. Only one case was somewhat nasty to convert: The accessors for the 16 tissues are now generated via a recursive template. Thanks to C++17's constexpr if, such a template is pleasantly easy to follow, though. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
11913e614c
commit
6f2965c5af
4 changed files with 112 additions and 63 deletions
|
@ -54,9 +54,11 @@ public:
|
|||
const struct dive *d;
|
||||
int dc;
|
||||
private:
|
||||
template<typename T, class... Args> T *createItem(const DiveCartesianAxis &vAxis, int vColumn, int z, Args&&... args);
|
||||
PartialPressureGasItem *createPPGas(int column, color_index_t color, color_index_t colorAlert,
|
||||
using DataAccessor = double (*)(const plot_data &data);
|
||||
template<typename T, class... Args> T *createItem(const DiveCartesianAxis &vAxis, DataAccessor accessor, int z, Args&&... args);
|
||||
PartialPressureGasItem *createPPGas(DataAccessor accessor, color_index_t color, color_index_t colorAlert,
|
||||
const double *thresholdSettingsMin, const double *thresholdSettingsMax);
|
||||
template <int ACT, int MAX> void addTissueItems(double dpr);
|
||||
void updateVisibility(bool diveHasHeartBeat, bool simplified); // Update visibility of non-interactive chart features according to preferences
|
||||
void updateAxes(bool diveHasHeartBeat, bool simplified); // Update axes according to preferences
|
||||
|
||||
|
@ -94,7 +96,7 @@ private:
|
|||
PartialPressureGasItem *ocpo2GasItem;
|
||||
DiveCalculatedCeiling *diveCeiling;
|
||||
DiveTextItem *decoModelParameters;
|
||||
QList<DiveCalculatedTissue *> allTissues;
|
||||
std::vector<DiveCalculatedTissue *> allTissues;
|
||||
DiveHeartrateItem *heartBeatItem;
|
||||
DivePercentageItem *percentageItem;
|
||||
TankItem *tankItem;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue