void GraphQtInteractiveRenderer::fillPixelRect(int x, int y, 
            int width, int height, Color *color)
    {
        if (!m_data->renderer)
            return;

        int targetWidth = m_data->renderer->widthPixels();
        int targetHeight = m_data->renderer->heightPixels();

        if (x + width < 0 || y + height < 0 || 
                x > targetWidth || y > targetHeight)
            return;

        QPainter *painter = m_data->renderer->painter();
        painter->save();
        painter->fillRect(x, y, width, height, *color);
        painter->restore();
    }
예제 #2
0
// ============================================================================
// Renders AA battery
void AntiAirBattery::render ( QPainter& painter, const QRectF& rect, const RenderingOptions& options )
{
	Machine::render( painter, rect, options );
	
	QTransform t = _bodyMain->transform();
	
	// get angle
	double currentAngle = _sysOperator->currentAngle();
	double lastSign = _lastDisplayedAngle > 0 ? 1 : -1;
	
	// limit angle to min/max
	if ( fabs( currentAngle ) < _sysOperator->minAngle() )
	{
		currentAngle = _sysOperator->minAngle() * lastSign; // don't change sign while outside range
	}
	if (  fabs( currentAngle ) > _sysOperator->maxAngle() )
	{
		currentAngle = _sysOperator->maxAngle() * lastSign;
	}
	
	// check if sign changed
	if ( ( lastSign * currentAngle)  < 0 )
	{
		double x = _bodyMain->position().x;
		_bodyMain->flip( QPointF( x, 1 ), QPointF( x, -1 ) ); // flip around vertical axis
	}
	_lastDisplayedAngle = currentAngle;
	double sign = currentAngle > 0 ? 1 : -1;
	
	// calculate screen angle
	double screenAngle =  M_PI/2 - currentAngle;
	
	painter.save();
		QImage barrel = TextureProvider::loadTexture("installations/flak1-barrel.png").image(Texture::Normal);
		QPointF textureAxis = QPointF( 13, 8 ); // axis in texture coords
		
		double scale = 0.05; // TODO this has to go with texture somehow
		t.rotateRadians( screenAngle );
		t.scale( scale * sign, -scale * sign );
		t.translate( -textureAxis.x(), -textureAxis.y() );
		painter.setTransform( t, true );
		painter.drawImage( 0, 0, barrel );
	painter.restore();
}
예제 #3
0
void QgsSimpleLineSymbolLayerV2::renderPolygonOutline( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context )
{
  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  if ( mDrawInsidePolygon )
  {
    //only drawing the line on the interior of the polygon, so set clip path for painter
    p->save();
    QPainterPath clipPath;
    clipPath.addPolygon( points );

    if ( rings != NULL )
    {
      //add polygon rings
      QList<QPolygonF>::const_iterator it = rings->constBegin();
      for ( ; it != rings->constEnd(); ++it )
      {
        QPolygonF ring = *it;
        clipPath.addPolygon( ring );
      }
    }

    //use intersect mode, as a clip path may already exist (eg, for composer maps)
    p->setClipPath( clipPath, Qt::IntersectClip );
  }

  renderPolyline( points, context );
  if ( rings )
  {
    foreach ( const QPolygonF& ring, *rings )
      renderPolyline( ring, context );
  }

  if ( mDrawInsidePolygon )
  {
    //restore painter to reset clip path
    p->restore();
  }

}
void QgsPointDisplacementRenderer::drawLabels( const QPointF& centerPoint, QgsSymbolV2RenderContext& context, const QList<QPointF>& labelShifts, const QStringList& labelList )
{
  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  QPen labelPen( mLabelColor );
  p->setPen( labelPen );

  //scale font (for printing)
  QFont pixelSizeFont = mLabelFont;
  pixelSizeFont.setPixelSize( context.outputLineWidth( mLabelFont.pointSizeF() * 0.3527 ) );
  QFont scaledFont = pixelSizeFont;
  scaledFont.setPixelSize( pixelSizeFont.pixelSize() * context.renderContext().rasterScaleFactor() );
  p->setFont( scaledFont );

  QFontMetricsF fontMetrics( pixelSizeFont );
  QPointF currentLabelShift; //considers the signs to determine the label position

  QList<QPointF>::const_iterator labelPosIt = labelShifts.constBegin();
  QStringList::const_iterator text_it = labelList.constBegin();

  for ( ; labelPosIt != labelShifts.constEnd() && text_it != labelList.constEnd(); ++labelPosIt, ++text_it )
  {
    currentLabelShift = *labelPosIt;
    if ( currentLabelShift.x() < 0 )
    {
      currentLabelShift.setX( currentLabelShift.x() - fontMetrics.width( *text_it ) );
    }
    if ( currentLabelShift.y() > 0 )
    {
      currentLabelShift.setY( currentLabelShift.y() + fontMetrics.ascent() );
    }

    QPointF drawingPoint( centerPoint + currentLabelShift );
    p->save();
    p->translate( drawingPoint.x(), drawingPoint.y() );
    p->scale( 1.0 / context.renderContext().rasterScaleFactor(), 1.0 / context.renderContext().rasterScaleFactor() );
    p->drawText( QPointF( 0, 0 ), *text_it );
    p->restore();
  }
}
예제 #5
0
void KoPictureClipart::drawQPicture(QPicture& clipart, QPainter& painter,
    int x, int y, int width, int height, int sx, int sy, int sw, int sh)
{
    kdDebug(30003) << "Drawing KoPictureClipart " << this << endl;
    kdDebug(30003) << "  x=" << x << " y=" << y << " width=" << width << " height=" << height << endl;
    kdDebug(30003) << "  sx=" << sx << " sy=" << sy << " sw=" << sw << " sh=" << sh << endl;
    painter.save();
    // Thanks to Harri, Qt3 makes it much easier than Qt2 ;)
    QRect br = clipart.boundingRect();
    kdDebug(30003) << "  Bounding rect. " << br << endl;

    painter.translate(x,y); // Translating must be done before scaling!
    if ( br.width() && br.height() )
        painter.scale(double(width)/double(br.width()),double(height)/double(br.height()));
    else
        kdWarning(30003) << "Null bounding rectangle: " << br.width() << " x " << br.height() << endl;
    painter.drawPicture(0,0,clipart);
    painter.restore();
}
예제 #6
0
void AccumulateEnergy::DrawRulerDV(QPainter &painter)
{
    //根据数据中的最大事件数确定纵坐标范围

    painter.setFont(QFont(QObject::tr("WenQuanYi"),8));

    float x = draw_area_range.left();
    float y = draw_area_range.bottom();
    int tmaxeventnum = maxeventnum_;
    if (tmaxeventnum == 0)
    {
        tmaxeventnum = 1;
    }

    tmaxeventnum = std::pow(10,std::log10(tmaxeventnum));

    float step = dheight_ / ENERGYDYRULERFACTORY;
    float diff = maxeventnum_ / ENERGYDYRULERFACTORY;
    float vindex = 0;
    float count = 0;
    while (vindex <= dheight_)
    {
        painter.drawLine(x,y - vindex + 1,x - 2,y - vindex + 1);
        float width = painter.fontMetrics().width(QString::number(count));
        float height = painter.fontMetrics().height();
        int p = std::floor(count);
        painter.drawText(QRectF(x-4 - width,y-vindex + 1 - height*0.5,width,height),Qt::AlignRight,QString::number(p));
        vindex += step;

        if (vindex < dheight_)
        {
            painter.save();
            QPen pen;
            pen.setStyle(Qt::DashLine);
            pen.setColor(QColor(Qt::gray));
            pen.setWidthF(1.2);
            painter.setPen(pen);
            painter.drawLine(x,y - vindex + 1,x + draw_area_range.width(),y - vindex + 1);
            painter.restore();
        }
        count +=diff;
    }
}
예제 #7
0
void PaintUtils::DrawArrow(QPainter &painter,
                           const QPointF &start,
                           const QPointF &end,
                           int bevel_length,
                           GFLOAT64 bevel_angle,
                           const QColor &color,
                           int thickness)
{
    if(bevel_angle >= 90)
        throw Exception<>("No angles over 90 degrees");

    painter.save();
    QPen pen(color);
    pen.setWidth(thickness);
    painter.setPen(pen);

    // Draw the arrow main line
    painter.drawLine(start, end);

    // Draw the pointy part of the arrow

    // First create a vector from the two points and find its unit vector
    EuclideanVector2<GFLOAT64> v(start.x(), start.y(), end.x(), end.y());
    EuclideanVector2<GFLOAT64> unit = v.UnitVector();

    // Find the base of the point triangle
    EuclideanVector2<GFLOAT64> bevel_base(v - (unit * (cos(bevel_angle*G_PI/180)*bevel_length)));

    // Find the orthogonal vector which takes us to the two points of the triangle
    EuclideanVector2<GFLOAT64> d = unit.Orthogonal()*(sin(bevel_angle*G_PI/180)*bevel_length);

    // The two points we need are the bevel_base +- the orthogonal vector
    EuclideanVector2<GFLOAT64> pt = bevel_base + d;

    // Don't forget to offset by the start point, since the euclidean vector is based at the origin
    painter.drawLine(end, QPointF(start.x() + pt.GetX(), start.y() + pt.GetY()));

    // Draw the line on the opposite side
    pt = bevel_base - d;
    painter.drawLine(end, QPointF(start.x() + pt.GetX(), start.y() + pt.GetY()));

    painter.restore();
}
void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
{
    if (paintingDisabled())
        return;

    if (npoints <= 1)
        return;

    QPolygonF polygon(npoints);

    for (size_t i = 0; i < npoints; i++)
        polygon[i] = points[i];

    QPainter *p = m_data->p();
    p->save();
    p->setRenderHint(QPainter::Antialiasing, shouldAntialias);
    p->drawConvexPolygon(polygon);
    p->restore();
}
예제 #9
0
void counterWidget::paintItself(QPainter& inp)
{
    inp.save();
        int w_width = inp.window().width();
        int w_height = inp.window().height();
        // first let's draw ownership
        inp.setBrush(QBrush(Qt::NoBrush));
        if(ownerPresent_m) inp.setBrush(QBrush(playerColor2QColor(frameColor_m), Qt::Dense5Pattern));
        if(mortgage_m) inp.setBrush(QBrush(Qt::gray, Qt::Dense5Pattern));
        inp.drawRect(0, 0, w_width, w_height); // outer rectangle
        // now we need to draw counter pattern
        inp.setBrush(QBrush(Qt::blue, Qt::VerPattern));
        QRect patternRectangle(frameWidth_m, frameWidth_m, w_width- 2*frameWidth_m,
                        w_height - 2*frameWidth_m);
        inp.drawRect(patternRectangle);
        // now we need to draw name
        inp.drawText(patternRectangle, name_m, QTextOption(Qt::AlignTop| Qt::AlignHCenter));
    inp.restore();
}
예제 #10
0
파일: qgraph.cpp 프로젝트: kolzar/sail7
void QGraph::DrawGraph(QPainter &painter)
{
	static QColor color;
	painter.save();

//	Paint background
//	QBrush bg(m_BkColor);
//	painter.setBackground(bg);

//	Draw Border
	if(m_bBorder) color = m_BorderColor;
	else          color = m_BkColor;
	QPen BorderPen(color);
	BorderPen.setStyle(GetStyle(m_BorderStyle));
	BorderPen.setWidth(m_BorderWidth);

	painter.setPen(BorderPen);
	painter.fillRect(m_rCltRect, m_BkColor);
	painter.drawRect(m_rCltRect);
	Init();

	painter.setClipRect(m_rCltRect);

	painter.setBackgroundMode(Qt::TransparentMode);

	if(m_bXMinGrid) DrawXMinGrid(painter);
	if(m_bYMinGrid) DrawYMinGrid(painter);
	if(m_bXMajGrid) DrawXMajGrid(painter);
	if(m_bYMajGrid) DrawYMajGrid(painter);

	DrawAxes(painter);

	DrawXTicks(painter);

	DrawYTicks(painter);

	for (int nc=0; nc < m_oaCurves.size(); nc++)	DrawCurve(nc,painter);

	DrawTitles(painter);

	painter.setClipping(false);
	painter.restore();
}
예제 #11
0
void KoPAPageBase::paintBackground( QPainter & painter, const KoViewConverter & converter, KoShapePaintingContext &paintContext )
{
    painter.save();
    applyConversion( painter, converter );
    KoPageLayout layout = pageLayout();
    painter.setPen( Qt::black );

    if (background()) {
        QPainterPath p;
        p.addRect( QRectF( 0.0, 0.0, layout.width, layout.height ) );
        background()->paint( painter, converter, paintContext, p );
    }
    else {
        painter.setBrush(Qt::white);
        painter.drawRect(QRectF(0.0, 0.0, layout.width, layout.height));
    }

    painter.restore();
}
예제 #12
0
void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine)
{
#if PLATFORM(QT)
    QImage image(reinterpret_cast<const uchar*>(data), targetRect.width(), targetRect.height(), bytesPerLine, NativeImageQt::defaultFormatForAlphaEnabledImages());

    QPainter* painter = m_image->context()->platformContext();
    painter->save();
    painter->setCompositionMode(QPainter::CompositionMode_Source);
    painter->drawImage(targetRect, image, IntRect(sourceOffset, targetRect.size()));
    painter->restore();
#elif PLATFORM(CAIRO)
    RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(static_cast<unsigned char*>(data()),
                                                                                   CAIRO_FORMAT_ARGB32,
                                                                                   targetRect.width(), targetRect.height(),
                                                                                   bytesPerLine));
    m_image->context()->platformContext()->drawSurfaceToContext(surface.get(), targetRect,
                                                                IntRect(sourceOffset, targetRect.size()), m_image->context());
