Пример #1
1
void SerpinskiShape::drawShape(QPainter &painter, float cx, float cy, float radius) {
    if (radius < 3) return;

    float step = 2 * M_PI / _corners;
    float beginAngle = (-_rotateAngle - 90) * M_PI / 180;
    float endAngle = M_PI * ((float)(-_rotateAngle - 90) / 180 + 2);
    if (_corners == 4) {
        beginAngle += M_PI / 4;
        endAngle += M_PI / 4;
    }

    QVector<QPointF> vertices;
    for (float angle = beginAngle; angle < endAngle; angle += step) {
        vertices.push_back(QPointF(cos(angle) * radius, sin(angle) * radius));
    }
    vertices.push_back(vertices[0]);

    painter.save();
    painter.translate(cx, cy);
    painter.drawPolyline(QPolygonF(vertices));
    painter.restore();

    float nextRadius = 0;
    switch (_corners) {
    case 3:
        nextRadius = radius * 0.5;
        break;
    case 4:
    case 6:
        nextRadius = radius * 0.333;
        break;
    case 5:
        nextRadius = radius / 2.63;
        break;
    }

    float centerRaduis = radius - nextRadius;
    for (float angle = beginAngle; angle < endAngle; angle += step) {
        drawShape(painter,
                  cos(angle) * centerRaduis + cx,
                  sin(angle) * centerRaduis + cy,
                  nextRadius);
    }

    if (_corners != 4) return;

    float addRotate = M_PI / 4;
    beginAngle += addRotate;
    endAngle += addRotate;
    centerRaduis = radius * cos(addRotate) * 0.667;
    for (float angle = beginAngle; angle < endAngle; angle += step) {
        drawShape(painter,
                  cos(angle) * centerRaduis + cx,
                  sin(angle) * centerRaduis + cy,
                  nextRadius);
    }
}
Пример #2
0
/*!
    Draws the first \a pointCount points in the buffer \a points
*/
void QPaintEngine::drawPoints(const QPointF *points, int pointCount)
{
    QPainter *p = painter();
    if (!p)
        return;

    qreal penWidth = p->pen().widthF();
    if (penWidth == 0)
        penWidth = 1;

    bool ellipses = p->pen().capStyle() == Qt::RoundCap;

    p->save();

    QTransform transform;
    if (p->pen().isCosmetic()) {
        transform = p->transform();
        p->setTransform(QTransform());
    }

    p->setBrush(p->pen().brush());
    p->setPen(Qt::NoPen);

    for (int i=0; i<pointCount; ++i) {
        QPointF pos = transform.map(points[i]);
        QRectF rect(pos.x() - penWidth / 2, pos.y() - penWidth / 2, penWidth, penWidth);

        if (ellipses)
            p->drawEllipse(rect);
        else
            p->drawRect(rect);
    }

    p->restore();
}
Пример #3
0
void QPaintEnginePrivate::drawBoxTextItem(const QPointF &p, const QTextItemInt &ti)
{
    if (!ti.glyphs.numGlyphs)
        return;

    // any fixes here should probably also be done in QFontEngineBox::draw
    const int size = qRound(ti.fontEngine->ascent());
    QVarLengthArray<QFixedPoint> positions;
    QVarLengthArray<glyph_t> glyphs;
    QTransform matrix = QTransform::fromTranslate(p.x(), p.y() - size);
    ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
    if (glyphs.size() == 0)
        return;

    QSize s(size - 3, size - 3);

    QPainter *painter = q_func()->state->painter();
    painter->save();
    painter->setBrush(Qt::NoBrush);
    QPen pen = painter->pen();
    pen.setWidthF(ti.fontEngine->lineThickness().toReal());
    painter->setPen(pen);
    for (int k = 0; k < positions.size(); k++)
        painter->drawRect(QRectF(positions[k].toPointF(), s));
    painter->restore();
}
Пример #4
0
void Canvas::paintEvent(QPaintEvent *e)
{
    QPainter *p = new QPainter(this);
    QPen pen(QColor(0,0,0,255));
    qreal curangle = 0.0;

    if(p->isActive()){
        p->setRenderHint(QPainter::Antialiasing);
        pen.setWidth(1);
        p->setPen(pen);

        p->save();
        pen.setColor(QColor(255,0,0,255));
        p->setPen(pen);

        foreach(qreal v, _values){
		qreal span = (5760.0 / _valueSum) * v;

		cout << "Value: " << v << " (sum="<<_valueSum<<") , span = " << span << "/5760, curangle = " << curangle;

		p->drawPie(rect(), curangle, span);
		curangle += span;

		cout << ", newangle = " << curangle << endl;
	}
Пример #5
0
void QgsAnnotation::render( QgsRenderContext &context ) const
{
  QPainter *painter = context.painter();
  if ( !painter )
  {
    return;
  }

  painter->save();
  drawFrame( context );
  if ( mHasFixedMapPosition )
  {
    drawMarkerSymbol( context );
  }
  if ( mHasFixedMapPosition )
  {
    painter->translate( mOffsetFromReferencePoint.x() + context.convertToPainterUnits( mContentsMargins.left(), QgsUnitTypes::RenderMillimeters ),
                        mOffsetFromReferencePoint.y() + context.convertToPainterUnits( mContentsMargins.top(), QgsUnitTypes::RenderMillimeters ) );
  }
  else
  {
    painter->translate( context.convertToPainterUnits( mContentsMargins.left(), QgsUnitTypes::RenderMillimeters ),
                        context.convertToPainterUnits( mContentsMargins.top(), QgsUnitTypes::RenderMillimeters ) );
  }
  QSizeF size( mFrameSize.width() - context.convertToPainterUnits( mContentsMargins.left() + mContentsMargins.right(), QgsUnitTypes::RenderMillimeters ),
               mFrameSize.height() - context.convertToPainterUnits( mContentsMargins.top() + mContentsMargins.bottom(), QgsUnitTypes::RenderMillimeters ) );

  renderAnnotation( context, size );
  painter->restore();
}
Пример #6
0
void QmitkTransferFunctionCanvas::PaintHistogram(QPainter &p)
{
  if (m_Histogram)
  {
    p.save();

    p.setPen(Qt::gray);

    int displayWidth = contentsRect().width();
    int displayHeight = contentsRect().height();

    double windowLeft = m_Lower;
    double windowRight = m_Upper;

    double step = (windowRight - windowLeft) / double(displayWidth);

    double pos = windowLeft;

    for (int x = 0; x < displayWidth; x++)
    {
      double left = pos;
      double right = pos + step;

      float height = m_Histogram->GetRelativeBin(left, right);

      if (height >= 0)
        p.drawLine(x, displayHeight * (1 - height), x, displayHeight);

      pos += step;
    }

    p.restore();
  }
}
Пример #7
0
/**
 * @brief Draw all the nodes generated in the RRT algorithm.
 * @param painter
 */
void RenderArea::drawNodes(QPainter &painter)
{
    painter.save();
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(Qt::black);
    painter.setBrush(QBrush(Qt::black));
    Vector2f pos;
    for(int i = 0; i < (int)rrt->nodes.size(); i++) {
        for(int j = 0; j < (int)rrt->nodes[i]->children.size(); j++) {
            pos = rrt->nodes[i]->children[j]->position;
            painter.drawEllipse(pos.x()-1.5, pos.y()-1.5, 3, 3);
        }
        pos = rrt->nodes[i]->position;
        painter.drawEllipse(pos.x() - NODE_RADIUS, pos.y() - NODE_RADIUS, 2 * NODE_RADIUS, 2 * NODE_RADIUS);
    }
    painter.setPen(Qt::red);
    painter.setBrush(QBrush(Qt::red));

    // if a path exists, draw it.
    for(int i = 0; i < (int)rrt->path.size() - 1; i++) {
        QPointF p1(rrt->path[i]->position.x(), rrt->path[i]->position.y());
        QPointF p2(rrt->path[i+1]->position.x(), rrt->path[i+1]->position.y());
        painter.drawLine(p1, p2);
    }
    painter.restore();
}
void QgsFontMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context )
{
  QPainter* p = context.renderContext().painter();
  QColor penColor = context.selected() ? context.selectionColor() : mColor;
  penColor.setAlphaF( context.alpha() );
  p->setPen( penColor );
  p->setFont( mFont );


  p->save();
  QPointF outputOffset = QPointF( context.outputLineWidth( mOffset.x() ), context.outputLineWidth( mOffset.y() ) );
  if ( mAngle )
    outputOffset = _rotatedOffset( outputOffset, mAngle );
  p->translate( point + outputOffset );

  if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale )
  {
    double s = mSize / mOrigSize;
    p->scale( s, s );
  }

  if ( mAngle != 0 )
    p->rotate( mAngle );

  p->drawText( -mChrOffset, mChr );
  p->restore();
}
Пример #9
0
void QWebFramePrivate::renderFromTiledBackingStore(GraphicsContext* context, const QRegion& clip)
{
    ASSERT(frame->tiledBackingStore());

    if (!frame->view() || !frame->contentRenderer())
        return;

    QVector<QRect> vector = clip.rects();
    if (vector.isEmpty())
        return;

    QPainter* painter = context->platformContext();

    WebCore::FrameView* view = frame->view();
    
    int scrollX = view->scrollX();
    int scrollY = view->scrollY();
    context->translate(-scrollX, -scrollY);

    for (int i = 0; i < vector.size(); ++i) {
        const QRect& clipRect = vector.at(i);

        painter->save();
        
        QRect rect = clipRect.translated(scrollX, scrollY);
        painter->setClipRect(rect, Qt::IntersectClip);

        frame->tiledBackingStore()->paint(context, rect);

        painter->restore();
    }
}
Пример #10
0
void TextRenderable::render(QPainter &painter, const RenderConfig &config) const
{
	painter.save();
	
	bool disable_antialiasing = config.options.testFlag(RenderConfig::Screen) && !(Settings::getInstance().getSettingCached(Settings::MapDisplay_TextAntialiasing).toBool());
	if (disable_antialiasing)
	{
		painter.setRenderHint(QPainter::Antialiasing, false);
		painter.setRenderHint(QPainter::TextAntialiasing, false);
	}
	
	if (framing_line)
	{
		QPen pen(painter.pen());
		pen.setJoinStyle(Qt::MiterJoin);
		pen.setMiterLimit(0.5);
		painter.setPen(pen);
	}
	
	painter.translate(anchor_x, anchor_y);
	if (rotation != 0)
		painter.rotate(-rotation * 180 / M_PI);
	painter.scale(scale_factor, scale_factor);
	painter.drawPath(path);
	
	painter.restore();
}
Пример #11
0
void QgsDoubleBoxScaleBarRenderer::draw( QgsRenderContext &context, const QgsScaleBarSettings &settings, const ScaleBarContext &scaleContext ) const
{
  if ( !context.painter() )
  {
    return;
  }
  QPainter *painter = context.painter();

  double barTopPosition = QgsComposerUtils::fontAscentMM( settings.font() ) + settings.labelBarSpace() + settings.boxContentSpace();
  double segmentHeight = settings.height() / 2;

  painter->save();
  if ( context.flags() & QgsRenderContext::Antialiasing )
    painter->setRenderHint( QPainter::Antialiasing, true );
  painter->setPen( settings.pen() );

  bool useColor = true; //alternate brush color/white

  double xOffset = firstLabelXOffset( settings );

  QList<double> positions = segmentPositions( scaleContext, settings );
  QList<double> widths = segmentWidths( scaleContext, settings );

  for ( int i = 0; i < positions.size(); ++i )
  {
    //draw top half
    if ( useColor )
    {
      painter->setBrush( settings.brush() );
    }
    else //secondary color
    {
      painter->setBrush( settings.brush2() );
    }

    QRectF segmentRectTop( positions.at( i ) + xOffset, barTopPosition, widths.at( i ), segmentHeight );
    painter->drawRect( segmentRectTop );

    //draw bottom half
    if ( useColor )
    {
      //secondary color
      painter->setBrush( settings.brush2() );
    }
    else //primary color
    {
      painter->setBrush( settings.brush() );
    }

    QRectF segmentRectBottom( positions.at( i ) + xOffset, barTopPosition + segmentHeight, widths.at( i ), segmentHeight );
    painter->drawRect( segmentRectBottom );
    useColor = !useColor;
  }

  painter->restore();

  //draw labels using the default method
  drawDefaultLabels( context, settings, scaleContext );
}
Пример #12
0
void DAbstractSliderSpinBox::paintBreeze(QPainter& painter)
{
    Q_D(DAbstractSliderSpinBox);

    QStyleOptionSpinBox spinOpts         = spinBoxOptions();
    QStyleOptionProgressBar progressOpts = progressBarOptions();
    QString valueText                    = progressOpts.text;
    progressOpts.text                    = QLatin1String("");
    progressOpts.rect.adjust(0, 1, 0, -1);

    style()->drawComplexControl(QStyle::CC_SpinBox, &spinOpts, &painter, this);
    style()->drawControl(QStyle::CE_ProgressBarGroove, &progressOpts, &painter, this);

    painter.save();

    QRect leftRect;

    int progressIndicatorPos = (progressOpts.progress - double(progressOpts.minimum)) / qMax(double(1.0),
                                double(progressOpts.maximum) - progressOpts.minimum) * progressOpts.rect.width();

    if (progressIndicatorPos >= 0 && progressIndicatorPos <= progressOpts.rect.width())
    {
        leftRect = QRect(progressOpts.rect.left(), progressOpts.rect.top(), progressIndicatorPos, progressOpts.rect.height());
    }
    else if (progressIndicatorPos > progressOpts.rect.width())
    {
        painter.setPen(palette().highlightedText().color());
    }
    else
    {
        painter.setPen(palette().buttonText().color());
    }

    QRegion rightRect = progressOpts.rect;
    rightRect         = rightRect.subtracted(leftRect);
    painter.setClipRegion(rightRect);

    QTextOption textOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter);
    textOption.setWrapMode(QTextOption::NoWrap);

    if (!(d->edit && d->edit->isVisible()))
    {
        painter.drawText(progressOpts.rect, valueText, textOption);
    }

    if (!leftRect.isNull())
    {
        painter.setPen(palette().highlightedText().color());
        painter.setClipRect(leftRect);
        style()->drawControl(QStyle::CE_ProgressBarContents, &progressOpts, &painter, this);

        if (!(d->edit && d->edit->isVisible()))
        {
            painter.drawText(progressOpts.rect, valueText, textOption);
        }
    }

    painter.restore();
}
Пример #13
0
void Template::drawFocusRect( QPainter& p)
{
    p.save();
    p.setBrush( QBrush::NoBrush );
    p.setPen( QPen( QColor( 100, 100, 100 ), 2, QPen::DotLine ) );
    p.drawRect( d->focusRect );
    p.restore();
}
  void Spectrum1DWidget::saveAsImage()
  {
    QString file_name = QFileDialog::getSaveFileName(this, "Save File", "", "Raster images *.bmp *.png *.jpg *.gif (*.bmp *.png *.jpg *.gif);;Vector images *.svg (*.svg)");
    bool x_visible = x_scrollbar_->isVisible();
    bool y_visible = y_scrollbar_->isVisible();
    x_scrollbar_->hide();
    y_scrollbar_->hide();

    if (file_name.contains(".svg", Qt::CaseInsensitive)) // svg vector format
    {
      QSvgGenerator generator;
      generator.setFileName(file_name);
      generator.setSize(QSize(this->width(), this->height()));
      generator.setViewBox(QRect(0, 0, this->width() - 1, this->height() - 1));
      generator.setTitle(file_name);
      generator.setDescription("TOPPView generated SVG");
      QPainter painter;
      painter.begin(&generator);

      painter.save();
      painter.translate(QPoint(y_axis_->pos()));
      y_axis_->paint(&painter, new QPaintEvent(y_axis_->contentsRect()));
      painter.restore();

      painter.save();
      painter.translate(QPoint(canvas_->pos()));
      dynamic_cast<Spectrum1DCanvas*>(canvas_)->paint(&painter, new QPaintEvent(canvas_->contentsRect()));
      painter.restore();

      painter.save();
      painter.translate(QPoint(x_axis_->pos()));
      x_axis_->paint(&painter, new QPaintEvent(x_axis_->contentsRect()));
      painter.restore();

      painter.end();
      x_scrollbar_->setVisible(x_visible);
      y_scrollbar_->setVisible(y_visible);
    }
    else // raster graphics formats
    {
      QPixmap pixmap = QPixmap::grabWidget(this);
      x_scrollbar_->setVisible(x_visible);
      y_scrollbar_->setVisible(y_visible);
      pixmap.save(file_name);
    }
  }
