28 #include <QPainterPath> 30 #include <QProgressDialog> 89 #ifdef TESTPROVIDERLIB 98 const QString& styleDescription,
126 bool loadDefaultStyleFlag )
127 :
QgsMapLayer( VectorLayer, baseName, vectorLayerPath )
128 , mDataProvider( nullptr )
129 , mProviderKey( providerKey )
132 , mWkbType(
QGis::WKBUnknown )
133 , mRendererV2( nullptr )
137 , mLabelFontNotFoundNotified( false )
138 , mFeatureBlendMode(
QPainter::CompositionMode_SourceOver )
139 , mLayerTransparency( 0 )
140 , mVertexMarkerOnlyForSelection( false )
142 , mEditBuffer( nullptr )
143 , mJoinBuffer( nullptr )
144 , mExpressionFieldBuffer( nullptr )
145 , mDiagramRenderer( nullptr )
146 , mDiagramLayerSettings( nullptr )
147 , mValidExtent( false )
148 , mLazyExtent( true )
149 , mSymbolFeatureCounted( false )
150 , mEditCommandActive( false )
157 if ( ! mProviderKey.
isEmpty() )
159 setDataSource( vectorLayerPath, baseName, providerKey, loadDefaultStyleFlag );
167 mSimplifyMethod.
setSimplifyHints( static_cast< QgsVectorSimplifyMethod::SimplifyHints >( settings.
value(
"/qgis/simplifyDrawingHints", static_cast< int>( mSimplifyMethod.
simplifyHints() ) ).
toInt() ) );
183 delete mDataProvider;
186 delete mExpressionFieldBuffer;
190 delete mDiagramLayerSettings;
191 delete mDiagramRenderer;
196 delete mConditionalStyles;
251 mDisplayField = fldName;
255 int fieldsSize = mUpdatedFields.
size();
257 Q_FOREACH (
const QgsField& field, mUpdatedFields )
266 if ( fldName.
indexOf(
"name", 0, Qt::CaseInsensitive ) > -1 )
273 if ( fldName.
indexOf(
"descrip", 0, Qt::CaseInsensitive ) > -1 )
280 if ( fldName.
indexOf(
"id", 0, Qt::CaseInsensitive ) > -1 )
290 if ( fieldsSize == 0 )
293 if ( idxName.
length() > 0 )
295 mDisplayField = idxName;
301 mDisplayField = idxId;
305 mDisplayField = mUpdatedFields.
at( 0 ).
name();
322 if ( mRendererV2 && mLabelOn && mLabel &&
329 attributes.
append( attrNum );
337 QgsDebugMsg(
"Selecting features based on view extent" );
346 .setFilterRect( rendererContext.
extent() )
347 .setSubsetOfAttributes( attributes ) );
354 bool sel = mSelectedFeatureIds.
contains( fet.id() );
355 mLabel->
renderLabel( rendererContext, fet, sel,
nullptr );
401 p.
drawEllipse( x - m, y - m, m * 2 + 1, m * 2 + 1 );
406 p.
drawLine( x - m, y + m, x + m, y - m );
407 p.
drawLine( x - m, y - m, x + m, y + m );
413 mSelectedFeatureIds.
insert( fid );
420 mSelectedFeatureIds.
unite( featureIds );
427 mSelectedFeatureIds.
remove( fid );
434 mSelectedFeatureIds.
subtract( featureIds );
452 .setFilterRect( rect )
459 newSelection << feat.
id();
491 newSelection << feat.
id();
517 newSelection << feat.
id();
521 newSelection << feat.
id();
540 newSelection = mSelectedFeatureIds + ids;
544 newSelection = mSelectedFeatureIds - ids;
548 newSelection = mSelectedFeatureIds.
intersect( ids );
552 QgsFeatureIds deselectedFeatures = mSelectedFeatureIds - newSelection;
553 mSelectedFeatureIds = newSelection;
561 if ( !intersectingIds.
isEmpty() )
563 QgsDebugMsg(
"Trying to select and deselect the same item at the same time. Unsure what to do. Selecting dubious items." );
566 mSelectedFeatureIds -= deselectIds;
567 mSelectedFeatureIds += selectIds;
575 ids.
subtract( mSelectedFeatureIds );
607 .setFilterRect( rect )
617 if ( mSelectedFeatureIds.
contains( fet.
id() ) )
619 deselectIds << fet.
id();
623 selectIds << fet.
id();
632 if ( mSelectedFeatureIds.
isEmpty() )
640 return mDataProvider;
645 return mDataProvider;
650 if (
mValid && mDataProvider && mDataProvider->
encoding() != encoding )
659 delete mDiagramRenderer;
660 mDiagramRenderer = r;
667 if (
mValid && mDataProvider )
674 QgsDebugMsg(
"invalid layer or pointer to mDataProvider is null" );
682 QgsDebugMsg(
"WARNING: This code should never be reached. Problems may occur..." );
712 .setFilterFids( mSelectedFeatureIds )
730 if ( mSelectedFeatureIds.
contains( fet.
id() ) )
741 if ( retval.
width() == 0.0 || retval.
height() == 0.0 )
750 retval.
set( -1.0, -1.0, 1.0, 1.0 );
764 if ( mLabeling->
type() ==
"simple" )
773 if ( !mDiagramRenderer || !mDiagramLayerSettings )
779 return settingList.
at( 0 ).enabled;
786 if ( !mSymbolFeatureCounted )
789 return mSymbolFeatureCountMap.
value( symbol );
808 if ( mDialog->isVisible() )
822 return mDialog->wasCanceled();
833 if ( mSymbolFeatureCounted )
836 mSymbolFeatureCountMap.clear();
843 if ( !mDataProvider )
857 for ( ; symbolIt != symbolList.
constEnd(); ++symbolIt )
859 mSymbolFeatureCountMap.insert( symbolIt->second, 0 );
865 Q_FOREACH (
QWidget* widget, qApp->topLevelWidgets() )
874 QProgressDialog progressDialog(
tr(
"Updating feature count for layer %1" ).arg(
name() ),
tr(
"Abort" ), 0, nFeatures, mainWindow );
883 int featuresCounted = 0;
886 if ( !mRendererV2->filterNeedsGeometry() )
903 mRendererV2->startRender( renderContext,
fields() );
911 QgsSymbolV2List featureSymbolList = mRendererV2->originalSymbolsForFeature( f, renderContext );
914 mSymbolFeatureCountMap[*symbolIt] += 1;
921 if (( featuresCounted % 50 == 0 ) || time.
elapsed() > 1000 )
924 if ( featuresCounted > nFeatures )
928 progressDialog.
setValue( featuresCounted );
944 mSymbolFeatureCountMap.clear();
945 mRendererV2->stopRender( renderContext );
950 mRendererV2->stopRender( renderContext );
951 progressDialog.
setValue( nFeatures );
952 mSymbolFeatureCounted =
true;
958 mValidExtent =
false;
975 if ( !mValidExtent && mLazyExtent && mDataProvider )
991 if ( !
mValid || !mDataProvider )
993 QgsDebugMsg(
"invoked with invalid layer or null mDataProvider" );
998 ( mEditBuffer->mDeletedFeatureIds.isEmpty() && mEditBuffer->mChangedGeometries.isEmpty() ) ||
1001 mDataProvider->updateExtents();
1005 if ( mDataProvider->featureCount() != 0 )
1013 for ( QgsFeatureMap::const_iterator it = mEditBuffer->mAddedFeatures.constBegin(); it != mEditBuffer->mAddedFeatures.constEnd(); ++it )
1015 if ( it->constGeometry() )
1055 if ( !
mValid || !mDataProvider )
1057 QgsDebugMsg(
"invoked with invalid layer or null mDataProvider" );
1060 return mDataProvider->subsetString();
1065 if ( !
mValid || !mDataProvider )
1067 QgsDebugMsg(
"invoked with invalid layer or null mDataProvider" );
1071 bool res = mDataProvider->setSubsetString( subset );
1088 double maximumSimplificationScale = mSimplifyMethod.maximumScale();
1091 if ( maximumSimplificationScale > 1 && renderContext.
rendererScale() <= maximumSimplificationScale )
1101 return mConditionalStyles;
1106 if ( !
mValid || !mDataProvider )
1115 Q_UNUSED( alsoUpdateExtent );
1116 if ( !
mValid || !mEditBuffer || !mDataProvider )
1119 bool success = mEditBuffer->addFeature( feature );
1155 for (
int attr = 0; attr < fa.
count(); ++attr )
1157 if ( fa.
at( attr ) != ca.
at( attr ) )
1161 QgsDebugMsg(
QString(
"attribute %1 of feature %2 could not be changed." ).arg( attr ).arg( f.
id() ) );
1173 if ( !
mValid || !mEditBuffer || !mDataProvider )
1177 bool result = utils.
insertVertex( x, y, atFeatureId, beforeVertex );
1186 if ( !
mValid || !mEditBuffer || !mDataProvider )
1190 bool result = utils.
moveVertex( x, y, atFeatureId, atVertex );
1199 if ( !
mValid || !mEditBuffer || !mDataProvider )
1203 bool result = utils.
moveVertex( p, atFeatureId, atVertex );
1222 if ( !
mValid || !mEditBuffer || !mDataProvider )
1247 int count = mSelectedFeatureIds.size();
1260 *deletedCount = deleted;
1263 return deleted == count;
1268 if ( !
mValid || !mEditBuffer || !mDataProvider )
1275 if ( !mSelectedFeatureIds.isEmpty() )
1277 result = utils.
addRing( ring, mSelectedFeatureIds, featureId );
1291 if ( !
mValid || !mEditBuffer || !mDataProvider )
1312 if ( !mSelectedFeatureIds.isEmpty() )
1314 result = utils.
addRing( static_cast< QgsCurveV2* >( ring->
clone() ), mSelectedFeatureIds, featureId );
1329 if ( !
mValid || !mEditBuffer || !mDataProvider )
1334 if ( mSelectedFeatureIds.size() < 1 )
1339 else if ( mSelectedFeatureIds.size() > 1 )
1355 if ( !
mValid || !mEditBuffer || !mDataProvider )
1360 if ( mSelectedFeatureIds.size() < 1 )
1365 else if ( mSelectedFeatureIds.size() > 1 )
1381 if ( !
mValid || !mEditBuffer || !mDataProvider )
1386 if ( mSelectedFeatureIds.size() < 1 )
1391 else if ( mSelectedFeatureIds.size() > 1 )
1398 int result = utils.
addPart( ring, *mSelectedFeatureIds.constBegin() );
1407 if ( !
mValid || !mEditBuffer || !mDataProvider )
1420 if ( !
mValid || !mEditBuffer || !mDataProvider )
1424 return utils.
splitParts( splitLine, topologicalEditing );
1429 if ( !
mValid || !mEditBuffer || !mDataProvider )
1433 return utils.
splitFeatures( splitLine, topologicalEditing );
1441 int returnValue = 0;
1454 .setFilterRect( geomBBox )
1482 if ( !
mValid || !mEditBuffer || !mDataProvider )
1491 if ( !
mValid || !mEditBuffer || !mDataProvider )
1520 if ( mLabeling == labeling )
1529 if ( !
mValid || !mDataProvider )
1553 mDataProvider->enterUpdateMode();
1555 if ( mDataProvider->transaction() )
1603 if ( pkeyNode.isNull() )
1610 mProviderKey = pkeyElt.
text();
1614 if ( !mProviderKey.isNull() )
1621 mProviderKey =
"postgres";
1625 mProviderKey =
"ogr";
1628 if ( !setDataProvider( mProviderKey ) )
1634 if ( !pkeyElem.
isNull() )
1637 if ( !encodingString.
isEmpty() )
1639 mDataProvider->setEncoding( encodingString );
1647 connect( mJoinBuffer, SIGNAL( joinedFieldsChanged() ),
this, SLOT( onJoinedFieldsChanged() ) );
1649 mJoinBuffer->readXml( layer_node );
1651 if ( !mExpressionFieldBuffer )
1653 mExpressionFieldBuffer->readXml( layer_node );
1682 setDataProvider( provider );
1695 bool defaultLoadedFlag =
false;
1696 if ( loadDefaultStyleFlag )
1716 bool QgsVectorLayer::setDataProvider(
QString const & provider )
1718 mProviderKey = provider;
1723 delete mDataProvider;
1725 if ( !mDataProvider )
1733 QgsDebugMsg(
"Instantiated the data provider plugin" );
1735 mValid = mDataProvider->isValid();
1746 mWkbType = mDataProvider->geometryType();
1749 connect( mJoinBuffer, SIGNAL( joinedFieldsChanged() ),
this, SLOT( onJoinedFieldsChanged() ) );
1757 if ( mProviderKey ==
"postgres" )
1762 QRegExp reg(
"\"[^\"]+\"\\.\"([^\"]+)\"( \\([^)]+\\))?" );
1771 for ( it = layers.
constBegin(); it != layers.
constEnd() && ( *it )->name() != lName; ++it )
1776 lName +=
'.' + stuff[2].
mid( 2, stuff[2].length() - 3 );
1788 else if ( mProviderKey ==
"osm" )
1793 else if ( provider ==
"ogr" )
1802 mLabel =
new QgsLabel( mDataProvider->fields() );
1822 if ( mapLayerNode.
isNull() || (
"maplayer" != mapLayerNode.
nodeName() ) )
1834 if ( mDataProvider )
1837 provider.
setAttribute(
"encoding", mDataProvider->encoding() );
1844 mJoinBuffer->writeXml( layer_node, document );
1857 mExpressionFieldBuffer->writeXml( layer_node, document );
1874 mActions->readXML( node );
1876 mEditFormConfig->readXml( node );
1879 if ( !annotationFormNode.
isNull() )
1885 mAttributeAliasMap.
clear();
1887 if ( !aliasesNode.
isNull() )
1892 for (
int i = 0; i < aliasNodeList.
size(); ++i )
1905 if ( index >= 0 && index <
fields().count() )
1913 mDefaultExpressionMap.
clear();
1915 if ( !defaultsNode.
isNull() )
1918 for (
int i = 0; i < defaultNodeList.
size(); ++i )
1927 mDefaultExpressionMap.
insert( field, expression );
1933 mExcludeAttributesWMS.clear();
1935 if ( !excludeWMSNode.
isNull() )
1938 for (
int i = 0; i < attributeNodeList.
size(); ++i )
1940 mExcludeAttributesWMS.insert( attributeNodeList.
at( i ).
toElement().
text() );
1944 mExcludeAttributesWFS.clear();
1946 if ( !excludeWFSNode.
isNull() )
1949 for (
int i = 0; i < attributeNodeList.
size(); ++i )
1951 mExcludeAttributesWFS.insert( attributeNodeList.
at( i ).
toElement().
text() );
1955 mEditFormConfig->readXml( node );
1957 mAttributeTableConfig.readXml( node );
1959 mConditionalStyles->readXml( node );
1963 if ( prevExpNode.
isNull() )
1965 mDisplayExpression =
"";
1970 mDisplayExpression = prevExpElem.
text();
1991 if ( !rendererElement.
isNull() )
2009 if ( !labelingElement.
isNull() )
2017 if ( !displayFieldNode.
isNull() )
2025 if ( !blendModeNode.isNull() )
2033 if ( !featureBlendModeNode.isNull() )
2041 if ( !layerTransparencyNode.isNull() )
2051 mLabel->setScaleBasedVisibility( e.attribute(
"scaleBasedLabelVisibilityFlag",
"0" ) ==
"1" );
2052 mLabel->setMinScale( e.attribute(
"minLabelScale",
"1" ).toFloat() );
2053 mLabel->setMaxScale( e.attribute(
"maxLabelScale",
"100000000" ).toFloat() );
2057 mSimplifyMethod.setSimplifyHints( static_cast< QgsVectorSimplifyMethod::SimplifyHints >( e.attribute(
"simplifyDrawingHints",
"1" ).toInt() ) );
2058 mSimplifyMethod.setSimplifyAlgorithm( static_cast< QgsVectorSimplifyMethod::SimplifyAlgorithm >( e.attribute(
"simplifyAlgorithm",
"0" ).toInt() ) );
2059 mSimplifyMethod.setThreshold( e.attribute(
"simplifyDrawingTol",
"1" ).toFloat() );
2060 mSimplifyMethod.setForceLocalOptimization( e.attribute(
"simplifyLocal",
"1" ).toInt() );
2061 mSimplifyMethod.setMaximumScale( e.attribute(
"simplifyMaxScale",
"1" ).toFloat() );
2071 if ( hasLabelsEnabled < 1 )
2083 if ( !labelattributesnode.isNull() && mLabel )
2085 mLabel->readXML( labelattributesnode );
2089 delete mDiagramRenderer;
2090 mDiagramRenderer =
nullptr;
2092 if ( !singleCatDiagramElem.
isNull() )
2095 mDiagramRenderer->readXML( singleCatDiagramElem,
this );
2098 if ( !linearDiagramElem.
isNull() )
2101 mDiagramRenderer->readXML( linearDiagramElem,
this );
2104 if ( mDiagramRenderer )
2107 if ( !diagramSettingsElem.
isNull() )
2109 delete mDiagramLayerSettings;
2111 mDiagramLayerSettings->readXML( diagramSettingsElem,
this );
2120 ( void )
writeStyle( node, doc, errorMessage );
2136 Q_FOREACH (
const QgsField& field, mUpdatedFields )
2140 aliasEntryElem.
setAttribute(
"index", mUpdatedFields.indexFromName( field.
name() ) );
2149 for ( ; attWMSIt != mExcludeAttributesWMS.
constEnd(); ++attWMSIt )
2161 for ( ; attWFSIt != mExcludeAttributesWFS.
constEnd(); ++attWFSIt )
2171 mActions->writeXML( node, doc );
2172 mAttributeTableConfig.writeXml( node );
2173 mEditFormConfig->writeXml( node );
2174 mConditionalStyles->writeXml( node, doc );
2181 Q_FOREACH (
const QgsField& field, mUpdatedFields )
2222 mapLayerNode.
setAttribute(
"scaleBasedLabelVisibilityFlag", mLabel->scaleBasedVisibility() ? 1 : 0 );
2231 mapLayerNode.
setAttribute(
"simplifyLocal", mSimplifyMethod.forceLocalOptimization() ? 1 : 0 );
2246 featureBlendModeElem.
appendChild( featureBlendModeText );
2252 layerTransparencyElem.
appendChild( layerTransparencyText );
2284 if ( fieldname !=
"" )
2292 mLabel->writeXML( node, doc );
2295 if ( mDiagramRenderer )
2297 mDiagramRenderer->writeXML( mapLayerNode, doc,
this );
2298 if ( mDiagramLayerSettings )
2299 mDiagramLayerSettings->writeXML( mapLayerNode, doc,
this );
2311 errorMessage =
"Warning: Name element not found within NamedLayer while it's required.";
2323 readSldLabeling( node );
2335 Q_UNUSED( errorMessage );
2358 if ( !mEditBuffer || !mDataProvider )
2365 bool result = mEditBuffer->changeGeometry( fid, geom );
2375 Q_UNUSED( emitSignal );
2381 if ( !mEditBuffer || !mDataProvider )
2384 return mEditBuffer->changeAttributeValue( fid, field, newValue, oldValue );
2394 QgsAttributeMap::const_iterator it;
2397 const int field = it.
key();
2402 oldValue = oldValues[field];
2410 newValidValues[field] = newValue;
2411 oldValidValues[field] = oldValue;
2421 if ( ! newValidValues.
isEmpty() && mEditBuffer && mDataProvider )
2423 result &= mEditBuffer->changeAttributeValues( fid, newValidValues, oldValidValues );
2431 if ( !mEditBuffer || !mDataProvider )
2434 return mEditBuffer->addAttribute( field );
2439 if ( attIndex < 0 || attIndex >=
fields().count() )
2443 mUpdatedFields[ attIndex ].setAlias(
QString() );
2444 if ( mAttributeAliasMap.contains( name ) )
2446 mAttributeAliasMap.
remove( name );
2454 if ( index < 0 || index >=
fields().count() )
2457 switch ( mUpdatedFields.fieldOrigin( index ) )
2461 if ( mExpressionFieldBuffer )
2463 int oi = mUpdatedFields.fieldOriginIndex( index );
2464 mExpressionFieldBuffer->renameExpression( oi, newName );
2477 if ( !mEditBuffer || !mDataProvider )
2480 return mEditBuffer->renameAttribute( index, newName );
2493 if ( attIndex < 0 || attIndex >=
fields().count() )
2498 mAttributeAliasMap.
insert( name, aliasString );
2499 mUpdatedFields[ attIndex ].setAlias( aliasString );
2505 if ( attributeIndex < 0 || attributeIndex >=
fields().count() )
2513 if ( attributeIndex >= 0 && attributeIndex < mUpdatedFields.count() )
2514 return mUpdatedFields.
at( attributeIndex ).displayName();
2532 if ( index < 0 || index >=
fields().count() )
2541 if ( !mEditBuffer || !mDataProvider )
2544 return mEditBuffer->deleteAttribute( index );
2549 bool deleted =
false;
2552 attrs = attrs.
toSet().toList();
2554 qSort( attrs.
begin(), attrs.
end(), qGreater<int>() );
2556 Q_FOREACH (
int attr, attrs )
2572 bool res = mEditBuffer->deleteFeature( fid );
2575 mSelectedFeatureIds.remove( fid );
2587 bool res = mEditBuffer->deleteFeatures( fids );
2591 mSelectedFeatureIds.subtract( fids );
2603 for (
int i = 0; i < mUpdatedFields.count(); ++i )
2606 providerIndexes.
contains( mUpdatedFields.fieldOriginIndex( i ) ) )
2607 pkAttributesList << i;
2610 return pkAttributesList;
2615 return mDataProvider->featureCount() +
2616 ( mEditBuffer ? mEditBuffer->mAddedFeatures.size() - mEditBuffer->mDeletedFeatureIds.size() : 0 );
2621 mCommitErrors.clear();
2623 if ( !mDataProvider )
2625 mCommitErrors <<
tr(
"ERROR: no provider" );
2631 mCommitErrors <<
tr(
"ERROR: layer not editable" );
2637 bool success = mEditBuffer->commitChanges( mCommitErrors );
2642 mEditBuffer =
nullptr;
2653 mCache->deleteCachedGeometries();
2657 mDataProvider->updateExtents();
2659 mDataProvider->leaveUpdateMode();
2668 return mCommitErrors;
2678 bool rollbackExtent = !mEditBuffer->mDeletedFeatureIds.isEmpty() ||
2679 !mEditBuffer->mAddedFeatures.isEmpty() ||
2680 !mEditBuffer->mChangedGeometries.isEmpty();
2684 mEditBuffer->rollBack();
2698 mEditBuffer =
nullptr;
2705 mCache->deleteCachedGeometries();
2708 if ( rollbackExtent )
2711 mDataProvider->leaveUpdateMode();
2724 return mSelectedFeatureIds.size();
2729 return mSelectedFeatureIds;
2737 if ( mSelectedFeatureIds.count() <= 8 )
2762 if ( mSelectedFeatureIds.isEmpty() )
2768 if ( mSelectedFeatureIds.count() == 1 )
2769 request.
setFilterFid( *mSelectedFeatureIds.constBegin() );
2778 if ( !mEditBuffer || !mDataProvider )
2781 bool res = mEditBuffer->addFeatures( features );
2812 if ( snapResults.
size() < 1 )
2818 point.
setX( snap_it.
value().snappedVertex.x() );
2819 point.
setY( snap_it.
value().snappedVertex.y() );
2831 if ( snappingTolerance <= 0 || !mDataProvider )
2836 QgsRectangle searchRect( startPoint.
x() - snappingTolerance, startPoint.
y() - snappingTolerance,
2837 startPoint.
x() + snappingTolerance, startPoint.
y() + snappingTolerance );
2838 double sqrSnappingTolerance = snappingTolerance * snappingTolerance;
2843 if ( mCache->cachedGeometriesRect().contains( searchRect ) )
2846 for ( QgsGeometryMap::iterator it = cachedGeometries.
begin(); it != cachedGeometries.
end() ; ++it )
2851 snapToGeometry( startPoint, it.key(), g, sqrSnappingTolerance, snappingResults, snap_to );
2861 .setFilterRect( searchRect )
2867 snapToGeometry( startPoint, f.
id(), f.
constGeometry(), sqrSnappingTolerance, snappingResults, snap_to );
2872 return n == 0 ? 2 : 0;
2875 void QgsVectorLayer::snapToGeometry(
const QgsPoint& startPoint,
2878 double sqrSnappingTolerance,
2887 int atVertex, beforeVertex, afterVertex;
2888 double sqrDistVertexSnap, sqrDistSegmentSnap;
2895 snappedPoint = geom->
closestVertex( startPoint, atVertex, beforeVertex, afterVertex, sqrDistVertexSnap );
2896 if ( sqrDistVertexSnap < sqrSnappingTolerance )
2901 if ( beforeVertex != -1 )
2906 if ( afterVertex != -1 )
2911 snappingResultVertex.
layer =
this;
2912 snappingResults.
insert( sqrt( sqrDistVertexSnap ), snappingResultVertex );
2920 sqrDistSegmentSnap = geom->
closestSegmentWithContext( startPoint, snappedPoint, afterVertex,
nullptr,
crs().geographicFlag() ? 1e-12 : 1e-8 );
2922 if ( sqrDistSegmentSnap < sqrSnappingTolerance )
2931 snappingResultSegment.
layer =
this;
2932 snappingResults.
insert( sqrt( sqrDistSegmentSnap ), snappingResultSegment );
2947 QgsDebugMsg(
"----- Computing Coordinate System" );
2957 setCrs( mDataProvider->crs() );
2968 return mDisplayField;
2978 return mDisplayExpression;
2983 return ( mEditBuffer && mDataProvider );
2999 if ( readonly && mEditBuffer )
3002 mReadOnly = readonly;
3009 return mEditBuffer && mEditBuffer->isModified();
3014 if ( idx < 0 || idx >= mUpdatedFields.count() )
3024 if ( idx < 0 || idx >= mUpdatedFields.count() )
3039 mAnnotationForm = ui;
3072 return QSize( cfg.value(
"Width" ).toInt(), cfg.value(
"Height" ).toInt() );
3081 if ( r != mRendererV2 )
3085 mSymbolFeatureCounted =
false;
3086 mSymbolFeatureCountMap.clear();
3095 if ( !mDataProvider )
3099 if ( !mDataProvider->transaction() )
3102 mEditCommandActive =
true;
3109 if ( !mDataProvider )
3113 if ( !mDataProvider->transaction() )
3116 mEditCommandActive =
false;
3117 if ( !mDeletedFids.isEmpty() )
3120 mDeletedFids.clear();
3128 if ( !mDataProvider )
3132 if ( !mDataProvider->transaction() )
3136 mEditCommandActive =
false;
3137 mDeletedFids.clear();
3147 cfg[
"CheckedState"] = checked;
3148 cfg[
"UncheckedState"] = unchecked;
3160 return mJoinBuffer && mJoinBuffer->addJoin( joinInfo );
3173 res = mJoinBuffer->removeJoin( joinLayerId );
3181 return mJoinBuffer->vectorJoins();
3189 mExpressionFieldBuffer->addExpression( exp, fld );
3191 int idx = mUpdatedFields.indexFromName( fld.
name() );
3199 int oi = mUpdatedFields.fieldOriginIndex( index );
3200 mExpressionFieldBuffer->removeExpression( oi );
3207 int oi = mUpdatedFields.fieldOriginIndex( index );
3208 return mExpressionFieldBuffer->expressions().value( oi ).expression;
3213 int oi = mUpdatedFields.fieldOriginIndex( index );
3214 mExpressionFieldBuffer->updateExpression( oi, exp );
3219 if ( !mDataProvider )
3224 mUpdatedFields = mDataProvider->fields();
3228 mEditBuffer->updateFields( mUpdatedFields );
3231 if ( mJoinBuffer && mJoinBuffer->containsJoins() )
3232 mJoinBuffer->updateFields( mUpdatedFields );
3234 if ( mExpressionFieldBuffer )
3235 mExpressionFieldBuffer->updateFields( mUpdatedFields );
3239 for ( ; aliasIt != mAttributeAliasMap.
constEnd(); ++aliasIt )
3241 int index = mUpdatedFields.fieldNameIndex( aliasIt.
key() );
3245 mUpdatedFields[
index ].setAlias( aliasIt.
value() );
3248 for ( ; defaultIt != mDefaultExpressionMap.
constEnd(); ++defaultIt )
3250 int index = mUpdatedFields.fieldNameIndex( defaultIt.
key() );
3254 mUpdatedFields[
index ].setDefaultValueExpression( defaultIt.
value() );
3256 if ( oldFields != mUpdatedFields )
3259 mEditFormConfig->setFields( mUpdatedFields );
3266 if ( mJoinBuffer->containsJoins() )
3268 mJoinBuffer->createJoinCaches();
3274 if ( index < 0 || index >= mUpdatedFields.count() )
3277 QString expression = mUpdatedFields.
at( index ).defaultValueExpression();
3279 return mDataProvider->defaultValue( index );
3290 evalContext = tempContext.
data();
3323 if ( index < 0 || index >= mUpdatedFields.count() )
3328 mDefaultExpressionMap.remove( mUpdatedFields.at( index ).name() );
3332 mDefaultExpressionMap.insert( mUpdatedFields.at( index ).name(), expression );
3339 if ( index < 0 || index >= mUpdatedFields.count() )
3342 return mUpdatedFields.
at( index ).defaultValueExpression();
3347 uniqueValues.
clear();
3348 if ( !mDataProvider )
3361 mDataProvider->uniqueValues( index, uniqueValues, limit );
3366 Q_FOREACH (
const QVariant& v, uniqueValues )
3373 while ( addedIt.
hasNext() && ( limit < 0 || uniqueValues.
count() < limit ) )
3389 while ( it.hasNext() && ( limit < 0 || uniqueValues.
count() < limit ) )
3410 if ( mEditBuffer->mDeletedFeatureIds.isEmpty() &&
3411 mEditBuffer->mAddedFeatures.isEmpty() &&
3412 !mEditBuffer->mDeletedAttributeIds.contains( index ) &&
3413 mEditBuffer->mChangedAttributeValues.isEmpty() )
3415 mDataProvider->uniqueValues( index, uniqueValues, limit );
3428 .setSubsetOfAttributes( attList ) );
3437 if ( limit >= 0 && val.
size() >= limit )
3443 uniqueValues = val.
values();
3448 Q_ASSERT_X(
false,
"QgsVectorLayer::uniqueValues()",
"Unknown source of the field!" );
3453 if ( !mDataProvider )
3467 QVariant min = mDataProvider->minimumValue( index );
3483 while ( it.hasNext() )
3499 if ( mEditBuffer->mDeletedFeatureIds.isEmpty() &&
3500 mEditBuffer->mAddedFeatures.isEmpty() && !
3501 mEditBuffer->mDeletedAttributeIds.contains( index ) &&
3502 mEditBuffer->mChangedAttributeValues.isEmpty() )
3504 return mDataProvider->minimumValue( index );
3518 .setSubsetOfAttributes( attList ) );
3522 double currentValue = 0;
3526 if ( currentValue < minimumValue )
3528 minimumValue = currentValue;
3535 Q_ASSERT_X(
false,
"QgsVectorLayer::minimumValue()",
"Unknown source of the field!" );
3541 if ( !mDataProvider )
3554 QVariant min = mDataProvider->maximumValue( index );
3570 while ( it.hasNext() )
3585 if ( mEditBuffer->mDeletedFeatureIds.isEmpty() &&
3586 mEditBuffer->mAddedFeatures.isEmpty() &&
3587 !mEditBuffer->mDeletedAttributeIds.contains( index ) &&
3588 mEditBuffer->mChangedAttributeValues.isEmpty() )
3590 return mDataProvider->maximumValue( index );
3603 .setSubsetOfAttributes( attList ) );
3607 double currentValue = 0;
3611 if ( currentValue > maximumValue )
3613 maximumValue = currentValue;
3620 Q_ASSERT_X(
false,
"QgsVectorLayer::maximumValue()",
"Unknown source of the field!" );
3630 if ( !mDataProvider )
3636 int attrIndex = mUpdatedFields.fieldNameIndex( fieldOrExpression );
3637 if ( attrIndex >= 0 )
3644 bool providerOk =
false;
3645 QVariant val = mDataProvider->aggregate( aggregate, attrIndex, parameters, context, providerOk );
3659 return c.
calculate( aggregate, fieldOrExpression, context, ok );
3671 if ( attrNum == -1 )
3679 if ( expression->hasParserError() || !expression->prepare( &context ) )
3688 if ( expression.
isNull() )
3689 lst.
append( fieldOrExpression );
3691 lst = expression->referencedColumns();
3694 .
setFlags(( expression && expression->needsGeometry() ) ?
3700 if ( !selectedOnly )
3715 QVariant v = expression->evaluate( &context );
3739 Q_FOREACH (
const QVariant& value, variantValues )
3741 double val = value.
toDouble( &convertOk );
3744 else if ( value.
isNull() )
3766 return mFeatureBlendMode;
3780 return mLayerTransparency;
3785 void QgsVectorLayer::readSldLabeling(
const QDomNode& node )
3792 if ( userStyleElem.
isNull() )
3794 QgsDebugMsg(
"Info: UserStyle element not found." );
3799 if ( featureTypeStyleElem.
isNull() )
3801 QgsDebugMsg(
"Info: FeatureTypeStyle element not found." );
3815 if ( textSymbolizerElem.
isNull() )
3817 QgsDebugMsg(
"Info: TextSymbolizer element not found." );
3824 if ( !labelElem.
isNull() )
3827 if ( !propertyNameElem.
isNull() )
3863 if ( fieldIndex == -1 )
3879 QgsDebugMsg(
"Info: PropertyName element not found." );
3891 if ( !fontElem.
isNull() )
3896 while ( !cssElem.
isNull() )
3898 cssName = cssElem.
attribute(
"name",
"not_found" );
3899 if ( cssName !=
"not_found" )
3901 elemText = cssElem.
text();
3902 if ( cssName ==
"font-family" )
3906 else if ( cssName ==
"font-style" )
3908 setCustomProperty(
"labeling/fontItalic", ( elemText ==
"italic" ) || ( elemText ==
"Italic" ) );
3910 else if ( cssName ==
"font-size" )
3913 int fontSize = elemText.
toInt( &ok );
3919 else if ( cssName ==
"font-weight" )
3921 setCustomProperty(
"labeling/fontBold", ( elemText ==
"bold" ) || ( elemText ==
"Bold" ) );
3923 else if ( cssName ==
"font-underline" )
3925 setCustomProperty(
"labeling/fontUnderline", ( elemText ==
"underline" ) || ( elemText ==
"Underline" ) );
3945 if ( !haloElem.
isNull() )
3951 if ( !radiusElem.
isNull() )
3973 if ( !labelPlacementElem.
isNull() )
3977 if ( !pointPlacementElem.
isNull() )
3982 if ( !displacementElem.
isNull() )
3985 if ( !displacementXElem.
isNull() )
3988 double xOffset = displacementXElem.
text().
toDouble( &ok );
3995 if ( !displacementYElem.
isNull() )
3998 double yOffset = displacementYElem.
text().
toDouble( &ok );
4007 if ( !rotationElem.
isNull() )
4032 if ( mAttributeTableConfig != attributeTableConfig )
4041 if ( !mDiagramLayerSettings )
4043 *mDiagramLayerSettings = s;
4048 QString myMetadata =
"<html><body>";
4052 myMetadata +=
"<p class=\"subheaderglossy\">";
4053 myMetadata +=
tr(
"General" );
4054 myMetadata +=
"</p>\n";
4059 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Layer comment" ) +
"</p>\n";
4060 myMetadata +=
"<p>";
4062 myMetadata +=
"</p>\n";
4066 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Storage type of this layer" ) +
"</p>\n";
4067 myMetadata +=
"<p>";
4069 myMetadata +=
"</p>\n";
4074 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Description of this provider" ) +
"</p>\n";
4075 myMetadata +=
"<p>";
4077 myMetadata +=
"</p>\n";
4081 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Source for this layer" ) +
"</p>\n";
4082 myMetadata +=
"<p>";
4084 myMetadata +=
"</p>\n";
4099 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Geometry type of the features in this layer" ) +
"</p>\n";
4100 myMetadata +=
QString(
"<p>%1 (WKB type: \"%2\")</p>\n" ).
arg( typeString, wkbTypeString );
4106 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Primary key attributes" ) +
"</p>\n";
4107 myMetadata +=
"<p>";
4108 Q_FOREACH (
int idx, pkAttrList )
4112 myMetadata +=
"</p>\n";
4117 myMetadata +=
"<p class=\"glossy\">" +
tr(
"The number of features in this layer" ) +
"</p>\n";
4118 myMetadata +=
"<p>";
4120 myMetadata +=
"</p>\n";
4122 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Capabilities of this layer" ) +
"</p>\n";
4123 myMetadata +=
"<p>";
4125 myMetadata +=
"</p>\n";
4130 myMetadata +=
"<p class=\"subheaderglossy\">";
4131 myMetadata +=
tr(
"Extents" );
4132 myMetadata +=
"</p>\n";
4135 myMetadata +=
"<p class=\"glossy\">" +
tr(
"In layer spatial reference system units" ) +
"</p>\n";
4136 myMetadata +=
"<p>";
4149 QString xMin, yMin, xMax, yMax;
4150 double changeoverValue = 99999;
4151 if ( qAbs( myExtent.
xMinimum() ) > changeoverValue )
4159 if ( qAbs( myExtent.
yMinimum() ) > changeoverValue )
4167 if ( qAbs( myExtent.
xMaximum() ) > changeoverValue )
4175 if ( qAbs( myExtent.
yMaximum() ) > changeoverValue )
4184 myMetadata +=
tr(
"xMin,yMin %1,%2 : xMax,yMax %3,%4" )
4185 .
arg( xMin, yMin, xMax, yMax );
4189 myMetadata +=
tr(
"unknown extent" );
4192 myMetadata +=
"</p>\n";
4200 QgsRectangle myProjectedExtent = coordinateTransform->transformBoundingBox(
extent() );
4201 myMetadata +=
"<p class=\"glossy\">" +
tr(
"In project spatial reference system units" ) +
"</p>\n";
4202 myMetadata +=
"<p>";
4203 myMetadata +=
tr(
"xMin,yMin %1,%2 : xMax,yMax %3,%4" )
4205 .arg( myProjectedExtent.
yMinimum() )
4206 .arg( myProjectedExtent.
xMaximum() )
4207 .arg( myProjectedExtent.
yMaximum() );
4208 myMetadata +=
"</p>\n";
4214 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Layer Spatial Reference System" ) +
"</p>\n";
4215 myMetadata +=
"<p>";
4217 myMetadata +=
"</p>\n";
4225 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Project (Output) Spatial Reference System" ) +
"</p>\n";
4226 myMetadata +=
"<p>";
4227 myMetadata += coordinateTransform->destCRS().toProj4().
replace(
'"',
" \"" );
4228 myMetadata +=
"</p>\n";
4236 myMetadata +=
"<p class=\"glossy\">" +
tr(
"In project spatial reference system units" ) +
"</p>\n";
4237 myMetadata +=
"<p>";
4238 myMetadata +=
tr(
"(Invalid transformation of layer extents)" );
4239 myMetadata +=
"</p>\n";
4247 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Attribute field info" ) +
"</p>\n";
4248 myMetadata +=
"<p>";
4251 myMetadata +=
"<table width=\"100%\">";
4252 myMetadata +=
"<tr><th>";
4253 myMetadata +=
tr(
"Field" );
4254 myMetadata +=
"</th>";
4255 myMetadata +=
"<th>";
4256 myMetadata +=
tr(
"Type" );
4257 myMetadata +=
"</th>";
4258 myMetadata +=
"<th>";
4259 myMetadata +=
tr(
"Length" );
4260 myMetadata +=
"</th>";
4261 myMetadata +=
"<th>";
4262 myMetadata +=
tr(
"Precision" );
4263 myMetadata +=
"</th>";
4264 myMetadata +=
"<th>";
4265 myMetadata +=
tr(
"Comment" );
4266 myMetadata +=
"</th>";
4270 for (
int i = 0, n = myFields.
size(); i < n; ++i )
4274 myMetadata +=
"<tr><td>";
4275 myMetadata += myField.
name();
4276 myMetadata +=
"</td>";
4277 myMetadata +=
"<td>";
4279 myMetadata +=
"</td>";
4280 myMetadata +=
"<td>";
4282 myMetadata +=
"</td>";
4283 myMetadata +=
"<td>";
4285 myMetadata +=
"</td>";
4286 myMetadata +=
"<td>";
4288 myMetadata +=
"</td></tr>";
4292 myMetadata +=
"</table>";
4295 myMetadata +=
"</body></html>";
4301 mSymbolFeatureCounted =
false;
4304 void QgsVectorLayer::onJoinedFieldsChanged()
4310 void QgsVectorLayer::onFeatureDeleted(
QgsFeatureId fid )
4312 if ( mEditCommandActive )
4313 mDeletedFids << fid;
4322 if ( mEditFormConfig->widgetType( idx ) ==
"ValueRelation" )
4327 cfg.value(
"Key" ).toString(),
4328 cfg.value(
"Value" ).toString(),
4329 cfg.value(
"AllowNull" ).toBool(),
4330 cfg.value(
"OrderByValue" ).toBool(),
4331 cfg.value(
"AllowMulti" ).toBool(),
4332 cfg.value(
"FilterExpression" ).toString()
4352 msgError =
QObject::tr(
"Unable to load %1 provider" ).
arg( mProviderKey );
4357 if ( !listStylesExternalMethod )
4360 msgError =
QObject::tr(
"Provider %1 has no %2 method" ).
arg( mProviderKey,
"listStyles" );
4364 return listStylesExternalMethod(
mDataSource, ids, names, descriptions, msgError );
4373 msgError =
QObject::tr(
"Unable to load %1 provider" ).
arg( mProviderKey );
4378 if ( !getStyleByIdMethod )
4381 msgError =
QObject::tr(
"Provider %1 has no %2 method" ).
arg( mProviderKey,
"getStyleById" );
4385 return getStyleByIdMethod(
mDataSource, styleId, msgError );
4390 bool useAsDefault,
const QString& uiFileContent,
QString &msgError )
4398 msgError =
QObject::tr(
"Unable to load %1 provider" ).
arg( mProviderKey );
4403 if ( !saveStyleExternalMethod )
4406 msgError =
QObject::tr(
"Provider %1 has no %2 method" ).
arg( mProviderKey,
"saveStyle" );
4425 saveStyleExternalMethod(
mDataSource, qmlStyle, sldStyle, name,
4426 description, uiFileContent, useAsDefault, msgError );
4439 if ( !loadFromLocalDB && mDataProvider && mDataProvider->isSaveAndLoadStyleToDBSupported() )
4446 if ( loadStyleExternalMethod )
4449 qml = loadStyleExternalMethod(
mDataSource, errorMsg );
4474 if ( mDataProvider )
4476 return mDataProvider->layerDependencies();
Q_DECL_DEPRECATED bool deleteVertex(QgsFeatureId atFeatureId, int atVertex)
Deletes a vertex from a feature.
void setExtent(const QgsRectangle &rect) override
Set the extent.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
bool draw(QgsRenderContext &rendererContext) override
Draws the layer.
virtual QString subsetString()
Get the string (typically sql) used to define a subset of the layer.
bool isValid() const
Returns the validity of this feature.
virtual Q_DECL_DEPRECATED bool applyNamedStyle(const QString &namedStyle, QString &errorMsg)
Will load a named style from a provided QML string.
Class for parsing and evaluation of expressions (formerly called "search strings").
void updateFields()
Assembles mUpdatedFields considering provider fields, joined fields and added fields.
Q_DECL_DEPRECATED int removePolygonIntersections(QgsGeometry *geom, const QgsFeatureIds &ignoreFeatures=QgsFeatureIds())
Changes the specified geometry such that it has no intersections with other polygon (or multipolygon)...
QString encoding() const
Get encoding which is used for accessing data.
QgsStringMap attributeAliases() const
Returns a map of field name to attribute alias.
Wrapper for iterator of features from vector data provider or vector layer.
void featuresDeleted(const QgsFeatureIds &fids)
Emitted when features have been deleted.
void selectAll()
Select all the features.
QDomNodeList elementsByTagName(const QString &tagname) const
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
#define RENDERER_TAG_NAME
bool addJoin(const QgsVectorJoinInfo &joinInfo)
Joins another vector layer to this layer.
static QgsProviderRegistry * instance(const QString &pluginPath=QString::null)
Means of accessing canonical single instance.
A rectangle specified with double values.
Base class for all map layer types.
double rendererScale() const
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
void setDiagramLayerSettings(const QgsDiagramLayerSettings &s)
iterator insert(const Key &key, const T &value)
int insertSegmentVerticesForSnap(const QList< QgsSnappingResult > &snapResults)
Inserts vertices to the snapped segments.
void update(const QgsFields &fields)
Update the configuration with the given fields.
bool readSymbology(const QDomNode &node, QString &errorMessage) override
Read the symbology for the current layer from the Dom node supplied.
field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
QgsAttributes attributes() const
Returns the feature's attributes.
QgsFeatureList selectedFeatures()
Get a copy of the user-selected features.
virtual bool writeXml(QDomNode &layer_node, QDomDocument &doc) override
Write vector layer specific state to project file Dom node.
int size() const
Return number of items.
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
bool contains(const Key &key) const
Q_DECL_DEPRECATED QVariant evaluate(const QgsFeature *f)
Evaluate the feature and return the result.
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith="")
Read custom properties from project file.
void selectByRect(QgsRectangle &rect, SelectBehaviour behaviour=SetSelection)
Select features found within the search rectangle (in layer's coordinates)
QDomNode appendChild(const QDomNode &newChild)
void beforeRollBack()
Is emitted, before changes are rolled back.
void setSimplifyAlgorithm(const SimplifyAlgorithm &simplifyAlgorithm)
Sets the local simplification algorithm of the vector layer managed.
void beginEditCommand(const QString &text)
Create edit command for undo/redo operations.
bool readStyle(const QDomNode &node, QString &errorMessage) override
Read the style for the current layer from the Dom node supplied.
Use exact geometry intersection (slower) instead of bounding boxes.
static QgsFeatureRendererV2 * loadSld(const QDomNode &node, QGis::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
void setMaximum(int maximum)
void push_back(const T &value)
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
QVariant maximumValue(int index)
Returns the maximum value for an attribute column or an invalid variant in case of error...
QgsMapLayerLegend * legend() const
Can be null.
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
Modify current selection to include only select features which match.
Renders the diagrams for all features with the same settings.
QString attribute(const QString &name, const QString &defValue) const
Q_DECL_DEPRECATED bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
int addTopologicalPoints(const QgsGeometry *geom)
Adds topological points for every vertex of the geometry.
void beginMacro(const QString &text)
SimplifyAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
void layerTransparencyChanged(int layerTransparency)
Signal emitted when setLayerTransparency() is called.
QgsVectorLayerInterruptionCheckerDuringCountSymbolFeatures(QProgressDialog *dialog)
Constructor.
bool deleteFeature(QgsFeatureId fid)
Delete a feature from the layer (but does not commit it)
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QSet< QgsFeatureId > QgsFeatureIds
void uniqueValues(int index, QList< QVariant > &uniqueValues, int limit=-1)
Calculates a list of unique values contained within an attribute in the layer.
QString toString(int indent) const
QStringList referencedColumns() const
Get list of columns referenced by the expression.
static void warning(const QString &msg)
Goes to qWarning.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
friend class QgsVectorLayerFeatureSource
void setForceLocalOptimization(bool localOptimization)
Sets where the simplification executes, after fetch the geometries from provider, or when supported...
void invertSelectionInRectangle(QgsRectangle &rect)
Invert selection of features found within the search rectangle (in layer's coordinates) ...
QLibrary * providerLibrary(const QString &providerKey) const
bool commitChanges()
Attempts to commit any changes to disk.
void setRendererV2(QgsFeatureRendererV2 *r)
Set renderer which will be invoked to represent this layer.
virtual void setEncoding(const QString &e)
Set encoding used for accessing data from layer.
bool startEditing()
Make layer editable.
const_iterator constBegin() const
void setRendererScale(double scale)
const T & at(int i) const
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
VertexMarkerType
Editing vertex markers.
void removeExpressionField(int index)
Remove an expression field.
void setFeatureBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering each feature.
Q_DECL_DEPRECATED void select(QgsRectangle &rect, bool addToSelection)
Select features found within the search rectangle (in layer's coordinates)
bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues)
Changes attributes' values for a feature (but does not immediately commit the changes).
#define Q_NOWARN_DEPRECATED_PUSH
int makeDifference(const QgsGeometry *other)
Changes this geometry such that it does not intersect the other geometry.
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
static QgsMapRenderer::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QString toProj4() const
Returns a Proj4 string representation of this CRS.
Q_DECL_DEPRECATED QString dateFormat(int idx)
Access date format.
SimplifyHint
Simplification flags for fast rendering of features.
Utility class for calculating aggregates for a field (or expression) over the features from a vector ...
bool deleteAttributes(QList< int > attrs)
Deletes a list of attribute fields (but does not commit it)
void setLabeling(QgsAbstractVectorLayerLabeling *labeling)
Set labeling configuration.
void readCustomSymbology(const QDomElement &element, QString &errorMessage)
Signal emitted whenever the symbology (QML-file) for this layer is being read.
QString evalErrorString() const
Returns evaluation error.
QDomElement nextSiblingElement(const QString &tagName) const
bool deleteFeatures(const QgsFeatureIds &fids)
Deletes a set of features from the layer (but does not commit it)
int insertSegmentVerticesForSnap(const QList< QgsSnappingResult > &snapResults)
Inserts vertices to the snapped segments.
void setDefaultValueExpression(int index, const QString &expression)
Sets an expression to use when calculating the default value for a field.
Q_DECL_DEPRECATED QMap< QString, QVariant > valueMap(int idx)
Access value map.
void configChanged()
Emitted whenever the configuration is changed.
Container of fields for a vector layer.
QMap< QString, QgsMapLayer * > mapLayers() const
Returns a map of all registered layers by layer ID.
A geometry is the spatial representation of a feature.
void setDiagramRenderer(QgsDiagramRendererV2 *r)
Sets diagram rendering object (takes ownership)
void setLayerTransparency(int layerTransparency)
Set the transparency for the vector layer.
QSet< T > & subtract(const QSet< T > &other)
ValueRelationData valueRelation(int idx)
Access value relation widget data.
void beforeRemovingExpressionField(int idx)
Will be emitted, when an expression field is going to be deleted from this vector layer...
static const char * vectorGeometryType(GeometryType type)
description strings for geometry types
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
WkbType
Used for symbology operations.
static void mergeScaleDependencies(int mScaleMinDenom, int mScaleMaxDenom, QgsStringMap &props)
Merges the local scale limits, if any, with the ones already in the map, if any.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the scope.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
void remAttributeAlias(int attIndex)
Removes an alias (a display name) for attributes to display in dialogs.
QList< double > getDoubleValues(const QString &fieldOrExpression, bool &ok, bool selectedOnly=false, int *nullCount=nullptr)
Fetches all double values from a specified field name or expression.
The QGis class provides global constants for use throughout the application.
Set selection, removing any existing selection.
void setDisplayExpression(const QString &displayExpression)
Set the preview expression, used to create a human readable preview string.
virtual QList< QString > usedAttributes()=0
Returns a set of attributes required for this renderer.
void selectByIds(const QgsFeatureIds &ids, SelectBehaviour behaviour=SetSelection)
Select matching features using a list of feature IDs.
field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
Edit operation resulted in an empty geometry.
QString expressionField(int index)
Returns the expressoin used for a given expression field.
int addPart(const QList< QgsPoint > &ring, QgsFeatureId featureId)
Adds a new part polygon to a multipart feature.
const_iterator insert(const T &value)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QString & remove(int position, int n)
QList< QgsRelation > referencingRelations(int idx)
Get relations, where the foreign key is on this layer.
bool addFeature(QgsFeature &feature, bool alsoUpdateExtent=true)
Adds a feature.
QgsRelationManager * relationManager() const
void drawLine(const QLineF &line)
static const int EditingCapabilities
Bitmask of all provider's editing capabilities.
virtual ~QgsVectorLayer()
Destructor.
virtual QgsCurveV2 * clone() const override=0
Clones the geometry by performing a deep copy.
const QList< QgsVectorJoinInfo > vectorJoins() const
Q_DECL_DEPRECATED void setCheckedState(int idx, const QString &checked, const QString ¬Checked)
Set string representing 'true' for a checkbox.
void beforeCommitChanges()
Is emitted, before changes are commited to the data provider.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
virtual Q_DECL_DEPRECATED bool isReadOnly() const override
Returns true if the provider is in read-only mode.
void committedFeaturesRemoved(const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
This signal is emitted, when features are deleted from the provider.
double toDouble(bool *ok) const
void committedAttributesDeleted(const QString &layerId, const QgsAttributeList &deletedAttributes)
This signal is emitted, when attributes are deleted from the provider.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
virtual bool isEditable() const override
Returns true if the provider is in editing mode.
virtual QSet< QString > layerDependencies() const
Get the list of layer ids on which this layer depends.
QVariant minimumValue(int index)
Returns the minimum value for an attribute column or an invalid variant in case of error...
void selectByExpression(const QString &expression, SelectBehaviour behaviour=SetSelection)
Select matching features using an expression.
bool insertVertex(double x, double y, QgsFeatureId atFeatureId, int beforeVertex)
Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0)...
void setSimplifyHints(const SimplifyHints &simplifyHints)
Sets the simplification hints of the vector layer managed.
QgsMapLayer::LayerType type() const
Get the type of the layer.
virtual Q_DECL_DEPRECATED bool willRenderFeature(QgsFeature &feat)
Returns whether the renderer will render a feature or not.
QString tr(const char *sourceText, const char *disambiguation, int n)
void featureDeleted(QgsFeatureId fid)
Emitted when a feature has been deleted.
QMap< QString, QString > QgsStringMap
long featureCount() const
Returns feature count including changes which have not yet been committed If you need only the count ...
void editCommandEnded()
Signal emitted, when an edit command successfully ended.
QString mLayerName
Name of the layer - used for display.
bool isGeosEqual(const QgsGeometry &) const
Compares the geometry with another geometry using GEOS.
Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config(int fieldIdx) const
Get the configuration for the editor widget used to represent the field at the given index...
void invertSelection()
Select not selected features and deselect selected ones.
void setParameters(const AggregateParameters ¶meters)
Sets all aggregate parameters from a parameter bundle.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
it has not been specified where the field comes from
int splitFeatures(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
void styleChanged()
Signal emitted whenever a change affects the layer's style.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
double y() const
Get the y value of the point.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
virtual void updateExtents()
Update the extents for the layer.
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file.
void removeSelection()
Clear selection.
Manages joined fields for a vector layer.
QgsFields fields() const
Returns the list of fields of this layer.
QgsConditionalLayerStyles * conditionalStyles() const
Return the conditional styles that are set for this layer.
void set(const QgsPoint &p1, const QgsPoint &p2)
Set the rectangle from two QgsPoints.
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
static QString capitaliseLayerName(const QString &name)
A convenience function to (un)capitalise the layer name.
Interface that can be optionaly attached to an iterator so its nextFeature() implementaton can check ...
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
QDomElement toElement() const
bool hasGeometryType() const
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
Q_DECL_DEPRECATED void setEditorWidgetV2(int attrIdx, const QString &widgetType)
Set the editor widget type for a field.
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
void setData(const QString &v)
int indexIn(const QString &str, int offset, CaretMode caretMode) const
virtual int listStylesInDatabase(QStringList &ids, QStringList &names, QStringList &descriptions, QString &msgError)
Lists all the style in db split into related to the layer and not related to.
static QgsWKBTypes::Type fromOldWkbType(QGis::WkbType type)
Converts from old (pre 2.10) WKB type (OGR) to new WKB type.
SnappingType
Snap to vertex, to segment or both.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Return new instance of QgsMapLayerRenderer that will be used for rendering of given context...
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Set feature ID that should be fetched.
void setValue(int progress)
void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
Update the data source of the layer.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QString number(int n, int base)
float maximumScale() const
Gets the maximum scale at which the layer should be simplified.
int count(const T &value) const
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
void processEvents(QFlags< QEventLoop::ProcessEventsFlag > flags)
void append(const T &value)
QList< QgsRelation > referencingRelations(QgsVectorLayer *layer=nullptr, int fieldIdx=-2) const
Get all relations where the specified layer (and field) is the referencing part (i.e.
const QgsFields * fields() const
Returns the field map associated with the feature.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
void deselect(const QgsFeatureId featureId)
Deselect feature by its ID.
void layerDeleted()
TODO QGIS3: remove in favor of QObject::destroyed.
QString & insert(int position, QChar ch)
QgsRectangle extent() override
Return the extent of the layer.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any).
QDomDocument ownerDocument() const
bool rollBack(bool deleteBuffer=true)
Stop editing and discard the edits.
bool isInScaleRange(double scale) const
Return true if the label is visible at the given scale.
int toInt(bool *ok) const
virtual bool isClosed() const
Returns true if the curve is closed.
bool writeSld(QDomNode &node, QDomDocument &doc, QString &errorMessage) const
Writes the symbology of the layer into the document provided in SLD 1.1 format.
QgsDataProvider * provider(const QString &providerKey, const QString &dataSource)
Create an instance of the provider.
bool hasAttribute(const QString &name) const
bool isEmpty() const
test if rectangle is empty.
QString typeName() const
Gets the field type.
const QgsRectangle & extent() const
The attribute value should not be shown in the attribute form.
void featureBlendModeChanged(QPainter::CompositionMode blendMode)
Signal emitted when setFeatureBlendMode() is called.
QString defaultValueExpression
Represents the result of a snapping operation.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
void setPen(const QColor &color)
void beforeModifiedCheck() const
Is emitted, when layer is checked for modifications.
QStringList capturedTexts() const
void drawEllipse(const QRectF &rectangle)
QString dataComment() const
Returns a comment for the data in the layer.
void setAttribute(const QString &name, const QString &value)
int addTopologicalPoints(const QgsGeometry *geom)
Adds topological points for every vertex of the geometry.
Q_DECL_DEPRECATED EditType editType(int idx)
Get edit type.
int snapWithContext(const QgsPoint &startPoint, double snappingTolerance, QMultiMap< double, QgsSnappingResult > &snappingResults, QgsSnapper::SnappingType snap_to)
Snaps to segment or vertex within given tolerance.
double width() const
Width of the rectangle.
bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage) const override
Write just the style information for the layer into the document.
Point geometry type, with support for z-dimension and m-values.
int toInt(bool *ok, int base) const
virtual void setExtent(const QgsRectangle &rect)
Set the extent.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void committedFeaturesAdded(const QString &layerId, const QgsFeatureList &addedFeatures)
This signal is emitted, when features are added to the provider.
int addPart(const QList< QgsPoint > &ring)
Adds a new part polygon to a multipart feature.
const_iterator constEnd() const
bool deleteAttribute(int attr)
Delete an attribute field (but does not commit it)
void editingStopped()
Is emitted, when edited changes successfully have been written to the data provider.
void beforeEditingStarted()
Is emitted, before editing on this layer is started.
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
bool moveVertex(double x, double y, QgsFeatureId atFeatureId, int atVertex)
Moves the vertex at the given position number, ring and item (first number is index 0)...
Arranges candidates in a circle around a point (or centroid of a polygon).
void triggerRepaint()
Will advice the map canvas (and any other interested party) that this layer requires to be repainted...
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
virtual bool isSpatial() const override
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
QList< int > QgsAttributeList
float threshold() const
Gets the simplification threshold of the vector layer managed.
void destroyEditCommand()
Destroy active command and reverts all changes in it.
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
void setBrush(const QBrush &brush)
void setDisplayField(const QString &fldName="")
Set the primary display field to be used in the identify results dialog.
Storage and management of actions associated with a layer.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
const QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority.
QMap< Key, T >::iterator insert(const Key &key, const T &value)
const_iterator constEnd() const
int layerTransparency() const
Returns the current transparency for the vector layer.
bool setReadOnly(bool readonly=true)
Make layer read-only (editing disabled) or not.
bool changeGeometry(QgsFeatureId fid, QgsGeometry *geom)
Change feature's geometry.
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
int afterVertexNr
The index of the vertex after snappedVertex or -1 if no such vertex.
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &value)
Is emitted whenever an attribute value change is done in the edit buffer.
Encapsulate a field in an attribute table or data source.
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg)
Import the properties of this layer from a QDomDocument.
void featureAdded(QgsFeatureId fid)
Emitted when a new feature has been added to the layer.
static QgsFeatureRendererV2 * defaultRenderer(QGis::GeometryType geomType)
return a new renderer - used by default in vector layers
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
void rendererChanged()
Signal emitted when renderer is changed.
virtual QGis::WkbType geometryType() const =0
Get feature type.
Single scope for storing variables and functions for use within a QgsExpressionContext.
double minimumScale() const
Returns the minimum scale denominator at which the layer is visible.
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
Fast access to features using their ID.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities Note, some capabilities may change depending ...
QgsFeatureId snappedAtGeometry
Index of the snapped geometry.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
double maximumScale() const
Returns the maximum scale denominator at which the layer is visible.
bool mValid
Indicates if the layer is valid and can be drawn.
QList< QVariant > getValues(const QString &fieldOrExpression, bool &ok, bool selectedOnly=false)
Fetches all values from a specified field name or expression.
static QPainter::CompositionMode getCompositionMode(BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
void geometryChanged(QgsFeatureId fid, QgsGeometry &geometry)
Is emitted whenever a geometry change is done in the edit buffer.
void raiseError(const QString &msg)
Signals an error related to this vector layer.
void editingStarted()
Is emitted, when editing on this layer has started.
void setName(const QString &name)
Set the display name of the layer.
QgsAttributeList pkAttributeList() const
Returns list of attributes making up the primary key.
QString capabilitiesString() const
Capabilities for this layer in a friendly format.
static void drawVertexMarker(double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
Draws a vertex symbol at (screen) coordinates x, y.
bool addFeatures(QgsFeatureList features, bool makeSelected=true)
Insert a copy of the given features into the layer (but does not commit it)
QVariant calculate(Aggregate aggregate, const QString &fieldOrExpression, QgsExpressionContext *context=nullptr, bool *ok=nullptr) const
Calculates the value of an aggregate.
A class to represent a point.
Q_DECL_DEPRECATED bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &value, bool emitSignal)
Changes an attribute value (but does not commit it)
void addAttributeAlias(int attIndex, const QString &aliasString)
Sets an alias (a display name) for attributes to display in dialogs.
Q_DECL_DEPRECATED void setEditorWidgetV2Config(int attrIdx, const QgsEditorWidgetConfig &config)
Set the editor widget config for a field.
void endEditCommand()
Finish edit command and add it to undo/redo stack.
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
void committedAttributeValuesChanges(const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
This signal is emitted, when attribute value changes are saved to the provider.
QString right(int n) const
QString displayField() const
Returns the primary display field name used in the identify results dialog.
const QStringList & commitErrors()
QDomText createTextNode(const QString &value)
void invalidateSymbolCountedFlag()
QgsFeatureId id() const
Get the feature ID for this feature.
QByteArray toLocal8Bit() const
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, eg both MultiPolygon and CurvePolygon would have a PolygonG...
QgsPoint beforeVertex
The layer coordinates of the vertex before snappedVertex.
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
QgsPoint afterVertex
The layer coordinates of the vertex after snappedVertex.
QDomNode namedItem(const QString &name) const
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name also looks up case-insensitive if there is no match otherwise...
bool contains(QChar ch, Qt::CaseSensitivity cs) const
void editCommandDestroyed()
Signal emitted, whan an edit command is destroyed.
void setX(double x)
Sets the x value of the point.
int addExpressionField(const QString &exp, const QgsField &fld)
Add a new field which is calculated by the expression specified.
void setMaximumScale(float maximumScale)
Sets the maximum scale at which the layer should be simplified.
QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, const QString &fieldOrExpression, const QgsAggregateCalculator::AggregateParameters ¶meters=QgsAggregateCalculator::AggregateParameters(), QgsExpressionContext *context=nullptr, bool *ok=nullptr)
Calculates an aggregated value from the layer's features.
void setY(double y)
Sets the y value of the point.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
virtual void reload() override
Synchronises with changes in the datasource.
bool contains(const T &value) const
bool countSymbolFeatures(bool showProgress=true)
Count features for symbols.
A class to render labels.
static QgsMapLayerLegend * defaultVectorLegend(QgsVectorLayer *vl)
Create new legend implementation for vector layer.
A registry / canonical manager of data providers.
void setProviderEncoding(const QString &encoding)
Sets the textencoding of the data provider.
QgsExpressionContext & expressionContext()
Gets the expression context.
virtual QString loadNamedStyle(const QString &theURI, bool &theResultFlag, bool loadFromLocalDb)
Load a named style from file/local db/datasource db.
QgsGeometry * geometry()
Get the geometry object associated with this feature.
Implementation of threaded rendering for vector layers.
const_iterator constBegin() const
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists).
Stores the settings for rendering of all diagrams for a layer.
double xMaximum() const
Get the x maximum value (right side of rectangle)
bool renameAttribute(int attIndex, const QString &newName)
Renames an attribute field (but does not commit it).
bool contains(const T &value) const
void combineExtentWith(const QgsRectangle &rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
QString defaultValueExpression(int index) const
Returns the expression used when calculating the default value for a field.
QgsFeatureIterator selectedFeaturesIterator(QgsFeatureRequest request=QgsFeatureRequest())
Get an iterator of the selected features.
QString capabilitiesString() const
Returns the above in friendly format.
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
int snappedVertexNr
The vertex index of snappedVertex or -1 if no such vertex number (e.g.
#define Q_NOWARN_DEPRECATED_POP
const Key key(const T &value) const
bool snapPoint(QgsPoint &point, double tolerance)
Snaps a point to the closest vertex if there is one within the snapping tolerance.
bool removeJoin(const QString &joinLayerId)
Removes a vector layer join.
Q_DECL_DEPRECATED void setEditType(int idx, EditType edit)
Set edit type.
EditResult deleteVertexV2(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature.
virtual void exportNamedStyle(QDomDocument &doc, QString &errorMsg)
Export the properties of this layer as named style in a QDomDocument.
bool updateFeature(QgsFeature &f)
Updates an existing feature.
SelectBehaviour
Selection behaviour.
void selectionChanged()
This signal is emitted when selection was changed.
bool insertVertex(double x, double y, QgsFeatureId atFeatureId, int beforeVertex)
Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0)...
virtual bool render() override
Do the rendering (based on data stored in the class)
QString & replace(int position, int n, QChar after)
Add selection to current selection.
QgsAttributeTableConfig attributeTableConfig() const
Get the attribute table configuration object.
void renderLabel(QgsRenderContext &renderContext, QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes=nullptr)
render label
double closestSegmentWithContext(const QgsPoint &point, QgsPoint &minDistPoint, int &afterVertex, double *leftOf=nullptr, double epsilon=DEFAULT_SEGMENT_EPSILON) const
Searches for the closest segment of geometry to the given point.
const T & at(int i) const
QVariant value(const QString &key, const QVariant &defaultValue) const
void attributeAdded(int idx)
Will be emitted, when a new attribute has been added to this vector layer.
Q_DECL_DEPRECATED QSize widgetSize(int idx)
Access widget size for photo and webview widget.
void beforeAddingExpressionField(const QString &fieldName)
Will be emitted, when an expression field is going to be added to this vector layer.
int addRing(const QList< QgsPoint > &ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
Adds a ring to polygon/multipolygon features.
Contains information about the context of a rendering operation.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
QString name() const
Get the display name of the layer.
Buffers information about expression fields for a vector layer.
QString getStyleById_t(const QString &uri, QString styleID, QString &errCause)
bool isEmpty() const
Returns true if the configuration is empty, ie it contains no columns.
void save(QTextStream &str, int indent) const
void editCommandStarted(const QString &text)
Signal emitted when a new edit command has been started.
QString loadStyle_t(const QString &uri, QString &errCause)
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QgsVectorLayer(const QString &path=QString::null, const QString &baseName=QString::null, const QString &providerLib=QString::null, bool loadDefaultStyleFlag=true)
Constructor - creates a vector layer.
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Set feature IDs that should be fetched.
bool remove(const T &value)
void setAnnotationForm(const QString &ui)
Set annotation form for layer.
QSet< T > & unite(const QSet< T > &other)
QString mDataSource
Data source description string, varies by layer type.
virtual QString loadDefaultStyle(bool &theResultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
void * resolve(const char *symbol)
static Q_DECL_DEPRECATED const QString convertEditType(QgsVectorLayer::EditType editType, QgsEditorWidgetConfig &cfg, QgsVectorLayer *vl, const QString &name, const QDomElement &editTypeElement=QDomElement())
QSet< T > & intersect(const QSet< T > &other)
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
QgsVectorLayer::EditResult deleteVertexV2(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature.
Q_DECL_DEPRECATED void setSelectedFeatures(const QgsFeatureIds &ids)
Change selection to the new set of features.
static QgsFeatureRendererV2 * load(QDomElement &symbologyElem)
create a renderer from XML element
virtual void reloadData()
Reloads the data from the source.
bool deleteSelectedFeatures(int *deletedCount=nullptr)
Deletes the selected features.
Q_DECL_DEPRECATED RangeData range(int idx)
Access range widget config data.
Edit operation was successful.
static QgsAbstractVectorLayerLabeling * create(const QDomElement &element)
Try to create instance of an implementation based on the XML data.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
The QgsConditionalLayerStyles class holds conditional style information for a layer.
bool moveVertex(double x, double y, QgsFeatureId atFeatureId, int atVertex)
Moves the vertex at the given position number, ring and item (first number is index 0)...
QString readPath(QString filename, const QString &relativeBasePath=QString()) const
Turn filename read from the project file to an absolute path.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void repaintRequested()
By emitting this signal the layer tells that either appearance or content have been changed and any v...
void committedAttributesAdded(const QString &layerId, const QList< QgsField > &addedAttributes)
This signal is emitted, when attributes are added to the provider.
const QChar at(int position) const
static QgsProject * instance()
Returns the QgsProject singleton instance.
QDomElement firstChildElement(const QString &tagName) const
QgsPoint snappedVertex
The coordinates of the snapping result.
QDomElement lastChildElement(const QString &tagName) const
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
virtual QString dataComment() const
Return a short comment for the data that this provider is providing access to (e.g.
Class for storing a coordinate reference system (CRS)
friend class QgsVectorLayerEditBuffer
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
int count(const T &value) const
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
QgsLabel * label()
Get the label rendering properties associated with this layer.
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
virtual QString description() const =0
Return description.
QList< T > values() const
QList< T > mid(int pos, int length) const
void recalculateExtents()
This is used to send a request that any mapcanvas using this layer update its extents.
void writeCustomSymbology(QDomElement &element, QDomDocument &doc, QString &errorMessage) const
Signal emitted whenever the symbology (QML-file) for this layer is being written. ...
virtual bool setSubsetString(const QString &subset)
Set the string (typically sql) used to define a subset of the layer.
virtual bool mustStop() const
return true if the iterator must stop as soon as possible
double xMinimum() const
Get the x minimum value (left side of rectangle)
virtual QString getStyleFromDatabase(const QString &styleId, QString &msgError)
Will return the named style corresponding to style id provided.
bool readSld(const QDomNode &node, QString &errorMessage) override
Read the symbology of the layer according to the information contained in the UserStyle element of a ...
Basic implementation of the labeling interface.
QgsFields pendingFields() const
Returns the list of fields of this layer.
void dataChanged()
Data of layer changed.
static QColor colorFromOgcFill(const QDomElement &fillElement)
Parse XML with OGC fill into QColor.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
Remove from current selection.
Allows deletion of features.
double yMaximum() const
Get the y maximum value (top side of rectangle)
virtual QString loadNamedStyle(const QString &theURI, bool &theResultFlag)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
double toDouble(bool *ok) const
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage) const override
Write the symbology for the layer into the docment provided.
iterator insert(const Key &key, const T &value)
void checkJoinLayerRemove(const QString &theLayerId)
Check if there is a join with a layer that will be removed.
void(*)() cast_to_fptr(void *p)
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
void addRequiredFields(QgsAttributeList &fields) const
add vector of required fields to existing list of fields
Q_DECL_DEPRECATED const QString editorWidgetV2(int fieldIdx) const
Get the id for the editor widget used to represent the field at the given index.
Edit failed due to invalid layer.
Custom exception class for Coordinate Reference System related exceptions.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QUndoStack * undoStack()
Return pointer to layer's undo stack.
virtual QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
QString metadata() override
Obtain Metadata for this layer.
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
QgsVectorDataProvider * dataProvider()
Returns the data provider.
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
int splitParts(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QString providerType() const
Return the provider type for this layer.
const_iterator constEnd() const
void normalize()
Normalize the rectangle so it has non-negative width/height.
QDomElement createElement(const QString &tagName)
bool nextFeature(QgsFeature &f)
This is a container for configuration of the attribute table.
const_iterator constBegin() const
void setCoordinateSystem()
Setup the coordinate system transformation for the layer.
This is the base class for vector data providers.
void attributeDeleted(int idx)
Will be emitted, when an attribute has been deleted from this vector layer.
static QString displayString(Type type)
Returns a display string type for a WKB type, eg the geometry name used in WKT geometry representatio...
Q_DECL_DEPRECATED bool hasLabelsEnabled() const
Label is on.
Abstract base class for curved geometry type.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
bool intersects(const QgsRectangle &rect) const
returns true when rectangle intersects with other rectangle
virtual bool readXml(const QDomNode &layer_node) override
Reads vector layer specific state from project file Dom node.
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
int addRing(const QList< QgsPoint > &ring, QgsFeatureId *featureId=nullptr)
Adds a ring to polygon/multipolygon features.
void committedGeometriesChanges(const QString &layerId, const QgsGeometryMap &changedGeometries)
This signal is emitted, when geometry changes are saved to the provider.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QgsFeatureIds allFeatureIds()
Get all feature Ids.
static QgsFeatureRendererV2 * readOldRenderer(const QDomNode &layerNode, QGis::GeometryType geomType)
Read old renderer definition from XML and create matching new renderer.
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
QString displayExpression() const
Get the preview expression, used to create a human readable preview string.
virtual QgsRectangle extent()
Return the extent of the layer.
bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
int splitParts(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line.
void modifySelection(QgsFeatureIds selectIds, QgsFeatureIds deselectIds)
Modifies the current selection on this layer.
field is calculated from an expression
int selectedFeatureCount()
The number of features that are selected in this layer.
void updatedFields()
Is emitted, whenever the fields available from this layer have been changed.
QgsPoint closestVertex(const QgsPoint &point, int &atVertex, int &beforeVertex, int &afterVertex, double &sqrDist) const
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap ...
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void updateExpressionField(int index, const QString &exp)
Changes the expression used to define an expression based (virtual) field.
EditResult
Result of an edit operation.
const QgsVectorLayer * layer
Layer where the snap occurred.
void setAttributeTableConfig(const QgsAttributeTableConfig &attributeTableConfig)
Set the attribute table configuration object.
void layerModified()
This signal is emitted when modifications has been done on layer.
Q_DECL_DEPRECATED void drawLabels(QgsRenderContext &rendererContext) override
Draws the layer labels using the old labeling engine.
QString attributeDisplayName(int attributeIndex) const
Convenience function that returns the attribute alias if defined or the field name else...
int beforeVertexNr
The index of the vertex before snappedVertex or -1 if no such vertex.
void createJoinCaches()
Caches joined attributes if required (and not already done)
virtual void exportSldStyle(QDomDocument &doc, QString &errorMsg)
Export the properties of this layer as SLD style in a QDomDocument.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
double x() const
Get the x value of the point.
int splitFeatures(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
void setInterruptionChecker(QgsInterruptionChecker *interruptionChecker)
Attach an object that can be queried regularly by the iterator to check if it must stopped...
Aggregate
Available aggregates to calculate.
QString attributeAlias(int attributeIndex) const
Returns the alias of an attribute name or a null string if there is no alias.
Used by QgsVectorLayer::countSymbolFeatures() to provide an interruption checker. ...
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
double height() const
Height of the rectangle.
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
QDomNode at(int index) const
const T value(const Key &key) const
A bundle of parameters controlling aggregate calculation.
QVariant defaultValue(int index, const QgsFeature &feature=QgsFeature(), QgsExpressionContext *context=nullptr) const
Returns the calculated default value for the specified field index.
virtual void saveStyleToDatabase(const QString &name, const QString &description, bool useAsDefault, const QString &uiFileContent, QString &msgError)
Save named and sld style of the layer to the style table in the db.
Q_DECL_DEPRECATED void enableLabels(bool on)
Set labels on.
void setThreshold(float threshold)
Sets the simplification threshold of the vector layer managed.
QgsRectangle boundingBoxOfSelected()
Returns the bounding box of the selected features.
bool saveStyle_t(const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause)
int listStyles_t(const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
QByteArray toUtf8() const