本文整理汇总了C++中QgsVectorLayer::id方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsVectorLayer::id方法的具体用法?C++ QgsVectorLayer::id怎么用?C++ QgsVectorLayer::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QgsVectorLayer
的用法示例。
在下文中一共展示了QgsVectorLayer::id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
HeatmapGui::HeatmapGui( QWidget* parent, Qt::WindowFlags fl, QMap<QString, QVariant>* temporarySettings )
: QDialog( parent, fl ),
mRows( 500 )
{
setupUi( this );
QgsDebugMsg( QString( "Creating Heatmap Dialog" ) );
blockAllSignals( true );
mHeatmapSessionSettings = temporarySettings;
// Adding point layers to the inputLayerCombo
QString defaultLayer = mHeatmapSessionSettings->value( QString( "lastInputLayer" ) ).toString();
int defaultLayerIndex = 0;
bool usingLastInputLayer = false;
int currentIndex = -1;
foreach ( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( l );
if ( !vl || vl->geometryType() != QGis::Point )
continue;
currentIndex++;
inputLayerCombo->addItem( vl->name(), vl->id() );
if ( vl->id() == defaultLayer )
{
// if this layer is the same layer as a heatmap was last generated using,
// then default to this layer
usingLastInputLayer = true;
defaultLayerIndex = currentIndex;
}
}
示例2: populateCbTargetLayer
void QgsSpatialQueryDialog::populateCbTargetLayer()
{
cbTargetLayer->blockSignals( true );
QMap <QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers();
QMapIterator <QString, QgsMapLayer*> item( layers );
QgsMapLayer * mapLayer = NULL;
QgsVectorLayer * lyr = NULL;
QString layerId;
while ( item.hasNext() )
{
item.next();
mapLayer = item.value();
if ( mapLayer->type() != QgsMapLayer::VectorLayer )
{
continue;
}
lyr = qobject_cast<QgsVectorLayer *>( mapLayer );
if ( !lyr )
{
continue;
}
addCbLayer( true, lyr );
mMapIdVectorLayers.insert( lyr->id(), lyr );
}
cbTargetLayer->setCurrentIndex( 0 );
cbTargetLayer->blockSignals( false );
} // void QgsSpatialQueryDialog::populateCbTargetLayer()
示例3: QDialog
QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl )
: QDialog()
, mLayer( vl )
{
setupUi( this );
tableWidget->insertRow( 0 );
connect( selectionListWidget, SIGNAL( currentRowChanged( int ) ), this, SLOT( setStackPage( int ) ) );
connect( removeSelectedButton, SIGNAL( clicked() ), this, SLOT( removeSelectedButtonPushed() ) );
connect( loadFromLayerButton, SIGNAL( clicked() ), this, SLOT( loadFromLayerButtonPushed() ) );
connect( loadFromCSVButton, SIGNAL( clicked() ), this, SLOT( loadFromCSVButtonPushed() ) );
connect( tableWidget, SIGNAL( cellChanged( int, int ) ), this, SLOT( vCellChanged( int, int ) ) );
connect( valueRelationEditExpression, SIGNAL( clicked() ), this, SLOT( editValueRelationExpression() ) );
QMapIterator<QString, QgsEditorWidgetFactory*> i( QgsEditorWidgetRegistry::instance()->factories() );
while ( i.hasNext() )
{
i.next();
QListWidgetItem* item = new QListWidgetItem( selectionListWidget );
item->setText( i.value()->name() );
item->setData( Qt::UserRole, i.key() );
selectionListWidget->addItem( item );
}
valueRelationLayer->clear();
foreach ( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
{
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( l );
if ( vl )
valueRelationLayer->addItem( vl->name(), vl->id() );
}
示例4: canvasReleaseEvent
void QgsMapToolOffsetCurve::canvasReleaseEvent( QMouseEvent * e )
{
Q_UNUSED( e );
QgsVectorLayer* vlayer = currentVectorLayer();
if ( !vlayer )
{
deleteRubberBandAndGeometry();
return;
}
if ( !mGeometryModified )
{
deleteRubberBandAndGeometry();
vlayer->destroyEditCommand();
return;
}
if ( mMultiPartGeometry )
{
mModifiedGeometry.convertToMultiType();
}
vlayer->beginEditCommand( tr( "Offset curve" ) );
bool editOk;
if ( mSourceLayerId == vlayer->id() && !mForceCopy )
{
editOk = vlayer->changeGeometry( mModifiedFeature, &mModifiedGeometry );
}
else
{
QgsFeature f;
f.setGeometry( mModifiedGeometry );
//add empty values for all fields (allows inserting attribute values via the feature form in the same session)
QgsAttributes attrs( vlayer->pendingFields().count() );
const QgsFields& fields = vlayer->pendingFields();
for ( int idx = 0; idx < fields.count(); ++idx )
{
attrs[idx] = QVariant();
}
f.setAttributes( attrs );
editOk = vlayer->addFeature( f );
}
if ( editOk )
{
vlayer->endEditCommand();
}
else
{
vlayer->destroyEditCommand();
}
deleteRubberBandAndGeometry();
deleteDistanceItem();
delete mSnapVertexMarker; mSnapVertexMarker = 0;
mForceCopy = false;
mCanvas->refresh();
}
示例5: configure
void QgsMapCanvasTracer::configure()
{
setCrsTransformEnabled( mCanvas->mapSettings().hasCrsTransformEnabled() );
setDestinationCrs( mCanvas->mapSettings().destinationCrs() );
setExtent( mCanvas->extent() );
QList<QgsVectorLayer*> layers;
QStringList visibleLayerIds = mCanvas->mapSettings().layers();
switch ( mCanvas->snappingUtils()->snapToMapMode() )
{
default:
case QgsSnappingUtils::SnapCurrentLayer:
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( mCanvas->currentLayer() );
if ( vl && visibleLayerIds.contains( vl->id() ) )
layers << vl;
}
break;
case QgsSnappingUtils::SnapAllLayers:
Q_FOREACH ( const QString& layerId, visibleLayerIds )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerId ) );
if ( vl )
layers << vl;
}
break;
case QgsSnappingUtils::SnapAdvanced:
Q_FOREACH ( const QgsSnappingUtils::LayerConfig& cfg, mCanvas->snappingUtils()->layers() )
{
if ( visibleLayerIds.contains( cfg.layer->id() ) )
layers << cfg.layer;
}
break;
}
示例6: insertAvailableLayers
void QgsZonalStatisticsDialog::insertAvailableLayers()
{
//insert available raster layers
//enter available layers into the combo box
QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin();
for ( ; layer_it != mapLayers.end(); ++layer_it )
{
QgsRasterLayer* rl = dynamic_cast<QgsRasterLayer*>( layer_it.value() );
if ( rl )
{
QgsRasterDataProvider* rp = rl->dataProvider();
if ( rp && rp->name() == "gdal" )
{
mRasterLayerComboBox->addItem( rl->name(), QVariant( rl->id() ) );
}
}
else
{
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer_it.value() );
if ( vl && vl->geometryType() == QGis::Polygon )
{
QgsVectorDataProvider* provider = vl->dataProvider();
if ( provider->capabilities() & QgsVectorDataProvider::AddAttributes )
{
mPolygonLayerComboBox->addItem( vl->name(), QVariant( vl->id() ) );
}
}
}
}
}
示例7: showHideLabels
void QgsMapToolShowHideLabels::showHideLabels( QMouseEvent *e )
{
QgsMapLayer *layer = mCanvas->currentLayer();
QgsVectorLayer *vlayer = dynamic_cast<QgsVectorLayer *>( layer );
if ( !vlayer )
return;
bool doHide = e->modifiers() & Qt::ShiftModifier;
QString editTxt = doHide ? tr( "Hid labels" ) : tr( "Showed labels" );
vlayer->beginEditCommand( editTxt );
bool labelChanged = false;
if ( doHide )
{
QList<QgsLabelPosition> positions;
if ( selectedLabelFeatures( vlayer, positions ) )
{
for ( const QgsLabelPosition &pos : qgis::as_const( positions ) )
{
if ( showHide( pos, false ) )
labelChanged = true;
}
}
}
else
{
QgsFeatureIds fids;
if ( selectedFeatures( vlayer, fids ) )
{
for ( const QgsFeatureId &fid : qgis::as_const( fids ) )
{
QgsLabelPosition pos;
pos.featureId = fid;
pos.layerID = vlayer->id();
// we want to show labels...
pos.isDiagram = false;
if ( showHide( pos, true ) )
labelChanged = true;
// ... and diagrams
pos.isDiagram = true;
if ( showHide( pos, true ) )
labelChanged = true;
}
}
}
if ( labelChanged )
{
vlayer->endEditCommand();
vlayer->triggerRepaint();
}
else
{
vlayer->destroyEditCommand();
}
}
示例8: fillLayerList
void QgsAttributeTypeLoadDialog::fillLayerList()
{
layerComboBox->clear();
foreach ( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
{
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( l );
if ( vl )
layerComboBox->addItem( vl->name(), vl->id() );
}
示例9: layers
QStringList QgsEmbeddedLayerSelectDialog::layers() const
{
QStringList ids;
QModelIndexList selected = mLayers->selectionModel()->selectedRows();
for ( int i = 0; i < selected.size(); i++ )
{
QgsVectorLayer* l = static_cast<QgsVectorLayer*>( mLayers->item( selected[i].row() )->data( Qt::UserRole ).value<void*>() );
ids << l->id();
}
return ids;
}
示例10:
QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers() const
{
QList< QPair<QgsVectorLayer *, int> > layers;
QHash< QString, int > layerIdx;
Q_FOREACH ( const QModelIndex &idx, mCheckedLeafs )
{
QgsLayerTreeNode *node = index2node( idx );
if ( QgsLayerTree::isGroup( node ) )
{
Q_FOREACH ( QgsLayerTreeLayer *treeLayer, QgsLayerTree::toGroup( node )->findLayers() )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( treeLayer->layer() );
Q_ASSERT( vl );
if ( !layerIdx.contains( vl->id() ) )
{
layerIdx.insert( vl->id(), layers.size() );
layers << qMakePair<QgsVectorLayer *, int>( vl, mAttributeIdx.value( vl, -1 ) );
}
}
}
示例11: fromJoinedLayer
QgsVirtualLayerDefinition QgsVirtualLayerDefinitionUtils::fromJoinedLayer( QgsVectorLayer *layer )
{
QgsVirtualLayerDefinition def;
QStringList leftJoins;
QStringList columns;
// look for the uid
QgsFields fields = layer->dataProvider()->fields();
{
QgsAttributeList pk = layer->dataProvider()->pkAttributeIndexes();
if ( pk.size() == 1 )
{
def.setUid( fields.field( pk[0] ).name() );
}
else
{
// find an uid name
QString uid = QStringLiteral( "uid" );
while ( fields.lookupField( uid ) != -1 )
uid += QLatin1String( "_" ); // add "_" each time this name already exists
// add a column
columns << "t.rowid AS " + uid;
def.setUid( uid );
}
}
Q_FOREACH ( const QgsField &f, layer->dataProvider()->fields() )
{
columns << "t." + f.name();
}
int joinIdx = 0;
Q_FOREACH ( const QgsVectorLayerJoinInfo &join, layer->vectorJoins() )
{
QString joinName = QStringLiteral( "j%1" ).arg( ++joinIdx );
QgsVectorLayer *joinedLayer = join.joinLayer();
if ( !joinedLayer )
continue;
QString prefix = join.prefix().isEmpty() ? joinedLayer->name() + "_" : join.prefix();
leftJoins << QStringLiteral( "LEFT JOIN %1 AS %2 ON t.\"%5\"=%2.\"%3\"" ).arg( joinedLayer->id(), joinName, join.joinFieldName(), join.targetFieldName() );
if ( join.joinFieldNamesSubset() )
{
Q_FOREACH ( const QString &f, *join.joinFieldNamesSubset() )
{
columns << joinName + "." + f + " AS " + prefix + f;
}
}
else
{
示例12: QDialog
HeatmapGui::HeatmapGui( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
setupUi( this );
// Adding point layers to the mInputVectorCombo
foreach( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( l );
if ( !vl || vl->geometryType() != QGis::Point )
continue;
mInputVectorCombo->addItem( vl->name(), vl->id() );
}
示例13: joinedLayerUpdatedFields
void QgsVectorLayerJoinBuffer::joinedLayerUpdatedFields()
{
QgsVectorLayer* joinedLayer = qobject_cast<QgsVectorLayer*>( sender() );
Q_ASSERT( joinedLayer );
// recache the joined layer
for ( QgsVectorJoinList::iterator it = mVectorJoins.begin(); it != mVectorJoins.end(); ++it )
{
if ( joinedLayer->id() == it->joinLayerId )
{
it->cachedAttributes.clear();
cacheJoinLayer( *it );
}
}
emit joinedFieldsChanged();
}
示例14: QDialog
QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl )
: QDialog()
, mLayer( vl )
{
setupUi( this );
tableWidget->insertRow( 0 );
connect( selectionComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setStackPage( int ) ) );
connect( removeSelectedButton, SIGNAL( clicked() ), this, SLOT( removeSelectedButtonPushed() ) );
connect( loadFromLayerButton, SIGNAL( clicked() ), this, SLOT( loadFromLayerButtonPushed() ) );
connect( loadFromCSVButton, SIGNAL( clicked() ), this, SLOT( loadFromCSVButtonPushed() ) );
connect( tableWidget, SIGNAL( cellChanged( int, int ) ), this, SLOT( vCellChanged( int, int ) ) );
valueRelationLayer->clear();
foreach( QgsMapLayer *l, QgsMapLayerRegistry::instance()->mapLayers() )
{
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( l );
if ( vl )
valueRelationLayer->addItem( vl->name(), vl->id() );
}
示例15: signal_qgis_layerWasAdded
//! Slots for signs of QGIS
void QgsSpatialQueryDialog::signal_qgis_layerWasAdded( QgsMapLayer* mapLayer )
{
if ( mapLayer->type() != QgsMapLayer::VectorLayer )
{
return;
}
QgsVectorLayer * lyr = qobject_cast<QgsVectorLayer *>( mapLayer );
if ( !lyr )
{
return;
}
addCbLayer( true, lyr );
if ( cbTargetLayer->count() > 1 && bbMain->button( QDialogButtonBox::Apply )->isHidden() )
{
bbMain->button( QDialogButtonBox::Apply )->show();
cbOperation->setEnabled( true );
cbResultFor->setEnabled( true );
}
addCbLayer( false, lyr );
mMapIdVectorLayers.insert( lyr->id(), lyr );
} // QgsSpatialQueryDialog::signal_qgis_layerWasAdded(QgsMapLayer* mapLayer)