Пример #15
0
void RectangleMaker::draw(QPainter &painter) const
{
    if( m_rectangle ){
        painter.save();
        m_rectangle->draw(painter);
        painter.restore();
    }
}
Пример #16
0
void KoFormulaShape::paint( QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &)
{
    painter.save();
    applyConversion( painter, converter );   // apply zooming and coordinate translation
    m_formulaRenderer->layoutElement(  m_formulaData->formulaElement() );
    m_formulaRenderer->paintElement( painter,  m_formulaData->formulaElement() );  // paint the formula
    painter.restore();
}
void QgsDecorationNorthArrowDialog::rotatePixmap( int theRotationInt )
{
  QPixmap myQPixmap;
  QString myFileNameQString = ":/images/north_arrows/default.png";
// QgsDebugMsg(QString("Trying to load %1").arg(myFileNameQString));
  if ( myQPixmap.load( myFileNameQString ) )
  {
    QPixmap  myPainterPixmap( myQPixmap.height(), myQPixmap.width() );
    myPainterPixmap.fill();
    QPainter myQPainter;
    myQPainter.begin( &myPainterPixmap );

    myQPainter.setRenderHint( QPainter::SmoothPixmapTransform );

    double centerXDouble = myQPixmap.width() / 2.0;
    double centerYDouble = myQPixmap.height() / 2.0;
    //save the current canvas rotation
    myQPainter.save();
    //myQPainter.translate( (int)centerXDouble, (int)centerYDouble );

    //rotate the canvas
    myQPainter.rotate( theRotationInt );
    //work out how to shift the image so that it appears in the center of the canvas
    //(x cos a + y sin a - x, -x sin a + y cos a - y)
    const double PI = 3.14159265358979323846;
    double myRadiansDouble = ( PI / 180 ) * theRotationInt;
    int xShift = static_cast<int>((
                                    ( centerXDouble * cos( myRadiansDouble ) ) +
                                    ( centerYDouble * sin( myRadiansDouble ) )
                                  ) - centerXDouble );
    int yShift = static_cast<int>((
                                    ( -centerXDouble * sin( myRadiansDouble ) ) +
                                    ( centerYDouble * cos( myRadiansDouble ) )
                                  ) - centerYDouble );

    //draw the pixmap in the proper position
    myQPainter.drawPixmap( xShift, yShift, myQPixmap );

    //unrotate the canvas again
    myQPainter.restore();
    myQPainter.end();

    pixmapLabel->setPixmap( myPainterPixmap );
  }
  else
  {
    QPixmap  myPainterPixmap( 200, 200 );
    myPainterPixmap.fill();
    QPainter myQPainter;
    myQPainter.begin( &myPainterPixmap );
    QFont myQFont( "time", 12, QFont::Bold );
    myQPainter.setFont( myQFont );
    myQPainter.setPen( Qt::red );
    myQPainter.drawText( 10, 20, tr( "Pixmap not found" ) );
    myQPainter.end();
    pixmapLabel->setPixmap( myPainterPixmap );
  }
}
Пример #18
0
void PaintWidget::paintTo(const QRect &dirtyRect, QPainter &painter)
{
    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
    painter.setRenderHint(QPainter::Antialiasing, true);
    //painter.setRenderHint(QPainter::HighQualityAntialiasing, true);

    //draw screenshot if enabled
    if(drawScreenhot_)
    {
       painter.save();

       auto size = painter.viewport().size();
       QSize s = screenshot_.size();
       QRect r = calcDrawArea(s, size);

       painter.drawPixmap(r,screenshot_);
       painter.restore();
    }

    //draw pdf if available
    if(drawPdf_ && pdfDocument_)
    {
       QSize s(4, 3);
       QRect area = calcDrawArea(s, painter.viewport().size());
       //std::cout << area.x() << ' ' << area.y() << ' ' << area.width() << ' ' << area.height() << std::endl;
       painter.drawImage(area, pdfImage_);
    }

    painter.save();

    //draw the overlay image
    auto size = this->size();
    painter.scale( (qreal)size.width() / (qreal)overlayImage_.width(), (qreal)size.height() / (qreal)overlayImage_.height());
    painter.drawImage(dirtyRect, overlayImage_, dirtyRect);

    //draw temporary stuff
    if(isPainting_ && paintTool_ == PaintToolType::Rectangle)
    {
       QColor color(pen_.color());
       color.setAlpha(100);
       painter.fillRect(rectTool, color);
    }

    painter.restore();
}
Пример #19
0
void PreviewWidget::drawShadow(QPainter &painter, QRectF rect)
{
    // Shadow width
    int width = qBound(4, int(qMax(rect.height(), rect.width())) / 100, 7);

    painter.save();
    painter.setClipRect(rect.adjusted(0, 0, width, width));

    QColor lightColor = this->palette().color(QPalette::Background);
    QColor darkColor  = lightColor.darker(160);

    QRectF shadowRect = rect.adjusted(0, 0, width, width);
    QLinearGradient lg;
    lg.setColorAt(0.0, darkColor);
    lg.setColorAt(1.0, lightColor);


    QRadialGradient rg;
    rg.setColorAt(0, darkColor);
    rg.setColorAt(1, lightColor);
    rg.setRadius(width);


    // Right
    lg.setStart(QPointF(rect.right(), rect.center().y()));
    lg.setFinalStop(QPointF(shadowRect.right(), rect.center().y()));
    painter.fillRect(rect.right(), rect.top() + width, width, rect.height() - width, lg);

    // Bottom
    lg.setStart(rect.center().x(),  rect.bottom());
    lg.setFinalStop(rect.center().x(), rect.bottom() + width);
    painter.fillRect(rect.left() + width, rect.bottom(), rect.width() - width, width, lg);

    //TopRight
    QPointF p;
    p = rect.bottomRight();
    rg.setCenter(p);
    rg.setFocalPoint(p);
    painter.fillRect(rect.right(), rect.bottom(), width, width, rg);

    // BottomRight
    p = rect.topRight();
    p.ry() += width;
    rg.setCenter(p);
    rg.setFocalPoint(p);
    painter.fillRect(rect.right(), rect.top(), width, width, rg);

    //BottomLeft
    p = rect.bottomLeft();
    p.rx() += width;
    rg.setCenter(p);
    rg.setFocalPoint(p);
    painter.fillRect(rect.left(), rect.bottom(), width, width, rg);


    painter.restore();
}
Пример #20
0
void TextureMapperQt::beginClip(const TransformationMatrix& matrix, const FloatRect& rect)
{
    QPainter* painter = currentPainter();
    painter->save();
    QTransform prevTransform = painter->transform();
    painter->setTransform(matrix, false);
    painter->setClipRect(rect);
    painter->setTransform(prevTransform, false);
}
Пример #21
0
void EncloseElement::paint( QPainter& painter, AttributeManager* )
{
    painter.save();
    QPen pen;
    pen.setWidth( 1 );
    painter.setPen( pen );
    painter.drawPath( m_enclosePath );
    painter.restore();
}
Пример #22
0
void PictureBase::draw(QPainter& painter, int x, int y, int width, int height, int, int, int, int, bool /*fastMode*/)
{
    // Draw a light red box (easier DEBUG)
    kWarning(30508) << "Drawing light red rectangle! (PictureBase::draw)";
    painter.save();
    painter.setBrush(QColor(128, 0, 0));
    painter.drawRect(x, y, width, height);
    painter.restore();
}
void KoShapeManagerPaintingStrategy::paint(KoShape * shape, QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &paintContext)
{
    if (d->shapeManager) {
        painter.save();
        painter.setTransform(shape->absoluteTransformation(&converter) * painter.transform());
        d->shapeManager->paintShape(shape, painter, converter, paintContext);
        painter.restore();  // for the matrix
    }
}
Пример #24
0
/**
 * @brief Draw the start position of the bot.
 * @param painter
 */
