Skip to content
Permalink
Browse files
move vertex for postgis point/multipoint layers
git-svn-id: http://svn.osgeo.org/qgis/trunk@5644 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jul 27, 2006
1 parent a7c8404 commit fdbaf80d2e194b5f6d17e9f46a708b66e42d5bb8
Showing with 87 additions and 69 deletions.
  1. +1 −1 src/core/qgsgeometry.cpp
  2. +4 −1 src/gui/qgisapp.cpp
  3. +81 −67 src/gui/qgsmaptoolvertexedit.cpp
  4. +1 −0 src/legend/qgslegend.cpp
@@ -238,7 +238,7 @@ QgsPoint QgsGeometry::closestVertex(const QgsPoint& point, QgsGeometryVertexInde
case QGis::WKBPoint:
x = *((double *) (mGeometry + 5));
y = *((double *) (mGeometry + 5 + sizeof(double)));
sqrDist = point.sqrDist(x, y);
actdist = point.sqrDist(x, y);
vertexnr = 0;
break;

@@ -4667,7 +4667,10 @@ void QgisApp::activateDeactivateLayerRelatedActions(const QgsMapLayer* layer)
mActionCapturePolygon->setEnabled(false);
mActionAddVertex->setEnabled(false);
mActionDeleteVertex->setEnabled(false);
mActionMoveVertex->setEnabled(false);
if(dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries)
{
mActionMoveVertex->setEnabled(true);
}
return;
}
else if(vlayer->vectorType() == QGis::Line)
@@ -110,32 +110,32 @@ void QgsMapToolVertexEdit::canvasPressEvent(QMouseEvent * e)
#ifdef QGISDEBUG
std::cout << "QgsMapCanvas::mousePressEvent: QGis::AddVertex." << std::endl;
#endif

//Find nearest segment of the selected line, move that node to the mouse location
if (!snapSegmentWithContext(point))
{
QMessageBox::warning(0, "Error",
QObject::tr("Could not snap segment. Have you set the tolerance in Settings > Project Properties > General?"),
QMessageBox::Ok, Qt::NoButton);
return;
}

index = mSnappedBeforeVertex;
// Get the endpoint of the snapped-to segment
mSnappedAtGeometry.vertexAt(x2, y2, index);
// Get the startpoint of the snapped-to segment
index.decrement_back();
mStartPointValid = mSnappedAtGeometry.vertexAt(x1, y1, index);
createRubberBand();
if (mStartPointValid)
{
mRubberBand->addPoint(QgsPoint(x1,y1));
}
mRubberBand->addPoint(toMapCoords(e->pos()));
mRubberBand->addPoint(QgsPoint(x2,y2));
//Find nearest segment of the selected line, move that node to the mouse location
if (!snapSegmentWithContext(point))
{
QMessageBox::warning(0, "Error",
QObject::tr("Could not snap segment. Have you set the tolerance in Settings > Project Properties > General?"),
QMessageBox::Ok, Qt::NoButton);
return;
}
index = mSnappedBeforeVertex;
// Get the endpoint of the snapped-to segment
mSnappedAtGeometry.vertexAt(x2, y2, index);
// Get the startpoint of the snapped-to segment
index.decrement_back();
mStartPointValid = mSnappedAtGeometry.vertexAt(x1, y1, index);
createRubberBand();
if (mStartPointValid)
{
mRubberBand->addPoint(QgsPoint(x1,y1));
}
mRubberBand->addPoint(toMapCoords(e->pos()));
mRubberBand->addPoint(QgsPoint(x2,y2));
}
else if (mTool == MoveVertex)
{
@@ -150,53 +150,67 @@ void QgsMapToolVertexEdit::canvasPressEvent(QMouseEvent * e)
QgsPoint snapPoint;

snapPoint = point;
if (!snapSegmentWithContext(snapPoint))
{
QMessageBox::warning(0, "Error",
QObject::tr("Could not snap segment. Have you set the tolerance in Settings > Project Properties > General?"),
QMessageBox::Ok, Qt::NoButton);
return;
}

snapPoint = point;
if (!snapVertexOfSnappedSegment(snapPoint))
{
QMessageBox::warning(0, "Error",
QObject::tr("Could not snap vertex. Have you set the tolerance in Settings > Project Properties > General?"),
QMessageBox::Ok, Qt::NoButton);
return;
}

#ifdef QGISDEBUG
qWarning("Creating rubber band for moveVertex");
#endif

index = mSnappedAtVertex;
createRubberBand();
if(mRubberBandIndex1 != -1)
{
rb1Index.push_back(mRubberBandIndex1);
mSnappedAtGeometry.vertexAt(x1, y1, rb1Index);
mRubberBand->addPoint(QgsPoint(x1,y1));
mStartPointValid = true;
}
else
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>(mCanvas->currentLayer());
if(vlayer->vectorType() == QGis::Point)//snap to point for point/multipoint layers
{
mStartPointValid = false;
}
if(mRubberBandIndex1 != -1 && mRubberBandIndex2 != -1)
{
mRubberBand->addPoint(toMapCoords(e->pos()));
if(!snapVertexWithContext(snapPoint))
{
QMessageBox::warning(0, "Error",
QObject::tr("Could not snap segment. Have you set the tolerance in Settings > Project Properties > General?"),
QMessageBox::Ok, Qt::NoButton);
return;
}
}
if(mRubberBandIndex2 != -1)
else //snap to segment and take the closest vertex in case of line/multiline/polygon/multipolygon layers
{
rb2Index.push_back(mRubberBandIndex2);
mSnappedAtGeometry.vertexAt(x2, y2, rb2Index);
mRubberBand->addPoint(QgsPoint(x2,y2));
}
if (!snapSegmentWithContext(snapPoint))
{
QMessageBox::warning(0, "Error",
QObject::tr("Could not snap segment. Have you set the tolerance in Settings > Project Properties > General?"),
QMessageBox::Ok, Qt::NoButton);
return;
}

snapPoint = point;
if (!snapVertexOfSnappedSegment(snapPoint))
{
QMessageBox::warning(0, "Error",
QObject::tr("Could not snap vertex. Have you set the tolerance in Settings > Project Properties > General?"),
QMessageBox::Ok, Qt::NoButton);
return;
}

#ifdef QGISDEBUG
qWarning("Creating rubber band for moveVertex");
#endif

index = mSnappedAtVertex;
createRubberBand();
if(mRubberBandIndex1 != -1)
{
rb1Index.push_back(mRubberBandIndex1);
mSnappedAtGeometry.vertexAt(x1, y1, rb1Index);
mRubberBand->addPoint(QgsPoint(x1,y1));
mStartPointValid = true;
}
else
{
mStartPointValid = false;
}
if(mRubberBandIndex1 != -1 && mRubberBandIndex2 != -1)
{
mRubberBand->addPoint(toMapCoords(e->pos()));
}
if(mRubberBandIndex2 != -1)
{
rb2Index.push_back(mRubberBandIndex2);
mSnappedAtGeometry.vertexAt(x2, y2, rb2Index);
mRubberBand->addPoint(QgsPoint(x2,y2));
}
#ifdef QGISDEBUG
qWarning("Creating rubber band for moveVertex");
#endif
}
}
else if (mTool == DeleteVertex)
{
@@ -954,6 +954,7 @@ bool QgsLegend::readXML(QDomNode& legendnode)
theLayer = new QgsLegendLayer(this, name);
lastGroup = 0;
}

childelem.attribute("open") == "true" ? expandItem(theLayer) : collapseItem(theLayer);

//set the checkbox of the legend layer to the right state

0 comments on commit fdbaf80

Please sign in to comment.