本文整理汇总了C++中QgsFeature函数的典型用法代码示例。如果您正苦于以下问题:C++ QgsFeature函数的具体用法?C++ QgsFeature怎么用?C++ QgsFeature使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QgsFeature函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: highlightFeature
void QgsRelationReferenceWidget::highlightActionTriggered( QAction *action )
{
if ( action == mHighlightFeatureAction )
{
highlightFeature();
}
else if ( action == mScaleHighlightFeatureAction )
{
highlightFeature( QgsFeature(), Scale );
}
else if ( action == mPanHighlightFeatureAction )
{
highlightFeature( QgsFeature(), Pan );
}
}
示例2: connect
void QgsDualView::init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest &request, const QgsAttributeEditorContext &context )
{
mEditorContext = context;
connect( mTableView, SIGNAL( willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT( viewWillShowContextMenu( QMenu*, QModelIndex ) ) );
initLayerCache( layer, !request.filterRect().isNull() );
initModels( mapCanvas, request );
mConditionalFormatWidget->setLayer( layer );
mTableView->setModel( mFilterModel );
mFeatureList->setModel( mFeatureListModel );
mAttributeForm = new QgsAttributeForm( layer, QgsFeature(), mEditorContext );
if ( !mAttributeEditorScrollArea->layout() )
mAttributeEditorScrollArea->setLayout( new QGridLayout() );
mAttributeEditorScrollArea->layout()->addWidget( mAttributeForm );
mAttributeEditorScrollArea->setWidget( mAttributeForm );
mAttributeForm->hideButtonBox();
connect( mAttributeForm, SIGNAL( attributeChanged( QString, QVariant ) ), this, SLOT( featureFormAttributeChanged() ) );
connect( mMasterModel, SIGNAL( modelChanged() ), mAttributeForm, SLOT( refreshFeature() ) );
if ( mFeatureListPreviewButton->defaultAction() )
mFeatureList->setDisplayExpression( mDisplayExpression );
else
columnBoxInit();
// This slows down load of the attribute table heaps and uses loads of memory.
//mTableView->resizeColumnsToContents();
mFeatureList->setEditSelection( QgsFeatureIds() << mFeatureListModel->idxToFid( mFeatureListModel->index( 0, 0 ) ) );
}
示例3: QSettings
void QgsRelationReferenceWidget::deleteForeignKey()
{
QVariant nullValue = QSettings().value( "qgis/nullValue", "NULL" );
if ( mReadOnlySelector )
{
QString nullText = "";
if ( mAllowNull )
{
nullText = tr( "%1 (no selection)" ).arg( nullValue.toString() );
}
mLineEdit->setText( nullText );
mForeignKey = QVariant();
mFeature.setValid( false );
}
else
{
if ( mAllowNull )
{
mComboBox->setCurrentIndex( 0 );
}
else
{
mComboBox->setCurrentIndex( -1 );
}
}
mRemoveFKButton->setEnabled( false );
updateAttributeEditorFrame( QgsFeature() );
emit foreignKeyChanged( QVariant( QVariant::Int ) );
}
示例4: while
bool QgsCachedFeatureIterator::fetchFeature( QgsFeature &f )
{
f.setValid( false );
if ( mClosed )
return false;
while ( mFeatureIdIterator != mFeatureIds.constEnd() )
{
if ( !mVectorLayerCache->mCache.contains( *mFeatureIdIterator ) )
{
++mFeatureIdIterator;
continue;
}
f = QgsFeature( *mVectorLayerCache->mCache[*mFeatureIdIterator]->feature() );
++mFeatureIdIterator;
if ( mRequest.acceptFeature( f ) )
{
f.setValid( true );
geometryToDestinationCrs( f, mTransform );
return true;
}
}
close();
return false;
}
示例5: disableChainedComboBoxes
void QgsRelationReferenceWidget::deleteForeignKey()
{
// deactivate filter comboboxes
if ( mChainFilters && !mFilterComboBoxes.isEmpty() )
{
QComboBox *cb = mFilterComboBoxes.first();
cb->setCurrentIndex( 0 );
disableChainedComboBoxes( cb );
}
if ( mReadOnlySelector )
{
const QString nullValue = QgsApplication::nullRepresentation();
QString nullText;
if ( mAllowNull )
{
nullText = tr( "%1 (no selection)" ).arg( nullValue );
}
mLineEdit->setText( nullText );
mForeignKey = QVariant( QVariant::Int );
mFeature.setValid( false );
}
else
{
mComboBox->setIdentifierValue( QVariant( QVariant::Int ) );
}
mRemoveFKButton->setEnabled( false );
updateAttributeEditorFrame( QgsFeature() );
emitForeignKeyChanged( QVariant( QVariant::Int ) );
}
示例6: QDialog
QgsSelectByFormDialog::QgsSelectByFormDialog( QgsVectorLayer *layer, const QgsAttributeEditorContext &context, QWidget *parent, Qt::WindowFlags fl )
: QDialog( parent, fl )
, mLayer( layer )
, mMessageBar( nullptr )
{
QgsAttributeEditorContext dlgContext = context;
dlgContext.setFormMode( QgsAttributeEditorContext::StandaloneDialog );
dlgContext.setAllowCustomUi( false );
mForm = new QgsAttributeForm( layer, QgsFeature(), dlgContext, this );
mForm->setMode( QgsAttributeForm::SearchMode );
QVBoxLayout *vLayout = new QVBoxLayout();
vLayout->setMargin( 0 );
vLayout->setContentsMargins( 0, 0, 0, 0 );
setLayout( vLayout );
vLayout->addWidget( mForm );
connect( mForm, &QgsAttributeForm::closed, this, &QWidget::close );
QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/SelectByForm/geometry" ) ).toByteArray() );
setWindowTitle( tr( "Select features by value" ) );
}
示例7: mComposition
QgsAtlasComposition::QgsAtlasComposition( QgsComposition* composition )
: mComposition( composition )
, mEnabled( false )
, mHideCoverage( false )
, mFilenamePattern( "'output_'||$feature" )
, mCoverageLayer( 0 )
, mSingleFile( false )
, mSortFeatures( false )
, mSortAscending( true )
, mCurrentFeatureNo( 0 )
, mFilterFeatures( false )
{
// declare special columns with a default value
QgsExpression::setSpecialColumn( "$page", QVariant(( int )1 ) );
QgsExpression::setSpecialColumn( "$feature", QVariant(( int )0 ) );
QgsExpression::setSpecialColumn( "$numpages", QVariant(( int )1 ) );
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )0 ) );
QgsExpression::setSpecialColumn( "$atlasfeatureid", QVariant(( int )0 ) );
QgsExpression::setSpecialColumn( "$atlasfeature", QVariant::fromValue( QgsFeature() ) );
QgsExpression::setSpecialColumn( "$atlasgeometry", QVariant::fromValue( QgsGeometry() ) );
//listen out for layer removal
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( removeLayers( QStringList ) ) );
}
示例8: connect
void QgsDualView::init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, const QgsFeatureRequest &request, QgsAttributeEditorContext context )
{
mEditorContext = context;
connect( mTableView, SIGNAL( willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT( viewWillShowContextMenu( QMenu*, QModelIndex ) ) );
initLayerCache( layer );
initModels( mapCanvas, request );
mTableView->setModel( mFilterModel );
mFeatureList->setModel( mFeatureListModel );
mAttributeForm = new QgsAttributeForm( layer, QgsFeature(), mEditorContext );
mAttributeEditorScrollArea->setLayout( new QGridLayout() );
mAttributeEditorScrollArea->layout()->addWidget( mAttributeForm );
mAttributeEditorScrollArea->setWidget( mAttributeForm );
mAttributeForm->hideButtonBox();
connect( mAttributeForm, SIGNAL( attributeChanged( QString, QVariant ) ), this, SLOT( featureFormAttributeChanged() ) );
if ( mFeatureListPreviewButton->defaultAction() )
mFeatureList->setDisplayExpression( mDisplayExpression );
else
columnBoxInit();
mFeatureList->setEditSelection( QgsFeatureIds() << mFeatureListModel->idxToFid( mFeatureListModel->index( 0, 0 ) ) );
}
示例9: context
void QgsRelationReferenceWidget::setRelation( const QgsRelation& relation, bool allowNullValue )
{
mAllowNull = allowNullValue;
mRemoveFKButton->setVisible( allowNullValue && mReadOnlySelector );
if ( relation.isValid() )
{
mInvalidLabel->hide();
mRelation = relation;
mReferencingLayer = relation.referencingLayer();
mRelationName = relation.name();
mReferencedLayer = relation.referencedLayer();
mFkeyFieldIdx = mReferencedLayer->fieldNameIndex( relation.fieldPairs().first().second );
QgsAttributeEditorContext context( mEditorContext, relation, QgsAttributeEditorContext::Single, QgsAttributeEditorContext::Embed );
if ( mEmbedForm )
{
mAttributeEditorFrame->setTitle( mReferencedLayer->name() );
mReferencedAttributeForm = new QgsAttributeForm( relation.referencedLayer(), QgsFeature(), context, this );
mReferencedAttributeForm->hideButtonBox();
mAttributeEditorLayout->addWidget( mReferencedAttributeForm );
}
}
else
{
mInvalidLabel->show();
}
if ( mShown && isVisible() )
{
init();
}
}
示例10: QString
bool QgsPostgresFeatureIterator::fetchFeature( QgsFeature& feature )
{
feature.setValid( false );
if ( mClosed )
return false;
if ( mFeatureQueue.empty() )
{
QString fetch = QString( "FETCH FORWARD %1 FROM %2" ).arg( mFeatureQueueSize ).arg( mCursorName );
QgsDebugMsgLevel( QString( "fetching %1 features." ).arg( mFeatureQueueSize ), 4 );
if ( mConn->PQsendQuery( fetch ) == 0 ) // fetch features asynchronously
{
QgsMessageLog::logMessage( QObject::tr( "Fetching from cursor %1 failed\nDatabase error: %2" ).arg( mCursorName, mConn->PQerrorMessage() ), QObject::tr( "PostGIS" ) );
}
QgsPostgresResult queryResult;
for ( ;; )
{
queryResult = mConn->PQgetResult();
if ( !queryResult.result() )
break;
if ( queryResult.PQresultStatus() != PGRES_TUPLES_OK )
{
QgsMessageLog::logMessage( QObject::tr( "Fetching from cursor %1 failed\nDatabase error: %2" ).arg( mCursorName, mConn->PQerrorMessage() ), QObject::tr( "PostGIS" ) );
break;
}
int rows = queryResult.PQntuples();
if ( rows == 0 )
continue;
for ( int row = 0; row < rows; row++ )
{
mFeatureQueue.enqueue( QgsFeature() );
getFeature( queryResult, row, mFeatureQueue.back() );
} // for each row in queue
}
}
if ( mFeatureQueue.empty() )
{
QgsDebugMsg( QString( "Finished after %1 features" ).arg( mFetched ) );
close();
mSource->mShared->ensureFeaturesCountedAtLeast( mFetched );
return false;
}
feature = mFeatureQueue.dequeue();
mFetched++;
feature.setValid( true );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
return true;
}
示例11: connect
void QgsDualView::init( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas, const QgsFeatureRequest &request, const QgsAttributeEditorContext &context, bool loadFeatures )
{
if ( !layer )
return;
mLayer = layer;
mEditorContext = context;
connect( mTableView, &QgsAttributeTableView::willShowContextMenu, this, &QgsDualView::viewWillShowContextMenu );
mTableView->horizontalHeader()->setContextMenuPolicy( Qt::CustomContextMenu );
connect( mTableView->horizontalHeader(), &QHeaderView::customContextMenuRequested, this, &QgsDualView::showViewHeaderMenu );
connect( mTableView, &QgsAttributeTableView::columnResized, this, &QgsDualView::tableColumnResized );
connect( mFeatureList, &QgsFeatureListView::willShowContextMenu, this, &QgsDualView::widgetWillShowContextMenu );
initLayerCache( !( request.flags() & QgsFeatureRequest::NoGeometry ) || !request.filterRect().isNull() );
initModels( mapCanvas, request, loadFeatures );
mConditionalFormatWidget->setLayer( mLayer );
mTableView->setModel( mFilterModel );
mFeatureList->setModel( mFeatureListModel );
delete mAttributeForm;
mAttributeForm = new QgsAttributeForm( mLayer, mTempAttributeFormFeature, mEditorContext );
mTempAttributeFormFeature = QgsFeature();
if ( !context.parentContext() )
{
mAttributeEditorScrollArea = new QgsScrollArea();
mAttributeEditorScrollArea->setWidgetResizable( true );
mAttributeEditor->layout()->addWidget( mAttributeEditorScrollArea );
mAttributeEditorScrollArea->setWidget( mAttributeForm );
}
else
{
mAttributeEditor->layout()->addWidget( mAttributeForm );
}
connect( mAttributeForm, &QgsAttributeForm::widgetValueChanged, this, &QgsDualView::featureFormAttributeChanged );
connect( mAttributeForm, &QgsAttributeForm::modeChanged, this, &QgsDualView::formModeChanged );
connect( mMasterModel, &QgsAttributeTableModel::modelChanged, mAttributeForm, &QgsAttributeForm::refreshFeature );
connect( mAttributeForm, &QgsAttributeForm::filterExpressionSet, this, &QgsDualView::filterExpressionSet );
connect( mFilterModel, &QgsAttributeTableFilterModel::sortColumnChanged, this, &QgsDualView::onSortColumnChanged );
if ( mFeatureListPreviewButton->defaultAction() )
mFeatureList->setDisplayExpression( mDisplayExpression );
else
columnBoxInit();
// This slows down load of the attribute table heaps and uses loads of memory.
//mTableView->resizeColumnsToContents();
mFeatureList->setEditSelection( QgsFeatureIds() << mFeatureListModel->idxToFid( mFeatureListModel->index( 0, 0 ) ) );
}
示例12: while
bool QgsCachedFeatureIterator::fetchFeature( QgsFeature& f )
{
mFeatureIdIterator++;
while ( mFeatureIdIterator != mFeatureIds.end() )
{
f = QgsFeature( *mVectorLayerCache->mCache[*mFeatureIdIterator]->feature() );
if ( mRequest.acceptFeature( f ) )
return true;
}
return false;
}
示例13: referencedColumns
QStringList QgsDataDefined::referencedColumns( QgsVectorLayer* layer )
{
if ( layer )
{
return referencedColumns( QgsExpressionContextUtils::createFeatureBasedContext( QgsFeature(), layer->fields() ) );
}
else
{
QgsExpressionContext empty;
return referencedColumns( empty );
}
}
示例14: whileBlocking
void QgsRelationReferenceWidget::showIndeterminateState()
{
if ( mReadOnlySelector )
{
whileBlocking( mLineEdit )->setText( QString() );
}
else
{
whileBlocking( mComboBox )->setCurrentIndex( -1 );
}
mRemoveFKButton->setEnabled( false );
updateAttributeEditorFrame( QgsFeature() );
}
示例15: prepareExpression
bool QgsDataDefined::prepareExpression( QgsVectorLayer* layer )
{
if ( layer )
{
return prepareExpression( QgsExpressionContextUtils::createFeatureBasedContext( QgsFeature(), layer->fields() ) );
}
else
{
//preparing expression without a layer set, so pass empty context
QgsExpressionContext empty;
return prepareExpression( empty );
}
}