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


C++ QPolygonF::at方法代码示例

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


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

示例1: pointsUpdated

void GradientEditor::pointsUpdated()
{
    qreal w = m_alpha_shade->width();

    QGradientStops stops;

    QPolygonF points;

    points += m_red_shade->points();
    points += m_green_shade->points();
    points += m_blue_shade->points();
    points += m_alpha_shade->points();

    qSort(points.begin(), points.end(), x_less_than);

    for (int i=0; i<points.size(); ++i) {
        qreal x = int(points.at(i).x());
        if (i < points.size() - 1 && x == points.at(i+1).x())
            continue;
        QColor color((0x00ff0000 & m_red_shade->colorAt(int(x))) >> 16,
                     (0x0000ff00 & m_green_shade->colorAt(int(x))) >> 8,
                     (0x000000ff & m_blue_shade->colorAt(int(x))),
                     (0xff000000 & m_alpha_shade->colorAt(int(x))) >> 24);

        if (x / w > 1)
            return;

        stops << QGradientStop(x / w, color);
    }

    m_alpha_shade->setGradientStops(stops);

    emit gradientStopsChanged(stops);
}
开发者ID:BGmot,项目名称:Qt,代码行数:34,代码来源:gradients.cpp

示例2: drawFrame

void QgsAnnotation::drawFrame( QgsRenderContext &context ) const
{
  if ( !mFillSymbol )
    return;

  context.painter()->setRenderHint( QPainter::Antialiasing, context.flags() & QgsRenderContext::Antialiasing );

  QPolygonF poly;
  QList<QPolygonF> rings; //empty list
  for ( int i = 0; i < 4; ++i )
  {
    QLineF currentSegment = segment( i );
    poly << currentSegment.p1();
    if ( i == mBalloonSegment && mHasFixedMapPosition )
    {
      poly << mBalloonSegmentPoint1;
      poly << QPointF( 0, 0 );
      poly << mBalloonSegmentPoint2;
    }
    poly << currentSegment.p2();
  }
  if ( poly.at( 0 ) != poly.at( poly.count() - 1 ) )
    poly << poly.at( 0 );

  mFillSymbol->startRender( context );
  mFillSymbol->renderPolygon( poly, &rings, nullptr, context );
  mFillSymbol->stopRender( context );
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:28,代码来源:qgsannotation.cpp

示例3: nextPoint

 /**
  * Return the point in \a poly which follows the point at index \a index.
  * If \a index is the last index then return the first (or, if
  * \a poly.isClosed() is true, the second) point.
  */
 QPointF nextPoint(int index, const QPolygonF& poly) {
     if (poly.size() < 3 || index >= poly.size())
         return QPoint();
     if (index == poly.size() - 1)
         return poly.at((int)poly.isClosed());
     return poly.at(index + 1);
 }
开发者ID:KDE,项目名称:umbrello,代码行数:12,代码来源:widget_utils.cpp

示例4: findLine

 /**
  * Find the line of \a poly with the smallest or largest value (controlled by \a seek)
  * along the axis controlled by \a axis.
  * In case \a axis is X, do not consider lines whose Y values lie outside the Y values
  * defined by \a boundingRect.
  * In case \a axis is Y, do not consider lines whose X values lie outside the X values
  * defined by \a boundingRect.
  */
 QLineF findLine(const QPolygonF& poly, Axis_Type axis, Comparison_Type seek, const QRectF& boundingRect)
 {
     const int lastIndex = poly.size() - 1 - (int)poly.isClosed();
     QPointF prev = poly.at(lastIndex), curr;
     QPointF p1(seek == Smallest ? QPointF(1.0e6, 1.0e6) : QPointF(-1.0e6, -1.0e6));
     QPointF p2;
     for (int i = 0; i <= lastIndex; i++) {
         curr = poly.at(i);
         // uDebug() << "  poly[" << i << "] = " << curr;
         if (axis == X) {
             if (fmin(prev.y(), curr.y()) > boundingRect.y() + boundingRect.height() ||
                 fmax(prev.y(), curr.y()) < boundingRect.y()) {
                 // line is outside Y-axis range defined by boundingRect
             } else if ((seek == Smallest && curr.x() <= p1.x()) ||
                        (seek == Largest  && curr.x() >= p1.x())) {
                 p1 = curr;
                 p2 = prev;
             }
         } else {
             if (fmin(prev.x(), curr.x()) > boundingRect.x() + boundingRect.width() ||
                 fmax(prev.x(), curr.x()) < boundingRect.x()) {
                 // line is outside X-axis range defined by boundingRect
             } else if ((seek == Smallest && curr.y() <= p1.y()) ||
                        (seek == Largest  && curr.y() >= p1.y())) {
                 p1 = curr;
                 p2 = prev;
             }
         }
         prev = curr;
     }
     return QLineF(p1, p2);
 }
开发者ID:KDE,项目名称:umbrello,代码行数:40,代码来源:widget_utils.cpp

示例5:

QVector<QLineF> Polygon::_getSegments(const QPolygonF& polygon)
{
    QVector<QLineF> segments;
    for (int i=0; i<polygon.size(); i++)
        segments.push_back(QLineF(polygon.at(i), polygon.at( (i+1) % polygon.size() )));
    return segments;
}
开发者ID:flv0,项目名称:mapmap,代码行数:7,代码来源:Shape.cpp

示例6: prevPoint

 /**
  * Return the point in \a poly which precedes the point at index \a index.
  * If \a index is 0 then return the last (or, if \a poly.isClosed() is
  * true, the second to last) point.
  */
 QPointF prevPoint(int index, const QPolygonF& poly) {
     if (poly.size() < 3 || index >= poly.size())
         return QPoint();
     if (index == 0)
         return poly.at(poly.size() - 1 - (int)poly.isClosed());
     return poly.at(index - 1);
 }
开发者ID:KDE,项目名称:umbrello,代码行数:12,代码来源:widget_utils.cpp

示例7: findFirstVertex

int ObstacleBitmap::findFirstVertex(const QPolygonF& polygon)const{
	std::vector<int> tmp;
	qreal minY = DBL_MAX;
	for(int i = 0; i < polygon.size(); i++){
		if(polygon.at(i).y() < minY){
			tmp.clear();
			minY = polygon.at(i).y();
			tmp.push_back(i);
		}
		else if(minY == polygon.at(i).y()){
			tmp.push_back(i);
		}
	}

	if(tmp.size() == 1){
		return tmp.at(0);
	}

	qreal minX = DBL_MAX;
	int ret = -1;

	for(size_t i = 0; i < tmp.size(); i++){
		if(polygon.at(tmp.at(i)).x() < minX){
			minX = polygon.at(tmp.at(i)).x();
			ret = tmp.at(i);
		}
	}

	return ret;
}
开发者ID:gwpandia,项目名称:MotionPlannerQt,代码行数:30,代码来源:ObstacleBitmap.cpp

示例8: fillPolygon

void GLUtils::fillPolygon( const QPolygonF& p )
{
#if 1
    GLUtesselator *tobj;
    GLdouble* polygon = new GLdouble[p.size()*3];
    for(int i=0;i<p.size();i++)
    {
        polygon[i*3 + 0] = p.at(i).x();
        polygon[i*3 + 1] = p.at(i).y();
        polygon[i*3 + 2] = 0.0;
    }

    tobj = gluNewTess();
    gluTessCallback(tobj, GLU_TESS_VERTEX, (void (CALLBACK *) ())&glVertex3dv);
    gluTessCallback(tobj, GLU_TESS_BEGIN, (void (CALLBACK*) ())&glBegin);
    gluTessCallback(tobj, GLU_TESS_END, (void (CALLBACK*) ())&glEnd);

    glShadeModel(GL_SMOOTH);
    gluTessBeginPolygon(tobj, NULL);
    gluTessBeginContour(tobj);
        for(int i=0;i<p.size();i++)
            gluTessVertex(tobj, polygon+i*3, polygon+i*3);
    gluTessEndContour(tobj);
    gluTessEndPolygon(tobj);
    glEndList();
    gluDeleteTess(tobj);
#else
    glBegin(GL_POLYGON);
    for(int i=0;i<p.size();i++)
    {
        glVertex2f(p.at(i).x(), p.at(i).y());
    }
    glEnd();
#endif
}
开发者ID:phg1024,项目名称:CSCE641,代码行数:35,代码来源:glutils.cpp

示例9: addMiddlePoint

QPointF Meshing::addMiddlePoint(int id)
{
    QPointF point(0,0);
    QPolygonF poly = mesh_.at(id);
    if(poly.isEmpty())
        return point;

    if(!poly.isClosed())
        poly << poly.at(0);

    mesh_.removeAt(id);

    for(int i=0;i<poly.size()-1;i++)
        point += poly.at(i);
    point /= (double)(poly.size()-1);

    /*while(!poly.containsPoint(point,Qt::WindingFill)){
        point += QPointF(-50+rand()%100,-50+rand()%100);
    }*/

    for(int i=0;i<poly.size()-1;i++){
        QPolygonF p;
        p << poly.at(i) << poly.at(i+1) << point << poly.at(i);
        mesh_.push_back(p);
    }
    return point;
}
开发者ID:lbaudouin,项目名称:SewingPattern,代码行数:27,代码来源:meshing.cpp

示例10: while

void QgsLineDecorationSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
  // draw arrow at the end of line

  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  int cnt = points.count();
  QPointF p2 = points.at( --cnt );
  QPointF p1 = points.at( --cnt );
  while ( p2 == p1 && cnt )
    p1 = points.at( --cnt );
  if ( p1 == p2 ) {
    // this is a collapsed line... don't bother drawing an arrow
    // with arbitrary orientation
    return;
  }

  double angle = atan2( p2.y() - p1.y(), p2.x() - p1.x() );
  double size = context.outputLineWidth( mWidth * 8 );
  double angle1 = angle + M_PI / 6;
  double angle2 = angle - M_PI / 6;

  QPointF p2_1 = p2 - QPointF( size * cos( angle1 ), size * sin( angle1 ) );
  QPointF p2_2 = p2 - QPointF( size * cos( angle2 ), size * sin( angle2 ) );

  p->setPen( context.selected() ? mSelPen : mPen );
  p->drawLine( p2, p2_1 );
  p->drawLine( p2, p2_2 );
}
开发者ID:RealworldSystems,项目名称:Quantum-GIS,代码行数:33,代码来源:qgslinesymbollayerv2.cpp

