Пример #1
0
void NOR_component::PaintComp(QPainter &p){
    if(!ref.isNull())
    {
        QPoint lStart(ref.x()+20,ref.y());
        QPoint lEnd(ref.x()+20,ref.y()+80);
        QPoint centar(ref.x()+75,ref.y()+40);
        //unutrasnji luk
        p.drawArc(lStart.x()-20,lStart.y(),40,80,-90*16, 180*16);

        //produzeci zbog estetike
        p.drawLine(lStart.x(),lStart.y(),lStart.x()+20,lStart.y());
        p.drawLine(lStart.x(),lStart.y()+80,lStart.x()+20,lStart.y()+80);

        //spoljasnji krug
        p.drawArc(lStart.x()-10,lStart.y(),60,80,-90*16, 180*16);

        //pinovi
        p.drawLine(ref.x(),ref.y()+30,ref.x()+38,ref.y()+30);
        p.drawLine(ref.x(),ref.y()+50,ref.x()+38,ref.y()+50);
        p.drawLine(ref.x()+80,ref.y()+40,ref.x()+90,ref.y()+40);

        //kruzic za not
        p.drawEllipse(centar,5,5);
    }
}
Пример #2
0
void SLErrorWidget::paintEvent(QPaintEvent *) {
  QPainter paint (this);
  double ww = QWidget::width();
  double wh = QWidget::height()-30;
  double scale_x = ww/static_cast<double>(width);
  double scale_y = wh/static_cast<double>(height);
  scale = (scale_x<scale_y ? scale_x : scale_y);
  offset_x = 0.5*(ww-scale*width);
  offset_y = 0.5*(wh-scale*height);
  if (own_half>0)
    paint.setWorldMatrix (QMatrix (scale, 0, 0, scale, offset_x, offset_y));
  else
    paint.setWorldMatrix (QMatrix (-scale, 0, 0, -scale, ww-offset_x, wh-offset_y));


  for (unsigned int i=0; i<width; i++)
    for (unsigned int j=0; j<height; j++) {
      unsigned int g=error_array[i][j];
      paint.setPen (QColor (g,g,g));
      paint.fillRect (i,j,2,2, QBrush (QColor (g,g,g), Qt::SolidPattern));
    }
  paint.setPen (QPen(Qt::blue,2));
  paint.drawArc (best_i-1, best_j-1, 3, 3, 0, 5760);  // beste Position einzeichnen
  if (ci) {
    paint.setPen (QPen(Qt::cyan,2));
    if (ci->rloc_vis.size()>0) {
      Tribots::Vec cur = field2widget (ci->rloc_vis[0].pos);
      paint.drawArc (static_cast<int>(cur.x)-1, static_cast<int>(cur.y)-1, 3, 3, 0, 5760);  // aktuelle Position zeichnen

      paint.setPen (QPen(Qt::magenta,2));
      cur = field2widget (optimising_pos);
      paint.drawArc (static_cast<int>(cur.x)-1, static_cast<int>(cur.y)-1, 3, 3, 0, 5760);  // optimierte Position zeichnen
    }
  }
}
Пример #3
0
void draw_pointer(int x, int y, QPainter & painter)
{
    painter.setPen(Qt::black);
    painter.drawArc(x - POINTER_SIZE / 2, y - POINTER_SIZE / 2, 
                    POINTER_SIZE, POINTER_SIZE, 0, 16 * 360);
    painter.setPen(Qt::white);
    painter.drawArc(x - POINTER_SIZE2 / 2, y - POINTER_SIZE2 / 2, 
                    POINTER_SIZE2, POINTER_SIZE2, 0, 16 * 360);
}
Пример #4
0
/*!

 */
