本文整理汇总了C++中QgsVectorLayer::name方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsVectorLayer::name方法的具体用法?C++ QgsVectorLayer::name怎么用?C++ QgsVectorLayer::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QgsVectorLayer
的用法示例。
在下文中一共展示了QgsVectorLayer::name方法的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: QDialog
QgsInterpolationDialog::QgsInterpolationDialog( QWidget* parent, QgisInterface* iface ): QDialog( parent ), mIface( iface ), mInterpolatorDialog( nullptr )
{
setupUi( this );
QSettings settings;
restoreGeometry( settings.value( "/Interpolation/geometry" ).toByteArray() );
//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 )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( layer_it.value() );
if ( vl )
{
mInputLayerComboBox->insertItem( 0, vl->name() );
}
}
//default resolution 300 * 300
mNumberOfColumnsSpinBox->setValue( 300 );
mNumberOfRowsSpinBox->setValue( 300 );
//only inverse distance weighting available for now
mInterpolationMethodComboBox->insertItem( 0, tr( "Triangular interpolation (TIN)" ) );
mInterpolationMethodComboBox->insertItem( 1, tr( "Inverse Distance Weighting (IDW)" ) );
mInterpolationMethodComboBox->setCurrentIndex( settings.value( "/Interpolation/lastMethod", 0 ).toInt() );
enableOrDisableOkButton();
}
示例3: updateFields
void QgsVectorLayerJoinBuffer::updateFields( QgsFields& fields )
{
QList< QgsVectorJoinInfo>::const_iterator joinIt = mVectorJoins.constBegin();
for ( int joinIdx = 0 ; joinIt != mVectorJoins.constEnd(); ++joinIt, ++joinIdx )
{
QgsVectorLayer* joinLayer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( joinIt->joinLayerId ) );
if ( !joinLayer )
{
continue;
}
joinIt->tmpTargetField = fields.indexFromName( joinIt->targetFieldName );
const QgsFields& joinFields = joinLayer->pendingFields();
joinIt->tmpJoinField = joinFields.indexFromName( joinIt->joinFieldName );
for ( int idx = 0; idx < joinFields.count(); ++idx )
{
//skip the join field to avoid double field names (fields often have the same name)
if ( joinFields[idx].name() != joinIt->joinFieldName )
{
QgsField f = joinFields[idx];
f.setName( joinLayer->name() + "_" + f.name() );
fields.append( f, QgsFields::OriginJoin, idx + ( joinIdx*1000 ) );
}
}
}
}
示例4: 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() ) );
}
}
}
}
}
示例5: 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() );
}
示例6: updateLayerList
void QgsOfflineEditingPluginGui::updateLayerList( bool filterEditableLayers )
{
ui_layerList->clear();
QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
for ( QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin() ; layer_it != mapLayers.end(); ++layer_it )
{
if ( layer_it.value()->type() == QgsMapLayer::VectorLayer )
{
QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( layer_it.value() );
bool showLayer = true;
if ( filterEditableLayers )
{
int cap = layer->dataProvider()->capabilities();
showLayer = ( cap & QgsVectorDataProvider::AddFeatures ) &&
( cap & QgsVectorDataProvider::DeleteFeatures ) &&
( cap & QgsVectorDataProvider::ChangeAttributeValues ) &&
( cap & QgsVectorDataProvider::AddAttributes ) &&
( cap & QgsVectorDataProvider::ChangeGeometries );
}
if ( showLayer )
{
QListWidgetItem* item = new QListWidgetItem( layer->name(), ui_layerList );
item->setData( Qt::UserRole, QVariant( layer_it.key() ) );
}
}
}
}
示例7: updateFields
void QgsVectorLayerJoinBuffer::updateFields( QgsFields& fields )
{
QList< QgsVectorJoinInfo>::const_iterator joinIt = mVectorJoins.constBegin();
for ( int joinIdx = 0 ; joinIt != mVectorJoins.constEnd(); ++joinIt, ++joinIdx )
{
QgsVectorLayer* joinLayer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( joinIt->joinLayerId ) );
if ( !joinLayer )
{
continue;
}
const QgsFields& joinFields = joinLayer->pendingFields();
QString joinFieldName;
if ( joinIt->joinFieldName.isEmpty() && joinIt->joinFieldIndex >= 0 && joinIt->joinFieldIndex < joinFields.count() )
joinFieldName = joinFields.field( joinIt->joinFieldIndex ).name(); //for compatibility with 1.x
else
joinFieldName = joinIt->joinFieldName;
for ( int idx = 0; idx < joinFields.count(); ++idx )
{
//skip the join field to avoid double field names (fields often have the same name)
if ( joinFields[idx].name() != joinFieldName )
{
QgsField f = joinFields[idx];
f.setName( joinLayer->name() + "_" + f.name() );
fields.append( f, QgsFields::OriginJoin, idx + ( joinIdx*1000 ) );
}
}
}
}
示例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: if
void QgsLegendModel::updateSymbolV2ItemText( QStandardItem* symbolItem )
{
QgsComposerSymbolV2Item* sv2Item = dynamic_cast<QgsComposerSymbolV2Item*>( symbolItem );
if ( !sv2Item ) return;
QgsComposerLayerItem* lItem = dynamic_cast<QgsComposerLayerItem*>( sv2Item->parent() );
if ( !lItem ) return;
QgsMapLayer* mapLayer = QgsMapLayerRegistry::instance()->mapLayer( lItem->layerID() );
if ( !mapLayer ) return;
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
if ( !vLayer ) return;
QgsFeatureRendererV2* renderer = vLayer->rendererV2();
if ( !renderer ) return;
if ( lItem->showFeatureCount() ) vLayer->countSymbolFeatures();
QgsLegendSymbolList symbolList = renderer->legendSymbolItems();
QPair<QString, QgsSymbolV2*> symbol = symbolList.value( symbolItem->row() );
QString label = sv2Item->userText().isEmpty() ? symbol.first : sv2Item->userText();
if ( renderer->type() == "singleSymbol" )
{
if ( !sv2Item->userText().isEmpty() )
{
label = sv2Item->userText();
}
else if ( !lItem->userText().isEmpty() )
{
label = lItem->userText();
}
else if ( !vLayer->title().isEmpty() )
{
label = vLayer->title();
}
else
{
label = vLayer->name();
}
}
if ( lItem->showFeatureCount() )
{
// Add counts to multi symbols layers only or labeled single symbols,
// so that single symbol layers are still drawn on single line
if ( symbolList.size() > 1 || !label.isEmpty() )
{
label += QString( " [%1]" ).arg( vLayer->featureCount( symbol.second ) );
}
}
symbolItem->setText( label );
}
示例10: fromJoinedLayer
QgsVirtualLayerDefinition QgsVirtualLayerDefinitionUtils::fromJoinedLayer( QgsVectorLayer *layer )
{
QgsVirtualLayerDefinition def;
QStringList leftJoins;
QStringList columns;
// add the geometry column if the layer is spatial
if ( layer->isSpatial() )
columns << "t.geometry";
// 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 );
}
}
const QgsFields providerFields = layer->dataProvider()->fields();
for ( const auto &f : providerFields )
{
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
{
示例11: updatePointLayers
void QgsGlobePluginDialog::updatePointLayers()
{
modelLayerCombo->clear();
QList<QgsVectorLayer*> layers = pointLayers();
QListIterator<QgsVectorLayer*> it( layers );
while ( it.hasNext() )
{
QgsVectorLayer* layer = it.next();
modelLayerCombo->addItem( layer->name() );
}
}
示例12: onEditingStarted
void QgsGrassPlugin::onEditingStarted()
{
QgsDebugMsg( "Entered" );
QgsVectorLayer *vectorLayer = qobject_cast<QgsVectorLayer *>( sender() );
if ( !vectorLayer )
return;
QgsDebugMsg( "started editing of layer " + vectorLayer->name() );
// Set editing renderer
QgsGrassProvider* grassProvider = dynamic_cast<QgsGrassProvider*>( vectorLayer->dataProvider() );
if ( !grassProvider )
return;
QgsRendererV2Registry::instance()->addRenderer( new QgsRendererV2Metadata( "grassEdit",
QObject::tr( "GRASS Edit" ),
QgsGrassEditRenderer::create,
QIcon(),
QgsGrassEditRendererWidget::create ) );
QgsGrassEditRenderer *renderer = new QgsGrassEditRenderer();
mOldStyles[vectorLayer] = vectorLayer->styleManager()->currentStyle();
// Because the edit style may be stored to project:
// - do not translate because it may be loaded in QGIS running with different language
// - do not change the name until really necessary because it could not be found in project
QString editStyleName = "GRASS Edit"; // should not be translated
if ( vectorLayer->styleManager()->styles().contains( editStyleName ) )
{
QgsDebugMsg( editStyleName + " style exists -> set as current" );
vectorLayer->styleManager()->setCurrentStyle( editStyleName );
}
else
{
QgsDebugMsg( "create and set style " + editStyleName );
vectorLayer->styleManager()->addStyleFromLayer( editStyleName );
//vectorLayer->styleManager()->addStyle( editStyleName, QgsMapLayerStyle() );
vectorLayer->styleManager()->setCurrentStyle( editStyleName );
vectorLayer->setRendererV2( renderer );
}
grassProvider->startEditing( vectorLayer );
vectorLayer->updateFields();
connect( vectorLayer, SIGNAL( editingStopped() ), SLOT( onEditingStopped() ) );
resetEditActions();
}
示例13: 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() );
}
示例14: addJoinToTreeWidget
void QgsVectorLayerProperties::addJoinToTreeWidget( const QgsVectorJoinInfo& join )
{
QTreeWidgetItem* joinItem = new QTreeWidgetItem();
QgsVectorLayer* joinLayer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( join.joinLayerId ) );
if ( !joinLayer )
{
return;
}
joinItem->setText( 0, joinLayer->name() );
joinItem->setData( 0, Qt::UserRole, join.joinLayerId );
joinItem->setText( 1, join.joinFieldName );
joinItem->setText( 2, join.targetFieldName );
mJoinTreeWidget->addTopLevelItem( joinItem );
}
示例15: selectedLayer
QgsVectorLayer* RgLineVectorLayerSettingsWidget::selectedLayer()
{
QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin();
for ( ; layer_it != mapLayers.end(); ++layer_it )
{
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer_it.value() );
if ( !vl )
continue;
if ( vl->geometryType() != QGis::Line )
continue;
if ( vl->name() == mcbLayers->currentText() )
return vl;
}
return NULL;
} // RgLineVectorLayerSettingsWidget::setlectedLayer()