• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ painter函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中painter函数的典型用法代码示例。如果您正苦于以下问题:C++ painter函数的具体用法?C++ painter怎么用?C++ painter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: initLines

void LinkStatusWidget::paintEvent(QPaintEvent *event){

    initLines();

    QPainter painter(this);

    QPixmap pic(QString::fromUtf8(":/computer_white.png"));

    QRectF dest(0,0,pic.width(),pic.height());



    QPixmap pic2(QString::fromUtf8(":/honeywell.png"));

    QRectF dest2(0,0,pic2.width(),pic2.height());
    //220*180

    QRectF target_0(this->left_left,this->left_top,this->left_width,this->left_height);

    QRectF target_1(this->width()-this->right_right-this->right_width,this->right_top,this->right_width,this->right_height);

    QRectF target_2(this->width()-this->right_right-this->right_width,this->right_top+this->right_height+this->right_space,this->right_width,this->right_height);

    painter.setPen(Qt::white);
    painter.drawPixmap(target_0,pic2,dest2);

    painter.drawText(this->left_left+this->left_width+this->left_space,this->left_top+painter.fontMetrics().height(),Config::LINKSTATUS_LABEL.split("#").at(2));



    painter.drawPixmap(target_1,pic,dest);

    QString text=Config::LINKSTATUS_LABEL.split("#").at(0);
    int f_w=painter.fontMetrics().width(text);

    painter.drawText(this->width()-this->right_right-this->right_width-this->right_space*2-f_w,this->right_top+painter.fontMetrics().height()+this->right_space,text);

    painter.drawPixmap(target_2,pic,dest);

    text=Config::LINKSTATUS_LABEL.split("#").at(1);
    f_w=painter.fontMetrics().width(text);


    painter.drawText(this->width()-this->right_right-this->right_width-this->right_space*2-f_w,this->right_top+this->right_height+this->right_space*2+painter.fontMetrics().height(),text);



    //draw base line
    painter.save();
    //#353942
    QPen pen1(Qt::white,8,Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    pen1.setColor(QColor(53, 57, 66));

    painter.setPen(pen1);
    painter.drawLines(lines);
    painter.restore();

    if(!this->isConn){
        return;
    }

    int centerHeight=this->right_top+this->right_height+this->right_space/2;

    QColor co1 =QColor(146, 196, 15) ;
    QColor co2 =QColor(0, 255, 0, 0);

    QColor co3 =QColor( 255,0, 0,200);
    QColor co4 =QColor( 255,0,0, 0);


    int mleft=this->width()-this->right_right-this->right_width-this->right_space-this->countMain;
    int mright=mleft+this->line_width_main;

    if(this->isBroken_1){

        QLinearGradient linearGradient = QLinearGradient(mleft,centerHeight,mright,centerHeight);
        linearGradient.setColorAt(0,co3);
        linearGradient.setColorAt(1,co4);

        QPen pen2(linearGradient,5);
        pen2.setCapStyle(Qt::RoundCap);
        painter.setPen(pen2);

    }else{

        QLinearGradient linearGradient = QLinearGradient(mleft,centerHeight,mright,centerHeight);
        linearGradient.setColorAt(0,co1);
        linearGradient.setColorAt(1,co2);

        QPen pen2(linearGradient,5);
        pen2.setCapStyle(Qt::RoundCap);
        painter.setPen(pen2);

    }

    painter.drawLine(mleft,centerHeight,mright,centerHeight);


    int sbottom= this->right_top+this->right_height/2+this->countSub;
    int stop= sbottom-this->line_width_sub;
//.........这里部分代码省略.........
开发者ID:kyyblabla,项目名称:gas_check,代码行数:101,代码来源:linkstatuswidget.cpp


示例2: painter

void MyGLWidget::paintGL()
{
    QPainter painter(this);
    drawBubble(&painter);
}
开发者ID:mykzhu,项目名称:game,代码行数:5,代码来源:myglwidget.cpp


示例3: lineImage

QImage VisionDisplayModule::makeOverlay(Camera::Type which)
{
    QImage lineImage(320, 240, QImage::Format_ARGB32);
    lineImage.fill(qRgba(0, 0, 0, 0));
    QPainter painter(&lineImage);
    painter.setPen(QColor(246, 15, 15));
	const messages::VisionField *visField = visMod.vision_field.getMessage(true).get();
	const messages::VisionBall *visBall = visMod.vision_ball.getMessage(true).get();
	const messages::VisionRobot *visRobots = visMod.vision_robot.getMessage(true).get();

	if (which == Camera::TOP) {
		for (int i = 0; i < visField->visual_line_size(); i++) {

			painter.drawLine(visField->visual_line(i).start_x(),
							 visField->visual_line(i).start_y(),
							 visField->visual_line(i).end_x(),
							 visField->visual_line(i).end_y());
		}


		painter.setPen(Qt::magenta);
		for (int i = 0; i < visField->visual_corner_size(); i++) {
			switch(visField->visual_corner(i).corner_type()) {
			case messages::VisualCorner::INNER_L: painter.setPen(Qt::green);
				break;
			case messages::VisualCorner::OUTER_L: painter.setPen(Qt::blue);
				break;
			case messages::VisualCorner::T: painter.setPen(Qt::black);
				break;
			case messages::VisualCorner::CIRCLE: painter.setPen(Qt::magenta);
				break;
			}
			painter.drawLine(visField->visual_corner(i).x() - 5,
							 visField->visual_corner(i).y() - 5,
							 visField->visual_corner(i).x() + 5,
							 visField->visual_corner(i).y() + 5);
			painter.drawLine(visField->visual_corner(i).x() + 5,
							 visField->visual_corner(i).y() - 5,
							 visField->visual_corner(i).x() - 5,
							 visField->visual_corner(i).y() + 5);
		}

		if (visBall->intopcam()) {
			int ball_x = visBall->x();
			int ball_y = visBall->y();
			int ball_radius = visBall->radius();

			painter.setPen(QPen(QColor(0,0,255,200), 1, Qt::SolidLine, Qt::FlatCap));
			painter.setBrush(QBrush(QColor(255,0,0,80),Qt::SolidPattern));
			painter.drawEllipse(ball_x,ball_y,2*ball_radius,2*ball_radius);
		}

		const messages::Robot red1 = visRobots->red1();
		const messages::Robot navy1 = visRobots->navy1();
		const messages::Robot red2 = visRobots->red2();
		const messages::Robot navy2 = visRobots->navy2();

		painter.setPen(QColor(0,0,0));
		painter.setBrush(QBrush(QColor(0, 0, 255, 0), Qt::SolidPattern));
		painter.setPen(QPen(QColor(255,0,0,200), 1, Qt::SolidLine, Qt::FlatCap));
		painter.setBrush(QBrush(QColor(255,0,0,80), Qt::SolidPattern));
		if (red1.on()) {
			QPoint r_points[4] = {
				QPoint(red1.x(), red1.y()),
				QPoint(red1.x()+red1.width(), red1.y()),
				QPoint(red1.x()+red1.width(), red1.y()+red1.height()),
				QPoint(red1.x(), red1.y()+red1.height())
			};
			painter.drawConvexPolygon(r_points, 4);
			if (red2.on()) {
				QPoint r_points[4] = {
					QPoint(red2.x(), red2.y()),
					QPoint(red2.x()+red2.width(), red2.y()),
					QPoint(red2.x()+red2.width(), red2.y()+red2.height()),
					QPoint(red2.x(), red2.y()+red2.height())
				};
				painter.drawConvexPolygon(r_points, 4);
			}
		}
		painter.setPen(QPen(QColor(0,0,255,200), 1, Qt::SolidLine, Qt::FlatCap));
		painter.setBrush(QBrush(QColor(255, 0, 0, 0), Qt::SolidPattern));
		painter.setBrush(QBrush(QColor(0,0,255,80), Qt::SolidPattern));
		if (navy1.on()) {
			QPoint r_points[4] = {
				QPoint(navy1.x(), navy1.y()),
				QPoint(navy1.x()+navy1.width(), navy1.y()),
				QPoint(navy1.x()+navy1.width(), navy1.y()+navy1.height()),
				QPoint(navy1.x(), navy1.y()+navy1.height())
			};
			painter.drawConvexPolygon(r_points, 4);
			if (navy2.on()) {
				QPoint r_points[4] = {
					QPoint(navy2.x(), navy2.y()),
					QPoint(navy2.x()+navy2.width(), navy2.y()),
					QPoint(navy2.x()+navy2.width(), navy2.y()+navy2.height()),
					QPoint(navy2.x(), navy2.y()+navy2.height())
				};
				painter.drawConvexPolygon(r_points, 4);
			}
		}
//.........这里部分代码省略.........
开发者ID:bmende,项目名称:nbites,代码行数:101,代码来源:VisionDisplayModule.cpp


示例4: isDown

void ToolButton::paintEvent( QPaintEvent * _pe )
{
	const bool active = isDown() || isChecked();

	QPainter painter(this);
	painter.setRenderHint(QPainter::SmoothPixmapTransform);
	painter.setRenderHint(QPainter::Antialiasing);
	painter.setPen(Qt::NoPen);

	QLinearGradient outlinebrush(0, 0, 0, height());
	QLinearGradient brush(0, 0, 0, height());

	brush.setSpread(QLinearGradient::PadSpread);
	QColor highlight(255, 255, 255, 70);
	QColor shadow(0, 0, 0, 70);
	QColor sunken(220, 220, 220, 30);
	QColor normal1(255, 255, 245, 60);
	QColor normal2(255, 255, 235, 10);

	if( active )
	{
		outlinebrush.setColorAt(0.0f, shadow);
		outlinebrush.setColorAt(1.0f, highlight);
		brush.setColorAt(0.0f, sunken);
		painter.setPen(Qt::NoPen);
	}
	else
	{
		outlinebrush.setColorAt(1.0f, shadow);
		outlinebrush.setColorAt(0.0f, highlight);
		brush.setColorAt(0.0f, normal1);
		if( m_mouseOver == false )
		{
			brush.setColorAt(1.0f, normal2);
		}
		painter.setPen(QPen(outlinebrush, 1));
	}

	painter.setBrush(brush);

	painter.drawRoundedRect( 0, 0, width(), height(), 5, 5 );

	const int dd = active ? 1 : 0;
	QPoint pt = QPoint( ( width() - m_img.width() ) / 2 + dd, 3 + dd );
	if( s_iconOnlyMode )
	{
		pt.setY( ( height() - m_img.height() ) / 2 - 1 + dd );
	}
	painter.drawImage( pt, m_img );

	if( s_iconOnlyMode == false )
	{
		const QString l = ( active && m_altLabel.isEmpty() == FALSE ) ?
								m_altLabel : m_label;
		const int w = painter.fontMetrics().width( l );
		painter.setPen( Qt::black );
		painter.drawText( ( width() - w ) / 2 +1+dd, height() - 4+dd, l );
		painter.setPen( Qt::white );
		painter.drawText( ( width() - w ) / 2 +dd, height() - 5+dd, l );
	}
}
开发者ID:EmebedQtsoft,项目名称:italc2,代码行数:61,代码来源:ToolButton.cpp


示例5: Q_UNUSED

/*!
   \return Icon representing the curve on the legend

   \param index Index of the legend entry 
                ( ignored as there is only one )
   \param size Icon size

   \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
 */
QwtGraphic QwtPlotCurve::legendIcon( int index, 
    const QSizeF &size ) const
{
    Q_UNUSED( index );

    if ( size.isEmpty() )
        return QwtGraphic();

    QwtGraphic graphic;
    graphic.setDefaultSize( size );
    graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true );

    QPainter painter( &graphic );
    painter.setRenderHint( QPainter::Antialiasing,
        testRenderHint( QwtPlotItem::RenderAntialiased ) );

    if ( d_data->legendAttributes == 0 ||
        d_data->legendAttributes & QwtPlotCurve::LegendShowBrush )
    {
        QBrush brush = d_data->brush;

        if ( brush.style() == Qt::NoBrush &&
            d_data->legendAttributes == 0 )
        {
            if ( style() != QwtPlotCurve::NoCurve )
            {
                brush = QBrush( pen().color() );
            }
            else if ( d_data->symbol &&
                ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
            {
                brush = QBrush( d_data->symbol->pen().color() );
            }
        }

        if ( brush.style() != Qt::NoBrush )
        {
            QRectF r( 0, 0, size.width(), size.height() );
            painter.fillRect( r, brush );
        }
    }

    if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine )
    {
        if ( pen() != Qt::NoPen )
        {
            QPen pn = pen();
            pn.setCapStyle( Qt::FlatCap );

            painter.setPen( pn );

            const double y = 0.5 * size.height();
            QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
        }
    }

    if ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
    {
        if ( d_data->symbol )
        {
            QRectF r( 0, 0, size.width(), size.height() );
            d_data->symbol->drawSymbol( &painter, r );
        }
    }

    return graphic;
}
开发者ID:Au-Zone,项目名称:qwt,代码行数:76,代码来源:qwt_plot_curve.cpp


示例6: painter

void Screen::paintEvent( QPaintEvent * e ) {
    //qDebug("Screen::paintEvent");
    QPainter painter(this);
    painter.eraseRect( e->rect() );
    //painter.fillRect( e->rect(), QColor(255,0,0) );
}
开发者ID:rossy,项目名称:SMPlayer2,代码行数:6,代码来源:mplayerwindow.cpp


示例7: painter

void MusicWidget::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.drawPixmap(0,0,QPixmap("image/player_skin.png"));
    painter.drawPixmap(QRectF(142,133,ArtistPic.width()/ArtistPic.height()*67,67),ArtistPic,QRectF(0,0,ArtistPic.width(),ArtistPic.height()));
}
开发者ID:thddaniel,项目名称:Intelligent-Home-Medical-System,代码行数:6,代码来源:musicwidget.cpp


示例8: Q_UNUSED

void AreaDialog::paintEvent(QPaintEvent* e)
{
  Q_UNUSED(e);

  if (mGrabbing) // grabWindow() should just get the background
    return;

  QPainter painter(this);

  QPalette pal = palette();
  QFont font   = QToolTip::font();

  QColor handleColor(85, 160, 188, 220);
  QColor overlayColor(0, 0, 0, mOverlayAlpha);
  QColor textColor = pal.color(QPalette::Active, QPalette::Text);
  QColor textBackgroundColor = pal.color(QPalette::Active, QPalette::Base);
  painter.drawPixmap(0, 0, mScreenshot->pixmap());
  painter.setFont(font);

  QRect r = mSelection.normalized().adjusted(0, 0, -1, -1);

  QRegion grey(rect());
  grey = grey.subtracted(r);
  painter.setPen(handleColor);
  painter.setBrush(overlayColor);
  painter.setClipRegion(grey);
  painter.drawRect(-1, -1, rect().width() + 1, rect().height() + 1);
  painter.setClipRect(rect());
  painter.setBrush(Qt::NoBrush);
  painter.drawRect(r);

  if (mShowHelp) {
    //Drawing the explanatory text.
    QRect helpRect = qApp->desktop()->screenGeometry(qApp->desktop()->primaryScreen());
    QString helpTxt = tr("Lightscreen area mode:\nUse your mouse to draw a rectangle to capture.\nPress any key or right click to exit.");

    helpRect.setHeight(qRound((float)(helpRect.height() / 10))); // We get a decently sized rect where the text should be drawn (centered)

    // We draw the white contrasting background for the text, using the same text and options to get the boundingRect that the text will have.
    painter.setPen(QPen(Qt::white));
    painter.setBrush(QBrush(QColor(255, 255, 255, 180), Qt::SolidPattern));
    QRectF bRect = painter.boundingRect(helpRect, Qt::AlignCenter, helpTxt);

    // These four calls provide padding for the rect
    bRect.setWidth(bRect.width() + 12);
    bRect.setHeight(bRect.height() + 10);
    bRect.setX(bRect.x() - 12);
    bRect.setY(bRect.y() - 10);

    painter.drawRoundedRect(bRect, 8, 8);

    // Draw the text:
    painter.setPen(QPen(Qt::black));
    painter.drawText(helpRect, Qt::AlignCenter, helpTxt);
  }

  if (!mSelection.isNull()) {
    // The grabbed region is everything which is covered by the drawn
    // rectangles (border included). This means that there is no 0px
    // selection, since a 0px wide rectangle will always be drawn as a line.
    QString txt = QString("%1x%2").arg(mSelection.width() == 0 ? 2 : mSelection.width())
        .arg(mSelection.height() == 0 ? 2 : mSelection.height());
    QRect textRect = painter.boundingRect(rect(), Qt::AlignLeft, txt);
    QRect boundingRect = textRect.adjusted(-4, 0, 0, 0);

    if (textRect.width() < r.width() - 2*mHandleSize &&
       textRect.height() < r.height() - 2*mHandleSize &&
       (r.width() > 100 && r.height() > 100)) // center, unsuitable for small selections
    {
      boundingRect.moveCenter(r.center());
      textRect.moveCenter(r.center());
    }
    else if (r.y() - 3 > textRect.height() &&
      r.x() + textRect.width() < rect().right()) // on top, left aligned
    {
      boundingRect.moveBottomLeft(QPoint(r.x(), r.y() - 3));
      textRect.moveBottomLeft(QPoint(r.x() + 2, r.y() - 3));
    }
    else if (r.x() - 3 > textRect.width()) // left, top aligned
    {
      boundingRect.moveTopRight(QPoint(r.x() - 3, r.y()));
      textRect.moveTopRight(QPoint(r.x() - 5, r.y()));
    }
    else if (r.bottom() + 3 + textRect.height() < rect().bottom() &&
      r.right() > textRect.width()) // at bottom, right aligned
    {
      boundingRect.moveTopRight(QPoint(r.right(), r.bottom() + 3));
      textRect.moveTopRight(QPoint(r.right() - 2, r.bottom() + 3));
    }
    else if (r.right() + textRect.width() + 3 < rect().width()) // right, bottom aligned
    {
      boundingRect.moveBottomLeft(QPoint(r.right() + 3, r.bottom()));
      textRect.moveBottomLeft(QPoint(r.right() + 5, r.bottom()));
    }
    // if the above didn't catch it, you are running on a very tiny screen...
    painter.setPen(textColor);
    painter.setBrush(textBackgroundColor);
    painter.drawRect(boundingRect);
    painter.drawText(textRect, txt);

//.........这里部分代码省略.........
开发者ID:rndstr,项目名称:Lightscreen,代码行数:101,代码来源:areadialog.cpp


示例9: painter

void Plotter::paintEvent(QPaintEvent *)
{
    QStylePainter painter(this);
    painter.drawPixmap(0 , 0 ,this->pixmap);
    this->refreshImage();
}
开发者ID:Qt-Widgets,项目名称:uav,代码行数:6,代码来源:Plotter.cpp


示例10: settings

bool Object::exportFrames1( ExportFrames1Parameters par )
{
    int frameStart = par.frameStart;
    int frameEnd = par.frameEnd;
    QTransform view = par.view;
    Layer* currentLayer = par.currentLayer;
    QSize exportSize = par.exportSize;
    QString filePath = par.filePath;
    const char* format = par.format;
    int quality = par.quality;
    bool background = par.background;
    bool antialiasing = par.antialiasing;
    QProgressDialog* progress = par.progress;
    int progressMax = par.progressMax;
    int fps = par.fps;
    int exportFps = par.exportFps;

    int frameRepeat;
    int frameReminder, frameReminder1;
    int framePutEvery, framePutEvery1;
    int frameSkipEvery, frameSkipEvery1;
    int frameNumber;
    int framePerSecond;

    QSettings settings( "Pencil", "Pencil" );

    QString extension = "";
    QString formatStr = format;
    if ( formatStr == "PNG" || formatStr == "png" )
    {
        format = "PNG";
        extension = ".png";
    }
    if ( formatStr == "JPG" || formatStr == "jpg" || formatStr == "JPEG" )
    {
        format = "JPG";
        extension = ".jpg";
        background = true; // JPG doesn't support transparency so we have to include the background
    }
    if ( filePath.endsWith( extension, Qt::CaseInsensitive ) )
    {
        filePath.chop( extension.size() );
    }
    //qDebug() << "format =" << format << "extension = " << extension;

    qDebug() << "Exporting frames from " << frameStart << "to" << frameEnd << "at size " << exportSize;
    convertNFrames( fps, exportFps, &frameRepeat, &frameReminder, &framePutEvery, &frameSkipEvery );
    qDebug() << "fps " << fps << " exportFps " << exportFps << " frameRepeat " << frameRepeat << " frameReminder " << frameReminder << " framePutEvery " << framePutEvery << " frameSkipEvery " << frameSkipEvery;
    frameNumber = 0;
    framePerSecond = 0;
    frameReminder1 = frameReminder;
    framePutEvery1 = framePutEvery;
    frameSkipEvery1 = frameSkipEvery;
    for ( int currentFrame = frameStart; currentFrame <= frameEnd; currentFrame++ )
    {
        if ( progress != NULL ) progress->setValue( ( currentFrame - frameStart )*progressMax / ( frameEnd - frameStart ) );
        QImage tempImage( exportSize, QImage::Format_ARGB32_Premultiplied );
        QPainter painter( &tempImage );

        // Make sure that old frame is erased before exporting a new one
        tempImage.fill( 0x00000000 );

        if ( currentLayer->type() == Layer::CAMERA )
        {
            QRect viewRect = ( ( LayerCamera* )currentLayer )->getViewRect();
            QTransform mapView = RectMapTransform( viewRect, QRectF( QPointF( 0, 0 ), exportSize ) );
            mapView = ( ( LayerCamera* )currentLayer )->getViewAtFrame( currentFrame ) * mapView;
            painter.setWorldTransform( mapView );
        }
        else
        {
            painter.setTransform( view );
        }
        paintImage( painter, currentFrame, background, antialiasing );

        frameNumber++;
        framePerSecond++;
        QString frameNumberString = QString::number( frameNumber );
        while ( frameNumberString.length() < 4 ) frameNumberString.prepend( "0" );

        tempImage.save( filePath + frameNumberString + extension, format, quality );
        int delta = 0;
        if ( framePutEvery )
        {
            framePutEvery1--;
            qDebug() << "-->framePutEvery1" << framePutEvery1;
            if ( framePutEvery1 )
            {
                delta = 0;
            }
            else
            {
                delta = 1; framePutEvery1 = framePutEvery;
            }
        }
        if ( frameSkipEvery )
        {
            frameSkipEvery1--;
            qDebug() << "-->frameSkipEvery1" << frameSkipEvery1;
            if ( frameSkipEvery1 )
//.........这里部分代码省略.........
开发者ID:GraphiXS6,项目名称:pencil,代码行数:101,代码来源:object.cpp


示例11: painter

/*绘制*/
void CheckersPicture::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);

    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setViewport(p.x(),p.y(),side,side);
    painter.setWindow(0, 0, zoom*(n), zoom*(n));

    QColor dark(0xcc,0xcc,0xcc,200);

    QColor endColor(0x78,0xff,0x21,200);            /*终点颜色*/
    QColor startColor(0xea,0x76,0x0f,200);              /*起点颜色*/
    QColor capturedColor(0xed,0x50,0x62,200);       /*捕获颜色*/
    QColor normalColor(0xd6,0xb8,0x2c,200);         /*正常色*/
    QColor black(0x00, 0x00, 0x00, 200);
    QColor white(0xff, 0xff, 0xff, 220);
    QColor light(0xed,0xfc,0xdf,200);
    QColor deep(0x5a,0x61,0x54,200);

    /*绘制棋盘*/
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            QRect rect = pixelRect(i, j);
            if( !((i+j%2)%2) ) {
                    painter.fillRect(rect, deep);
            } else {
                painter.fillRect(rect, light);
            }
        }
    }

    int ix,jx;

    if(v.size()) {
        int type;
        for(unsigned i=0; i< v.size(); i++) {
            color==WHITE ? jx = n-1-v.at(i).y : jx = v.at(i).y;
            color==WHITE ? ix = n-1-v.at(i).x : ix = v.at(i).x;
            QRect rect = pixelRect(ix, jx);
            type = v.at(i).type;
            if(type == MOVEDFROM)
                painter.fillRect(rect, startColor);
            else if(type == MOVEDTO || type == TOKING)
                painter.fillRect(rect, endColor);
            else if(type == MOVEDTHROUGH)
                painter.fillRect(rect, normalColor);
            else if(type == DELETED)
                painter.fillRect(rect, capturedColor);
        }
    }

    int s = zoom*0.4;
    int sd = zoom*0.3;
    /*画白棋*/
    if(curstate){   /*如果棋局状态发生了改变*/
        painter.setPen(QPen(black,zoom*0.025));
        painter.setBrush(QBrush(white));
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                /*如果是白色则从最后一行开始画*/
                color==WHITE ? jx = j+1 : jx = n-j;
                color==WHITE? ix = n-i : ix = i+1;
                if(curstate->at(i,j)==WHITE)
                    painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),s,s);
                if(curstate->at(i,j)==WHITEKING) {
                    painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),s,s);
                    painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),sd,sd);
                }
            }
        }
        /*画黑棋*/
        painter.setBrush(QBrush(black));
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                color==WHITE ? jx = j+1 : jx = n-j;
                color==WHITE ? ix = n-i : ix = i+1;
                if(curstate->at(i,j)==BLACK)
                    painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),s,s);
                if(curstate->at(i,j)==BLACKKING) {
                    painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),s,s);
                    painter.setPen(QPen(white,zoom*0.1));
                    painter.drawEllipse(QPoint(zoom*(ix-0.5),zoom*(jx-0.5)),sd,sd);
                    painter.setPen(QPen(black,zoom*0.1));
                }
            }
        }
    }
    if (thinking && showHourglass)
    {
        painter.setWindow(painter.viewport());
        painter.drawImage((width() - hourglass.width()) / 2, (height() - hourglass.height()) / 2, hourglass);
    }
}
开发者ID:Moilk,项目名称:Draughts,代码行数:94,代码来源:checkerpicture.cpp


