当前位置: 首页>>代码示例>>C++>>正文


C++ Stat::add方法代码示例

本文整理汇总了C++中Stat::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Stat::add方法的具体用法?C++ Stat::add怎么用?C++ Stat::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stat的用法示例。


在下文中一共展示了Stat::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read

 virtual bool read(ConnectionReader& connection) {
     double now = Time::now();
     Bottle b;
     bool ok = b.read(connection);
     if (ok) {
         mutex.wait();
         ct++;
         if (ct>1) {
             double dt = now - lastTime;
             period.add(dt);
         }
         lastTime = now;
         printf("Period is %g +/- %g (%d)\n",
                period.mean(),
                period.deviation(),
                ct);
         mutex.post();
     }
     return ok;
 }
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:20,代码来源:Ping.cpp

示例2: paintEvent

void Graph::paintEvent(QPaintEvent *e)
{
    VtlWidget::paintEvent(e);
    QPainter p(this);
    Interval iv = currentInterval();

    p.setTransform(wtr);

    if(!noScale)
    {
        p.setPen(cText);
        QRect rs(0, topScale ? h:-lh, w, lh);
        p.fillRect(rs, cScale);
        drawTextEx(p, rs, Qt::AlignLeft|Qt::AlignVCenter,
            QDateTime::fromTime_t(iv.t1).toString(timeFormat), reverse, 1);
        drawTextEx(p, rs, Qt::AlignRight|Qt::AlignVCenter,
            QDateTime::fromTime_t(iv.t2).toString(timeFormat), reverse, 1);
    }

    p.fillRect(0, 0, w, h, cBack);

    p.setPen(cGrid);
    for(int i = 0; i <= nTimeLines; i++) { int x = i*w/nTimeLines; p.drawLine(x, 0, x, h); }
    for(int i = 0; i <= nValLines; i++) { int y = i*h/nValLines; p.drawLine(0, y, w, y); }

    int scaleX = w + sh + 1;
    int *curScaleWidth = scaleWidth.begin();
    QRect rScales(scaleX, 0, scalesWidth, h);
    p.fillRect(rScales, cScale);

    p.setClipRect(QRectF(-1, -1, w + 2 + sh, h + 2));

    for(QList<Plot>::iterator plot = plots.begin(); plot != plots.end(); ++plot)
    {
        if(!plot->sourcer()) continue;
        const RingBuf<Stat> &st = stats[plot->sourcer()];
        Stat total;
        for(RingBuf<Stat>::citerator s = st.begin(); s != st.end(); ++s) total.add(*s);
        //int pc = plot->precission();
        float s1 = plot->minScale(), s2 = plot->maxScale(), ds = s2 - s1;
        if(plot->autoScale())
        {
            float as1 = total.min, as2 = total.max, ads = as2 - as1;
            if(ads)
            {
                ds *= 0.01f*plot->autoScalePercent();
                if(ads < ds)
                {
                    float as = 0.5*(as1 + as2), k = ds/ads;
                    as1 = as + k*(as1 - as);
                    as2 = as + k*(as2 - as);
                }
                //float t = pow(10, pc - 2);
                s1 = qMax(s1, floorf(/*t*/as1)/*t*/);
                s2 = qMin(s2, ceilf(/*t*/as2)/*t*/);
                ds = s2 - s1;
            }
        }
        if(ds) switch(md)
        {
        case Average:
            {
                QVector<QPointF> points;
                int x = 0;
                float y = NAN;
                p.setPen(plot->color);
                for(RingBuf<Stat>::citerator s = st.begin(); s != st.end(); ++s, ++x)
                {
                    if(s->n)
                    {
                        if(y == y) points << QPointF(x, y); else points.clear();
                        y = (h - 1)*(s->sum/s->n - s1)/ds;
                        points << QPointF(x, y);
                    }
                    else if(s != st.end() - 1)
                    {
                        p.drawPolyline(points);
                        y = NAN;
                    }
                }
                if(plot->sourcer()->getReliability() == 1)
                {
                    y = (h - 1)*(plot->sourcer()->value() - s1)/ds;
                    points << QPointF(w, y);
                    p.setBrush(plot->color);
                    p.drawPolygon(QPolygonF() << QPointF(w, y) <<
                        QPointF(w + sh, y + 2) << QPointF(w + sh, y - 2));
                }
                p.drawPolyline(points);
            }
            break;
        case MinMax:
            {
                QVector<QPointF> lines;
                int x = 0;
                float y1 = NAN, y2 = NAN;
                p.setPen(plot->color);
                for(RingBuf<Stat>::citerator s = st.begin(); s != st.end(); ++s, ++x)
                {
                    if(s->n)
//.........这里部分代码省略.........
开发者ID:obrpasha,项目名称:votlis_krizh_gaz_nas,代码行数:101,代码来源:graph.cpp


注:本文中的Stat::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。