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


C++ QPointArray::setPoints方法代码示例

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


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

示例1: drawClock

//
// The clock is painted using a 1000x1000 square coordinate system, in
// the a centered square, as big as possible.  The painter's pen and
// brush colors are used.
//
void QTodoClock::drawClock( QPainter *paint )
{
	paint->save();

	paint->setWindow( -500,-500, 1000,1000 );

	QRect v = paint->viewport();
	int d = QMIN( v.width(), v.height() );
	paint->setViewport( v.left() + (v.width()-d)/2,
	                    v.top() + (v.height()-d)/2, d, d );

	QPointArray pts;

	paint->save();
	paint->rotate( 30*(time.hour()%12-3) + time.minute()/2 );
	pts.setPoints( 4, -20,0,  0,-20, 300,0, 0,20 );
	paint->drawConvexPolygon( pts );
	paint->restore();

	paint->save();
	paint->rotate( (time.minute()-15)*6 );
	pts.setPoints( 4, -10,0, 0,-10, 400,0, 0,10 );
	paint->drawConvexPolygon( pts );
	paint->restore();

	for ( int i=0; i<12; i++ )
	{
		paint->drawLine( 440,0, 460,0 );
		paint->rotate( 30 );
	}

	paint->restore();
}
开发者ID:BackupTheBerlios,项目名称:qtodo-svn,代码行数:38,代码来源:qtodo_clock.cpp

示例2: switch

void
QWindowsStyle::drawArrow( QPainter *p, ArrowType type, bool down,
		 int x, int y, int w, int h,
		 const QColorGroup &g, bool enabled, const QBrush *fill )
{
    QPointArray a;				// arrow polygon
    switch ( type ) {
    case UpArrow:
	a.setPoints( 7, -4,1, 2,1, -3,0, 1,0, -2,-1, 0,-1, -1,-2 );
	break;
    case DownArrow:
	a.setPoints( 7, -4,-2, 2,-2, -3,-1, 1,-1, -2,0, 0,0, -1,1 );
	break;
    case LeftArrow:
	a.setPoints( 7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0 );
	break;
    case RightArrow:
	a.setPoints( 7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0 );
	break;
    }
    if ( a.isNull() )
	return;

    if ( down ) {
	x++;
	y++;
    }

    QPen savePen = p->pen();			// save current pen
    if (down)
	p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
    if ( fill )
	p->fillRect( x, y, w, h, *fill );
    if (down)
	p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
    if ( enabled ) {
	a.translate( x+w/2, y+h/2 );
	p->setPen( g.buttonText() );
	p->drawLineSegments( a, 0, 3 );		// draw arrow
	p->drawPoint( a[6] );
    } else {
	a.translate( x+w/2+1, y+h/2+1 );
	p->setPen( g.light() );
	p->drawLineSegments( a, 0, 3 );		// draw arrow
	p->drawPoint( a[6] );
	a.translate( -1, -1 );
	p->setPen( g.mid() );
	p->drawLineSegments( a, 0, 3 );		// draw arrow
	p->drawPoint( a[6] );
    }
    p->setPen( savePen );			// restore pen

}
开发者ID:opieproject,项目名称:qte-opie,代码行数:53,代码来源:qwindowsstyle.cpp

示例3: qDrawWinArrow