void
FieldPainter::drawPenaltyAreaLines( QPainter & painter ) const
{
    const Options & opt = Options::instance();

    // set gdi objects
    painter.setPen( M_line_pen );
    painter.setBrush( Qt::NoBrush );

    // set screen coordinates of field
    int left_x   = opt.screenX( - Options::PITCH_HALF_LENGTH );
    int right_x  = opt.screenX( + Options::PITCH_HALF_LENGTH );

    // set penalty area params
    int pen_top_y    = opt.screenY( - Options::PENALTY_AREA_WIDTH*0.5 );
    int pen_bottom_y = opt.screenY( + Options::PENALTY_AREA_WIDTH*0.5 );
    double pen_circle_y_degree_abs
        = std::acos( ( Options::PENALTY_AREA_LENGTH - Options::PENALTY_SPOT_DIST )
                     / Options::PENALTY_CIRCLE_R )
        * ( 180.0 / M_PI );
    int span_angle = qRound( pen_circle_y_degree_abs * 2.0 * 16 );
    int pen_circle_r = opt.scale( Options::PENALTY_CIRCLE_R );
    int pen_circle_size = opt.scale( Options::PENALTY_CIRCLE_R * 2.0 );

    // left penalty area X
    int pen_x = opt.screenX( -( Options::PITCH_HALF_LENGTH - Options::PENALTY_AREA_LENGTH ) );
    // left arc
    int pen_spot_x = opt.screenX( -( Options::PITCH_HALF_LENGTH - Options::PENALTY_SPOT_DIST ) );
    painter.drawArc( pen_spot_x - pen_circle_r + 1,
                     opt.fieldCenter().y() - pen_circle_r,
                     pen_circle_size,
                     pen_circle_size,
                     qRound( -pen_circle_y_degree_abs * 16 ),
                     span_angle );
    // left rectangle
    painter.drawLine( left_x, pen_top_y, pen_x, pen_top_y );
    painter.drawLine( pen_x, pen_top_y, pen_x, pen_bottom_y );
    painter.drawLine( pen_x, pen_bottom_y, left_x, pen_bottom_y );
    // left spot
    painter.drawPoint( pen_spot_x, opt.fieldCenter().y() );

    // right penalty area X
    pen_x = opt.screenX( +( Options::PITCH_HALF_LENGTH - Options::PENALTY_AREA_LENGTH ) );
    // right arc
    pen_spot_x = opt.screenX( +( Options::PITCH_HALF_LENGTH - Options::PENALTY_SPOT_DIST ) );
    painter.drawArc( pen_spot_x - pen_circle_r,
                     opt.fieldCenter().y() - pen_circle_r,
                     pen_circle_size, pen_circle_size,
                     qRound( ( 180.0 - pen_circle_y_degree_abs + 0.5 ) * 16 ),
                     span_angle );
    // right rectangle
    painter.drawLine( right_x, pen_top_y, pen_x, pen_top_y );
    painter.drawLine( pen_x, pen_top_y, pen_x, pen_bottom_y );
    painter.drawLine( pen_x, pen_bottom_y, right_x, pen_bottom_y );
    // right spot
    painter.drawPoint( pen_spot_x, opt.fieldCenter().y() );
}
Пример #5
0
void GEVor::draw(QPainter& painter)
{
    painter.save();

    painter.setPen(QPen(m_active_color));
    
    QPointF center_xy;
    MYASSERT(m_projection->convertLatLonToXY(m_vor->getLatLon(), center_xy));
    painter.translate(center_xy.x(), center_xy.y());

    // outer circle
    QRectF rect(-VOR_OUTER_RADIUS, -VOR_OUTER_RADIUS, 2*VOR_OUTER_RADIUS, 2*VOR_OUTER_RADIUS);
    painter.drawArc(rect, 0, FULL_ARC);

    // middle circle
    rect = QRectF(-VOR_MIDDLE_RADIUS, -VOR_MIDDLE_RADIUS, 2*VOR_MIDDLE_RADIUS, 2*VOR_MIDDLE_RADIUS);
    painter.drawArc(rect, 0, FULL_ARC);

    // inner circle
    rect = QRectF(-VOR_INNER_RADIUS, -VOR_INNER_RADIUS, 2*VOR_INNER_RADIUS, 2*VOR_INNER_RADIUS);
    painter.drawArc(rect, 0, FULL_ARC);

    // crown lines
    painter.save();
    QLineF line(0, VOR_MIDDLE_RADIUS, 0, VOR_OUTER_RADIUS);
    int max_rotation = 12;
    for(int rotation = 0; rotation<max_rotation; ++rotation)
    {
        painter.rotate(360/(double)max_rotation);
        painter.drawLine(line);
    }
    painter.restore();

    // text


//     double text_dist = 30;
//     double text_angle = -135.0;

//     painter.rotate(text_angle);
//     painter.translate(0, -text_dist);
//     line = QLineF(0,0, 0, text_dist-VOR_OUTER_RADIUS);
//     painter.drawLine(line);
//     painter.rotate(-text_angle);

//     QRect text_bounding_rect = 
//         painter.boundingRect(QRect(0, 0, 500, 500), Qt::AlignLeft | Qt::AlignTop, text);

//     QRectF text_rect = QRectF(-text_bounding_rect.width(), 0,
//                               text_bounding_rect.width(), text_bounding_rect.height());

//     painter.drawRect(text_rect);
//     painter.drawText(text_rect, text);

    painter.restore();
}
Пример #6
0
void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, bool hover, bool inc)
{
    p.setRenderHint(QPainter::Antialiasing, true);
    p.setPen(dialColor);
    p.setBrush(dialColor);

    int dialStartAngle = 225 * 16;
    int dialSpanAngle = -270 * 16;

    // draw dial arc
    p.drawArc(dialRect, dialStartAngle, dialSpanAngle);
    // draw ticks
    p.save();
    p.translate(dialRect.center());
    p.rotate(45);
    for (uint64_t i = 0; i < _div; i++) {
        // draw major ticks
        p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+8);
        // draw minor ticks
        for (uint64_t j = 0; (j < 5) && (i < _div - 1); j++) {
            p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+5);
            p.rotate(54.0/(_div-1));
        }
    }
    // draw pointer
    p.rotate(90+270.0/(_div-1)*_sel);
    p.drawEllipse(-3, -3, 6, 6);
    p.drawLine(3, 0, 0, dialRect.width()/2-3);
    p.drawLine(-3, 0, 0, dialRect.width()/2-3);
    p.restore();
    // draw value
    uint64_t displayValue = _value[_sel]*_factor;
    uint64_t displayIndex = 0;
    while(displayValue / _step >= 1) {
        displayValue = displayValue / _step;
        displayIndex++;
    }
    QString pText = QString::number(displayValue) + _unit[displayIndex] + "/div";
    QFontMetrics fm(p.font());
    const QRectF valueRect = QRectF(dialRect.left(), dialRect.bottom()-dialRect.width()*0.3+fm.height()*0.5, dialRect.width(), fm.height());
    p.drawText(valueRect, Qt::AlignCenter, pText);

    // draw +/-
    if (hover) {
        const int arcInc = 15;
        const QRectF hoverRect = QRectF(dialRect.left()-arcInc, dialRect.top()-arcInc, dialRect.width()+arcInc*2, dialRect.height()+arcInc*2);
        const double arcSpan = hoverRect.width()/(2*sqrt(2));
        p.drawArc(hoverRect, 135 * 16, -90 * 16);
        if (inc)
            p.drawLine(hoverRect.center().x()+arcSpan, hoverRect.center().y()-arcSpan,
                       hoverRect.center().x()+arcSpan-4, hoverRect.center().y()-arcSpan-10);
        else
            p.drawLine(hoverRect.center().x()-arcSpan, hoverRect.center().y()-arcSpan,
                       hoverRect.center().x()-arcSpan+4, hoverRect.center().y()-arcSpan-10);
    }
}
Пример #7
0
void graphics::ThaiCucQuyen(QPainter& painter)
{
    int w=width();
    int h=height();
    QPoint a(w/2,h/2);
    painter.drawEllipse(a,200,200);
// 2 Hinh Tron Nho
    painter.drawEllipse(w/2-120,h/2,30,30);
    painter.drawEllipse(w/2+100,h/2,30,30);
// 2 Can Moc
    painter.drawArc(w/2-200,h/2-100,200,200,0,16*-180);
    painter.drawArc(w/2,h/2-100,200,200,0,16*180);
}
Пример #8
0
void QRoundProgressBar::drawValue(QPainter &p, const QRectF &baseRect, double value, double arcLength)
{
    // nothing to draw
    if (value == m_min)
        return;

    // for Line style
    if (m_barStyle == StyleLine)
    {
        p.setPen(QPen(palette().highlight().color(), m_dataPenWidth));
        p.setBrush(Qt::NoBrush);
        p.drawArc(baseRect.adjusted(m_outlinePenWidth/2, m_outlinePenWidth/2, -m_outlinePenWidth/2, -m_outlinePenWidth/2),
                  m_nullPosition * 16,
                  -arcLength * 16);
        return;
    }

    // for Pie and Donut styles
    QPainterPath dataPath;
    dataPath.setFillRule(Qt::WindingFill);

    // pie segment outer
    dataPath.moveTo(baseRect.center());
    dataPath.arcTo(baseRect, m_nullPosition, -arcLength);
    dataPath.lineTo(baseRect.center());

    p.setBrush(palette().highlight());
    p.setPen(QPen(palette().shadow().color(), m_dataPenWidth));
    p.drawPath(dataPath);
}
Пример #9
0
void PicItem::drawShape( QPainter & p )
{
	int _x = int(x());
	int _y = int(y());
	
	p.setBrush( QColor( 0xef, 0xff, 0xef ) );
	p.setFont( font() );
	
	p.drawRoundRect( _x, _y, width(), height(), 2000/width(), 2000/height() );
	
	p.drawText( _x+TopPadding-2, _y, width()-TopPadding+2, TopPadding, Qt::AlignVCenter, i18n("PIC Settings") );
	
	if ( !m_bExpanded )
		return;
	
	// Draw rectangle to cut off pins
	p.setBrush( QColor( 239, 255, 255 ) );
	QRect r( _x+SidePadding, _y+TopPadding, InnerWidth, m_innerHeight );
	p.drawRect(r);
	
	// Draw dimple thingy at end of pic
	p.drawArc( r.x()+(r.width()-ArcWidth)/2, r.y()+1-ArcWidth/2, ArcWidth, ArcWidth, 180*16, 180*16 );
	
	// Draw vertical text centered in PIC
	p.translate( r.width()/2 + r.x(), r.height()/2 + r.y() );
	p.rotate(90);
	QRect textRect( r.width()/-2, r.height()/-2, r.width(), r.height() );
	p.drawText( textRect, Qt::AlignCenter, microSettings->microInfo()->id() );
	
	p.rotate(-90);
	p.translate( r.width()/-2 - r.x(), r.height()/-2 - r.y() );
}
Пример #10
0
	void FileSharingWidget::renderDataTransferProgress(QPainter &p)
	{
		assert(Metainfo_.FileSize_ >= 0);
		assert(BytesTransferred_ >= 0);
		assert(BytesTransferred_ <= Metainfo_.FileSize_);
		assert(DownloadingBarBaseAngle_ >= DOWNLOADING_BAR_BASE_ANGLE_MIN);
		assert(DownloadingBarBaseAngle_ <= DOWNLOADING_BAR_BASE_ANGLE_MAX);

		p.save();

		auto percents = 1.0;
		if (Metainfo_.FileSize_ > 0)
		{
			percents = std::max(0.05, (double)BytesTransferred_ / (double)Metainfo_.FileSize_);
		}
		assert(percents <= (1.0 + std::numeric_limits<double>::epsilon()));

		const auto angle = (int)std::ceil(percents * 360 * 16);
		assert(angle <= (361 * 16));

		const auto penWidth = Utils::scale_value(PROGRESS_PEN_WIDTH);
		QPen pen(QBrush(Qt::black), penWidth);
		p.setPen(pen);

		const auto baseAngle = (DownloadingBarBaseAngle_ * 16);
		p.drawArc(getControlButtonRect(), -baseAngle, -angle);

		p.restore();
	}
