Example #1
0
//-----------------------------------------------------------------------------
//! 
//-----------------------------------------------------------------------------
void tBoatWidget::DrawThrusterIcon( QPainter& painter, int yPos )
{
    painter.save();

    QColor thrusterColor = tSystemSettings::Instance()->NightMode() ? Qt::darkGray : Qt::black;

    int w_2 = width()/2;
    painter.translate( QPointF(w_2, yPos) );

    painter.setRenderHint(QPainter::Antialiasing, false);
    painter.setPen( QPen(thrusterColor, 1) );
    painter.drawLine(-5,0,5,0);
    painter.drawLine(0,-5,0,5);
    painter.setRenderHint(QPainter::Antialiasing, true);

    
    for(int i=0;i<4;i++)
    {
        painter.save();
        painter.translate(QPointF(0.5, 0.5));
        painter.rotate(i*90);
        QPainterPath p1;
        p1.lineTo( QPointF( -4.5, -13 ) );
        p1.lineTo( QPointF( 4.5, -13 ) );
        painter.fillPath( p1, thrusterColor );
        painter.restore();
    }
        
    painter.setPen( QPen(thrusterColor, 3.5) );
    painter.drawEllipse(QPointF(0.5,0.5),13.0, 13.0);
    painter.restore();
}
Example #2
0
 void BoardView::fillPolygon(QPainter& painter, float cellSize)
 {
   const QColor firstColor(Settings::firstPointColor());
   const QColor secondColor(Settings::secondPointColor());
   
   const auto& polygonVector = m_model->polygons();
   
   const QBrush firstPolyBrush(firstColor,
       BrushComboDelegate::getBrushStyle(Settings::firstFillStyle()));
   const QBrush secondPolyBrush(secondColor,
       BrushComboDelegate::getBrushStyle(Settings::secondFillStyle()));
   
   for (Polygon_ptr polygon : polygonVector)
   {
     QPolygon qPoly;
     for(const QPoint& point : polygon->points())
     {
       const QPoint& newPoint = point + QPoint{1, 1};
       qPoly << QPoint(newPoint) * cellSize;
     }
     QPainterPath path;
     path.addPolygon(qPoly);
     painter.fillPath(path, polygon->owner() == Owner::FIRST
         ? firstPolyBrush
         : secondPolyBrush);
   }
 }
Example #3
0
void PanelRadar::paintEvent(QPaintEvent* event) {
    const qreal scale0 = 0.14644660940672623779957781894758;
    const qreal scale1 = (1.0 - scale0);
    
    PanelWidget::paintEvent(event);
    QPainter p;
    p.begin(this);
    setMargins(&p);
    p.setRenderHint(QPainter::Antialiasing, true);
    p.setRenderHint(QPainter::TextAntialiasing, true);
    
    QPen pen = p.pen();
    pen.setWidth(1);
    p.setPen(QColor("black"));
    
    QPainterPath path;
    qreal rx = p.device()->width();
    qreal ry = p.device()->height();
    
    QPointF point(0.5 * rx, 0.5 * ry);
    
    path.addEllipse(point, 0.50 * rx, 0.50 * ry);
    p.fillPath(path, QColor("white"));
    path.addEllipse(point, 0.25 * rx, 0.25 * ry);
    p.drawPath(path);

    p.drawLine(0, 0.5 * ry, rx, 0.5 * ry);
    p.drawLine(0.5 * rx, 0, 0.5 * rx, ry);
    p.drawLine(rx * scale0 + 1, ry * scale0 + 1, rx * scale1 - 1, ry * scale1 - 1);
    p.drawLine(rx * scale0 + 1, ry * scale1 - 1, rx * scale1 - 1, ry * scale0 + 1);
    
    drawItems(&p);
    
    p.end();
}
Example #4
0
//-----------------------------------------------------------------------------
//! 
//-----------------------------------------------------------------------------
void tBoatWidget::DrawThrustArrow( QPainter& painter, int value, int yPos )
{
    painter.save();
    painter.translate( QPointF(width()/2, yPos+0.5) );

    int minValue = 10;
    int headLength = 24;
    int valuePix = value/2;
    if( valuePix < 0 )
        valuePix = -valuePix;
   
    int s = (value > 0) ? 1 : -1;
    QColor arrowColor = (value > 0) ? QColor(0,188,0) : Qt::red;

    QColor grad1Color = QColor(7,131,255,255);
    QColor grad2Color = QColor(7,131,255,0);

    if( tSystemSettings::Instance()->NightMode() )
    {
        arrowColor = arrowColor.darker();
        grad1Color = grad1Color.darker();
    }

    // Draw arrow
    QPainterPath path;
    path.moveTo( 0, -10 );
    path.lineTo( s*(minValue + valuePix), -10);
    path.lineTo( s*(minValue + valuePix), -15 );
    path.lineTo( s*(minValue + valuePix + headLength), 0 );
    path.lineTo( s*(minValue + valuePix), 15 );
    path.lineTo( s*(minValue + valuePix), 10 );
    path.lineTo( 0, 10 );
    painter.fillPath( path, arrowColor );

    // Draw vacuum
    QGradient grad = QLinearGradient( QPointF(0,0), QPointF(-s*40,0) );
    grad.setColorAt(0.0, grad1Color );
    grad.setColorAt(1.0, grad2Color );
    QPainterPath p2;
    p2.moveTo( 0, -12 );
    p2.lineTo( -s*40, -21 );
    p2.lineTo( -s*40, 21 );
    p2.lineTo( 0, 12 );
    painter.fillPath( p2, grad );

    painter.restore();
}
Example #5
0
void
drawCompositedPopup( QWidget* widget,
                     const QPainterPath& outline,
                     const QColor& lineColor,
                     const QBrush& backgroundBrush,
                     qreal opacity )
{
    bool compositingWorks = true;
#if defined(Q_WS_WIN)   //HACK: Windows refuses to perform compositing so we must fake it
    compositingWorks = false;
#elif defined(Q_WS_X11)
    if ( !QX11Info::isCompositingManagerRunning() )
        compositingWorks = false;
#endif

    QPainter p;
    QImage result;
    if ( compositingWorks )
    {
        p.begin( widget );
        p.setRenderHint( QPainter::Antialiasing );
        p.setBackgroundMode( Qt::TransparentMode );
    }
    else
    {
        result =  QImage( widget->rect().size(), QImage::Format_ARGB32_Premultiplied );
        p.begin( &result );
        p.setCompositionMode( QPainter::CompositionMode_Source );
        p.fillRect( result.rect(), Qt::transparent );
        p.setCompositionMode( QPainter::CompositionMode_SourceOver );
    }

    QPen pen( lineColor );
    pen.setWidth( 2 );
    p.setPen( pen );
    p.drawPath( outline );

    p.setOpacity( opacity );
    p.fillPath( outline, backgroundBrush );
    p.end();

    if ( !compositingWorks )
    {
        QPainter finalPainter( widget );
        finalPainter.setRenderHint( QPainter::Antialiasing );
        finalPainter.setBackgroundMode( Qt::TransparentMode );
        finalPainter.drawImage( 0, 0, result );
        widget->setMask( QPixmap::fromImage( result ).mask() );
    }

#ifdef QT_MAC_USE_COCOA
    // Work around bug in Qt/Mac Cocoa where opening subsequent popups
    // would incorrectly calculate the background due to it not being
    // invalidated.
    SourceTreePopupHelper::clearBackground( widget );
#endif
}
Example #6
0
void
Thumbnail::paintOverImage(
	QPainter& painter, QTransform const& image_to_display,
	QTransform const& thumb_to_display)
{	
	// We work in display coordinates because we want to be
	// pixel-accurate with what we draw.
	painter.setWorldTransform(QTransform());

	QTransform const virt_to_display(virtToThumb() * thumb_to_display);

	QRectF const inner_rect(virt_to_display.map(m_virtContentRect).boundingRect());
	
	// We extend the outer rectangle because otherwise we may get white
	// thin lines near the edges due to rounding errors and the lack
	// of subpixel accuracy.  Doing that is actually OK, because what
	// we paint will be clipped anyway.
	QRectF const outer_rect(
		virt_to_display.map(m_virtOuterRect).boundingRect().adjusted(-1.0, -1.0, 1.0, 1.0)
	);
	
	QPainterPath outer_outline;
	outer_outline.addPolygon(PolygonUtils::round(outer_rect));
	
	QPainterPath content_outline;
	content_outline.addPolygon(PolygonUtils::round(inner_rect));
	
	painter.setRenderHint(QPainter::Antialiasing, true);
	
	QColor bg_color;
	QColor fg_color;
	if (m_params.alignment().isNull()) {
		// "Align with other pages" is turned off.
		// Different color is useful on a thumbnail list to
		// distinguish "safe" pages from potentially problematic ones.
		bg_color = QColor(0x58, 0x7f, 0xf4, 70);
		fg_color = QColor(0x00, 0x52, 0xff);
	} else {
		bg_color = QColor(0xbb, 0x00, 0xff, 40);
		fg_color = QColor(0xbe, 0x5b, 0xec);
	}

	// Draw margins.
	painter.fillPath(outer_outline.subtracted(content_outline), bg_color);
	
	QPen pen(fg_color);
	pen.setCosmetic(true);
	pen.setWidthF(1.0);
	painter.setPen(pen);
	painter.setBrush(Qt::NoBrush);
	
	// toRect() is necessary because we turn off antialiasing.
	// For some reason, if we let Qt round the coordinates,
	// the result is slightly different.
	painter.drawRect(inner_rect.toRect());
}
void SelectLocation::paintEvent(QPaintEvent *paintevent)
{
	QPainter painter;
	QPainterPath roundedrect;
	roundedrect.addRoundRect(this->rect(),20);
	
	painter.setOpacity(0.8);
	painter.fillPath(roundedrect,QColor(Qt::black));
	painter.setOpacity(1);
	
}
Example #8
0
void Shape2DRectangle::drawShape(QPainter& painter) const
{
  QRectF drawRect = m_boundingRect.toQRectF();
  painter.drawRect(drawRect);
  if (m_fill_color != QColor())
  {
    QPainterPath path;
    path.addRect(drawRect);
    painter.fillPath(path,m_fill_color);
  }
}
Example #9
0
void KoShapeStroke::Private::paintBorder(KoShape *shape, QPainter &painter, const QPen &pen) const
{
    if (!pen.isCosmetic()) {
        KoPathShape *pathShape = dynamic_cast<KoPathShape *>(shape);
        if (pathShape) {
            QPainterPath path = pathShape->pathStroke(pen);
            painter.fillPath(path, pen.brush());
            return;
        }
        painter.strokePath(shape->outline(), pen);
    }
}
Example #10
0
void GraphicsContext::fillPath()
{
    if (paintingDisabled())
        return;

    QPainter *p = m_data->p();
    QPainterPath path = m_data->currentPath;

    switch (m_common->state.fillColorSpace) {
    case SolidColorSpace:
        if (fillColor().alpha())
            p->fillPath(path, p->brush());
        break;
    case PatternColorSpace:
        p->fillPath(path, QBrush(m_common->state.fillPattern.get()->createPlatformPattern(getCTM())));
        break;
    case GradientColorSpace:
        p->fillPath(path, QBrush(*(m_common->state.fillGradient.get()->platformGradient())));
        break;
    }
}
Example #11
0
void CMeteorite::Draw( QPainter &painter, const float freq_tick )
{
	painter.setPen( QPen( meteo_clr, 1 ) );


	float tx = 0, ty = 0;
	getTickCoords( freq_tick, tx, ty );

	QPolygon m_tmp_bd( m_body );
	m_tmp_bd.translate( tx, ty );

	painter.drawPolygon( m_tmp_bd );

	QPainterPath pt;
	pt.addPolygon( m_tmp_bd );


	painter.fillPath( pt, QBrush( Qt::black ));
	painter.fillPath( pt, QBrush( meteo_clr, Qt::Dense2Pattern ));

}
Example #12
0
void Shape2DRing::drawShape(QPainter& painter) const
{
  m_outer_shape->draw(painter);
  m_inner_shape->draw(painter);
  if (m_fill_color != QColor())
  {
    QPainterPath path;
    m_outer_shape->addToPath(path);
    m_inner_shape->addToPath(path);
    painter.fillPath(path,m_fill_color);
  }
}
void CanvasRenderingContext2D::fill()
{
    GraphicsContext* c = drawingContext();
    if (!c)
        return;
    // FIXME: Do this through platform-independent GraphicsContext API.
#if PLATFORM(CG)
    CGContextBeginPath(c->platformContext());
    CGContextAddPath(c->platformContext(), state().m_path.platformPath());

    if (!state().m_path.isEmpty())
        willDraw(CGContextGetPathBoundingBox(c->platformContext()));

    if (state().m_fillStyle->gradient()) {
        // Shading works on the entire clip region, so convert the current path to a clip.
        c->save();
        CGContextClip(c->platformContext());
        CGContextDrawShading(c->platformContext(), state().m_fillStyle->gradient()->platformShading());        
        c->restore();
    } else {
        if (state().m_fillStyle->pattern())
            applyFillPattern();
        CGContextFillPath(c->platformContext());
    }
#elif PLATFORM(QT)
    QPainterPath* path = state().m_path.platformPath();
    QPainter* p = static_cast<QPainter*>(c->platformContext());
    willDraw(path->controlPointRect());
    if (state().m_fillStyle->gradient()) {
        p->fillPath(*path, QBrush(*(state().m_fillStyle->gradient()->platformShading())));
    } else {
        if (state().m_fillStyle->pattern())
            applyFillPattern();
        p->fillPath(*path, p->brush());
    }
#endif

    clearPathForDashboardBackwardCompatibilityMode();
}
Example #14
0
void drawPolygon(QPainter &p, const std::vector<QPointF> &points, bool fill,
                 const QColor colorFill, const QColor colorLine) {
  if (points.size() == 0) return;
  p.setPen(colorLine);
  QPolygonF E0Polygon;
  int i = 0;
  for (i = 0; i < (int)points.size(); i++) E0Polygon << QPointF(points[i]);
  E0Polygon << QPointF(points[0]);

  QPainterPath E0Path;
  E0Path.addPolygon(E0Polygon);
  if (fill) p.fillPath(E0Path, QBrush(colorFill));
  p.drawPath(E0Path);
}
Example #15
0
/// Draw marker as a diamond
void PeakMarker2D::drawDiamond(QPainter& painter)const
{
  QPointF dp = origin();
  QPointF mdp(-dp.x(),-dp.y());
  // draw a diamond as a square rotated by 45 degrees
  painter.save();
  painter.translate(dp);
  painter.rotate(45);
  painter.translate(mdp);
  QPainterPath path;
  path.addRect(m_boundingRect.toQRectF());
  painter.fillPath(path,m_color);
  painter.restore();
}
Example #16
0
void PanWidget::
paintEvent ( QPaintEvent * event )
{
    QPainter painter (this);
    painter.setRenderHints (QPainter::Antialiasing | QPainter::HighQualityAntialiasing);
    painter.fillPath (path_, QColor(220,220,220,200));
    painter.strokePath (path_, QPen(
                            QColor(100,100,100,200),
                            hasFocus () ? 1.6 : .8,
                            Qt::SolidLine,
                            Qt::RoundCap,
                            Qt::RoundJoin));

    QWidget::paintEvent(event);
}
Example #17
0
 QPixmap MessageWidget::_decorateAvatar(QPixmap *avatar)
 {
     QBrush brush(*avatar);
     QPixmap roundedAvatar(avatar->width(), avatar->height());
     roundedAvatar.fill(Qt::transparent);
     QPainter painter;
     painter.begin(&roundedAvatar);
     QPainterPath roundRect;
     roundRect.addRoundedRect(0, 0, roundedAvatar.width(), roundedAvatar.height(), 10, 10, Qt::AbsoluteSize);
     painter.setRenderHint(QPainter::Antialiasing, true);
     painter.fillPath(roundRect, brush);
     painter.setRenderHint(QPainter::Antialiasing, false);
     painter.end();
     return roundedAvatar;
 }
Example #18
0
QPixmap ImageProcessor::drawStroke(const QPainterPath &strokeShape, const QSize &pxSize)
{
    QPainter p;
    QPixmap stroke(pxSize.width() + _p->descriptor.strokeThickness * 2,
                   pxSize.height() + _p->descriptor.strokeThickness * 2);
    stroke.fill(Qt::transparent);
    p.begin(&stroke);
    p.setRenderHint(QPainter::SmoothPixmapTransform, true);
    p.setRenderHint(QPainter::Antialiasing, true);
    p.setRenderHint(QPainter::HighQualityAntialiasing, true);
    p.fillPath(strokeShape, QBrush(QColor(255, 255, 255, 255)));
    p.end();

    return stroke;
}
Example #19
0
void WTFWidget::drawBounceCircle(QPainter& painter)
{

   if(_bouncePercent == 0) return;
   QRect rect = this->contentsRect();
   QPoint center = rect.center();

   QPainterPath mPath;
   float radius = CIRCLE_RADIUS;

   float longRadius = radius * (1 + _bouncePercent) /*+ distance*/;
   float shortRadius = radius * 1.0f /*- distance * 0.1f*/;


   painter.save();
   painter.translate(center);
   painter.rotate(90);

   mPath.lineTo(0, -radius);
   mPath.cubicTo(radius * sMagicNumber, -radius
           , longRadius, -radius * sMagicNumber
           , longRadius, 0);
   mPath.lineTo(0, 0);

   mPath.lineTo(0, radius);
   mPath.cubicTo(radius * sMagicNumber, radius
           , longRadius, radius * sMagicNumber
           , longRadius, 0);
   mPath.lineTo(0, 0);

   mPath.lineTo(0, -radius);
   mPath.cubicTo(-radius * sMagicNumber, -radius
           , -shortRadius, -radius * sMagicNumber
           , -shortRadius, 0);
   mPath.lineTo(0, 0);

   mPath.lineTo(0, radius);
   mPath.cubicTo(-radius * sMagicNumber, radius
           , -shortRadius, radius * sMagicNumber
           , -shortRadius, 0);
   mPath.lineTo(0, 0);

   QBrush brush = QBrush(QColor::fromRgb(11,160,238));
   painter.fillPath(mPath,brush);

   painter.translate(-center.x(),-center.y());
   painter.restore();
}
Example #20
0
void MapView::drawArrow(QPainter &painter, const QPoint &p)
{
    QPainterPath path;

    path.moveTo(0, 0);
    path.lineTo(1, 0);
    path.lineTo(7, 15);
    path.lineTo(0, 10);
    path.lineTo(-7, 15);
    path.lineTo(0, 0);

    path.translate(p);
    path.translate(0, 2);

    painter.fillPath(path, QBrush(Qt::yellow));
}
Example #21
0
void MapEditorWidget::paintPoints()
{
  QPolygonF sPoints = transform.map(points);
  QPainter p;
  p.begin(this);
  
  p.setRenderHint(QPainter::Antialiasing);

  p.setPen(QColor("#000000"));
  p.setBrush(QBrush());
  //  p.drawRect(plotArea);
  
  p.setPen(connectionPen);
  if(sPoints.size()){
    QPainterPath path;
    path.moveTo(QPointF(plotArea.topLeft().x(),sPoints.at(0).y()));
    path.lineTo(QPointF(sPoints.at(0)));
      //    path.moveTo(sPoints.at(0));
    for (int i=1; i<sPoints.size(); ++i) {
      QPointF p1 = sPoints.at(i-1);
      QPointF p2 = sPoints.at(i);
      double distance = p2.x() - p1.x();
      
      path.cubicTo(p1.x() + distance / 2, p1.y(),
		   p1.x() + distance / 2, p2.y(),
		   p2.x(), p2.y());
    }
    path.lineTo(plotArea.bottomRight().x(),sPoints.last().y());
    p.drawPath(path);    
    path.lineTo(plotArea.bottomRight());
    path.lineTo(plotArea.topLeft().x(),plotArea.bottomRight().y());
    QLinearGradient grad = QLinearGradient(0,0,0,plotArea.height());
    grad.setColorAt(0,QColor("#B2DFEE"));
    grad.setColorAt(1,QColor("#26466D"));
    QBrush grad_brush(grad);      
    p.fillPath(path,grad_brush);
  }
  p.setPen(pointPen);
  p.setBrush(pointBrush);
  for (int i=0; i<sPoints.size(); ++i) {
    QRectF bounds = pointBoundingRect(i);
    p.drawEllipse(bounds);
  }



}
Example #22
0
void RescaleWidget::
        paintEvent(QPaintEvent *event)
{
    QPainter painter (this);
    painter.setRenderHints (QPainter::Antialiasing | QPainter::HighQualityAntialiasing);
    //painter.fillPath (path_, QBrush(QColor(125,125,125,125)));
    painter.fillPath (path_, QColor(220,220,220,200));
    painter.strokePath (path_, QPen(
                            QColor(100,100,100,200),
                            hasFocus () ? 1.6 : .8,
                            Qt::SolidLine,
                            Qt::RoundCap,
                            Qt::RoundJoin));

    //painter.drawImage(QPoint(),qimage_);

    QWidget::paintEvent (event);
}
void PeakRepresentationSphere::doDraw(
    QPainter &painter, PeakViewColor &foregroundColor,
    PeakViewColor &backgroundColor,
    std::shared_ptr<PeakPrimitives> drawingInformation,
    PeakRepresentationViewInformation viewInformation) {
  auto drawingInformationSphere =
      std::static_pointer_cast<PeakPrimitiveCircle>(drawingInformation);

  // Setup the QPainter
  painter.setRenderHint(QPainter::Antialiasing);
  painter.setOpacity(drawingInformationSphere->peakOpacityAtDistance);

  // Add a pen with color, style and stroke, and a painter path
  auto foregroundColorSphere = foregroundColor.colorSphere;
  QPainterPath peakRadiusInnerPath;
  const QPointF originWindows(viewInformation.xOriginWindow,
                              viewInformation.yOriginWindow);
  peakRadiusInnerPath.addEllipse(originWindows,
                                 drawingInformationSphere->peakInnerRadiusX,
                                 drawingInformationSphere->peakInnerRadiusY);

  QPen pen(foregroundColorSphere);
  pen.setWidth(drawingInformationSphere->peakLineWidth);
  pen.setStyle(Qt::DashLine);
  painter.strokePath(peakRadiusInnerPath, pen);

  // Draw the background if this is requested
  if (m_showBackgroundRadius) {
    QPainterPath backgroundOuterPath;
    backgroundOuterPath.setFillRule(Qt::WindingFill);
    backgroundOuterPath.addEllipse(
        originWindows, drawingInformationSphere->backgroundOuterRadiusX,
        drawingInformationSphere->backgroundOuterRadiusY);
    QPainterPath backgroundInnerPath;
    backgroundInnerPath.addEllipse(
        originWindows, drawingInformationSphere->backgroundInnerRadiusX,
        drawingInformationSphere->backgroundInnerRadiusY);
    QPainterPath backgroundRadiusFill =
        backgroundOuterPath.subtracted(backgroundInnerPath);
    painter.fillPath(backgroundRadiusFill, backgroundColor.colorSphere);
  }
  painter.end();
}
    void PreviewContentWidget::renderTextBubble(QPainter &p)
    {
        const auto &bubblePath = getTextBubble();
        if (bubblePath.isEmpty())
        {
            return;
        }

        p.save();
        
        int theme_id = Ui::get_qt_theme_settings()->themeIdForContact(aimId_);
        
        QBrush b;
        p.fillPath(
            bubblePath,
            Ui::MessageStyle::getBodyBrush(isOutgoing(), isSelected(), theme_id)
        );

        p.restore();
    }
