本文整理汇总了C++中QVector::constEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::constEnd方法的具体用法?C++ QVector::constEnd怎么用?C++ QVector::constEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::constEnd方法的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 );
}
}
示例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;
}
}
示例3: 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);
}
}
示例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)] = '|';
}
示例5: 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;
}
示例6: 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
示例7: 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();
}
}
示例8: 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;
}
示例9: 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();
}
示例10: 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;
}
示例11: 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 ) ) );
}
示例12: 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;
}
示例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 ¤tSlice = billon.slice(k);
const Slice &previousSlice = billon.previousSlice(k);
const iCoord2D ¤tPithCoord = 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++;
}
}
}
}
示例14: QString
void QgsDxfExport::writeLinestyleAC1018( QTextStream& stream, 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;
}
stream << " 0\n";
stream << "LTYPE\n";
stream << " 5\n";
stream << QString( "%1\n" ).arg( mNextHandleId++ );
stream << "100\n";
stream << "AcDbSymbolTableRecord\n";
stream << "100\n";
stream << "AcDbLinetypeTableRecord\n";
stream << " 2\n";
stream << QString( "%1\n" ).arg( styleName );
stream << " 70\n";
stream << "64\n";
stream << " 3\n";
stream << "\n";
stream << " 72\n";
stream << "65\n";
stream << " 73\n";
stream << QString( "%1\n" ).arg( pattern.size() ); //number of segments
stream << " 40\n"; //total length of segments
stream << QString( "%1\n" ).arg( length );
dashIt = pattern.constBegin();
bool isSpace = false;
for ( ; dashIt != pattern.constEnd(); ++dashIt )
{
stream << " 49\n";
//map units or mm?
double segmentLength = ( isSpace ? -*dashIt : *dashIt );
segmentLength *= mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits );
stream << QString( "%1\n" ).arg( segmentLength );
isSpace = !isSpace;
}
}
示例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;
}