Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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/qgis@10700 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed May 2, 2009
1 parent f90acbe commit d007db3
Show file tree
Hide file tree
Showing 16 changed files with 1,237 additions and 2 deletions.
Binary file added images/themes/default/mActionDeleteHole.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/themes/default/mActionDeletePart.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/themes/default/mActionSimplify.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions python/core/qgsgeometry.sip
Expand Up @@ -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

4 changes: 4 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -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
Expand Down Expand Up @@ -115,6 +118,7 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptooladdring.h
qgsmaptoolmovefeature.h
qgsmaptoolselect.h
qgsmaptoolsimplify.h

qgsmeasuretool.h
qgsmeasuredialog.h
Expand Down
83 changes: 82 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -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"
Expand All @@ -166,6 +168,7 @@
#include "qgsmaptoolsplitfeatures.h"
#include "qgsmaptoolvertexedit.h"
#include "qgsmaptoolzoom.h"
#include "qgsmaptoolsimplify.h"
#include "qgsmeasuretool.h"

//
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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" ) );
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 )
{
Expand All @@ -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
{
Expand All @@ -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 );
Expand Down
22 changes: 21 additions & 1 deletion src/app/qgisapp.h
Expand Up @@ -42,6 +42,8 @@ class QgisAppInterface;
class QgsClipboard;
class QgsComposer;
class QgsHelpViewer;
class QgsFeature;

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


/*! \class QgisApp
* \brief Main window for the Qgis application
*/
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -666,6 +677,7 @@ class QgisApp : public QMainWindow
QToolBar *mLayerToolBar;
QToolBar *mMapNavToolBar;
QToolBar *mDigitizeToolBar;
QToolBar *mAdvancedDigitizeToolBar;
QToolBar *mAttributesToolBar;
QToolBar *mPluginToolBar;
QToolBar *mHelpToolBar;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -816,6 +832,9 @@ class QgisApp : public QMainWindow
QgsMapTool* mVertexDelete;
QgsMapTool* mAddRing;
QgsMapTool* mAddIsland;
QgsMapTool* mSimplifyFeature;
QgsMapTool* mDeleteHole;
QgsMapTool* mDeletePart;
} mMapTools;

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

static QgisApp *smInstance;

};

#endif

0 comments on commit d007db3

Please sign in to comment.