void NAND_component::PaintComp(QPainter &p)
{
    if(!ref.isNull())
    {
        if(selektovan==true){
              p.setPen(Qt::red);
        }
        else
        {
           p.setPen(Qt::black);
        }
        QPoint lStart(ref.x()+20,ref.y());
        QPoint lEnd(ref.x()+20,ref.y()+80);
        QPoint centar(ref.x()+65,ref.y()+40);

        //komponenta
        p.drawLine(lStart.x(),lStart.y(),lEnd.x(),lEnd.y());
        p.drawArc(lStart.x()-40,lStart.y(),80,80,-90*16, 180*16);
        p.drawEllipse(centar,5,5);

        //pinovi
        p.drawLine(ref.x(),ref.y()+30,ref.x()+20,ref.y()+30);
        p.drawLine(ref.x(),ref.y()+50,ref.x()+20,ref.y()+50);
        p.drawLine(ref.x()+70,ref.y()+40,ref.x()+90,ref.y()+40);
    }
}
Пример #12
0
void GEAirport::draw(QPainter& painter)
{
    painter.save();

    QPointF center_xy;
    MYASSERT(m_projection->convertLatLonToXY(m_airport->getLatLon(), center_xy));
    painter.translate(center_xy.x(), center_xy.y());

    QPen pen(m_active_color);
    pen.setWidthF(APT_CIRCLE_WIDTH);
    painter.setPen(pen);

    // circle
    QRectF rect(-APT_CIRCLE_RADIUS, -APT_CIRCLE_RADIUS, 2*APT_CIRCLE_RADIUS, 2*APT_CIRCLE_RADIUS);
    painter.drawArc(rect, 0, FULL_ARC);

    // crown

    pen.setWidthF(APT_CIRCLE_CROWN_WIDTH);
    painter.setPen(pen);
    
    QLineF line(0, APT_CIRCLE_RADIUS, 0, APT_CIRCLE_RADIUS + APT_CIRCLE_CROWN_HEIGHT);
    int max_rotation = 6;
    for(int rotation=1; rotation<=max_rotation; ++rotation)
    {
        painter.rotate(360/(double)max_rotation);
        painter.drawLine(line);
    }

    painter.restore();
}
Пример #13
0
void t_libraryEditor::paintArc(QPainter &painter, const t_ArcObject &ob)
{
    QPen dotPen;
    dotPen.setWidth(ob.thickness);
    dotPen.setStyle(Qt::SolidLine);
    dotPen.setColor(g_color);
    painter.setPen(dotPen);
    painter.drawArc(ob.posx - ob.radius, ob.posy - ob.radius, ob.radius*2, ob.radius*2 , ob.start_angle, ob.end_angle);
}
Пример #14
0
void GoalRenderer::_drawArc(QPainter &painter, GoalElement* ele)
{
    // arc
    painter.setPen(QPen(QColor(255, 255, 240), 3));
    QRectF rect(mRectX, mRectY, mRectW, mRectH);
    painter.drawRect(rect); // debug
    painter.setPen(QPen(QColor(255, 0, 0), 3));
    painter.drawArc(rect, 16 * ele->getStartAngle(), 16 * ele->getEndAngle());
}
Пример #15
0
void GfxCanvasRoundedRect::init()
{
    if(!_vdirty)
        return;
    dirty();
    _vdirty = false;

    if(_cornerCurve) {
        ul = QImage(_cornerCurve, _cornerCurve, 
                    QImage::Format_ARGB32_Premultiplied); 
        ul.fill(0);
        QPainter p;
        p.begin(&ul);
        p.setPen(QPen(_color, _lineWidth));
        p.setBrush(_color);
        p.setRenderHint(QPainter::Antialiasing);

        if(_filled) {
            p.drawEllipse(QRectF(qreal(_lineWidth) / 2, qreal(_lineWidth) / 2, 
                             _cornerCurve * 2, _cornerCurve * 2));
        } else {
            p.drawArc(QRectF(qreal(_lineWidth) / 2, qreal(_lineWidth) / 2, 
                             _cornerCurve * 2, _cornerCurve * 2), 
                      90 * 16, 90 * 16);
        }
        p.end();
        ur = ul.mirrored(true, false);
        ll = ul.mirrored(false, true);
        lr = ul.mirrored(true, true);
    } else {
        ul = QImage();
        ur = ul;
        ll = ul;
        lr = ul;
    }

    upper = QImage(15, _lineWidth, QImage::Format_ARGB32_Premultiplied);
    left = QImage(_lineWidth, 15, QImage::Format_ARGB32_Premultiplied);
  
    upper.fill(0); 
    left.fill(0);

    QPainter p;
    p.begin(&upper);
    p.setPen(QPen(_color, _lineWidth));
    p.setRenderHint(QPainter::Antialiasing);
    p.drawLine(QPointF(0, qreal(_lineWidth) / 2), QPointF(15, qreal(_lineWidth) / 2));
    p.end();
    p.begin(&left);
    p.setPen(QPen(_color, _lineWidth));
    p.setRenderHint(QPainter::Antialiasing);
    p.drawLine(QPointF((qreal)(_lineWidth) / 2, 0), QPointF(qreal(_lineWidth) / 2, 15));
    p.end();
    lower = upper.mirrored(false, true);
    right = left.mirrored(true, false);
}
Пример #16
0
void ArrowJunctionCanvas::draw(QPainter & p)
{
    if (!visible())
        return;

    ArrowCanvas * a;
    FILE * fp = svg();

    for (a = lines.first(); a != 0; a = lines.next()) {
        switch (a->type()) {
        case UmlRequired: {
            QRect r = rect();
            int wh = r.width() - 2;
            int startangle = a->get_point(1).x(); // degree * 16

            p.drawArc(r.x() + 1, r.y() + 1,
                      wh, wh,
                      startangle, 180 * 16);

            if (fp != 0) {
                int radius = r.width() / 2;

                QPoint ce = r.center();
                double r_startangle = startangle * 3.1415927 / 180 / 16;
                double dx = cos(r_startangle) * radius;
                double dy = sin(r_startangle) * radius;

                fprintf(fp, "<path fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" d=\"M%lg,%lg a%d,%d 0 0,1 %lg,%lg\" />\n",
                        ce.x() - dx, ce.y() + dy,
                        radius, radius,
                        dx + dx, -dy - dy);
            }
        }
        break;

        case UmlProvided:
            p.drawPixmap(QPoint((int) x(), (int) y()), *providedPixmap);

            if (fp != 0)
                fprintf(fp, "<ellipse fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\" cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n",
                        // 4 is the margin inside the pixmap
                        (int)(x() + PROVIDED_RADIUS + 4),
                        (int)(y() + PROVIDED_RADIUS + 4),
                        (int) PROVIDED_RADIUS, (int) PROVIDED_RADIUS);

            break;

        default:
            // to avoid compiler warning
            break;
        }
    }

    if (selected())
        show_mark(p, rect());
}
Пример #17
0
void ECXor::drawShape(QPainter &p) {
	if (m_logicSymbolShape == Rectangular) {
		MultiInputGate::drawShape(p);
		return;
	}

	initPainter(p);

	int _x = (int)x() + offsetX();
	int _y = (int)y() + offsetY();

	p.save();
	p.setPen(Qt::NoPen);
	p.drawChord(_x - width() + 16, _y, 2 * width() - 16, height(), -16 * 81, 16 * 162);
	p.restore();

	p.drawArc(_x - width() + 16, _y, 2 * width() - 16, height(), -16 * 90, 16 * 180);
	p.drawArc(_x - 8, _y, 16, height(), -16 * 90, 16 * 180);
	p.drawArc(_x, _y, 16, height(), -16 * 90, 16 * 180);

	deinitPainter(p);
}
Пример #18
0
    static void draw(unsigned icam, unsigned ncam,
		     QPainter& painter, bool draw_fast) 
    { 
      int a0 = int(round(double(icam)/double(ncam)*5760));
      int a1 = int(round(double(icam+1)/double(ncam)*5760));
      if(painter.brush().style() == Qt::NoBrush)
	{
	  painter.drawArc(QRectF(-1,-1,2,2),a0,a1-a0);
	}
      else if(painter.pen().color() != painter.brush().color())
	{
	  QPen pen = painter.pen();
	  painter.setPen(QPen(painter.brush().color()));
	  painter.drawPie(QRectF(-1,-1,2,2),a0,a1-a0);
	  painter.setPen(pen);
	  painter.drawArc(QRectF(-1,-1,2,2),a0,a1-a0);
	}
      else
	{
	  painter.drawPie(QRectF(-1,-1,2,2),a0,a1-a0);
	}
    }
