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


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

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


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

示例1: prepareForDisplay

void Checker::prepareForDisplay (const QPolygonF &polygon,
                                 int pointRadius,
                                 const DocumentModelAxesChecker &modelAxesChecker,
                                 const DocumentModelCoords &modelCoords)
{
  LOG4CPP_INFO_S ((*mainCat)) << "Checker::prepareForDisplay";

  ENGAUGE_ASSERT (polygon.count () == NUM_AXES_POINTS);

  // Convert pixel coordinates in QPointF to screen and graph coordinates in Point using
  // identity transformation, so this routine can reuse computations provided by Transformation
  QList<Point> points;
  QPolygonF::const_iterator itr;
  for (itr = polygon.begin (); itr != polygon.end (); itr++) {

    const QPointF &pF = *itr;

    Point p (DUMMY_CURVENAME,
             pF,
             pF);
    points.push_back (p);
  }

  // Screen and graph coordinates are treated as the same, so identity transform is used
  Transformation transformIdentity;
  transformIdentity.identity();
  prepareForDisplay (points,
                     pointRadius,
                     modelAxesChecker,
                     modelCoords,
                     transformIdentity);
}
开发者ID:thurberdog,项目名称:engauge6,代码行数:32,代码来源:Checker.cpp

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

示例3: main

int main(int argc, char *argv[])
{
    // This usage QApplication and QLabel is adapted from
    // http://en.wikipedia.org/wiki/Qt_(toolkit)#Qt_hello_world
    QApplication app(argc, argv);

    // Declare a polygon. This is just Qt. The Qt Polygon can be used
    // in GGL as well, just by its oneline registration above.
    QPolygonF polygon;

    // Qt methods can be used, in this case to add points
    polygon
        << QPointF(10, 20) << QPointF(20, 30)
        << QPointF(30, 20) << QPointF(20, 10)
        << QPointF(10, 20);

    // GGL methods can be used, e.g. to calculate area
    std::ostringstream out;
    out << "GGL area: " << boost::geometry::area(polygon) << std::endl;

    // Some functionality is defined in both Qt and GGL
    QPointF p(20,20);
    out << "Qt contains: "
        << (polygon.containsPoint(p, Qt::WindingFill) ? "yes" : "no")
        << std::endl
        << "GGL within: "
        << (boost::geometry::within(p, polygon) ? "yes" : "no")
        << std::endl;
    // Detail: if point is ON boundary, Qt says yes, GGL says no.


    // Qt defines an iterator
    // (which is actually required for GGL, it's part of the ring-concept)
    // such that GGL can use the points of this polygon
    QPolygonF::const_iterator it;
    for (it = polygon.begin(); it != polygon.end(); ++it)
    {
        // Stream Delimiter-Separated, just to show something GGL can do
        out << boost::geometry::dsv(*it) << std::endl;
    }

    // Stream the polygon as well
    out << boost::geometry::dsv(polygon) << std::endl;

    // Just show what we did in a label
    QLabel label(out.str().c_str());
    label.show();
    return app.exec();

    // What else could be useful, functionality that GGL has and Qt not (yet)?
    // - simplify a polygon (to get less points and preserve shape)
    // - clip a polygon with a box
    // - calculate the centroid
    // - calculate the perimeter
    // - calculate the convex hull
    // - transform it using matrix transformations
}
开发者ID:lihe757,项目名称:mylinuxproject,代码行数:57,代码来源:main.cpp

示例4: CHECK_AND_MAKE

Circle::Circle(const QPointF& p1, const QPointF& p2, const QPointF& p3) {
    QPolygonF poly;
    poly << p1 << p2 << p3;
    qSort(poly.begin(), poly.end(), pointLessThan);
    if      CHECK_AND_MAKE(0, 1, 2)
    else if CHECK_AND_MAKE(0, 2, 1)
    else if CHECK_AND_MAKE(1, 0, 2)
    else if CHECK_AND_MAKE(1, 2, 0)
    else if CHECK_AND_MAKE(2, 0, 1)
    else if CHECK_AND_MAKE(2, 1, 0)
    else mRadius = -1;
}
开发者ID:superkartoffel,项目名称:evo-cubist,代码行数:12,代码来源:circle.cpp

示例5: onInsertPoint

void DialogFunction::onInsertPoint()
{
	QAction* pActionInsertPoint = static_cast<QAction*>(sender());
	const QPoint& point = pActionInsertPoint->data().toPoint();
	QwtArraySeriesData<QPointF>* pSeries = static_cast<QwtArraySeriesData<QPointF>*>(_pCurve->data());
	if (pSeries)
	{
		QPolygonF samples = pSeries->samples();
		QPointF newPoint;
		newPoint.setX(widgetPlot->invTransform(_pCurve->xAxis(), point.x()));
		newPoint.setY(widgetPlot->invTransform(_pCurve->yAxis(), point.y()));
		QPolygonF::iterator it = qLowerBound(samples.begin(), samples.end(), newPoint, boost::bind(&QPointF::x, _1) < boost::bind(&QPointF::x, _2));
		samples.insert(it, newPoint);
		_pCurve->setSamples(samples);
		widgetPlot->replot();
	}
}
开发者ID:FromtonRouge,项目名称:eProDrums,代码行数:17,代码来源:DialogFunction.cpp

示例6: polygonClip

void polygonClip(const QPolygonF& inpoly,
		 const QRectF& cliprect,
		 QPolygonF& out)
{
  // construct initial state
  State state(cliprect, out);

  // do the clipping
  for(QPolygonF::const_iterator pt = inpoly.begin(); pt != inpoly.end(); ++pt)
    {
      state.leftClipPoint(*pt);
    }

  // complete
  state.leftClipPoint(state.left1st);
  state.rightClipPoint(state.right1st);
  state.topClipPoint(state.top1st);
  state.bottomClipPoint(state.bottom1st);
}
开发者ID:Felipeasg,项目名称:veusz,代码行数:19,代码来源:polygonclip.cpp

