Skip to content

Commit 45b045f

Browse files
author
mhugent
committed
Added a tool to cut holes into polygons/multipolygons. Made QgsMapToolCapture 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
1 parent b93ef15 commit 45b045f

20 files changed

+1027
-555
lines changed
1.03 KB
Loading

src/app/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ qgslabeldialog.cpp
2626
qgslinestyledialog.cpp
2727
qgslinestylewidget.cpp
2828
qgsludialog.cpp
29+
qgsmaptooladdfeature.cpp
30+
qgsmaptooladdring.cpp
2931
qgsmaptoolcapture.cpp
3032
qgsmaptoolidentify.cpp
3133
qgsmaptoolselect.cpp

src/app/qgisapp.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@
144144
//
145145
// Map tools
146146
//
147-
#include "qgsmaptoolcapture.h"
147+
#include "qgsmaptooladdfeature.h"
148+
#include "qgsmaptooladdring.h"
148149
#include "qgsmaptoolidentify.h"
149150
#include "qgsmaptoolpan.h"
150151
#include "qgsmaptoolselect.h"
@@ -748,6 +749,11 @@ void QgisApp::createActions()
748749
connect(mActionMoveVertex, SIGNAL(triggered()), this, SLOT(moveVertex()));
749750
mActionMoveVertex->setEnabled(false);
750751

752+
mActionAddRing = new QAction(QIcon(myIconPath+"/mActionAddRing.png"), tr("Add Ring"), this);
753+
mActionAddRing->setStatusTip(tr("Add Ring"));
754+
connect(mActionAddRing, SIGNAL(triggered()), this, SLOT(addRing()));
755+
mActionAddRing->setEnabled(false);
756+
751757
mActionEditCut = new QAction(QIcon(myIconPath+"/mActionEditCut.png"), tr("Cut Features"), this);
752758
mActionEditCut->setStatusTip(tr("Cut selected features"));
753759
connect(mActionEditCut, SIGNAL(triggered()), this, SLOT(editCut()));
@@ -811,6 +817,8 @@ void QgisApp::createActionGroups()
811817
mMapToolGroup->addAction(mActionDeleteVertex);
812818
mActionMoveVertex->setCheckable(true);
813819
mMapToolGroup->addAction(mActionMoveVertex);
820+
mActionAddRing->setCheckable(true);
821+
mMapToolGroup->addAction(mActionAddRing);
814822
}
815823

816824
void QgisApp::createMenus()
@@ -965,6 +973,7 @@ void QgisApp::createToolBars()
965973
mDigitizeToolBar->addAction(mActionAddVertex);
966974
mDigitizeToolBar->addAction(mActionDeleteVertex);
967975
mDigitizeToolBar->addAction(mActionMoveVertex);
976+
mDigitizeToolBar->addAction(mActionAddRing);
968977
mDigitizeToolBar->addAction(mActionEditCut);
969978
mDigitizeToolBar->addAction(mActionEditCopy);
970979
mDigitizeToolBar->addAction(mActionEditPaste);
@@ -1207,11 +1216,11 @@ void QgisApp::createCanvas()
12071216
mMapTools.mMeasureDist->setAction(mActionMeasure);
12081217
mMapTools.mMeasureArea = new QgsMeasureTool(mMapCanvas, TRUE /* area */);
12091218
mMapTools.mMeasureArea->setAction(mActionMeasureArea);
1210-
mMapTools.mCapturePoint = new QgsMapToolCapture(mMapCanvas, QgsMapToolCapture::CapturePoint);
1219+
mMapTools.mCapturePoint = new QgsMapToolAddFeature(mMapCanvas, QgsMapToolCapture::CapturePoint);
12111220
mMapTools.mCapturePoint->setAction(mActionCapturePoint);
1212-
mMapTools.mCaptureLine = new QgsMapToolCapture(mMapCanvas, QgsMapToolCapture::CaptureLine);
1221+
mMapTools.mCaptureLine = new QgsMapToolAddFeature(mMapCanvas, QgsMapToolCapture::CaptureLine);
12131222
mMapTools.mCaptureLine->setAction(mActionCaptureLine);
1214-
mMapTools.mCapturePolygon = new QgsMapToolCapture(mMapCanvas, QgsMapToolCapture::CapturePolygon);
1223+
mMapTools.mCapturePolygon = new QgsMapToolAddFeature(mMapCanvas, QgsMapToolCapture::CapturePolygon);
12151224
mMapTools.mCapturePolygon->setAction(mActionCapturePolygon);
12161225
mMapTools.mSelect = new QgsMapToolSelect(mMapCanvas);
12171226
mMapTools.mSelect->setAction(mActionSelect);
@@ -1221,6 +1230,8 @@ void QgisApp::createCanvas()
12211230
mMapTools.mVertexMove->setAction(mActionMoveVertex);
12221231
mMapTools.mVertexDelete = new QgsMapToolVertexEdit(mMapCanvas, QgsMapToolVertexEdit::DeleteVertex);
12231232
mMapTools.mVertexDelete->setAction(mActionDeleteVertex);
1233+
mMapTools.mAddRing = new QgsMapToolAddRing(mMapCanvas);
1234+
//mMapTools.mAddRing->setAction(mActionAddRing);
12241235
}
12251236

12261237
void QgisApp::createOverview()
@@ -3417,6 +3428,11 @@ void QgisApp::moveVertex()
34173428
mMapCanvas->setMapTool(mMapTools.mVertexMove);
34183429
}
34193430

3431+
void QgisApp::addRing()
3432+
{
3433+
mMapCanvas->setMapTool(mMapTools.mAddRing);
3434+
}
3435+
34203436

34213437
void QgisApp::deleteVertex()
34223438
{
@@ -4766,6 +4782,7 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
47664782
mActionCapturePolygon->setEnabled(false);
47674783
mActionAddVertex->setEnabled(false);
47684784
mActionDeleteVertex->setEnabled(false);
4785+
mActionAddRing->setEnabled(false);
47694786
if(dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries)
47704787
{
47714788
mActionMoveVertex->setEnabled(true);
@@ -4784,6 +4801,7 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
47844801
}
47854802
mActionCapturePoint->setEnabled(false);
47864803
mActionCapturePolygon->setEnabled(false);
4804+
mActionAddRing->setEnabled(false);
47874805
}
47884806
else if(vlayer->vectorType() == QGis::Polygon)
47894807
{
@@ -4805,6 +4823,10 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
48054823
mActionAddVertex->setEnabled(true);
48064824
mActionMoveVertex->setEnabled(true);
48074825
mActionDeleteVertex->setEnabled(true);
4826+
if(vlayer->vectorType() == QGis::Polygon)
4827+
{
4828+
mActionAddRing->setEnabled(true);
4829+
}
48084830
}
48094831
else
48104832
{
@@ -4826,6 +4848,7 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
48264848
mActionCaptureLine->setEnabled(false);
48274849
mActionCapturePolygon->setEnabled(false);
48284850
mActionDeleteSelected->setEnabled(false);
4851+
mActionAddRing->setEnabled(false);
48294852
mActionAddVertex->setEnabled(false);
48304853
mActionDeleteVertex->setEnabled(false);
48314854
mActionMoveVertex->setEnabled(false);

src/app/qgisapp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ public slots:
293293
void moveVertex();
294294
//! activates the delete vertex tool
295295
void deleteVertex();
296+
//! activates the add ring tool
297+
void addRing();
296298

297299
//! activates the selection tool
298300
void select();
@@ -484,6 +486,7 @@ public slots:
484486
QAction *mActionAddVertex;
485487
QAction *mActionDeleteVertex;
486488
QAction *mActionMoveVertex;
489+
QAction *mActionAddRing;
487490
QAction *mActionEditCut;
488491
QAction *mActionEditCopy;
489492
QAction *mActionEditPaste;
@@ -539,6 +542,7 @@ public slots:
539542
QgsMapTool* mVertexAdd;
540543
QgsMapTool* mVertexMove;
541544
QgsMapTool* mVertexDelete;
545+
QgsMapTool* mAddRing;
542546
} mMapTools;
543547

544548
//!The name of the active theme

0 commit comments

Comments
 (0)