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


C++ QPointArray类代码示例

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


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

示例1: drawDots

/*!
  \brief Draw dots
  \param painter Painter
  \param xMap x map
  \param yMap y map
  \param from index of the first point to be painted
  \param to index of the last point to be painted
  \sa QwtCurve::drawPolyline, QwtCurve::drawLine, 
      QwtCurve::drawLines, QwtCurve::drawSpline, QwtCurve::drawSteps
      QwtCurve::drawPolyline, QwtCurve::drawPolygon
*/
void QwtCurve::drawDots(QPainter *painter,
    const QwtDiMap &xMap, const QwtDiMap &yMap, int from, int to)
{
    const bool doFill = painter->brush().style() != Qt::NoBrush;

    QPointArray polyline;
    if ( doFill )
        polyline.resize(to - from + 1);

    for (int i = from; i <= to; i++)
    {
        int xi = xMap.transform(x(i));
        int yi = yMap.transform(y(i));
        QwtPainter::drawPoint(painter, xi, yi);

        if ( doFill )
            polyline.setPoint(i - from, xi, yi);
    }

    if ( doFill )
    {
        closePolyline(xMap, yMap, polyline);
        painter->setPen(QPen(Qt::NoPen));
        QwtPainter::drawPolygon(painter, polyline);
    }
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:37,代码来源:qwt_curve.cpp

示例2: 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

示例3: customEvent

void ClusterView::customEvent(QCustomEvent* event){
 if(event->type() == QEvent::User + 700){
  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
  
  ComputeEvent* computeEvent = (ComputeEvent*) event;
  //Get the polygon
  QPointArray polygon = computeEvent->polygon();
  QRegion selectionArea;
  QPointArray reviewPolygon;
  long Xdimension = 0;
  long Ydimension = 0;

   //The QRegion uses rectangles to define its area and the number of rectangles
   //increases with the height of the region (y axis). The more rectangles the longer
   //the search of one point in the region will take. With a dimension like the time
   //the height has an order of the millon (at least 5 going to 80 or more) given a huge amount
   //of rectangles. A way of speeding the search of points is to reduce the number of rectangles.
   //To do so, if the y dimension is the time, x and y axis are inverted.
   //Caution: in Qt graphical coordinate system, the Y axis is inverted (increasing downwards),
   //thus a point (x,y) is drawn as (x,-y), before creating the region the points are reset to there raw value (x,y).
     
  if(view.ordinateDimension() != timeDimension){
    for(uint i = 0; i< polygon.size();++i){
     reviewPolygon.putPoints(i, 1,polygon.point(i).x(),-polygon.point(i).y());
     Xdimension = dimensionX;
     Ydimension = dimensionY;    
    }
  }
  else{    
    for(uint i = 0; i< polygon.size();++i){
     reviewPolygon.putPoints(i, 1,-polygon.point(i).y(),polygon.point(i).x());

     Xdimension = dimensionY;
     Ydimension = dimensionX;         
   }
  }
  //Create a QRegion with the new selection area in order to use the research facilities offer by a QRegion.  
  selectionArea = QRegion(reviewPolygon);
  if(!selectionArea.isNull()){
    //Call any appropriate method
    switch(mode){
     case DELETE_NOISE:
        doc.deleteNoise(selectionArea,view.clusters(),Xdimension,Ydimension);        
        break;
     case DELETE_ARTEFACT:
       doc.deleteArtifact(selectionArea,view.clusters(),Xdimension,Ydimension);
       break;
     case NEW_CLUSTER:
       doc.createNewCluster(selectionArea,view.clusters(),Xdimension,Ydimension);
       break;
     case NEW_CLUSTERS:
        doc.createNewClusters(selectionArea,view.clusters(),Xdimension,Ydimension);
       break;
     case ZOOM:
       break; //nothing to do   
    }
  }
  QApplication::restoreOverrideCursor(); 
 }
}
开发者ID:caffeine-xx,项目名称:klusters,代码行数:60,代码来源:clusterview.cpp

示例4: QMIN

//
// 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

示例5: drawArrow

void BlastAlignPainter::drawArrow(int xs, int xe, int y, int w, QPainter* p, QColor c){
  int aw = (int)((float)w*1.25);
  int al = (int)((float)w*3);
  
  int tx;

  QPointArray head;
  if(xe > xs){
    head.putPoints(0, 4, 0, 0, -al/3, -aw, al, 0, -al/3, aw);  // forward arrow
  }else{
    head.putPoints(0, 4, 0, 0, al/3, -aw, -al, 0, al/3, aw);
  }
  p->setPen(QPen(c, w));
  if(xe > xs){     // again if forward arrow
    p->drawLine(xs, y, xe-al, y);
    p->translate((double)xe-al, (double)y);
    tx = xe-al;
  }else{
    p->drawLine(xs, y, xe+al, y);
    p->translate((double)xe+al, (double)y);
    tx = xe+al;
  }
  // draw Head.
  p->setPen(QPen(c, 0));
  p->setBrush(c);
  p->drawPolygon(head);
  p->translate(-tx, 0);    // put back to where we came from, and return..
}
开发者ID:lmjakt,项目名称:exint_client,代码行数:28,代码来源:blastalignpainter.cpp

示例6: XPolygonRegion

QRegion::QRegion( const QPointArray &a, bool winding )
{
    data = new QRegionData;
    CHECK_PTR( data );
    data->is_null = FALSE;
    data->rgn = XPolygonRegion( (XPoint*)a.data(), a.size(),
				winding ? WindingRule : EvenOddRule );
}
开发者ID:kthxbyte,项目名称:Qt1.45-Linaro,代码行数:8,代码来源:qregion_x11.cpp

示例7: availableSpaces

QPointArray Reversi::availableSpaces(const int player) const
{
	QPointArray spaces;
	for (int r = 0; r < size().height(); r++)
		for (int c = 0; c < size().width(); c++)
			if (available(QPoint(c, r), player))
				spaces.putPoints(spaces.size(), 1, c, r);
	return spaces;
}
开发者ID:OpenNoah,项目名称:BoardGame,代码行数:9,代码来源:reversi.cpp

示例8: map

QPointArray QWMatrix::map( const QPointArray &a ) const
{
    QPointArray result = a.copy();
    int x, y;
    for ( int i=0; i<(int)result.size(); i++ ) {
	result.point( i, &x, &y );
	map( x, y, &x, &y );
	result.setPoint( i, x, y );
    }
    return result;
}
开发者ID:opieproject,项目名称:qte-opie,代码行数:11,代码来源:qwmatrix.cpp

示例9: drawPoints

void MontageView::drawPoints(const QPointArray& pa, QValueList<int>& corners, int correct)
{
  if(ccv::debug) std::cerr << "MontageView::drawPoints - pa = " << pa.count() << " corners = " << corners.count() << "\n";

  QIconViewItem* item = firstItem();
  if( !item )
    return;

  m_dirty = true;

  QImage img = item->pixmap()->convertToImage();
  
  int item_nr = 0;

  bool failed = corners[item_nr] != correct;

  for( uint i=0; i<pa.count()+1; ++i ){

    if( corners[item_nr] == 0 ) {

      QPixmap pm(img);
      item->setPixmap( pm );
      item = item->nextItem();
      if( !item )
	return;

      img = item->pixmap()->convertToImage();

      item_nr++;
      failed = corners[item_nr] != correct;
    }    

    if(ccv::debug) std::cerr << " Point: " << i << " Image: " << item_nr 
			     << " (" << pa[i].x() << "," << pa[i].y() << ")" 
			     << " Corners: " << corners[item_nr] << "\n"; 

    if( !failed ) {
      img.setPixel( pa[i].x()  , pa[i].y()-1, qRgb(255,255,0) );
      img.setPixel( pa[i].x()-1, pa[i].y()  , qRgb(255,255,0) );
      img.setPixel( pa[i].x()  , pa[i].y()  , qRgb(255,0,0)   );
      img.setPixel( pa[i].x()+1, pa[i].y()  , qRgb(255,255,0) );
      img.setPixel( pa[i].x()  , pa[i].y()+1, qRgb(255,255,0) );
    }
    else {
      img.setPixel( pa[i].x()  , pa[i].y()-1, qRgb(255,0,0)   );
      img.setPixel( pa[i].x()-1, pa[i].y()  , qRgb(255,0,0)   );
      img.setPixel( pa[i].x()  , pa[i].y()  , qRgb(255,255,0) );
      img.setPixel( pa[i].x()+1, pa[i].y()  , qRgb(255,0,0)   );
      img.setPixel( pa[i].x()  , pa[i].y()+1, qRgb(255,0,0)   );
    }
    corners[item_nr]--;
  }
}
开发者ID:Zitrax,项目名称:peru,代码行数:53,代码来源:MontageView.cpp

示例10: createEllipse

void RS_Painter::createEllipse(QPointArray& pa,
                             const RS_Vector& cp,
                             double radius1, double radius2,
                             double angle,
                             double angle1, double angle2,
                             bool reversed)
{


    double aStep;         // Angle Step (rad)
    double a;             // Current Angle (rad)

    aStep=0.01;

    RS_Vector vp;
    RS_Vector vc(cp.x, cp.y);
    vp.set(cp.x+cos(angle1)*radius1,
           cp.y-sin(angle1)*radius2);
    vp.rotate(vc, -angle);

    int i=0;
    pa.resize(i+1);
    pa.setPoint(i++, toScreenX(vp.x),toScreenY(vp.y));

    if(!reversed) {
        // Arc Counterclockwise:
        if(angle1>angle2-RS_TOLERANCE) {
            angle2+=2*M_PI;
        }
        for(a=angle1+aStep; a<=angle2; a+=aStep) {
            vp.set(cp.x+cos(a)*radius1,
                   cp.y-sin(a)*radius2);
            vp.rotate(vc, -angle);

	    pa.resize(i+1);
            pa.setPoint(i++, toScreenX(vp.x),toScreenY(vp.y));
        }
    } else {
        // Arc Clockwise:
        if(angle1<angle2+RS_TOLERANCE) {
            angle2-=2*M_PI;
        }
        for(a=angle1-aStep; a>=angle2; a-=aStep) {
            vp.set(cp.x+cos(a)*radius1,
                   cp.y-sin(a)*radius2);
            vp.rotate(vc, -angle);

	    pa.resize(i+1);
            pa.setPoint(i++, toScreenX(vp.x),toScreenY(vp.y));
        }
    }
    vp.set(cp.x+cos(angle2)*radius1,
           cp.y-sin(angle2)*radius2);
    vp.rotate(vc, -angle);

    pa.resize(i+1);
    pa.setPoint(i++, toScreenX(vp.x),toScreenY(vp.y));

}
开发者ID:Akaur,项目名称:qdraw,代码行数:59,代码来源:rs_painter.cpp

示例11: 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

示例12: getCoordY

void TimelineSubItem::showItem( bool show, int coordY )
{
  KDGanttViewTaskItem::showItem( show, coordY );
  int y;
  if ( coordY != 0 ) {
    y = coordY;
  } else {
    y = getCoordY();
  }
  int startX = myGanttView->timeHeaderWidget()->getCoordX( myStartTime );
  int endX = myGanttView->timeHeaderWidget()->getCoordX( myEndTime );

  const int mw = qMax( 1, qMin( 4, endX - startX ) );
  if ( !mLeft || mw != mMarkerWidth ) {
    if ( !mLeft ) {
      mLeft = new KDCanvasPolygon( myGanttView->timeTableWidget(), this, Type_is_KDGanttViewItem );
      mLeft->setBrush( Qt::black );
    }
    QPointArray a = QPointArray( 4 );
    a.setPoint( 0, 0, -mw -myItemSize / 2 - 2 );
    a.setPoint( 1, mw, -myItemSize / 2 - 2 );
    a.setPoint( 2, mw, myItemSize / 2 + 2 );
    a.setPoint( 3, 0, myItemSize / 2 + mw + 2 );
    mLeft->setPoints( a );
  }
  if ( !mRight || mw != mMarkerWidth ) {
    if ( !mRight ) {
      mRight = new KDCanvasPolygon( myGanttView->timeTableWidget(), this, Type_is_KDGanttViewItem );
      mRight->setBrush( Qt::black );
    }
    QPointArray a = QPointArray( 4 );
    a.setPoint( 0, -mw, -myItemSize / 2 - 2 );
    a.setPoint( 1, 0, -myItemSize / 2 - mw - 2 );
    a.setPoint( 2, 0, myItemSize / 2 + mw + 2 );
    a.setPoint( 3, -mw, myItemSize / 2 + 2 );
    mRight->setPoints( a );
  }
  mMarkerWidth = mw;
  mLeft->setX( startX );
  mLeft->setY( y );
  mLeft->setZ( startShape->z() - 1 );
  mLeft->show();
  mRight->setX( endX );
  mRight->setY( y );
  mRight->setZ( startShape->z() - 1 );
  mRight->show();
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:47,代码来源:timelineitem.cpp

示例13: drawEllipses

// --------------------------------------------------------------------------------
void QmvCanvasGrid::drawEllipses( const QPointArray & pa,
                                  int w, int h, const QPen & pen )
{

    QPainter pt;
    pt.begin(&work_pixmap);
    pt.setPen( pen );
    
        // we want the centre at pa.point
    for ( int i = 0; i < pa.count(); i++ )
        pt.drawEllipse( pa.point(i).x() - w/2,
                        pa.point(i).y() - h/2, w, h );
    pt.end();
    
    updateGridImage( work_pixmap );
        
}
开发者ID:py1668,项目名称:xpracman-qt2-final,代码行数:18,代码来源:qmvcanvasgrid.cpp

示例14: x

void OutputFlowNode::drawShape ( QPainter &p )
{
	const int _x = ( int ) x();
	const int _y = ( int ) y();



	if	( m_dir == 0 )		p.drawLine ( _x, _y, _x-8, _y );
	else if ( m_dir == 90 )		p.drawLine ( _x, _y, _x, _y-8 );
	else if ( m_dir == 180 )	p.drawLine ( _x, _y, _x+8, _y );
	else if ( m_dir == 270 )	p.drawLine ( _x, _y, _x, _y+8 );

	QPointArray pa ( 3 );

	switch ( m_dir )
	{
		case 0: // right
			pa = arrowPoints ( 0 );
			break;
		case 180: // left
			pa = arrowPoints ( 180 );
			break;
		case 90: // down
			pa = arrowPoints ( 90 );
			break;
		case 270: // up
			pa = arrowPoints ( 270 );
			break;
		default:
			kdError() << k_funcinfo << "BUG: m_dir = " << m_dir << endl;
	}


	// Note: I have not tested the positioning of the arrows for all combinations.
	// In fact, most almost definitely do not work. So feel free to change the code
	// as you see fit if necessary.

	if	( m_dir == 0 ) pa.translate ( -5, 0 );
	else if ( m_dir == 90 ) pa.translate ( 0, -5 );
	else if ( m_dir == 180 ) pa.translate ( 5, 0 );
	else if ( m_dir == 270 ) pa.translate ( 0, 5 );

	pa.translate ( _x, _y );
	p.drawPolygon ( pa );
}
开发者ID:Munrek,项目名称:ktechlab,代码行数:45,代码来源:outputflownode.cpp

示例15: drawPointArray

void KIconEditGrid::drawPointArray(QPointArray a, DrawAction action)
{
  QRect rect = a.boundingRect();
  bool update = false;

  int s = a.size(); //((rect.size().width()) * (rect.size().height()));
  for(int i = 0; i < s; i++)
  {
    int x = a[i].x();
    int y = a[i].y();
    //if(img->valid(x, y) && !QSize(x, y).isNull() && rect.contains(QPoint(x, y)))
    if(img->valid(x, y) && rect.contains(QPoint(x, y)))
    {
      //debug("x: %d - y: %d", x, y);
      switch( action )
      {
        case Draw:
        {
          *((uint*)img->scanLine(y) + x) = currentcolor; //colors[cell]|OPAQUE;
          int cell = y * numCols() + x;
          setColor( cell, currentcolor, false );
          modified = true;
          update = true;
          //updateCell( y, x, FALSE );
          break;
        }
        case Mark:
        case UnMark:
          repaint(x*cellsize,y*cellsize, cellsize, cellsize, false);
          //updateCell( y, x, true );
          break;
        default:
          break;
      }
    }
  }
  if(update)
  {
    updateColors();
    repaint(rect.x()*cellSize()-1, rect.y()*cellSize()-1,
        rect.width()*cellSize()+1, rect.height()*cellSize()+1, false);
    pntarray.resize(0);
  }

}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:45,代码来源:kicongrid.cpp


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