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


C++ QPainterPath::moveTo方法代码示例

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


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

示例1: HandleMiddle

void regionselection::HandleMiddle()
{
  QColor color, arrow;
  
  color = Qt::green;
  arrow = Qt::black;

  QBrush brush( color, Qt::SolidPattern );
  painter->setBrush( brush );
  painter->setPen( QPen( Qt::black, penWidth ) );
  
  QRect rect( ( width() - borderLeft - borderRight ) / 2 + borderLeft - radius, 
              ( height() - borderTop - borderBottom ) / 2 + borderTop - radius,
                2 * radius,
                2 * radius );
  
  painter->drawEllipse ( rect );
  
  //Begin Pfeil zeichnen
  painter->setPen( QPen( arrow, 2 ) );

  QPainterPath * painterPath = new QPainterPath();
  //arrow left
  painterPath->moveTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft,                        ( height() - borderTop - borderBottom ) / 2 + borderTop );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft - radius + penWidth,    ( height() - borderTop - borderBottom ) / 2 + borderTop );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft - radius + penWidth + 7,( height() - borderTop - borderBottom ) / 2 + borderTop + 3 );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft - radius + penWidth + 7,( height() - borderTop - borderBottom ) / 2 + borderTop - 3 );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft - radius + penWidth,    ( height() - borderTop - borderBottom ) / 2 + borderTop );
  
  //arrow top
  painterPath->moveTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft,     ( height() - borderTop - borderBottom ) / 2 + borderTop );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft,     ( height() - borderTop - borderBottom ) / 2 + borderTop - radius + penWidth );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft + 3, ( height() - borderTop - borderBottom ) / 2 + borderTop - radius + penWidth + 7 );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft - 3, ( height() - borderTop - borderBottom ) / 2 + borderTop - radius + penWidth + 7 );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft,     ( height() - borderTop - borderBottom ) / 2 + borderTop - radius + penWidth );
  
  //arrow right
  painterPath->moveTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft,                         ( height() - borderTop - borderBottom ) / 2 + borderTop );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft + radius - penWidth,     ( height() - borderTop - borderBottom ) / 2 + borderTop );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft + radius - penWidth - 7, ( height() - borderTop - borderBottom ) / 2 + borderTop + 3 );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft + radius - penWidth - 7, ( height() - borderTop - borderBottom ) / 2 + borderTop - 3 );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft + radius - penWidth,     ( height() - borderTop - borderBottom ) / 2 + borderTop );

  //arrow bottom
  painterPath->moveTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft,     ( height() - borderTop - borderBottom ) / 2 + borderTop );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft,     ( height() - borderTop - borderBottom ) / 2 + borderTop + radius - penWidth );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft + 3, ( height() - borderTop - borderBottom ) / 2 + borderTop + radius - penWidth - 7 );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft - 3, ( height() - borderTop - borderBottom ) / 2 + borderTop + radius - penWidth - 7 );
  painterPath->lineTo( ( width() - borderLeft - borderRight ) / 2 + borderLeft,     ( height() - borderTop - borderBottom ) / 2 + borderTop + radius - penWidth );
  
  painterPath->setFillRule( Qt::OddEvenFill );
  
  painter->drawPath( *painterPath );
  // End Pfeil zeichnen
  
  rect.setLeft( rect.left() - 2 );
  rect.setTop( rect.top() - 2 );
  rect.setWidth( rect.width() + 2 );
  rect.setHeight( rect.height() + 2 );
  setHandleMiddleForMask( rect );
}
开发者ID:Acidburn0zzz,项目名称:vokoscreen,代码行数:61,代码来源:regionselection.cpp

示例2: A

