Skip to content

Commit

Permalink
Added a tool to cut holes into polygons/multipolygons. Made QgsMapToo…
Browse files Browse the repository at this point in the history
…lCapture a base class of QgsMapToolAddRing and QgsMapToolAddFeature. Many bugfixes, e.g. it should now be possible to edit a reprojected layer (but the snapping distance needs to be given in the source units of the edited layer)

git-svn-id: http://svn.osgeo.org/qgis/trunk@6942 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 13, 2007
1 parent b93ef15 commit 45b045f
Show file tree
Hide file tree
Showing 20 changed files with 1,027 additions and 555 deletions.
Binary file added images/themes/default/mActionAddRing.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -26,6 +26,8 @@ qgslabeldialog.cpp
qgslinestyledialog.cpp
qgslinestylewidget.cpp
qgsludialog.cpp
qgsmaptooladdfeature.cpp
qgsmaptooladdring.cpp
qgsmaptoolcapture.cpp
qgsmaptoolidentify.cpp
qgsmaptoolselect.cpp
Expand Down
31 changes: 27 additions & 4 deletions src/app/qgisapp.cpp
Expand Up @@ -144,7 +144,8 @@
//
// Map tools
//
#include "qgsmaptoolcapture.h"
#include "qgsmaptooladdfeature.h"
#include "qgsmaptooladdring.h"
#include "qgsmaptoolidentify.h"
#include "qgsmaptoolpan.h"
#include "qgsmaptoolselect.h"
Expand Down Expand Up @@ -748,6 +749,11 @@ void QgisApp::createActions()
connect(mActionMoveVertex, SIGNAL(triggered()), this, SLOT(moveVertex()));
mActionMoveVertex->setEnabled(false);

mActionAddRing = new QAction(QIcon(myIconPath+"/mActionAddRing.png"), tr("Add Ring"), this);
mActionAddRing->setStatusTip(tr("Add Ring"));
connect(mActionAddRing, SIGNAL(triggered()), this, SLOT(addRing()));
mActionAddRing->setEnabled(false);

mActionEditCut = new QAction(QIcon(myIconPath+"/mActionEditCut.png"), tr("Cut Features"), this);
mActionEditCut->setStatusTip(tr("Cut selected features"));
connect(mActionEditCut, SIGNAL(triggered()), this, SLOT(editCut()));
Expand Down Expand Up @@ -811,6 +817,8 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction(mActionDeleteVertex);
mActionMoveVertex->setCheckable(true);
mMapToolGroup->addAction(mActionMoveVertex);
mActionAddRing->setCheckable(true);
mMapToolGroup->addAction(mActionAddRing);
}

void QgisApp::createMenus()
Expand Down Expand Up @@ -965,6 +973,7 @@ void QgisApp::createToolBars()
mDigitizeToolBar->addAction(mActionAddVertex);
mDigitizeToolBar->addAction(mActionDeleteVertex);
mDigitizeToolBar->addAction(mActionMoveVertex);
mDigitizeToolBar->addAction(mActionAddRing);
mDigitizeToolBar->addAction(mActionEditCut);
mDigitizeToolBar->addAction(mActionEditCopy);
mDigitizeToolBar->addAction(mActionEditPaste);
Expand Down Expand Up @@ -1207,11 +1216,11 @@ void QgisApp::createCanvas()
mMapTools.mMeasureDist->setAction(mActionMeasure);
mMapTools.mMeasureArea = new QgsMeasureTool(mMapCanvas, TRUE /* area */);
mMapTools.mMeasureArea->setAction(mActionMeasureArea);
mMapTools.mCapturePoint = new QgsMapToolCapture(mMapCanvas, QgsMapToolCapture::CapturePoint);
mMapTools.mCapturePoint = new QgsMapToolAddFeature(mMapCanvas, QgsMapToolCapture::CapturePoint);
mMapTools.mCapturePoint->setAction(mActionCapturePoint);
mMapTools.mCaptureLine = new QgsMapToolCapture(mMapCanvas, QgsMapToolCapture::CaptureLine);
mMapTools.mCaptureLine = new QgsMapToolAddFeature(mMapCanvas, QgsMapToolCapture::CaptureLine);
mMapTools.mCaptureLine->setAction(mActionCaptureLine);
mMapTools.mCapturePolygon = new QgsMapToolCapture(mMapCanvas, QgsMapToolCapture::CapturePolygon);
mMapTools.mCapturePolygon = new QgsMapToolAddFeature(mMapCanvas, QgsMapToolCapture::CapturePolygon);
mMapTools.mCapturePolygon->setAction(mActionCapturePolygon);
mMapTools.mSelect = new QgsMapToolSelect(mMapCanvas);
mMapTools.mSelect->setAction(mActionSelect);
Expand All @@ -1221,6 +1230,8 @@ void QgisApp::createCanvas()
mMapTools.mVertexMove->setAction(mActionMoveVertex);
mMapTools.mVertexDelete = new QgsMapToolVertexEdit(mMapCanvas, QgsMapToolVertexEdit::DeleteVertex);
mMapTools.mVertexDelete->setAction(mActionDeleteVertex);
mMapTools.mAddRing = new QgsMapToolAddRing(mMapCanvas);
//mMapTools.mAddRing->setAction(mActionAddRing);
}

void QgisApp::createOverview()
Expand Down Expand Up @@ -3417,6 +3428,11 @@ void QgisApp::moveVertex()
mMapCanvas->setMapTool(mMapTools.mVertexMove);
}

void QgisApp::addRing()
{
mMapCanvas->setMapTool(mMapTools.mAddRing);
}


void QgisApp::deleteVertex()
{
Expand Down Expand Up @@ -4766,6 +4782,7 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
mActionCapturePolygon->setEnabled(false);
mActionAddVertex->setEnabled(false);
mActionDeleteVertex->setEnabled(false);
mActionAddRing->setEnabled(false);
if(dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries)
{
mActionMoveVertex->setEnabled(true);
Expand All @@ -4784,6 +4801,7 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
}
mActionCapturePoint->setEnabled(false);
mActionCapturePolygon->setEnabled(false);
mActionAddRing->setEnabled(false);
}
else if(vlayer->vectorType() == QGis::Polygon)
{
Expand All @@ -4805,6 +4823,10 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
mActionAddVertex->setEnabled(true);
mActionMoveVertex->setEnabled(true);
mActionDeleteVertex->setEnabled(true);
if(vlayer->vectorType() == QGis::Polygon)
{
mActionAddRing->setEnabled(true);
}
}
else
{
Expand All @@ -4826,6 +4848,7 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
mActionCaptureLine->setEnabled(false);
mActionCapturePolygon->setEnabled(false);
mActionDeleteSelected->setEnabled(false);
mActionAddRing->setEnabled(false);
mActionAddVertex->setEnabled(false);
mActionDeleteVertex->setEnabled(false);
mActionMoveVertex->setEnabled(false);
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -293,6 +293,8 @@ public slots:
void moveVertex();
//! activates the delete vertex tool
void deleteVertex();
//! activates the add ring tool
void addRing();

//! activates the selection tool
void select();
Expand Down Expand Up @@ -484,6 +486,7 @@ public slots:
QAction *mActionAddVertex;
QAction *mActionDeleteVertex;
QAction *mActionMoveVertex;
QAction *mActionAddRing;
QAction *mActionEditCut;
QAction *mActionEditCopy;
QAction *mActionEditPaste;
Expand Down Expand Up @@ -539,6 +542,7 @@ public slots:
QgsMapTool* mVertexAdd;
QgsMapTool* mVertexMove;
QgsMapTool* mVertexDelete;
QgsMapTool* mAddRing;
} mMapTools;

//!The name of the active theme
Expand Down

0 comments on commit 45b045f

Please sign in to comment.