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


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

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


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

示例1: pixmappainter

void plot2d::paintEvent(QPaintEvent *)
{
    //printf("paintEvent\n"); fflush(stdout);
    if (!backbuffer || !backbuffervalid) {
        if (!backbuffer) {
            backbuffer = new QPixmap (size ());
        }

        backbuffer->fill (isEnabled () ? Qt::white : Qt::lightGray);
        QPainter pixmappainter (backbuffer);
        {
            QReadLocker rd (&lock);
            setBoundaries();
            drawChannels(pixmappainter);
        }
        drawTicks(pixmappainter);
        backbuffervalid = true;
    }

    QPainter painter (this);
    painter.drawPixmap(0, 0, *backbuffer);

    if (scalemode == ScaleX) {
        double start = (scalestart - viewport.x ()) / viewport.width();
        double end = (scaleend - viewport.x()) / viewport.width();
        QLine line1 (start * width (), 0.005 * height (), end * width (), 0.005 * height ());
        QLine line2 (start * width (), 0.995 * height (), end * width (), 0.995 * height ());

        painter.save ();
        QPen mypen = painter.pen();
        mypen.setColor(QColor(0,0,0,150));
        mypen.setWidth(5);
        painter.setPen (mypen);
        painter.drawLine (line1);
        painter.drawLine (line2);

        painter.restore ();
    }

    if (scalemode == ScaleY) {
        double start = (scalestart - viewport.y ()) / viewport.height();
        double end = (scaleend - viewport.y()) / viewport.height();
        QLine line1 (0.005 * width (), start * height (), 0.005 * width (), end * height ());
        QLine line2 (0.995 * width (), start * height (), 0.995 * width (), end * height ());

        painter.save ();
        QPen mypen = painter.pen();
        mypen.setColor(QColor(0,0,0,150));
        mypen.setWidth(5);
        painter.setPen (mypen);
        painter.drawLine (line1);
        painter.drawLine (line2);
        painter.restore ();
    }
}
开发者ID:mojca,项目名称:gecko,代码行数:55,代码来源:plot2d.cpp

示例2: paintEvent

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();
}
开发者ID:ivantaran,项目名称:ethmite,代码行数:35,代码来源:PanelRadar.cpp

示例3: drawSavedContour

void ImageDisplayer::drawSavedContour(QPainter &painter) 
{
	//cout << "seeds size: " << seeds.size() << endl;
	//cout << "paths size: " << paths.size() << endl;
	if(seeds.size() ==  paths.size()) {
		for(int i=0; i<seeds.size(); i++) {
			// draw seed
			QBrush o = painter.brush();
			painter.setBrush(QColor(255, 0, 0, 255));
			int x = seeds[i].pos[0];
			int y = seeds[i].pos[1];
			int* tem = img2dis(x, y);
			painter.drawRect(tem[0]-3, tem[1]-3, 7, 7);
			painter.setBrush(o);

			// draw path
			QPainterPath path;
			vector<vec2i> p = paths[i];
			int* tem2 = img2dis(p[0].pos[0], p[0].pos[1]);
			path.moveTo(tem2[0], tem2[1]);
			for(int j=1; j<p.size(); j++) {
				tem2 = img2dis(p[j].pos[0], p[j].pos[1]);
				path.lineTo(tem2[0], tem2[1]);
			}
			QPen op = painter.pen();
			QPen pen(Qt::green, 3);
			painter.setPen(pen);
			painter.drawPath(path);
			painter.setPen(op);
		}
	}
}
开发者ID:GYingchao,项目名称:IntelligentScissor,代码行数:32,代码来源:imageDisplayer.cpp

示例4: strokePath

void GraphicsContext::strokePath()
{
    if (paintingDisabled())
        return;

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

    switch (m_common->state.strokeColorSpace) {
    case SolidColorSpace:
        if (strokeColor().alpha())
            p->strokePath(path, pen);
        break;
    case PatternColorSpace: {
        TransformationMatrix affine;
        pen.setBrush(QBrush(m_common->state.strokePattern->createPlatformPattern(affine)));
        p->setPen(pen);
        p->strokePath(path, pen);
        break;
    }
    case GradientColorSpace: {
        QGradient* gradient = m_common->state.strokeGradient->platformGradient();
        *gradient = applySpreadMethod(*gradient, spreadMethod()); 
        pen.setBrush(QBrush(*gradient));
        p->setPen(pen);
        p->strokePath(path, pen);
        break;
    }
    }
    m_data->currentPath = QPainterPath();
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:32,代码来源:GraphicsContextQt.cpp

示例5: UpdatePreView

void PolygonWidget::UpdatePreView()
{
	double roundness = CurvatureSpin->value() / 100.0;
	QPixmap pm = QPixmap(Preview->width() - 5, Preview->height() - 5);
	pm.fill(Qt::white);
	QPainter p;
	p.begin(&pm);
	p.setBrush(Qt::NoBrush);
	p.setPen(Qt::black);
	QPainterPath pp = RegularPolygon(Preview->width() - 6, Preview->height() - 6, Ecken->value(), Konvex->isChecked(), GetFaktor(), Slider2->value(), roundness);
	QRectF br = pp.boundingRect();
	if (br.x() < 0)
	{
		QMatrix m;
		m.translate(-br.x(), 0);
		pp = pp * m;
	}
	if (br.y() < 0)
	{
		QMatrix m;
		m.translate(0, -br.y());
		pp = pp * m;
	}
	br = pp.boundingRect();
	if ((br.height() > Preview->height() - 6) || (br.width() > Preview->width() - 6))
	{
		QMatrix ma;
		double sca = static_cast<double>(qMax(Preview->height() - 6, Preview->width() - 6)) / static_cast<double>(qMax(br.width(), br.height()));
		ma.scale(sca, sca);
		pp = pp * ma;
	}
	p.strokePath(pp, p.pen());
	p.end();
	Preview->setPixmap(pm);
}
开发者ID:AlterScribus,项目名称:ece15,代码行数:35,代码来源:polygonwidget.cpp

示例6: drawShape

void VariableCapacitor::drawShape(QPainter &p) {
	initPainter(p);

	// Get centre point of component.
	int _y = (int)y();
	int _x = (int)x();

	p.drawRect(_x - 8, _y - 8, 5, 16);
	p.drawRect(_x + 3, _y - 8, 5, 16);

// 	p.drawLine( _x-8, _y, _x-16, _y );
// 	p.drawLine( _x+8, _y, _x+16, _y );

	// Diagonally pointing arrow
	QPointArray pa(3);
	pa[0] = QPoint(-4, 0);
	pa[1] = QPoint(-2, 4);
	pa[2] = QPoint(0, 0);

	pa.translate(_x + 16, _y - 8);
	p.setBrush(p.pen().color());
	p.drawPolygon(pa);

	p.drawLine(_x - 16, _y + 8, _x + 16, _y - 8);

	deinitPainter(p);
}
开发者ID:zoltanp,项目名称:ktechlab-0.3,代码行数:27,代码来源:variablecapacitor.cpp

示例7: paint

void MarkerMapObject::paint(QPainter &painter, QRect view, int scale) {

	// Save the painter state for this paint session
	// so that it can be restored after without influencing other objects
	painter.save(); {

		// Translate, scale, and rotate...
		QTransform t;
		t.scale(1.0/scale, 1.0/scale);
		t.translate(x - view.x()*scale, view.height()*scale - y + view.y()*scale);
		painter.setTransform(t);

		for(int index = 0; index < transformationCount; index++) {
			long arrowLength = 1000*scale;
			long ballSize = 20*scale;
			Vector2D a = transformation[index].trans();
			Vector2D b = (transformation[index] * Trafo2D::trans(0, arrowLength)).trans();
			painter.setPen(transformationColors[index]);
			QPen pen = painter.pen();
			pen.setWidth(2*scale);
			painter.setPen(pen);
			painter.drawLine(a.x(), -a.y(), b.x(), -b.y());
			painter.setBrush(QBrush(transformationColors[index]));
			painter.drawEllipse(a.x()-ballSize/2, -(a.y()+ballSize/2), ballSize, ballSize);
		}

	} painter.restore();
}
开发者ID:seeyousystems,项目名称:core,代码行数:28,代码来源:MarkerMapObject.cpp

示例8: adoptPtr

ImageBufferData::ImageBufferData(const IntSize& size)
    : m_pixmap(size)
{
    if (m_pixmap.isNull())
        return;

    m_pixmap.fill(QColor(Qt::transparent));

    QPainter* painter = new QPainter;
    m_painter = adoptPtr(painter);

    if (!painter->begin(&m_pixmap))
        return;

    // Since ImageBuffer is used mainly for Canvas, explicitly initialize
    // its painter's pen and brush with the corresponding canvas defaults
    // NOTE: keep in sync with CanvasRenderingContext2D::State
    QPen pen = painter->pen();
    pen.setColor(Qt::black);
    pen.setWidth(1);
    pen.setCapStyle(Qt::FlatCap);
    pen.setJoinStyle(Qt::SvgMiterJoin);
    pen.setMiterLimit(10);
    painter->setPen(pen);
    QBrush brush = painter->brush();
    brush.setColor(Qt::black);
    painter->setBrush(brush);
    painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
    
    m_image = StillImage::createForRendering(&m_pixmap);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:31,代码来源:ImageBufferQt.cpp

示例9: DrawTimeLabelAndGridLine

//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tWindPlotGraph::DrawTimeLabelAndGridLine(QPainter& painter, QPen& gridPen, int timeIncrement)
{
    // Work out the Y position for the label and grid line
    int samplePosition;

    // Calculate the samplePosition
    samplePosition = timeIncrement * 60000;
    samplePosition /= tDigitalTimePlotDataManager::Instance()->GetSamplePeriod(m_TimePlotRange);

    qreal y = m_GraphConfig.originY + (samplePosition * m_GraphConfig.pixPerTime);

    QFontMetrics fm = QFontMetrics(painter.font());

    // Draw the label
    QString label = QString("%1").arg(timeIncrement);
    QRect boundingRect = fm.boundingRect( label );

    int w = contentsRect().width();

    QRectF textRect = QRectF((w - m_GraphConfig.centreMarginWidth) / 2, y - (boundingRect.height() / 2), m_GraphConfig.centreMarginWidth, boundingRect.height() );
    painter.drawText(textRect, Qt::AlignCenter, label );

    QPen savedPen = painter.pen();

    // draw grid lines
    if ( (samplePosition != 0) && (samplePosition != m_TimePlotData[0].GetMaxNumberOfSamples()) )
    {
        painter.setPen( gridPen );
        painter.drawLine( m_GraphConfig.originX[0], static_cast<int>(y), m_GraphConfig.originX[0] + m_GraphConfig.extentX[0], static_cast<int>(y) );
        painter.drawLine( m_GraphConfig.originX[1], static_cast<int>(y), m_GraphConfig.originX[1] + m_GraphConfig.extentX[1], static_cast<int>(y) );
    }

    painter.setPen(savedPen);
}
开发者ID:dulton,项目名称:53_hero,代码行数:37,代码来源:tWindPlotGraph.cpp

示例10: drawShape

void ECBJT::drawShape( QPainter &p )
{
	const int _x = int(x());
	const int _y = int(y());
	
	initPainter(p);
	
	p.drawLine( _x-8, _y-8, _x-8, _y+8 );
	p.drawLine( _x+8, _y-8, _x-8, _y );
	p.drawLine( _x+8, _y+8, _x-8, _y );
	
	QPolygon pa(3);
	if ( m_bIsNPN )
	{
		pa[0] = QPoint( _x+6, _y+7 );
		pa[1] = QPoint( _x+2, _y+8 );
		pa[2] = QPoint( _x+5, _y+3 );
	}
	else
	{
		pa[0] = QPoint( _x-7, _y+1 );
		pa[1] = QPoint( _x-4, _y+5 );
		pa[2] = QPoint( _x-2, _y );
	}
	p.setBrush( p.pen().color() );
	p.drawPolygon(pa);
	
	deinitPainter(p);
}
开发者ID:ktechlab,项目名称:ktechlab,代码行数:29,代码来源:ecbjt.cpp

示例11: drawSelection

void ZoomableAssemblyOverview::drawSelection(QPainter & p) {
    cachedSelection = calcCurrentSelection();
    //if selection is TOO small - enlarge it a bit
    if(0 == cachedSelection.width())  {
        cachedSelection.setWidth(1);
    }
    if(0 == cachedSelection.height()) {
        cachedSelection.setHeight(1);
    }

    //cached selection can be outside the visible range, so intersect it with it
    QRect selectionToDraw = rect().intersected(cachedSelection);
    if(selectionToDraw.isNull()) {
        return;
    }
    if(isRectVerySmall(selectionToDraw)) {
        //draw red cross
        QPoint c = selectionToDraw.center();
        QPen oldPen = p.pen();
        p.setPen(Qt::red);
        p.drawLine(c - CROSS_LEFT_CORNER, c + CROSS_LEFT_CORNER);
        p.drawLine(c - CROSS_RIGHT_CORNER, c + CROSS_RIGHT_CORNER);
        p.setPen(oldPen);
    } else {
        //draw transparent rectangle
        if(selectionToDraw.width() < 5 || selectionToDraw.height() < 5) {
            //red borders if rect is thin
            p.setPen(Qt::red);
        }
        p.fillRect(selectionToDraw, QColor(230, 230, 230, 180));
        p.drawRect(selectionToDraw.adjusted(0, 0, -1, -1));
    }
}
开发者ID:m-angelov,项目名称:ugene,代码行数:33,代码来源:ZoomableAssemblyOverview.cpp

示例12: plotClippedPolygon

void plotClippedPolygon(QPainter& painter,
			QRectF rect,
			const QPolygonF& inpoly,
			bool autoexpand)
{
  if ( autoexpand )
    {
      const qreal lw = painter.pen().widthF();
      if( painter.pen().style() != Qt::NoPen )
	rect.adjust(-lw, -lw, lw, lw);
    }

  QPolygonF plt;
  polygonClip(inpoly, rect, plt);
  painter.drawPolygon(plt);
}
开发者ID:Felipeasg,项目名称:veusz,代码行数:16,代码来源:polygonclip.cpp

示例13: plotBoxesToPainter

void plotBoxesToPainter(QPainter& painter,
			const Numpy1DObj& x1, const Numpy1DObj& y1,
			const Numpy1DObj& x2, const Numpy1DObj& y2,
			const QRectF* clip, bool autoexpand)
{
  // if autoexpand, expand rectangle by line width
  QRectF clipcopy(QPointF(-32767,-32767), QPointF(32767,32767));
  if ( clip != 0 && autoexpand )
    {
      const qreal lw = painter.pen().widthF();
      qreal x1, y1, x2, y2;
      clip->getCoords(&x1, &y1, &x2, &y2);
      clipcopy.setCoords(x1, y1, x2, y2);
      clipcopy.adjust(-lw, -lw, lw, lw);
    }

  const int maxsize = min(x1.dim, x2.dim, y1.dim, y2.dim);

  QVector<QRectF> rects;
  for(int i = 0; i < maxsize; ++i)
    {
      QPointF pt1(x1(i), y1(i));
      QPointF pt2(x2(i), y2(i));
      const QRectF rect(pt1, pt2);

      if( clipcopy.intersects(rect) )
	{
	  rects << clipcopy.intersected(rect);
	}
    }

  if( ! rects.isEmpty() )
    painter.drawRects(rects);
}
开发者ID:amcdawes,项目名称:veusz,代码行数:34,代码来源:qtloops.cpp

示例14: drawShape

void FancyRectangle::drawShape(QPainter &p)
{
    QPen oldPen = p.pen();

    // draw rectangle
    p.setPen(QPen(QColor(118, 118, 118), 1));
    p.drawRect((int)x(), (int)y(),
               width(), height());

    // draw decorations
    p.setPen(QPen(QColor(192, 192, 192), 1));
    p.drawPoint((int)x(), (int)y());
    p.drawPoint((int)x(), (int)y() + height() - 1);
    p.drawPoint((int)x() + width() - 1, (int)y());
    p.drawPoint((int)x() + width() - 1, (int)y() + height() - 1);

    //    p.setPen(QPen(QColor(196, 194, 205), 1));
    p.setPen(QPen(p.brush().color().dark(120), 1));
    p.drawLine((int)x() + 1, (int)y() + height() - 2,
               (int)x() + width() - 2, (int)y() + height() - 2);
    p.drawLine((int)x() + width() - 2, (int)y() + height() - 1,
               (int)x() + width() - 2, (int)y() + 1);

    p.setPen(oldPen);
}
开发者ID:BackupTheBerlios,项目名称:poa,代码行数:25,代码来源:scheduledialog.cpp

示例15: draw

void QgsMeshVectorRenderer::draw()
{
  // Set up the render configuration options
  QPainter *painter = mContext.painter();
  painter->save();
  if ( mContext.flags() & QgsRenderContext::Antialiasing )
    painter->setRenderHint( QPainter::Antialiasing, true );

  painter->setRenderHint( QPainter::Antialiasing );
  QPen pen = painter->pen();
  pen.setCapStyle( Qt::FlatCap );
  pen.setJoinStyle( Qt::MiterJoin );

  double penWidth = mContext.convertToPainterUnits( mCfg.lineWidth(),
                    QgsUnitTypes::RenderUnit::RenderMillimeters );
  pen.setWidthF( penWidth );
  pen.setColor( mCfg.color() );
  painter->setPen( pen );

  if ( mDataOnVertices )
    drawVectorDataOnVertices();
  else
    drawVectorDataOnFaces();

  painter->restore();
}
开发者ID:lbartoletti,项目名称:QGIS,代码行数:26,代码来源:qgsmeshvectorrenderer.cpp


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