void OpenInfraPlatform::UserInterface::Alignment2DScene::drawAxis(
	QPainterPath& diagPainter, 
	double at, 
	double from, 
	double to, 
	double scaling, 
	double desiredStepSize, 
	bool doubleLine /*= true*/, 
	bool vertical /*= false*/)
{
#define A(X) if(!vertical) { a = X;}else{ b = X;}
#define B(Y) if(!vertical) { b = Y;}else{ a = Y;}

	if(to - from == 0)
		return;

	QString text;
	int width = 80;
	double a, b;
	int sign = vertical ? -1 : 1;
	
	A(from * scaling);
	B(at + 10 * sign);
	diagPainter.moveTo(a,b);

	A(to * scaling);
	B(at + 10 * sign);
	diagPainter.lineTo(a,b);

	if(doubleLine)
	{
		A(from * scaling);
		B(at + (width + 10) * sign);
		diagPainter.moveTo(a,b);

		A(to * scaling)
		B(at + (width + 10) * sign);
		diagPainter.lineTo(a,b);
	}

	std::vector<double> drawStaions;
	drawStaions.push_back(from);
	drawStaions.push_back(to);

	// calculate stations to draw
	{
		double size = (to - from) * scaling;
		int count = size / desiredStepSize;
		count = std::min(count, 10);

		if(count != 0)
		{
			double stepSize = size / count;
			double step = stepSize / scaling;

			double allowedsteps[4] = { 1, 2.5, 5.0, 10.0};
			double dimension = 100000;
			while(step / dimension < 1)
			{
				dimension /= 10;
			}

			double min =  std::numeric_limits<double>().max();
			int index;
			for(int i=0; i<4; i++)
			{
				allowedsteps[i] *= dimension;
				double diff = std::abs(allowedsteps[i] - step);
				if(diff < min)
				{
					min = diff;
					index = i;
				}
			}

			step = allowedsteps[index];

			for(double s = (int)(from/step) * step; s < to; s+= step)
			{
				double spacing;
				if(vertical)
					spacing = (QFontMetrics(diagramFont).height() + 2 ) / scalingY;
				else
					spacing = (QFontMetrics(diagramFont).width("0+000") + 2) / scalingX;

				if(	abs(drawStaions[0] - s) > spacing && abs(drawStaions[1] - s) > spacing )
					drawStaions.push_back(s);
			}
		}
	}

	for(double x : drawStaions)
	{
		double X = x * scaling;
		A(X); 
		B(at + 10 * sign);
		diagPainter.moveTo(a,b);

		A(X);
		B(at + (width + 10) * sign);
//.........这里部分代码省略.........
开发者ID:bigdoods,项目名称:OpenInfraPlatform,代码行数:101,代码来源:Alignment2DScene.cpp

示例3: drawPrimitive

void ArthurStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
                                QPainter *painter, const QWidget *widget) const
{

    Q_ASSERT(option);
    switch (element) {
    case PE_FrameFocusRect:
        break;

    case PE_IndicatorRadioButton:
        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
            bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver);
            painter->save();
            QPixmap radio;
            if (hover)
                drawHoverRect(painter, widget->rect());

            if (button->state & State_Sunken)
                radio = cached(":res/images/radiobutton-on.png");
            else if (button->state & State_On)
                radio = cached(":res/images/radiobutton_on.png");
            else
                radio = cached(":res/images/radiobutton_off.png");
            painter->drawPixmap(button->rect.topLeft(), radio);

            painter->restore();
        }
        break;

    case PE_PanelButtonCommand:
        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
            bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver);

            painter->save();
            const QPushButton *pushButton = qobject_cast<const QPushButton *>(widget);
            Q_ASSERT(pushButton);
            QWidget *parent = pushButton->parentWidget();
            if (parent && qobject_cast<QGroupBox *>(parent)) {
                QLinearGradient lg(0, 0, 0, parent->height());
                lg.setColorAt(0, QColor(224,224,224));
                lg.setColorAt(1, QColor(255,255,255));
                painter->setPen(Qt::NoPen);
                painter->setBrush(lg);
                painter->setBrushOrigin(-widget->mapToParent(QPoint(0,0)));
                painter->drawRect(button->rect);
                painter->setBrushOrigin(0,0);
            }

            bool down = (button->state & State_Sunken) || (button->state & State_On);

            QPixmap left, right, mid;
            if (down) {
                left = cached(":res/images/button_pressed_cap_left.png");
                right = cached(":res/images/button_pressed_cap_right.png");
                mid = cached(":res/images/button_pressed_stretch.png");
            } else {
                left = cached(":res/images/button_normal_cap_left.png");
                right = cached(":res/images/button_normal_cap_right.png");
                mid = cached(":res/images/button_normal_stretch.png");
            }
            painter->drawPixmap(button->rect.topLeft(), left);
            painter->drawTiledPixmap(QRect(button->rect.x() + left.width(),
                                           button->rect.y(),
                                           button->rect.width() - left.width() - right.width(),
                                           left.height()),
                                     mid);
            painter->drawPixmap(button->rect.x() + button->rect.width() - right.width(),
                                button->rect.y(),
                                right);
            if (hover)
                painter->fillRect(widget->rect().adjusted(3,5,-3,-5), QColor(31,127,31,63));
            painter->restore();
        }
        break;

    case PE_FrameGroupBox:
        if (const QStyleOptionFrameV2 *group
                = qstyleoption_cast<const QStyleOptionFrameV2 *>(option)) {
            const QRect &r = group->rect;

            painter->save();
            int radius = 14;
            int radius2 = radius*2;
            QPainterPath clipPath;
            clipPath.moveTo(radius, 0);
            clipPath.arcTo(r.right() - radius2, 0, radius2, radius2, 90, -90);
            clipPath.arcTo(r.right() - radius2, r.bottom() - radius2, radius2, radius2, 0, -90);
            clipPath.arcTo(r.left(), r.bottom() - radius2, radius2, radius2, 270, -90);
            clipPath.arcTo(r.left(), r.top(), radius2, radius2, 180, -90);
            painter->setClipPath(clipPath);
            QPixmap titleStretch = cached(":res/images/title_stretch.png");
            QPixmap topLeft = cached(":res/images/groupframe_topleft.png");
            QPixmap topRight = cached(":res/images/groupframe_topright.png");
            QPixmap bottomLeft = cached(":res/images/groupframe_bottom_left.png");
            QPixmap bottomRight = cached(":res/images/groupframe_bottom_right.png");
            QPixmap leftStretch = cached(":res/images/groupframe_left_stretch.png");
            QPixmap topStretch = cached(":res/images/groupframe_top_stretch.png");
            QPixmap rightStretch = cached(":res/images/groupframe_right_stretch.png");
            QPixmap bottomStretch = cached(":res/images/groupframe_bottom_stretch.png");
            QLinearGradient lg(0, 0, 0, r.height());
//.........这里部分代码省略.........
开发者ID:qiqidone,项目名称:Raytracing,代码行数:101,代码来源:arthurstyle.cpp

示例4: render


//.........这里部分代码省略.........
	}
	
	if (((m_zintSymbol->symbology == BARCODE_UPCA) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_UPCA_CC)) {
		if(m_zintSymbol->whitespace_width == 0) {
			m_zintSymbol->whitespace_width = 10;
		}
		main_width = 96 + comp_offset;
	}
	
	if (((m_zintSymbol->symbology == BARCODE_UPCE) && (m_zintSymbol->rows == 1)) || (m_zintSymbol->symbology == BARCODE_UPCE_CC)) {
		if(m_zintSymbol->whitespace_width == 0) {
			m_zintSymbol->whitespace_width = 10;
		}
		main_width = 51 + comp_offset;
	}
	
	p.setWidth(1);
	painter.setPen(p);

	if (m_zintSymbol->symbology == BARCODE_MAXICODE)
	{
		/* Draw Maxicode with hexagons */
		painter.save();
		painter.setRenderHint(QPainter::Antialiasing);
		for (int r=0;r<m_zintSymbol->rows;r++)
		{
			for (int c=0;c<m_zintSymbol->width;c++)
			{
				if (module_set(r, c))
				{
					qreal col=(qreal)c*(maxi_width+1)+(r%2)*((maxi_width+1)/2);
					qreal row=(qreal)r*(maxi_width+1)*0.868;
					QPainterPath pt;
					pt.moveTo(col+maxi_width/2, 	row);
					pt.lineTo(col+maxi_width, 	row+maxi_diagonal/4);
					pt.lineTo(col+maxi_width, 	row+(maxi_diagonal-maxi_diagonal/4));
					pt.lineTo(col+maxi_width/2, 	row+maxi_diagonal);
					pt.lineTo(col, 			row+(maxi_diagonal-maxi_diagonal/4));
					pt.lineTo(col, 			row+maxi_diagonal/4);
					pt.lineTo(col+maxi_width/2, 	row);
					painter.fillPath(pt,QBrush(m_fgColor));
				}
			}
		}
		p.setWidth(maxi_width);
		painter.setPen(p);
		const qreal w=maxi_width+1;
		painter.drawEllipse(QPointF(14.5*w,16.5*w*0.868),w,w);
		painter.drawEllipse(QPointF(14.5*w,16.5*w*0.868),w+w*1.5,w+w*1.5);
		painter.drawEllipse(QPointF(14.5*w,16.5*w*0.868),w+w*3,w+w*3);
		painter.restore();
	}
	else
	{
		/* Draw all other symbols with rectangles */
		int y=0;
		for (int row=0;row<m_zintSymbol->rows;row++)
		{
			for (int i=0;i<m_zintSymbol->width;i++) {
				if (module_set(row, i))
				{
					int ed = module_set(row, i);
					int linewidth=0;
					for (int j=i;j<m_zintSymbol->width;j++,linewidth++)
						if (ed != module_set(row, j))
							break;
开发者ID:navrocky,项目名称:CuteReport,代码行数:67,代码来源:qzint.cpp

示例5: drawVectorType

void XFormView::drawVectorType(QPainter *painter)
{
    QPainterPath path;
    painter->translate(ctrlPoints.at(0) - QPointF(250,250));

    painter->scale(0.77, 0.77);
    painter->translate(98.9154 + 30 , -217.691 - 20);

    QRect br(-55, 275, 500, 590);
    QPoint center = br.center();
    painter->translate(center.x(), center.y());
    painter->rotate(m_rotation);
    painter->scale(m_scale, m_scale);
    painter->shear(0, m_shear);
    painter->translate(-center.x(), -center.y());

    painter->setPen(Qt::NoPen);
    path.moveTo(120, 470);
    path.lineTo(60+245, 470);
    path.lineTo(60+245, 470+350);
    path.lineTo(60, 470+350);
    path.lineTo(60, 470+80);

    painter->setBrush(Qt::white);
    painter->drawPath(path);
    path = QPainterPath();

    painter->setBrush(QColor( 193, 193, 191, 255));
    path.moveTo(329.336, 727.552);
    path.cubicTo(QPointF(315.224, 726.328), QPointF(304.136, 715.816), QPointF(303.128, 694.936));
    path.cubicTo(QPointF(306.368, 639.496), QPointF(309.608, 582.112), QPointF(271.232, 545.104));
    path.cubicTo(QPointF(265.256, 499.024), QPointF(244.016, 482.104), QPointF(234.008, 452.512));
    path.lineTo(218.24, 441.208);
    path.lineTo(237.104, 411.688);
    path.lineTo(245.168, 411.904);
    path.lineTo(323.936, 571.168);
    path.lineTo(340.424, 651.448);
    path.closeSubpath();
    painter->drawPath(path);
    path = QPainterPath();

    painter->setBrush(QColor(193, 193, 191, 255));
    path.moveTo(136.232, 439.696);
    path.cubicTo(QPointF(133.856, 455.248), QPointF(132.56, 470.512), QPointF(134.792, 485.272));
    path.cubicTo(QPointF(118.376, 507.592), QPointF(105.92, 530.128), QPointF(104.48, 553.312));
    path.cubicTo(QPointF(92.024, 586.504), QPointF(62.432, 614.584), QPointF(67.544, 680.104));
    path.cubicTo(QPointF(84.176, 697.456), QPointF(107.432, 713.584), QPointF(127.376, 730.36));
    path.cubicTo(QPointF(152.432, 751.312), QPointF(137.528, 778.96), QPointF(102.248, 772.408));
    path.cubicTo(QPointF(94.4, 763.768), QPointF(76.616, 709.624), QPointF(42.92, 676.288));
    path.lineTo(49.544, 632.584);
    path.lineTo(81.368, 547.408);
    path.lineTo(120.968, 484.048);
    path.lineTo(125.36, 456.688);
    path.lineTo(119.816, 386.776);
    path.lineTo(124.424, 361.216);
    path.lineTo(136.232, 439.696);
    path.closeSubpath();
    painter->drawPath(path);
    path = QPainterPath();

    painter->setBrush(QColor(193, 193, 191, 255));
    path.moveTo(115.64, 341.416);
    path.cubicTo(QPointF(116.576, 336.376), QPointF(117.8, 331.624), QPointF(119.312, 327.16));
    path.lineTo(121.688, 342.784);
    path.closeSubpath();
    painter->drawPath(path);
    path = QPainterPath();

    painter->setBrush(QColor(193, 193, 191, 255));
    path.moveTo(120.968, 500.464);
    path.cubicTo(QPointF(108.368, 523.792), QPointF(103.976, 546.256), QPointF(132.92, 550.216));
    path.cubicTo(QPointF(117.008, 553.888), QPointF(97.208, 568.648), QPointF(77.192, 593.488));
    path.lineTo(77.624, 543.016);
    path.lineTo(101.456, 503.272);
    path.closeSubpath();
    painter->drawPath(path);
    path = QPainterPath();

    painter->setBrush(QColor(193, 193, 191, 255));
    path.moveTo(-33.256, 818.488);
    path.cubicTo(QPointF(10.52, 838.144), QPointF(41.408, 837.064), QPointF(69.272, 850.96));
    path.cubicTo(QPointF(91.304, 862.552), QPointF(113.552, 861.184), QPointF(126.944, 847.144));
    path.cubicTo(QPointF(138.32, 832.456), QPointF(146.744, 831.736), QPointF(163.52, 830.224));
    path.cubicTo(QPointF(190.952, 828.568), QPointF(217.736, 828.28), QPointF(241.928, 830.8));
    path.lineTo(269.576, 833.032);
    path.cubicTo(QPointF(269.072, 864.064), QPointF(328.04, 867.88), QPointF(345.392, 844.336));
    path.cubicTo(QPointF(366.344, 819.424), QPointF(395.144, 808.264), QPointF(419.84, 790.192));
    path.lineTo(289.304, 725.536);
    path.cubicTo(QPointF(255.824, 806.464), QPointF(131.048, 827.632), QPointF(113.768, 763.264));
    path.closeSubpath();
    painter->drawPath(path);
    path = QPainterPath();

    painter->setBrush(QColor(193, 193, 191, 255));
    path.moveTo(286.424, 711.568);
    path.cubicTo(QPointF(273.824, 711.496), QPointF(260.936, 715.6), QPointF(261.944, 732.16));
    path.lineTo(266.192, 776.44);
    path.lineTo(304.424, 756.64);
    path.closeSubpath();
    painter->drawPath(path);
//.........这里部分代码省略.........
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:101,代码来源:xform.cpp

示例6: draw


//.........这里部分代码省略.........
                QPointF(p.x(), p.y() + pW),
                QPointF(cX + cW/2, cY + cH/2 + pW),
                QPointF(cX + cW/2, cY + cH/2)
            };
            gradient_side.setColorAt(1, pieces[0].rgbColor);
            painter->setBrush(gradient_side);
            painter->drawPolygon(points, 4);
        }

        for (int i = 0;i < pieces.size(); i++)
        {
            gradient.setColorAt(0.5, pieces[i].rgbColor);
            painter->setBrush(gradient);
            pdegree = 3.6 * pieces[i].pPerc;
            painter->drawPie(cX, cY, cW, cH, palpha * 16, pdegree * 16);

            double a_ = Angle360(palpha);
            int q_ = GetQuater(palpha);

            palpha += pdegree;

            double a = Angle360(palpha);
            int q = GetQuater(palpha);

            QPainterPath path;
            p = GetPoint(palpha);

            if((q == 3 || q == 4) && (q_ == 3 || q_ == 4))
            {
                // 1)
                if (a>a_)
                {
                    QPointF p_old = GetPoint(palpha-pdegree);
                    path.moveTo(p_old.x() - 1, p_old.y());
                    path.arcTo(cX, cY, cW, cH, palpha-pdegree, pdegree);
                    path.lineTo(p.x(), p.y() + pW);
                    path.arcTo(cX, cY + pW, cW, cH, palpha, -pdegree);
                }
                // 2)
                else
                {
                    path.moveTo(cX, cY + cH/2);
                    path.arcTo(cX, cY, cW, cH, 180, Angle360(palpha) - 180);
                    path.lineTo(p.x(), p.y() + pW);
                    path.arcTo(cX, cY + pW, cW, cH, Angle360(palpha), -Angle360(palpha) + 180);
                    path.lineTo(cX, cY + cH/2);

                    path.moveTo(p.x(), p.y());
                    path.arcTo(cX, cY, cW, cH, palpha-pdegree, 360 - Angle360(palpha - pdegree));
                    path.lineTo(cX + cW, cY + cH/2 + pW);
                    path.arcTo(cX, cY + pW, cW, cH, 0, -360 + Angle360(palpha - pdegree));
                }

            }
            // 3)
            else if((q == 3 || q == 4) && (q_ == 1 || q_ == 2) && a>a_ )
            {
                path.moveTo(cX,cY+cH/2);
                path.arcTo(cX,cY,cW,cH,180,Angle360(palpha)-180);
                path.lineTo(p.x(),p.y()+pW);
                path.arcTo(cX,cY+pW,cW,cH,Angle360(palpha),-Angle360(palpha)+180);
                path.lineTo(cX,cY+cH/2);
            }
            // 4)
            else if((q == 1 || q == 2) && (q_ == 3 || q_ == 4) && a<a_)
            {
开发者ID:GLDsuh-a,项目名称:qt-1,代码行数:67,代码来源:nightcharts.cpp

示例7: paint

void PathStrokeRenderer::paint(QPainter *painter)
{
    if (m_points.isEmpty())
        initializePoints();

    painter->setRenderHint(QPainter::Antialiasing);

    QPalette pal = palette();
    painter->setPen(Qt::NoPen);

    // Construct the path
    QPainterPath path;
    path.moveTo(m_points.at(0));

    if (m_pathMode == LineMode) {
        for (int i=1; i<m_points.size(); ++i)
            path.lineTo(m_points.at(i));
    } else {
        int i=1;
        while (i + 2 < m_points.size()) {
            path.cubicTo(m_points.at(i), m_points.at(i+1), m_points.at(i+2));
            i += 3;
        }
        while (i < m_points.size()) {
            path.lineTo(m_points.at(i));
            ++i;
        }
    }

    // Draw the path
    {
        QColor lg = Qt::red;

        // The "custom" pen
        if (m_penStyle == Qt::NoPen) {
            QPainterPathStroker stroker;
            stroker.setWidth(m_penWidth);
            stroker.setJoinStyle(m_joinStyle);
            stroker.setCapStyle(m_capStyle);

            QVector<qreal> dashes;
            qreal space = 4;
            dashes << 1 << space
                   << 3 << space
                   << 9 << space
                   << 27 << space
                   << 9 << space
                   << 3 << space;
            stroker.setDashPattern(dashes);
            QPainterPath stroke = stroker.createStroke(path);
            painter->fillPath(stroke, lg);

        } else {
            QPen pen(lg, m_penWidth, m_penStyle, m_capStyle, m_joinStyle);
            painter->strokePath(path, pen);
        }
    }

    if (1) {
        // Draw the control points
        painter->setPen(QColor(50, 100, 120, 200));
        painter->setBrush(QColor(200, 200, 210, 120));
        for (int i=0; i<m_points.size(); ++i) {
            QPointF pos = m_points.at(i);
            painter->drawEllipse(QRectF(pos.x() - m_pointSize,
                                       pos.y() - m_pointSize,
                                       m_pointSize*2, m_pointSize*2));
        }
        painter->setPen(QPen(Qt::lightGray, 0, Qt::SolidLine));
        painter->setBrush(Qt::NoBrush);
        painter->drawPolyline(m_points);
    }

}
开发者ID:crobertd,项目名称:qtbase,代码行数:74,代码来源:pathstroke.cpp

示例8: create

QIcon QSparkLineIconFactory::create(const QList< double > &_observations,
                                    const double _minimum,
                                    const double _minRange,
                                    const QColor &_color,
                                    const QColor &_bgColor,
                                    const int _width,
                                    const int _height,
                                    const int _leftPadding,
                                    const int _rightPadding,
                                    const int _topPadding,
                                    const int _bottomPadding)
{
    QPixmap pixmap(_width, _height);
    pixmap.fill(_bgColor);
    QPainter painter(&pixmap);

    int graphHeight = pixmap.rect().height() - _topPadding - _bottomPadding;
    int graphWidth = pixmap.rect().width() - _leftPadding - _rightPadding;
    QPoint bl = pixmap.rect().bottomLeft();

    QPainterPath path;

    if (_observations.size() > 1)
    {
        double min =
            *std::min_element(_observations.begin(), _observations.end());
        min = std::min(min, _minimum);
        double max =
            *std::max_element(_observations.begin(), _observations.end());

        double range = max - min;

        if (range < _minRange)
        {
            max += _minRange - range;
        }

        double skip = 0;

        if (min != max)
        {
            skip = double(graphHeight - 1) / (max - min);

            double width = graphWidth / double(_observations.size() - 1);

            double x = _leftPadding;
            double y = -_bottomPadding;

            bool first = true;

            QList< double >::const_iterator i = _observations.begin();
            QList< double >::const_iterator iend = _observations.end();

            for (; i != iend; ++i)
            {
                double height = (*i - min) * skip;

                if (first)
                {
                    y -= height;
                    first = false;
                    path.moveTo(bl.x() + int(x), bl.y() + int(y));
                }
                else
                {
                    x += width;
                    y = -_bottomPadding - height;

                    path.lineTo(bl.x() + int(x), bl.y() + int(y));
                }
            }
        }
    }

    if (!path.isEmpty())
    {
        painter.setRenderHint(QPainter::Antialiasing, true);
        painter.setPen(
            QPen(_color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        painter.drawPath(path);
    }

    return QIcon(pixmap);
}
开发者ID:zackxue,项目名称:dqtx,代码行数:84,代码来源:QSparkLineIconFactory.cpp

示例9: deer

QPainterPath Paths::deer()
{
    QPainterPath path;

    path.moveTo(39.88,31.658);
    path.cubicTo(35.632,31.658, 31.398,31.004, 27.871,32.82);
    path.cubicTo(25.015,34.29, 19.608,34.158, 16.297,34.158);
    path.cubicTo(14.722,34.158, 17.755,37.718, 17.709,38.922);
    path.cubicTo(17.578,42.396, 24.612,43.15, 26.755,44.058);
    path.cubicTo(30.062,45.46, 28.682,47.701, 28.963,50.574);
    path.cubicTo(29.715,58.243, 26.887,63.745, 24.182,70.589);
    path.cubicTo(23.365,72.657, 21.772,75.56, 21.972,77.866);
    path.cubicTo(22.333,82.029, 15.803,77.207, 13.894,76.535);
    path.cubicTo(10.977,75.508, 5.507,74.071, 2.424,75.331);
    path.cubicTo(-1.532,76.947, 0.076,80.491, 2.169,82.806);
    path.cubicTo(6.17,87.234, 2.703,90.713, 3.895,95.363);
    path.cubicTo(4.321,97.026, 11.682,104.683, 12.858,103.668);
    path.cubicTo(16.706,100.347, 11.464,98.692, 10.105,96.164);
    path.cubicTo(9.487,95.015, 8.616,83.742, 8.866,83.759);
    path.cubicTo(10.018,83.837, 12.591,85.867, 13.671,86.392);
    path.cubicTo(16.889,87.954, 20.066,89.63, 22.963,91.741);
    path.cubicTo(29.156,94.47, 35.543,96.965, 42.102,98.676);
    path.cubicTo(51.085,101.02, 59.407,102.003, 68.009,106.005);
    path.cubicTo(72.92,108.289, 72.05,113.282, 75.744,117.004);
    path.cubicTo(79.422,120.709, 84.733,123.053, 88.978,126.053);
    path.cubicTo(92.402,128.473, 95.422,132.308, 97.334,135.998);
    path.cubicTo(99.551,140.279, 99.071,146.004, 99.838,150.674);
    path.cubicTo(100.369,153.91, 104.378,156.321, 106.302,158.859);
    path.cubicTo(110.471,164.355, 109.86,155.112, 108.163,154.412);
    path.cubicTo(104.97,153.094, 103.991,146.625, 103.812,143.439);
    path.cubicTo(103.525,138.336, 105.568,134.331, 101.918,130.346);
    path.cubicTo(95.104,122.907, 89.488,114.182, 94.711,103.742);
    path.cubicTo(96.889,99.388, 91.191,95.497, 96.94,94.368);
    path.cubicTo(99.551,93.856, 102.49,94.367, 104.326,92.034);
    path.cubicTo(106.639,89.095, 105.063,85.343, 102.943,82.798);
    path.cubicTo(102.686,82.417, 102.359,82.121, 101.962,81.909);
    path.cubicTo(102.331,81.909, 101.923,86.98, 100.981,87.628);
    path.cubicTo(98.868,89.082, 95.569,91.586, 92.88,91.672);
    path.cubicTo(90.569,91.745, 86.738,89.184, 85.212,87.658);
    path.cubicTo(84.092,86.538, 80.176,86.157, 78.598,85.83);
    path.cubicTo(74.737,85.031, 71.741,84.326, 68.012,82.806);
    path.cubicTo(63.318,80.893, 58.687,78.672, 54.555,75.71);
    path.cubicTo(44.573,68.555, 42.755,56.146, 44.022,44.495);
    path.cubicTo(44.295,41.987, 43.169,38.057, 44.617,35.915);
    path.cubicTo(44.961,35.406, 46.52,35.553, 47.119,35.024);
    path.cubicTo(47.882,34.35, 49.574,31.822, 49.878,30.792);
    path.cubicTo(51.126,26.569, 44.36,32.002, 45.336,31.938);
    path.cubicTo(43.861,32.036, 47.011,22.934, 47.191,22.574);
    path.cubicTo(47.555,21.846, 52.489,13.123, 49.511,13.222);
    path.cubicTo(47.643,13.284, 48.563,18.667, 46.354,18.227);
    path.cubicTo(43.964,17.751, 40.522,11.396, 41.566,9.011);
    path.cubicTo(43.4,4.819, 39.743,3.905, 39.214,7.564);
    path.cubicTo(39.112,8.269, 40.893,13.438, 38.159,12.665);
    path.cubicTo(35.335,11.866, 35.748,-0.125, 34.38,-8.0352391e-15);
    path.cubicTo(31.991,0.219, 34.074,10.836, 33.361,12.176);
    path.cubicTo(33.144,12.584, 29.68,8.66, 29.459,7.718);
    path.cubicTo(28.48,3.558, 28.031,5.106, 26.87,7.752);
    path.cubicTo(25.333,11.254, 37.159,17.423, 39.292,18.663);
    path.cubicTo(40.993,19.651, 42.39,20.504, 42.973,22.48);
    path.cubicTo(43.482,24.205, 44.098,26.568, 42.926,28.191);
    path.cubicTo(42.092,29.346, 39.88,29.982, 39.88,31.658);
    return path;
}
开发者ID:RS102839,项目名称:qt,代码行数:63,代码来源:paths.cpp

示例10: paintEvent

//! [8]
void RenderArea::paintEvent(QPaintEvent * /* event */)
{
    //! [9]
        QPainter painter(this);
        painter.setPen(pen);
        painter.setBrush(brush);
        painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing, antialiased);

    //! [9]

        if (doRunTest)
       {
            QPoint ptCenter = this->rect().center();
            if (transformed) {
                painter.translate(ptCenter);
                //painter.rotate(60.0);
                painter.scale(0.99, 0.99);
                painter.translate(-ptCenter );
            }

            if (this->deviceType4Draw == QInternal::Widget) {
                qDebug() << "RenderArea: painter.device(): " << g_paintDeviceType[painter.device()->devType()]
                                << ", painter.paintEngine(): " << g_paintEngineType[painter.paintEngine()->type()];
                painter.fillRect(this->rect(), Qt::white);
                KQtTester tester(&painter);
                tester.runTest();
            } else if (this->deviceType4Draw == QInternal::Pixmap) {
                QPixmap pix(this->width(), this->height());
                pix.fill(Qt::white);
                QPainter pixPainter(&pix);
                pixPainter.setPen(pen);
                pixPainter.setBrush(brush);
                pixPainter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing, antialiased);
                qDebug() << "Pixmap: pixPainter.device(): " << g_paintDeviceType[pixPainter.device()->devType()]
                                 << ", pixPainter.paintEngine(): " << g_paintEngineType[pixPainter.paintEngine()->type()];

                KQtTester tester(&pixPainter);
                tester.runTest();
                pixPainter.end();

                painter.fillRect(0, 0, 2000, 2000, Qt::white);
                painter.drawPixmap(0, 0, pix);
            } else if (this->deviceType4Draw == QInternal::Image) {
                QImage img(this->width(), this->height(), QImage::Format_ARGB32_Premultiplied);
                img.fill(0xffffffff);
                QPainter imgPainter(&img);
                imgPainter.setPen(pen);
                imgPainter.setBrush(brush);
                imgPainter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing, antialiased);
                qDebug() << "Image: imgPainter.device(): " << g_paintDeviceType[imgPainter.device()->devType()]
                                << ", imgPainter.paintEngine(): " << g_paintEngineType[imgPainter.paintEngine()->type()];

                KQtTester tester(&imgPainter);
                tester.runTest();
                imgPainter.end();

                painter.fillRect(0, 0, 2000, 2000, Qt::white);
                painter.drawImage(0, 0, img);
            } else
                Q_ASSERT(0);


            return;
        }

    static const QPoint points[4] = {
        QPoint(10, 80),
        QPoint(20, 10),
        QPoint(80, 30),
        QPoint(90, 70)
    };

    QRect rect(10, 20, 80, 60);

    QPainterPath path;
    path.moveTo(20, 80);
    path.lineTo(20, 30);
    path.cubicTo(80, 0, 50, 50, 80, 80);

    int startAngle = 20 * 16;
    int arcLength = 120 * 16;
//! [8]

//! [10]
    for (int x = 0; x < width(); x += 100) {
        for (int y = 0; y < height(); y += 100) {
            painter.save();
            painter.translate(x, y);
//! [10] //! [11]
            if (transformed) {
                painter.translate(50, 50);
                painter.rotate(60.0);
                painter.scale(0.6, 0.9);
                painter.translate(-50, -50);
            }
//! [11]

//! [12]
            switch (shape) {
//.........这里部分代码省略.........
开发者ID:okenjian,项目名称:coding,代码行数:101,代码来源:renderarea.cpp

示例11: rect

//=============================================================================
void sstQt01TestPaintWidgetCls::paintEvent(QPaintEvent * /* event */)
{
    static const QPoint points[4] = {
        QPoint(10, 80),
        QPoint(20, 10),
        QPoint(80, 30),
        QPoint(90, 70)
    };

    QRect rect(10, 20, 80, 60);

    QPainterPath path;
    path.moveTo(20, 80);
    path.lineTo(20, 30);
    path.cubicTo(80, 0, 50, 50, 80, 80);

    int startAngle = 20 * 16;
    int arcLength = 120 * 16;

    QPainter painter(this);
    painter.setPen(pen);
    painter.setBrush(brush);
    if (antialiased)
        painter.setRenderHint(QPainter::Antialiasing, true);

    for (int x = 0; x < width(); x += 100) {
        for (int y = 0; y < height(); y += 100) {
            painter.save();
            painter.translate(x, y);
            if (transformed) {
                painter.translate(50, 50);
                painter.rotate(60.0);
                painter.scale(0.6, 0.9);
                painter.translate(-50, -50);
            }

            switch (shape) {
            case Line:
                painter.drawLine(rect.bottomLeft(), rect.topRight());
                break;
            case Points:
                painter.drawPoints(points, 4);
                break;
            case Polyline:
                painter.drawPolyline(points, 4);
                break;
            case Polygon:
                painter.drawPolygon(points, 4);
                break;
            case Rect:
                painter.drawRect(rect);
                break;
            case RoundedRect:
                painter.drawRoundedRect(rect, 25, 25, Qt::RelativeSize);
                break;
            case Ellipse:
                painter.drawEllipse(rect);
                break;
            case Arc:
                painter.drawArc(rect, startAngle, arcLength);
                break;
            case Chord:
                painter.drawChord(rect, startAngle, arcLength);
                break;
            case Pie:
                painter.drawPie(rect, startAngle, arcLength);
                break;
            case Path:
                painter.drawPath(path);
                break;
            case Text:
                painter.drawText(rect,
                                 Qt::AlignCenter,
                                 tr("Qt by\nThe Qt Company"));
                break;
            case Pixmap:
                painter.drawPixmap(10, 10, pixmap);
            }
            painter.restore();
        }
    }

    painter.setRenderHint(QPainter::Antialiasing, false);
    painter.setPen(palette().dark().color());
    painter.setBrush(Qt::NoBrush);
    painter.drawRect(QRect(0, 0, width() - 1, height() - 1));
}
开发者ID:UliRehr15,项目名称:sstQt01Lib,代码行数:88,代码来源:sstQt01TestPaintWidget.cpp

示例12: QGraphicsPolygonItem

//! [0]
DiagramItem::DiagramItem(DiagramType diagramType, QMenu *contextMenu,
                         QGraphicsItem *parent, QGraphicsScene *scene)
    : QGraphicsPolygonItem(parent, scene)
{
    myDiagramType = diagramType;
    myContextMenu = contextMenu;
    myGText = new QGraphicsSimpleTextItem(this,scene);

    QPainterPath path;
    switch (myDiagramType) {
    case StartEnd:
        path.moveTo(200, 50);
        path.arcTo(150, 0, 50, 50, 0, 90);
        path.arcTo(50, 0, 50, 50, 90, 90);
        path.arcTo(50, 50, 50, 50, 180, 90);
        path.arcTo(150, 50, 50, 50, 270, 90);
        path.lineTo(200, 25);
        myPolygon = path.toFillPolygon();
        myText = "StartEnd";
        break;
    case Conditional:
        myPolygon << QPointF(-50, 0) << QPointF(0, 50)
                  << QPointF(50, 0) << QPointF(0, -50)
                  << QPointF(-50, 0);
        myText = "Conditional";
        break;
    case Step:
        myPolygon << QPointF(-50, -50) << QPointF(50, -50)
                  << QPointF(50, 50) << QPointF(-50, 50)
                  << QPointF(-50, -50);
        myText = "Step";
        break;
    case Compo:
        myPolygon << QPointF(-50, 0) << QPointF(0, 50)
                  << QPointF(50, 0) << QPointF(0, -50)
                  << QPointF(-50, 0);
        myText = /*"Composition " + */QString::fromUtf8("  \u2229");
        myGText->setScale(3);
        break;
    case Union:
        myPolygon << QPointF(-50, 0) << QPointF(0, 50)
                  << QPointF(50, 0) << QPointF(0, -50)
                  << QPointF(-50, 0);
        myText = /*"Union " +*/QString::fromUtf8("  \u222A");
        myGText->setScale(3);
        break;
    case Constraint:
        myPolygon << QPointF(-50, -50) << QPointF(50, -50)
                  << QPointF(50, 50) << QPointF(-50, 50)
                  << QPointF(-50, -50);
        myText = "Constraint";
        break;
    case Io:
        myPolygon << QPointF(-60, -40) << QPointF(-35, 40)
                  << QPointF(60, 40) << QPointF(35, -40)
                  << QPointF(-60, -40);
        myText = "Input/Output";
        break;
    default:
        myPolygon << QPointF(-60, -40) << QPointF(-35, 40)
                  << QPointF(60, 40) << QPointF(35, -40)
                  << QPointF(-60, -40);
        myText = "Default";
        break;
    }
    setPolygon(myPolygon);
    setFlag(QGraphicsItem::ItemIsMovable, true);
    setFlag(QGraphicsItem::ItemIsSelectable, true);
    setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

    myGText->setText(myText);

    myGText->setPos(this->boundingRect().topLeft());

    ub = 0;
    lb = 0;
}
开发者ID:msis,项目名称:proj2D_ng,代码行数:78,代码来源:diagramitem.cpp

示例13: paint

void ProcessorGraphicsItem::paint(QPainter* p, const QStyleOptionGraphicsItem* options,
                                  QWidget* widget) {
    IVW_UNUSED_PARAM(options);
    IVW_UNUSED_PARAM(widget);
    p->save();
    p->setPen(Qt::NoPen);
    p->setRenderHint(QPainter::Antialiasing, true);
    QColor topColor(140, 140, 140);
    QColor middleColor(59, 61, 61);
    QColor bottomColor(40, 40, 40);
    // paint processor
    QLinearGradient grad(rect().topLeft(), rect().bottomLeft());

    if (isSelected()) {
        grad.setColorAt(0.0f, topColor);
        grad.setColorAt(0.2f, middleColor);
        grad.setColorAt(0.5f, Qt::darkRed);
        grad.setColorAt(1.0f, bottomColor);
    } else {
        grad.setColorAt(0.0f, topColor);
        grad.setColorAt(0.2f, middleColor);
        grad.setColorAt(1.0f, bottomColor);
    }

    QRectF bRect = rect();
    QPainterPath roundRectPath = makeRoundedBox(rect(), roundedCorners);

    p->setBrush(grad);
    p->drawPath(roundRectPath);
    QLinearGradient highlightGrad(rect().topLeft(), rect().bottomLeft());

    if (isSelected()) {
        highlightGrad.setColorAt(0.0f, bottomColor);
        highlightGrad.setColorAt(0.1f, bottomColor);
        highlightGrad.setColorAt(0.5f, Qt::darkRed);
        highlightGrad.setColorAt(1.0f, bottomColor);
    } else {
        highlightGrad.setColorAt(0.0f, bottomColor);
        highlightGrad.setColorAt(1.0f, bottomColor);
    }

    QPainterPath highlightPath;
    float highlightLength = bRect.width() / 8.0;
    highlightPath.moveTo(bRect.left(), bRect.top() + roundedCorners);
    highlightPath.lineTo(bRect.left(), bRect.bottom() - roundedCorners);
    highlightPath.arcTo(bRect.left(), bRect.bottom() - (2 * roundedCorners), (2 * roundedCorners),
                        (2 * roundedCorners), 180.0, 90.0);
    highlightPath.lineTo(bRect.left() + (bRect.width() / 2.0) + highlightLength, bRect.bottom());
    highlightPath.lineTo(bRect.left() + (bRect.width() / 2.0) - highlightLength, bRect.top());
    highlightPath.lineTo(bRect.left() + roundedCorners, bRect.top());
    highlightPath.arcTo(bRect.left(), bRect.top(), (2 * roundedCorners), (2 * roundedCorners), 90.0,
                        90.0);

    p->setBrush(highlightGrad);
    p->drawPath(highlightPath);
    p->setPen(QPen(QColor(164, 164, 164), 1.0));
    p->setBrush(Qt::NoBrush);
    p->drawPath(roundRectPath);

    p->restore();
}
开发者ID:Ojaswi,项目名称:inviwo,代码行数:61,代码来源:processorgraphicsitem.cpp

示例14: paint

void EventsSceneArrowTmpItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);
    
    QRectF rect = boundingRect();
    
    //painter->fillRect(rect, QColor(255, 0, 0, 30));
    
    painter->setRenderHint(QPainter::Antialiasing);
    int penWidth = 2;
    QColor color = Qt::black;
    
    switch(mState)
    {
        case eNormal:
            color = Qt::black;
            break;
        case eAllowed:
            color = QColor(77, 180, 62);
            break;
        case eForbidden:
            color = Qt::red;
            break;
        default:
            break;
    }
    painter->setPen(QPen(color, penWidth, Qt::DashLine));
    painter->drawLine(mXFrom, mYFrom, mXTo, mYTo);
    
    // arrows
    
    float angle_rad = atanf(rect.width() / rect.height());
    float angle_deg = angle_rad * 180. / M_PI;
    
    QPainterPath path;
    int arrow_w = 10;
    int arrow_l = 15;
    path.moveTo(-arrow_w/2, arrow_l/2);
    path.lineTo(arrow_w/2, arrow_l/2);
    path.lineTo(0, -arrow_l/2);
    path.closeSubpath();
    
    float posX = rect.width()/2;
    float posY = rect.height()/2;
    
    if(mXFrom < mXTo && mYFrom > mYTo)
    {
        painter->save();
        painter->translate(rect.x() + posX, rect.y() + posY);
        painter->rotate(angle_deg);
        painter->fillPath(path, color);
        painter->restore();
    }
    else if(mXFrom < mXTo && mYFrom < mYTo)
    {
        painter->save();
        painter->translate(rect.x() + posX, rect.y() + posY);
        painter->rotate(180 - angle_deg);
        painter->fillPath(path, color);
        painter->restore();
    }
    else if(mXFrom > mXTo && mYFrom < mYTo)
    {
        painter->save();
        painter->translate(rect.x() + posX, rect.y() + posY);
        painter->rotate(180 + angle_deg);
        painter->fillPath(path, color);
        painter->restore();
    }
    else if(mXFrom > mXTo && mYFrom > mYTo)
    {
        painter->save();
        painter->translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
        painter->rotate(-angle_deg);
        painter->fillPath(path, color);
        painter->restore();
    }
    
    // Message
    
    switch(mState)
    {
        case eAllowed:
        case eForbidden:
        {
            float w = 40;
            float h = 40;
            QRectF r(rect.x() + (rect.width() - w)/2, rect.y() + (rect.height() - h)/2, w, h);
            painter->setBrush(Qt::white);
            painter->drawEllipse(r);
            
            if(mState == eAllowed)
            {
                painter->drawText(r, Qt::AlignCenter, "OK");
            }
            else
            {
                painter->setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap));
                painter->drawLine(r.x() + r.width()/4, r.y() + r.height()/4, r.x() + 3*r.width()/4, r.y() + 3*r.height()/4);
//.........这里部分代码省略.........
开发者ID:chrono35,项目名称:chronomodel,代码行数:101,代码来源:EventsSceneArrowTmpItem.cpp

示例15: addText

void OpenInfraPlatform::UserInterface::VerticalAlignmentScene::v_drawDiagram(QPainterPath& diagPainter, QPainterPath& diagDashedPainter)
{		
	QString text;
	
	// 
	if(displayPoints_)
	{
		for(int i=0; i<arcPoints.size(); i++)
		{
			buw::vector2d start, end;
			int ai = std::get<0>(arcPoints[i]);
			start = std::get<1>(arcPoints[i]);
			end = std::get<2>(arcPoints[i]);

			text = "AA" + QString::number(ai+1);;
			auto startLabel = addText(text, diagramFont);
			startLabel->setPos(start.x() * scalingX, start.y() * scalingY - 25);
			startLabel->setDefaultTextColor(Qt::lightGray);

			diagDashedPainter.moveTo(start.x() * scalingX, start.y() * scalingY);
			diagDashedPainter.lineTo(start.x() * scalingX, bounds[3] * scalingY + 5);

			text = "AE" + QString::number(ai+1);
			auto endLabel = addText(text, diagramFont);
			endLabel->setPos(end.x() * scalingX, end.y() * scalingY - 25);
			endLabel->setDefaultTextColor(Qt::lightGray);

			diagDashedPainter.moveTo(end.x() * scalingX, end.y() * scalingY);
			diagDashedPainter.lineTo(end.x() * scalingX, bounds[3] * scalingY + 5);
		}
		for (int i = 0; i<parabolaPoints.size(); i++)
		{
			buw::vector2d start, end, pvi;
			int ai = std::get<0>(parabolaPoints[i]);
			start = std::get<1>(parabolaPoints[i]);
			end = std::get<2>(parabolaPoints[i]);
			pvi = std::get<3>(parabolaPoints[i]);

			text = "AA" + QString::number(ai + 1);;
			auto startLabel = addText(text, diagramFont);
			startLabel->setPos(start.x() * scalingX, start.y() * scalingY - 25);
			startLabel->setDefaultTextColor(Qt::lightGray);

			diagDashedPainter.moveTo(start.x() * scalingX, start.y() * scalingY);
			diagDashedPainter.lineTo(start.x() * scalingX, bounds[3] * scalingY + 5);

			text = "AE" + QString::number(ai + 1);
			auto endLabel = addText(text, diagramFont);
			endLabel->setPos(end.x() * scalingX, end.y() * scalingY - 25);
			endLabel->setDefaultTextColor(Qt::lightGray);

			diagDashedPainter.moveTo(end.x() * scalingX, end.y() * scalingY);
			diagDashedPainter.lineTo(end.x() * scalingX, bounds[3] * scalingY + 5);

			text = "VB" + QString::number(ai + 1);;
			auto pviLabel = addText(text, diagramFont);
			pviLabel->setPos(pvi.x() * scalingX, pvi.y() * scalingY - 25);
			pviLabel->setDefaultTextColor(Qt::lightGray);

			diagDashedPainter.moveTo(pvi.x() * scalingX, pvi.y() * scalingY);
			diagDashedPainter.lineTo(pvi.x() * scalingX, bounds[3] * scalingY + 5);
		}
	}

}
开发者ID:bigdoods,项目名称:OpenInfraPlatform,代码行数:65,代码来源:VerticalAlignmentWindow.cpp


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