mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: move total_weight() into struct dive
Feels natural in a C++ code base. Change the function to return a weight_t. Sadly, use of the units.h types is very inconsistent and many parts of the code use int or double instead. So let's try to make this consistent. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
df1affc25b
commit
d36fd79527
9 changed files with 22 additions and 34 deletions
|
@ -1297,8 +1297,8 @@ struct WeightBinner : public IntRangeBinner<WeightBinner, IntBin> {
|
|||
return get_weight_unit(metric);
|
||||
}
|
||||
int to_bin_value(const dive *d) const {
|
||||
return metric ? total_weight(d) / 1000 / bin_size
|
||||
: lrint(grams_to_lbs(total_weight(d))) / bin_size;
|
||||
return metric ? d->total_weight().grams / 1000 / bin_size
|
||||
: lrint(grams_to_lbs(d->total_weight().grams)) / bin_size;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1328,8 +1328,8 @@ struct WeightVariable : public StatsVariableTemplate<StatsVariable::Type::Numeri
|
|||
return { &weight_binner_2lbs, &weight_binner_5lbs, &weight_binner_10lbs, &weight_binner_20lbs };
|
||||
}
|
||||
double toFloat(const dive *d) const override {
|
||||
return prefs.units.weight == units::KG ? total_weight(d) / 1000.0
|
||||
: grams_to_lbs(total_weight(d));
|
||||
return prefs.units.weight == units::KG ? d->total_weight().grams / 1000.0
|
||||
: grams_to_lbs(d->total_weight().grams);
|
||||
}
|
||||
std::vector<StatsOperation> supportedOperations() const override {
|
||||
return { StatsOperation::Median, StatsOperation::Mean, StatsOperation::Sum, StatsOperation::Min, StatsOperation::Max };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue