当前位置: 首页>>代码示例>>C++>>正文


C++ QPainter::setClipping方法代码示例

本文整理汇总了C++中QPainter::setClipping方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::setClipping方法的具体用法?C++ QPainter::setClipping怎么用?C++ QPainter::setClipping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPainter的用法示例。


在下文中一共展示了QPainter::setClipping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateGC

void nsRenderingContextQt::UpdateGC()
{
  QPainter *pGC;
  QColor color(NS_GET_R(mCurrentColor),
               NS_GET_G(mCurrentColor),
               NS_GET_B(mCurrentColor));
  QPen   pen(color,0,mQLineStyle);
  QBrush brush(color);

  pGC = mSurface->GetGC();
  pGC->setPen(pen);
  pGC->setBrush(brush);
  pGC->setRasterOp(mFunction);
  if (mCurrentFont)
    pGC->setFont(mCurrentFont->font);
  if (mClipRegion) {
     QRegion *rgn = nsnull;

     pGC->setClipping(TRUE);
     mClipRegion->GetNativeRegion((void*&)rgn);
     pGC->setClipRegion(*rgn);
  }
  else {
    pGC->setClipping(FALSE);
  }
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:26,代码来源:nsRenderingContextQt.cpp

示例2: drawMarker

void MapWidget::drawMarker(const MapMarker &marker, QPainter &painter, const QPointF &markerPosition, const QPointF &rectPosition)
{
    QRectF markerRect = getMarkerRect(marker, rectPosition);

    QColor bgColor = getMarkerTextBackgroundColor();
    painter.setBrush(QBrush(bgColor));

    // drawing the line connector
    painter.setPen(bgColor);
    painter.setClipping(true);
    painter.setClipRegion(QRegion(rect()).subtracted(markerRect.toRect()));
    painter.drawLine(markerRect.center(), markerPosition);

    // drawing the transparent background
    painter.setClipping(false);
    painter.setPen(Qt::NoPen);
    painter.drawRect(markerRect);

    // drawing the player marker
    const static qreal markerSize = 1.6;
    painter.setBrush(getMarkerColor());
    painter.drawEllipse(markerPosition, markerSize, markerSize);

    qreal hOffset = rectPosition.x() + TEXT_MARGIM; // left margin

    // draw the player name text
    QString playerName = marker.getPlayerName();
    painter.setFont(userFont);

    QFontMetrics metrics = painter.fontMetrics();
    qreal playerNameWidth = metrics.width(playerName);
    painter.setPen(getMarkerTextColor());
    qreal textY = rectPosition.y() + TEXT_MARGIM + metrics.descent()/2.0;
    painter.drawText(hOffset, textY, playerName);
    hOffset += playerNameWidth + TEXT_MARGIM * 3;

    // draw the player country name
    painter.setFont(countryFont);
    metrics = painter.fontMetrics();

    QColor countryNameColor(getMarkerTextColor());
    countryNameColor.setAlpha(180); // country name is drawed using some alpha
    painter.setPen(countryNameColor);
    QString countryName = marker.getCountryName();
    painter.drawText(hOffset, textY, countryName);

    hOffset += metrics.width(countryName);

    painter.setFont(userFont); //restore the normal font
    metrics = painter.fontMetrics();

    // draw the player country flag
    const QImage &image = marker.getFlag();
    qreal imageX = hOffset + TEXT_MARGIM;
    qreal imageY = rectPosition.y() - image.height()/2.0;
    painter.drawImage(QPointF(imageX, imageY), image);
}
开发者ID:elieserdejesus,项目名称:JamTaba,代码行数:57,代码来源:MapWidget.cpp

示例3: drawPiece

QPixmap ImageProcessor::drawPiece(int i, int j, const QPainterPath &shape, const Puzzle::Creation::Correction &corr)
{
    QPainter p;
    QPixmap px(_p->descriptor.unitSize.width() + corr.widthCorrection + 1,
               _p->descriptor.unitSize.height() + corr.heightCorrection + 1);
    px.fill(Qt::transparent);

    p.begin(&px);
    p.setRenderHint(QPainter::SmoothPixmapTransform);
    p.setRenderHint(QPainter::Antialiasing);
    p.setRenderHint(QPainter::HighQualityAntialiasing);
    p.setClipping(true);
    p.setClipPath(shape);

    p.drawPixmap(_p->descriptor.tabFull + corr.xCorrection + corr.sxCorrection,
                 _p->descriptor.tabFull + corr.yCorrection + corr.syCorrection,
                 _p->pixmap,
                 i * _p->descriptor.unitSize.width() + corr.sxCorrection,
                 j * _p->descriptor.unitSize.height() + corr.syCorrection,
                 _p->descriptor.unitSize.width() * 2,
                 _p->descriptor.unitSize.height() * 2);

    p.end();
    return px;
}
开发者ID:Jornason,项目名称:puzzle-master,代码行数:25,代码来源:imageprocessor.cpp

示例4: drawAmplitude

void AFCWidget::drawAmplitude(QPainter & painter, QRectF rect)
{
	if(m_dB_points.size()<2) return;

	painter.setClipping(true);
	painter.setClipRect(rect);
	painter.setRenderHint(QPainter::Antialiasing, true);
	

	//amplitude
	painter.setPen( QPen(QColor(0, 0, 0, 255)) );

	float prev_x=m_dB_points.first().x();
	float prev_y=m_dB_points.first().y();

	float dB_range = m_dB2-m_dB1;

	foreach(QPointF p, m_dB_points){
//		QPointF p1( rect.left()+log_coef*log10(prev_x-m_freq1)/freq_range*rect.width(), rect.bottom()-(prev_y-m_dB1)/dB_range*rect.height() );
//		QPointF p2( rect.left()+log_coef*log10(p.rx()-m_freq1)/freq_range*rect.width(), rect.bottom()-(p.ry()-m_dB1)/dB_range*rect.height() );

		//linear scale
//		QPointF p1( rect.left()+(prev_x-m_freq1)/(m_freq2-m_freq1)*rect.width(), rect.bottom()-(prev_y-m_dB1)/dB_range*rect.height() );
//		QPointF p2( rect.left()+(p.rx()-m_freq1)/(m_freq2-m_freq1)*rect.width(), rect.bottom()-(p.ry()-m_dB1)/dB_range*rect.height() );

		//log scale
		QPointF p1( rect.left()+logFreq(prev_x)*rect.width(), rect.bottom()-(prev_y-m_dB1)/dB_range*rect.height() );
		QPointF p2( rect.left()+logFreq(p.rx())*rect.width(), rect.bottom()-(p.ry()-m_dB1)/dB_range*rect.height() );


		if(p.x() <= m_freq2) painter.drawLine(p1, p2);
		prev_x = p.rx();
		prev_y = p.ry();
	}
开发者ID:mofr,项目名称:AmplitubeTime,代码行数:34,代码来源:afc_widget.cpp

示例5: platformTransformColorSpace

void ImageBufferDataPrivateAccelerated::platformTransformColorSpace(const Vector<int>& lookUpTable)
{
    QPainter* painter = paintDevice()->paintEngine()->painter();

    QImage image = toQImage().convertToFormat(QImage::Format_ARGB32);
    ASSERT(!image.isNull());

    uchar* bits = image.bits();
    const int bytesPerLine = image.bytesPerLine();

    for (int y = 0; y < image.height(); ++y) {
        quint32* scanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine);
        for (int x = 0; x < image.width(); ++x) {
            QRgb& pixel = scanLine[x];
            pixel = qRgba(lookUpTable[qRed(pixel)],
                          lookUpTable[qGreen(pixel)],
                          lookUpTable[qBlue(pixel)],
                          qAlpha(pixel));
        }
    }

    painter->save();
    painter->resetTransform();
    painter->setOpacity(1.0);
    painter->setClipping(false);
    painter->setCompositionMode(QPainter::CompositionMode_Source);
    // Should coordinates be flipped?
    painter->drawImage(QPoint(0,0), image);
    painter->restore();
}
开发者ID:Metrological,项目名称:qtwebkit,代码行数:30,代码来源:ImageBufferQt.cpp

示例6: paintFrame

void UIPopupPane::paintFrame(QPainter &painter)
{
    /* Paint frame: */
    QColor currentColor(palette().color(QPalette::Window).darker(150));
    QPainterPath path = painter.clipPath();
    painter.setClipping(false);
    painter.strokePath(path, currentColor);
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:8,代码来源:UIPopupPane.cpp

示例7: rect

void
PlayField::paintPainterClip(QPainter &paint, int x, int y, int w, int h) {
  QRect rect(x, y, w, h);

  paint.setClipRect(rect);
  paint.setClipping(true);
  paintPainter(paint, rect);
}
开发者ID:KDE,项目名称:ksokoban,代码行数:8,代码来源:PlayField.cpp

示例8: DrawTextClipped

void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase,
        const char *s, int len, ColourDesired fore, ColourDesired back)
{
    Q_ASSERT(painter);

    SetClip(rc);
    DrawTextNoClip(rc, font_, ybase, s, len, fore, back);
    painter->setClipping(false);
}
开发者ID:Snake174,项目名称:PipmakAssistant,代码行数:9,代码来源:PlatQt.cpp

示例9: print

void ItemDocument::print() {
	static KPrinter *printer = new KPrinter;

	if (! printer->setup(KTechlab::self()))
		return;

	// setup the printer.  with Qt, you always "print" to a
	// QPainter.. whether the output medium is a pixmap, a screen,
	// or paper
	QPainter p;
	p.begin(printer);

	// we let our view do the actual printing
	QPaintDeviceMetrics metrics(printer);

	// Round to 16 so that we cut in the middle of squares
	int w = metrics.width();
	w = (w & 0xFFFFFFF0) + ((w << 1) & 0x10);

	int h = metrics.height();
	h = (h & 0xFFFFFFF0) + ((h << 1) & 0x10);

	p.setClipping(true);
	p.setClipRect(0, 0, w, h, QPainter::CoordPainter);

	// Send off the painter for drawing
	m_canvas->setBackgroundPixmap(0);
	QRect bounding = canvasBoundingRect();

	unsigned int rows = (unsigned) std::ceil(double(bounding.height()) / double(h));
	unsigned int cols = (unsigned) std::ceil(double(bounding.width()) / double(w));

	int offset_x = bounding.x();
	int offset_y = bounding.y();

	for (unsigned row = 0; row < rows; ++row) {
		for (unsigned col = 0; col < cols; ++col) {
			if (row != 0 || col != 0)
				printer->newPage();

			QRect drawArea(offset_x + (col * w), offset_y + (row * h), w, h);

			m_canvas->drawArea(drawArea, & p);

			p.translate(-w, 0);
		}

		p.translate(w * cols, -h);
	}

	updateBackground();

	// and send the result to the printer
	p.end();
}
开发者ID:zoltanp,项目名称:ktechlab-0.3,代码行数:55,代码来源:itemdocument.cpp

示例10: paintEvent

void SeekGraph::paintEvent ( QPaintEvent* event )
{
    QFrame::paintEvent( event );
    QPainter p;

     p.begin( this );
     p.setRenderHint( QPainter::Antialiasing, antialiasing() );
     p.fillRect( rect(), backgroundColor() );
     p.translate( leftPadding() + 0.5, topPadding() + 0.5 );

     p.setClipping( false );
     drawAxes( &p );

     setPixRect();
     p.setClipRect( pixRect() );
     p.setClipping( true );

     resetPlotMask();

     foreach( KPlotObject *po, plotObjects() )
     {
       po->draw( &p, this );
     }
开发者ID:leaderwing,项目名称:test_repo,代码行数:23,代码来源:seekgraph.cpp

示例11: roundedPoint

void ossimGui::ImageScrollWidget::drawCursor(QPainter& painter)
{
   if(!m_trackPoint.hasNans())
   {
      ossimIpt roundedPoint(m_trackPoint);
      bool hasClipping = painter.hasClipping();
      painter.setClipping(false);
      painter.setPen(QColor(255, 255, 255));
      
      ossimIrect rect(0,0,size().width()-1, size().height()-1);
      // ossimIpt ul = rect.ul();
      // ossimIpt lr = rect.lr();
      int left   = rect.ul().x;
      int right  = rect.lr().x;
      int top    = rect.ul().y;
      int bottom = rect.lr().y;
      if(rect.pointWithin(roundedPoint))
      {
         // draw horizontal
         //
         int x1 = left;
         int x2 = right;
         int y1  = roundedPoint.y;
         int y2  = y1;
         painter.drawLine(x1, y1, x2, y2);
         
         // draw vertical
         x1 = roundedPoint.x;
         x2 = x1;
         y1 = top;
         y2 = bottom;
         painter.drawLine(x1, y1, x2, y2);
      }
      painter.setClipping(hasClipping);
   }
   m_oldTrackPoint = m_trackPoint;
}
开发者ID:Dukeke,项目名称:ossim,代码行数:37,代码来源:ImageWidget.cpp

示例12: drawOutline

/*!
  draw an outline

  \warning Outlining functionality is obsolete: use QwtPlotPicker or
  QwtPlotZoomer.
*/
void QwtPlotCanvas::drawOutline(QPainter &p)
{
    const QRect &r = contentsRect();

    QColor bg = ((QwtPlot *)parent())->canvasBackground();

    QPen pn = d_pen;
    pn.setColor(QColor(bg.rgb() ^ d_pen.color().rgb()));

    p.setPen(pn);
    p.setRasterOp(XorROP);
    p.setClipRect(r);
    p.setClipping(TRUE);

    switch(d_outline)
    {
        case Qwt::VLine:
            QwtPainter::drawLine(&p, d_lastPoint.x(), 
                r.top(), d_lastPoint.x(), r.bottom());
            break;
        
        case Qwt::HLine:
            QwtPainter::drawLine(&p, r.left(), 
                d_lastPoint.y(), r.right(), d_lastPoint.y());
            break;
        
        case Qwt::Cross:
            QwtPainter::drawLine(&p, r.left(), 
                d_lastPoint.y(), r.right(), d_lastPoint.y());
            QwtPainter::drawLine(&p, d_lastPoint.x(), 
                r.top(), d_lastPoint.x(), r.bottom());
            break;

        case Qwt::Rect:
            QwtPainter::drawRect(&p, d_entryPoint.x(), d_entryPoint.y(),
               d_lastPoint.x() - d_entryPoint.x() + 1,
               d_lastPoint.y() - d_entryPoint.y() + 1);
            break;
        
        case Qwt::Ellipse:
            p.drawEllipse(d_entryPoint.x(), d_entryPoint.y(),
               d_lastPoint.x() - d_entryPoint.x() + 1,
               d_lastPoint.y() - d_entryPoint.y() + 1);
            break;

        default:
            break;
    }
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:55,代码来源:qwt_plot_canvas.cpp

示例13: polishImage

 /**
  * Makes the corners of the image rounded
  */
 QImage polishImage(const QImage &img)
 {
     const int sz = 48 * 4;
     QImage roundedImage = QImage(QSize(sz, sz), QImage::Format_ARGB32_Premultiplied);
     roundedImage.fill(Qt::transparent);
     QPainter p;
     p.begin(&roundedImage);
     QPainterPath clippingPath;
     QRectF imgRect = QRectF(QPoint(0, 0), roundedImage.size());
     clippingPath.addRoundedRect(imgRect, 24, 24);
     p.setClipPath(clippingPath);
     p.setClipping(true);
     p.drawImage(QRectF(QPointF(0, 0), roundedImage.size()), img);
     return roundedImage;
 }
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:18,代码来源:imageprovider.cpp

示例14: render

void NativeRenderDialog::render(QPainter& P, QRect theR, RendererOptions opt)
{
    P.setClipRect(theR);
    P.setClipping(true);
    P.setRenderHint(QPainter::Antialiasing);

    mapview->setGeometry(theR);
    mapview->setViewport(boundingBox(), theR);
    mapview->setRenderOptions(opt);
    mapview->invalidate(true, true, false);
    mapview->drawFeaturesSync(P);
    if (opt.options & RendererOptions::ScaleVisible)
        mapview->drawScale(P);
    if (opt.options & RendererOptions::LatLonGridVisible)
        mapview->drawLatLonGrid(P);
}
开发者ID:chxyfish,项目名称:merkaartor,代码行数:16,代码来源:NativeRenderDialog.cpp

示例15: print

void ClusterView::print(QPainter& printPainter,QPaintDeviceMetrics& metrics,bool whiteBackground){
 //Draw the double buffer (pixmap) by copying it into the printer device throught the painter.
  QRect viewportOld = QRect(viewport.left(),viewport.top(),viewport.width(),viewport.height());

  viewport = QRect(printPainter.viewport().left(),printPainter.viewport().top(),printPainter.viewport().width(),printPainter.viewport().height());

  QRect r = ((QRect)window);

  //Set the window (part of the world I want to show)
  printPainter.setWindow(r.left(),r.top(),r.width()-1,r.height()-1);//hack because Qt QRect is used differently in this function

  //Fill the background with the background color
  QRect back = QRect(r.left(),r.top(),r.width(),r.height());

  QColor colorLegendTmp = colorLegend;
  QColor background= backgroundColor();
  if(whiteBackground){
   colorLegend = black;
   setPaletteBackgroundColor(white);
  }
  
  printPainter.fillRect(back,backgroundColor());
  printPainter.setClipRect(back,QPainter::CoordPainter);

  //Draw the axes
  drawAxes(printPainter);

  //Paint all the clusters in the shownClusters list (in the double buffer)
  drawClusters(printPainter,view.clusters(),true);

  //reset transformation due to setWindow and setViewport
  printPainter.resetXForm();

  //Draw the time axis information if the time is displayed
  drawTimeInformation(printPainter);

  printPainter.setClipping(false);

  //Restore the colors.
  if(whiteBackground){
   colorLegend = colorLegendTmp;
   setPaletteBackgroundColor(background);
  }
  
  //Restore the previous state
  viewport = QRect(viewportOld.left(),viewportOld.top(),viewportOld.width(),viewportOld.height());
}
开发者ID:caffeine-xx,项目名称:klusters,代码行数:47,代码来源:clusterview.cpp


注:本文中的QPainter::setClipping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。