28 #include <QPainterPath>
30 #include <QProgressDialog>
80 #include "diagram/qgsdiagram.h"
82 #ifdef TESTPROVIDERLIB
88 const QString& qmlStyle,
89 const QString& sldStyle,
90 const QString& styleName,
91 const QString& styleDescription,
92 const QString& uiFileContent,
106 QStringList &descriptions,
119 bool loadDefaultStyleFlag )
120 :
QgsMapLayer( VectorLayer, baseName, vectorLayerPath )
121 , mUpdateThreshold( 0 )
122 , mDataProvider( NULL )
123 , mProviderKey( providerKey )
125 , mRendererV2( NULL )
128 , mLabelFontNotFoundNotified( false )
129 , mFeatureBlendMode( QPainter::CompositionMode_SourceOver )
130 , mLayerTransparency( 0 )
131 , mVertexMarkerOnlyForSelection( false )
132 , mFeatureFormSuppress( SuppressDefault )
136 , mDiagramRenderer( 0 )
137 , mDiagramLayerSettings( 0 )
138 , mValidExtent( false )
139 , mLazyExtent( true )
140 , mSymbolFeatureCounted( false )
141 , mCurrentRendererContext( 0 )
158 bool defaultLoadedFlag =
false;
159 if ( loadDefaultStyleFlag )
265 QString idxName =
"";
268 if ( !fldName.isEmpty() )
275 int fieldsSize = fields.
size();
277 for (
int idx = 0; idx < fields.
count(); ++idx )
279 QString fldName = fields[idx].name();
280 QgsDebugMsg(
"Checking field " + fldName +
" of " + QString::number( fieldsSize ) +
" total" );
286 if ( fldName.indexOf(
"name", 0, Qt::CaseInsensitive ) > -1 )
288 if ( idxName.isEmpty() )
293 if ( fldName.indexOf(
"descrip", 0, Qt::CaseInsensitive ) > -1 )
295 if ( idxName.isEmpty() )
300 if ( fldName.indexOf(
"id", 0, Qt::CaseInsensitive ) > -1 )
302 if ( idxId.isEmpty() )
310 if ( fieldsSize == 0 )
313 if ( idxName.length() > 0 )
319 if ( idxId.length() > 0 )
351 attributes.append( attrNum );
359 QgsDebugMsg(
"Selecting features based on view extent" );
368 .setFilterRect( rendererContext.
extent() )
369 .setSubsetOfAttributes( attributes ) );
393 QgsDebugMsg( QString(
"Total features processed %1" ).arg( featureCount ) );
412 bool vertexMarkerOnlyForSelection = settings.value(
"/qgis/digitizing/marker_only_for_selected",
false ).toBool();
426 #ifndef Q_WS_MAC //MH: disable this on Mac for now to avoid problems with resizing
435 qApp->processEvents();
437 else if ( featureCount % 1000 == 0 )
440 qApp->processEvents();
453 bool drawMarker = (
mEditBuffer && ( !vertexMarkerOnlyForSelection || sel ) );
480 QgsDebugMsg( QString(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
481 .arg( fet.
id() ).arg( cse.
what() ) );
493 QgsDebugMsg( QString(
"Total features processed %1" ).arg( featureCount ) );
502 QHash< QgsSymbolV2*, QList<QgsFeature> > features;
505 bool vertexMarkerOnlyForSelection = settings.value(
"/qgis/digitizing/marker_only_for_selected",
false ).toBool();
532 if ( featureCount % 1000 == 0 )
534 qApp->processEvents();
543 if ( !features.contains( sym ) )
545 features.insert( sym, QList<QgsFeature>() );
547 features[sym].append( fet );
575 for (
int i = 0; i < symbols.count(); i++ )
581 if ( level < 0 || level >= 1000 )
584 while ( level >= levels.count() )
586 levels[level].append( item );
591 for (
int l = 0; l < levels.count(); l++ )
594 for (
int i = 0; i < level.count(); i++ )
597 if ( !features.contains( item.
symbol() ) )
602 int layer = item.
layer();
603 QList<QgsFeature>& lst = features[item.
symbol()];
604 QList<QgsFeature>::iterator fit;
608 for ( fit = lst.begin(); fit != lst.end(); ++fit )
616 if ( featureCount % 1000 == 0 )
618 qApp->processEvents();
623 bool drawMarker = (
mEditBuffer && ( !vertexMarkerOnlyForSelection || sel ) );
632 QgsDebugMsg( QString(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
633 .arg( fet.
id() ).arg( cse.
what() ) );
691 attributes.append( attrNum );
692 QgsDebugMsg(
"attrs: " + attrName +
" - " + QString::number( attrNum ) );
695 bool labeling =
false;
704 .setSubsetOfAttributes( attributes );
709 QPainter* p = rendererContext.
painter();
710 double dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;
728 QgsDebugMsg( QString(
"Simplify - SourceTransformRect=%1" ).arg( sourceRect.
toString( 16 ) ) );
729 QgsDebugMsg( QString(
"Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ) );
731 if ( !sourceRect.
isEmpty() && sourceRect.
isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
735 QgsPoint minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
736 QgsPoint maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
738 double sourceHypothenuse = sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
739 double targetHypothenuse = sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
741 QgsDebugMsg( QString(
"Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ) );
742 QgsDebugMsg( QString(
"Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ) );
744 if ( targetHypothenuse != 0 )
745 map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
776 p.setPen( QColor( 50, 100, 120, 200 ) );
777 p.setBrush( QColor( 200, 200, 210, 120 ) );
778 p.drawEllipse( x - m, y - m, m * 2 + 1, m * 2 + 1 );
782 p.setPen( QColor( 255, 0, 0 ) );
783 p.drawLine( x - m, y + m, x + m, y - m );
784 p.drawLine( x - m, y - m, x + m, y + m );
827 .setFilterRect( rect )
839 if ( !addToSelection )
852 if ( intersectingIds.count() > 0 )
854 QgsDebugMsg(
"Trying to select and deselect the same item at the same time. Unsure what to do. Selecting dubious items." );
900 .setFilterRect( rect )
912 deselectIds << fet.
id();
916 selectIds << fet.
id();
995 QgsDebugMsg( QString(
"Data Provider Geometry type is not recognised, is %1" ).arg( type ) );
1007 QgsDebugMsg(
"WARNING: This code should never be reached. Problems may occur..." );
1039 .setFilterFid( fid )
1067 if ( retval.
width() == 0.0 || retval.
height() == 0.0 )
1076 retval.
set( -1.0, -1.0, 1.0, 1.0 );
1117 QgsLegendSymbolList::const_iterator symbolIt = symbolList.constBegin();
1119 for ( ; symbolIt != symbolList.constEnd(); ++symbolIt )
1125 QProgressDialog progressDialog(
tr(
"Updating feature count for layer %1" ).arg(
name() ),
tr(
"Abort" ), 0, nFeatures );
1126 progressDialog.setWindowModality( Qt::WindowModal );
1127 int featuresCounted = 0;
1140 for ( QgsSymbolV2List::iterator symbolIt = featureSymbolList.begin(); symbolIt != featureSymbolList.end(); ++symbolIt )
1148 if ( featuresCounted % 50 == 0 )
1150 if ( featuresCounted > nFeatures )
1152 progressDialog.setMaximum( 0 );
1154 progressDialog.setValue( featuresCounted );
1155 if ( progressDialog.wasCanceled() )
1165 progressDialog.setValue( nFeatures );
1226 if ( it->geometry() )
1300 if ( maximumSimplificationScale > 1 && renderContext.
rendererScale() <= maximumSimplificationScale )
1319 Q_UNUSED( alsoUpdateExtent );
1343 QgsDebugMsg( QString(
"feature %1 could not be retrieved" ).arg( f.
id() ) );
1351 QgsDebugMsg( QString(
"geometry of feature %1 could not be changed." ).arg( f.
id() ) );
1359 for (
int attr = 0; attr < fa.count(); ++attr )
1361 if ( fa[attr] != ca[attr] )
1365 QgsDebugMsg( QString(
"attribute %1 of feature %2 could not be changed." ).arg( attr ).arg( f.
id() ) );
1381 return utils.
insertVertex( x, y, atFeatureId, beforeVertex );
1391 return utils.
moveVertex( x, y, atFeatureId, atVertex );
1481 return utils.
splitParts( splitLine, topologicalEditing );
1490 return utils.
splitFeatures( splitLine, topologicalEditing );
1498 int returnValue = 0;
1511 .setFilterRect( geomBBox )
1518 if ( ignoreFeatures.contains( f.
id() ) )
1625 QDomNode pkeyNode = layer_node.namedItem(
"provider" );
1627 if ( pkeyNode.isNull() )
1633 QDomElement pkeyElt = pkeyNode.toElement();
1657 QDomElement pkeyElem = pkeyNode.toElement();
1658 if ( !pkeyElem.isNull() )
1660 QString encodingString = pkeyElem.attribute(
"encoding" );
1661 if ( !encodingString.isEmpty() )
1677 QDomNode prevExpNode = layer_node.namedItem(
"previewExpression" );
1679 if ( prevExpNode.isNull() )
1685 QDomElement prevExpElem = prevExpNode.toElement();
1715 QgsDebugMsg(
"Instantiated the data provider plugin" );
1739 QRegExp reg(
"\"[^\"]+\"\\.\"([^\"]+)\"( \\([^)]+\\))?" );
1740 if ( reg.indexIn(
name() ) >= 0 )
1742 QStringList stuff = reg.capturedTexts();
1743 QString lName = stuff[1];
1747 QMap<QString, QgsMapLayer*>::const_iterator it;
1748 for ( it = layers.constBegin(); it != layers.constEnd() && ( *it )->name() != lName; ++it )
1751 if ( it != layers.constEnd() && stuff.size() > 2 )
1753 lName +=
"." + stuff[2].mid( 2, stuff[2].length() - 3 );
1756 if ( !lName.isEmpty() )
1770 else if ( provider ==
"ogr" )
1803 QDomDocument & document )
1807 QDomElement mapLayerNode = layer_node.toElement();
1809 if ( mapLayerNode.isNull() || (
"maplayer" != mapLayerNode.nodeName() ) )
1815 mapLayerNode.setAttribute(
"type",
"vector" );
1823 QDomElement provider = document.createElement(
"provider" );
1825 QDomText providerText = document.createTextNode(
providerType() );
1826 provider.appendChild( providerText );
1827 layer_node.appendChild( provider );
1831 QDomElement prevExpElem = document.createElement(
"previewExpression" );
1833 prevExpElem.appendChild( prevExpText );
1834 layer_node.appendChild( prevExpElem );
1846 Q_UNUSED( errorMessage );
1851 if ( !rendererElement.isNull() )
1869 QDomNode displayFieldNode = node.namedItem(
"displayfield" );
1870 if ( !displayFieldNode.isNull() )
1872 QDomElement e = displayFieldNode.toElement();
1877 QDomNode blendModeNode = node.namedItem(
"blendMode" );
1878 if ( !blendModeNode.isNull() )
1880 QDomElement e = blendModeNode.toElement();
1885 QDomNode featureBlendModeNode = node.namedItem(
"featureBlendMode" );
1886 if ( !featureBlendModeNode.isNull() )
1888 QDomElement e = featureBlendModeNode.toElement();
1893 QDomNode layerTransparencyNode = node.namedItem(
"layerTransparency" );
1894 if ( !layerTransparencyNode.isNull() )
1896 QDomElement e = layerTransparencyNode.toElement();
1901 QDomElement e = node.toElement();
1919 QDomNode labelnode = node.namedItem(
"label" );
1920 QDomElement element = labelnode.toElement();
1922 if ( hasLabelsEnabled < 1 )
1931 QDomNode labelattributesnode = node.namedItem(
"labelattributes" );
1933 if ( !labelattributesnode.isNull() &&
mLabel )
1941 QDomElement singleCatDiagramElem = node.firstChildElement(
"SingleCategoryDiagramRenderer" );
1942 if ( !singleCatDiagramElem.isNull() )
1947 QDomElement linearDiagramElem = node.firstChildElement(
"LinearlyInterpolatedDiagramRenderer" );
1948 if ( !linearDiagramElem.isNull() )
1956 QDomElement diagramSettingsElem = node.firstChildElement(
"DiagramLayerSettings" );
1957 if ( !diagramSettingsElem.isNull() )
1969 QDomNode editTypesNode = node.namedItem(
"edittypes" );
1970 if ( !editTypesNode.isNull() )
1972 QDomNodeList editTypeNodes = editTypesNode.childNodes();
1974 for (
int i = 0; i < editTypeNodes.size(); i++ )
1976 QDomNode editTypeNode = editTypeNodes.at( i );
1977 QDomElement editTypeElement = editTypeNode.toElement();
1979 QString
name = editTypeElement.attribute(
"name" );
1986 int editable = editTypeElement.attribute(
"editable" ,
"1" ).toInt();
1989 int labelOnTop = editTypeElement.attribute(
"labelontop" ,
"0" ).toInt();
1995 if ( editTypeNode.hasChildNodes() )
1997 mValueMaps.insert( name, QMap<QString, QVariant>() );
1999 QDomNodeList valueMapNodes = editTypeNode.childNodes();
2000 for (
int j = 0; j < valueMapNodes.size(); j++ )
2002 QDomElement value = valueMapNodes.at( j ).toElement();
2003 mValueMaps[
name ].insert( value.attribute(
"key" ), value.attribute(
"value" ) );
2012 QVariant
min = editTypeElement.attribute(
"min" );
2013 QVariant
max = editTypeElement.attribute(
"max" );
2014 QVariant step = editTypeElement.attribute(
"step" );
2021 mCheckedStates[
name ] = QPair<QString, QString>( editTypeElement.attribute(
"checked" ), editTypeElement.attribute(
"unchecked" ) );
2026 QString
id = editTypeElement.attribute(
"layer" );
2027 QString key = editTypeElement.attribute(
"key" );
2028 QString value = editTypeElement.attribute(
"value" );
2029 bool allowNull = editTypeElement.attribute(
"allowNull" ) ==
"true";
2030 bool orderByValue = editTypeElement.attribute(
"orderByValue" ) ==
"true";
2031 bool allowMulti = editTypeElement.attribute(
"allowMulti",
"false" ) ==
"true";
2033 QString filterExpression;
2034 if ( editTypeElement.hasAttribute(
"filterAttributeColumn" ) &&
2035 editTypeElement.hasAttribute(
"filterAttributeValue" ) )
2037 filterExpression = QString(
"\"%1\"='%2'" )
2038 .arg( editTypeElement.attribute(
"filterAttributeColumn" ) )
2039 .arg( editTypeElement.attribute(
"filterAttributeValue" ) );
2043 filterExpression = editTypeElement.attribute(
"filterExpression", QString::null );
2056 mWidgetSize[
name ] = QSize( editTypeElement.attribute(
"widgetWidth" ).toInt(), editTypeElement.attribute(
"widgetHeight" ).toInt() );
2076 QDomNode editFormNode = node.namedItem(
"editform" );
2077 if ( !editFormNode.isNull() )
2079 QDomElement e = editFormNode.toElement();
2083 QDomNode editFormInitNode = node.namedItem(
"editforminit" );
2084 if ( !editFormInitNode.isNull() )
2089 QDomNode fFSuppNode = node.namedItem(
"featformsuppress" );
2090 if ( fFSuppNode.isNull() )
2096 QDomElement e = fFSuppNode.toElement();
2100 QDomNode annotationFormNode = node.namedItem(
"annotationform" );
2101 if ( !annotationFormNode.isNull() )
2103 QDomElement e = annotationFormNode.toElement();
2108 QDomNode aliasesNode = node.namedItem(
"aliases" );
2109 if ( !aliasesNode.isNull() )
2111 QDomElement aliasElem;
2114 QDomNodeList aliasNodeList = aliasesNode.toElement().elementsByTagName(
"alias" );
2115 for (
int i = 0; i < aliasNodeList.size(); ++i )
2117 aliasElem = aliasNodeList.at( i ).toElement();
2120 if ( aliasElem.hasAttribute(
"field" ) )
2122 field = aliasElem.attribute(
"field" );
2126 int index = aliasElem.attribute(
"index" ).toInt();
2137 QDomNode editorLayoutNode = node.namedItem(
"editorlayout" );
2138 if ( editorLayoutNode.isNull() )
2144 if ( editorLayoutNode.toElement().text() ==
"uifilelayout" )
2148 else if ( editorLayoutNode.toElement().text() ==
"tablayout" )
2160 QDomNode excludeWMSNode = node.namedItem(
"excludeAttributesWMS" );
2161 if ( !excludeWMSNode.isNull() )
2163 QDomNodeList attributeNodeList = excludeWMSNode.toElement().elementsByTagName(
"attribute" );
2164 for (
int i = 0; i < attributeNodeList.size(); ++i )
2171 QDomNode excludeWFSNode = node.namedItem(
"excludeAttributesWFS" );
2172 if ( !excludeWFSNode.isNull() )
2174 QDomNodeList attributeNodeList = excludeWFSNode.toElement().elementsByTagName(
"attribute" );
2175 for (
int i = 0; i < attributeNodeList.size(); ++i )
2183 QDomNode attributeEditorFormNode = node.namedItem(
"attributeEditorForm" );
2184 QDomNodeList attributeEditorFormNodeList = attributeEditorFormNode.toElement().childNodes();
2186 for (
int i = 0; i < attributeEditorFormNodeList.size(); i++ )
2188 QDomElement elem = attributeEditorFormNodeList.at( i ).toElement();
2201 if ( elem.tagName() ==
"attributeEditorContainer" )
2205 QDomNodeList childNodeList = elem.childNodes();
2207 for (
int i = 0; i < childNodeList.size(); i++ )
2209 QDomElement childElem = childNodeList.at( i ).toElement();
2215 newElement = container;
2217 else if ( elem.tagName() ==
"attributeEditorField" )
2219 QString
name = elem.attribute(
"name" );
2223 else if ( elem.tagName() ==
"attributeEditorRelation" )
2227 QString
name = elem.attribute(
"name" );
2235 Q_UNUSED( errorMessage );
2236 QDomElement mapLayerNode = node.toElement();
2241 node.appendChild( rendererElement );
2247 mapLayerNode.setAttribute(
"minLabelScale", QString::number(
mLabel->
minScale() ) );
2248 mapLayerNode.setAttribute(
"maxLabelScale", QString::number(
mLabel->
maxScale() ) );
2261 QDomElement blendModeElem = doc.createElement(
"blendMode" );
2263 blendModeElem.appendChild( blendModeText );
2264 node.appendChild( blendModeElem );
2267 QDomElement featureBlendModeElem = doc.createElement(
"featureBlendMode" );
2269 featureBlendModeElem.appendChild( featureBlendModeText );
2270 node.appendChild( featureBlendModeElem );
2273 QDomElement layerTransparencyElem = doc.createElement(
"layerTransparency" );
2274 QDomText layerTransparencyText = doc.createTextNode( QString::number(
layerTransparency() ) );
2275 layerTransparencyElem.appendChild( layerTransparencyText );
2276 node.appendChild( layerTransparencyElem );
2279 QDomElement dField = doc.createElement(
"displayfield" );
2280 QDomText dFieldText = doc.createTextNode(
displayField() );
2281 dField.appendChild( dFieldText );
2282 node.appendChild( dField );
2285 QDomElement labelElem = doc.createElement(
"label" );
2286 QDomText labelText = doc.createTextNode(
"" );
2290 labelText.setData(
"1" );
2294 labelText.setData(
"0" );
2296 labelElem.appendChild( labelText );
2298 node.appendChild( labelElem );
2305 if ( fieldname !=
"" )
2307 dField = doc.createElement(
"labelfield" );
2308 dFieldText = doc.createTextNode( fieldname );
2309 dField.appendChild( dFieldText );
2310 node.appendChild( dField );
2327 QDomElement editTypesElement = doc.createElement(
"edittypes" );
2329 for ( QMap<QString, EditType>::const_iterator it =
mEditTypes.begin(); it !=
mEditTypes.end(); ++it )
2331 QDomElement editTypeElement = doc.createElement(
"edittype" );
2332 editTypeElement.setAttribute(
"name", it.key() );
2333 editTypeElement.setAttribute(
"type", it.value() );
2334 editTypeElement.setAttribute(
"editable",
mFieldEditables[ it.key()] ? 1 : 0 );
2335 editTypeElement.setAttribute(
"labelontop",
mLabelOnTop[ it.key()] ? 1 : 0 );
2342 const QMap<QString, QVariant> &map =
mValueMaps[ it.key()];
2344 for ( QMap<QString, QVariant>::const_iterator vmit = map.begin(); vmit != map.end(); ++vmit )
2346 QDomElement value = doc.createElement(
"valuepair" );
2347 value.setAttribute(
"key", vmit.key() );
2348 value.setAttribute(
"value", vmit.value().toString() );
2349 editTypeElement.appendChild( value );
2357 if (
mRanges.contains( it.key() ) )
2359 editTypeElement.setAttribute(
"min",
mRanges[ it.key()].mMin.toString() );
2360 editTypeElement.setAttribute(
"max",
mRanges[ it.key()].mMax.toString() );
2361 editTypeElement.setAttribute(
"step",
mRanges[ it.key()].mStep.toString() );
2368 editTypeElement.setAttribute(
"checked",
mCheckedStates[ it.key()].first );
2369 editTypeElement.setAttribute(
"unchecked",
mCheckedStates[ it.key()].second );
2377 editTypeElement.setAttribute(
"layer", data.
mLayer );
2378 editTypeElement.setAttribute(
"key", data.
mKey );
2379 editTypeElement.setAttribute(
"value", data.
mValue );
2380 editTypeElement.setAttribute(
"allowNull", data.
mAllowNull ?
"true" :
"false" );
2381 editTypeElement.setAttribute(
"orderByValue", data.
mOrderByValue ?
"true" :
"false" );
2382 editTypeElement.setAttribute(
"allowMulti", data.
mAllowMulti ?
"true" :
"false" );
2389 editTypeElement.setAttribute(
"dateFormat",
mDateFormats[ it.key()] );
2394 editTypeElement.setAttribute(
"widgetWidth",
mWidgetSize[ it.key()].width() );
2395 editTypeElement.setAttribute(
"widgetHeight",
mWidgetSize[ it.key()].height() );
2413 editTypesElement.appendChild( editTypeElement );
2416 node.appendChild( editTypesElement );
2419 QDomElement efField = doc.createElement(
"editform" );
2421 efField.appendChild( efText );
2422 node.appendChild( efField );
2424 QDomElement efiField = doc.createElement(
"editforminit" );
2426 efiField.appendChild( efiText );
2427 node.appendChild( efiField );
2429 QDomElement fFSuppElem = doc.createElement(
"featformsuppress" );
2431 fFSuppElem.appendChild( fFSuppText );
2432 node.appendChild( fFSuppElem );
2434 QDomElement afField = doc.createElement(
"annotationform" );
2436 afField.appendChild( afText );
2437 node.appendChild( afField );
2440 QDomElement editorLayoutElem = doc.createElement(
"editorlayout" );
2444 editorLayoutElem.appendChild( doc.createTextNode(
"uifilelayout" ) );
2448 editorLayoutElem.appendChild( doc.createTextNode(
"tablayout" ) );
2453 editorLayoutElem.appendChild( doc.createTextNode(
"generatedlayout" ) );
2457 node.appendChild( editorLayoutElem );
2462 QDomElement aliasElem = doc.createElement(
"aliases" );
2470 QDomElement aliasEntryElem = doc.createElement(
"alias" );
2471 aliasEntryElem.setAttribute(
"field", a_it.key() );
2472 aliasEntryElem.setAttribute(
"index", idx );
2473 aliasEntryElem.setAttribute(
"name", a_it.value() );
2474 aliasElem.appendChild( aliasEntryElem );
2476 node.appendChild( aliasElem );
2480 QDomElement excludeWMSElem = doc.createElement(
"excludeAttributesWMS" );
2484 QDomElement attrElem = doc.createElement(
"attribute" );
2485 QDomText attrText = doc.createTextNode( *attWMSIt );
2486 attrElem.appendChild( attrText );
2487 excludeWMSElem.appendChild( attrElem );
2489 node.appendChild( excludeWMSElem );
2492 QDomElement excludeWFSElem = doc.createElement(
"excludeAttributesWFS" );
2496 QDomElement attrElem = doc.createElement(
"attribute" );
2497 QDomText attrText = doc.createTextNode( *attWFSIt );
2498 attrElem.appendChild( attrText );
2499 excludeWFSElem.appendChild( attrElem );
2501 node.appendChild( excludeWFSElem );
2506 QDomElement tabsElem = doc.createElement(
"attributeEditorForm" );
2510 QDomElement attributeEditorWidgetElem = ( *it )->toDomElement( doc );
2511 tabsElem.appendChild( attributeEditorWidgetElem );
2514 node.appendChild( tabsElem );
2526 QDomElement nameElem = node.firstChildElement(
"Name" );
2527 if ( nameElem.isNull() )
2529 errorMessage =
"Warning: Name element not found within NamedLayer while it's required.";
2549 Q_UNUSED( errorMessage );
2552 QDomElement nameNode = doc.createElement(
"se:Name" );
2553 nameNode.appendChild( doc.createTextNode(
name() ) );
2554 node.appendChild( nameNode );
2579 Q_UNUSED( emitSignal );
2627 if ( attributeIndex < 0 || attributeIndex >=
pendingFields().count() )
2638 if ( displayName.isEmpty() )
2641 if ( attributeIndex >= 0 && attributeIndex < fields.
count() )
2643 displayName = fields[attributeIndex].name();
2659 bool deleted =
false;
2662 attrs = attrs.toSet().toList();
2664 qSort( attrs.begin(), attrs.end(), qGreater<int>() );
2666 foreach (
int attr, attrs )
2713 pkAttributesList << i;
2716 return pkAttributesList;
2866 for ( QgsFeatureList::iterator iter = features.begin(); iter != features.end(); ++iter )
2883 QMultiMap<double, QgsSnappingResult> snapResults;
2891 if ( snapResults.size() < 1 )
2896 QMultiMap<double, QgsSnappingResult>::const_iterator snap_it = snapResults.constBegin();
2897 point.
setX( snap_it.value().snappedVertex.x() );
2898 point.
setY( snap_it.value().snappedVertex.y() );
2904 QMultiMap<double, QgsSnappingResult>& snappingResults,
2915 QList<QgsFeature> featureList;
2916 QgsRectangle searchRect( startPoint.
x() - snappingTolerance, startPoint.
y() - snappingTolerance,
2917 startPoint.
x() + snappingTolerance, startPoint.
y() + snappingTolerance );
2918 double sqrSnappingTolerance = snappingTolerance * snappingTolerance;
2926 for ( QgsGeometryMap::iterator it = cachedGeometries.begin(); it != cachedGeometries.end() ; ++it )
2931 snapToGeometry( startPoint, it.key(), g, sqrSnappingTolerance, snappingResults, snap_to );
2941 .setFilterRect( searchRect )
2952 return n == 0 ? 2 : 0;
2958 double sqrSnappingTolerance,
2959 QMultiMap<double, QgsSnappingResult>& snappingResults,
2967 int atVertex, beforeVertex, afterVertex;
2968 double sqrDistVertexSnap, sqrDistSegmentSnap;
2975 snappedPoint = geom->
closestVertex( startPoint, atVertex, beforeVertex, afterVertex, sqrDistVertexSnap );
2976 if ( sqrDistVertexSnap < sqrSnappingTolerance )
2981 if ( beforeVertex != -1 )
2986 if ( afterVertex != -1 )
2991 snappingResultVertex.
layer =
this;
2992 snappingResults.insert( sqrt( sqrDistVertexSnap ), snappingResultVertex );
3000 sqrDistSegmentSnap = geom->
closestSegmentWithContext( startPoint, snappedPoint, afterVertex, NULL,
crs().geographicFlag() ? 1e-12 : 1e-8 );
3002 if ( sqrDistSegmentSnap < sqrSnappingTolerance )
3011 snappingResultSegment.
layer =
this;
3012 snappingResults.insert( sqrt( sqrDistSegmentSnap ), snappingResultSegment );
3028 QString markerTypeString = settings.value(
"/qgis/digitizing/marker_style",
"Cross" ).toString();
3029 if ( markerTypeString ==
"Cross" )
3033 else if ( markerTypeString ==
"SemiTransparentCircle" )
3046 return settings.value(
"/qgis/digitizing/marker_size", 3 ).toInt();
3053 QgsDebugMsg(
"----- Computing Coordinate System" );
3124 if ( idx >= 0 && idx < fields.
count() )
3178 static QMap< QString, QVariant > invalidMap;
3179 if ( idx < 0 || idx >= fields.
count() )
3181 QgsDebugMsg( QString(
"field %1 not found" ).arg( idx ) );
3184 QString fieldName = fields[idx].name();
3187 mValueMaps[fieldName] = QMap<QString, QVariant>();
3198 if ( idx < 0 || idx >= fields.
count() )
3200 QgsDebugMsg( QString(
"field %1 not found" ).arg( idx ) );
3201 return invalidRange;
3203 QString fieldName = fields[idx].name();
3205 if ( !
mRanges.contains( fieldName ) )
3215 QString fieldName = fields[idx].name();
3227 QString fieldName = fields[idx].name();
3238 if ( idx >= 0 && idx < fields.
count() )
3251 if ( idx >= 0 && idx < fields.
count() )
3252 return mLabelOnTop.value( fields[idx].name(), false );
3260 if ( idx >= 0 && idx < fields.
count() )
3267 if ( idx >= 0 && idx < fields.
count() )
3317 if ( idx >= 0 && idx < fields.
count() )
3327 return QPair<QString, QString>(
"1",
"0" );
3334 for (
int idx = 0; idx < theFields.
count(); ++idx )
3336 if ( QString::compare( theFields[idx].
name(), fieldName, Qt::CaseInsensitive ) == 0 )
3395 uniqueValues.clear();
3409 int sourceLayerIndex;
3432 .setSubsetOfAttributes( attList ) );
3435 QVariant currentValue;
3436 QHash<QString, QVariant> val;
3440 val.insert( currentValue.toString(), currentValue );
3441 if ( limit >= 0 && val.size() >= limit )
3447 uniqueValues = val.values();
3451 Q_ASSERT_X(
false,
"QgsVectorLayer::uniqueValues()",
"Unknown source of the field!" );
3469 int sourceLayerIndex;
3492 .setSubsetOfAttributes( attList ) );
3496 double currentValue = 0;
3499 currentValue = f.
attribute( index ).toDouble();
3500 if ( currentValue < minimumValue )
3502 minimumValue = currentValue;
3505 return QVariant( minimumValue );
3508 Q_ASSERT_X(
false,
"QgsVectorLayer::minimumValue()",
"Unknown source of the field!" );
3527 int sourceLayerIndex;
3553 .setSubsetOfAttributes( attList ) );
3557 double currentValue = 0;
3560 currentValue = f.
attribute( index ).toDouble();
3561 if ( currentValue > maximumValue )
3563 maximumValue = currentValue;
3566 return QVariant( maximumValue );
3569 Q_ASSERT_X(
false,
"QgsVectorLayer::maximumValue()",
"Unknown source of the field!" );
3614 QSet<int> attrIndex;
3617 QSet<int>::const_iterator attIt = attrIndex.constBegin();
3618 for ( ; attIt != attrIndex.constEnd(); ++attIt )
3620 if ( !attributes.contains( *attIt ) )
3622 attributes << *attIt;
3636 .setFilterRect( rendererContext.
extent() )
3641 int nFeatsToLabel = 0;
3664 QList<QString>::const_iterator attIt = att.constBegin();
3665 for ( ; attIt != att.constEnd(); ++attIt )
3669 QStringList::const_iterator columnsIterator = columns.constBegin();
3670 for ( ; columnsIterator != columns.constEnd(); ++columnsIterator )
3673 if ( !attributes.contains( index ) )
3675 attributes <<
index;
3681 if ( mLinearlyInterpolatedDiagramRenderer != NULL )
3687 QStringList::const_iterator columnsIterator = columns.constBegin();
3688 for ( ; columnsIterator != columns.constEnd(); ++columnsIterator )
3691 if ( !attributes.contains( index ) )
3693 attributes <<
index;
3720 QDomElement element = node.toElement();
3721 if ( element.isNull() )
3724 QDomElement userStyleElem = element.firstChildElement(
"UserStyle" );
3725 if ( userStyleElem.isNull() )
3727 QgsDebugMsg(
"Info: UserStyle element not found." );
3731 QDomElement featureTypeStyleElem = userStyleElem.firstChildElement(
"FeatureTypeStyle" );
3732 if ( featureTypeStyleElem.isNull() )
3734 QgsDebugMsg(
"Info: FeatureTypeStyle element not found." );
3739 QDomElement ruleElem = featureTypeStyleElem.lastChildElement(
"Rule" );
3740 if ( ruleElem.isNull() )
3747 QDomElement textSymbolizerElem = ruleElem.lastChildElement(
"TextSymbolizer" );
3748 if ( textSymbolizerElem.isNull() )
3750 QgsDebugMsg(
"Info: TextSymbolizer element not found." );
3756 QDomElement labelElem = textSymbolizerElem.firstChildElement(
"Label" );
3757 if ( !labelElem.isNull() )
3759 QDomElement propertyNameElem = labelElem.firstChildElement(
"PropertyName" );
3760 if ( !propertyNameElem.isNull() )
3791 QString labelAttribute = propertyNameElem.text();
3796 if ( fieldIndex == -1 )
3812 QgsDebugMsg(
"Info: PropertyName element not found." );
3823 QDomElement fontElem = textSymbolizerElem.firstChildElement(
"Font" );
3824 if ( !fontElem.isNull() )
3828 QDomElement cssElem = fontElem.firstChildElement(
"CssParameter" );
3829 while ( !cssElem.isNull() )
3831 cssName = cssElem.attribute(
"name",
"not_found" );
3832 if ( cssName !=
"not_found" )
3834 elemText = cssElem.text();
3835 if ( cssName ==
"font-family" )
3839 else if ( cssName ==
"font-style" )
3841 setCustomProperty(
"labeling/fontItalic", ( elemText ==
"italic" ) || ( elemText ==
"Italic" ) );
3843 else if ( cssName ==
"font-size" )
3846 int fontSize = elemText.toInt( &ok );
3852 else if ( cssName ==
"font-weight" )
3854 setCustomProperty(
"labeling/fontBold", ( elemText ==
"bold" ) || ( elemText ==
"Bold" ) );
3856 else if ( cssName ==
"font-underline" )
3858 setCustomProperty(
"labeling/fontUnderline", ( elemText ==
"underline" ) || ( elemText ==
"Underline" ) );
3862 cssElem = cssElem.nextSiblingElement(
"CssParameter" );
3868 if ( textColor.isValid() )
3873 setCustomProperty(
"labeling/textTransp", 100 - (
int )( 100 * textColor.alphaF() ) );
3877 QDomElement haloElem = textSymbolizerElem.firstChildElement(
"Halo" );
3878 if ( !haloElem.isNull() )
3883 QDomElement radiusElem = haloElem.firstChildElement(
"Radius" );
3884 if ( !radiusElem.isNull() )
3887 double bufferSize = radiusElem.text().toDouble( &ok );
3895 if ( bufferColor.isValid() )
3900 setCustomProperty(
"labeling/bufferTransp", 100 - (
int )( 100 * bufferColor.alphaF() ) );
3905 QDomElement labelPlacementElem = textSymbolizerElem.firstChildElement(
"LabelPlacement" );
3906 if ( !labelPlacementElem.isNull() )
3909 QDomElement pointPlacementElem = labelPlacementElem.firstChildElement(
"PointPlacement" );
3910 if ( !pointPlacementElem.isNull() )
3914 QDomElement displacementElem = pointPlacementElem.firstChildElement(
"Displacement" );
3915 if ( !displacementElem.isNull() )
3917 QDomElement displacementXElem = displacementElem.firstChildElement(
"DisplacementX" );
3918 if ( !displacementXElem.isNull() )
3921 double xOffset = displacementXElem.text().toDouble( &ok );
3927 QDomElement displacementYElem = displacementElem.firstChildElement(
"DisplacementY" );
3928 if ( !displacementYElem.isNull() )
3931 double yOffset = displacementYElem.text().toDouble( &ok );
3939 QDomElement rotationElem = pointPlacementElem.firstChildElement(
"Rotation" );
3940 if ( !rotationElem.isNull() )
3943 double rotation = rotationElem.text().toDouble( &ok );
3962 QString myMetadata =
"<html><body>";
3966 myMetadata +=
"<p class=\"subheaderglossy\">";
3967 myMetadata +=
tr(
"General" );
3968 myMetadata +=
"</p>\n";
3973 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Layer comment" ) +
"</p>\n";
3974 myMetadata +=
"<p>";
3976 myMetadata +=
"</p>\n";
3980 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Storage type of this layer" ) +
"</p>\n";
3981 myMetadata +=
"<p>";
3983 myMetadata +=
"</p>\n";
3988 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Description of this provider" ) +
"</p>\n";
3989 myMetadata +=
"<p>";
3991 myMetadata +=
"</p>\n";
3995 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Source for this layer" ) +
"</p>\n";
3996 myMetadata +=
"<p>";
3998 myMetadata +=
"</p>\n";
4012 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Geometry type of the features in this layer" ) +
"</p>\n";
4013 myMetadata +=
"<p>";
4014 myMetadata += typeString;
4015 myMetadata +=
"</p>\n";
4019 if ( !pkAttrList.isEmpty() )
4021 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Primary key attributes" ) +
"</p>\n";
4022 myMetadata +=
"<p>";
4023 foreach (
int idx, pkAttrList )
4027 myMetadata +=
"</p>\n";
4032 myMetadata +=
"<p class=\"glossy\">" +
tr(
"The number of features in this layer" ) +
"</p>\n";
4033 myMetadata +=
"<p>";
4035 myMetadata +=
"</p>\n";
4037 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Editing capabilities of this layer" ) +
"</p>\n";
4038 myMetadata +=
"<p>";
4040 myMetadata +=
"</p>\n";
4045 myMetadata +=
"<p class=\"subheaderglossy\">";
4046 myMetadata +=
tr(
"Extents" );
4047 myMetadata +=
"</p>\n";
4050 myMetadata +=
"<p class=\"glossy\">" +
tr(
"In layer spatial reference system units" ) +
"</p>\n";
4051 myMetadata +=
"<p>";
4064 QString xMin, yMin, xMax, yMax;
4065 double changeoverValue = 99999;
4066 if ( qAbs( myExtent.
xMinimum() ) > changeoverValue )
4068 xMin = QString(
"%1" ).arg( myExtent.
xMinimum(), 0,
'f', 2 );
4072 xMin = QString(
"%1" ).arg( myExtent.
xMinimum() );
4074 if ( qAbs( myExtent.
yMinimum() ) > changeoverValue )
4076 yMin = QString(
"%1" ).arg( myExtent.
yMinimum(), 0,
'f', 2 );
4080 yMin = QString(
"%1" ).arg( myExtent.
yMinimum() );
4082 if ( qAbs( myExtent.
xMaximum() ) > changeoverValue )
4084 xMax = QString(
"%1" ).arg( myExtent.
xMaximum(), 0,
'f', 2 );
4088 xMax = QString(
"%1" ).arg( myExtent.
xMaximum() );
4090 if ( qAbs( myExtent.
yMaximum() ) > changeoverValue )
4092 yMax = QString(
"%1" ).arg( myExtent.
yMaximum(), 0,
'f', 2 );
4096 yMax = QString(
"%1" ).arg( myExtent.
yMaximum() );
4099 myMetadata +=
tr(
"xMin,yMin %1,%2 : xMax,yMax %3,%4" )
4100 .arg( xMin ).arg( yMin ).arg( xMax ).arg( yMax );
4104 myMetadata +=
tr(
"unknown extent" );
4107 myMetadata +=
"</p>\n";
4115 QgsRectangle myProjectedExtent = coordinateTransform->transformBoundingBox(
extent() );
4116 myMetadata +=
"<p class=\"glossy\">" +
tr(
"In project spatial reference system units" ) +
"</p>\n";
4117 myMetadata +=
"<p>";
4118 myMetadata +=
tr(
"xMin,yMin %1,%2 : xMax,yMax %3,%4" )
4119 .arg( myProjectedExtent.
xMinimum() )
4120 .arg( myProjectedExtent.
yMinimum() )
4121 .arg( myProjectedExtent.
xMaximum() )
4122 .arg( myProjectedExtent.
yMaximum() );
4123 myMetadata +=
"</p>\n";
4129 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Layer Spatial Reference System" ) +
"</p>\n";
4130 myMetadata +=
"<p>";
4131 myMetadata +=
crs().
toProj4().replace( QRegExp(
"\"" ),
" \"" );
4132 myMetadata +=
"</p>\n";
4140 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Project (Output) Spatial Reference System" ) +
"</p>\n";
4141 myMetadata +=
"<p>";
4142 myMetadata += coordinateTransform->destCRS().toProj4().replace( QRegExp(
"\"" ),
" \"" );
4143 myMetadata +=
"</p>\n";
4151 myMetadata +=
"<p class=\"glossy\">" +
tr(
"In project spatial reference system units" ) +
"</p>\n";
4152 myMetadata +=
"<p>";
4153 myMetadata +=
tr(
"(Invalid transformation of layer extents)" );
4154 myMetadata +=
"</p>\n";
4162 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Attribute field info" ) +
"</p>\n";
4163 myMetadata +=
"<p>";
4166 myMetadata +=
"<table width=\"100%\">";
4167 myMetadata +=
"<tr><th>";
4168 myMetadata +=
tr(
"Field" );
4169 myMetadata +=
"</th>";
4170 myMetadata +=
"<th>";
4171 myMetadata +=
tr(
"Type" );
4172 myMetadata +=
"</th>";
4173 myMetadata +=
"<th>";
4174 myMetadata +=
tr(
"Length" );
4175 myMetadata +=
"</th>";
4176 myMetadata +=
"<th>";
4177 myMetadata +=
tr(
"Precision" );
4178 myMetadata +=
"</th>";
4179 myMetadata +=
"<th>";
4180 myMetadata +=
tr(
"Comment" );
4181 myMetadata +=
"</th>";
4185 for ( QgsFieldMap::const_iterator it = myFields.begin(); it != myFields.end(); ++it )
4189 myMetadata +=
"<tr><td>";
4190 myMetadata += myField.
name();
4191 myMetadata +=
"</td>";
4192 myMetadata +=
"<td>";
4194 myMetadata +=
"</td>";
4195 myMetadata +=
"<td>";
4196 myMetadata += QString(
"%1" ).arg( myField.
length() );
4197 myMetadata +=
"</td>";
4198 myMetadata +=
"<td>";
4199 myMetadata += QString(
"%1" ).arg( myField.
precision() );
4200 myMetadata +=
"</td>";
4201 myMetadata +=
"<td>";
4202 myMetadata += QString(
"%1" ).arg( myField.
comment() );
4203 myMetadata +=
"</td></tr>";
4207 myMetadata +=
"</table>";
4210 myMetadata +=
"</body></html>";
4248 if ( idx < 0 || idx >= fields.
count() )
4250 QgsDebugMsg( QString(
"field %1 not found" ).arg( idx ) );
4253 QString fieldName = fields[idx].name();
4280 QDomElement elem = doc.createElement(
"attributeEditorContainer" );
4281 elem.setAttribute(
"name",
mName );
4297 QList<QgsAttributeEditorElement*> results;
4303 results.append( elem );
4318 QDomElement elem = doc.createElement(
"attributeEditorField" );
4319 elem.setAttribute(
"name",
mName );
4320 elem.setAttribute(
"index",
mIdx );
4335 if ( !listStylesExternalMethod )
4342 return listStylesExternalMethod(
mDataSource, ids, names, descriptions, msgError );
4356 if ( !getStyleByIdMethod )
4363 return getStyleByIdMethod(
mDataSource, styleId, msgError );
4368 bool useAsDefault, QString uiFileContent, QString &msgError )
4371 QString sldStyle, qmlStyle;
4381 if ( !saveStyleExternalMethod )
4388 QDomDocument qmlDocument, sldDocument;
4390 if ( !msgError.isNull() )
4394 qmlStyle = qmlDocument.toString();
4397 if ( !msgError.isNull() )
4401 sldStyle = sldDocument.toString();
4403 saveStyleExternalMethod(
mDataSource, qmlStyle, sldStyle, name,
4404 description, uiFileContent, useAsDefault, msgError );
4417 if ( !loadFromLocalDB && !dsUri.
database().isEmpty() )
4424 if ( loadStyleExternalMethod )
4426 QString qml, errorMsg;
4427 qml = loadStyleExternalMethod(
mDataSource, errorMsg );
4428 if ( !qml.isEmpty() )
4442 QDomDocument myDocument(
"qgis" );
4443 myDocument.setContent( namedStyle );
4445 QDomElement myRoot = myDocument.firstChildElement(
"qgis" );
4447 if ( myRoot.isNull() )
4449 errorMsg =
tr(
"Error: qgis element could not be found" );
4458 QDomNode transparencyNode = myRoot.namedItem(
"transparencyLevelInt" );
4459 if ( ! transparencyNode.isNull() )
4463 QDomElement myElement = transparencyNode.toElement();
4464 setTransparency( myElement.text().toInt() );
4474 QDomElement elem = doc.createElement(
"attributeEditorRelation" );
4475 elem.setAttribute(
"name",
mName );
QgsFeatureId id() const
Get the feature id for this feature.
bool deleteVertex(QgsFeatureId atFeatureId, int atVertex)
Deletes a vertex from a feature.
virtual int addDiagramLayer(QgsVectorLayer *layer, QgsDiagramLayerSettings *s)
adds a diagram layer to the labeling engine
virtual QString subsetString()
Get the string (typically sql) used to define a subset of the layer.
virtual QDomElement toDomElement(QDomDocument &doc) const
Class for parsing and evaluation of expressions (formerly called "search strings").
void updateFields()
Assembles mUpdatedFields considering provider fields, joined fields and added fields.
QMap< QString, QVariant > & valueMap(int idx)
access value map
const QString & name() const
Gets the name of the field.
EditorLayout mEditorLayout
Defines the default layout to use for the attribute editor (Drag and drop, UI File, Generated)
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
const QList< QgsVectorJoinInfo > & vectorJoins() const
int mWkbType
Geometry type as defined in enum WkbType (qgis.h)
Wrapper for iterator of features from vector data provider or vector layer.
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
bool isValid() const
Returns the validity of this relation.
void selectAll()
Select all the features.
bool intersects(const QgsRectangle &rect) const
returns true when rectangle intersects with other rectangle
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
#define RENDERER_TAG_NAME
void screenUpdateRequested()
The layer emits this signal when a screen update is requested.
virtual QString subsetString()
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
bool fieldEditable(int idx)
is edit widget editable
virtual QString getStyleFromDatabase(QString styleId, QString &msgError)
Will return the named style corresponding to style id provided.
virtual bool willRenderFeature(QgsFeature &feat)
return whether the renderer will render a feature or not.
void setRenderingStopped(bool stopped)
A rectangle specified with double values.
void setEditorWidgetV2Config(int attrIdx, const QMap< QString, QVariant > &config)
Base class for all map layer types.
QSet< QString > mExcludeAttributesWFS
Attributes which are not published in WFS.
QgsVectorLayer::FeatureFormSuppress mFeatureFormSuppress
Type of feature form suppression after feature creation.
bool init(QgsRelationManager *relManager)
Initializes the relation from the id.
void setDiagramLayerSettings(const QgsDiagramLayerSettings &s)
bool isEmpty() const
test if rectangle is empty
int insertSegmentVerticesForSnap(const QList< QgsSnappingResult > &snapResults)
Inserts vertices to the snapped segments.
field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
float threshold() const
Gets the simplification threshold of the vector layer managed.
void clearAttributeEditorWidgets()
Clears all the tabs for the attribute editor form.
QgsFeatureList selectedFeatures()
Get a copy of the user-selected features.
QgsVectorDataProvider * mDataProvider
Pointer to data provider derived from the abastract base class QgsDataProvider.
QgsMapLayer::LayerType type() const
Get the type of the layer.
bool addAttribute(const QgsField &field)
add an attribute field (but does not commit it) returns true if the field was added ...
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
QgsSymbolV2 * symbol() const
int makeDifference(QgsGeometry *other)
Changes this geometry such that it does not intersect the other geometry.
EditorLayout editorLayout()
get the active layout for the attribute editor for this layer (added in 1.9)
virtual void saveStyleToDatabase(QString name, QString description, bool useAsDefault, QString uiFileContent, QString &msgError)
Save named and sld style of the layer to the style table in the db.
void createJoinCaches()
Calls cacheJoinLayer() for all vector joins.
virtual void updateExtents()
Update the extents of the layer.
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith="")
Read custom properties from project file.
RangeData & range(int idx)
access range
QList< QgsSymbolV2 * > QgsSymbolV2List
void setCacheImage(QImage *thepImage)
Set the QImage used for caching render operations.
void removeJoin(const QString &joinLayerId)
Removes a vector layer join.
QString publicSource() const
void beforeRollBack()
Is emitted, before changes are rolled back.
bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it)
EditorLayout
The different types to layout the attribute editor.
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 setEditFormInit(QString function)
set python function for edit form initialization (added in 1.4)
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
QVariant maximumValue(int index)
Returns maximum value for an attribute column or invalid variant in case of error.
Renders the diagrams for all features with the same settings.
QString capabilitiesString() const
Returns the above in friendly format.
QColor selectionColor() const
Added in QGIS v2.0.
virtual QgsPalLayerSettings & layer(const QString &layerName)=0
returns PAL layer settings for a registered layer
Q_DECL_DEPRECATED int removePolygonIntersections(QgsGeometry *geom, QgsFeatureIds ignoreFeatures=QgsFeatureIds())
Changes the specified geometry such that it has no intersections with other polygon (or multipolygon)...
bool addFeature(QgsFeature &f)
Adds a feature.
virtual QString dump() const
for debugging
virtual QList< QString > diagramAttributes() const =0
Returns attribute indices needed for diagram rendering.
static QgsProviderRegistry * instance(QString pluginPath=QString::null)
means of accessing canonical single instance
field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
bool isFinite() const
Returns true if the rectangle has finite boundaries.
void layerTransparencyChanged(int layerTransparency)
Signal emitted when setLayerTransparency() is called.
double yMaximum() const
Get the y maximum value (top side of rectangle)
bool deleteFeature(QgsFeatureId fid)
delete a feature from the layer (but does not commit it)
The attribute value should not be changed in the attribute form.
virtual QgsCoordinateReferenceSystem crs()=0
QSet< QgsFeatureId > QgsFeatureIds
void uniqueValues(int index, QList< QVariant > &uniqueValues, int limit=-1)
Returns unique values for column.
QList< QgsFeature > QgsFeatureList
void drawLabels(QgsRenderContext &rendererContext)
Draws the layer labels using coordinate transformation.
The geometries can be simplified using the current map2pixel context state.
QgsDiagram * diagram() const
void beginEditCommand(QString text)
Create edit command for undo/redo operations.
QList< QgsAttributeEditorElement * > mAttributeEditorElements
Stores a list of attribute editor elements (Each holding a tree structure for a tab in the attribute ...
double rendererScale() const
void drawRendererV2(QgsFeatureIterator &fit, QgsRenderContext &rendererContext, bool labeling)
Draw layer with renderer V2.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
void setForceLocalOptimization(bool localOptimization)
Sets where the simplification executes, after fetch the geometries from provider, or when supported...
QgsFeatureRendererV2 * mRendererV2
Renderer object which holds the information about how to display the features.
void invertSelectionInRectangle(QgsRectangle &rect)
Invert selection of features found within the search rectangle (in layer's coordinates) ...
bool commitChanges()
Attempts to commit any changes to disk.
void setRendererV2(QgsFeatureRendererV2 *r)
Set renderer V2.
void deleteCachedGeometries()
Deletes the geometries in mCachedGeometries.
Storage and management of actions associated with Qgis layer attributes.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
virtual void setEncoding(const QString &e)
Set encoding used for accessing data from layer.
bool startEditing()
Make layer editable.
virtual void startRender(QgsRenderContext &context, const QgsVectorLayer *vlayer)
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
bool contains(const QgsRectangle &rect) const
return true when rectangle contains other rectangle
void setRendererScale(double scale)
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
VertexMarkerType
Editing vertex markers.
static QgsVectorLayer::VertexMarkerType currentVertexMarkerType()
Reads vertex marker type from settings.
double closestSegmentWithContext(const QgsPoint &point, QgsPoint &minDistPoint, int &afterVertex, double *leftOf=0, double epsilon=DEFAULT_SEGMENT_EPSILON)
Searches for the closest segment of geometry to the given point.
void select(QgsRectangle &rect, bool addToSelection)
Select features found within the search rectangle (in layer's coordinates)
friend class QgsVectorLayerFeatureIterator
QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const
Type of feature form pop-up suppression after feature creation (overrides app setting) ...
int precision() const
Gets the precision of the field.
void renderLabel(QgsRenderContext &renderContext, QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes=0)
render label
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, QString rule="")
return a list of item text / symbol
SimplifyHint
Simplification flags for fast rendering of features.
bool deleteAttributes(QList< int > attrs)
Deletes a list of attribute fields (but does not commit it)
void addAttributeAlias(int attIndex, QString aliasString)
Sets an alias (a display name) for attributes to display in dialogs.
static const char * vectorGeometryType(GeometryType type)
description strings for geometry types
QString mDisplayExpression
the preview expression used to generate a human readable preview string for features ...
QGis::GeometryType type()
Returns type of the vector.
int insertSegmentVerticesForSnap(const QList< QgsSnappingResult > &snapResults)
Inserts vertices to the snapped segments.
void readXml(const QDomNode &layer_node)
Reads joins from project file.
virtual void uniqueValues(int index, QList< QVariant > &uniqueValues, int limit=-1)
Return unique values of an attribute.
virtual bool writeXml(QDomNode &layer_node, QDomDocument &doc)
write vector layer specific state to project file Dom node.
Container of fields for a vector layer.
bool mEnableBackbuffer
Enables backbuffering for the map window.
void rollBack()
Stop editing and discard the edits.
const QgsRectangle & cachedGeometriesRect()
void setDiagramRenderer(QgsDiagramRendererV2 *r)
Sets diagram rendering object (takes ownership)
void setLayerTransparency(int layerTransparency)
Write transparency for layer.
bool readSld(const QDomNode &node, QString &errorMessage)
QgsChangedAttributesMap mChangedAttributeValues
Changed attributes values which are not commited.
WkbType
Used for symbology operations.
QMap< QString, bool > mFieldEditables
const QgsRectangle & extent() const
QMap< int, QgsField > QgsFieldMap
void labelingFontNotFound(QgsVectorLayer *layer, const QString &fontfamily)
Emitted when the font family defined for labeling layer is not found on system.
void setDisplayExpression(const QString &displayExpression)
Set the preview expression, used to create a human readable preview string.
bool addFeature(QgsFeature &f, bool alsoUpdateExtent=true)
Adds a feature.
virtual QList< QString > usedAttributes()=0
field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
int addPart(const QList< QgsPoint > &ring, QgsFeatureId featureId)
Adds a new part polygon to a multipart feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QList< QgsRelation > referencingRelations(int idx)
Get relations, where the foreign key is on this layer.
static const int EditingCapabilities
bitmask of all provider's editing capabilities
virtual ~QgsVectorLayer()
Destructor.
virtual QgsAttributeList pkAttributeIndexes()
Return list of indexes of fields that make up the primary key.
const QString displayExpression()
Get the preview expression, used to create a human readable preview string.
bool deleteVertex(QgsFeatureId atFeatureId, int atVertex)
Deletes a vertex from a feature.
const QgsCoordinateTransform * coordinateTransform() const
void beforeCommitChanges()
Is emitted, before changes are commited to the data provider.
QStringList mCommitErrors
QgsPoint closestVertex(const QgsPoint &point, int &atVertex, int &beforeVertex, int &afterVertex, double &sqrDist)
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap ...
QgsPoint vertexAt(int atVertex)
Returns coordinates of a vertex.
void committedFeaturesRemoved(const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
virtual void stopRender(QgsRenderContext &context)
void setCachedGeometriesRect(const QgsRectangle &extent)
QVariant minimumValue(int index)
Returns minimum value for an attribute column or invalid variant in case of error.
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 featureDeleted(QgsFeatureId fid)
QString readPath(QString filename) const
turn filename read from the project file to an absolute path
void editCommandEnded()
Signal emitted, when an edit command successfully ended.
void setBlendMode(const QPainter::CompositionMode &blendMode)
Write blend mode for layer.
bool setDataProvider(QString const &provider)
bind layer to a specific data provider
void setMaximumScale(float theMaxScale)
Accessor and mutator for the maximum scale denominator member.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer...
void invertSelection()
Select not selected features and deselect selected ones.
int splitFeatures(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
static void logMessage(QString message, QString tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
virtual void updateExtents()
Update the extents for the layer.
Returns diagram settings for a feature.
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
void removeSelection()
Clear selection.
Manages joined fields for a vector layer.
const QgsVectorJoinInfo * joinForFieldIndex(int index, const QgsFields &fields, int &sourceFieldIndex) const
Finds the vector join for a layer field index.
QString editForm()
get edit form (added in 1.4)
void set(const QgsPoint &p1, const QgsPoint &p2)
Set the rectangle from two QgsPoints.
virtual void stopRender(QgsRenderContext &context)=0
void setEditorLayout(EditorLayout editorLayout)
set the active layout for the attribute editor for this layer (added in 1.9)
bool writeXML(QDomNode &layer_node, QDomDocument &doc) const
Writes the actions out in XML format.
const QgsEditorWidgetConfig editorWidgetV2Config(int fieldIdx)
Get the configuration for the editor widget used to represent the field at the given index...
QgsGeometryMap & cachedGeometries()
double ANALYSIS_EXPORT max(double x, double y)
returns the maximum of two doubles or the first argument if both are equal
bool containsJoins() const
Quick way to test if there is any join at all.
const QString & name() const
Get the display name of the layer.
virtual QgsSymbolV2List symbols()=0
for symbol levels
void checkJoinLayerRemove(QString theLayerId)
Check if there is a join with a layer that will be removed.
QgsRectangle extent()
Return the extent of the layer as a QRect.
Perform transforms between map coordinates and device coordinates.
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.
SnappingType
Snap to vertex, to segment or both.
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
QString encoding() const
Get encoding which is used for accessing data.
virtual void writeXML(QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer) const =0
void setColor(const QColor &color)
virtual QVariant maximumValue(int index)
Returns the maximum value of an attribute.
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Set feature ID that should be fetched.
Simplify using the map2pixel data to optimize the rendering of geometries.
QList< QgsAttributeEditorElement * > mChildren
void geometryChanged(QgsFeatureId fid, QgsGeometry &geom)
QSize & widgetSize(int idx)
access widget size for photo and webview widget
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
QPainter::CompositionMode blendMode() const
Read blend mode for layer.
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
virtual void reload()
Synchronises with changes in the datasource.
void deselect(const QgsFeatureId featureId)
Deselect feature by its ID.
QPainter::CompositionMode featureBlendMode() const
Read blend mode for layer.
bool mLabelFontNotFoundNotified
Whether 'labeling font not found' has be shown for this layer (only show once in QgsMessageBar, on first rendering)
bool writeSld(QDomNode &node, QDomDocument &doc, QString &errorMessage) const
bool rollBack(bool deleteBuffer=true)
Stop editing and discard the edits.
QgsGeometryCache * mCache
cache for some vector layer data - currently only geometries for faster editing
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
virtual bool setSubsetString(QString subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
QgsDataProvider * provider(const QString &providerKey, const QString &dataSource)
Create an instance of the provider.
double xMaximum() const
Get the x maximum value (right side of rectangle)
QString attributeDisplayName(int attributeIndex) const
Convenience function that returns the attribute alias if defined or the field name else...
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
QString capabilitiesString() const
Capabilities for this layer in a friendly format.
QgsRelation relation(const QString &id) const
The attribute value should not be shown in the attribute form.
virtual QString dataComment() const
Return a short comment for the data that this provider is providing access to (e.g.
Represents the result of a snapping operation.
bool renderingStopped() const
QMap< int, QString > mEditorWidgetV2Types
void readXML(const QDomElement &elem, const QgsVectorLayer *layer)
virtual void onCacheImageDelete()
Is called when the cache image is being deleted.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
void prepareLabelingAndDiagrams(QgsRenderContext &rendererContext, QgsAttributeList &attributes, bool &labeling)
Registers label and diagram layer.
EditType editType(int idx)
get edit type
virtual int capabilities() const
Returns a bitmask containing the supported capabilities Note, some capabilities may change depending ...
int snapWithContext(const QgsPoint &startPoint, double snappingTolerance, QMultiMap< double, QgsSnappingResult > &snappingResults, QgsSnapper::SnappingType snap_to)
Snaps to segment or vertex within given tolerance.
const QString & id() const
The id.
virtual void setExtent(const QgsRectangle &rect)
Set the extent.
int addTopologicalPoints(QgsGeometry *geom)
Adds topological points for every vertex of the geometry.
void setTolerance(double tolerance)
Sets the tolerance of simplification. Represents the maximum distance between two coordinates which c...
void setScaleBasedVisibility(bool theVisibilityFlag)
Accessor and mutator for the scale based visilibility flag.
void committedFeaturesAdded(const QString &layerId, const QgsFeatureList &addedFeatures)
virtual QDomElement toDomElement(QDomDocument &doc) const
int addPart(const QList< QgsPoint > &ring)
Adds a new part polygon to a multipart feature.
virtual void registerDiagramFeature(QgsVectorLayer *layer, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext())
called for every diagram feature
int fieldOriginIndex(int fieldIdx) const
Get field's origin index (its meaning is specific to each type of origin)
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.
QgsGeometryMap mChangedGeometries
Changed geometries which are not commited.
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
QStringList referencedColumns()
Get list of columns referenced by the expression.
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)...
virtual QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
virtual long featureCount() const =0
Number of features in the layer.
QgsVectorLayer(QString path=QString::null, QString baseName=QString::null, QString providerLib=QString::null, bool loadDefaultStyleFlag=true)
Constructor - creates a vector layer.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
int pendingFeatureCount()
returns feature count after commit
QList< int > QgsAttributeList
void readSldLabeling(const QDomNode &node)
Read labeling from SLD.
AttributeEditorType type() const
void destroyEditCommand()
Destroy active command and reverts all changes in it.
Q_DECL_DEPRECATED bool changeAttributeValue(QgsFeatureId fid, int field, QVariant value, bool emitSignal)
Changes an attribute value (but does not commit it)
QString & dateFormat(int idx)
access date format
const QgsAttributes & attributes() const
bool scaleBasedVisibility() const
bool mSymbolFeatureCounted
QPair< QString, QString > checkedState(int idx)
return string representing 'true' for a checkbox (added in 1.4)
virtual void registerFeature(QgsVectorLayer *layer, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext())=0
called for every feature
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file.
const QString displayField() const
Returns the primary display field name used in the identify results dialog.
int count() const
Return number of items.
bool setReadOnly(bool readonly=true)
Make layer read-only (editing disabled) or not.
double mapUnitsPerPixel() const
Return current map units per pixel.
bool changeGeometry(QgsFeatureId fid, QgsGeometry *geom)
change feature's geometry
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
QString labelField(int attr) const
label field
QgsFeatureIds mDeletedFeatureIds
Deleted feature IDs which are not commited.
int afterVertexNr
The index of the vertex after snappedVertex or -1 if no such vertex.
QgsDiagramRendererV2 * renderer
QgsVectorSimplifyMethod mSimplifyMethod
Simplification object which holds the information about how to simplify the features for fast renderi...
QgsDiagramLayerSettings * mDiagramLayerSettings
Encapsulate a field in an attribute table or data source.
void featureAdded(QgsFeatureId fid)
static QgsFeatureRendererV2 * defaultRenderer(QGis::GeometryType geomType)
return a new renderer - used by default in vector layers
void setFeatureBlendMode(const QPainter::CompositionMode &blendMode)
Write blend mode for features.
QMap< QgsSymbolV2 *, long > mSymbolFeatureCountMap
virtual QGis::WkbType geometryType() const =0
Get feature type.
QString attributeAlias(int attributeIndex) const
Returns the alias of an attribute name or an empty string if there is no alias.
ValueRelationData & valueRelation(int idx)
access relations
fast access to features using their ID
void readXML(const QDomNode &node)
Reads the renderer configuration from an XML file.
QgsFeatureId snappedAtGeometry
Index of the snapped geometry.
bool mValid
Indicates if the layer is valid and can be drawn.
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
virtual bool readXml(const QDomNode &layer_node)
reads vector layer specific state from project file Dom node.
QMap< QString, int > fieldNameMap() const
Return a map where the key is the name of the field and the value is its index.
const QList< QgsVectorJoinInfo > & vectorJoins() const
QMap< QString, QPair< QString, QString > > mCheckedStates
void editingStarted()
Is emitted, when editing on this layer has started.
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)
A class to represent a point geometry.
QList< QgsRelation > referencingRelations(QgsVectorLayer *layer=0, int fieldIdx=-2) const
void writeXML(QDomNode &label_node, QDomDocument &document) const
Writes the contents of the renderer to a configuration file.
void removeJoin(const QString &joinLayerId)
Removes a vector layer join.
void endEditCommand()
Finish edit command and add it to undo/redo stack.
bool commitChanges(QStringList &commitErrors)
Attempts to commit any changes to disk.
int addRing(const QList< QgsPoint > &ring)
Adds a ring to polygon/multipolygon features.
QMap< QString, QString > mAttributeAliasMap
Map that stores the aliases for attributes.
bool deleteAttribute(int attr)
delete an attribute field (but does not commit it)
const QStringList & commitErrors()
virtual int prepareLayer(QgsVectorLayer *layer, QSet< int > &attrIndices, QgsRenderContext &ctx)=0
called when starting rendering of a layer
bool labelOnTop(int idx)
label widget on top
void invalidateSymbolCountedFlag()
bool readSymbology(const QDomNode &node, QString &errorMessage)
Read the symbology for the current layer from the Dom node supplied.
QgsPoint beforeVertex
The layer coordinates of the vertex before snappedVertex.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
QgsVectorLayerEditBuffer * mEditBuffer
stores information about uncommitted changes to layer
QList< QgsSymbolV2LevelItem > QgsSymbolV2Level
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
QgsPoint afterVertex
The layer coordinates of the vertex after snappedVertex.
virtual QDomElement toDomElement(QDomDocument &doc) const
int addTopologicalPoints(QgsGeometry *geom)
Adds topological points for every vertex of the geometry.
void editCommandDestroyed()
Signal emitted, whan an edit command is destroyed.
bool isGeosEqual(QgsGeometry &)
compare geometries using GEOS
void setMaximumScale(float maximumScale)
Sets the maximum scale at which the layer should be simplified.
QMap< QString, RangeData > mRanges
int renderingPass() const
bool countSymbolFeatures(bool showProgress=true)
Count features for symbols.
A class to render labels.
A registry / canonical manager of data providers.
void setProviderEncoding(const QString &encoding)
Sets the textencoding of the data provider.
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
virtual bool isReadOnly() const
Returns true if the provider is in read-only mode.
virtual QString loadNamedStyle(const QString &theURI, bool &theResultFlag, bool loadFromLocalDb)
Load a named style from file/local db/datasource db.
QgsAttributeEditorElement * attributeEditorElementFromDomElement(QDomElement &elem, QObject *parent)
convert a saved attribute editor element into a AttributeEditor structure as it's used internally...
int layerTransparency() const
Read transparency for layer.
static QPainter::CompositionMode getCompositionMode(const QgsMapRenderer::BlendMode &blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode Added in 1.9.
void drawRendererV2Levels(QgsFeatureIterator &fit, QgsRenderContext &rendererContext, bool labeling)
Draw layer with renderer V2 using symbol levels.
QLibrary * providerLibrary(const QString &providerKey) const
int classificationAttribute() const
QMap< QString, EditType > mEditTypes
int snappedVertexNr
The vertex index of snappedVertex or -1 if no such vertex number (e.g.
uuid generator - readonly and automatically intialized
bool snapPoint(QgsPoint &point, double tolerance)
Snaps a point to the closest vertex if there is one within the snapping tolerance.
void setForceLocalOptimization(bool localOptimization)
Sets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries.
void setEditorWidgetV2(int attrIdx, const QString &widgetType)
void addRequiredFields(QgsAttributeList &fields) const
add vector of required fields to existing list of fields
void setEditType(int idx, EditType edit)
set edit type
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.
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)...
QString providerType() const
Return the provider type for this layer.
void stopRendererV2(QgsRenderContext &rendererContext, QgsSingleSymbolRendererV2 *selRenderer)
Add joined attributes to a feature.
void featureBlendModeChanged(const QPainter::CompositionMode &blendMode)
Signal emitted when setFeatureBlendMode() is called.
QgsRectangle boundingBox()
Returns the bounding box of this feature.
QgsDiagramRendererV2 * mDiagramRenderer
bool hasGeometryType() const
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
void attributeAdded(int idx)
Will be emitted, when a new attribute has been added to this vector layer.
virtual long featureCount() const
Number of features in the layer.
Contains information about the context of a rendering operation.
void setMaxScale(float theMaxScale)
Accessor and mutator for the maximum scale member.
int addRing(const QList< QgsPoint > &ring)
Adds a ring to polygon/multipolygon features.
QString mDisplayField
index of the primary label field
QMap< QString, QSize > mWidgetSize
QgsRenderContext * mCurrentRendererContext
QString getStyleById_t(const QString &uri, QString styleID, QString &errCause)
virtual QDomElement toDomElement(QDomDocument &doc) const =0
virtual const QgsFields & fields() const =0
Return a map of indexes with field names for this layer.
QSet< QString > mExcludeAttributesWMS
Attributes which are not published in WMS.
QMap< QString, ValueRelationData > mValueRelations
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.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsAttributeList pendingAllAttributesList()
returns list of attributes
virtual QgsRectangle extent()=0
Get the extent of the layer.
QMap< QString, QMap< QString, QVariant > > mValueMaps
void setAnnotationForm(const QString &ui)
set annotation form for layer (added in 1.5)
void setExtent(const QgsRectangle &rect)
Set the extent.
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
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...
bool mLabelOn
Display labels.
QgsVectorLayerJoinBuffer * mJoinBuffer
bool draw(QgsRenderContext &rendererContext)
Draws the layer.
const QString editorWidgetV2(int fieldIdx)
Get the id for the editor widget used to represent the field at the given index.
QVector< QVariant > QgsAttributes
void setSelectedFeatures(const QgsFeatureIds &ids)
Change selection to the new set of features.
virtual QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
return list of symbols used for rendering the feature.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves mVectorJoins to xml under the layer node.
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
This class manages a set of relations between layers.
static QgsFeatureRendererV2 * load(QDomElement &symbologyElem)
create a renderer from XML element
const QString & typeName() const
Gets the field type.
virtual bool setSubsetString(QString subset)
Set the string (typically sql) used to define a subset of the layer.
virtual void reloadData()
Reloads the data from the source.
virtual QVariant minimumValue(int index)
Returns the minimum value of an attribute.
void setEditForm(QString ui)
set edit form (added in 1.4)
virtual bool isValid()=0
Returns true if this is a valid layer.
void snapToGeometry(const QgsPoint &startPoint, QgsFeatureId featureId, QgsGeometry *geom, double sqrSnappingTolerance, QMultiMap< double, QgsSnappingResult > &snappingResults, QgsSnapper::SnappingType snap_to) const
Snaps to a geometry and adds the result to the multimap if it is within the snapping result...
void setMethodType(MethodType methodType)
Sets the simplification type.
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)...
void updateFields(QgsFields &fields)
Updates field map with joined attributes.
void repaintRequested()
This signal should be connected with the slot QgsMapCanvas::refresh()
void setVertexMarkerAppearance(int type, int size)
set type and size of editing vertex markers for subsequent rendering
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &)
static QgsProject * instance()
access to canonical QgsProject instance
QgsPoint snappedVertex
The coordinates of the snapping result.
bool usingSymbolLevels() const
void setCheckedState(int idx, QString checked, QString notChecked)
set string representing 'true' for a checkbox (added in 1.4)
Class for storing a coordinate reference system (CRS)
void writeXML(QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer) const
int length() const
Gets the length of the field.
bool classificationAttributeIsExpression() const
friend class QgsVectorLayerEditBuffer
QgsLabel * label()
Get the label object associated with this layer.
int size() const
Return number of items.
virtual QString description() const =0
return description
bool hasLabelsEnabled() const
Label is on.
QList< QgsAttributeEditorElement * > & attributeEditorElements()
Returns a list of tabs holding groups and fields.
virtual QDomElement writeSld(QDomDocument &doc, const QgsVectorLayer &layer) const
create the SLD UserStyle element following the SLD v1.1 specs
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
QString mFilterExpression
QMap< QString, QString > mDateFormats
void cacheGeometry(QgsFeatureId fid, const QgsGeometry &geom)
store a geometry in the cache
virtual void readXML(const QDomElement &elem, const QgsVectorLayer *layer)=0
const QMap< QString, QgsMapLayer * > & mapLayers()
Retrieve the mapLayers collection (mainly intended for use by projection)
void recalculateExtents()
This is used to send a request that any mapcanvas using this layer update its extents.
QMap< QString, bool > mLabelOnTop
const QString & comment() const
Returns the field comment.
void setFieldEditable(int idx, bool editable)
set edit widget editable
bool deleteFeature(QgsFeatureId fid)
delete a feature from the layer (but does not commit it)
const QgsMapToPixel & mapToPixel() const
QList< QgsSymbolV2Level > QgsSymbolV2LevelOrder
static QColor colorFromOgcFill(const QDomElement &fillElement)
Parse XML with OGC fill into QColor.
bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
changed an attribute value (but does not commit it)
void setLayerName(const QString &name)
Set the display name of the layer.
static int currentVertexMarkerSize()
Reads vertex marker size from settings.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
virtual void startRender(QgsRenderContext &context, const QgsVectorLayer *vlayer)=0
allows deletion of features
int mLayerTransparency
Layer transparency.
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
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 ...
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
void(*)() cast_to_fptr(void *p)
static QgsMapRenderer::BlendMode getBlendModeEnum(const QPainter::CompositionMode &blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode Added in 1.9.
QString dataComment() const
Returns a comment for the data in the layer.
void setMinScale(float theMinScale)
Accessor and mutator for the minimum scale member.
Custom exception class for Coordinate Reference System related exceptions.
QUndoStack * undoStack()
Return pointer to layer's undo stack.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
void setLabelOnTop(int idx, bool onTop)
label widget on top
QMap< int, QMap< QString, QVariant > > mEditorWidgetV2Configs
QgsSymbolLayerV2 * symbolLayer(int layer)
QgsVectorDataProvider * dataProvider()
Returns the data provider.
virtual void addChildElement(QgsAttributeEditorElement *widget)
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.
void normalize()
Normalize the rectangle so it has non-negative width/height.
QString editFormInit()
get python function for edit form initialization (added in 1.4)
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
float maximumScale() const
Gets the maximum scale at which the layer should be simplified.
bool nextFeature(QgsFeature &f)
FeatureFormSuppress
Types of feature form suppression after feature creation.
void setCoordinateSystem()
Setup the coordinate system tranformation 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.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
QString classificationAttributeExpression() const
QgsFields mUpdatedFields
field map to commit
QgsFeatureMap mAddedFeatures
New features which are not commited.
double width() const
Width of the rectangle.
int mUpdateThreshold
Update threshold for drawing features as they are read.
QgsFeatureIds allFeatureIds()
Get all feature Ids.
QgsAttributeList pendingPkAttributesList()
returns list of attribute making up the primary key
virtual bool isEditable() const
Returns true if the provider is in editing mode.
QPainter::CompositionMode mFeatureBlendMode
Blend mode for features.
QString metadata()
Obtain Metadata for this layer.
static QgsFeatureRendererV2 * readOldRenderer(const QDomNode &layerNode, QGis::GeometryType geomType)
Read old renderer definition from XML and create matching new renderer.
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage) const
Write the symbology for the layer into the docment provided.
void updateFields(QgsFields &fields)
virtual QgsRectangle extent()
Return the extent of the layer.
Represents a vector layer which manages a vector based data sets.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
bool addAttribute(const QgsField &field)
add an attribute field (but does not commit it) returns true if the field was added ...
bool geographicFlag() const
bool isModified() const
Returns true if the provider has been modified since the last commit.
bool deleteSelectedFeatures()
Deletes the selected features.
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)=0
to be overridden
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.
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.
QgsFeatureRequest & setFlags(Flags flags)
Set flags that affect how features will be fetched.
QgsRelationManager * relationManager() const
double xMinimum() const
Get the x minimum value (left side of rectangle)
bool mReadOnly
Flag indicating whether the layer is in read-only mode (editing disabled) or not. ...
QgsFeatureIds mSelectedFeatureIds
Set holding the feature IDs that are activated.
const QgsVectorLayer * layer
Layer where the snap occured.
void rendererChanged()
Signal emitted on symbology changes, when setRendererV2() is called.
QgsPoint center() const
Center point of the rectangle.
QString joinLayerId
Source layer.
void layerModified()
This signal is emitted when modifications has been done on layer.
QgsAttributeList mDeletedAttributeIds
deleted attributes fields which are not commited.
QString evalErrorString() const
Returns evaluation error.
virtual bool applyNamedStyle(QString namedStyle, QString errorMsg)
bool readXML(const QDomNode &layer_node)
Reads the actions in in XML format.
bool changeGeometry(QgsFeatureId fid, QgsGeometry *geom)
change feature's geometry
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.
virtual QString dataSourceUri() const
Get the data source specification.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken.
int splitFeatures(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
void setDisplayField(QString fldName="")
Set the primary display field to be used in the identify results dialog.
const CORE_EXPORT QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority.
QString mProviderKey
Data provider key.
void addJoin(const QgsVectorJoinInfo &joinInfo)
Joins another vector layer to this layer.
virtual QList< QgsAttributeEditorElement * > findElements(AttributeEditorType type) const
void toggleScaleBasedVisibility(bool theVisibilityFlag)
Accessor and mutator for the scale based visilibility flag.
QgsLabelingEngineInterface * labelingEngine() const
Added in QGIS v1.4.
double height() const
Height of the rectangle.
QString toProj4() const
Get the Proj Proj4 string representation of this srs.
void enableLabels(bool on)
Set labels on.
void setMinimumScale(float theMinScale)
Accessor and mutator for the minimum scale denominator member.
void setThreshold(float threshold)
Sets the simplification threshold of the vector layer managed.
void addAttributeEditorWidget(QgsAttributeEditorElement *data)
Adds a tab (for the attribute editor form) holding groups and fields.
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)
QgsAttributeAction * mActions
The user-defined actions that are accessed from the Identify Results dialog box.
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
int listStyles_t(const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
void addJoin(const QgsVectorJoinInfo &joinInfo)
Joins another vector layer to this layer.