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


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

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


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

示例1: DrawTrace

void LivewireCalculator::DrawTrace(uint x, uint y, QPainter &g) const
{
	const uint w = this->_weights->GetReducedWidth(), scale = this->_weights->GetScale(), s2 = scale / 2;
	if (this->_visited.Get(x /= scale, y /= scale)) // The endpoint has been solved, so we can actually draw the livewire
	{
		// Get every point from end to start by looping through the trace data
		QVector<QPoint> pts;
		uint I = x + y * w;
		do
		{
			QPoint p = QPoint((x = I % w) * scale + s2, (y = I / w) * scale + s2);
			pts.push_back(p);
			pts.push_back(p);
		}
		while ((I = this->_trace.Get(x, y)) != UINT_MAX);

		// Draw the points
		if (pts.size() >= 4)
		{
			pts.pop_back();
			pts.pop_front();
			g.drawLines(pts);
		}
	}
}
开发者ID:slash-segmentation,项目名称:livewire,代码行数:25,代码来源:LivewireCalculator.cpp

示例2: drawCrossGrid

void VpGrid::drawCrossGrid(GridGC &gridGC)
{
    int x,y;
    VpGC *vpgc = gridGC.m_gc;
    QPainter *gc = vpgc->getGC();

    // Assuming QPainter has already established begin().
    gc->setRenderHint(QPainter::Antialiasing, true);

    // Set the pen.
    QPen pen;
    pen.setColor(m_color);
    pen.setStyle(Qt::SolidLine);
    gc->setPen(pen);

    // Create a cross Marker.
    QLine cross[2];

    for (int i = 0; i < gridGC.m_ynum + 1; i++) {
        y = gridGC.m_yll + (i * gridGC.m_dy);
        for (int j = 0; j < gridGC.m_xnum; j++) {
            x = gridGC.m_xll + (j * gridGC.m_dx);
            cross[0].setLine(x-1, y, x+1, y);
            cross[1].setLine(x, y-1, x, y+1);
            gc->drawLines(cross, 2);
        }
    }

    // Flush graphics to display.
    //gc.flush();

    //delete gc;
}
开发者ID:WizzerWorks,项目名称:QtVp,代码行数:33,代码来源:vpgrid.cpp

示例3: drawReference

 void VpGrid::drawReference(GridGC &gridGC)
 {
     int x,y;
     VpGC *vpgc = gridGC.m_gc;
     QPainter *gc = vpgc->getGC();

     // Assuming QPainter has already established begin().
     gc->setRenderHint(QPainter::Antialiasing, true);

     if (m_referenceStyle == VpGrid::REFSTYLE_SQUARE)
     {
         // Set the pen.
         QPen pen;
         pen.setStyle(Qt::NoPen);
         gc->setPen(pen);
         // Set the brush.
         QBrush brush;
         brush.setColor(m_referenceColor);
         brush.setStyle(Qt::SolidPattern);
         gc->setBrush(brush);

         QRectF origin;
         origin.setLeft(-1.5 + m_xAlignment);
         origin.setRight(1.5 + m_xAlignment);
         origin.setBottom(-1.5 + m_yAlignment);
         origin.setTop(1.5 + m_yAlignment);

         gc->drawRect(origin);
     } else if (m_referenceStyle == VpGrid::REFSTYLE_CIRCLE)
     {
         // Set the pen.
         QPen pen;
         pen.setStyle(Qt::NoPen);
         gc->setPen(pen);
         // Set the brush.
         QBrush brush;
         brush.setColor(m_referenceColor);
         brush.setStyle(Qt::SolidPattern);
         gc->setBrush(brush);

         gc->drawEllipse(QPoint(m_xAlignment, m_yAlignment), 2, 2);
     } else
     {
         // Set the pen, no brush.
         QPen pen;
         pen.setColor(m_referenceColor);
         pen.setStyle(Qt::SolidLine);
         pen.setWidth(2);
         gc->setPen(pen);

         // Create a 'X' pattern.
         QLineF cross[2];
         cross[0].setLine(-1.5 + m_xAlignment, -1.5 + m_yAlignment, 1.5 + m_xAlignment, 1.5 + m_yAlignment);
         cross[1].setLine(-1.5 + m_xAlignment, 1.5 + m_yAlignment, 1.5 + m_xAlignment, -1.5 + m_yAlignment);
         gc->drawLines(cross, 2);
     }

     //delete gc;
 }