#endif
}
예제 #13
0
void NavyPainter::drawGrid(QPainter & painter)
{
    painter.save();

    painter.translate(50,85);

    QPen pen(Qt::DashLine);
    pen.setColor(Qt::white);
    painter.setPen(pen);

    const double w = m_w/2.5;
    const double s = w/10;

    QString alpha = tr("АБВГДЕЖЗИК ");

    for(int i=0; i<= 10; i++)
    {
        painter.drawLine(i* s, 0, i * s , w);
        painter.drawText(i* s + 10, -10, QString(alpha[i]));
    }
    for(int i=0; i<= 10; i++)
    {
        painter.drawLine(0, i* s, w, i * s );
        if(i<10)
        painter.drawText(-15, i*s + 20, QString::number(i+1));
    }

    painter.translate(300,0);

    for(int i=0; i<= 10; i++)
    {
        painter.drawLine(i* s, 0, i * s , w);
        painter.drawText(i* s + 10, -10, QString(alpha[i]));
    }
    for(int i=0; i<= 10; i++)
    {
        painter.drawLine(0, i* s, w, i * s );
        if(i<10)
        painter.drawText(-15, i*s + 20, QString::number(i+1));
    }
    painter.restore();
}
예제 #14
0
파일: UmlCanvas.cpp 프로젝트: kralf/bouml
void UmlCanvas::drawBackground(QPainter& painter, const QRect& clip) {
  if (show_grid()) {
    int s = grid_size();
    
    qreal left = int(clip.left())-(int(clip.left()) % s);
    qreal top = int(clip.top())-(int(clip.top()) % s);
    
    QVarLengthArray<QLineF, 100> lines;
    
    for (qreal x = left; x < clip.right(); x += s)
      lines.append(QLineF(x, clip.top(), x, clip.bottom()));
    for (qreal y = top; y < clip.bottom(); y += s)
      lines.append(QLineF(clip.left(), y, clip.right(), y));
    
    painter.save();
    painter.setPen(Qt::lightGray);
    painter.drawLines(lines.data(), lines.size());
    painter.restore();
  }
}
예제 #15
0
void KWCanvasBase::paintBorder(QPainter &painter, KWViewMode::ViewMap &viewMap)
{
    painter.save();

    const QRectF       pageRect = viewMap.page.rect();
    const KoPageLayout pageLayout = viewMap.page.pageStyle().pageLayout();

    qreal zoomX, zoomY;
    viewConverter()->zoom(&zoomX, &zoomY);
    painter.scale(zoomX, zoomY);

    QPointF topLeftCorner = QPointF(pageRect.topLeft() + QPointF(pageLayout.leftMargin,
                                                                 pageLayout.topMargin));
    QPointF bottomRightCorner = QPointF(pageRect.bottomRight() + QPointF(-pageLayout.rightMargin,
                                                                         -pageLayout.bottomMargin));
    QRectF borderRect = QRectF(topLeftCorner, bottomRightCorner);
    pageLayout.border.paint(painter, borderRect);

    painter.restore();
}
예제 #16
0
    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();
    }
예제 #17
0
파일: find.cpp 프로젝트: vprus/vis3
    QRect xdraw(QPainter& painter)
    {
        if (!rect.isValid())
            return QRect();

        painter.save();

        QColor halfRed(Qt::red);
        halfRed.setAlpha(75);
        painter.setBrush(halfRed);
        painter.setPen(QPen(Qt::red, 2));

        painter.drawRect(rect);
        QRect r = rect;
        r.adjust(-2, -2, 2, 2);

        painter.restore();

        return r;
    }
예제 #18
0
void QgsLineSymbolV2::renderPolylineUsingLayer( QgsLineSymbolLayerV2 *layer, const QPolygonF &points, QgsSymbolV2RenderContext &context )
{
  QgsPaintEffect* effect = layer->paintEffect();
  if ( effect && effect->enabled() )
  {
    QPainter* p = context.renderContext().painter();
    p->save();
    p->translate( points.boundingRect().topLeft() );

    effect->begin( context.renderContext() );
    layer->renderPolyline( points.translated( -points.boundingRect().topLeft() ), context );
    effect->end( context.renderContext() );

    p->restore();
  }
  else
  {
    layer->renderPolyline( points, context );
  }
}
예제 #19
0
	void FileSharingWidget::renderFilename(QPainter &p)
	{
		assert(!Metainfo_.Filename_.isEmpty());

		p.save();

        QFont font = Utils::appFont(Utils::FontsFamily::SEGOE_UI, Utils::scale_value(16));

		p.setFont(font);
		p.setPen(QColor(0x282828));

		auto x = downloadButton().GetWidth();
		x += Utils::scale_value(12);

		auto y = Utils::scale_value(29);

		p.drawText(x, y, Metainfo_.Filename_);

		p.restore();
	}