示例12: painter

void CWizShadowWidget::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    m_shadow->DrawBorder(&painter, rect());
}
开发者ID:Axure,项目名称:WizQTClient,代码行数:5,代码来源:wizshadoweffect.cpp


示例13: switch

/************
 *
 *功能:绘制背景
 *
 *
 *
 **/
void    mainview::paintEvent(QPaintEvent *)
{

    switch(ui->widgetstack->currentIndex())
    {
        case    0:
        case    2:
        logo_y = this->height()/2 - 200;
        logo_x = this->width()/2 - 100;
        break;
        default:
        logo_y = 50;
        logo_x=this->width()/2-100;
        break;
    }
    switch(ui->widgetstack->currentIndex())
    {
        case  0:
        ui->widgetstack->move(logo_x-80,logo_y+50);
        break;
        case  1://networkconfig
        {
        ui->widgetstack->move(logo_x-150,height()/2-325);
        if(height()/2 > 325)
        ui->widgetstack->resize(461,650);
        break;}
        case  3://wifi
        ui->widgetstack->move(logo_x-50,height()/2-283);
        break;
        case  4://vmlist
        {
                if(this->hostlist->nums_vm <= 12)
                    //vmlist display  order  in  the  windows
                {
                    ui->widgetstack->move(width()/20,this->height()/2-100);
                }
                else if(this->hostlist->nums_vm > 12 && this->hostlist->nums_vm <= 18 )
                {
                    ui->widgetstack->move(width()/20,this->height()/2-200);
                }
                else
                {
                    ui->widgetstack->move(width()/20,this->height()/2-300);
                }
        break;
        }
        default:
        ui->widgetstack->move(logo_x-100,height()/2-80);
        break;

    }
    
    
    
    
    QFont font("Arial",10);
    QPainter painter(this);

    painter.drawPixmap(rect(),QPixmap("./images/terminal-bg.png"));
    painter.drawPixmap(QPoint(logo_x,logo_y),QPixmap("./images/terminal-logo.png"));

    QPixmap  *map = new  QPixmap("./images/information.png");
    painter.drawPixmap(QPoint(this->width()-200,this->height()-50),map->copy(0,map->height()/2,map->width(),
                map->height()/14));//down
    painter.drawPixmap(QPoint(this->width()-100,this->height()-50),map->copy(0,map->height()/2+map->height()/7,//reset
                map->width(),map->height()/14));

    painter.drawPixmap(QPoint(this->width()-70,10),map->copy(0,map->height()/14,map->width(),map->height()/14));//?help
    painter.drawPixmap(QPoint(this->width()-230,10),map->copy(0,map->height()/7+map->height()/14,//reflush
                map->width(),map->height()/14));
    painter.drawPixmap(QPoint(this->width()-270,10),map->copy(0,2*(map->height()/7)+map->height()/14,map->width(),
                                                                  map->height()/14));//more operator
    delete map;

    if(wifi->connectedname.length()<=0)
    {
    map = new  QPixmap("./images/wifi.png");
    painter.drawPixmap(QPoint(this->width()-120,5),map->copy(0,map->height()/2,map->width(),map->height()/2));
    }
    else
    {
    map = new  QPixmap("./images/wifi_img.png"/*wifi->CheckSignals(wifi->choice_signal)*/);
    painter.drawPixmap(QPoint(this->width()-120,5),map->copy(0,10*map->height()/14,map->width(),map->height()/14));
    }

    delete map;

    QFont font1("Arial",10,QFont::Normal,true);
    painter.setFont(font1);//????
    painter.setPen(QColor(Qt::white));
    painter.drawText(155+logo_x,15+logo_y,version);
    painter.setFont(font);//????
    painter.drawText(20,this->height()-30,"Copyright (C)2001-2015 Yovole Corporation, All Rights Reserved");
//.........这里部分代码省略.........
开发者ID:hwc56,项目名称:newcloud,代码行数:101,代码来源:mainview.cpp


示例14: painter

void ImagingWindow::paintEvent(QPaintEvent *)
{
   QPainter painter(this);
   painter.drawPixmap(0, 0, plot);
}
开发者ID:zhyuey,项目名称:simcalib,代码行数:5,代码来源:imagingwindow.cpp


示例15: painter

void ScribbleArea::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    QRect dirtyRect = event->rect();
    painter.drawImage(dirtyRect, image, dirtyRect);
}
开发者ID:QYPan,项目名称:qt-examples,代码行数:6,代码来源:scribblearea.cpp