示例7: resizePolygon

void BaseObjectView::resizePolygon(QPolygonF &pol, float width, float height)
{
	QVector<QPointF>::iterator itr,itr_end;
	float coef_a, coef_b;

	itr=pol.begin();
	itr_end=pol.end();

	//Calculates the resize factor
	coef_a=width / pol.boundingRect().width();
	coef_b=height / pol.boundingRect().height();

	//Applies the resize factor to all the polygon points
	while(itr!=itr_end)
	{
		itr->setX(itr->x() * coef_a);
		itr->setY(itr->y() * coef_b);
		itr++;
	}
}
开发者ID:K-Lean,项目名称:pgmodeler,代码行数:20,代码来源:baseobjectview.cpp

示例8: l

void
ViewerGL::Implementation::drawCheckerboardTexture(const QPolygonF& polygon)
{
    ///We divide by 2 the tiles count because one texture is 4 tiles actually
    QPointF topLeft, btmRight;
    double screenW, screenH;
    {
        QMutexLocker l(&zoomCtxMutex);
        topLeft = zoomCtx.toZoomCoordinates(0, 0);
        screenW = zoomCtx.screenWidth();
        screenH = zoomCtx.screenHeight();
        btmRight = zoomCtx.toZoomCoordinates(screenW - 1, screenH - 1);
    }
    double xTilesCountF = screenW / (checkerboardTileSize * 4); //< 4 because the texture contains 4 tiles
    double yTilesCountF = screenH / (checkerboardTileSize * 4);
    GLuint savedTexture;

    GL_GPU::glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&savedTexture);
    {
        GLProtectAttrib<GL_GPU> a(GL_ENABLE_BIT);

        GL_GPU::glEnable(GL_TEXTURE_2D);
        GL_GPU::glBindTexture(GL_TEXTURE_2D, checkerboardTextureID);
        GL_GPU::glBegin(GL_POLYGON);
        for (QPolygonF::const_iterator it = polygon.begin();
             it != polygon.end();
             ++it) {
            GL_GPU::glTexCoord2d( xTilesCountF * ( it->x() - topLeft.x() )  / ( btmRight.x() - topLeft.x() ),
                          yTilesCountF * ( it->y() - btmRight.y() ) / ( topLeft.y() - btmRight.y() ) );
            GL_GPU::glVertex2d( it->x(), it->y() );
        }
        GL_GPU::glEnd();


        //glDisable(GL_SCISSOR_TEST);
    } // GLProtectAttrib a(GL_SCISSOR_BIT | GL_ENABLE_BIT);
    GL_GPU::glBindTexture(GL_TEXTURE_2D, savedTexture);
    glCheckError(GL_GPU);
}
开发者ID:Kthulhu,项目名称:Natron,代码行数:39,代码来源:ViewerGLPrivate.cpp

示例9: transform

QTransform Carton::transform(Faces face, const QPointF &translation, qreal scaling) const
{
    QTransform result;

    const QSizeF originalSize(faceSize(face));
    QPolygonF original(4);
    original[0] = QPointF(0,                    0);                     // TopLeft
    original[1] = QPointF(originalSize.width(), 0);                     // TopRight
    original[2] = QPointF(originalSize.width(), originalSize.height()), // BottomRight
    original[3] = QPointF(0,                    originalSize.height()); // BottomLeft

    QPolygonF targetFace = face2d(face);
    QPolygonF::iterator i;
    for (i = targetFace.begin(); i != targetFace.end(); ++i) {
        (*i).setX((*i).x() * scaling + translation.x());
        (*i).setY((*i).y() * scaling + translation.y());
    }

    const bool possible = QTransform::quadToQuad(original, targetFace, result);
    Q_ASSERT(possible);

    return result;
}
开发者ID:aportale,项目名称:cartonizer,代码行数:23,代码来源:carton.cpp

示例10: clipPolyline

void _PolyClipper::clipPolyline(const QPolygonF& poly)
{
  // exit if fewer than 2 points in polygon
  if ( poly.size() < 2 )
    return;

  // output goes here
  QPolygonF pout;

  QPolygonF::const_iterator polyiter = poly.begin();
  QPointF lastpt = *polyiter;
  polyiter++;

  for( ; polyiter != poly.end(); ++polyiter )
    {
      QPointF p1 = lastpt;
      QPointF p2 = *polyiter;

      bool plotline = _clipper.clipLine(p1, p2);
      if( plotline )
        {
          if( pout.isEmpty() )
            {
              // add first line
              pout << p1;
              if( ! smallDelta(p1, p2) )
                pout << p2;
            }
          else
            {
              if( p1 == pout.last() )
                {
                  if( ! smallDelta(p1, p2) )
                    // extend polyline
                    pout << p2;
                }
              else
                {
                  // paint existing line
                  if( pout.size() >= 2 )
                    emitPolyline(pout);

                  // start new line
                  pout.clear();
                  pout << p1;
                  if( ! smallDelta(p1, p2) )
                    pout << p2;
                }
            }
        }
      else
        {
          // line isn't in region, so ignore results from clip function

          // paint existing line
          if( pout.size() >= 2 )
            emitPolyline(pout);

          // cleanup
          pout.clear();
        }


      lastpt = *polyiter;
    }

  if( pout.size() >= 2 )
    emitPolyline(pout);
}
开发者ID:jeremysanders,项目名称:veusz,代码行数:69,代码来源:polylineclip.cpp


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