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


C++ QVector::constBegin方法代码示例

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


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

示例1: savePlacemarks

void savePlacemarks( QDataStream &out, const GeoDataContainer *container, MarbleClock* clock )
{
    qreal lon;
    qreal lat;
    qreal alt;

    const QVector<GeoDataPlacemark*> placemarks = container->placemarkList();
    QVector<GeoDataPlacemark*>::const_iterator it = placemarks.constBegin();
    QVector<GeoDataPlacemark*>::const_iterator const end = placemarks.constEnd();
    for (; it != end; ++it ) {
        out << (*it)->name();
        (*it)->coordinate().geoCoordinates( lon, lat, alt );

        // Use double to provide a single cache file format across architectures
        out << (double)(lon) << (double)(lat) << (double)(alt);
        out << QString( (*it)->role() );
        out << QString( (*it)->description() );
        out << QString( (*it)->countryCode() );
        out << QString( (*it)->state() );
        out << (double) (*it)->area();
        out << (qint64) (*it)->population();
        out << ( qint16 ) ( (*it)->extendedData().value("gmt").value().toInt() );
        out << ( qint8 ) ( (*it)->extendedData().value("dst").value().toInt() );
    }

    const QVector<GeoDataFolder*> folders = container->folderList();
    QVector<GeoDataFolder*>::const_iterator cont = folders.constBegin();
    QVector<GeoDataFolder*>::const_iterator endcont = folders.constEnd();
    for (; cont != endcont; ++cont ) {
            savePlacemarks( out, *cont, clock );
    }
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:32,代码来源:kml2cache.cpp

示例2: writeLinestyle

void QgsDxfExport::writeLinestyle( const QString& styleName, const QVector<qreal>& pattern, QgsSymbolV2::OutputUnit u )
{
  double length = 0;
  QVector<qreal>::const_iterator dashIt = pattern.constBegin();
  for ( ; dashIt != pattern.constEnd(); ++dashIt )
  {
    length += ( *dashIt * mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits ) );
  }

  writeGroup( 0, "LTYPE" );
  writeGroup( 2, styleName );
  writeGroup( 70, 64 );
  writeGroup( 3, "" );
  writeGroup( 72, 65 );
  writeGroup( 73, pattern.size() );
  writeGroup( 40, length );

  dashIt = pattern.constBegin();
  bool isSpace = false;
  for ( ; dashIt != pattern.constEnd(); ++dashIt )
  {
    //map units or mm?
    double segmentLength = ( isSpace ? -*dashIt : *dashIt );
    segmentLength *= mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits );
    writeGroup( 49, segmentLength );
    isSpace = !isSpace;
  }
}
开发者ID:Aladar64,项目名称:QGIS,代码行数:28,代码来源:qgsdxfexport.cpp

示例3: createCoordinateElem

QDomElement QgsWFSServer::createCoordinateElem( const QVector<QgsPoint> points, QDomDocument& doc ) const
{
  QDomElement coordElem = doc.createElement( "gml:coordinates" );
  coordElem.setAttribute( "cs", "," );
  coordElem.setAttribute( "ts", " " );

  //precision 4 for meters / feet, precision 8 for degrees
  int precision = 8;
  /*
  if ( mSourceCRS.mapUnits() == QGis::Meters
       || mSourceCRS.mapUnits() == QGis::Feet )
  {
    precision = 4;
  }
  */

  QString coordString;
  QVector<QgsPoint>::const_iterator pointIt = points.constBegin();
  for ( ; pointIt != points.constEnd(); ++pointIt )
  {
    if ( pointIt != points.constBegin() )
    {
      coordString += " ";
    }
    coordString += QString::number( pointIt->x(), 'f', precision );
    coordString += ",";
    coordString += QString::number( pointIt->y(), 'f', precision );
  }

  QDomText coordText = doc.createTextNode( coordString );
  coordElem.appendChild( coordText );
  return coordElem;
}
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:33,代码来源:qgswfsserver.cpp

示例4: printHistogram