示例16: QgsDebugMsg

void QgsBench::render()
{
  QgsDebugMsg( "entered" );

  QgsDebugMsg( "extent: " +  mMapRenderer->extent().toString() );

  QMap<QString, QgsMapLayer*> layersMap = QgsMapLayerRegistry::instance()->mapLayers();

  QStringList layers( layersMap.keys() );

  mMapRenderer->setLayerSet( layers );

  if ( mSetExtent )
  {
    mMapRenderer->setExtent( mExtent );
  }

  // Maybe in future
  //outputCRS = QgsCRSCache::instance()->crsByAuthId( crsId );
  //mMapRenderer->setMapUnits( outputCRS.mapUnits() );
  //mMapRenderer->setDestinationCrs( outputCRS );

  // TODO: this should be probably set according to project
  mMapRenderer->setProjectionsEnabled( true );

  // Necessary?
  //mMapRenderer->setLabelingEngine( new QgsPalLabeling() );

  mImage = new QImage( mWidth, mHeight, QImage::Format_ARGB32_Premultiplied );
  mImage->fill( 0 );

  mMapRenderer->setOutputSize( QSize( mWidth, mHeight ), mImage->logicalDpiX() );

  QPainter painter( mImage );

  painter.setRenderHints( mRendererHints );

  for ( int i = 0; i < mIterations; i++ )
  {
    start();
    mMapRenderer->render( &painter );
    elapsed();
  }

  mLogMap.insert( "iterations", mTimes.size() );
  mLogMap.insert( "revision", QGSVERSION );

  // Calc stats: user, sys, total
  double min[4], max[4];
  double stdev[4] = {0.};
  double maxdev[4] = {0.};
  double avg[4] = {0.};

  for ( int t = 0; t < 4; t++ )
  {
    for ( int i = 0; i < mTimes.size(); i++ )
    {
      avg[t] += mTimes[i][t];

      if ( i == 0 || mTimes[i][t] < min[t] ) min[t] = mTimes[i][t];
      if ( i == 0 || mTimes[i][t] > max[t] ) max[t] = mTimes[i][t];
    }
    avg[t] /= mTimes.size();
  }

  QMap<QString, QVariant> timesMap;
  for ( int t = 0; t < 4; t++ )
  {
    if ( mIterations > 1 )
    {
      for ( int i = 0; i < mTimes.size(); i++ )
      {
        double d = fabs( avg[t] - mTimes[i][t] );
        stdev[t] += pow( d, 2 );
        if ( i == 0 || d > maxdev[t] ) maxdev[t] = d;
      }

      stdev[t] = sqrt( stdev[t] / mTimes.size() );
    }

    const char *pre[] = { "user", "sys", "total", "wall" };

    QMap<QString, QVariant> map;

    map.insert( "min", min[t] );
    map.insert( "max", max[t] );
    map.insert( "avg", avg[t] );
    map.insert( "stdev", stdev[t] );
    map.insert( "maxdev", maxdev[t] );

    timesMap.insert( pre[t], map );
  }
  mLogMap.insert( "times", timesMap );
}
开发者ID:loiemilio,项目名称:Quantum-GIS,代码行数:94,代码来源:qgsbench.cpp


