static void
fill_arc(DiaRenderer *self, 
         Point *center,
         real width, real height,
         real angle1, real angle2,
         Color *color)
{
  _arc (self, center, width, height, angle1, angle2, color, TRUE);
}
Exemple #2
0
        void Dial::paintEvent(QPaintEvent *e)
        {
            auto && _rect = rect();
            QPointF _center = _rect.center();

            double   _r = radius() - radius() / 50.0;
            QPainter _p(this);
            _p.setRenderHint(QPainter::Antialiasing);
            _p.setBrush(colorSet().button());
            _p.setPen(hasFocus() ? QPen(colorSet().dark(),
                                        radius() / 50.0) : Qt::NoPen);

            _p.drawEllipse(_center, _r, _r);

            QPainterPath _ellipsePath, _piePath;
            _ellipsePath.addEllipse(_center, _r,        _r);
            _ellipsePath.addEllipse(_center, _r * 0.75, _r * 0.75);
            auto && _pieRect = _ellipsePath.boundingRect().adjusted(-2, -2, 2, 2);

            _p.setBrush(
                hasFocus() ?
                colorSet().highlight() :
                colorSet().dark());

            QPainterPath _arc(_center);
            _arc.arcTo(_pieRect, -90, -ratio() * 360);
            _arc.lineTo(_center);
            _arc.closeSubpath();

            _piePath = _arc & _ellipsePath;
            _p.drawPath(_piePath);

            if (showTicks())
            {
                mixin_range_type::for_each_step([&](int _step, double i,
                                                    bool _isPage)
                {
                    _p.setPen(QPen(i >= mixin_range_type::value() ?
                                   colorSet().shadow() :
                                   colorSet().windowText(), 1));
                    paintTick(_p, i, _isPage ? 0.25 : 0.125);
                });
            }

            _p.setPen(QPen(colorSet().shadow(), _r / 50.0));
            paintTick(_p, mixin_range_type::value(), 0.333);
            paintTick(_p, 0.0,                       0.25);


            // Draw big letter in the middle
            _p.setPen(QPen(QColor("#3d3d3d"), 2));
            QFont _font = font();
            _font.setPixelSize(_r);
            _p.setFont(_font);
            _p.drawText(_rect, Qt::AlignCenter, letter_);
        }