开发者ID:WizzerWorks,项目名称:QtVp,代码行数:59,代码来源:vpgrid.cpp

示例4: drv_painter

int drv_painter(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QPainter *self = (QPainter*)head->native;
    switch (drvid) {
    case PAINTER_INIT: {
        drvNewHead(a0,new QPainter);
        break;
    }
    case PAINTER_DESTROY: {
        drvDelObj(a0,self);
        break;
    }
    case PAINTER_BEGIN: {
        self->begin(drvGetWidget(a1));
        break;
    }
    case PAINTER_END: {
        self->end();
        break;
    }
    case PAINTER_SETFONT: {
        self->setFont(drvGetFont(a1));
        break;
    }
    case PAINTER_FONT: {
        drvSetFont(a1,self->font());
        break;
    }
    case PAINTER_DRAWPOINT: {
        self->drawPoint(drvGetPoint(a1));
        break;
    }
    case PAINTER_DRAWLINE: {
        self->drawLine(drvGetPoint(a1),drvGetPoint(a2));
        break;
    }
    case PAINTER_DRAWLINES: {
        self->drawLines(drvGetPoints(a1));
        break;
    }
    case PAINTER_DRAWPOLYLINE: {
        self->drawPolyline(drvGetPoints(a1));
        break;
    }
    case PAINTER_DRAWTEXT: {
        self->drawText(drvGetPoint(a1),drvGetString(a2));
        break;
    }
    default:
        return 0;
    }
    return 1;
}
开发者ID:weigj,项目名称:loongide,代码行数:54,代码来源:cdrv.cpp

示例5: paintEvent

void FlowWidget::paintEvent(QPaintEvent *event)
{
	QPainter *painter = new QPainter(this);
	painter->setPen(QPen(Qt::black, 2));

	//重画所有箭头组
	for (int i = 0; i < numLine; i++){
		painter->drawLines(lines[i], 4);
	}

	//画实时显示的箭头
	painter->drawLines(lineShow, 4);

	if (clearFlag == 1)  //如果有清除画线命令传来
	{
		numLine = 0;
		memset(lines, 0,sizeof(lines));//清空画线组
		clearFlag = 0;
	}

}
开发者ID:sylzd,项目名称:FFCP,代码行数:21,代码来源:FlowWidget.cpp

示例6: draw_close_btn

/*!
    \fn TitleBar::draw_close_btn()
 */
void TitleBar::draw_close_btn()
{
    //draw close button
	int ih1 = 13;
	int iw1 = 30;
        QPainter painter;
        QPen pen;
	QLinearGradient gradient1(0, ih1, 0, 0);
	gradient1.setColorAt(0, QColor::fromRgb(131, 3, 3));
	rightPm = QPixmap(iw1, ih1);
	painter.begin(&rightPm);
	
	if(bpress)
	{
		gradient1.setColorAt(1, QColor::fromRgb(237, 26, 86));
		painter.fillRect(0, 0, iw1, ih1, QBrush(gradient1));
		//draw frame close button
		painter.setPen(QColor(0,0,0));
		painter.drawLine(0,0,iw1,0);
		painter.drawLine(0,ih1,0,0);
                painter.drawLine(0, ih1-1, iw1,ih1-1);
                pen.setColor(QColor(83,31,31));

	}
	else
	{
		
	    gradient1.setColorAt(1, QColor::fromRgb(243, 115, 115));
	    painter.fillRect(0, 0, iw1, ih1, QBrush(gradient1));
		//draw frame close button
	    painter.setPen(QColor(66,67,70));
	    painter.drawLine(0,0,iw1,0);
		painter.setPen(QColor(71,71,74));
	    painter.drawLine(0,ih1,0,0);
		painter.setPen(QColor(88,88,90));
            painter.drawLine(0, ih1-1, iw1,ih1-1);
            pen.setColor(QColor(255,255,255));
	}
		
	//draw line close button
	painter.setPen(pen);
	QVector<QLine> lines;
	lines << QLine(iw1-16,ih1-10,iw1-11,ih1-5) << QLine(iw1-11,ih1-10,iw1-16,ih1-5);
	painter.drawLines(lines);
		
	update();
	painter.end();
}
开发者ID:CheeryLee,项目名称:QShaderEditor,代码行数:51,代码来源:titlebar.cpp