示例17: painter

void LayerItem::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.drawPixmap(0, 0, _pixmap);
}
开发者ID:BackupTheBerlios,项目名称:qtfin-svn,代码行数:5,代码来源:layeritem.cpp


示例18: painter

void AboutWindow::Logo::paintEvent(QPaintEvent*) {
  QPainter painter(this);
  QPixmap pixmap(":/logo.png");
  painter.drawPixmap(0, 0, pixmap);
}
开发者ID:BigEd,项目名称:snes-sdk,代码行数:5,代码来源:about.cpp


示例19: bm

void QwtPicker::PickerWidget::updateMask()
{
    QRegion mask;

    if ( d_type == RubberBand )
    {
        QBitmap bm( width(), height() );
        bm.fill( Qt::color0 );

        QPainter painter( &bm );
        QPen pen = d_picker->rubberBandPen();
        pen.setColor( Qt::color1 );
        painter.setPen( pen );

        d_picker->drawRubberBand( &painter );

        mask = QRegion( bm );
    }
    if ( d_type == Text )
    {
        d_hasTextMask = parentWidget()->testAttribute( Qt::WA_PaintOnScreen );

        if ( d_hasTextMask )
        {
            const QwtText label = d_picker->trackerText(
                d_picker->trackerPosition() );

            if ( label.testPaintAttribute( QwtText::PaintBackground )
                && label.backgroundBrush().style() != Qt::NoBrush )
            {
                if ( label.backgroundBrush().color().alpha() > 0 )
                {
                    // We don't need a text mask, when we have a background
                    d_hasTextMask = false;
                }
            }
        }

        if ( d_hasTextMask )
        {
            QBitmap bm( width(), height() );
            bm.fill( Qt::color0 );

            QPainter painter( &bm );
            painter.setFont( font() );

            QPen pen = d_picker->trackerPen();
            pen.setColor( Qt::color1 );
            painter.setPen( pen );

            d_picker->drawTracker( &painter );

            mask = QRegion( bm );
        }
        else
        {
            mask = d_picker->trackerRect( font() );
        }
    }

    QWidget *w = parentWidget();
    if ( w && !w->testAttribute( Qt::WA_PaintOnScreen ) )
    {
        // The parent widget gets an update for its complete rectangle
        // when the mask is changed in visible state.
        // With this hide/show we only get an update for the
        // previous mask.

        hide();
    }
    setMask( mask );
    setVisible( !mask.isEmpty() );
}
开发者ID:dcardenasnl,项目名称:Test,代码行数:73,代码来源:qwt_picker.cpp


