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


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

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


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

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

示例2: ai

QPoint Reversi::ai(const int player)
{
	const int choices[8][8] = {
		{100,	-100,	50,	30,	30,	50,	-100,	100,},
		{-100,	-100,	-50,	-50,	-50,	-50,	-100,	-100,},
		{50,	-50,	10,	10,	10,	10,	-50,	50,},
		{30,	-50,	10,	0,	0,	10,	-50,	30,},
		{30,	-50,	10,	0,	0,	10,	-50,	30,},
		{50,	-50,	10,	10,	10,	10,	-50,	50,},
		{-100,	-100,	-50,	-50,	-50,	-50,	-100,	-100,},
		{100,	-100,	50,	30,	30,	50,	-100,	100,},
	};
	QPointArray spaces = availableSpaces(player);
	if (spaces.size() == 0)
		return BoardGame::ai(player);
	int values[spaces.size()];
	for (unsigned int i = 0; i < spaces.size(); i++) {
		QPoint p(spaces[i]);
		values[i] = choices[p.y()][p.x()] + reversible(p, player) * 5;
	}
	int max = 0;
	for (unsigned int i = 0; i < spaces.size(); i++)
		if (values[i] > values[max])
			max = i;
	QList<int> equals;
	equals.setAutoDelete(true);
	for (unsigned int i = 0; i < spaces.size(); i++)
		if (values[i] == values[max])
			equals.append(new int(i));
	return spaces[*equals.at(rand() % equals.count())];
}
开发者ID:OpenNoah,项目名称:BoardGame,代码行数:31,代码来源:reversi.cpp

示例3: GpiMove

