Exemplo n.º 1
0
    virtual void draw(QPainter *painter,
              const QwtScaleMap &xMap, const QwtScaleMap &,
              const QRect &rect) const
    {
    RideItem *rideItem = parent->rideItem;

    if (! rideItem)
        return;

    const HrZones *zones       = parent->mainWindow->hrZones();
    int zone_range     = rideItem->hrZoneRange();

    if (parent->shadeHRZones() && (zone_range >= 0)) {
        QList <int> zone_lows = zones->getZoneLows(zone_range);
        int num_zones = zone_lows.size();
        if (num_zones > 0) {
        for (int z = 0; z < num_zones; z ++) {
            QRect r = rect;

            QColor shading_color =
            hrZoneColor(z, num_zones);
            shading_color.setHsv(
                     shading_color.hue(),
                     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]));
            if (r.right() >= r.left())
            painter->fillRect(r, shading_color);
        }
        }
    }
    }
Exemplo n.º 2
0
    HrHistZoneLabel(PowerHist *_parent, int _zone_number)
    {
    parent = _parent;
    zone_number = _zone_number;

    RideItem *rideItem = parent->rideItem;

    if (! rideItem)
        return;

    const HrZones *zones       = parent->mainWindow->hrZones();
    int zone_range     = rideItem->hrZoneRange();

    setZ(1.0 + zone_number / 100.0);

    // create new zone labels if we're shading
    if (parent->shadeHRZones() && (zone_range >= 0)) {
        QList <int> zone_lows = zones->getZoneLows(zone_range);
        QList <QString> zone_names = zones->getZoneNames(zone_range);
        int num_zones = zone_lows.size();
        assert(zone_names.size() == num_zones);
        if (zone_number < num_zones) {
        watts =
            (
             (zone_number + 1 < num_zones) ?
             0.5 * (zone_lows[zone_number] + zone_lows[zone_number + 1]) :
             (
              (zone_number > 0) ?
              (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));
        QColor text_color = hrZoneColor(zone_number, num_zones);
        text_color.setAlpha(64);
        text.setColor(text_color);
        }
    }

    }