示例11: clipByRect

bool clipByRect( QLineF& line, const QPolygonF& rect )
{
  QVector<QLineF> borderLines;
  borderLines << QLineF( rect.at( 0 ), rect.at( 1 ) );
  borderLines << QLineF( rect.at( 1 ), rect.at( 2 ) );
  borderLines << QLineF( rect.at( 2 ), rect.at( 3 ) );
  borderLines << QLineF( rect.at( 3 ), rect.at( 0 ) );

  QVector<QPointF> intersectionList;
  QVector<QLineF>::const_iterator it = borderLines.constBegin();
  for ( ; it != borderLines.constEnd(); ++it )
  {
    QPointF intersectionPoint;
    if ( it->intersect( line, &intersectionPoint ) == QLineF::BoundedIntersection )
    {
      intersectionList.push_back( intersectionPoint );
      if ( intersectionList.size() >= 2 )
      {
        break; //we already have two intersections, skip further tests
      }
    }
  }
  if ( intersectionList.size() < 2 ) return false; // no intersection

  line = QLineF( intersectionList.at( 0 ), intersectionList.at( 1 ) );
  return true;
}
开发者ID:AM7000000,项目名称:QGIS,代码行数:27,代码来源:qgsdecorationgrid.cpp

示例12: addHistoryValue

void VLCStatsView::addHistoryValue( float value )
{
    /* We keep a full history by creating virtual blocks for inserts, growing
       by power of 2 when no more space is available. At this time, we also
       free space by agregating the oldest values 2 by 2.
       Each shown value finally being a mean of blocksize samples.
    */
    bool doinsert = false;
    int next_blocksize = blocksize;
    QPolygonF shape = historyShape->polygon();
    int count = shape.count();
    if ( count == 0 )
    {
        shape << QPointF( 0, 0 ); /* begin and close shape */
        shape << QPointF( count, 0 );
    }

    valuesaccumulator += ( value / blocksize );
    valuesaccumulatorcount++;

    if ( valuesaccumulatorcount == blocksize )
    {
        valuesaccumulator = 0;
        valuesaccumulatorcount = 0;
        doinsert = true;
    }

    if ( doinsert )
    {
        if ( count > ( STATS_LENGTH + 2 ) )
        {
            float y = 0;
            y += ((QPointF &) shape.at( historymergepointer + 1 )).y();
            y += ((QPointF &) shape.at( historymergepointer + 2 )).y();
            y /= 2;

            /* merge */
            shape.remove( historymergepointer + 2 );
            ( (QPointF &) shape.at( historymergepointer + 1 ) ).setY( y );
            for(int i=historymergepointer +1; i<( STATS_LENGTH + 2 ); i++)
                ( (QPointF &) shape.at(i) ).setX( i - 1 ); /*move back values*/
            historymergepointer++;
            if ( historymergepointer > ( STATS_LENGTH - 1 ) )
            {
                historymergepointer = 0;
                next_blocksize = ( blocksize << 1 );
            }
        }

        shape.insert( shape.end() - 1, QPointF( count, value ) );
        ( (QPointF &) shape.last() ).setX( count );
    }
    else
        ( (QPointF &) shape.last() ).setX( count - 1 );

    historyShape->setPolygon( shape );

    blocksize = next_blocksize;
}
开发者ID:12307,项目名称:VLC-for-VS2010,代码行数:59,代码来源:info_widgets.cpp

示例13: fromConformalInverted

void UwMath::fromConformalInverted(QPolygonF &object) {
    QPointF * data = object.data();

    for(int i = 0; i < object.size(); i++) {
        data[i].setX(UwMath::toDegrees(object.at(i).x()));
        data[i].setY(UwMath::fromMercator(object.at(i).y() * (-1)));
    }
}
开发者ID:pcannon67,项目名称:devel,代码行数:8,代码来源:uwmath.cpp

示例14: toConformal

/** Converts a list of points from degrees to a conformal
  * point in Mercator projection
  * @param points in longitude, latitude given in degrees (DD)
  * @return conformal points in radians
  */
void UwMath::toConformal(QPolygonF &object) {
    QPointF * data = object.data();

    for(int i = 0; i < object.size(); i++) {
        data[i].setX(UwMath::toRadians(object.at(i).x()));
        data[i].setY(UwMath::toMercator(object.at(i).y()));
    }
}
开发者ID:pcannon67,项目名称:devel,代码行数:13,代码来源:uwmath.cpp

示例15: triangleToHalf_OnePointVersion

QPolygonF UwMath::triangleToHalf_OnePointVersion(const QPolygonF &original) {
    QPolygonF half;

    half << original.at(0);
    half << original.at(1);
    half << UwMath::getMiddlePoint(original.at(1), original.at(2));
    return half;
}
开发者ID:pcannon67,项目名称:devel,代码行数:8,代码来源:uwmath.cpp


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