void PieChart3D::paintLeft( QPainter& painter, QColor color ) {
  if ( myRender == WireFrame ) {
    return;
  }
  painter.save();
  color.setAlpha( 125 );
  configureColor( painter, color, 0 );
  int width = painter.pen().width()/2;
  painter.setPen( Qt::NoPen );
  QPainterPath path;
  QPainterPath ellipse1, ellipse2;
  ellipse1.addEllipse( myRect );
  ellipse2.addEllipse( myRect.translated( 0, myHeight ) );
  path.moveTo( ellipse1.pointAtPercent( 0.5 ) + QPointF( -width, 0 ) );
  path.lineTo( ellipse2.pointAtPercent( 0.5 ) + QPointF( -width, 0 ) );
  path.arcTo( myRect.translated( 0, myHeight ), 180, -90 );
  path.moveTo( ellipse1.pointAtPercent( 0.5 ) );
  path.arcTo( myRect, 180, 90 );
  path = path.subtracted( ellipse1 );
  painter.fillPath( path, color );
  painter.restore();
}
Example #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();
}
Example #27
0
void QPlot::draw_Data(QPainter &painter)
{
    if(pt_Data != NULL)
    {
        //Pen settings
        QPen pen(QBrush(Qt::NoBrush), 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
        pen.setColor(QColor(255,0,0));
        painter.setPen(pen);

        //Drawing operations
        qreal st_X = (qreal)this->rect().width() / Data_length;
        qreal st_Y = (qreal)this->rect().height() / 10;

        qint32 Y0 = this->rect().height()/2;
        if(unsigned_flag)
        {
            Y0 = this->rect().height();
        }

        QPainterPath path;
        path.moveTo(0, Y0);
        for(quint32 i = 0; i < Data_length; i++)
        {
            path.lineTo(st_X*i, Y0 - st_Y*pt_Data[i]);
        }

        if(unsigned_flag)
        {
            path.lineTo( st_X*(Data_length-1), Y0 ); // for right view of the plot of spectrum
            painter.fillPath(path, QBrush(QColor(0,145,225)));
        }
        else
        {
            painter.drawPath(path);
        }
    }
}
Example #28
0
static inline void fillEllipse(const QPointF &center, qreal hDiameter, qreal vDiameter, const QColor &color, QPainter &painter)
{
    QPainterPath painterPath;
    painterPath.addEllipse(center, hDiameter / 2, vDiameter / 2);
    painter.fillPath(painterPath, color);
}
Example #29
0
void RenderArea::drawShape(QPainter &painter)
{
    painter.fillPath(shape, Qt::blue);
}
Example #30
0
/// Draw marker as a circle
void PeakMarker2D::drawCircle(QPainter& painter)const
{
  QPainterPath path;
  path.addEllipse(m_boundingRect.toQRectF());
  painter.fillPath(path,m_color);
}