Пример #19
0
 void operator()
     ( QPainter & painter
     , const DrawArc & d
     ) const
 {
     painter.setPen( d.pen );
     painter.setBrush( d.brush );
     painter.drawArc
         ( d.rect
         , degToDeg16( d.startAngle )
         , degToDeg16( d.spanAngle )
         );
 }
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
{
    if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha())
        return;

    QPainter *p = m_data->p();
    const bool antiAlias = p->testRenderHint(QPainter::Antialiasing);
    p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines);

    p->drawArc(rect, startAngle * 16, angleSpan * 16);

    p->setRenderHint(QPainter::Antialiasing, antiAlias);
}
void QgsPointDisplacementRenderer::drawCircle( double radiusPainterUnits, QgsSymbolV2RenderContext& context, const QPointF& centerPoint, int nSymbols )
{
  QPainter* p = context.renderContext().painter();
  if ( nSymbols < 2 || !p ) //draw circle only if multiple features
  {
    return;
  }

  //draw Circle
  QPen circlePen( mCircleColor );
  circlePen.setWidthF( context.outputLineWidth( mCircleWidth ) );
  p->setPen( circlePen );
  p->drawArc( QRectF( centerPoint.x() - radiusPainterUnits, centerPoint.y() - radiusPainterUnits, 2 * radiusPainterUnits, 2 * radiusPainterUnits ), 0, 5760 );
}
void IntervalProgressDisplay::EllipticalPaintStrategy::paintEllipticalPath(QPainter &p, const QRectF &rect, const PaintColors &colors, int currentBeat, int beatsToDraw)
{
    QPen pen(Qt::SolidLine);
    pen.setColor(colors.disabledBeats);
    pen.setWidthF(3);
    p.setPen(pen);
    p.setBrush(Qt::BrushStyle::NoBrush);
    //p.drawEllipse(rect);

    double degreesPerSlice = 360.0 / beatsToDraw;
    int beatIndex = currentBeat < beatsToDraw ? currentBeat : (currentBeat - beatsToDraw);
    qreal startAngle = -(degreesPerSlice * beatIndex - 90) * 16;
    qreal spanAngle = -(degreesPerSlice * (beatsToDraw - beatIndex)) * 16;
    p.drawArc(rect, startAngle, spanAngle);
}
Пример #23
0
void testPeekAndPoke3()
{
    // Anonymous structs
    {
#ifndef Q_CC_RVCT
        union {
            struct { int i; int b; };
            struct { float f; };
            double d;
        } a = { 42, 43 };
        a.i = 1; // Break here. Expand a. Step.
        a.i = 2; // Change a.i in Locals view to 0. This changes f, d but expectedly not b. Step.
        a.i = 3; // Continue.
#endif
    }

    // Complex watchers
    {
        struct S { int a; double b; } s[10];
        for (int i = 0; i != 10; ++i) {
            s[i].a = i;  // Break here. Expand s and s[0]. Step.
            // Watcher Context: "Add New Watcher".
            // Type    ['s[%d].a' % i for i in range(5)]
            // Expand it, continue stepping.
        }
    }

    // QImage display
    {
        QImage im(QSize(200, 200), QImage::Format_RGB32);
        im.fill(QColor(200, 10, 30).rgba());
        QPainter pain;
        pain.begin(&im);
        pain.setPen(QPen(Qt::black, 5.0, Qt::SolidLine, Qt::RoundCap));
        pain.drawEllipse(20, 20, 160, 160); // Break here. Step.
        // Toggle between "Normal" and "Displayed" in L&W Context Menu, entry "Display of Type QImage". Step.
        pain.drawArc(70, 115, 60, 30, 200 * 16, 140 * 16);
        pain.setBrush(Qt::black);
        pain.drawEllipse(65, 70, 15, 15); // Step.
        pain.drawEllipse(120, 70, 15, 15); // Step.
        pain.end();
    }

}
Пример #24
0
void NAND_component::PaintComp(QPainter &p)
{
    if(!ref.isNull())
    {
        QPoint lStart(ref.x()+20,ref.y());
        QPoint lEnd(ref.x()+20,ref.y()+80);
        QPoint centar(ref.x()+65,ref.y()+40);

        //komponenta
        p.drawLine(lStart.x(),lStart.y(),lEnd.x(),lEnd.y());
        p.drawArc(lStart.x()-40,lStart.y(),80,80,-90*16, 180*16);
        p.drawEllipse(centar,5,5);

        //pinovi
        p.drawLine(ref.x(),ref.y()+30,ref.x()+20,ref.y()+30);
        p.drawLine(ref.x(),ref.y()+50,ref.x()+20,ref.y()+50);
        p.drawLine(ref.x()+70,ref.y()+40,ref.x()+90,ref.y()+40);
    }
}
Пример #25
0
void widget::paintEvent(QPaintEvent *)
{
    QPainter p;

    p.begin(this);

    p.setRenderHint( QPainter::Antialiasing, true);
    foreach( function func, functionList )
    {
        switch( func.id )
        {
        case 1:
            {
                p.drawLine( func.args.at(0).toInt() , func.args.at(1).toInt() ,  func.args.at(2).toInt(), func.args.at(3).toInt() );
                break;
            }
        case 2:
            {
                p.drawRect( func.args.at(0).toInt() , func.args.at(1).toInt() ,  func.args.at(2).toInt(), func.args.at(3).toInt() );
                break;
            }
        case 3:
            {
                p.drawEllipse( func.args.at(0).toInt() , func.args.at(1).toInt() ,  func.args.at(2).toInt(), func.args.at(3).toInt() );
                break;
            }
        case 4:
            {
                p.drawArc( func.args.at(0).toInt() , func.args.at(1).toInt() ,  func.args.at(2).toInt(), func.args.at(3).toInt() ,
                           func.args.at(4).toInt() , func.args.at(5).toInt());
                break;
            }
        default:
            {
                qDebug() << "no function with that name";
            }
        }
    }
    p.end();
}
Пример #26
0
void WTFWidget::drawInnerArrow(QPainter& painter) {

    if(_innerPercent == 0) return;

    QRect rect = this->contentsRect();
    QPoint center = rect.center();
    painter.save();
    painter.translate(center);
    painter.rotate(90 * _innerPercent);

    QColor arrowColor = QColor::fromRgb(0xff,0xff,0xff,0xff * _innerPercent);
    QPen pen = QPen(arrowColor);
    pen.setWidth(2);
    painter.setPen(pen);
    int left = - CIRCLE_INNER_RADIUS;
    int top =  - CIRCLE_INNER_RADIUS;
    QRect arcRect = QRect(left,top,CIRCLE_INNER_RADIUS * 2,
                          CIRCLE_INNER_RADIUS * 2);
    painter.drawArc(arcRect,90 * 16,270 * 16);

    // start draw arrow
    qreal arrowBorderLen = 8;
    QPainterPath path;
    QPoint topPoint(0,
                    - CIRCLE_INNER_RADIUS - arrowBorderLen/2);
    path.moveTo(topPoint);
    qreal distance = (arrowBorderLen / 2) / qTan(qDegreesToRadians((double)30));
    QPoint rightPoint(distance,-CIRCLE_INNER_RADIUS);
    path.lineTo(rightPoint);
    QPoint bottomPoint(0,
                       - CIRCLE_INNER_RADIUS + arrowBorderLen/2);
    path.lineTo(bottomPoint);
    path.closeSubpath();
    painter.fillPath(path,QBrush(arrowColor));

    painter.translate(-center.x(),-center.y());
    painter.restore();
}
Пример #27
0
void enginewidget::paintEvent(QPaintEvent*){
    QPainter *painter = new QPainter(this);
    painter->setWindow(-100, -100, 200, 200);
    
    QPen backgroundpen(Qt::black, 1, Qt::SolidLine);
    painter->setPen(backgroundpen);
    QBrush backgroundbrush(Qt::black);
    painter->setBrush(backgroundbrush);
    painter->drawRect(-100, -100, 200, 200);
    
    QPen scalepen(Qt::green, 3, Qt::SolidLine);
    painter->setPen(scalepen);
    painter->drawArc(-75, -75, 150, 150, 45*16, 180*16);
    
    QPen pointerpen(Qt::white, 1, Qt::SolidLine);
    painter->setPen(pointerpen);
    QBrush pointerbrush(Qt::white);
    painter->setBrush(pointerbrush);
    painter->rotate(135);
    painter->rotate(throttle*1.8);
    QPoint arrow[3] = {QPoint(75, 0), QPoint(65, 5), QPoint(65, -5)};
    painter->drawPolygon(arrow, 3);
}
void ribi::QtToggleButtonWidget::DrawToggleButton(
  QPainter& painter,
  const int left, const int top,
  const int width, const int height,
  const ToggleButton * const button)
{
  const int maxx = width - 1;
  const int maxy = height -1;
  painter.setBrush(QColor(
    button->GetRed(),
    button->GetGreen(),
    button->GetBlue()));
  //Draw base
  painter.drawArc(
    left + 0,
    top + (maxy * 1 / 3),
    maxx,
    maxy * 2 / 3,
    180 * 16,
    180 * 16);
  //Draw top
  painter.drawEllipse(
    left + 0,
    top + (button->IsPressed() ? (maxy * 1 / 3) - 2 : 0.0),
    maxx,
    maxy * 2 / 3);
  painter.drawLine(
    left,
    top + (button->IsPressed() ? (maxy * 2 / 3) - 2 : (maxy * 1 / 3)),
    left,
    top + (maxy * 2 / 3));
  painter.drawLine(
    left + maxx,
    top + (button->IsPressed() ? (maxy * 2 / 3) - 2 : (maxy * 1 / 3)),
    left + maxx,
    top + (maxy * 2 / 3));
}
Пример #29
0
void FlowPart::drawShape(QPainter &p) {
	initPainter(p);

	const double _x = int(x() + offsetX());
	const double _y = int(y() + offsetY());
	const double w = width();
	double h = height();

	switch (m_flowSymbol) {

	case FlowPart::ps_other:
		CNItem::drawShape(p);
		break;

	case FlowPart::ps_io: {
		h--;
		double roundSize = 8;
		double slantIndent = 5;

// 		CNItem::drawShape(p);
		double inner = std::atan(h / slantIndent);
		double outer = M_PI - inner;

		int inner16 = int(16 * inner * DPR);
		int outer16 = int(16 * outer * DPR);

		p.save();
		p.setPen(Qt::NoPen);
		p.drawPolygon(areaPoints());
		p.restore();

		p.drawLine(int(_x + slantIndent + roundSize / 2),
		           int(_y),
		           int(_x + w - roundSize / 2),
		           int(_y));

		p.drawLine(int(_x + w - slantIndent - roundSize / 2),
		           int(_y + h),
		           int(_x + roundSize / 2),
		           int(_y + h));

		p.drawLine(int(_x + w + (std::sin(outer) - 1) * roundSize / 2),
		           int(_y + (1 - std::cos(outer)) * roundSize / 2),
		           int(_x + w - slantIndent + (std::sin(inner) - 1) * roundSize / 2),
		           int(_y + h + (std::cos(inner) - 1) * roundSize / 2));

		p.drawLine(int(_x + (1 - std::sin(outer)) * roundSize / 2),
		           int(_y + h + (std::cos(outer) - 1) * roundSize / 2),
		           int(_x + slantIndent + (1 - std::sin(inner)) * roundSize / 2),
		           int(_y + (1 - std::cos(inner)) * roundSize / 2));

		p.drawArc(int(_x + slantIndent),
		          int(_y),
		          int(roundSize),
		          int(roundSize),
		          90 * 16,
		          inner16);

		p.drawArc(int(_x + w - roundSize),
		          int(_y),
		          int(roundSize),
		          int(roundSize),
		          270 * 16 + inner16,
		          outer16);

		p.drawArc(int(_x - slantIndent + w - roundSize),
		          int(_y + h - roundSize),
		          int(roundSize),
		          int(roundSize),
		          270*16,
		          inner16);

		p.drawArc(int(_x),
		          int(_y + h - roundSize),
		          int(roundSize),
		          int(roundSize),
		          90*16 + inner16,
		          outer16);
		break;
	}

	case FlowPart::ps_decision:
		// TODO Make the shape nice and pretty with rounded corners
		CNItem::drawShape(p);
		break;

	case FlowPart::ps_call:
		p.drawRoundRect(int(_x), int(_y), int(w), int(h + 1), int(1000. / w), int(1000. / h));
		p.drawLine(int(_x + 8), int(_y), int(_x + 8), int(_y + h));
		p.drawLine(int(_x + w - 8), int(_y), int(_x + w - 8), int(_y + h));
		break;

	case FlowPart::ps_process:
		p.drawRoundRect(int(_x), int(_y), int(w), int(h + 1), int(1000. / w), int(1000. / h));
		break;

	case FlowPart::ps_round:
		p.drawRoundRect(int(_x), int(_y), int(w), int(h + 1), 30, 100);
		break;
	}

	p.setPen(Qt::black);

	p.setFont(font());
	p.drawText(boundingRect(), (Qt::WordBreak | Qt::AlignHCenter | Qt::AlignVCenter), m_caption);
}
Пример #30
0
void QDial::repaintScreen( const QRect *cr )
{
    QPainter p;
    p.begin( this );

    bool resetClipping = FALSE;

    // calculate clip-region for erasing background
    if ( cr ) {
	p.setClipRect( *cr );
    } else if ( !d->onlyOutside && d->eraseAreaValid ) {
	QRegion reg = d->eraseArea;
	double a;
	reg = reg.subtract( calcArrow( a ) );
	p.setClipRegion( reg );
	resetClipping = TRUE;
    }

    QRect br( calcDial() );
    p.setPen( NoPen );
    // if ( style() == MotifStyle )
    // p.setBrush( colorGroup().brush( QColorGroup::Mid ) );
    // else {
    QBrush b;
    if ( colorGroup().brush( QColorGroup::Light ).pixmap() )
	b = QBrush( colorGroup().brush( QColorGroup::Light ) );
    else
	b = QBrush( colorGroup().light(), Dense4Pattern );
    p.setBrush( b );
    p.setBackgroundMode( OpaqueMode );
    // }

    QRect te = br;
    te.setWidth(te.width()+2);
    te.setHeight(te.height()+2);
    // erase background of dial
    if ( !d->onlyOutside ) {
	p.drawEllipse( te );
    }

    // erase remaining space around the dial
    QRegion remaining( 0, 0, width(), height() );
    remaining = remaining.subtract( QRegion( te, QRegion::Ellipse ) );
    if ( p.hasClipping() )
	remaining = remaining.intersect( p.clipRegion() );
    erase(remaining);

    if ( resetClipping ) {
	if ( cr )
	    p.setClipRect( *cr );
	else
	    p.setClipRect( QRect( 0, 0, width(), height() ) );
    }

    // draw notches
    if ( d->showNotches ) {
	calcLines();
	p.setPen( colorGroup().foreground() );
	p.drawLineSegments( d->lines );
    }

    // calculate and paint arrow
    p.setPen( QPen( colorGroup().dark() ) );
    p.drawArc( te, 60 * 16, 180 * 16 );
    p.setPen( QPen( colorGroup().light() ) );
    p.drawArc( te, 240 * 16, 180 * 16 );

    double a;
    QPointArray arrow( calcArrow( a ) );
    QRect ea( arrow.boundingRect() );
    d->eraseArea = ea;
    d->eraseAreaValid = TRUE;

    p.setPen( NoPen );
    p.setBrush( colorGroup().brush( QColorGroup::Button ) );
    if ( !d->onlyOutside )
	p.drawPolygon( arrow );

    a = angle( QPoint( width() / 2, height() / 2 ), arrow[ 0 ] );
    p.setBrush( Qt::NoBrush );

    // that's still a hack...
    if ( a <= 0 || a > 200 ) {
	p.setPen( colorGroup().light() );
	p.drawLine( arrow[ 2 ], arrow[ 0 ] );
	p.drawLine( arrow[ 1 ], arrow[ 2 ] );
	p.setPen( colorGroup().dark() );
	p.drawLine( arrow[ 0 ], arrow[ 1 ] );
    } else if ( a > 0 && a < 45 ) {
	p.setPen( colorGroup().light() );
	p.drawLine( arrow[ 2 ], arrow[ 0 ] );
	p.setPen( colorGroup().dark() );
	p.drawLine( arrow[ 1 ], arrow[ 2 ] );
	p.drawLine( arrow[ 0 ], arrow[ 1 ] );
    } else if ( a >= 45 && a < 135 ) {
	p.setPen( colorGroup().dark() );
	p.drawLine( arrow[ 2 ], arrow[ 0 ] );
	p.drawLine( arrow[ 1 ], arrow[ 2 ] );
	p.setPen( colorGroup().light() );
	p.drawLine( arrow[ 0 ], arrow[ 1 ] );
    } else if ( a >= 135 && a < 200 ) {
	p.setPen( colorGroup().dark() );
	p.drawLine( arrow[ 2 ], arrow[ 0 ] );
	p.setPen( colorGroup().light() );
	p.drawLine( arrow[ 0 ], arrow[ 1 ] );
	p.drawLine( arrow[ 1 ], arrow[ 2 ] );
    }

    // draw focus rect around the dial
    if ( hasFocus() ) {
	p.setClipping( FALSE );
	br.setWidth( br.width() + 2 );
	br.setHeight( br.height() + 2 );
	if ( d->showNotches ) {
	    int r = QMIN( width(), height() ) / 2;
	    br.moveBy( -r / 6, - r / 6 );
	    br.setWidth( br.width() + r / 3 );
	    br.setHeight( br.height() + r / 3 );
	}
	// strange, but else we get redraw errors on Windows
	p.end();
	p.begin( this );
	p.save();
	p.setPen( QPen( colorGroup().background() ) );
	p.setBrush( NoBrush );
	p.drawRect( br );
	p.restore();
	style().drawPrimitive( QStyle::PE_FocusRect, &p, br, colorGroup());
    }
    p.end();
}