static void qDrawWinArrow( QPainter *p, Qt::ArrowType type, bool down,
			   int x, int y, int w, int h,
			   const QColorGroup &g, bool enabled )
{
    QPointArray a;				// arrow polygon
    switch ( type ) {
    case Qt::UpArrow:
	a.setPoints( 7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2 );
	break;
    case Qt::DownArrow:
	a.setPoints( 7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2 );
	break;
    case Qt::LeftArrow:
	a.setPoints( 7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0 );
	break;
    case Qt::RightArrow:
	a.setPoints( 7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0 );
	break;
    }
    if ( a.isNull() )
	return;

    if ( down ) {
	x++;
	y++;
    }

    QPen savePen = p->pen();			// save current pen
    if (down)
	p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
    p->fillRect( x, y, w, h, g.brush( QColorGroup::Button ) );
    if (down)
	p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
    if ( enabled ) {
	a.translate( x+w/2, y+h/2 );
	p->setPen( g.foreground() );
	p->drawLineSegments( a, 0, 3 );		// draw arrow
	p->drawPoint( a[6] );
    } else {
	a.translate( x+w/2+1, y+h/2+1 );
	p->setPen( g.light() );
	p->drawLineSegments( a, 0, 3 );		// draw arrow
	p->drawPoint( a[6] );
	a.translate( -1, -1 );
	p->setPen( g.mid() );
	p->drawLineSegments( a, 0, 3 );		// draw arrow
	p->drawPoint( a[6] );
    }
    p->setPen( savePen );			// restore pen
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:50,代码来源:qdrawutil.cpp

示例4: paintCar

void paintCar( QPainter *p )			// paint a car
{
    QPointArray a;
    QBrush brush( Qt::yellow, Qt::SolidPattern );
    p->setBrush( brush );			// use solid, yellow brush

    a.setPoints( 5, 50,50, 350,50, 450,120, 450,250, 50,250 );
    p->drawPolygon( a );			// draw car body

    QFont f( "courier", 12, QFont::Bold );
    p->setFont( f );

    QColor windowColor( 120, 120, 255 );	// a light blue color
    brush.setColor( windowColor );		// set this brush color
    p->setBrush( brush );			// set brush
    p->drawRect( 80, 80, 250, 70 );		// car window
    p->drawText( 180, 80, 150, 70, Qt::AlignCenter, "--  Qt  --\nTrolltech AS" );

    QPixmap pixmap;
    if ( pixmap.load("flag.bmp") )		// load and draw image
	p->drawPixmap( 100, 85, pixmap );

    p->setBackgroundMode( Qt::OpaqueMode );		// set opaque mode
    p->setBrush( Qt::DiagCrossPattern );		// black diagonal cross pattern
    p->drawEllipse( 90, 210, 80, 80 );		// back wheel
    p->setBrush( Qt::CrossPattern );		// black cross fill pattern
    p->drawEllipse( 310, 210, 80, 80 );		// front wheel
}
开发者ID:opieproject,项目名称:qte-opie,代码行数:28,代码来源:picture.cpp

示例5: paintEvent

void AnalogClock::paintEvent( QPaintEvent * )	// paint clock
{
    if ( !isVisible() )				// is is invisible
	return;
    time = QTime::currentTime();		// save current time

    QPointArray pts;
    QPainter paint( this );
    paint.setBrush( foregroundColor() );	// fill with foreground color

    QPoint cp = rect().center();		// widget center point
    int d = QMIN(width(),height());		// we want a circular clock

    QWMatrix matrix;				// setup transformation matrix
    matrix.translate( cp.x(), cp.y() );		// origin at widget center
    matrix.scale( d/1000.0F, d/1000.0F );	// scale coordinate system

    float h_angle = 30*(time.hour()%12-3) + time.minute()/2;
    matrix.rotate( h_angle );			// rotate to draw hour hand
    paint.setWorldMatrix( matrix );
    pts.setPoints( 4, -20,0,  0,-20, 300,0, 0,20 );
    paint.drawPolygon( pts );			// draw hour hand
    matrix.rotate( -h_angle );			// rotate back to zero

    float m_angle = (time.minute()-15)*6;
    matrix.rotate( m_angle );			// rotate to draw minute hand
    paint.setWorldMatrix( matrix );
    pts.setPoints( 4, -10,0, 0,-10, 400,0, 0,10 );
    paint.drawPolygon( pts );			// draw minute hand
    matrix.rotate( -m_angle );			// rotate back to zero

    for ( int i=0; i<12; i++ ) {		// draw hour lines
	paint.setWorldMatrix( matrix );
	paint.drawLine( 450,0, 500,0 );
	matrix.rotate( 30 );
    }
}
开发者ID:kthxbyte,项目名称:Qt1.45-Linaro,代码行数:37,代码来源:aclock.cpp

示例6: paintEvent

/*!
  Paints the resize grip - small diagonal textured lines in the
  lower right-hand corner.
*/
void QSizeGrip::paintEvent( QPaintEvent *e )
{
    QPainter painter( this );
    painter.setClipRegion(e->region());
    painter.translate( width()-13, height()-13 ); // paint in the corner
    QPointArray a;
    a.setPoints( 3, 1,12, 12,1, 12,12 );
    painter.setPen( QPen( colorGroup().dark(), 1 ) );
    painter.setBrush( colorGroup().dark() );
    painter.drawPolygon( a );
    painter.setPen( QPen( colorGroup().light(), 1 ) );
    painter.drawLine(  0, 12, 13,  -1 );
    painter.drawLine(  4, 12, 13,  3 );
    painter.drawLine( 8, 12, 13, 7 );
    painter.setPen( QPen( colorGroup().background(), 1 ) );
    painter.drawLine( 3, 12, 13, 2 );
    painter.drawLine( 7, 12, 13, 6 );
    painter.drawLine( 11, 12, 13, 10 );
    painter.drawLine( 12, 12, 13, 11 );
}
开发者ID:kthxbyte,项目名称:QT2-Linaro,代码行数:24,代码来源:qsizegrip.cpp

示例7: drawSegment

void BW_LED_Number::drawSegment( const QPoint &pos, char seg_number, QPainter &p,
			      int Segment_Length, bool erase){


  QPoint pt = pos;
  QColorGroup g = colorGroup();
  QColor lightColor,darkColor;
  if ( erase ){
    
    lightColor = offcolor;
    darkColor  = offcolor;
    
  } else {
    lightColor = g.light();
    darkColor  = g.dark();
  }

  //  int Width = (int) Segment_Length/5 ; // original
  int Width = (int) Segment_Length/4;

  
  QBrush brush(g.light()); 
  QPointArray pts;
  
  
  pt.ry() += (QCOORD)Width/2;
  
  
  if (erase){
    
    p.setBrush(offcolor);
    brush.setColor(offcolor);
    
  }
  else
    p.setBrush(g.light());
  
  if(!smallLED){
    
    switch ( seg_number ) {
    case 0 :
      
      
      if (erase) 
	p.setPen(offcolor);
      
      pts.setPoints(3,pt.x(), pt.y() ,
		    pt.x(), pt.y()-Width +1,
		    pt.x() + Width-1, pt.y());
      p.drawPolygon(pts);
      pts.setPoints(3,pt.x(), pt.y() + Segment_Length -Width - Width/2 -1  ,
		    pt.x() + Width -1 , pt.y()  -Width +Segment_Length - Width/2 -1,
		    pt.x() , pt.y() + Segment_Length - 3*Width/4 -1);
      p.drawPolygon(pts);
      
      if (erase)
	p.setPen(g.light());
      
      p.fillRect(pt.x(),pt.y()+ Width/2 -1, Width , 
		 Segment_Length - Width -Width +1 ,brush);
      
      break;
    case 1 :
      
      p.fillRect(pt.x()+Width,pt.y()- Width , Segment_Length -2* Width, Width ,brush);
      
      if (erase) 
	p.setPen(offcolor);
      
      pts.setPoints(3,pt.x()+1, pt.y()-Width  ,
		    pt.x()+Width, pt.y()-Width  ,
		    pt.x() + Width, pt.y() -1 );
      p.drawPolygon(pts);
      
      pts.setPoints(3,pt.x()+ Segment_Length - Width , pt.y() - Width,
		    pt.x()+  Segment_Length  -1, pt.y() - Width,
		    pt.x() + Segment_Length - Width , pt.y() -1 );
      p.drawPolygon(pts);
      
      if (erase) 
	p.setPen(g.light());
      break;
    case 2 :
      pt.rx() += (QCOORD)(Segment_Length);
      
      
      if (erase) 
	p.setPen(offcolor);
      
      pts.setPoints(3,pt.x() , pt.y() ,
		    pt.x() , pt.y() - Width + 1,    // changes from 1 to 2 
		    pt.x() - Width +1, pt.y() );
      
      p.drawPolygon(pts);
      
      pts.setPoints(3,pt.x() , pt.y() + Segment_Length - Width - Width/2 -1,
		    pt.x() , pt.y() + Segment_Length - 3*Width/4 - 1,
		    pt.x() - Width +1, pt.y() + Segment_Length - Width - Width/2 -1);

      p.drawPolygon(pts);
//.........这里部分代码省略.........
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:101,代码来源:bwlednum.cpp

示例8: mouseReleaseEvent

// Mouse release event handler
void MyMainWindow::mouseReleaseEvent(QMouseEvent* e)
{
   if( e->button() == Qt::LeftButton )
   {
      
      if ( image->isNull() ) 
      { 
         OnLoadImage(); 
      }
      else 
      { 
         QPointArray a;

         // For any temporary pen and brush settings
         QPen tpen;
         QBrush tbrush;

         int mx, my;  // displacements of user moving the mouse

         // close active painter
         if( paint->isActive () )
         {
            paint->end();
         }
         switch( selectedbutton ){
            case DPen:  // drawing with the Pen tool
               paint->begin( image );  // begin painting onto picture   
               paint->setClipRect ( 0, 0, image->width(), image->height() ); // clipping
               paint->setPen( pendialog->pen ); // set the painter settings from the pen dialog
              
               // Set the array of points 
               a.setPoints( 3, dx - xPos, dy - yPos,
                               px - xPos, py - yPos,
                               e->x() - xPos, e->y() - yPos );
               paint->drawPolyline( a, 0, 3 );

               // update the cursor positions
               dx = px; dy = py;
               px = e->x(); py = e->y();

               paint->end();
               break;

            case DLine:  // drawing with the Line tool 
               // TODO 
               if(!linedialog->poly){
               paint->begin( image ); // begin painting onto the picture
               paint->setClipRect ( 0, 0, image->width(), image->height() );  // clipping
               paint->setPen( linedialog->pen ); 
               paint->drawLine(px-xPos, py-yPos, e->x()-xPos, e->y()-yPos);
               //store previous coord. for poly line 
               paint->end();
               }
               
               if(linedialog->poly && !linedialog->firstChoosePoly){
               paint->begin( image ); // begin painting onto the picture
               paint->setClipRect ( 0, 0, image->width(), image->height() );  // clipping
               paint->setPen( linedialog->pen ); 
               paint->drawLine(dx-xPos, dy-yPos, e->x()-xPos, e->y()-yPos);
               paint->end();
               }
               dx = e->x(); 
               dy = e->y();
               
               if(linedialog->firstChoosePoly)
                  linedialog->firstChoosePoly = false;
                  
               if(linedialog->resetPoly){
                  linedialog->firstChoosePoly = true;
                  linedialog->resetPoly = false;
               }
               
               break;

            case DEraser:  // drawing with the Eraser tool
               // TODO
            break;

            case Drect:  // drawing with the Rectangle tool
               // TODO  
                // begins painting the pixmap image
                paint->begin(image);
                paint->setPen( rectdialog->pen ); // set the pen of the painter
                paint->setBrush(rectdialog->brush); // set the brush of the painter
                paint->setClipRect(0, 0, image->width(), image->height()); // enable drawing with a rectangular area only
                switch (rectdialog->drawtype){
                  case 0://rect
                   paint->drawRect(px-xPos, py-yPos, e->x()-px, e->y()-py); // draw a rectangle of size determined dynamically
                   break;
                   
                  case 1://round-rect
                   paint->drawRoundRect(px-xPos, py-yPos, e->x()-px, e->y()-py); // draw a rectangle of size determined dynamically
                   break;
                  
                  case 2://circle
                  {
                   double diagonal=sqrt(pow((double)(e->x()-px),2.0)+pow((double)(e->y()-py),2.0));
                   int negativeX, negativeY;
                   if ((e->x()-px)>0) negativeX=1;else negativeX=-1;
//.........这里部分代码省略.........
开发者ID:MarShin,项目名称:qt_paint,代码行数:101,代码来源:my_widget.cpp

示例9: mouseMoveEvent

// Mouse move event handler
void MyMainWindow::mouseMoveEvent(QMouseEvent* e)
{
   // dragging by left button click
   if( mouseevent == 1 )
   {
      if ( image->isNull() ) 
      { 
      }
      else 
      { 
         QPointArray a;

         // For any temporary pen and brush settings
         QPen tpen;
         QBrush tbrush;

         // close active painter
         if( paint->isActive() )
         {
            paint->end();
         }

     //    int mx, my;  // displacements of user moving the mouse

         switch( selectedbutton ){
            case DPen:  // drawing with the Pen tool
               paint->begin( image ); // begin painting onto the picture
               paint->setClipRect ( 0, 0, image->width(), image->height() );  // clipping
               paint->setPen( pendialog->pen );  // set the painter settings from the pen dialog
               // Set the array of points 
               a.setPoints( 3, dx - xPos, dy - yPos, 
                               px - xPos, py - yPos,
                               e->x() - xPos, e->y() - yPos );
               paint->drawPolyline( a, 0, 3 );//**
 
               // update the cursor positions
               dx = px; dy = py; 
               px = e->x(); py = e->y();

               paint->end(); // end painting onto the picture
               paintbmp();
               break;

            case DLine: { // drawing with the Line tool
               paintbmp();
               // TODO
               if(linedialog->poly){
                 px = dx;
                 py = dy;
               }
               paint->begin( this ); // begin painting onto the picture
               paint->setClipRect ( xPos, yPos, image->width(), image->height() );  // clipping
               paint->setPen( linedialog->pen );  
               paint->drawLine(px, py, e->x(), e->y());
               paint->end();
                  
               break;
            }
            
            case DEraser: { // drawing with the Eraser tool
               
                int size=eraserdialog->size;
                QPen pen(black, 1, Qt::SolidLine);
                QBrush brush(bgcolor);
               
               paintbmp();
               // TODO
               //set widget eraser
               paint->begin( this ); // begin painting onto the picture
               paint->setPen(pen); 
               paint->setBrush(brush);
               paint->setClipRect ( xPos, yPos, image->width(), image->height() );  // clipping
               paint->drawRect(e->x()-size/2, e->y()-size/2, size, size);
               paint->end();
               
               //set Pixmap eraser
               paint->begin( image ); // begin painting onto the picture
               pen.setColor(bgcolor);
               paint->setPen(pen); 
               paint->setBrush(brush);
               paint->setClipRect ( 0, 0, image->width(), image->height() );  // clipping
               paint->drawRect(e->x()-size/2-xPos, e->y()-size/2-yPos, size, size);
               paint->end();
               break;
               }

            case Drect:  // drawing with the Rectangle tool
            paintbmp();
               // TODO
		            
               
               // begins painting the widget
                paint->begin(this);
                paint->setPen( rectdialog->pen ); // set the pen of the painter
                paint->setBrush(rectdialog->brush); // set the brush of the painter
                paint->setClipRect(xPos, yPos, image->width(), image->height()); // enable drawing with a rectangular area only
                
                switch (rectdialog->drawtype){
                  case 0://rect
//.........这里部分代码省略.........
开发者ID:MarShin,项目名称:qt_paint,代码行数:101,代码来源:my_widget.cpp

示例10: qDrawMotifArrow

// motif arrows look the same whether they are used or not
// is this correct?
static void qDrawMotifArrow( QPainter *p, Qt::ArrowType type, bool down,
			     int x, int y, int w, int h,
			     const QColorGroup &g, bool )
{
    QPointArray bFill;				// fill polygon
    QPointArray bTop;				// top shadow.
    QPointArray bBot;				// bottom shadow.
    QPointArray bLeft;				// left shadow.
#ifndef QT_NO_TRANSFORMATIONS
    QWMatrix	matrix;				// xform matrix
#endif
    bool vertical = type == Qt::UpArrow || type == Qt::DownArrow;
    bool horizontal = !vertical;
    int	 dim = w < h ? w : h;
    int	 colspec = 0x0000;			// color specification array

    if ( dim < 2 )				// too small arrow
	return;

    if ( dim > 3 ) {
	if ( dim > 6 )
	    bFill.resize( dim & 1 ? 3 : 4 );
	bTop.resize( (dim/2)*2 );
	bBot.resize( dim & 1 ? dim + 1 : dim );
	bLeft.resize( dim > 4 ? 4 : 2 );
	bLeft.putPoints( 0, 2, 0,0, 0,dim-1 );
	if ( dim > 4 )
	    bLeft.putPoints( 2, 2, 1,2, 1,dim-3 );
	bTop.putPoints( 0, 4, 1,0, 1,1, 2,1, 3,1 );
	bBot.putPoints( 0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2 );

	for( int i=0; i<dim/2-2 ; i++ ) {
	    bTop.putPoints( i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i );
	    bBot.putPoints( i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i );
	}
	if ( dim & 1 )				// odd number size: extra line
	    bBot.putPoints( dim-1, 2, dim-3,dim/2, dim-1,dim/2 );
	if ( dim > 6 ) {			// dim>6: must fill interior
	    bFill.putPoints( 0, 2, 1,dim-3, 1,2 );
	    if ( dim & 1 )			// if size is an odd number
		bFill.setPoint( 2, dim - 3, dim / 2 );
	    else
		bFill.putPoints( 2, 2, dim-4,dim/2-1, dim-4,dim/2 );
	}
    }
    else {
	if ( dim == 3 ) {			// 3x3 arrow pattern
	    bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 );
	    bTop .setPoints( 2, 1,0, 1,0 );
	    bBot .setPoints( 2, 1,2, 2,1 );
	}
	else {					// 2x2 arrow pattern
	    bLeft.setPoints( 2, 0,0, 0,1 );
	    bTop .setPoints( 2, 1,0, 1,0 );
	    bBot .setPoints( 2, 1,1, 1,1 );
	}
    }

    if ( type == Qt::UpArrow || type == Qt::LeftArrow ) {
#ifndef QT_NO_TRANSFORMATIONS	// #### fix me!
	matrix.translate( x, y );
	if ( vertical ) {
	    matrix.translate( 0, h - 1 );
	    matrix.rotate( -90 );
	} else {
	    matrix.translate( w - 1, h - 1 );
	    matrix.rotate( 180 );
	}
#endif
	if ( down )
	    colspec = horizontal ? 0x2334 : 0x2343;
	else
	    colspec = horizontal ? 0x1443 : 0x1434;
    }
    else if ( type == Qt::DownArrow || type == Qt::RightArrow ) {
#ifndef QT_NO_TRANSFORMATIONS	// #### fix me!
	matrix.translate( x, y );
	if ( vertical ) {
	    matrix.translate( w-1, 0 );
	    matrix.rotate( 90 );
	}
#endif
	if ( down )
	    colspec = horizontal ? 0x2443 : 0x2434;
	else
	    colspec = horizontal ? 0x1334 : 0x1343;
    }

    QColor *cols[5];
    cols[0] = 0;
    cols[1] = (QColor *)&g.button();
    cols[2] = (QColor *)&g.mid();
    cols[3] = (QColor *)&g.light();
    cols[4] = (QColor *)&g.dark();
#define CMID	*cols[ (colspec>>12) & 0xf ]
#define CLEFT	*cols[ (colspec>>8) & 0xf ]
#define CTOP	*cols[ (colspec>>4) & 0xf ]
#define CBOT	*cols[ colspec & 0xf ]
//.........这里部分代码省略.........
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:101,代码来源:qdrawutil.cpp

示例11: qDrawShadeLine

void qDrawShadeLine( QPainter *p, int x1, int y1, int x2, int y2,
		     const QColorGroup &g, bool sunken,
		     int lineWidth, int midLineWidth )
{
    if (!( p && lineWidth >= 0 && midLineWidth >= 0 ) )	{
#if defined(QT_CHECK_RANGE)
	qWarning( "qDrawShadeLine invalid parameters." );
#endif
	return;
    }
    int tlw = lineWidth*2 + midLineWidth;	// total line width
    QPen oldPen = p->pen();			// save pen
    if ( sunken )
	p->setPen( g.dark() );
    else
	p->setPen( g.light() );
    QPointArray a;
    int i;
    if ( y1 == y2 ) {				// horizontal line
	int y = y1 - tlw/2;
	if ( x1 > x2 ) {			// swap x1 and x2
	    int t = x1;
	    x1 = x2;
	    x2 = t;
	}
	x2--;
	for ( i=0; i<lineWidth; i++ ) {		// draw top shadow
	    a.setPoints( 3, x1+i, y+tlw-1-i,
			 x1+i, y+i,
			 x2-i, y+i );
	    p->drawPolyline( a );
	}
	if ( midLineWidth > 0 ) {
	    p->setPen( g.mid() );
	    for ( i=0; i<midLineWidth; i++ )	// draw lines in the middle
		p->drawLine( x1+lineWidth, y+lineWidth+i,
			     x2-lineWidth, y+lineWidth+i );
	}
	if ( sunken )
	    p->setPen( g.light() );
	else
	    p->setPen( g.dark() );
	for ( i=0; i<lineWidth; i++ ) {		// draw bottom shadow
	    a.setPoints( 3, x1+i, y+tlw-i-1,
			 x2-i, y+tlw-i-1,
			 x2-i, y+i+1 );
	    p->drawPolyline( a );
	}
    }
    else if ( x1 == x2 ) {			// vertical line
	int x = x1 - tlw/2;
	if ( y1 > y2 ) {			// swap y1 and y2
	    int t = y1;
	    y1 = y2;
	    y2 = t;
	}
	y2--;
	for ( i=0; i<lineWidth; i++ ) {		// draw left shadow
	    a.setPoints( 3, x+i, y2,
			 x+i, y1+i,
			 x+tlw-1, y1+i );
	    p->drawPolyline( a );
	}
	if ( midLineWidth > 0 ) {
	    p->setPen( g.mid() );
	    for ( i=0; i<midLineWidth; i++ )	// draw lines in the middle
		p->drawLine( x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2 );
	}
	if ( sunken )
	    p->setPen( g.light() );
	else
	    p->setPen( g.dark() );
	for ( i=0; i<lineWidth; i++ ) {		// draw right shadow
	    a.setPoints( 3, x+lineWidth, y2-i,
			 x+tlw-i-1, y2-i,
			 x+tlw-i-1, y1+lineWidth );
	    p->drawPolyline( a );
	}
    }
    p->setPen( oldPen );
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:81,代码来源:qdrawutil.cpp

示例12: drawComplexControl


//.........这里部分代码省略.........
		p->drawLine( xx+3, yy+hh-3 ,xx+ww-3, yy+hh-3 );
		p->drawLine( xx+ww-3, yy+3, xx+ww-3, yy+hh-3 );

		p->setPen( cg.dark() );
		p->drawLine( xx+2, yy+hh-2 ,xx+ww-2, yy+hh-2 );
		p->drawLine( xx+ww-2, yy+2, xx+ww-2, yy+hh-2 );

		p->setPen( cg.shadow() );
		p->drawLine( xx+1, yy+hh-1,xx+ww-1, yy+hh-1 );
		p->drawLine( xx+ww-1, yy, xx+ww-1, yy+hh-1 );

		// top right corner:
		p->setPen( cg.background() );
		p->drawPoint( xx + ww - 1, yy );
		p->drawPoint( xx + ww - 2, yy );
		p->drawPoint( xx + ww - 1, yy + 1 );
		p->setPen( cg.shadow() );
		p->drawPoint( xx + ww - 2, yy + 1 );
		// bottom right corner:
		p->setPen( cg.background() );
		p->drawPoint( xx + ww - 1, yy + hh - 1 );
		p->drawPoint( xx + ww - 2, yy + hh - 1 );
		p->drawPoint( xx + ww - 1, yy + hh - 2 );
		p->setPen( cg.shadow() );
		p->drawPoint( xx + ww - 2, yy + hh - 2 );
		p->setPen( cg.dark() );
		p->drawPoint( xx + ww - 3, yy + hh - 3 );
		p->setPen( cg.mid() );
		p->drawPoint( xx + ww - 4, yy + hh - 4 );

		// and the arrows
		p->setPen( cg.foreground() );
		QPointArray a ;
		a.setPoints(  7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2  );
		a.translate( xx + ww / 2, yy + hh / 2 - 3 );
		p->drawLineSegments( a, 0, 3 );		// draw arrow
		p->drawPoint( a[6] );
		a.setPoints( 7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2 );
		a.translate( xx + ww / 2, yy + hh / 2 + 2 );
		p->drawLineSegments( a, 0, 3 );		// draw arrow
		p->drawPoint( a[6] );

	    }
#ifndef QT_NO_COMBOBOX
	    if ( sub & SC_ComboBoxEditField ) {
		const QComboBox *cmb;
		cmb = (const QComboBox*)widget;
		// sadly this is pretty much the windows code, except
		// for the first fillRect call...
		QRect re =
		    QStyle::visualRect( querySubControlMetrics( CC_ComboBox,
								widget,
								SC_ComboBoxEditField ),
					widget );
		if ( cmb->hasFocus() && !cmb->editable() )
		    p->fillRect( re.x() + 1, re.y() + 1,
				 re.width() - 2, re.height() - 2,
				 cg.brush( QColorGroup::Highlight ) );

		if ( cmb->hasFocus() ) {
		    p->setPen( cg.highlightedText() );
		    p->setBackgroundColor( cg.highlight() );
		} else {
		    p->setPen( cg.text() );
		    p->setBackgroundColor( cg.background() );
		}
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:67,代码来源:qplatinumstyle.cpp

示例13: qDrawShadeRect

void qDrawShadeRect( QPainter *p, int x, int y, int w, int h,
		     const QColorGroup &g, bool sunken,
		     int lineWidth, int midLineWidth,
		     const QBrush *fill )
{
    if ( w == 0 || h == 0 )
	return;
    if ( ! ( w > 0 && h > 0 && lineWidth >= 0 && midLineWidth >= 0 ) ) {
#if defined(QT_CHECK_RANGE)
	qWarning( "qDrawShadeRect(): Invalid parameters" );
#endif
	return;
    }
    QPen oldPen = p->pen();
    if ( sunken )
	p->setPen( g.dark() );
    else
	p->setPen( g.light() );
    int x1=x, y1=y, x2=x+w-1, y2=y+h-1;
    QPointArray a;

    if ( lineWidth == 1 && midLineWidth == 0 ) {// standard shade rectangle
	p->drawRect( x1, y1, w-1, h-1 );
	if ( sunken )
	    p->setPen( g.light() );
	else
	    p->setPen( g.dark() );
	a.setPoints( 8, x1+1,y1+1, x2-2,y1+1, x1+1,y1+2, x1+1,y2-2,
		     x1,y2, x2,y2,  x2,y1, x2,y2-1 );
	p->drawLineSegments( a );		// draw bottom/right lines
    } else {					// more complicated
	int m = lineWidth+midLineWidth;
	int i, j=0, k=m;
	for ( i=0; i<lineWidth; i++ ) {		// draw top shadow
	    a.setPoints( 8, x1+i, y2-i, x1+i, y1+i, x1+i, y1+i, x2-i, y1+i,
			 x1+k, y2-k, x2-k, y2-k, x2-k, y2-k, x2-k, y1+k );
	    p->drawLineSegments( a );
	    k++;
	}
	p->setPen( g.mid() );
	j = lineWidth*2;
	for ( i=0; i<midLineWidth; i++ ) {	// draw lines in the middle
	    p->drawRect( x1+lineWidth+i, y1+lineWidth+i, w-j, h-j );
	    j += 2;
	}
	if ( sunken )
	    p->setPen( g.light() );
	else
	    p->setPen( g.dark() );
	k = m;
	for ( i=0; i<lineWidth; i++ ) {		// draw bottom shadow
	    a.setPoints( 8, x1+1+i,y2-i, x2-i, y2-i, x2-i, y2-i, x2-i, y1+i+1,
			 x1+k, y2-k, x1+k, y1+k, x1+k, y1+k, x2-k, y1+k );
	    p->drawLineSegments( a );
	    k++;
	}
    }
    if ( fill ) {
	QBrush oldBrush = p->brush();
	int tlw = lineWidth + midLineWidth;
	p->setPen( Qt::NoPen );
	p->setBrush( *fill );
	p->drawRect( x+tlw, y+tlw, w-2*tlw, h-2*tlw );
	p->setBrush( oldBrush );
    }
    p->setPen( oldPen );			// restore pen
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:67,代码来源:qdrawutil.cpp

示例14: drawScale

void ScalePlot::drawScale ()
{
  QPainter painter;
  painter.begin(&buffer);
  painter.setFont(plotFont);
  painter.setPen(QPen(borderColor, 1, QPen::SolidLine));

  painter.fillRect(0, 0, buffer.width(), buffer.height(), backgroundColor);
  
  QMemArray<double> scaleArray;
  scaler.getScaleArray(scaleArray);
  
  QFontMetrics fm(plotFont);

  int x = 0;
  int loop;
  for (loop = 0; loop < (int) scaleArray.size(); loop++)
  {
    int y = scaler.convertToY(scaleArray[loop]);
    painter.drawLine (x, y, x + 4, y);

    // draw the text
    QString s;
    strip(scaleArray[loop], 4, s);
    
    // abbreviate too many (>=3) trailing zeroes in large numbers on y-axes
    if (! mainFlag)
    {
      bool flag = FALSE;
      
      if (s.toDouble() < 0)
      {
        flag = TRUE;
	s.remove(0, 1);  
      }
      
      if (s.toDouble() >= 1000000000)
      {
        strip(s.toDouble() / 1000000000, 4, s);
	s.append("b");
      }
      else
      {
        if (s.toDouble() >= 1000000)
        {
          strip(s.toDouble() / 1000000, 4, s);
	  s.append("m");
        }
//        else
//        {
//          if (s.toDouble() >= 1000)
//          {
//            strip(s.toDouble() / 1000, 4, s);
//            s.append("k");
//          }
//        }
      }
      
      if (flag)
        s.prepend("-");
    }
    
    painter.drawText(x + 7, y + (fm.height() / 2), s);
  }

  painter.drawLine (x, 0, x, buffer.height());
  
  // draw the last value pointer on the scale of main plot
  int y = scaler.convertToY(close);
    
  QPointArray array;
  array.setPoints(3, x + 2, y,
                  x + 8, y - 4,
                  x + 8, y + 4);
  painter.setBrush(borderColor);
  painter.drawPolygon(array, TRUE, 0, -1);

  painter.end();
}
开发者ID:botvs,项目名称:FinancialAnalytics,代码行数:79,代码来源:ScalePlot.cpp

示例15: DrawSoma

void ClsEPuckDisp::DrawSoma(QPainter *_Painter, int iWhiskersWidth){
    int ii;
    int iWhiskFactor = iWhiskersMaxLength / 11;
     
//       printf("+++++++++++++++++++++++\n");
//       for (ii = 0; ii<8 ; ii++){
//  	  printf("Coll: %i, ", vaAmbient[ii]);
//  	  printf("IR: %g\n", vaProximity[ii]); 
//  	  if (ii <= 2) printf("Motor: %g\n", afMotor[ii]);
//       }


    int iXCenter, iYCenter;
    int iWidth, iHeight;


    iWidth  = 250; //this->width();
    iHeight = 250; //this->height();
     
    iXCenter = iWidth / 2 ;
    iYCenter = iHeight / 2 ;



// Khepera body
    _Painter->setPen( QPen( colLines, 1, SolidLine ) );
    _Painter->setBrush( colSoma );
    _Painter->drawEllipse( iXCenter - iSomaDiameter / 2, 
			   iYCenter - iSomaDiameter / 2, 
			   iSomaDiameter, iSomaDiameter );
// -----------------------------

   
// Wheels     
    _Painter->setPen( QPen( colLines, 1, SolidLine ) );
    _Painter->setBrush( colMotor );
    /* left */


    _Painter->drawRect ( iXCenter - iSomaDiameter / 2 - iWheelWidth,  
			 iYCenter - iWheelHeight / 2, 
			 iWheelWidth, iWheelHeight);

    /* right */
    _Painter->drawRect ( iXCenter + iSomaDiameter / 2,
			 iYCenter  - iWheelHeight / 2, 
			 iWheelWidth, iWheelHeight);


    /* wheel speedbars */
    QPointArray qpaSpeedbar;
    _Painter->setBrush( QBrush( yellow, SolidPattern ) );
    /* wheel speedbar left */
    qpaSpeedbar.setPoints( 3, 
			iXCenter - iSomaDiameter / 2 - iWheelWidth,
			iYCenter,
			iXCenter - iSomaDiameter / 2 - iWheelWidth - iWheelSpeedbarHeight,
			iYCenter,
			iXCenter - iSomaDiameter / 2 - iWheelWidth - iWheelSpeedbarHeight/2,
			iYCenter -(int)((double)iWheelSpeedbarWidth*afMotor[0]));
    _Painter->drawPolygon(qpaSpeedbar);


    /* wheel speedbar right */

    qpaSpeedbar.setPoints( 3, 
			iXCenter + iSomaDiameter / 2 + iWheelWidth,
			iYCenter,
			iXCenter + iSomaDiameter / 2 + iWheelWidth + iWheelSpeedbarHeight,
			iYCenter,
			iXCenter + iSomaDiameter / 2 + iWheelWidth + iWheelSpeedbarHeight/2,
			iYCenter -(int)((double)iWheelSpeedbarWidth*afMotor[1]));
    _Painter->drawPolygon(qpaSpeedbar);



	


// ----------------------------

// Proximity and Ambient
    double fAngle;
    int iXPos, iYPos;
    int iCountSensor;
    int iAmbientColor;


    _Painter->setPen( QPen( colLines, 1, SolidLine ) );
    iCountSensor = 0;
    for ( fAngle = 205; fAngle <= 255; fAngle += 25){
	_Painter->setPen( QPen(  colLines, 1, SolidLine ) );
	iAmbientColor = (int)(vaAmbient[iCountSensor]*254.0);
//	cout << "iAmbientColor 0: " << iAmbientColor << endl;
	colCollision.setRgb(iAmbientColor,iAmbientColor,iAmbientColor);
	_Painter->setBrush( colCollision );

	iXPos = (int)(cos( fAngle * PI / 180.0) * ((double)iSomaDiameter / 2.0  +
						   iAmbientSensorDiameter / 2 )) + iXCenter;
	iYPos = (int)(sin( fAngle * PI / 180.0) * ((double)iSomaDiameter / 2.0  +
//.........这里部分代码省略.........
开发者ID:jeez,项目名称:iqr,代码行数:101,代码来源:ClsEPuckDisp.cpp


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