示例7: paint_caps

void LogicSignal::paint_caps(QPainter &p, QLineF *const lines,
	vector< pair<int64_t, bool> > &edges, bool level,
	double samples_per_pixel, double pixels_offset, float x_offset,
	float y_offset)
{
	QLineF *line = lines;

	for (auto i = edges.begin(); i != (edges.end() - 1); i++)
		if ((*i).second == level) {
			*line++ = QLineF(
				((*i).first / samples_per_pixel -
					pixels_offset) + x_offset, y_offset,
				((*(i+1)).first / samples_per_pixel -
					pixels_offset) + x_offset, y_offset);
		}

	p.drawLines(lines, line - lines);
}
开发者ID:zeldin,项目名称:pulseview,代码行数:18,代码来源:logicsignal.cpp

示例8: DrawMarks

void ReRulerWidget::DrawMarks( QPainter& _painter )
{
	// For horizontal ruler:
	// Draw the mark just left to or on the viewport position, even if
	// it's hidden. This hidden mark would be clipped by Qt, but would 
	// be visually correct if the mark is thicker than one pixel.
	// For vertical ruler:
	// The above applies.
	QVector< QPoint > markerList;
	int markIndex = m_viewport / m_unit;
	int pos = -m_viewport % m_unit;

	int limit = IsHorizontal() ? width() : height();
	while( pos < limit )
	{
		bool isShortMark = ( 0 == ( markIndex % m_longMarkDivision ) ? false : true );

		if( IsMarkOnSizeA() )
		{
			markerList.push_back( IsHorizontal() 
				? QPoint( pos, m_rulerHeight )
				: QPoint( m_rulerHeight, pos ) );
			markerList.push_back( IsHorizontal()
				? QPoint( pos, m_rulerHeight - ( isShortMark ? gsShortMarkLength : gsLongMarkLength ) )
				: QPoint( m_rulerHeight - ( isShortMark ? gsShortMarkLength : gsLongMarkLength ), pos ) );
		}
		else
		{
			markerList.push_back( IsHorizontal() ? QPoint( pos, 0 ) : QPoint( 0, pos ) );
			markerList.push_back( IsHorizontal()
				? QPoint( pos, isShortMark ? gsShortMarkLength : gsLongMarkLength )
				: QPoint( isShortMark ? gsShortMarkLength : gsLongMarkLength, pos ) );
		}

		// Advance to the next mark.
		pos += m_unit;
		++markIndex;
	}

	_painter.setPen( QColor( 250, 250, 250 ) );
	_painter.drawLines( markerList );
}
开发者ID:Abyss116,项目名称:libguiex,代码行数:42,代码来源:ReRulerWidget.cpp

示例9: drawBackground

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();
  }
}
开发者ID:kralf,项目名称:bouml,代码行数:20,代码来源:UmlCanvas.cpp

示例10: paintNonBreakSpace

