Skip to content
Permalink
Browse files

New vector editing tools:

- delete part of multipart feature
- delete hole from polygon
- simplify feature

These tools are in the new "advanced" editing toolbar.
Contributed by Richard Kostecky (qgis-mapper project).


git-svn-id: http://svn.osgeo.org/qgis/trunk@10700 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed May 2, 2009
1 parent fac6117 commit cbc57dcb27c768b518aaf18f4cc429cce49dd3d5
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -289,5 +289,16 @@ not disjoint with existing polygons of the feature*/
// TODO: destruction of created geometries??
QList<QgsGeometry*> asGeometryCollection() /Factory/;

/** delete a hole in polygon or multipolygon.
Ring 0 is outer ring and can't be deleted.
@return TRUE on success
@note added in version 1.2 */
bool deleteHole( int ringNum, int partNum = 0 );

/** delete part identified by the part number
@return TRUE on success
@note added in version 1.2 */
bool deletePart( int partNum );

}; // class QgsGeometry

@@ -27,12 +27,15 @@ SET(QGIS_APP_SRCS
qgsmaptooladdisland.cpp
qgsmaptooladdring.cpp
qgsmaptoolcapture.cpp
qgsmaptooldeletehole.cpp
qgsmaptooldeletepart.cpp
qgsmaptooldeletevertex.cpp
qgsmaptooledit.cpp
qgsmaptoolidentify.cpp
qgsmaptoolmovefeature.cpp
qgsmaptoolmovevertex.cpp
qgsmaptoolselect.cpp
qgsmaptoolsimplify.cpp
qgsmaptoolsplitfeatures.cpp
qgsmaptoolvertexedit.cpp
qgsmeasuredialog.cpp
@@ -115,6 +118,7 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptooladdring.h
qgsmaptoolmovefeature.h
qgsmaptoolselect.h
qgsmaptoolsimplify.h

qgsmeasuretool.h
qgsmeasuredialog.h
@@ -157,6 +157,8 @@
#include "qgsmaptooladdisland.h"
#include "qgsmaptooladdring.h"
#include "qgsmaptooladdvertex.h"
#include "qgsmaptooldeletehole.h"
#include "qgsmaptooldeletepart.h"
#include "qgsmaptooldeletevertex.h"
#include "qgsmaptoolidentify.h"
#include "qgsmaptoolmovefeature.h"
@@ -166,6 +168,7 @@
#include "qgsmaptoolsplitfeatures.h"
#include "qgsmaptoolvertexedit.h"
#include "qgsmaptoolzoom.h"
#include "qgsmaptoolsimplify.h"
#include "qgsmeasuretool.h"

//
@@ -465,6 +468,9 @@ QgisApp::~QgisApp()
delete mMapTools.mVertexMove;
delete mMapTools.mVertexDelete;
delete mMapTools.mAddRing;
delete mMapTools.mSimplifyFeature;
delete mMapTools.mDeleteHole;
delete mMapTools.mDeletePart;
delete mMapTools.mAddIsland;

delete mPythonConsole;
@@ -667,6 +673,22 @@ void QgisApp::createActions()
connect( mActionAddIsland, SIGNAL( triggered() ), this, SLOT( addIsland() ) );
mActionAddIsland->setEnabled( false );

mActionSimplifyFeature = new QAction( getThemeIcon( "mActionSimplify.png" ), tr( "Simplify Feature" ), this );
mActionSimplifyFeature->setStatusTip( tr( "Simplify Feature" ) );
connect( mActionSimplifyFeature, SIGNAL( triggered() ), this, SLOT( simplifyFeature() ) );
mActionSimplifyFeature->setEnabled( false );

mActionDeleteHole = new QAction( getThemeIcon( "mActionDeleteHole.png" ), tr( "Delete Hole" ), this );
mActionDeleteHole->setStatusTip( tr( "Delete Hole" ) );
connect( mActionDeleteHole, SIGNAL( triggered() ), this, SLOT( deleteHole() ) );
mActionDeleteHole->setEnabled( false );

mActionDeletePart = new QAction( getThemeIcon( "mActionDeletePart.png" ), tr( "Delete Part" ), this );
mActionDeletePart->setStatusTip( tr( "Delete Part" ) );
connect( mActionDeletePart, SIGNAL( triggered() ), this, SLOT( deletePart() ) );
mActionDeletePart->setEnabled( false );


// View Menu Items

mActionPan = new QAction( getThemeIcon( "mActionPan.png" ), tr( "Pan Map" ), this );
@@ -990,6 +1012,12 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction( mActionAddRing );
mActionAddIsland->setCheckable( true );
mMapToolGroup->addAction( mActionAddIsland );
mActionSimplifyFeature->setCheckable( true );
mMapToolGroup->addAction( mActionSimplifyFeature );
mActionDeleteHole->setCheckable( true );
mMapToolGroup->addAction( mActionDeleteHole );
mActionDeletePart->setCheckable( true );
mMapToolGroup->addAction( mActionDeletePart );
}

void QgisApp::createMenus()
@@ -1073,9 +1101,15 @@ void QgisApp::createMenus()
mEditMenu->addAction( mActionAddRing );
mEditMenu->addAction( mActionAddIsland );

mActionEditSeparator2 = mEditMenu->addSeparator();

mEditMenu->addAction( mActionSimplifyFeature );
mEditMenu->addAction( mActionDeleteHole );
mEditMenu->addAction( mActionDeletePart );

if ( layout == QDialogButtonBox::GnomeLayout || layout == QDialogButtonBox::MacLayout )
{
mActionEditSeparator2 = mEditMenu->addSeparator();
mActionEditSeparator3 = mEditMenu->addSeparator();
mEditMenu->addAction( mActionOptions );
mEditMenu->addAction( mActionCustomProjection );
}
@@ -1267,6 +1301,16 @@ void QgisApp::createToolBars()
mDigitizeToolBar->addAction( mActionCopyFeatures );
mDigitizeToolBar->addAction( mActionPasteFeatures );
mToolbarMenu->addAction( mDigitizeToolBar->toggleViewAction() );

mAdvancedDigitizeToolBar = addToolBar( tr( "Advanced Digitizing" ) );
mAdvancedDigitizeToolBar->setIconSize( myIconSize );
mAdvancedDigitizeToolBar->setObjectName( "Advanced Digitizing" );
mAdvancedDigitizeToolBar->addAction( mActionSimplifyFeature );
mAdvancedDigitizeToolBar->addAction( mActionDeleteHole );
mAdvancedDigitizeToolBar->addAction( mActionDeletePart );
mToolbarMenu->addAction( mAdvancedDigitizeToolBar->toggleViewAction() );


//
// Map Navigation Toolbar
mMapNavToolBar = addToolBar( tr( "Map Navigation" ) );
@@ -1606,6 +1650,12 @@ void QgisApp::createCanvas()
mMapTools.mAddRing = new QgsMapToolAddRing( mMapCanvas );
mMapTools.mAddRing->setAction( mActionAddRing );
mMapTools.mAddIsland = new QgsMapToolAddIsland( mMapCanvas );
mMapTools.mSimplifyFeature = new QgsMapToolSimplify( mMapCanvas );
mMapTools.mSimplifyFeature->setAction( mActionSimplifyFeature );
mMapTools.mDeleteHole = new QgsMapToolDeleteHole( mMapCanvas );
mMapTools.mDeleteHole->setAction( mActionDeleteHole );
mMapTools.mDeletePart = new QgsMapToolDeletePart( mMapCanvas );
mMapTools.mDeletePart->setAction( mActionDeletePart );
//ensure that non edit tool is initialised or we will get crashes in some situations
mNonEditMapTool = mMapTools.mPan;
}
@@ -3979,6 +4029,21 @@ void QgisApp::moveFeature()
mMapCanvas->setMapTool( mMapTools.mMoveFeature );
}

void QgisApp::simplifyFeature()
{
mMapCanvas->setMapTool( mMapTools.mSimplifyFeature );
}

void QgisApp::deleteHole()
{
mMapCanvas->setMapTool( mMapTools.mDeleteHole );
}

void QgisApp::deletePart()
{
mMapCanvas->setMapTool( mMapTools.mDeletePart );
}

void QgisApp::splitFeatures()
{
mMapCanvas->setMapTool( mMapTools.mSplitFeatures );
@@ -5215,11 +5280,13 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
{
mActionCapturePoint->setEnabled( true );
mActionCapturePoint->setVisible( true );
mActionDeletePart->setEnabled( true );
}
else
{
mActionCapturePoint->setEnabled( false );
mActionCapturePoint->setVisible( false );
mActionDeletePart->setEnabled( false );
}
mActionCaptureLine->setEnabled( false );
mActionCapturePolygon->setEnabled( false );
@@ -5231,6 +5298,9 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionAddRing->setEnabled( false );
mActionAddIsland->setEnabled( false );
mActionSplitFeatures->setEnabled( false );
mActionSimplifyFeature->setEnabled( false );
mActionDeleteHole->setEnabled( false );

if ( vlayer->isEditable() && dprovider->capabilities() & QgsVectorDataProvider::ChangeGeometries )
{
mActionMoveVertex->setEnabled( true );
@@ -5244,19 +5314,24 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionCaptureLine->setEnabled( true );
mActionCaptureLine->setVisible( true );
mActionSplitFeatures->setEnabled( true );
mActionSimplifyFeature->setEnabled( true );
mActionDeletePart->setEnabled( true );
}
else
{
mActionCaptureLine->setEnabled( false );
mActionCaptureLine->setVisible( false );
mActionSplitFeatures->setEnabled( false );
mActionSimplifyFeature->setEnabled( false );
mActionDeletePart->setEnabled( false );
}
mActionCapturePoint->setEnabled( false );
mActionCapturePolygon->setEnabled( false );
mActionCapturePoint->setVisible( false );
mActionCapturePolygon->setVisible( false );
mActionAddRing->setEnabled( false );
mActionAddIsland->setEnabled( false );
mActionDeleteHole->setEnabled( false );
}
else if ( vlayer->geometryType() == QGis::Polygon )
{
@@ -5267,6 +5342,9 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionAddRing->setEnabled( true );
mActionAddIsland->setEnabled( true );
mActionSplitFeatures->setEnabled( true );
mActionSimplifyFeature->setEnabled( true );
mActionDeleteHole->setEnabled( true );
mActionDeletePart->setEnabled( true );
}
else
{
@@ -5275,6 +5353,9 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionAddRing->setEnabled( false );
mActionAddIsland->setEnabled( false );
mActionSplitFeatures->setEnabled( false );
mActionSimplifyFeature->setEnabled( false );
mActionDeleteHole->setEnabled( false );
mActionDeletePart->setEnabled( false );
}
mActionCapturePoint->setEnabled( false );
mActionCaptureLine->setEnabled( false );
@@ -42,6 +42,8 @@ class QgisAppInterface;
class QgsClipboard;
class QgsComposer;
class QgsHelpViewer;
class QgsFeature;

class QgsLegend;
class QgsMapCanvas;
class QgsMapLayer;
@@ -63,7 +65,6 @@ class QgsVectorLayer;
#include "qgsconfig.h"
#include "qgspoint.h"


/*! \class QgisApp
* \brief Main window for the Qgis application
*/
@@ -221,6 +222,9 @@ class QgisApp : public QMainWindow
QAction *actionMoveVertex() { return mActionMoveVertex; }
QAction *actionAddRing() { return mActionAddRing; }
QAction *actionAddIsland() { return mActionAddIsland; }
QAction *actionSimplifyFeature() { return mActionSimplifyFeature; }
QAction *actionDeleteHole() { return mActionDeleteHole; }
QAction *actionDeletePart() { return mActionDeletePart; }
QAction *actionEditSeparator2() { return mActionEditSeparator2; }

QAction *actionPan() { return mActionPan; }
@@ -318,6 +322,7 @@ class QgisApp : public QMainWindow
QToolBar *layerToolBar() { return mLayerToolBar; }
QToolBar *mapNavToolToolBar() { return mMapNavToolBar; }
QToolBar *digitizeToolBar() { return mDigitizeToolBar; }
QToolBar *advancedDigitizeToolBar() { return mAdvancedDigitizeToolBar; }
QToolBar *attributesToolBar() { return mAttributesToolBar; }
QToolBar *pluginToolBar() { return mPluginToolBar; }
QToolBar *helpToolBar() { return mHelpToolBar; }
@@ -495,6 +500,12 @@ class QgisApp : public QMainWindow
void addRing();
//! activates the add island tool
void addIsland();
//! simplifies feature
void simplifyFeature();
//! deletes hole in polygon
void deleteHole();
//! deletes part of polygon
void deletePart();

//! activates the selection tool
void select();
@@ -666,6 +677,7 @@ class QgisApp : public QMainWindow
QToolBar *mLayerToolBar;
QToolBar *mMapNavToolBar;
QToolBar *mDigitizeToolBar;
QToolBar *mAdvancedDigitizeToolBar;
QToolBar *mAttributesToolBar;
QToolBar *mPluginToolBar;
QToolBar *mHelpToolBar;
@@ -701,6 +713,10 @@ class QgisApp : public QMainWindow
QAction *mActionAddRing;
QAction *mActionAddIsland;
QAction *mActionEditSeparator2;
QAction *mActionSimplifyFeature;
QAction *mActionDeleteHole;
QAction *mActionDeletePart;
QAction *mActionEditSeparator3;

QAction *mActionPan;
QAction *mActionZoomIn;
@@ -816,6 +832,9 @@ class QgisApp : public QMainWindow
QgsMapTool* mVertexDelete;
QgsMapTool* mAddRing;
QgsMapTool* mAddIsland;
QgsMapTool* mSimplifyFeature;
QgsMapTool* mDeleteHole;
QgsMapTool* mDeletePart;
} mMapTools;

QgsMapTool *mNonEditMapTool;
@@ -921,6 +940,7 @@ class QgisApp : public QMainWindow
QgsPythonUtils* mPythonUtils;

static QgisApp *smInstance;

};

#endif

0 comments on commit cbc57dc

Please sign in to comment.
You can’t perform that action at this time.