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


C++ QPolygonF类代码示例

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


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

示例1: draw

/*!
  Draw dots

  \param painter Painter
  \param xMap x map
  \param yMap y map
  \param canvasRect Contents rect of the canvas
  \param from index of the first point to be painted
  \param to index of the last point to be painted

  \sa draw(), drawCurve(), drawSticks(), drawLines(), drawSteps()
*/
void QwtPlotCurve::drawDots( QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &canvasRect, int from, int to ) const
{
    const bool doFill = d_data->brush.style() != Qt::NoBrush;
    const bool doAlign = QwtPainter::roundingAlignment( painter );

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

    QPointF *points = polyline.data();

    for ( int i = from; i <= to; i++ )
    {
        const QPointF sample = d_series->sample( i );
        double xi = xMap.transform( sample.x() );
        double yi = yMap.transform( sample.y() );
        if ( doAlign )
        {
            xi = qRound( xi );
            yi = qRound( yi );
        }

        QwtPainter::drawPoint( painter, QPointF( xi, yi ) );

        if ( doFill )
        {
            points[i - from].rx() = xi;
            points[i - from].ry() = yi;
        }
    }

    if ( doFill )
        fillCurve( painter, xMap, yMap, canvasRect, polyline );
}
开发者ID:Aconex,项目名称:pcp,代码行数:48,代码来源:qwt_plot_curve.cpp

示例2: rotate

void QgsComposerItem::sizeChangedByRotation( double& width, double& height )
{
  if ( mRotation == 0.0 )
  {
    return;
  }

  //vector to p1
  double x1 = -width / 2.0;
  double y1 = -height / 2.0;
  rotate( mRotation, x1, y1 );
  //vector to p2
  double x2 = width / 2.0;
  double y2 = -height / 2.0;
  rotate( mRotation, x2, y2 );
  //vector to p3
  double x3 = width / 2.0;
  double y3 = height / 2.0;
  rotate( mRotation, x3, y3 );
  //vector to p4
  double x4 = -width / 2.0;
  double y4 = height / 2.0;
  rotate( mRotation, x4, y4 );

  //double midpoint
  QPointF midpoint( width / 2.0, height / 2.0 );

  QPolygonF rotatedRectPoly;
  rotatedRectPoly << QPointF( midpoint.x() + x1, midpoint.y() + y1 );
  rotatedRectPoly << QPointF( midpoint.x() + x2, midpoint.y() + y2 );
  rotatedRectPoly << QPointF( midpoint.x() + x3, midpoint.y() + y3 );
  rotatedRectPoly << QPointF( midpoint.x() + x4, midpoint.y() + y4 );
  QRectF boundingRect = rotatedRectPoly.boundingRect();
  width = boundingRect.width();
  height = boundingRect.height();
}
开发者ID:PhilippeDorelon,项目名称:Quantum-GIS,代码行数:36,代码来源:qgscomposeritem.cpp

示例3: paintElements

void paintElements( AbstractDiagram::Private *diagramPrivate, PaintContext* ctx,
                    const LabelPaintCache& lpc, const LineAttributesInfoList& lineList )
{
    AbstractDiagram* diagram = diagramPrivate->diagram;
    // paint all lines and their attributes
    const PainterSaver painterSaver( ctx->painter() );
    ctx->painter()->setRenderHint( QPainter::Antialiasing, diagram->antiAliasing() );

    QBrush curBrush;
    QPen curPen;
    QPolygonF points;
    KDAB_FOREACH ( const LineAttributesInfo& lineInfo, lineList ) {
        const QModelIndex& index = lineInfo.index;
        const ThreeDLineAttributes td = threeDLineAttributes( diagram, index );

        if ( td.isEnabled() ) {
            PaintingHelpers::paintThreeDLines( ctx, diagram, index, lineInfo.value,
                                               lineInfo.nextValue, td, &diagramPrivate->reverseMapper );
        } else {
            const QBrush brush( diagram->brush( index ) );
            const QPen pen( diagram->pen( index ) );

            // line goes from lineInfo.value to lineInfo.nextValue
            diagramPrivate->reverseMapper.addLine( lineInfo.index.row(), lineInfo.index.column(),
                                                   lineInfo.value, lineInfo.nextValue );

            if ( points.count() && points.last() == lineInfo.value && curBrush == brush && curPen == pen ) {
                // continue the current run of lines
            } else {
                // different painter settings or discontinuous line: start a new run of lines
                if ( points.count() ) {
                    PaintingHelpers::paintPolyline( ctx, curBrush, curPen, points );
                }
                curBrush = brush;
                curPen = pen;
                points.clear();
                points << lineInfo.value;
            }
            points << lineInfo.nextValue;
        }
    }
    if ( points.count() ) {
        // the last run of lines is yet to be painted - do it now
        PaintingHelpers::paintPolyline( ctx, curBrush, curPen, points );
    }

    KDAB_FOREACH ( const LineAttributesInfo& lineInfo, lineList ) {
        const ValueTrackerAttributes vt = valueTrackerAttributes( diagram, lineInfo.index );
        if ( vt.isEnabled() ) {
            PaintingHelpers::paintValueTracker( ctx, vt, lineInfo.nextValue );
        }
    }

    // paint all data value texts and the point markers
    diagramPrivate->paintDataValueTextsAndMarkers( ctx, lpc, true );
}
开发者ID:Wushaowei001,项目名称:mksPlanner,代码行数:56,代码来源:PaintingHelpers_p.cpp

示例4: tileToPixelCoords

QRectF IsometricRenderer::boundingRect(const MapObject *object) const
{
    const int nameHeight = object->name().isEmpty() ? 0 : 15;

    if (object->tile()) {
        const QPointF bottomCenter = tileToPixelCoords(object->position());
        const QPixmap &img = object->tile()->image();
        return QRectF(bottomCenter.x() - img.width() / 2,
                      bottomCenter.y() - img.height(),
                      img.width(),
                      img.height()).adjusted(-1, -1 - nameHeight, 1, 1);
    } else if (!object->polygon().isEmpty()) {
        const QPointF &pos = object->position();
        const QPolygonF polygon = object->polygon().translated(pos);
        const QPolygonF screenPolygon = tileToPixelCoords(polygon);
        return screenPolygon.boundingRect().adjusted(-2, -2 - nameHeight, 3, 3);
    } else {
        // Take the bounding rect of the projected object, and then add a few
        // pixels on all sides to correct for the line width.
        const QRectF base = tileRectToPolygon(object->bounds()).boundingRect();

        return base.adjusted(-2, -3 - nameHeight, 2, 2);
    }
}
开发者ID:brun01,项目名称:tiled,代码行数:24,代码来源:isometricrenderer.cpp

示例5: closePolyline

/*!
  \brief Complete a polygon to be a closed polygon including the 
         area between the original polygon and the baseline.

  \param painter Painter
  \param xMap X map
  \param yMap Y map
  \param polygon Polygon to be completed
*/
void QwtPlotCurve::closePolyline( QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    QPolygonF &polygon ) const
{
    if ( polygon.size() < 2 )
        return;

    const bool doAlign = QwtPainter::roundingAlignment( painter );

    double baseline = d_data->baseline;
    
    if ( orientation() == Qt::Vertical )
    {
        if ( yMap.transformation() )
            baseline = yMap.transformation()->bounded( baseline );

        double refY = yMap.transform( baseline );
        if ( doAlign )
            refY = qRound( refY );

        polygon += QPointF( polygon.last().x(), refY );
        polygon += QPointF( polygon.first().x(), refY );
    }
    else
    {
        if ( xMap.transformation() )
            baseline = xMap.transformation()->bounded( baseline );

        double refX = xMap.transform( baseline );
        if ( doAlign )
            refX = qRound( refX );

        polygon += QPointF( refX, polygon.last().y() );
        polygon += QPointF( refX, polygon.first().y() );
    }
}
开发者ID:Au-Zone,项目名称:qwt,代码行数:45,代码来源:qwt_plot_curve.cpp

示例6: drawStaticParEq

void GraphDraw::drawStaticParEq()
{
    QList< QList<Point> > *list;
    QPolygonF polygon;
    Point point;
    ColorSaver *colorSaver;

    pen.setWidth(graphSettings.curvesThickness);
    painter.setRenderHint(QPainter::Antialiasing, graphSettings.smoothing && !moving);
    painter.setPen(pen);

    for(int i = 0; i < parEqs->size(); i++)
    {
        if(!parEqs->at(i)->getDrawState() || parEqs->at(i)->isAnimated())
            continue;

        list = parEqs->at(i)->getPointsList();
        colorSaver = parEqs->at(i)->getColorSaver();

        for(int curve = 0; curve < list->size(); curve++)
        {
            pen.setColor(colorSaver->getColor(curve));
            painter.setPen(pen);

            polygon.clear();

            for(int pos = 0 ; pos < list->at(curve).size(); pos ++)
            {
                point = list->at(curve).at(pos);
                polygon << QPointF(point.x * uniteX, - point.y * uniteY);
            }

            painter.drawPolyline(polygon);
        }
    }
}
开发者ID:AdelKS,项目名称:ZeGrapher,代码行数:36,代码来源:graphdraw.cpp

示例7: setSymbol

/*!
  Draw symbols

  \param painter Painter
  \param symbol Curve symbol
  \param xMap x map
  \param yMap y map
  \param canvasRect Contents rectangle of the canvas
  \param from Index of the first point to be painted
  \param to Index of the last point to be painted

  \sa setSymbol(), drawSeries(), drawCurve()
*/
void QwtPlotCurve::drawSymbols( QPainter *painter, const QwtSymbol &symbol,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &canvasRect, int from, int to ) const
{
    QwtPointMapper mapper;
    mapper.setFlag( QwtPointMapper::RoundPoints, 
        QwtPainter::roundingAlignment( painter ) );
    mapper.setFlag( QwtPointMapper::WeedOutPoints, 
        testPaintAttribute( QwtPlotCurve::FilterPoints ) );
    mapper.setBoundingRect( canvasRect );

    const int chunkSize = 500;

    for ( int i = from; i <= to; i += chunkSize )
    {
        const int n = qMin( chunkSize, to - i + 1 );

        const QPolygonF points = mapper.toPointsF( xMap, yMap,
            data(), i, i + n - 1 );

        if ( points.size() > 0 )
            symbol.drawSymbols( painter, points );
    }
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:37,代码来源:qwt_plot_curve.cpp

示例8: isSelfintersectingPolygon

bool isSelfintersectingPolygon(QPolygonF polygon)
{
  assertPolygonIsClosed(polygon);
  int n = polygon.size() - 1;  // cut off last vertex
  for (int i1 = 0; i1 < n; i1++) {
    int i2 = (i1 + 1) % n;
    for (int j1 = 0; j1 < n; j1++) {
      int j2 = (j1 + 1) % n;
      if (i1 != j1 && i1 != j2 && i2 != j1
          && testSegmentsCross(polygon[i1], polygon[i2], polygon[j1], polygon[j2]))
        return true;
    }
  }
  return false;
}
开发者ID:amatveyakin,项目名称:area-measurement,代码行数:15,代码来源:shape.cpp

示例9: calculateFlightPerformance

qreal FlyThroughTask::calculateFlightPerformance(const QList<Position> &positions,
                                                 const QPolygonF &geoPoly,
                                                 const UAVParameters &)
{
    //First, see if one of the points is within the polygon
    foreach(const Position& pos, positions)
    {
        if (geoPoly.containsPoint(pos.lonLat(), Qt::OddEvenFill))
            return this->maxTaskPerformance();
    }

    //if that fails, take the distance to the last point
    Position goalPos(geoPoly.boundingRect().center(),
                     positions.first().altitude());

    const Position& last = positions.last();
    QVector3D enuPos = Conversions::lla2enu(last, goalPos);
    qreal dist = enuPos.length();

    const qreal stdDev = 90.0;
    qreal toRet = 100*FlightTask::normal(dist,stdDev,2000);

    return qMin<qreal>(toRet,this->maxTaskPerformance());
}
开发者ID:Qt-Widgets,项目名称:FlightPlanner,代码行数:24,代码来源:FlyThroughTask.cpp

示例10: QPointF

void PathPaintEngine::drawPath(const QPainterPath& path)
{
	if (!dev)
		return;

	if(!isCosmetic)
	{
		QList<QPolygonF> polys = path.toSubpathPolygons();
		for (int i = 0; i < polys.size(); ++i)
		{
			if(dashPattern.empty()) dev->addPath(transform.map(polys[i]));
			else
			{
				QPolygonF polytemp = transform.map(polys[i]), newpoly;
				int  dashtoggle = 1, dashi=0, j = 0;
				qreal actualdashsize = dashPattern[dashi];
				QPointF origin = QPointF(polytemp[j]), testp;
				j++; 
				do
				{
					newpoly = QPolygonF();
					newpoly.append(origin);
					do
					{
						testp = polytemp[j];
						origin = QPointF(getPointAtLenght(QPointF(origin), polytemp[j], actualdashsize));
						if (essentiallyEqual(origin.x(), polytemp[j].x(), 0.01 ) && approximatelyEqual(origin.y(), polytemp[j].y(),0.01) && j+1 < polytemp.size()) 
						{
							origin = polytemp[j];
							j++;
							testp =  polytemp[j];
						}
						newpoly.append(origin);
					
					}while(definitelyGreaterThan(actualdashsize,0.0,0.1) && testp!=origin);
					if(dashtoggle == 1)
					{
						dev->addPath(newpoly);
					}
					dashtoggle = dashtoggle * -1;
					dashi++;
					if(dashi >= dashPattern.size()) dashi=0;
					actualdashsize = dashPattern[dashi];
				}while(!essentiallyEqual(origin.x(), polytemp[j].x(), 0.001 ) || !essentiallyEqual(origin.y(), polytemp[j].y(),0.001));
			}
		}
	}
}
开发者ID:Timmmm,项目名称:robocut,代码行数:48,代码来源:PathPaintEngine.cpp

示例11: cubic_subdivide

void cubic_subdivide(QPolygonF& p, size_t j, int recurse = 1)
{
  assert(j > 0);
  assert(j < uint(p.size()) - 1);


  cubic_average(p, j);

  if(--recurse >= 0) {
    point_insert(p, j + 1);
    point_insert(p, j);
    cubic_subdivide(p, j + 1, recurse);
    cubic_subdivide(p, j, recurse);
  }

}
开发者ID:nr-dev,项目名称:Qt-Goodies,代码行数:16,代码来源:qRangeSlider.cpp

示例12: applyDataDefinedSymbology

void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
  QPainter* p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  double offset = 0.0;
  applyDataDefinedSymbology( context, mPen, mSelPen, offset );

  p->setPen( context.selected() ? mSelPen : mPen );

  // Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
  if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
  {
    p->setRenderHint( QPainter::Antialiasing, false );
    p->drawPolyline( points );
    p->setRenderHint( QPainter::Antialiasing, true );
    return;
  }

  if ( mDrawInsidePolygon )
  {
    //only drawing the line on the interior of the polygon, so set clip path for painter
    p->save();
    QPainterPath clipPath;
    clipPath.addPolygon( points );
    p->setClipPath( clipPath, Qt::IntersectClip );
  }

  if ( offset == 0 )
  {
    p->drawPolyline( points );
  }
  else
  {
    double scaledOffset = offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
    p->drawPolyline( ::offsetLine( points, scaledOffset ) );
  }

  if ( mDrawInsidePolygon )
  {
    //restore painter to reset clip path
    p->restore();
  }
}
开发者ID:FabrizioMu,项目名称:QGIS-1,代码行数:47,代码来源:qgslinesymbollayerv2.cpp

示例13: _constrainVertex

void Polygon::_constrainVertex(const QPolygonF& polygon, int i, QPointF& v)
{
    // Weird, but nothing to do.
    if (polygon.size() <= 3)
        return;

    // Save previous position of vertex.
    QPointF prevV = polygon.at(i);

    // Look at the two adjunct segments to vertex i and see if they
    // intersect with any non-adjacent segments.

    // Construct the list of segments (with the new candidate vertex).
    QVector<QLineF> segments = _getSegments(polygon);
    int prev = wrapAround(i - 1, segments.size());
    int next = wrapAround(i + 1, segments.size());
    segments[prev] = QLineF(polygon.at(prev), v);
    segments[i]    = QLineF(v, polygon.at(next));

    // We now stretch segments a little bit to cope with approximation errors.
    for (QVector<QLineF>::Iterator it = segments.begin(); it != segments.end(); ++it)
    {
        QLineF& seg = *it;
        QPointF p1 = seg.p1();
        QPointF p2 = seg.p2();
        seg.setP1( p1 + (p1 - p2) * 0.35f);
        seg.setP2( p2 + (p2 - p1) * 0.35f);
    }

    // For each adjunct segment.
    for (int adj=0; adj<2; adj++)
    {
        int idx = wrapAround(i + adj - 1, segments.size());
        for (int j=0; j<segments.size(); j++)
        {
            // If the segment to compare to is valid (ie. if it is not
            // the segment itself nor an adjacent one) then check for
            // intersection.
            if (j != idx &&
                    j != wrapAround(idx-1, segments.size()) &&
                    j != wrapAround(idx+1, segments.size()))
            {
                QPointF intersection;
                if (segments[idx].intersect(segments[j], &intersection) == QLineF::BoundedIntersection)
                {
                    // Rearrange segments with new position at intersection point.
                    v = intersection;
                    segments[prev] = QLineF(polygon.at(prev), v);
                    segments[i]    = QLineF(v, polygon.at(next));
                }
            }
        }
    }
}
开发者ID:flv0,项目名称:mapmap,代码行数:54,代码来源:Shape.cpp

示例14: cpa

//! Sutherland-Hodgman polygon clipping
QPolygonF GraphPolygonClipperF::clipPolygon(const QPolygonF &pa) const
{
    if ( contains( ::boundingRect(pa) ) )
        return pa;

    QPolygonF cpa(pa.size());

    clipEdge((Edge)0, pa, cpa);

    for ( uint edge = 1; edge < NEdges; edge++ ) 
    {
        const QPolygonF rpa = cpa;
        clipEdge((Edge)edge, rpa, cpa);
    }

    return cpa;
}
开发者ID:ongbe,项目名称:xchart,代码行数:18,代码来源:graph_clipper.cpp

示例15: brush

void ArrowItem::paint(QPainter *painter) {
  painter->drawLine(line());

  QBrush b = brush();
  b.setStyle(Qt::SolidPattern);
  b.setColor(pen().color());
  setBrush(b);

  start.clear();
  end.clear();
  if (_startArrowHead) {
    qreal deltax = view()->scaledFontSize(_startArrowScale, *painter->device())*0.5; // in points
    deltax *= painter->device()->logicalDpiX()/72.0; // convert to 'pixels'.
    qreal theta = atan2(qreal(line().y2() - line().y1()), qreal(line().x2() - line().x1())) - M_PI / 2.0;
    qreal sina = sin(theta);
    qreal cosa = cos(theta);
    qreal yin = sqrt(3.0) * deltax;
    qreal x1, y1, x2, y2;
    QMatrix m(cosa, sina, -sina, cosa, 0.0, 0.0);

    m.map( deltax, yin, &x1, &y1);
    m.map(-deltax, yin, &x2, &y2);

    QPolygonF pts;
    pts.append(line().p1());
    pts.append(line().p1() + QPointF(x1, y1));
    pts.append(line().p1() + QPointF(x2, y2));
    painter->drawPolygon(pts);
    start = pts;
  }

  if (_endArrowHead) {
    qreal deltax = view()->scaledFontSize(_endArrowScale, *painter->device())*0.5;
    deltax *= painter->device()->logicalDpiX()/72.0; // convert points to 'pixels'.
    qreal theta = atan2(qreal(line().y1() - line().y2()), qreal(line().x1() - line().x2())) - M_PI / 2.0;
    qreal sina = sin(theta);
    qreal cosa = cos(theta);
    qreal yin = sqrt(3.0) * deltax;
    qreal x1, y1, x2, y2;
    QMatrix m(cosa, sina, -sina, cosa, 0.0, 0.0);

    m.map( deltax, yin, &x1, &y1);
    m.map(-deltax, yin, &x2, &y2);

    QPolygonF pts;
    pts.append(line().p2());
    pts.append(line().p2() + QPointF(x1, y1));
    pts.append(line().p2() + QPointF(x2, y2));
    painter->drawPolygon(pts);
    end = pts;
  }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:52,代码来源:arrowitem.cpp


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