QgsVectorLayer Class Reference
[QGIS core library]

Vector layer backed by a data source provider. More...

#include <qgsvectorlayer.h>

Inheritance diagram for QgsVectorLayer:

Inheritance graph
[legend]
Collaboration diagram for QgsVectorLayer:

Collaboration graph
[legend]

List of all members.

Public Types

enum  EditType {
  LineEdit, UniqueValues, UniqueValuesEditable, ValueMap,
  Classification, EditRange, SliderRange, CheckBox,
  FileName, Enumeration, Immutable, Hidden,
  TextEdit, Calendar, DialRange
}
enum  VertexMarkerType { SemiTransparentCircle, Cross, NoMarker }
 Editing vertex markers. More...

Public Slots

void select (int featureId, bool emitSignal=true)
 Select feature by its ID, optionally emit signal selectionChanged().
void deselect (int featureId, bool emitSignal=true)
 Deselect feature by its ID, optionally emit signal selectionChanged().
void removeSelection (bool emitSignal=true)
 Clear selection.
void triggerRepaint ()
virtual void updateExtents ()
 Update the extents for the layer.

Signals

void selectionChanged ()
 This signal is emited when selection was changed.
void layerModified (bool onlyGeometry)
 This signal is emitted when modifications has been done on layer.
void editingStarted ()
void editingStopped ()
void attributeAdded (int idx)
void attributeDeleted (int idx)
void featureDeleted (int fid)
void layerDeleted ()
void attributeValueChanged (int fid, int idx, const QVariant &)
void committedAttributesDeleted (const QString &layerId, const QgsAttributeIds &deletedAttributeIds)
 Signals emitted after committing changes.
void committedAttributesAdded (const QString &layerId, const QList< QgsField > &addedAttributes)
void committedFeaturesAdded (const QString &layerId, const QgsFeatureList &addedFeatures)
void committedFeaturesRemoved (const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
void committedAttributeValuesChanges (const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
void committedGeometriesChanges (const QString &layerId, const QgsGeometryMap &changedGeometries)

Public Member Functions

 QgsVectorLayer (QString path=QString::null, QString baseName=QString::null, QString providerLib=QString::null, bool loadDefaultStyleFlag=true)
 Constructor.
virtual ~QgsVectorLayer ()
 Destructor.
QString storageType () const
 Returns the permanent storage type for this layer as a friendly name.
QString capabilitiesString () const
 Capabilities for this layer in a friendly format.
QString dataComment () const
 Returns a comment for the data in the layer.
void setDisplayField (QString fldName="")
 Set the primary display field to be used in the identify results dialog.
const QString displayField () const
 Returns the primary display field name used in the identify results dialog.
QgsVectorDataProviderdataProvider ()
 Returns the data provider.
const QgsVectorDataProviderdataProvider () const
 Returns the data provider in a const-correct manner.
void setProviderEncoding (const QString &encoding)
 Sets the textencoding of the data provider.
void setCoordinateSystem ()
 Setup the coordinate system tranformation for the layer.
QgsLabellabel ()
 Get the label object associated with this layer.
const QgsLabellabel () const
QgsAttributeActionactions ()
int selectedFeatureCount ()
 The number of features that are selected in this layer.
void select (QgsRectangle &rect, bool lock)
 Select features found within the search rectangle (in layer's coordinates).
void invertSelection ()
 Select not selected features and deselect selected ones.
void invertSelectionInRectangle (QgsRectangle &rect)
 Invert selection of features found within the search rectangle (in layer's coordinates).
QgsFeatureList selectedFeatures ()
 Get a copy of the user-selected features.
const QgsFeatureIdsselectedFeaturesIds () const
 Return reference to identifiers of selected features.
void setSelectedFeatures (const QgsFeatureIds &ids)
 Change selection to the new set of features.
QgsRectangle boundingBoxOfSelected ()
 Returns the bounding box of the selected features.
bool copySymbologySettings (const QgsMapLayer &other)
 Copies the symbology settings from another layer.
bool hasCompatibleSymbology (const QgsMapLayer &other) const
 Returns true if this layer can be in the same symbology group with another layer.
const QgsRendererrenderer () const
 Returns a pointer to the renderer.
void setRenderer (QgsRenderer *r)
 Sets the renderer.
QgsFeatureRendererV2rendererV2 ()
 Return renderer V2.
void setRendererV2 (QgsFeatureRendererV2 *r)
 Set renderer V2.
bool isUsingRendererV2 ()
 Return whether using renderer V2.
void setUsingRendererV2 (bool usingRendererV2)
 set whether to use renderer V2 for drawing.
void drawRendererV2 (QgsRenderContext &rendererContext, bool labeling)
 Draw layer with renderer V2.
void drawRendererV2Levels (QgsRenderContext &rendererContext, bool labeling)
 Draw layer with renderer V2 using symbol levels.
QGis::GeometryType geometryType () const
 Returns point, line or polygon.
QGis::WkbType wkbType () const
 Returns the WKBType or WKBUnknown in case of error.
QString providerType () const
 Return the provider type for this layer.
virtual bool readXml (QDomNode &layer_node)
 reads vector layer specific state from project file Dom node.
virtual bool writeXml (QDomNode &layer_node, QDomDocument &doc)
 write vector layer specific state to project file Dom node.
bool readSymbology (const QDomNode &node, QString &errorMessage)
 Read the symbology for the current layer from the Dom node supplied.
bool writeSymbology (QDomNode &node, QDomDocument &doc, QString &errorMessage) const
 Write the symbology for the layer into the docment provided.
virtual long featureCount () const
 Number of features in the layer.
virtual long updateFeatureCount () const
 This function does nothing useful, it's kept only for compatibility.
virtual bool setSubsetString (QString subset)
 Set the string (typically sql) used to define a subset of the layer.
virtual QString subsetString ()
 Get the string (typically sql) used to define a subset of the layer.
void select (QgsAttributeList fetchAttributes, QgsRectangle rect=QgsRectangle(), bool fetchGeometry=true, bool useIntersect=false)
 Select features with or without attributes in a given window.
bool nextFeature (QgsFeature &feature)
 fetch a feature (after select)
bool featureAtId (int featureId, QgsFeature &f, bool fetchGeometries=true, bool fetchAttributes=true)
 Gets the feature at the given feature id.
bool addFeature (QgsFeature &f, bool alsoUpdateExtent=true)
 Adds a feature.
bool insertVertex (double x, double y, int atFeatureId, int beforeVertex)
 Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries.
bool moveVertex (double x, double y, int atFeatureId, int atVertex)
 Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates.
bool deleteVertex (int atFeatureId, int atVertex)
 Deletes a vertex from a feature.
bool deleteSelectedFeatures ()
 Deletes the selected features.
int addRing (const QList< QgsPoint > &ring)
 Adds a ring to polygon/multipolygon features.
int addIsland (const QList< QgsPoint > &ring)
 Adds a new island polygon to a multipolygon feature.
int translateFeature (int featureId, double dx, double dy)
 Translates feature by dx, dy.
int splitFeatures (const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
 Splits features cut by the given line.
int removePolygonIntersections (QgsGeometry *geom)
 Changes the specified geometry such that it has no intersections with other polygon (or multipolygon) geometries in this vector layer.
int addTopologicalPoints (QgsGeometry *geom)
 Adds topological points for every vertex of the geometry.
int addTopologicalPoints (const QgsPoint &p)
 Adds a vertex to segments which intersect point p but don't already have a vertex there.
int insertSegmentVerticesForSnap (const QList< QgsSnappingResult > &snapResults)
 Inserts vertices to the snapped segments.
void enableLabels (bool on)
 Set labels on.
bool hasLabelsEnabled (void) const
 Label is on.
virtual bool isEditable () const
 Returns true if the provider is in editing mode.
virtual bool isReadOnly () const
 Returns true if the provider is in read-only mode.
virtual bool isModified () const
 Returns true if the provider has been modified since the last commit.
bool snapPoint (QgsPoint &point, double tolerance)
 Snaps a point to the closest vertex if there is one within the snapping tolerance.
int snapWithContext (const QgsPoint &startPoint, double snappingTolerance, QMultiMap< double, QgsSnappingResult > &snappingResults, QgsSnapper::SnappingType snap_to)
 Snaps to segment or vertex within given tolerance.
virtual void reload ()
 Synchronises with changes in the datasource.
bool draw (QgsRenderContext &rendererContext)
 Draws the layer.
void drawLabels (QgsRenderContext &rendererContext)
 Draws the layer labels using coordinate transformation.
const QgsFieldMappendingFields () const
 returns field list in the to-be-committed state
QgsAttributeList pendingAllAttributesList ()
 returns list of attributes
int pendingFeatureCount ()
 returns feature count after commit
bool setReadOnly (bool readonly=true)
 Make layer read-only (editing disabled) or not.
void setModified (bool modified=true, bool onlyGeometryWasModified=false)
 Sets whether some features are modified or not.
bool startEditing ()
 Make layer editable.
bool changeGeometry (int fid, QgsGeometry *geom)
 change feature's geometry
bool changeAttributeValue (int fid, int field, QVariant value, bool emitSignal=true)
 changed an attribute value (but does not commit it)
bool addAttribute (const QgsField &field)
 add an attribute field (but does not commit it) returns true if the field was added
bool addAttribute (QString name, QString type)
 add an attribute field (but does not commit it) returns true if the field was added
void addAttributeAlias (int attIndex, QString aliasString)
 Sets an alias (a display name) for attributes to display in dialogs.
QString attributeAlias (int attributeIndex) const
 Returns the alias of an attribute name or an empty string if there is no alias.
QString attributeDisplayName (int attributeIndex) const
 Convenience function that returns the attribute alias if defined or the field name else.
bool deleteAttribute (int attr)
 delete an attribute field (but does not commit it)
bool addFeatures (QgsFeatureList features, bool makeSelected=true)
 Insert a copy of the given features into the layer (but does not commit it).
bool deleteFeature (int fid)
 delete a feature from the layer (but does not commit it)
bool commitChanges ()
 Attempts to commit any changes to disk.
const QStringList & commitErrors ()
bool rollBack ()
 Stop editing and discard the edits.
EditType editType (int idx)
 get edit type
void setEditType (int idx, EditType edit)
 set edit type
void setCheckedState (int idx, QString checked, QString notChecked)
 set string representing 'true' for a checkbox (added in 1.4)
QPair< QString, QString > checkedState (int idx)
 return string representing 'true' for a checkbox (added in 1.4)
QString editForm ()
 get edit form (added in 1.4)
void setEditForm (QString ui)
 set edit form (added in 1.4)
QString annotationForm () const
 get annotation form (added in 1.5)
void setAnnotationForm (const QString &ui)
 set annotation form for layer (added in 1.5)
QString editFormInit ()
 get python function for edit form initialization (added in 1.4)
void setEditFormInit (QString function)
 set python function for edit form initialization (added in 1.4)
QMap< QString, QVariant > & valueMap (int idx)
 access value map
RangeDatarange (int idx)
 access range
void addOverlay (QgsVectorOverlay *overlay)
 Adds a new overlay to this class.
void removeOverlay (const QString &typeName)
 Removes all overlays of a given type.
void vectorOverlays (QList< QgsVectorOverlay * > &overlayList)
 Returns pointers to the overlays of this layer.
QgsVectorOverlayfindOverlayByType (const QString &typeName)
 Returns the (first) overlay of a type, e.g.
void beginEditCommand (QString text)
 Create edit command for undo/redo operations.
void endEditCommand ()
 Finish edit command and add it to undo/redo stack.
void destroyEditCommand ()
 Destroy active command and reverts all changes in it.
void undoEditCommand (QgsUndoCommand *cmd)
 Execute undo operation.
void redoEditCommand (QgsUndoCommand *cmd)
 Execute redo operation.
int fieldNameIndex (const QString &fieldName) const
 Returns the index of a field name or -1 if the field does not exist.

Static Public Member Functions

static void drawVertexMarker (double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
 Draws a vertex symbol at (screen) coordinates x, y.

Private Member Functions

 QgsVectorLayer (QgsVectorLayer const &rhs)
 vector layers are not copyable
QgsVectorLayeroperator= (QgsVectorLayer const &rhs)
 vector layers are not copyable
bool setDataProvider (QString const &provider)
 bind layer to a specific data provider
void drawFeature (QgsRenderContext &renderContext, QgsFeature &fet, QImage *marker)
 Draws features.
void transformPoint (double &x, double &y, const QgsMapToPixel *mtp, const QgsCoordinateTransform *ct)
 Convenience function to transform the given point.
void transformPoints (std::vector< double > &x, std::vector< double > &y, std::vector< double > &z, QgsRenderContext &renderContext)
unsigned char * drawLineString (unsigned char *WKBlinestring, QgsRenderContext &renderContext)
 Draw the linestring as given in the WKB format.
unsigned char * drawPolygon (unsigned char *WKBpolygon, QgsRenderContext &renderContext)
 Draw the polygon as given in the WKB format.
int findFreeId ()
 Goes through all features and finds a free id (e.g.
void deleteCachedGeometries ()
 Deletes the geometries in mCachedGeometries.
void snapToGeometry (const QgsPoint &startPoint, int 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.
int boundingBoxFromPointList (const QList< QgsPoint > &list, double &xmin, double &ymin, double &xmax, double &ymax) const
 Little helper function that gives bounding box from a list of points.
void updateFeatureAttributes (QgsFeature &f, bool all=false)
 Update feature with uncommited attribute updates.
void updateFeatureGeometry (QgsFeature &f)
 Update feature with uncommited geometry updates.
void editGeometryChange (int featureId, QgsGeometry &geometry)
 Record changed geometry, store in active command (if any).
void editFeatureAdd (QgsFeature &feature)
 Record added feature, store in active command (if any).
void editFeatureDelete (int featureId)
 Record deleted feature, store in active command (if any).
void editAttributeChange (int featureId, int field, QVariant value)
 Record changed attribute, store in active command (if any).
void stopRendererV2 (QgsRenderContext &rendererContext, QgsSingleSymbolRendererV2 *selRenderer)
 Stop version 2 renderer and selected renderer (if required).

Static Private Member Functions

static
QgsVectorLayer::VertexMarkerType 
currentVertexMarkerType ()
 Reads vertex marker type from settings.
static int currentVertexMarkerSize ()
 Reads vertex marker size from settings.

Private Attributes

int mUpdateThreshold
 Update threshold for drawing features as they are read.
QgsVectorDataProvidermDataProvider
 Pointer to data provider derived from the abastract base class QgsDataProvider.
QString mDisplayField
 index of the primary label field
QString mProviderKey
 Data provider key.
QgsAttributeActionmActions
 The user-defined actions that are accessed from the Identify Results dialog box.
bool mEditable
 Flag indicating whether the layer is in editing mode or not.
bool mReadOnly
 Flag indicating whether the layer is in read-only mode (editing disabled) or not.
bool mModified
 Flag indicating whether the layer has been modified since the last commit.
QgsGeometryMap mCachedGeometries
 cache of the committed geometries retrieved *for the current display*
QgsRectangle mCachedGeometriesRect
 extent for which there are cached geometries
QgsFeatureIds mSelectedFeatureIds
 Set holding the feature IDs that are activated.
QgsFeatureIds mDeletedFeatureIds
 Deleted feature IDs which are not commited.
QgsFeatureList mAddedFeatures
 New features which are not commited.
QgsChangedAttributesMap mChangedAttributeValues
 Changed attributes values which are not commited.
QgsAttributeIds mDeletedAttributeIds
 deleted attributes fields which are not commited
QgsAttributeIds mAddedAttributeIds
 added attributes fields which are not commited
QgsGeometryMap mChangedGeometries
 Changed geometries which are not commited.
QgsFieldMap mUpdatedFields
 field map to commit
QMap< int, QString > mAttributeAliasMap
 Map that stores the aliases for attributes.
int mMaxUpdatedIndex
 max field index
int mWkbType
 Geometry type as defined in enum WkbType (qgis.h).
QgsUndoCommandmActiveCommand
QgsRenderermRenderer
 Renderer object which holds the information about how to display the features.
QgsFeatureRendererV2mRendererV2
 Renderer V2.
bool mUsingRendererV2
 whether to use V1 or V2 renderer
QgsLabelmLabel
 Label.
bool mLabelOn
 Display labels.
QgsVectorLayer::VertexMarkerType mCurrentVertexMarkerType
 The current type of editing marker.
int mCurrentVertexMarkerSize
 The current size of editing marker.
bool mVertexMarkerOnlyForSelection
 Flag if the vertex markers should be drawn only for selection (true) or for all features (false).
QList< QgsVectorOverlay * > mOverlays
 List of overlays.
QStringList mCommitErrors
QMap< QString, EditTypemEditTypes
QMap< QString, QMap< QString,
QVariant > > 
mValueMaps
QMap< QString, RangeDatamRanges
QMap< QString, QPair< QString,
QString > > 
mCheckedStates
QString mEditForm
QString mEditFormInit
QString mAnnotationForm
bool mFetching
QgsRectangle mFetchRect
QgsAttributeList mFetchAttributes
QgsAttributeList mFetchProvAttributes
bool mFetchGeometry
QSet< int > mFetchConsidered
QgsGeometryMap::iterator mFetchChangedGeomIt
QgsFeatureList::iterator mFetchAddedFeaturesIt

Classes

struct  RangeData


Detailed Description

Vector layer backed by a data source provider.

Definition at line 61 of file qgsvectorlayer.h.


Member Enumeration Documentation

Enumerator:
LineEdit 
UniqueValues 
UniqueValuesEditable 
ValueMap 
Classification 
EditRange 
SliderRange 
CheckBox 
FileName 
Enumeration 
Immutable 
Hidden 
TextEdit 
Calendar 
DialRange 

Definition at line 66 of file qgsvectorlayer.h.

Editing vertex markers.

Note:
public from version 1.4
Enumerator:
SemiTransparentCircle 
Cross 
NoMarker 

Definition at line 586 of file qgsvectorlayer.h.


Constructor & Destructor Documentation

QgsVectorLayer::QgsVectorLayer ( QString  path = QString::null,
QString  baseName = QString::null,
QString  providerLib = QString::null,
bool  loadDefaultStyleFlag = true 
)

QgsVectorLayer::~QgsVectorLayer (  )  [virtual]

QgsVectorLayer::QgsVectorLayer ( QgsVectorLayer const &  rhs  )  [private]

vector layers are not copyable


Member Function Documentation

QString QgsVectorLayer::storageType (  )  const

Returns the permanent storage type for this layer as a friendly name.

Definition at line 201 of file qgsvectorlayer.cpp.

References mDataProvider, and QgsVectorDataProvider::storageType().

QString QgsVectorLayer::capabilitiesString (  )  const

Capabilities for this layer in a friendly format.

Definition at line 211 of file qgsvectorlayer.cpp.

References QgsVectorDataProvider::capabilitiesString(), and mDataProvider.

QString QgsVectorLayer::dataComment (  )  const

Returns a comment for the data in the layer.

Definition at line 220 of file qgsvectorlayer.cpp.

References QgsVectorDataProvider::dataComment(), and mDataProvider.

void QgsVectorLayer::setDisplayField ( QString  fldName = ""  ) 

Set the primary display field to be used in the identify results dialog.

sets the preferred display field based on some fuzzy logic

Definition at line 238 of file qgsvectorlayer.cpp.

References geometryType(), mDisplayField, QGis::NoGeometry, pendingFields(), and QgsDebugMsg.

Referenced by readSymbology(), and setDataProvider().

const QString QgsVectorLayer::displayField (  )  const

Returns the primary display field name used in the identify results dialog.

Definition at line 4205 of file qgsvectorlayer.cpp.

References mDisplayField.

Referenced by writeSymbology().

QgsVectorDataProvider * QgsVectorLayer::dataProvider (  ) 

const QgsVectorDataProvider * QgsVectorLayer::dataProvider (  )  const

Returns the data provider in a const-correct manner.

Definition at line 1272 of file qgsvectorlayer.cpp.

References mDataProvider.

void QgsVectorLayer::setProviderEncoding ( const QString &  encoding  ) 

Sets the textencoding of the data provider.

Definition at line 1277 of file qgsvectorlayer.cpp.

References mDataProvider, and QgsVectorDataProvider::setEncoding().

void QgsVectorLayer::setCoordinateSystem (  ) 

QgsLabel * QgsVectorLayer::label (  ) 

Get the label object associated with this layer.

Definition at line 2456 of file qgsvectorlayer.cpp.

References mLabel.

Referenced by QgsQuickPrint::scaleTextLabels().

const QgsLabel * QgsVectorLayer::label (  )  const

Definition at line 2461 of file qgsvectorlayer.cpp.

References mLabel.

QgsAttributeAction* QgsVectorLayer::actions (  )  [inline]

Definition at line 135 of file qgsvectorlayer.h.

int QgsVectorLayer::selectedFeatureCount (  ) 

The number of features that are selected in this layer.

Definition at line 3626 of file qgsvectorlayer.cpp.

References mSelectedFeatureIds.

Referenced by QgsMapCanvas::zoomToSelected().

void QgsVectorLayer::select ( QgsRectangle rect,
bool  lock 
)

void QgsVectorLayer::invertSelection (  ) 

Select not selected features and deselect selected ones.

Definition at line 1194 of file qgsvectorlayer.cpp.

References QgsFeature::id(), mSelectedFeatureIds, nextFeature(), removeSelection(), select(), selectionChanged(), and QgsMapLayer::setCacheImage().

void QgsVectorLayer::invertSelectionInRectangle ( QgsRectangle rect  ) 

Invert selection of features found within the search rectangle (in layer's coordinates).

Definition at line 1220 of file qgsvectorlayer.cpp.

References deselect(), QgsFeature::id(), mSelectedFeatureIds, nextFeature(), QgsRectangle::normalize(), select(), selectionChanged(), and QgsMapLayer::setCacheImage().

QgsFeatureList QgsVectorLayer::selectedFeatures (  ) 

const QgsFeatureIds & QgsVectorLayer::selectedFeaturesIds (  )  const

void QgsVectorLayer::setSelectedFeatures ( const QgsFeatureIds ids  ) 

Change selection to the new set of features.

Definition at line 3615 of file qgsvectorlayer.cpp.

References mSelectedFeatureIds, selectionChanged(), and QgsMapLayer::setCacheImage().

QgsRectangle QgsVectorLayer::boundingBoxOfSelected (  ) 

bool QgsVectorLayer::copySymbologySettings ( const QgsMapLayer other  )  [virtual]

Copies the symbology settings from another layer.

Returns true in case of success

Implements QgsMapLayer.

Definition at line 3726 of file qgsvectorlayer.cpp.

References QgsRenderer::clone(), geometryType(), mRenderer, and QGis::NoGeometry.

bool QgsVectorLayer::hasCompatibleSymbology ( const QgsMapLayer other  )  const [virtual]

Returns true if this layer can be in the same symbology group with another layer.

Implements QgsMapLayer.

Definition at line 3757 of file qgsvectorlayer.cpp.

References QgsVectorDataProvider::fields(), mDataProvider, QgsMapLayer::name(), and QgsMapLayer::type().

const QgsRenderer * QgsVectorLayer::renderer (  )  const

void QgsVectorLayer::setRenderer ( QgsRenderer r  ) 

QgsFeatureRendererV2 * QgsVectorLayer::rendererV2 (  ) 

Return renderer V2.

Note:
added in 1.4

Definition at line 4349 of file qgsvectorlayer.cpp.

References mRendererV2.

Referenced by QgsLegendModel::addVectorLayerItemsV2(), QgsAttributeEditor::createAttributeEditor(), and QgsSymbologyV2Conversion::rendererV2toV1().

void QgsVectorLayer::setRendererV2 ( QgsFeatureRendererV2 r  ) 

bool QgsVectorLayer::isUsingRendererV2 (  ) 

Return whether using renderer V2.

Note:
added in 1.4

Definition at line 4361 of file qgsvectorlayer.cpp.

References mUsingRendererV2.

Referenced by QgsLegendModel::addLayer(), QgsSymbologyV2Conversion::rendererV1toV2(), QgsSymbologyV2Conversion::rendererV2toV1(), and QgsLegendModel::updateLayer().

void QgsVectorLayer::setUsingRendererV2 ( bool  usingRendererV2  ) 

set whether to use renderer V2 for drawing.

Note:
added in 1.4

Definition at line 4365 of file qgsvectorlayer.cpp.

References geometryType(), mUsingRendererV2, and QGis::NoGeometry.

Referenced by QgsVectorLayer(), readSymbology(), QgsSymbologyV2Conversion::rendererV1toV2(), and QgsSymbologyV2Conversion::rendererV2toV1().

void QgsVectorLayer::drawRendererV2 ( QgsRenderContext rendererContext,
bool  labeling 
)

void QgsVectorLayer::drawRendererV2Levels ( QgsRenderContext rendererContext,
bool  labeling 
)

QGis::GeometryType QgsVectorLayer::geometryType (  )  const

QGis::WkbType QgsVectorLayer::wkbType (  )  const

Returns the WKBType or WKBUnknown in case of error.

Definition at line 1354 of file qgsvectorlayer.cpp.

References mWkbType.

Referenced by addTopologicalPoints(), drawFeature(), drawLineString(), drawPolygon(), and QgsVectorFileWriter::writeAsVectorFormat().

QString QgsVectorLayer::providerType (  )  const

Return the provider type for this layer.

Definition at line 230 of file qgsvectorlayer.cpp.

References mProviderKey.

Referenced by QgsMapLayer::saveNamedStyle(), writeXml(), and QgsMapLayer::writeXML().

bool QgsVectorLayer::readXml ( QDomNode &  layer_node  )  [virtual]

reads vector layer specific state from project file Dom node.

Note:
Called by QgsMapLayer::readXML().

Reimplemented from QgsMapLayer.

Definition at line 2515 of file qgsvectorlayer.cpp.

References geometryType(), mDataProvider, QgsMapLayer::mDataSource, mProviderKey, QgsMapLayer::mValid, QGis::NoGeometry, QgsDebugMsg, readSymbology(), setDataProvider(), and QgsVectorDataProvider::setEncoding().

bool QgsVectorLayer::writeXml ( QDomNode &  layer_node,
QDomDocument &  doc 
) [virtual]

write vector layer specific state to project file Dom node.

Note:
Called by QgsMapLayer::writeXML().

Reimplemented from QgsMapLayer.

Definition at line 2682 of file qgsvectorlayer.cpp.

References QgsVectorDataProvider::encoding(), geometryType(), mDataProvider, providerType(), QGis::qgisVectorGeometryType, QgsDebugMsg, and writeSymbology().

bool QgsVectorLayer::readSymbology ( const QDomNode &  node,
QString &  errorMessage 
) [virtual]

bool QgsVectorLayer::writeSymbology ( QDomNode &  node,
QDomDocument &  doc,
QString &  errorMessage 
) const [virtual]

Write the symbology for the layer into the docment provided.

Parameters:
node the node that will have the style element added to it.
doc the document that will have the QDomNode added.
errorMessage reference to string that will be updated with any error messages
Returns:
true in case of success.

Implements QgsMapLayer.

Definition at line 2908 of file qgsvectorlayer.cpp.

References CheckBox, QgsRenderer::classificationAttributes(), displayField(), EditRange, QgsVectorDataProvider::fields(), geometryType(), hasLabelsEnabled(), QgsProject::instance(), QgsLabel::labelField(), mActions, mAnnotationForm, mAttributeAliasMap, QgsLabel::maxScale(), mCheckedStates, mDataProvider, mEditForm, mEditFormInit, mEditTypes, QgsLabel::minScale(), mLabel, mOverlays, mRanges, mRenderer, mRendererV2, mUsingRendererV2, mValueMaps, QgsMapLayer::name(), QGis::NoGeometry, QgsDebugMsg, renderer(), QgsFeatureRendererV2::save(), QgsLabel::scaleBasedVisibility(), SliderRange, QgsLabel::Text, ValueMap, QgsAttributeAction::writeXML(), QgsLabel::writeXML(), and QgsRenderer::writeXML().

Referenced by writeXml().

long QgsVectorLayer::featureCount (  )  const [virtual]

Number of features in the layer.

This is necessary if features are added/deleted or the layer has been subsetted. If the data provider chooses not to support this feature, the total number of features can be returned.

Returns:
long containing number of features

Definition at line 1404 of file qgsvectorlayer.cpp.

References QgsVectorDataProvider::featureCount(), mDataProvider, and QgsDebugMsg.

Referenced by QgsGeometryAnalyzer::buffer(), QgsGeometryAnalyzer::centroids(), QgsGeometryAnalyzer::convexHull(), QgsGeometryAnalyzer::dissolve(), draw(), drawLabels(), drawRendererV2(), drawRendererV2Levels(), QgsOverlayAnalyzer::intersection(), and QgsGeometryAnalyzer::simplify().

long QgsVectorLayer::updateFeatureCount (  )  const [virtual]

This function does nothing useful, it's kept only for compatibility.

Todo:
to be removed

Definition at line 1415 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::setSubsetString ( QString  subset  )  [virtual]

Set the string (typically sql) used to define a subset of the layer.

Parameters:
subset The subset string. This may be the where clause of a sql statement or other defintion string specific to the underlying dataprovider and data store.
Returns:
true, when setting the subset string was successful, false otherwise (added in 1.4)

Definition at line 1481 of file qgsvectorlayer.cpp.

References QgsDataProvider::dataSourceUri(), mDataProvider, QgsMapLayer::mDataSource, QgsDebugMsg, QgsMapLayer::setCacheImage(), QgsDataProvider::setSubsetString(), and updateExtents().

QString QgsVectorLayer::subsetString (  )  [virtual]

Get the string (typically sql) used to define a subset of the layer.

Returns:
The subset string or QString::null if not implemented by the provider

Definition at line 1471 of file qgsvectorlayer.cpp.

References mDataProvider, QgsDebugMsg, and QgsDataProvider::subsetString().

void QgsVectorLayer::select ( QgsAttributeList  fetchAttributes,
QgsRectangle  rect = QgsRectangle(),
bool  fetchGeometry = true,
bool  useIntersect = false 
)

Select features with or without attributes in a given window.

Parameters:
fetchAttributes indizes of attributes to fetch
rect window (QgsRectangle() for all)
fetchGeometry fetch features with geometry
useIntersect fetch only features that actually intersect the window (not just the bounding box)

Definition at line 1533 of file qgsvectorlayer.cpp.

References mAddedAttributeIds, mAddedFeatures, mChangedGeometries, mDataProvider, mDeletedFeatureIds, mEditable, mFetchAddedFeaturesIt, mFetchAttributes, mFetchChangedGeomIt, mFetchConsidered, mFetchGeometry, mFetching, mFetchProvAttributes, mFetchRect, mUpdatedFields, and QgsVectorDataProvider::select().

bool QgsVectorLayer::nextFeature ( QgsFeature feature  ) 

bool QgsVectorLayer::featureAtId ( int  featureId,
QgsFeature f,
bool  fetchGeometries = true,
bool  fetchAttributes = true 
)

bool QgsVectorLayer::addFeature ( QgsFeature f,
bool  alsoUpdateExtent = true 
)

Adds a feature.

Parameters:
f feature to add
alsoUpdateExtent If True, will also go to the effort of e.g. updating the extents.
Returns:
True in case of success and False in case of error

Definition at line 1776 of file qgsvectorlayer.cpp.

References QgsVectorDataProvider::AddFeatures, QgsVectorDataProvider::capabilities(), editFeatureAdd(), QgsFeature::geometry(), QgsFeature::id(), isEditable(), mCachedGeometries, mDataProvider, QgsDebugMsg, QgsFeature::setFeatureId(), setModified(), and updateExtents().

Referenced by addFeatures().

bool QgsVectorLayer::insertVertex ( double  x,
double  y,
int  atFeatureId,
int  beforeVertex 
)

Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries.

Definition at line 1820 of file qgsvectorlayer.cpp.

References editGeometryChange(), geometryType(), QgsGeometry::insertVertex(), mCachedGeometries, mChangedGeometries, mDataProvider, mEditable, QGis::NoGeometry, and setModified().

Referenced by insertSegmentVerticesForSnap().

bool QgsVectorLayer::moveVertex ( double  x,
double  y,
int  atFeatureId,
int  atVertex 
)

Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates.

Definition at line 1859 of file qgsvectorlayer.cpp.

References editGeometryChange(), geometryType(), mCachedGeometries, mChangedGeometries, mDataProvider, mEditable, QgsGeometry::moveVertex(), QGis::NoGeometry, and setModified().

bool QgsVectorLayer::deleteVertex ( int  atFeatureId,
int  atVertex 
)

bool QgsVectorLayer::deleteSelectedFeatures (  ) 

int QgsVectorLayer::addRing ( const QList< QgsPoint > &  ring  ) 

Adds a ring to polygon/multipolygon features.

Returns:
0 in case of success, 1 problem with feature type, 2 ring not closed, 3 ring not valid, 4 ring crosses existing rings, 5 no feature found where ring can be inserted

Definition at line 1973 of file qgsvectorlayer.cpp.

References QgsGeometry::addRing(), boundingBoxFromPointList(), editGeometryChange(), QgsFeature::geometry(), geometryType(), QgsFeature::id(), nextFeature(), QGis::NoGeometry, select(), setModified(), QgsRectangle::setXMaximum(), QgsRectangle::setXMinimum(), QgsRectangle::setYMaximum(), and QgsRectangle::setYMinimum().

int QgsVectorLayer::addIsland ( const QList< QgsPoint > &  ring  ) 

Adds a new island polygon to a multipolygon feature.

Returns:
0 in case of success, 1 if selected feature is not multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring not disjoint with existing rings, 4 if no feature was selected, 5 if several features are selected, 6 if selected geometry not found

Definition at line 2010 of file qgsvectorlayer.cpp.

References QgsGeometry::addIsland(), editGeometryChange(), featureAtId(), QgsFeature::geometryAndOwnership(), geometryType(), mAddedFeatures, mCachedGeometries, mChangedGeometries, mSelectedFeatureIds, QGis::NoGeometry, QgsDebugMsg, and setModified().

int QgsVectorLayer::translateFeature ( int  featureId,
double  dx,
double  dy 
)

Translates feature by dx, dy.

Parameters:
featureId id of the feature to translate
dx translation of x-coordinate
dy translation of y-coordinate
Returns:
0 in case of success

Definition at line 2087 of file qgsvectorlayer.cpp.

References editGeometryChange(), QgsVectorDataProvider::featureAtId(), QgsFeature::geometry(), geometryType(), mAddedFeatures, mCachedGeometries, mChangedGeometries, mDataProvider, QGis::NoGeometry, setModified(), and QgsGeometry::translate().

int QgsVectorLayer::splitFeatures ( const QList< QgsPoint > &  splitLine,
bool  topologicalEditing = false 
)

int QgsVectorLayer::removePolygonIntersections ( QgsGeometry geom  ) 

Changes the specified geometry such that it has no intersections with other polygon (or multipolygon) geometries in this vector layer.

Parameters:
geom geometry to modify
Returns:
0 in case of success

Definition at line 2257 of file qgsvectorlayer.cpp.

References QgsGeometry::boundingBox(), QgsFeature::geometry(), geometryType(), QgsGeometry::makeDifference(), nextFeature(), QGis::NoGeometry, QGis::Polygon, select(), and QgsGeometry::type().

Referenced by QgsGeometry::avoidIntersections().

int QgsVectorLayer::addTopologicalPoints ( QgsGeometry geom  ) 

Adds topological points for every vertex of the geometry.

Parameters:
geom the geometry where each vertex is added to segments of other features Note: geom is not going to be modified by the function
Returns:
0 in case of success

Definition at line 2292 of file qgsvectorlayer.cpp.

References QgsGeometry::asMultiPolygon(), QgsGeometry::asMultiPolyline(), QgsGeometry::asPolygon(), QgsGeometry::asPolyline(), geometryType(), QGis::NoGeometry, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPolygon, QGis::WKBPolygon25D, QgsGeometry::wkbType(), and wkbType().

Referenced by splitFeatures().

int QgsVectorLayer::addTopologicalPoints ( const QgsPoint p  ) 

Adds a vertex to segments which intersect point p but don't already have a vertex there.

If a feature already has a vertex at position p, no additional vertex is inserted. This method is useful for topological editing.

Parameters:
p position of the vertex
Returns:
0 in case of success

Definition at line 2399 of file qgsvectorlayer.cpp.

References QGis::Feet, geometryType(), insertSegmentVerticesForSnap(), QgsCoordinateReferenceSystem::mapUnits(), QgsMapLayer::mCRS, QGis::Meters, QGis::NoGeometry, QgsSnapper::SnapToSegment, QgsSnapper::SnapToVertex, and snapWithContext().

int QgsVectorLayer::insertSegmentVerticesForSnap ( const QList< QgsSnappingResult > &  snapResults  ) 

Inserts vertices to the snapped segments.

This is useful for topological editing if snap to segment is enabled.

Parameters:
snapResults results collected from the snapping operation
Returns:
0 in case of success

Definition at line 3930 of file qgsvectorlayer.cpp.

References geometryType(), insertVertex(), QGis::NoGeometry, QgsPoint::x(), and QgsPoint::y().

Referenced by addTopologicalPoints().

void QgsVectorLayer::enableLabels ( bool  on  ) 

Set labels on.

Definition at line 2466 of file qgsvectorlayer.cpp.

References mLabelOn.

Referenced by readSymbology().

bool QgsVectorLayer::hasLabelsEnabled ( void   )  const

Label is on.

Definition at line 2471 of file qgsvectorlayer.cpp.

References mLabelOn.

Referenced by readSymbology(), and writeSymbology().

bool QgsVectorLayer::isEditable (  )  const [virtual]

bool QgsVectorLayer::isReadOnly (  )  const [virtual]

Returns true if the provider is in read-only mode.

Note:
added in 1.6

Definition at line 4215 of file qgsvectorlayer.cpp.

References mReadOnly.

bool QgsVectorLayer::isModified (  )  const [virtual]

Returns true if the provider has been modified since the last commit.

Definition at line 4230 of file qgsvectorlayer.cpp.

References mModified.

Referenced by rollBack().

bool QgsVectorLayer::snapPoint ( QgsPoint point,
double  tolerance 
)

Snaps a point to the closest vertex if there is one within the snapping tolerance.

Parameters:
point The point which is set to the position of a vertex if there is one within the snapping tolerance. If there is no point within this tolerance, point is left unchanged.
tolerance The snapping tolerance
Returns:
true if point has been snapped, false if no vertex within search tolerance

Definition at line 3794 of file qgsvectorlayer.cpp.

References geometryType(), QGis::NoGeometry, QgsPoint::setX(), QgsPoint::setY(), QgsSnapper::SnapToVertex, and snapWithContext().

int QgsVectorLayer::snapWithContext ( const QgsPoint startPoint,
double  snappingTolerance,
QMultiMap< double, QgsSnappingResult > &  snappingResults,
QgsSnapper::SnappingType  snap_to 
)

Snaps to segment or vertex within given tolerance.

Parameters:
startPoint point to snap (in layer coordinates)
snappingTolerance distance tolerance for snapping
snappingResults snapping results. Key is the distance between startPoint and snapping target
snap_to to segment / to vertex
Returns:
0 in case of success

Definition at line 3819 of file qgsvectorlayer.cpp.

References QgsGeometry::boundingBox(), QgsRectangle::contains(), QgsFeature::geometry(), geometryType(), QgsFeature::id(), QgsRectangle::intersects(), mCachedGeometries, mCachedGeometriesRect, mDataProvider, nextFeature(), QGis::NoGeometry, QgsDebugMsg, select(), snapToGeometry(), QgsPoint::x(), and QgsPoint::y().

Referenced by addTopologicalPoints(), and snapPoint().

void QgsVectorLayer::reload (  )  [virtual]

Synchronises with changes in the datasource.

Note:
added in version 1.6

Reimplemented from QgsMapLayer.

Definition at line 906 of file qgsvectorlayer.cpp.

References mDataProvider, and QgsDataProvider::reloadData().

bool QgsVectorLayer::draw ( QgsRenderContext rendererContext  )  [virtual]

void QgsVectorLayer::drawLabels ( QgsRenderContext rendererContext  )  [virtual]

const QgsFieldMap & QgsVectorLayer::pendingFields (  )  const

QgsAttributeList QgsVectorLayer::pendingAllAttributesList (  ) 

int QgsVectorLayer::pendingFeatureCount (  ) 

returns feature count after commit

Definition at line 3248 of file qgsvectorlayer.cpp.

References QgsVectorDataProvider::featureCount(), mAddedFeatures, mDataProvider, and mDeletedFeatureIds.

bool QgsVectorLayer::setReadOnly ( bool  readonly = true  ) 

Make layer read-only (editing disabled) or not.

Returns:
false if the layer is in editing yet
Note:
added in 1.6

Definition at line 4220 of file qgsvectorlayer.cpp.

References mEditable, and mReadOnly.

void QgsVectorLayer::setModified ( bool  modified = true,
bool  onlyGeometryWasModified = false 
)

bool QgsVectorLayer::startEditing (  ) 

bool QgsVectorLayer::changeGeometry ( int  fid,
QgsGeometry geom 
)

change feature's geometry

Note:
added in version 1.2

Definition at line 3088 of file qgsvectorlayer.cpp.

References editGeometryChange(), geometryType(), mCachedGeometries, mDataProvider, mEditable, QGis::NoGeometry, and setModified().

bool QgsVectorLayer::changeAttributeValue ( int  fid,
int  field,
QVariant  value,
bool  emitSignal = true 
)

changed an attribute value (but does not commit it)

Definition at line 3102 of file qgsvectorlayer.cpp.

References attributeValueChanged(), editAttributeChange(), isEditable(), and setModified().

bool QgsVectorLayer::addAttribute ( const QgsField field  ) 

add an attribute field (but does not commit it) returns true if the field was added

Note:
added in version 1.2

Definition at line 3116 of file qgsvectorlayer.cpp.

References attributeAdded(), isEditable(), mActiveCommand, mAddedAttributeIds, mDataProvider, mMaxUpdatedIndex, mUpdatedFields, QgsField::name(), setModified(), QgsUndoCommand::storeAttributeAdd(), and QgsVectorDataProvider::supportedType().

Referenced by addAttribute().

bool QgsVectorLayer::addAttribute ( QString  name,
QString  type 
)

add an attribute field (but does not commit it) returns true if the field was added

Note:
deprecated

Definition at line 3147 of file qgsvectorlayer.cpp.

References addAttribute(), mDataProvider, and QgsVectorDataProvider::supportedNativeTypes().

void QgsVectorLayer::addAttributeAlias ( int  attIndex,
QString  aliasString 
)

Sets an alias (a display name) for attributes to display in dialogs.

Note:
added in version 1.2

Definition at line 3157 of file qgsvectorlayer.cpp.

References layerModified(), and mAttributeAliasMap.

QString QgsVectorLayer::attributeAlias ( int  attributeIndex  )  const

Returns the alias of an attribute name or an empty string if there is no alias.

Note:
added in version 1.2

Definition at line 3163 of file qgsvectorlayer.cpp.

References mAttributeAliasMap.

Referenced by attributeDisplayName(), and QgsComposerAttributeTable::initializeAliasMap().

QString QgsVectorLayer::attributeDisplayName ( int  attributeIndex  )  const

Convenience function that returns the attribute alias if defined or the field name else.

Note:
added in version 1.2

Definition at line 3176 of file qgsvectorlayer.cpp.

References attributeAlias(), and pendingFields().

Referenced by QgsLegendModel::addVectorLayerItems(), and QgsAttributeAction::expandAction().

bool QgsVectorLayer::deleteAttribute ( int  attr  ) 

bool QgsVectorLayer::addFeatures ( QgsFeatureList  features,
bool  makeSelected = true 
)

Insert a copy of the given features into the layer (but does not commit it).

Definition at line 3680 of file qgsvectorlayer.cpp.

References addFeature(), QgsVectorDataProvider::AddFeatures, QgsVectorDataProvider::capabilities(), isEditable(), mDataProvider, mSelectedFeatureIds, selectionChanged(), QgsMapLayer::setCacheImage(), and updateExtents().

Referenced by splitFeatures().

bool QgsVectorLayer::deleteFeature ( int  fid  ) 

delete a feature from the layer (but does not commit it)

Definition at line 3220 of file qgsvectorlayer.cpp.

References editFeatureDelete(), featureDeleted(), isEditable(), mDeletedFeatureIds, mSelectedFeatureIds, and setModified().

Referenced by deleteSelectedFeatures().

bool QgsVectorLayer::commitChanges (  ) 

Attempts to commit any changes to disk.

Returns the result of the attempt. If a commit fails, the in-memory changes are left alone.

This allows editing to continue if the commit failed on e.g. a disallowed value in a Postgres database - the user can re-edit and try again.

The commits occur in distinct stages, (add attributes, add features, change attribute values, change geometries, delete features, delete attributes) so if a stage fails, it's difficult to roll back cleanly. Therefore any error message also includes which stage failed so that the user has some chance of repairing the damage cleanly.

Definition at line 3255 of file qgsvectorlayer.cpp.

References QgsVectorDataProvider::addAttributes(), QgsVectorDataProvider::AddAttributes, QgsVectorDataProvider::addFeatures(), QgsVectorDataProvider::AddFeatures, QgsVectorDataProvider::capabilities(), QgsVectorDataProvider::changeAttributeValues(), QgsVectorDataProvider::ChangeAttributeValues, QgsVectorDataProvider::ChangeGeometries, QgsVectorDataProvider::changeGeometryValues(), committedAttributesAdded(), committedAttributesDeleted(), committedAttributeValuesChanges(), committedFeaturesAdded(), committedFeaturesRemoved(), committedGeometriesChanges(), QgsVectorDataProvider::deleteAttributes(), QgsVectorDataProvider::DeleteAttributes, deleteCachedGeometries(), QgsVectorDataProvider::deleteFeatures(), QgsVectorDataProvider::DeleteFeatures, editingStopped(), QgsVectorDataProvider::fields(), QgsMapLayer::getLayerID(), QgsFeature::id(), isEditable(), mAddedAttributeIds, mAddedFeatures, mChangedAttributeValues, mChangedGeometries, mCommitErrors, mDataProvider, mDeletedAttributeIds, mDeletedFeatureIds, mEditable, mMaxUpdatedIndex, mUpdatedFields, QgsMapLayer::name(), QgsDebugMsg, QgsMapLayer::setCacheImage(), QgsFeature::setGeometry(), setModified(), triggerRepaint(), QgsMapLayer::undoStack(), and QgsDataProvider::updateExtents().

const QStringList & QgsVectorLayer::commitErrors (  ) 

Definition at line 3552 of file qgsvectorlayer.cpp.

References mCommitErrors.

bool QgsVectorLayer::rollBack (  ) 

QgsVectorLayer::EditType QgsVectorLayer::editType ( int  idx  ) 

void QgsVectorLayer::setEditType ( int  idx,
EditType  edit 
)

set edit type

Definition at line 4250 of file qgsvectorlayer.cpp.

References mEditTypes, QgsMapLayer::name(), and pendingFields().

void QgsVectorLayer::setCheckedState ( int  idx,
QString  checked,
QString  notChecked 
)

set string representing 'true' for a checkbox (added in 1.4)

Definition at line 4691 of file qgsvectorlayer.cpp.

References mCheckedStates, QgsMapLayer::name(), and pendingFields().

QPair< QString, QString > QgsVectorLayer::checkedState ( int  idx  ) 

return string representing 'true' for a checkbox (added in 1.4)

Definition at line 4698 of file qgsvectorlayer.cpp.

References mCheckedStates, QgsMapLayer::name(), and pendingFields().

Referenced by QgsAttributeEditor::retrieveValue(), and QgsAttributeEditor::setValue().

QString QgsVectorLayer::editForm (  ) 

get edit form (added in 1.4)

Definition at line 4257 of file qgsvectorlayer.cpp.

References mEditForm.

void QgsVectorLayer::setEditForm ( QString  ui  ) 

set edit form (added in 1.4)

Definition at line 4262 of file qgsvectorlayer.cpp.

References mEditForm.

QString QgsVectorLayer::annotationForm (  )  const [inline]

get annotation form (added in 1.5)

Definition at line 523 of file qgsvectorlayer.h.

Referenced by QgsFormAnnotationItem::QgsFormAnnotationItem().

void QgsVectorLayer::setAnnotationForm ( const QString &  ui  ) 

set annotation form for layer (added in 1.5)

Definition at line 4267 of file qgsvectorlayer.cpp.

References mAnnotationForm.

QString QgsVectorLayer::editFormInit (  ) 

get python function for edit form initialization (added in 1.4)

Definition at line 4272 of file qgsvectorlayer.cpp.

References mEditFormInit.

void QgsVectorLayer::setEditFormInit ( QString  function  ) 

set python function for edit form initialization (added in 1.4)

Definition at line 4277 of file qgsvectorlayer.cpp.

References mEditFormInit.

QMap< QString, QVariant > & QgsVectorLayer::valueMap ( int  idx  ) 

access value map

Definition at line 4282 of file qgsvectorlayer.cpp.

References mValueMaps, pendingFields(), and QgsDebugMsg.

Referenced by QgsAttributeEditor::createAttributeEditor().

QgsVectorLayer::RangeData & QgsVectorLayer::range ( int  idx  ) 

access range

Definition at line 4298 of file qgsvectorlayer.cpp.

References mRanges, pendingFields(), and QgsDebugMsg.

Referenced by QgsAttributeEditor::createAttributeEditor().

void QgsVectorLayer::addOverlay ( QgsVectorOverlay overlay  ) 

Adds a new overlay to this class.

QgsVectorLayer takes ownership of the object

Note:
this method was added in version 1.1

Definition at line 4314 of file qgsvectorlayer.cpp.

References mOverlays.

void QgsVectorLayer::removeOverlay ( const QString &  typeName  ) 

Removes all overlays of a given type.

Note:
this method was added in version 1.1

Definition at line 4319 of file qgsvectorlayer.cpp.

References mOverlays.

void QgsVectorLayer::vectorOverlays ( QList< QgsVectorOverlay * > &  overlayList  ) 

Returns pointers to the overlays of this layer.

Note:
this method was added in version 1.1

Definition at line 4330 of file qgsvectorlayer.cpp.

References mOverlays.

Referenced by QgsMapRenderer::render().

QgsVectorOverlay * QgsVectorLayer::findOverlayByType ( const QString &  typeName  ) 

Returns the (first) overlay of a type, e.g.

diagram or label

Note:
this method was added in version 1.1

Definition at line 4335 of file qgsvectorlayer.cpp.

References mOverlays.

void QgsVectorLayer::beginEditCommand ( QString  text  ) 

Create edit command for undo/redo operations.

Parameters:
text text which is to be displayed in undo window

Definition at line 4456 of file qgsvectorlayer.cpp.

References mActiveCommand.

void QgsVectorLayer::endEditCommand (  ) 

Finish edit command and add it to undo/redo stack.

Definition at line 4464 of file qgsvectorlayer.cpp.

References mActiveCommand, and QgsMapLayer::undoStack().

void QgsVectorLayer::destroyEditCommand (  ) 

Destroy active command and reverts all changes in it.

Definition at line 4474 of file qgsvectorlayer.cpp.

References mActiveCommand, and undoEditCommand().

void QgsVectorLayer::undoEditCommand ( QgsUndoCommand cmd  ) 

void QgsVectorLayer::redoEditCommand ( QgsUndoCommand cmd  ) 

int QgsVectorLayer::fieldNameIndex ( const QString &  fieldName  )  const

void QgsVectorLayer::drawVertexMarker ( double  x,
double  y,
QPainter &  p,
QgsVectorLayer::VertexMarkerType  type,
int  vertexSize 
) [static]

Draws a vertex symbol at (screen) coordinates x, y.

(Useful to assist vertex editing.)

Note:
public and static from version 1.4

Definition at line 1127 of file qgsvectorlayer.cpp.

References Cross, and SemiTransparentCircle.

Referenced by drawLineString(), drawPolygon(), and QgsFeatureRendererV2::renderVertexMarker().

void QgsVectorLayer::select ( int  featureId,
bool  emitSignal = true 
) [slot]

Select feature by its ID, optionally emit signal selectionChanged().

Definition at line 1143 of file qgsvectorlayer.cpp.

References mSelectedFeatureIds, selectionChanged(), and QgsMapLayer::setCacheImage().

void QgsVectorLayer::deselect ( int  featureId,
bool  emitSignal = true 
) [slot]

Deselect feature by its ID, optionally emit signal selectionChanged().

Definition at line 1156 of file qgsvectorlayer.cpp.

References mSelectedFeatureIds, selectionChanged(), and QgsMapLayer::setCacheImage().

Referenced by invertSelectionInRectangle().

void QgsVectorLayer::removeSelection ( bool  emitSignal = true  )  [slot]

Clear selection.

Definition at line 1246 of file qgsvectorlayer.cpp.

References mSelectedFeatureIds, selectionChanged(), and QgsMapLayer::setCacheImage().

Referenced by invertSelection(), and select().

void QgsVectorLayer::triggerRepaint (  )  [slot]

void QgsVectorLayer::updateExtents (  )  [virtual, slot]

void QgsVectorLayer::selectionChanged (  )  [signal]

void QgsVectorLayer::layerModified ( bool  onlyGeometry  )  [signal]

This signal is emitted when modifications has been done on layer.

Referenced by addAttributeAlias(), and setModified().

void QgsVectorLayer::editingStarted (  )  [signal]

Referenced by startEditing().

void QgsVectorLayer::editingStopped (  )  [signal]

Referenced by commitChanges(), and rollBack().

void QgsVectorLayer::attributeAdded ( int  idx  )  [signal]

Referenced by addAttribute(), and rollBack().

void QgsVectorLayer::attributeDeleted ( int  idx  )  [signal]

Referenced by deleteAttribute(), and rollBack().

void QgsVectorLayer::featureDeleted ( int  fid  )  [signal]

Referenced by deleteFeature().

void QgsVectorLayer::layerDeleted (  )  [signal]

Referenced by ~QgsVectorLayer().

void QgsVectorLayer::attributeValueChanged ( int  fid,
int  idx,
const QVariant &   
) [signal]

void QgsVectorLayer::committedAttributesDeleted ( const QString &  layerId,
const QgsAttributeIds deletedAttributeIds 
) [signal]

Signals emitted after committing changes.

Referenced by commitChanges().

void QgsVectorLayer::committedAttributesAdded ( const QString &  layerId,
const QList< QgsField > &  addedAttributes 
) [signal]

Referenced by commitChanges().

void QgsVectorLayer::committedFeaturesAdded ( const QString &  layerId,
const QgsFeatureList addedFeatures 
) [signal]

Referenced by commitChanges().

void QgsVectorLayer::committedFeaturesRemoved ( const QString &  layerId,
const QgsFeatureIds deletedFeatureIds 
) [signal]

Referenced by commitChanges().

void QgsVectorLayer::committedAttributeValuesChanges ( const QString &  layerId,
const QgsChangedAttributesMap changedAttributesValues 
) [signal]

Referenced by commitChanges().

void QgsVectorLayer::committedGeometriesChanges ( const QString &  layerId,
const QgsGeometryMap changedGeometries 
) [signal]

Referenced by commitChanges().

QgsVectorLayer& QgsVectorLayer::operator= ( QgsVectorLayer const &  rhs  )  [private]

vector layers are not copyable

bool QgsVectorLayer::setDataProvider ( QString const &  provider  )  [private]

void QgsVectorLayer::drawFeature ( QgsRenderContext renderContext,
QgsFeature fet,
QImage *  marker 
) [private]

void QgsVectorLayer::transformPoint ( double &  x,
double &  y,
const QgsMapToPixel mtp,
const QgsCoordinateTransform ct 
) [inline, private]

Convenience function to transform the given point.

Definition at line 4174 of file qgsvectorlayer.cpp.

References QgsMapToPixel::transformInPlace(), and QgsCoordinateTransform::transformInPlace().

Referenced by drawFeature().

void QgsVectorLayer::transformPoints ( std::vector< double > &  x,
std::vector< double > &  y,
std::vector< double > &  z,
QgsRenderContext renderContext 
) [inline, private]

unsigned char * QgsVectorLayer::drawLineString ( unsigned char *  WKBlinestring,
QgsRenderContext renderContext 
) [private]

unsigned char * QgsVectorLayer::drawPolygon ( unsigned char *  WKBpolygon,
QgsRenderContext renderContext 
) [private]

int QgsVectorLayer::findFreeId (  )  [private]

Goes through all features and finds a free id (e.g.

to give it temporarily to a not-commited feature)

void QgsVectorLayer::deleteCachedGeometries (  )  [private]

Deletes the geometries in mCachedGeometries.

Definition at line 1120 of file qgsvectorlayer.cpp.

References mCachedGeometries, and mCachedGeometriesRect.

Referenced by commitChanges(), draw(), rollBack(), and ~QgsVectorLayer().

void QgsVectorLayer::snapToGeometry ( const QgsPoint startPoint,
int  featureId,
QgsGeometry geom,
double  sqrSnappingTolerance,
QMultiMap< double, QgsSnappingResult > &  snappingResults,
QgsSnapper::SnappingType  snap_to 
) const [private]

Snaps to a geometry and adds the result to the multimap if it is within the snapping result.

Parameters:
startPoint start point of the snap
featureId id of feature
geom geometry to snap
sqrSnappingTolerance squared search tolerance of the snap
snappingResults list to which the result is appended
snap_to snap to vertex or to segment

Definition at line 3870 of file qgsvectorlayer.cpp.

References QgsSnappingResult::afterVertex, QgsSnappingResult::afterVertexNr, QgsSnappingResult::beforeVertex, QgsSnappingResult::beforeVertexNr, QgsGeometry::closestSegmentWithContext(), QgsGeometry::closestVertex(), geometryType(), QgsSnappingResult::layer, QGis::Point, QgsSnappingResult::snappedAtGeometry, QgsSnappingResult::snappedVertex, QgsSnappingResult::snappedVertexNr, QgsSnapper::SnapToSegment, QgsSnapper::SnapToVertex, QgsSnapper::SnapToVertexAndSegment, and QgsGeometry::vertexAt().

Referenced by snapWithContext().

int QgsVectorLayer::boundingBoxFromPointList ( const QList< QgsPoint > &  list,
double &  xmin,
double &  ymin,
double &  xmax,
double &  ymax 
) const [private]

Little helper function that gives bounding box from a list of points.

Returns:
0 in case of success

Definition at line 3953 of file qgsvectorlayer.cpp.

References MathUtils::max().

Referenced by addRing(), and splitFeatures().

QgsVectorLayer::VertexMarkerType QgsVectorLayer::currentVertexMarkerType (  )  [static, private]

Reads vertex marker type from settings.

Definition at line 3988 of file qgsvectorlayer.cpp.

References Cross, NoMarker, and SemiTransparentCircle.

Referenced by draw(), and drawRendererV2Levels().

int QgsVectorLayer::currentVertexMarkerSize (  )  [static, private]

Reads vertex marker size from settings.

Definition at line 4006 of file qgsvectorlayer.cpp.

Referenced by draw(), and drawRendererV2Levels().

void QgsVectorLayer::updateFeatureAttributes ( QgsFeature f,
bool  all = false 
) [private]

void QgsVectorLayer::updateFeatureGeometry ( QgsFeature f  )  [private]

Update feature with uncommited geometry updates.

Definition at line 1526 of file qgsvectorlayer.cpp.

References QgsFeature::id(), mChangedGeometries, and QgsFeature::setGeometry().

Referenced by selectedFeatures().

void QgsVectorLayer::editGeometryChange ( int  featureId,
QgsGeometry geometry 
) [private]

Record changed geometry, store in active command (if any).

Definition at line 4374 of file qgsvectorlayer.cpp.

References mActiveCommand, mChangedGeometries, and QgsUndoCommand::storeGeometryChange().

Referenced by addIsland(), addRing(), changeGeometry(), deleteVertex(), insertVertex(), moveVertex(), splitFeatures(), and translateFeature().

void QgsVectorLayer::editFeatureAdd ( QgsFeature feature  )  [private]

Record added feature, store in active command (if any).

Definition at line 4384 of file qgsvectorlayer.cpp.

References mActiveCommand, mAddedFeatures, and QgsUndoCommand::storeFeatureAdd().

Referenced by addFeature().

void QgsVectorLayer::editFeatureDelete ( int  featureId  )  [private]

Record deleted feature, store in active command (if any).

Definition at line 4393 of file qgsvectorlayer.cpp.

References mActiveCommand, mDeletedFeatureIds, and QgsUndoCommand::storeFeatureDelete().

Referenced by deleteFeature().

void QgsVectorLayer::editAttributeChange ( int  featureId,
int  field,
QVariant  value 
) [private]

Record changed attribute, store in active command (if any).

Definition at line 4402 of file qgsvectorlayer.cpp.

References mActiveCommand, mAddedFeatures, mChangedAttributeValues, and QgsUndoCommand::storeAttributeChange().

Referenced by changeAttributeValue().

void QgsVectorLayer::stopRendererV2 ( QgsRenderContext rendererContext,
QgsSingleSymbolRendererV2 selRenderer 
) [private]

Stop version 2 renderer and selected renderer (if required).

Definition at line 4721 of file qgsvectorlayer.cpp.

References mRendererV2, QgsSingleSymbolRendererV2::stopRender(), and QgsFeatureRendererV2::stopRender().

Referenced by drawRendererV2Levels().


Member Data Documentation

Update threshold for drawing features as they are read.

A value of zero indicates that no features will be drawn until all have been read

Definition at line 728 of file qgsvectorlayer.h.

Referenced by draw(), and drawRendererV2().

QString QgsVectorLayer::mDisplayField [private]

index of the primary label field

Definition at line 734 of file qgsvectorlayer.h.

Referenced by displayField(), and setDisplayField().

QString QgsVectorLayer::mProviderKey [private]

Data provider key.

Definition at line 737 of file qgsvectorlayer.h.

Referenced by providerType(), QgsVectorLayer(), readXml(), and setDataProvider().

The user-defined actions that are accessed from the Identify Results dialog box.

Definition at line 740 of file qgsvectorlayer.h.

Referenced by QgsVectorLayer(), readSymbology(), writeSymbology(), and ~QgsVectorLayer().

bool QgsVectorLayer::mEditable [private]

bool QgsVectorLayer::mReadOnly [private]

Flag indicating whether the layer is in read-only mode (editing disabled) or not.

Definition at line 746 of file qgsvectorlayer.h.

Referenced by isReadOnly(), setReadOnly(), and startEditing().

bool QgsVectorLayer::mModified [private]

Flag indicating whether the layer has been modified since the last commit.

Definition at line 749 of file qgsvectorlayer.h.

Referenced by isModified(), and setModified().

cache of the committed geometries retrieved *for the current display*

Definition at line 752 of file qgsvectorlayer.h.

Referenced by addFeature(), addIsland(), changeGeometry(), deleteCachedGeometries(), deleteVertex(), draw(), drawRendererV2(), drawRendererV2Levels(), insertVertex(), moveVertex(), snapWithContext(), splitFeatures(), and translateFeature().

extent for which there are cached geometries

Definition at line 755 of file qgsvectorlayer.h.

Referenced by deleteCachedGeometries(), draw(), and snapWithContext().

Set holding the feature IDs that are activated.

Note that if a feature subsequently gets deleted (i.e. by its addition to mDeletedFeatureIds), it always needs to be removed from mSelectedFeatureIds as well.

Definition at line 761 of file qgsvectorlayer.h.

Referenced by addFeatures(), addIsland(), boundingBoxOfSelected(), deleteFeature(), deleteSelectedFeatures(), deselect(), draw(), drawLabels(), drawRendererV2(), drawRendererV2Levels(), invertSelection(), invertSelectionInRectangle(), removeSelection(), select(), selectedFeatureCount(), selectedFeatures(), selectedFeaturesIds(), and setSelectedFeatures().

Deleted feature IDs which are not commited.

Note a feature can be added and then deleted again before the change is committed - in that case the added feature would be removed from mAddedFeatures only and *not* entered here.

Definition at line 767 of file qgsvectorlayer.h.

Referenced by commitChanges(), deleteFeature(), editFeatureDelete(), featureAtId(), pendingFeatureCount(), redoEditCommand(), rollBack(), select(), undoEditCommand(), and updateExtents().

New features which are not commited.

Note a feature can be added and then changed, therefore the details here can be overridden by mChangedAttributeValues and mChangedGeometries.

Definition at line 772 of file qgsvectorlayer.h.

Referenced by addIsland(), commitChanges(), editAttributeChange(), editFeatureAdd(), featureAtId(), nextFeature(), pendingFeatureCount(), redoEditCommand(), rollBack(), select(), selectedFeatures(), translateFeature(), undoEditCommand(), and updateExtents().

Changed attributes values which are not commited.

Definition at line 775 of file qgsvectorlayer.h.

Referenced by commitChanges(), editAttributeChange(), redoEditCommand(), rollBack(), undoEditCommand(), and updateFeatureAttributes().

deleted attributes fields which are not commited

Definition at line 778 of file qgsvectorlayer.h.

Referenced by commitChanges(), deleteAttribute(), redoEditCommand(), rollBack(), and undoEditCommand().

added attributes fields which are not commited

Definition at line 781 of file qgsvectorlayer.h.

Referenced by addAttribute(), commitChanges(), deleteAttribute(), redoEditCommand(), rollBack(), select(), and undoEditCommand().

QMap<int, QString> QgsVectorLayer::mAttributeAliasMap [private]

Map that stores the aliases for attributes.

Key is the attribute index and value the alias for that attribute

Definition at line 790 of file qgsvectorlayer.h.

Referenced by addAttributeAlias(), attributeAlias(), deleteAttribute(), readSymbology(), and writeSymbology().

max field index

Definition at line 793 of file qgsvectorlayer.h.

Referenced by addAttribute(), commitChanges(), rollBack(), and startEditing().

int QgsVectorLayer::mWkbType [private]

Geometry type as defined in enum WkbType (qgis.h).

Definition at line 796 of file qgsvectorlayer.h.

Referenced by setDataProvider(), and wkbType().

Renderer object which holds the information about how to display the features.

Definition at line 801 of file qgsvectorlayer.h.

Referenced by copySymbologySettings(), draw(), drawLabels(), drawLineString(), drawPolygon(), readSymbology(), renderer(), setRenderer(), writeSymbology(), and ~QgsVectorLayer().

whether to use V1 or V2 renderer

Definition at line 807 of file qgsvectorlayer.h.

Referenced by draw(), isUsingRendererV2(), QgsVectorLayer(), setUsingRendererV2(), and writeSymbology().

bool QgsVectorLayer::mLabelOn [private]

Display labels.

Definition at line 813 of file qgsvectorlayer.h.

Referenced by drawLabels(), enableLabels(), hasLabelsEnabled(), and setDataProvider().

The current type of editing marker.

Definition at line 816 of file qgsvectorlayer.h.

Referenced by draw(), drawLineString(), and drawPolygon().

The current size of editing marker.

Definition at line 819 of file qgsvectorlayer.h.

Referenced by draw(), drawLineString(), and drawPolygon().

Flag if the vertex markers should be drawn only for selection (true) or for all features (false).

Definition at line 822 of file qgsvectorlayer.h.

Referenced by draw().

List of overlays.

Vector overlays will be rendered on top of all maplayers

Definition at line 825 of file qgsvectorlayer.h.

Referenced by addOverlay(), findOverlayByType(), removeOverlay(), vectorOverlays(), writeSymbology(), and ~QgsVectorLayer().

QStringList QgsVectorLayer::mCommitErrors [private]

Definition at line 827 of file qgsvectorlayer.h.

Referenced by commitChanges(), and commitErrors().

QMap< QString, EditType > QgsVectorLayer::mEditTypes [private]

Definition at line 829 of file qgsvectorlayer.h.

Referenced by editType(), readSymbology(), setEditType(), and writeSymbology().

QMap< QString, QMap<QString, QVariant> > QgsVectorLayer::mValueMaps [private]

Definition at line 830 of file qgsvectorlayer.h.

Referenced by readSymbology(), valueMap(), and writeSymbology().

QMap< QString, RangeData > QgsVectorLayer::mRanges [private]

Definition at line 831 of file qgsvectorlayer.h.

Referenced by range(), readSymbology(), and writeSymbology().

QMap< QString, QPair<QString, QString> > QgsVectorLayer::mCheckedStates [private]

Definition at line 832 of file qgsvectorlayer.h.

Referenced by checkedState(), readSymbology(), setCheckedState(), and writeSymbology().

QString QgsVectorLayer::mEditForm [private]

Definition at line 834 of file qgsvectorlayer.h.

Referenced by editForm(), readSymbology(), setEditForm(), and writeSymbology().

QString QgsVectorLayer::mEditFormInit [private]

Definition at line 834 of file qgsvectorlayer.h.

Referenced by editFormInit(), readSymbology(), setEditFormInit(), and writeSymbology().

Definition at line 836 of file qgsvectorlayer.h.

Referenced by readSymbology(), setAnnotationForm(), and writeSymbology().

bool QgsVectorLayer::mFetching [private]

Definition at line 838 of file qgsvectorlayer.h.

Referenced by nextFeature(), and select().

Definition at line 839 of file qgsvectorlayer.h.

Referenced by nextFeature(), and select().

Definition at line 840 of file qgsvectorlayer.h.

Referenced by nextFeature(), select(), and updateFeatureAttributes().

Definition at line 841 of file qgsvectorlayer.h.

Referenced by nextFeature(), and select().

Definition at line 842 of file qgsvectorlayer.h.

Referenced by nextFeature(), and select().

QSet<int> QgsVectorLayer::mFetchConsidered [private]

Definition at line 844 of file qgsvectorlayer.h.

Referenced by nextFeature(), and select().

QgsGeometryMap::iterator QgsVectorLayer::mFetchChangedGeomIt [private]

Definition at line 845 of file qgsvectorlayer.h.

Referenced by nextFeature(), and select().

QgsFeatureList::iterator QgsVectorLayer::mFetchAddedFeaturesIt [private]

Definition at line 846 of file qgsvectorlayer.h.

Referenced by nextFeature(), and select().


The documentation for this class was generated from the following files:

Generated on Sat Feb 4 19:17:58 2012 for Quantum GIS API Documentation by  doxygen 1.5.6