Add shaded power zones for watt per kilogram series in histogram

This commit is contained in:
Damien
2012-12-02 23:05:35 +01:00
parent 28faf74884
commit eaa84772fc
2 changed files with 26 additions and 8 deletions

View File

@@ -211,7 +211,7 @@ PowerHist::refreshZoneLabels()
if (!rideItem) return;
if (series == RideFile::watts) {
if (series == RideFile::watts || series == RideFile::wattsKg) {
const Zones *zones = rideItem->zones;
int zone_range = rideItem->zoneRange();
@@ -964,7 +964,7 @@ PowerHist::setSeries(RideFile::SeriesType x) {
bool PowerHist::shadeZones() const
{
return (rideItem && rideItem->ride() && series == RideFile::watts && !zoned && shade == true);
return (rideItem && rideItem->ride() && (series == RideFile::watts || series == RideFile::wattsKg) && !zoned && shade == true);
}
bool PowerHist::shadeHRZones() const

View File

@@ -262,9 +262,21 @@ public:
shading_color.saturation() / 4,
shading_color.value()
);
r.setLeft(xMap.transform(zone_lows[z]));
if (z + 1 < num_zones)
r.setRight(xMap.transform(zone_lows[z + 1]));
double wattsLeft = zone_lows[z];
if (parent->series == RideFile::wattsKg) {
wattsLeft = wattsLeft / rideItem->ride()->getWeight();
}
r.setLeft(xMap.transform(wattsLeft));
if (z + 1 < num_zones) {
double wattsRight = zone_lows[z + 1];
if (parent->series == RideFile::wattsKg) {
wattsRight = wattsRight / rideItem->ride()->getWeight();
}
r.setRight(xMap.transform(wattsRight));
}
if (r.right() >= r.left())
painter->fillRect(r, shading_color);
}
@@ -316,7 +328,7 @@ public:
(1.5 * zone_lows[zone_number] - 0.5 * zone_lows[zone_number - 1]) :
2.0 * zone_lows[zone_number]
)
);
);
text = QwtText(zone_names[zone_number]);
text.setFont(QFont("Helvetica",24, QFont::Bold));
@@ -337,8 +349,14 @@ public:
const QwtScaleMap &xMap, const QwtScaleMap &,
const QRectF &rect) const
{
if (parent->shadeZones()) {
int x = xMap.transform(watts);
RideItem *rideItem = parent->rideItem;
if (parent->shadeZones()) {
double position = watts;
if (parent->series == RideFile::wattsKg) {
position = watts / rideItem->ride()->getWeight();
}
int x = xMap.transform(position);
int y = (rect.bottom() + rect.top()) / 2;
// the following code based on source for QwtPlotMarker::draw()