예제 #20
0
void Template::draw( QPainter & p )
{
    // exit immediatelly when we are not visible
    if( ! isVisible() ) return;

    //qWarning( "Template[%d]::draw: visible %d, canvas %d",
    //       (unsigned)this, isVisible(),(unsigned)canvas() );

    //qWarning( "Template[%d]::draw: my rect is %d, %d %dx%d",
    //       (unsigned)this, r.left(), r.top(), r.width(), r.height() );
    //qWarning( "enab=%d, sel=%d, act=%d", isEnabled(), isSelected(),
    //        isActive() );

    p.save();

    // paint us
    drawShape( p );

    p.restore();
}
예제 #21
0
void StInterp2::draw(ImageView *view, QPainter &p, int pass) {
    Module::draw(view, p, pass);

    QRectF R = p.clipBoundingRect();
    QRect aR = R.toAlignedRect().intersected(view->image().rect());
    double pt = view->pt2px(1);

    if (view->zoom() > 10) {
        p.save();
        p.scale(1.0/nx, 1.0/ny);
        p.setPen(QPen(Qt::red, nx*0.25*pt));
        cpu_image st2 = publishedImage("st2");
        draw_minor_eigenvector_field(p, st2, QRect(aR.x()*nx, aR.y()*ny, aR.width()*nx, aR.height()*ny));
        p.restore();

        p.setPen(QPen(Qt::blue, 0.5*pt));
        cpu_image st = publishedImage("st");
        draw_minor_eigenvector_field(p, st, aR);
    }
}
예제 #22
0
void ConnectionTool::paint(QPainter &painter, const KoViewConverter &converter)
{
    // get the correctly sized rect for painting handles
    QRectF handleRect = handlePaintRect(QPointF());

    painter.setRenderHint(QPainter::Antialiasing, true);
    // Green rects
    if(m_shapeOn !=  0) {
        // save the painter to restore it later
        painter.save();
        // Apply the conversion make by the matrix transformation
        QTransform transform = m_shapeOn->absoluteTransformation(0);
        KoShape::applyConversion(painter, converter);
        foreach(const QPointF &point, m_shapeOn->connectionPoints())
        { // Draw all the connection point of the shape
            handleRect.moveCenter(transform.map(point));
            painter.fillRect(handleRect, QColor(Qt::darkGreen));
        }
        painter.restore();
    }
void KPrShapeManagerAnimationStrategy::paint( KoShape * shape, QPainter &painter, const KoViewConverter &converter, bool forPrint )
{
    if ( ! dynamic_cast<KPrPlaceholderShape *>( shape ) && m_strategy->page()->displayShape( shape ) ) {
        if ( m_animationCache->value(shape, "visibility", true).toBool() ) {
            painter.save();
            QTransform animationTransform = m_animationCache->value(shape, "transform", QTransform()).value<QTransform>();;
            QTransform transform(painter.transform() * shape->absoluteTransformation(&converter));
            if (animationTransform.isScaling()) {
                transform = animationTransform * transform;
            } else {
                transform = transform * animationTransform;
            }

            painter.setTransform(transform);
            // paint shape
            shapeManager()->paintShape( shape, painter, converter, forPrint );
            painter.restore();  // for the transform
        }
    }
}
예제 #24
0
void TankGameWidget::PaintText(const ScreenText& txt, QPainter& painter)
{
    if (txt.Finished())
    {
        return; //shall not be rendered now
    }

    painter.save();
    painter.setPen(txt.Pen());
    QFont font=painter.font();
    font.setPixelSize(txt.FontSize());
    font.setBold(true);
    painter.setFont(font);

    int rowStep=3*txt.FontSize();

    if (txt.Position().x()<0 || txt.Position().y()<0)
    {
        int xPos=txt.Position().x();
        int yPos=txt.Position().y();
        if (xPos<0) xPos=0;
        if (yPos<0) yPos=0;
        QRect rect(xPos, yPos, m_const.boardPixelSizeFloat.x(), txt.FontSize());
        for (const QString& s : txt.Text())
        {
            painter.drawText(rect, Qt::AlignCenter, s);
            rect.setY(rect.y()+rowStep);
        }
    }
    else
    {
        auto pos=ToScreen(txt.Position(), 0, 0);
        for (const QString& s : txt.Text())
        {
            painter.drawText(pos, s);
            pos.setY(pos.y()+rowStep);
        }
    }

    painter.restore();
}
예제 #25
0
void ColorWheel::drawIndicator(QPainter &painter) {
    const int hue = currentColor_.hue();

    if (hue > 20 && hue < 200)
        painter.setPen(Qt::black);
    else
        painter.setPen(Qt::white);

    painter.save();
    painter.setBrush(Qt::NoBrush);
    QPen pen = painter.pen();
    pen.setWidth(2);
    pen.setCosmetic(true);
    painter.setPen(pen);
    qreal r = qMin(height(), width()) / 2.0;
    painter.translate(r, r);
    painter.rotate(-hue);
    r = qMin(height(), width()) / 2.0 - margin_ - wheelWidth_/2;
    painter.drawEllipse(QPointF(r,0.0),5,5);
    painter.restore();
}
예제 #26
0
void Shape2D::draw(QPainter& painter) const
{
  painter.setPen(m_color);
  this->drawShape(painter);
  if (m_editing)
  {
    QColor c(255,255,255,100);
    painter.setPen(c);
    painter.setCompositionMode(QPainter::CompositionMode_Plus);
    painter.drawRect(m_boundingRect.toQRectF());
    for(size_t i = 0; i < getNControlPoints(); ++i)
    {
      QPointF p = painter.transform().map(getControlPoint(i));
      QRectF r(p - QPointF(sizeCP,sizeCP),p + QPointF(sizeCP,sizeCP));
      painter.save();
      painter.resetTransform();
      painter.fillRect(r,c);
      painter.restore();
    }
  }
}
예제 #27
0
void KoShapeShadow::Private::paintShadow(KoShape *shape, QPainter &painter, const KoViewConverter &converter)
{
    QPainterPath path(shape->shadowOutline());
    if (!path.isEmpty()) {
        painter.save();
        KoShape::applyConversion(painter, converter);
        painter.setBrush(QBrush(color));

        // Make sure the shadow has the same fill rule as the shape.
        KoPathShape * pathShape = dynamic_cast<KoPathShape*>(shape);
        if (pathShape)
            path.setFillRule(pathShape->fillRule());

        painter.drawPath(path);
        painter.restore();
    }

    if (shape->stroke()) {
        shape->stroke()->paint(shape, painter, converter);
    }
}
예제 #28
0
void BrushEngine::paintDab(const QPointF& point, QPainter& painter) {
    painter.save();
    painter.translate(point);
    painter.rotate(angle);
    painter.scale(1, roundness / 100.0);
    QRectF rect(-size / 2.0, -size / 2.0, size, size);
    painter.drawEllipse(rect);
    painter.restore();
    rect.moveTo(point.x() - size / 2.0, point.y() - size / 2.0);
    if (eraser > 50) {
        canvasItem->update(rect.toRect());
    } else {
        canvasBuffer->update(rect.toRect());
    }

    // Detect a min and max corner positions
    bottomright.setX(qMax(bottomright.x(), qRound(point.x())));
    bottomright.setY(qMax(bottomright.y(), qRound(point.y())));
    topleft.setX(qMin(topleft.x(), qRound(point.x())));
    topleft.setY(qMin(topleft.y(), qRound(point.y())));
}
예제 #29
0
void StickyLink::paint(QPainter &p){
    p.setPen(Qt::red);
    if (!joint || !goo) return;
    p.drawLine(goo->getPPosition(),toPoint(joint->GetAnchorB()));
    QPoint m=(goo->getPPosition()+toPoint(joint->GetAnchorB()))/2;
    int x,y;
    if (goo->getPPosition().x()<joint->GetAnchorB().x){
        x=joint->GetAnchorB().x-goo->getPPosition().x();
        y=joint->GetAnchorB().y-goo->getPPosition().y();
    }
    else {
        x=goo->getPPosition().x()-joint->GetAnchorB().x;
        y=goo->getPPosition().y()-joint->GetAnchorB().y;
    }
    float r=atan2(static_cast<float>(y),static_cast<float>(x));
    p.save();
    p.translate(m);
    p.rotate(r);
    p.drawText(0,0,QString::number((joint->GetReactionForce(1.0/60).y<0? -1:+1)*joint->GetReactionForce(1.0/60).Length()));
    p.restore();
}
예제 #30
0
void KarbonPatternTool::paint(QPainter &painter, const KoViewConverter &converter)
{
    painter.setBrush(Qt::green);   //TODO make configurable
    painter.setPen(Qt::blue);   //TODO make configurable

    // paint all the strategies
    foreach(KarbonPatternEditStrategyBase *strategy, m_strategies) {
        if (strategy == m_currentStrategy)
            continue;

        painter.save();
        strategy->paint(painter, converter);
        painter.restore();
    }

    // paint selected strategy with another color
    if (m_currentStrategy) {
        painter.setBrush(Qt::red);   //TODO make configurable
        m_currentStrategy->paint(painter, converter);
    }
}