void KateRenderer::paintNonBreakSpace(QPainter &paint, qreal x, qreal y)
{
  QPen penBackup( paint.pen() );
  QPen pen( config()->tabMarkerColor() );
  pen.setWidthF(qMax(1.0, spaceWidth() / 10.0));
  paint.setPen( pen );
  paint.setRenderHint(QPainter::Antialiasing, false);

  const int height = fontHeight();
  const int width = spaceWidth();

  QPoint points[6];
  points[0] = QPoint(x+width/10, y+height/4);
  points[1] = QPoint(x+width/10, y+height/3);
  points[2] = QPoint(x+width/10, y+height/3);
  points[3] = QPoint(x+width-width/10, y+height/3);
  points[4] = QPoint(x+width-width/10, y+height/3);
  points[5] = QPoint(x+width-width/10, y+height/4);
  paint.drawLines(points, 3);
  paint.setPen( penBackup );
}
开发者ID:fluxer,项目名称:kde-baseapps,代码行数:21,代码来源:katerenderer.cpp

示例11: drawFoldingLineVisible

void WTextSourceViewerLine::drawFoldingLineVisible(QPainter &p,const QPointF &p1,const QPointF &p2)
{
  QPolygonF area;
  float demi_char_space=char_space/2.0f;
  QPointF pos(0.0f,(p1.y()+p2.y())/2.0f-demi_char_space);
  QRectF  text_pos(pos,QSizeF(char_space,char_space));

  QPointF p3(demi_char_space,p2.y());
  QRectF endPoint2(p2.x()-2,p2.y()-2,4,4);
  QBrush b=p.brush();
  p.setBrush(Qt::black);
  if (p1!=p2)
  {
    QPointF p0(demi_char_space,p1.y());
    QPointF p1b(demi_char_space,pos.y());
    QPointF p2b(demi_char_space,pos.y()+char_space);
    QRectF endPoint1(p1.x()-2,p1.y()-2,4,4);
    area << p0 << p1 ;
    area << p0 << p1b ;
    area << p2b << p3 ;
    area << p3 << p2 ;
    p.drawEllipse(endPoint1);
  }
  else
  {
    QPointF p1c(char_space,p2.y());
    area << p1c << p2 ;
  }

  p.drawEllipse(endPoint2);
  p.setBrush(b);
  p.drawLines(area);
  float pos_size=char_space;
  QRectF rectangle(pos.x(),pos.y(),pos_size,pos_size);
  p.drawRoundRect(rectangle);
  float _x1=pos.x()+3.0f;
  float _y=pos.y()+pos_size/2.0f;
  float _x2=pos.x()+pos_size-3.0f;
  p.drawLine(QPointF(_x1,_y),QPointF(_x2,_y));
}
开发者ID:testcocoon,项目名称:testcocoon,代码行数:40,代码来源:WTextSourceViewerLine.cpp

示例12: encode

int BC_GEN::encode(const QString& input){
	if(input.size() < LEAST_CHAR){
		bc_pix->fill();
		update();
		return -4;//too short
	}
	code=input;

	encode_buf->clear();//clean these
	chksum=0;

	global_Xposition=start_Xposition-INTER_GAP_LEN;//init position
	global_Yposition=start_Yposition;

	int width=lenth_calc(input.size()+ADD_CODE_LEN);//calc width
	global_height=width*RATIO_H_W;//barcode height
	setMinimumSize(width+2*start_Xposition,global_height+2*start_Yposition);
	resize(minimumSize());

	//code39 start
	if(insertbuf(QChar('*'))!=1) return -5;//start character
	for(int i=0; i< input.size(); ++i){
		if(insertbuf(input.at(i))!=1)
			return -5;
	}
	if(insertbuf(code39_table[chksum%CODE39_SIZE])!=1) return -5;//chksum
	if(insertbuf(QChar('*'))!=1) return -5;//end character

	delete bc_pix;//begin to draw barcode
	bc_pix = new QPixmap(width+2*start_Xposition,global_height+2*start_Yposition);//init bc_pix
	bc_pix->fill();

	QPainter p;//draw barcode
	p.begin(bc_pix);
	p.drawLines(*encode_buf);
	p.end();
	update();//update display

	return 1;//successfully
}
开发者ID:xufooo,项目名称:conference_assistant,代码行数:40,代码来源:bc_generator.cpp