QRegion::QRegion( const QPointArray &a, bool winding )
{
    data = new QRegionData;
    Q_CHECK_PTR( data );
    data->hgt = 0;
    data->is_null = FALSE;
    QRect r = a.boundingRect();
    if ( a.isEmpty() || r.isEmpty() ) {
	data->rgn = 0;
    } else {
        HPS hps = qt_display_ps();
        POINTL *pts = new POINTL[ a.size() ]; 
        for ( uint i = 0; i < a.size(); ++ i ) {
            pts[i].x = a[i].x();
            pts[i].y = - (a[i].y() + 1);
        }
        // GpiCreatePolygonRegion() is bogus and always starts a poligon from
        // the current position. Make the last point the current one and reduce
        // the number of points by one.
        GpiMove( hps, &pts[ a.size() - 1 ] );
        POLYGON poly = { a.size() - 1, pts };
        ULONG opts = winding ? POLYGON_WINDING : POLYGON_ALTERNATE;
        data->rgn = GpiCreatePolygonRegion( hps, 1, &poly, opts );
        delete[] pts;
    }
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:26,代码来源:qregion_pm.cpp

示例4: GpiCreateRegion

QRegion::QRegion( const QRect &r, RegionType t )
{
    data = new QRegionData;
    Q_CHECK_PTR( data );
    data->hgt = 0;
    data->is_null = FALSE;
    if ( r.isEmpty() ) {
	data->rgn = 0;
    } else {
        HPS hps = qt_display_ps();
	if ( t == Rectangle ) {			// rectangular region
            RECTL rcl = { r.left(), -(r.bottom()+1), r.right()+1, -r.top() };
            data->rgn = GpiCreateRegion( hps, 1, &rcl );
	} else if ( t == Ellipse ) {		// elliptic region
            // if the width or height of the ellipse is odd, GPI always
            // converts it to a nearest even value, which is obviously stupid
            // (see also QPainter::drawArcInternal()). So, we don't use
            // GpiCreateEllipticRegion(), but create an array of points to
            // call GpiCreatePolygonRegion() instead.
            QPointArray a;
            a.makeArc( r.x(), r.y(), r.width(), r.height(), 0, 360 * 16 );
            for ( uint i = 0; i < a.size(); ++ i )
                a[i].ry() = -(a[i].y() + 1);
            // GpiCreatePolygonRegion() is bogus and always starts a poligon from
            // the current position. Make the last point the current one and reduce
            // the number of points by one.
            GpiMove( hps, (PPOINTL) &a[ a.size() - 1 ] );
            POLYGON poly = { a.size() - 1, (PPOINTL) a.data() };
            data->rgn = GpiCreatePolygonRegion( hps, 1, &poly, POLYGON_ALTERNATE );
	}
    }
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:32,代码来源:qregion_pm.cpp

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

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

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

示例8: closePolyline

void QwtCurve::closePolyline(const QwtDiMap &xMap, const QwtDiMap &yMap,
    QPointArray &pa) const
{
    const int sz = pa.size();
    if ( sz < 2 )
        return;

    pa.resize(sz + 2);

    if ( d_options & QwtCurve::Xfy )
    {
        pa.setPoint(sz,
            xMap.transform(d_ref), pa.point(sz - 1).y());
        pa.setPoint(sz + 1,
            xMap.transform(d_ref), pa.point(0).y());
    }
    else
    {
        pa.setPoint(sz,
            pa.point(sz - 1).x(), yMap.transform(d_ref));
        pa.setPoint(pa.size() - 1,
            pa.point(0).x(), yMap.transform(d_ref));
    }
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:24,代码来源:qwt_curve.cpp

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

示例10: dragPolygon

	void KviCanvasView::dragPolygon(KviCanvasPolygon * it,const QPoint &p)
	{
		switch(m_dragMode)
		{
			case All:
				it->move(p.x() - m_dragBegin.x(),p.y() - m_dragBegin.y());
			break;
			case SinglePoint:
			{
				QPointArray pnt = it->internalPoints();
				pnt.setPoint(m_dragPointIndex,(int)((p.x() - it->x()) / it->scaleFactor()),(int)((p.y() - it->y()) / it->scaleFactor()));
				it->setInternalPoints(pnt);
			}
			break;
			case Scale:
			{
				double dDistance = ssm_hypot(p.x() - it->x(),p.y() - it->y());
				double dOriginal = ssm_hypot(m_dragBegin.x(),m_dragBegin.y());
				if(dOriginal < 1)dOriginal = 1;
				if(dDistance < 0.1)dDistance = 0.1;
				it->setScaleFactor(m_dragScaleFactor * dDistance / dOriginal);
			}
			break;
			case Rotate:
			{
				QPoint act((int)(p.x() - it->x()),(int)(p.y() - it->y()));
				double dAngle = ssm_2d_rotationAngle(m_dragBegin.x(),m_dragBegin.y(),act.x(),act.y());
	//			qDebug("%d,%d %d,%d %f",m_dragBegin.x(),m_dragBegin.y(),act.x(),act.y(),dAngle);
				QPointArray thePoints = m_dragPointArray.copy();
				for(unsigned int i=0;i<thePoints.size();i++)
				{
					QPoint tmp = thePoints.point(i);
					double dx = tmp.x();
					double dy = tmp.y();
					ssm_2d_rotate(dx,dy,dAngle);
					thePoints.setPoint(i,(int)dx,(int)dy);
				}
				it->setInternalPoints(thePoints);
			}
			break;
			default:
			break;
		}
		canvas()->update();
	}
开发者ID:netrunner-debian-kde-extras,项目名称:kvirc,代码行数:45,代码来源:canvaswidget.cpp

示例11: beginDragPolygon

	void KviCanvasView::beginDragPolygon(KviCanvasPolygon * it,const QPoint &p,bool bShift,bool bCtrl)
	{
		m_dragBegin = QPoint((int)(p.x() - it->x()),(int)(p.y() - it->y()));

		QPointArray pa = it->areaPoints();

		for(unsigned int i=0;i<pa.size();i++)
		{
			QPoint pnt = pa.point(i);
			double dX = pnt.x() - p.x();
			double dY = pnt.y() - p.y();
			double dHypot = sqrt((dX * dX) + (dY * dY));
			if(dHypot < 3.0)
			{
				// We're dragging a point
				m_dragMode = SinglePoint;
				m_dragPointIndex = i;
				setCursor(crossCursor);
				return;
			}
		}

		if(bShift)
		{
			m_dragMode = Scale;
			m_dragScaleFactor = it->scaleFactor();
			setCursor(sizeAllCursor);
			return;
		}

		if(bCtrl)
		{
			m_dragMode = Rotate;
			m_dragPointArray = it->internalPoints();
	//		qDebug("Here");
			setCursor(sizeHorCursor);
			return;
		}

		m_dragMode = All;
		setCursor(pointingHandCursor);
	}
开发者ID:netrunner-debian-kde-extras,项目名称:kvirc,代码行数:42,代码来源:canvaswidget.cpp

示例12: XCreateRegion

QRegion::QRegion( const QRect &r, RegionType t )
{
    QRect rr = r.normalize();
    data = new QRegionData;
    CHECK_PTR( data );
    data->is_null = FALSE;
    if ( t == Rectangle ) {			// rectangular region
	data->rgn = XCreateRegion();
	XRectangle xr;
	xr.x = rr.x();
	xr.y = rr.y();
	xr.width  = rr.width();
	xr.height = rr.height();
	XUnionRectWithRegion( &xr, data->rgn, data->rgn );
    } else if ( t == Ellipse ) {		// elliptic region
	QPointArray a;
	a.makeEllipse( rr.x(), rr.y(), rr.width(), rr.height() );
	data->rgn = XPolygonRegion( (XPoint*)a.data(), a.size(), EvenOddRule );
    }
}
开发者ID:kthxbyte,项目名称:Qt1.45-Linaro,代码行数:20,代码来源:qregion_x11.cpp

示例13: specificPaintData


//.........这里部分代码省略.........
                                                         (datasetStart+dataset)*params()->threeDLineDepth() ) );
                    points[1]->setPoint( point, project( mp.p.x(), mp.p.y(),
                                                         (datasetStart+dataset + 1)*params()->threeDLineDepth() ) );
                    oripoints[0]->setPoint( point,  mp.p.x(), mp.p.y() );
                    oripoints[1]->setPoint( point,  mp.p.x() -  (datasetStart+dataset + 1)*params()->threeDLineDepth(), 
                                            mp.p.y() -  (datasetStart+dataset + 1)*params()->threeDLineDepth() );
		 
                } else
                    // 2D lines or areas
                    points[0]->setPoint( point, mp.p );
                ++point;

                int x = mp.p.x();
                int y = QMAX(QMIN(mp.p.y(),
                                  static_cast < int > (logHeight +axisYOffset)),
                             0);
                bool markerIsOutside = y != mp.p.y();
                // draw the marker and store the region
                if ( currentDrawMarkers ){
                    uint   theAlignment = Qt::AlignCenter;
                    bool   hasOwnSize = false;
                    int    theWidth  = 0;
                    int    theHeight = 0;
                    QColor theColor(params()->dataColor( dataset ));
                    int    theStyle = markerStyle;
                    if( curPropSetId != KDChartPropertySet::UndefinedID ){
                        // we can safely call the following functions and ignore their
                        // return values since they will touch the parameters' values
                        // if the propSet *contains* corresponding own values only.
                        int iDummy;
                        curPropSet.hasOwnMarkerAlign( iDummy, theAlignment );
                        curPropSet.hasOwnMarkerColor( iDummy, theColor );
                        curPropSet.hasOwnMarkerStyle( iDummy, theStyle );
                        QSize size(theWidth, theHeight);
                        hasOwnSize = curPropSet.hasOwnMarkerSize(iDummy, size);
                        if( hasOwnSize ){
                            theWidth  = size.width();
                            theHeight = size.height();
                        }
                    }

                    drawMarker( painter,
                                params(),
                                _areaWidthP1000, _areaHeightP1000,
                                _dataRect.x(),
                                _dataRect.y(),
                                markerIsOutside
                                ? KDChartParams::LineMarker1Pixel
                                : theStyle,
                                theColor,
                                QPoint(x,y),
                                dataset, value, chart, regions,
                                hasOwnSize ? &theWidth  : 0,
                                hasOwnSize ? &theHeight : 0,
                                theAlignment );

                }
                // store the region
                else if( regions ) {
                    QRect rect(
                        QPoint( x-params()->lineWidth()-1, y-params()->lineWidth()-1 ),
                        QPoint( x+params()->lineWidth()+1, y+params()->lineWidth()+1 )
                        );
                    rect.moveBy( _dataRect.x(), _dataRect.y() );
                    regions->append(
                                    new KDChartDataRegion(dataset, value, chart, rect) );
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:67,代码来源:KDChartLinesPainter.cpp

示例14: addPoint

static void addPoint( QPointArray &a, const QPoint &p )
{
    uint n = a.size();
    a.resize( n + 1 );
    a.setPoint( n, p );
}
开发者ID:opieproject,项目名称:qte-opie,代码行数:6,代码来源:qlcdnumber.cpp

示例15: paintChart

void toBarChart::paintChart ( QPainter *p, QRect &rect )
{
    QFontMetrics fm = p->fontMetrics();

    if ( !Zooming ) {
        if ( MinAuto ) {
            bool first = true;
            std::list<std::list<double> >::reverse_iterator i = Values.rbegin();
            if ( i != Values.rend() ) {
                for ( std::list<double>::iterator j = ( *i ).begin();j != ( *i ).end();j++ ) {
                    if ( first ) {
                        first = false;
                        zMinValue = *j;
                    } else if ( zMinValue > *j )
                        zMinValue = *j;
                }
            }
        }
        if ( MaxAuto ) {
            bool first = true;
            std::list<double> total;
            {
                for ( std::list<std::list<double> >::iterator i = Values.begin();i != Values.end();i++ ) {
                    std::list<double>::iterator k = total.begin();
                    for ( std::list<double>::iterator j = ( *i ).begin();j != ( *i ).end();j++ ) {
                        if ( k == total.end() ) {
                            total.insert ( total.end(), *j );
                            k = total.end();
                        } else {
                            *k += *j;
                            k++;
                        }
                    }
                }
            }
            for ( std::list<double>::iterator i = total.begin();i != total.end();i++ ) {
                if ( first ) {
                    first = false;
                    zMaxValue = *i;
                } else if ( zMaxValue < *i )
                    zMaxValue = *i;
            }
        }
        if ( !MinAuto )
            zMinValue = MinValue;
        else
            zMinValue = round ( zMinValue, false );
        if ( !MaxAuto )
            zMaxValue = MaxValue;
        else
            zMaxValue = round ( zMaxValue, true );
    }

    paintTitle ( p, rect );
    paintLegend ( p, rect );
    paintAxis ( p, rect );

    std::list<QPointArray> Points;
    int cp = 0;
    int samples = countSamples();
    int zeroy = int ( rect.height() - 2 - ( -zMinValue / ( zMaxValue - zMinValue ) * ( rect.height() - 4 ) ) );
    if ( samples > 1 ) {
        const QWMatrix & mtx = p->worldMatrix();
        p->setClipRect ( int ( mtx.dx() + 2 ), int ( mtx.dy() + 2 ), rect.width() - 3, rect.height() - 3 );
        if ( Zooming )
            p->drawText ( 2, 2, rect.width() - 4, rect.height() - 4,
                          AlignLeft | AlignTop, "Zoom" );
        for ( std::list<std::list<double> >::reverse_iterator i = Values.rbegin();i != Values.rend();i++ ) {
            std::list<double> &val = *i;
            int count = 0;
            int skip = SkipSamples;
            QPointArray a ( samples + 10 );
            int x = rect.width() - 2;
            for ( std::list<double>::reverse_iterator j = val.rbegin();j != val.rend() && x >= 2;j++ ) {
                if ( skip > 0 )
                    skip--;
                else {
                    int val = int ( rect.height() - 2 - ( ( *j - zMinValue ) / ( zMaxValue - zMinValue ) * ( rect.height() - 4 ) ) );
                    x = rect.width() - 2 - count * ( rect.width() - 4 ) / ( samples - 1 );
                    a.setPoint ( count, x, val );
                    count++;
                    if ( count >= samples )
                        break;
                }
            }
            a.resize ( count * 2 );
            Points.insert ( Points.end(), a );
            cp++;
        }
    }

    std::map<int, int> Bottom;
    for ( std::list<QPointArray>::iterator i = Points.begin();i != Points.end();i++ ) {
        QPointArray a = *i;
        int lx = 0;
        int lb = 0;
        for ( unsigned int j = 0;j < a.size() / 2;j++ ) {
            int x, y;
            a.point ( j, &x, &y );
            if ( Bottom.find ( x ) == Bottom.end() )
//.........这里部分代码省略.........
开发者ID:JustDevZero,项目名称:bulmages,代码行数:101,代码来源:tobarchart.cpp


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