inline void printHistogram(int width, int height,
                           const QVector<int> &histogram,
                           const QVector<int> &thresholds=QVector<int>())
{
    // Create the graph.
    QString graph((width + 1) * height, ' ');

    // Split each line.
    for (int y = 0; y < height; y++)
        graph[width + y * (width + 1)] = '\n';

    int maxValue = *std::max_element(histogram.constBegin(), histogram.constEnd());

    // Draw values.
    for (int x = 0; x < width; x++) {
        int h = (height - 1)
                * histogram[(histogram.size() - 1) * x / (width - 1)]
                / maxValue;

        for (int y = height - 1; y >= (height - h - 1); y--)
            graph[x + y * (width + 1)] = '*';
    }

    // Draw the trhesholds.
    foreach (int x, thresholds) {
        int w = (width - 1) * x / (histogram.size() - 1);

        for (int y = 0; y < height; y++)
            graph[w + y * (width + 1)] = '|';
    }
开发者ID:hipersayanX,项目名称:MultiOtsuThreshold,代码行数:30,代码来源:main.cpp

示例5: boundingBoxFromPointList

bool QgsVectorLayerEditUtils::boundingBoxFromPointList( const QVector<QgsPointXY> &list, double &xmin, double &ymin, double &xmax, double &ymax ) const
{
  if ( list.empty() )
  {
    return false;
  }

  xmin = std::numeric_limits<double>::max();
  xmax = -std::numeric_limits<double>::max();
  ymin = std::numeric_limits<double>::max();
  ymax = -std::numeric_limits<double>::max();

  for ( QVector<QgsPointXY>::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
  {
    if ( it->x() < xmin )
    {
      xmin = it->x();
    }
    if ( it->x() > xmax )
    {
      xmax = it->x();
    }
    if ( it->y() < ymin )
    {
      ymin = it->y();
    }
    if ( it->y() > ymax )
    {
      ymax = it->y();
    }
  }

  return true;
}
开发者ID:vmora,项目名称:QGIS,代码行数:34,代码来源:qgsvectorlayereditutils.cpp

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

示例7: probe_objectAdded

void BenchSuite::probe_objectAdded()
{
  Probe::createProbe(false);

  static const int NUM_OBJECTS = 10000;
  QVector<QObject*> objects;
  objects.reserve(NUM_OBJECTS + 1);
  // fill it
  for(int i = 0; i < NUM_OBJECTS; ++i) {
    QObject *obj = new QObject;
    objects << obj;
  }

  QVector<QObject*>::const_iterator it = objects.constBegin();
  QVector<QObject*>::const_iterator end = objects.constEnd();
  QBENCHMARK_ONCE {
    while (it != end) {
      Probe::objectAdded(*it);
      ++it;
    }
  }

  qDeleteAll(objects);
  delete Probe::instance();
}
开发者ID:bschuste,项目名称:GammaRay,代码行数:25,代码来源:benchsuite.cpp

示例8: initTheme

void MarbleLegendBrowser::initTheme()
{
    mDebug() << "initTheme";

    // Check for a theme specific legend.html first
    if ( d->m_marbleModel != 0 && d->m_marbleModel->mapTheme() != 0 )
    {
        GeoSceneDocument *currentMapTheme = d->m_marbleModel->mapTheme();

        QVector<GeoSceneProperty*> allProperties = currentMapTheme->settings()->allProperties();

        d->m_checkBoxMap.clear();

        QVector<GeoSceneProperty*>::const_iterator it = allProperties.constBegin();
        QVector<GeoSceneProperty*>::const_iterator const end = allProperties.constEnd();
        for (; it != end; ++it ) {
            if ( (*it)->available() ) {
                d->m_checkBoxMap[ (*it)->name() ] = (*it)->value();
            }
        }

        disconnect ( currentMapTheme, SIGNAL( valueChanged( QString, bool ) ), 0, 0 );
        connect ( currentMapTheme, SIGNAL( valueChanged( QString, bool ) ),
                  this, SLOT( setCheckedProperty( QString, bool ) ) );
    }
开发者ID:MChemodanov,项目名称:marble,代码行数:25,代码来源:MarbleLegendBrowser.cpp

示例9: matchesFilters

bool ZipDirIteratorPrivate::matchesFilters(const QString &fileName, CentralDirFileHeader* header ) const
{
    Q_ASSERT(!fileName.isEmpty());

    // Pass all entries through name filters
    if ( !nameFilters.isEmpty() )
    {
        bool matched = false;
        for (QVector<QRegExp>::const_iterator iter = nameRegExps.constBegin(), end = nameRegExps.constEnd(); iter != end; ++iter)
        {
            QRegExp copy = *iter;
            if (copy.exactMatch(fileName))
            {
                matched = true;
                break;
            }
        }
        if (!matched)
            return false;
    }

    // skip directories
    if ( (options & AbZip::IgnoreFolders) && header->isDirectory())
        return false;

    // skip files
    if ( (options & AbZip::IgnoreFiles) && !header->isDirectory())
        return false;

    return true;
}
开发者ID:abelayer,项目名称:AbZip,代码行数:31,代码来源:ZipDirIterator.cpp

示例10: computeNormals

//------------------------------------------------------------------------------
void CModel::computeNormals(QVector<SVertex> &vertices, const QVector<SFace> &faces)
{
  for(int32 v = 0; v < vertices.size(); v++)
  {
    /*if(!(v % 10000))
      qDebug(QString("%1").arg(v).toStdString().c_str());*/
    vertices[v].normal = QVector3D(0.0, 1.0, 0.0);
    uint32 found = 0;

    for(auto f = faces.constBegin(); f != faces.constEnd(); f++)
    {
      if(f->contains(v))
      {
        QVector3D n = QVector3D::normal(vertices[f->vertex0].position, vertices[f->vertex1].position, vertices[f->vertex2].position);
        if(!found)
          vertices[v].normal = n;
        else
          vertices[v].normal += n;
        found++;
      }
    }

    vertices[v].normal.normalize();
  }
}
开发者ID:djbozkosz,项目名称:FractLand,代码行数:26,代码来源:models.cpp

示例11: populateFromNode

void QuickSceneGraphModel::populateFromNode(QSGNode *node, bool emitSignals)
{
  if (!node) {
    return;
  }

  QVector<QSGNode*> &childList  = m_parentChildMap[node];
  QVector<QSGNode*> newChildList;

  newChildList.reserve(node->childCount());
  for (QSGNode *childNode = node->firstChild(); childNode; childNode = childNode->nextSibling()) {
    newChildList.append(childNode);
  }

  QModelIndex myIndex; // don't call indexForNode(node) here yet, in the common case of few changes we waste a lot of time here
  bool hasMyIndex = false;

  std::sort(newChildList.begin(), newChildList.end());

  QVector<QSGNode*>::iterator i = childList.begin();
  QVector<QSGNode*>::const_iterator j = newChildList.constBegin();

  while (i != childList.end() && j != newChildList.constEnd()) {
    if (*i < *j) { // handle deleted node
      emit nodeDeleted(*i);
      GET_INDEX
      if (emitSignals) {
        const auto idx = std::distance(childList.begin(), i);
        beginRemoveRows(myIndex, idx, idx);
      }
      pruneSubTree(*i);
      i = childList.erase(i);
      if (emitSignals)
        endRemoveRows();
    } else if (*i > *j) { // handle added node
开发者ID:ChristopherHahn,项目名称:GammaRay,代码行数:35,代码来源:quickscenegraphmodel.cpp

示例12: populateFromNode

void QuickSceneGraphModel::populateFromNode(QSGNode *node)
{
  if (!node)
    return;

  QVector<QSGNode*> &childList  = m_parentChildMap[node];
  QVector<QSGNode*> &oldChildList  = m_oldParentChildMap[node];
  QVector<QSGNode*> newChildList;

  for (int i = 0; i < node->childCount(); i++) {
    QSGNode *childNode = node->childAtIndex(i);

    newChildList.append(childNode);
  }

  QModelIndex myIndex = indexForNode(node);

  std::sort(newChildList.begin(), newChildList.end());

  QVector<QSGNode*>::iterator i = oldChildList.begin();
  QVector<QSGNode*>::const_iterator j = newChildList.constBegin();

  while (i != oldChildList.end() && j != newChildList.constEnd()) {
    if (*i < *j) { // We don't have to do anything but inform the client about the change
      beginRemoveRows(myIndex, childList.size(), childList.size());
      endRemoveRows();
      emit nodeDeleted(*i);
      i++;
    } else if (*i > *j) { // Add to new list and inform the client about the change
      beginInsertRows(myIndex, childList.size(), childList.size());
      m_childParentMap.insert(*j, node);
      childList.append(*j);
      endInsertRows();
      populateFromNode(*j);
      j++;
    } else { // Adopt to new list, without informing the client (as nothing really changed)
      m_childParentMap.insert(*j, node);
      childList.append(*j);
      populateFromNode(*j);
      j++;
      i++;
    }
  }
  if (i == oldChildList.end() && j != newChildList.constEnd()) { // Add remaining new items to list and inform the client
    beginInsertRows(myIndex, childList.size(), childList.size() + std::distance(j, newChildList.constEnd()) - 1);
    for (;j != newChildList.constEnd(); j++) {
      m_childParentMap.insert(*j, node);
      childList.append(*j);
      populateFromNode(*j);
    }
    endInsertRows();
  } else if (i != oldChildList.end()) { // Inform the client about the removed rows
    beginRemoveRows(myIndex, childList.size(), childList.size() + std::distance(i, oldChildList.end()) - 1);
    endRemoveRows();
    for (; i != oldChildList.end(); i++)
      emit nodeDeleted(*i);
  }
}
开发者ID:motto0808,项目名称:GammaRay,代码行数:58,代码来源:quickscenegraphmodel.cpp

示例13: construct

void SectorHistogram::construct( const Billon &billon, const Interval<uint> &sliceInterval, const Interval<int> &intensity,
								 const uint &zMotionMin, const int &radiusAroundPith )
{
	clear();

	if ( billon.hasPith() && sliceInterval.isValid() && sliceInterval.width() > 0 )
	{
		const int &width = billon.n_cols;
		const int &height = billon.n_rows;
		const qreal squareRadius = qPow(radiusAroundPith,2);

		fill(0.,PieChartSingleton::getInstance()->nbSectors());

		QVector<int> circleLines;
		circleLines.reserve(2*radiusAroundPith+1);
		for ( int lineIndex=-radiusAroundPith ; lineIndex<=radiusAroundPith ; ++lineIndex )
		{
			circleLines.append(qSqrt(squareRadius-qPow(lineIndex,2)));
		}

		QVector<int>::ConstIterator circlesLinesIterator;
		int iRadius;
		uint diff;
		iCoord2D currentPos;

		// Calcul du diagramme en parcourant les tranches du billon comprises dans l'intervalle
		for ( uint k=sliceInterval.min() ; k<=sliceInterval.max() ; ++k )
		{
			const Slice &currentSlice = billon.slice(k);
			const Slice &previousSlice = billon.previousSlice(k);
			const iCoord2D &currentPithCoord = billon.pithCoord(k);
			currentPos.y = currentPithCoord.y-radiusAroundPith;
			for ( circlesLinesIterator = circleLines.constBegin() ; circlesLinesIterator != circleLines.constEnd() ; ++circlesLinesIterator )
			{
				iRadius = *circlesLinesIterator;
				currentPos.x = currentPithCoord.x-iRadius;
				iRadius += currentPithCoord.x;
				while ( currentPos.x <= iRadius )
				{
					if ( currentPos.x < width && currentPos.y < height && intensity.containsOpen(currentSlice.at(currentPos.y,currentPos.x)) &&
						 intensity.containsOpen(previousSlice.at(currentPos.y,currentPos.x)) )
					{
						diff = billon.zMotion(currentPos.x,currentPos.y,k);
						//if ( motionInterval.containsClosed(diff) )
						if ( diff >= zMotionMin )
						{
							(*this)[PieChartSingleton::getInstance()->sectorIndexOfAngle( currentPithCoord.angle(currentPos) )] += diff-zMotionMin;
						}
					}
					currentPos.x++;
				}
				currentPos.y++;
			}
		}
	}
}
开发者ID:kerautret,项目名称:TKDetection,代码行数:56,代码来源:sectorhistogram.cpp

示例14: itemFor

ThumbnailWidget* ThumbnailListPrivate::itemFor( const QPoint & p ) const
{
    QVector< ThumbnailWidget * >::const_iterator tIt = m_thumbnails.constBegin(), tEnd = m_thumbnails.constEnd();
    for ( ; tIt != tEnd; ++tIt )
    {
        if ( (*tIt)->rect().contains( p ) )
            return (*tIt);
    }
    return 0;
}
开发者ID:azat-archive,项目名称:okular,代码行数:10,代码来源:thumbnaillist.cpp

示例15: segmentLength

double QgsCompoundCurve::segmentLength( QgsVertexId startVertex ) const
{
  QVector< QPair<int, QgsVertexId> > curveIds = curveVertexId( startVertex );
  double length = 0.0;
  for ( auto it = curveIds.constBegin(); it != curveIds.constEnd(); ++it )
  {
    length += mCurves.at( it->first )->segmentLength( it->second );
  }
  return length;
}
开发者ID:alexbruy,项目名称:QGIS,代码行数:10,代码来源:qgscompoundcurve.cpp


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