示例13: paint_caps

void LogicSignal::paint_caps(QPainter &p, QLineF *const lines,
    vector< pair<uint64_t, bool> > &edges, bool level,
	double samples_per_pixel, double pixels_offset, float x_offset,
	float y_offset)
{
	QLineF *line = lines;

    uint64_t curX = 0;
    uint64_t nxtX = 0;
	for (vector<pv::data::LogicSnapshot::EdgePair>::const_iterator i =
		edges.begin(); i != (edges.end() - 1); i++)
		if ((*i).second == level) {
            curX = ((*i).first / samples_per_pixel -
                    pixels_offset) + x_offset;
            nxtX = ((*(i+1)).first / samples_per_pixel -
                    pixels_offset) + x_offset;
            if (nxtX > curX)
                *line++ = QLineF(curX, y_offset, nxtX, y_offset);
		}

	p.drawLines(lines, line - lines);
}
开发者ID:ScMarxX,项目名称:DSView,代码行数:22,代码来源:logicsignal.cpp

示例14: paintTabstop

void KateRenderer::paintTabstop(QPainter &paint, qreal x, qreal y)
{
  QPen penBackup( paint.pen() );
  QPen pen( config()->tabMarkerColor() );
  pen.setWidthF(qMax(1.0, spaceWidth() / 10.0));
  paint.setPen( pen );
  paint.setRenderHint(QPainter::Antialiasing, false);

  int dist = spaceWidth() * 0.3;
  QPoint points[8];
  points[0] = QPoint(x - dist, y - dist);
  points[1] = QPoint(x, y);
  points[2] = QPoint(x, y);
  points[3] = QPoint(x - dist, y + dist);
  x += spaceWidth() / 3.0;
  points[4] = QPoint(x - dist, y - dist);
  points[5] = QPoint(x, y);
  points[6] = QPoint(x, y);
  points[7] = QPoint(x - dist, y + dist);
  paint.drawLines(points, 4);
  paint.setPen( penBackup );
}
开发者ID:fluxer,项目名称:kde-baseapps,代码行数:22,代码来源:katerenderer.cpp

示例15: pen

void
Thumbnail::paintOverImage(
	QPainter& painter, QTransform const& image_to_display,
	QTransform const& thumb_to_display)
{
	painter.setRenderHint(QPainter::Antialiasing, false);
	
	QPen pen(QColor(0, 0, 255, 70));
	pen.setWidth(1);
	pen.setCosmetic(true);
	painter.setPen(pen);
	
	QRectF const bounding_rect(boundingRect());
	
	double const cell_size = 8;
	double const left = bounding_rect.left();
	double const right = bounding_rect.right();
	double const top = bounding_rect.top();
	double const bottom = bounding_rect.bottom();
	double const w = bounding_rect.width();
	double const h = bounding_rect.height();
	
	QPointF const center(bounding_rect.center());
	QVector<QLineF> lines;
	for (double y = center.y(); y > 0.0; y -= cell_size) {
		lines.push_back(QLineF(left, y, right, y));
	}
	for (double y = center.y(); (y += cell_size) < h;) {
		lines.push_back(QLineF(left, y, right, y));
	}
	for (double x = center.x(); x > 0.0; x -= cell_size) {
		lines.push_back(QLineF(x, top, x, bottom));
	}
	for (double x = center.x(); (x += cell_size) < w;) {
		lines.push_back(QLineF(x, top, x, bottom));
	}
	painter.drawLines(lines);
}
开发者ID:4sp1r3,项目名称:scantailor,代码行数:38,代码来源:Thumbnail.cpp


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