void RenderArea::drawStartPos(QPainter &painter)
{
    painter.save();
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(Qt::black);
    painter.setBrush(QBrush(Qt::red));
    painter.drawEllipse(this->x() + START_POS_X - BOT_RADIUS, this->y() + START_POS_Y - BOT_RADIUS, 2 * BOT_RADIUS, 2 * BOT_RADIUS);
    painter.restore();
}
void KarbonOutlinePaintingStrategy::paint( KoShape * shape, QPainter &painter, const KoViewConverter &converter, bool )
{
    painter.save();
    painter.setMatrix( shape->absoluteTransformation(&converter) * painter.matrix() );

    m_border->paintBorder( shape, painter, converter );

    painter.restore();
}
Пример #26
0
/**
 * @brief Draw the end point.
 * @param painter
 */
void RenderArea::drawEndPos(QPainter &painter)
{
    painter.save();
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(Qt::black);
    painter.setBrush(QBrush(Qt::blue));
    painter.drawEllipse(END_POS_X - BOT_RADIUS, END_POS_Y - BOT_RADIUS, 2 * BOT_RADIUS, 2 * BOT_RADIUS);
    painter.restore();
}
Пример #27
0
void QgsGlowEffect::draw( QgsRenderContext &context )
{
  if ( !source() || !enabled() || !context.painter() )
    return;

  QImage im = sourceAsImage( context )->copy();

  QgsColorRamp* ramp = nullptr;
  if ( mColorType == ColorRamp && mRamp )
  {
    ramp = mRamp;
  }
  else
  {
    //create a temporary ramp
    QColor transparentColor = mColor;
    transparentColor.setAlpha( 0 );
    ramp = new QgsGradientColorRamp( mColor, transparentColor );
  }

  QgsImageOperation::DistanceTransformProperties dtProps;
  dtProps.spread = mSpread * QgsSymbolLayerUtils::pixelSizeScaleFactor( context, mSpreadUnit, mSpreadMapUnitScale );
  dtProps.useMaxDistance = false;
  dtProps.shadeExterior = shadeExterior();
  dtProps.ramp = ramp;
  QgsImageOperation::distanceTransform( im, dtProps );

  if ( mBlurLevel > 0 )
  {
    QgsImageOperation::stackBlur( im, mBlurLevel );
  }

  QgsImageOperation::multiplyOpacity( im, 1.0 - mTransparency );

  if ( !shadeExterior() )
  {
    //only keep interior portion
    QPainter p( &im );
    p.setRenderHint( QPainter::Antialiasing );
    p.setCompositionMode( QPainter::CompositionMode_DestinationIn );
    p.drawImage( 0, 0, *sourceAsImage( context ) );
    p.end();
  }

  QPainter* painter = context.painter();
  painter->save();
  painter->setCompositionMode( mBlendMode );
  painter->drawImage( imageOffset( context ), im );
  painter->restore();

  if ( !mRamp )
  {
    //delete temporary ramp
    delete ramp;
  }
}
Пример #28
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);
    }
}
Пример #29
0
void MyPlotter::DrawAxisText(QPainter &painter)
{
	painter.save();
	painter.setPen(axis_text_color_);
	QFont textfont(TEXT_FAMILY_AXIS,axis_text_size_);
	painter.setFont(textfont);
	DrawXText(painter);
	DrawYText(painter);
	painter.restore();
}
Пример #30
0
 void operator()
     ( QPainter & painter
     , const DrawTransform & t
     ) const
 {
     painter.save();
     painter.setTransform( t.t, true );
     draw( t.d, painter );
     painter.restore();
 }