示例20: painter

    void MapControl::paintEvent(QPaintEvent* evnt)
    {
        QWidget::paintEvent(evnt);
        QPainter painter(this);
        double line;


        // painter.translate(150,190);
        // painter.scale(0.5,0.5);

        // painter.setClipRect(0,0, size.width(), size.height());

        // painter.setViewport(10000000000,0,size.width(),size.height());

        /*
        // rotating
            rotation = 45;
            painter.translate(256,256);
            painter.rotate(rotation);
            painter.translate(-256,-256);
        */

        layermanager->drawImage(&painter);
        layermanager->drawGeoms(&painter);

        // added by wolf
        // draw scale
        if (scaleVisible)
        {
            if (currentZoom() >= 0 && distanceList.size() > currentZoom())
            {
                line = distanceList.at( currentZoom() ) / pow(2, 18-currentZoom() ) / 0.597164;

                // draw the scale
                painter.setPen(Qt::black);
                QPoint p1(10,size.height()-20);
                QPoint p2((int)line,size.height()-20);
                painter.drawLine(p1,p2);

                painter.drawLine(10,size.height()-15, 10,size.height()-25);
                painter.drawLine((int)line,size.height()-15, (int)line,size.height()-25);

                QString distance;
                if (distanceList.at(currentZoom()) >= 1000)
                {
                    distance = QVariant( distanceList.at(currentZoom())/1000 )  .toString()+ " km";
                }
                else
                {
                    distance = QVariant( distanceList.at(currentZoom()) ).toString() + " m";
                }

                painter.drawText(QPoint((int)line+10,size.height()-15), distance);
            }
        }

        painter.drawLine(screen_middle.x(), screen_middle.y()-10,
                         screen_middle.x(), screen_middle.y()+10); // |
        painter.drawLine(screen_middle.x()-10, screen_middle.y(),
                         screen_middle.x()+10, screen_middle.y()); // -

        // int cross_x = int(layermanager->getMapmiddle_px().x())%256;
        // int cross_y = int(layermanager->getMapmiddle_px().y())%256;
        // painter.drawLine(screen_middle.x()-cross_x+cross_x, screen_middle.y()-cross_y+0,
        //   screen_middle.x()-cross_x+cross_x, screen_middle.y()-cross_y+256); // |
        // painter.drawLine(screen_middle.x()-cross_x+0, screen_middle.y()-cross_y+cross_y,
        //   screen_middle.x()-cross_x+256, screen_middle.y()-cross_y+cross_y); // -

        painter.drawRect(0,0, size.width(), size.height());
        /*
        // rotating
          painter.setMatrix(painter.matrix().inverted());
        //qt = painter.transform();
           qm = painter.combinedMatrix();
        */
        if (mousepressed && mymousemode == Dragging)
        {
            QRect rect = QRect(pre_click_px, current_mouse_pos);
            painter.drawRect(rect);
        }


        // Draw the Lat and Lon if needed
        if (cursorPosVisible) {
          line = distanceList.at( currentZoom() ) / pow(2, 18-currentZoom() ) / 0.597164;

          QString str;
          str = QString(tr(" Lat: %1")).arg(currentWorldCoordinate.y());
          painter.drawText(QPoint((int)line+70,size.height()-15), str);

          str = QString(tr(" Lon: %1")).arg(currentWorldCoordinate.x());
          painter.drawText(QPoint((int)line+160,size.height()-15), str);
        }

        emit viewChanged(currentCoordinate(), currentZoom());
    }
开发者ID:calihem,项目名称:qgroundcontrol,代码行数:96,代码来源:mapcontrol.cpp



注:本文中的painter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ paintingDisabled函数代码示例发布时间:2022-05-30
下一篇:
C++ paint_util_set_segment_support_height函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap