mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
snapping tolerance from QgsProject, line color and width will follow
git-svn-id: http://svn.osgeo.org/qgis/trunk@2580 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
4f90677ec0
commit
1765d0cca2
@ -87,6 +87,7 @@
|
||||
#include "qgsmaplayerinterface.h"
|
||||
#include "qgsmarkersymbol.h"
|
||||
#include "qgspolygonsymbol.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsmaplayerregistry.h"
|
||||
|
||||
@ -1319,7 +1320,7 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
|
||||
}
|
||||
|
||||
//snap point to points within the vector layer snapping tolerance
|
||||
vlayer->snapPoint(idPoint);
|
||||
vlayer->snapPoint(idPoint,QgsProject::instance()->readDoubleEntry("Digitizing","/Tolerance",0));
|
||||
|
||||
QgsFeature* f = new QgsFeature(0,"WKBPoint");
|
||||
int size=5+2*sizeof(double);
|
||||
@ -1378,7 +1379,7 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
|
||||
}
|
||||
|
||||
QgsPoint digitisedpoint=mCanvasProperties->coordXForm->toMapCoordinates(e->x(), e->y());
|
||||
vlayer->snapPoint(digitisedpoint);
|
||||
vlayer->snapPoint(digitisedpoint,QgsProject::instance()->readDoubleEntry("Digitizing","/Tolerance",0));
|
||||
mCaptureList.push_back(digitisedpoint);
|
||||
if(mCaptureList.size()>1)
|
||||
{
|
||||
|
@ -97,7 +97,6 @@ QgsVectorLayer::QgsVectorLayer(QString vectorLayerPath,
|
||||
m_renderer(0),
|
||||
m_propertiesDialog(0),
|
||||
m_rendererDialog(0),
|
||||
mSnappingTolerance(0),
|
||||
ir(0), // initialize the identify results pointer
|
||||
mEditable(false),
|
||||
mModified(false)
|
||||
@ -1920,20 +1919,20 @@ bool QgsVectorLayer::rollBack()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::snapPoint(QgsPoint& point)
|
||||
bool QgsVectorLayer::snapPoint(QgsPoint& point, double tolerance)
|
||||
{
|
||||
if(mSnappingTolerance<=0||!dataProvider)
|
||||
if(tolerance<=0||!dataProvider)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
double mindist=mSnappingTolerance*mSnappingTolerance;//current minimum distance
|
||||
double mindist=tolerance*tolerance;//current minimum distance
|
||||
double mindistx=point.x();
|
||||
double mindisty=point.y();
|
||||
QgsFeature* fet;
|
||||
QgsPoint vertexFeature;//the closest vertex of a feature
|
||||
double minvertexdist;//the distance between 'point' and 'vertexFeature'
|
||||
|
||||
QgsRect selectrect(point.x()-mSnappingTolerance,point.y()-mSnappingTolerance,point.x()+mSnappingTolerance,point.y()+mSnappingTolerance);
|
||||
QgsRect selectrect(point.x()-tolerance,point.y()-tolerance,point.x()+tolerance,point.y()+tolerance);
|
||||
dataProvider->reset();
|
||||
dataProvider->select(&selectrect);
|
||||
while ((fet = dataProvider->getNextFeature(false)))
|
||||
@ -2124,7 +2123,7 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
|
||||
p->setPen ( pen );
|
||||
p->setBrush ( Qt::NoBrush );
|
||||
for (idx = 0; idx < *numRings; idx++) {
|
||||
p->drawPolygon( *pa, FALSE, ringStart[idx], ringNumPoints[idx]);
|
||||
p->drawPolygon( *pa, FALSE, ringStart[idx], ringNumPoints[idx]);
|
||||
}
|
||||
|
||||
delete pa;
|
||||
|
@ -268,11 +268,9 @@ class QgsVectorLayer : public QgsMapLayer
|
||||
/**Snaps a point to the closest vertex if there is one within the snapping tolerance (mSnappingTolerance)
|
||||
@param 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.
|
||||
@param tolerance the snapping tolerance
|
||||
@return true if the position of point has been changed and false else*/
|
||||
bool snapPoint(QgsPoint& point);
|
||||
|
||||
/**Sets the snapping tolerance for digitizing*/
|
||||
void setSnappingTolerance(double tol){mSnappingTolerance=tol;}
|
||||
bool snapPoint(QgsPoint& point, double tolerance);
|
||||
|
||||
protected:
|
||||
/**Pointer to the table display object if there is one, else a pointer to 0*/
|
||||
@ -293,8 +291,6 @@ protected:
|
||||
QgsDlgVectorLayerProperties *m_propertiesDialog;
|
||||
/**Widget to set the symbology properties*/
|
||||
QDialog *m_rendererDialog;
|
||||
/**Snapping tolerance for digitizing*/
|
||||
double mSnappingTolerance;
|
||||
/**Goes through all features and finds a free id (e.g. to give it temporarily to a not-commited feature)*/
|
||||
int findFreeId();
|
||||
/**Writes the changes to disk*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user