Skip to content
Permalink
Browse files

[FEATURE] New map tool for interactively setting point symbol offset

Allows for setting a point's offset if it is bound to a field using
data defined overrides (fix #14738)

TODO: replace temporary icons

Sponsored by North Road
  • Loading branch information
nyalldawson committed Apr 28, 2016
1 parent 583eaef commit 79b979458fd43cd72db5d0ea18ff45df9aa6e0a3
@@ -74,6 +74,8 @@ SET(QGIS_APP_SRCS
qgsmaptoolmovefeature.cpp
qgsmaptoolmovelabel.cpp
qgsmaptooloffsetcurve.cpp
qgsmaptooloffsetpointsymbol.cpp
qgsmaptoolpointsymbol.cpp
qgsmaptoolreshape.cpp
qgsmaptoolrotatefeature.cpp
qgsmaptoolrotatelabel.cpp
@@ -100,6 +102,7 @@ SET(QGIS_APP_SRCS
qgsmeasuretool.cpp
qgsmergeattributesdialog.cpp
qgsoptions.cpp
qgspointmarkeritem.cpp
qgspointrotationitem.cpp
qgspluginmetadata.cpp
qgspluginregistry.cpp
@@ -250,6 +253,8 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolmovelabel.h
qgsmaptoollabel.h
qgsmaptooloffsetcurve.h
qgsmaptooloffsetpointsymbol.h
qgsmaptoolpointsymbol.h
qgsmaptoolreshape.h
qgsmaptoolrotatefeature.h
qgsmaptoolrotatelabel.h
@@ -293,6 +293,7 @@
#include "qgsmaptoolmovefeature.h"
#include "qgsmaptoolrotatefeature.h"
#include "qgsmaptooloffsetcurve.h"
#include "qgsmaptooloffsetpointsymbol.h"
#include "qgsmaptoolpan.h"
#include "qgsmaptoolselect.h"
#include "qgsmaptoolselectrectangle.h"
@@ -1115,6 +1116,7 @@ QgisApp::~QgisApp()
delete mMapTools.mRotateFeature;
delete mMapTools.mRotateLabel;
delete mMapTools.mRotatePointSymbolsTool;
delete mMapTools.mOffsetPointSymbolTool;
delete mMapTools.mSelectFreehand;
delete mMapTools.mSelectPolygon;
delete mMapTools.mSelectRadius;
@@ -1396,6 +1398,7 @@ void QgisApp::createActions()
connect( mActionMultiEditAttributes, SIGNAL( triggered() ), this, SLOT( modifyAttributesOfSelectedFeatures() ) );
connect( mActionNodeTool, SIGNAL( triggered() ), this, SLOT( nodeTool() ) );
connect( mActionRotatePointSymbols, SIGNAL( triggered() ), this, SLOT( rotatePointSymbols() ) );
connect( mActionOffsetPointSymbol, SIGNAL( triggered() ), this, SLOT( offsetPointSymbol() ) );
connect( mActionSnappingOptions, SIGNAL( triggered() ), this, SLOT( snappingOptions() ) );
connect( mActionOffsetCurve, SIGNAL( triggered() ), this, SLOT( offsetCurve() ) );

@@ -1681,7 +1684,7 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction( mActionMergeFeatureAttributes );
mMapToolGroup->addAction( mActionNodeTool );
mMapToolGroup->addAction( mActionRotatePointSymbols );

mMapToolGroup->addAction( mActionOffsetPointSymbol );
mMapToolGroup->addAction( mActionPinLabels );
mMapToolGroup->addAction( mActionShowHideLabels );
mMapToolGroup->addAction( mActionMoveLabel );
@@ -2036,6 +2039,26 @@ void QgisApp::createToolBars()
connect( tbAddCircularString, SIGNAL( triggered( QAction * ) ), this, SLOT( toolButtonActionTriggered( QAction * ) ) );
mDigitizeToolBar->insertWidget( mActionMoveFeature, tbAddCircularString );

bt = new QToolButton();
bt->setPopupMode( QToolButton::MenuButtonPopup );
bt->addAction( mActionRotatePointSymbols );
bt->addAction( mActionOffsetPointSymbol );

QAction* defPointSymbolAction = mActionRotatePointSymbols;
switch ( settings.value( "/UI/defaultPointSymbolAction", 0 ).toInt() )
{
case 0:
defPointSymbolAction = mActionRotatePointSymbols;
break;
case 1:
defPointSymbolAction = mActionOffsetPointSymbol;
break;
}
bt->setDefaultAction( defPointSymbolAction );
QAction* pointSymbolAction = mAdvancedDigitizeToolBar->addWidget( bt );
pointSymbolAction->setObjectName( "ActionPointSymbolTools" );
connect( bt, SIGNAL( triggered( QAction * ) ), this, SLOT( toolButtonActionTriggered( QAction * ) ) );

// Cad toolbar
mAdvancedDigitizeToolBar->insertAction( mActionEnableTracing, mAdvancedDigitizingDockWidget->enableAction() );

@@ -2328,6 +2351,7 @@ void QgisApp::setTheme( const QString& theThemeName )
mActionOffsetCurve->setIcon( QgsApplication::getThemeIcon( "/mActionOffsetCurve.png" ) );
mActionMergeFeatureAttributes->setIcon( QgsApplication::getThemeIcon( "/mActionMergeFeatureAttributes.png" ) );
mActionRotatePointSymbols->setIcon( QgsApplication::getThemeIcon( "mActionRotatePointSymbols.png" ) );
mActionOffsetPointSymbol->setIcon( QgsApplication::getThemeIcon( "mActionRotatePointSymbols.png" ) );
mActionZoomIn->setIcon( QgsApplication::getThemeIcon( "/mActionZoomIn.svg" ) );
mActionZoomOut->setIcon( QgsApplication::getThemeIcon( "/mActionZoomOut.svg" ) );
mActionZoomFullExtent->setIcon( QgsApplication::getThemeIcon( "/mActionZoomFullExtent.svg" ) );
@@ -2591,6 +2615,8 @@ void QgisApp::createCanvasTools()
mMapTools.mNodeTool->setAction( mActionNodeTool );
mMapTools.mRotatePointSymbolsTool = new QgsMapToolRotatePointSymbols( mMapCanvas );
mMapTools.mRotatePointSymbolsTool->setAction( mActionRotatePointSymbols );
mMapTools.mOffsetPointSymbolTool = new QgsMapToolOffsetPointSymbol( mMapCanvas );
mMapTools.mOffsetPointSymbolTool->setAction( mActionOffsetPointSymbol );

mMapTools.mPinLabels = new QgsMapToolPinLabels( mMapCanvas );
mMapTools.mPinLabels->setAction( mActionPinLabels );
@@ -6754,6 +6780,11 @@ void QgisApp::rotatePointSymbols()
mMapCanvas->setMapTool( mMapTools.mRotatePointSymbolsTool );
}

void QgisApp::offsetPointSymbol()
{
mMapCanvas->setMapTool( mMapTools.mOffsetPointSymbolTool );
}

void QgisApp::snappingOptions()
{
mSnappingDialog->show();
@@ -10023,6 +10054,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionMergeFeatureAttributes->setEnabled( false );
mActionMultiEditAttributes->setEnabled( false );
mActionRotatePointSymbols->setEnabled( false );
mActionOffsetPointSymbol->setEnabled( false );
mActionEnableTracing->setEnabled( false );

mActionPinLabels->setEnabled( false );
@@ -10166,6 +10198,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionSimplifyFeature->setEnabled( false );
mActionDeleteRing->setEnabled( false );
mActionRotatePointSymbols->setEnabled( false );
mActionOffsetPointSymbol->setEnabled( false );
mActionOffsetCurve->setEnabled( false );

if ( isEditable && canChangeAttributes )
@@ -10174,6 +10207,10 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
{
mActionRotatePointSymbols->setEnabled( true );
}
if ( QgsMapToolOffsetPointSymbol::layerIsOffsetable( vlayer ) )
{
mActionOffsetPointSymbol->setEnabled( true );
}
}
}
else if ( vlayer->geometryType() == QGis::Line )
@@ -10287,6 +10324,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionCutFeatures->setEnabled( false );
mActionPasteFeatures->setEnabled( false );
mActionRotatePointSymbols->setEnabled( false );
mActionOffsetPointSymbol->setEnabled( false );
mActionDeletePart->setEnabled( false );
mActionDeleteRing->setEnabled( false );
mActionSimplifyFeature->setEnabled( false );
@@ -11282,6 +11320,11 @@ void QgisApp::toolButtonActionTriggered( QAction *action )
settings.setValue( "/UI/defaultNewLayer", 2 );
else if ( action == mActionNewGeoPackageLayer )
settings.setValue( "/UI/defaultNewLayer", 3 );
else if ( action == mActionRotatePointSymbols )
settings.setValue( "/UI/defaultPointSymbolAction", 0 );
else if ( action == mActionOffsetPointSymbol )
settings.setValue( "/UI/defaultPointSymbolAction", 1 );

bt->setDefaultAction( action );
}

@@ -1040,6 +1040,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void nodeTool();
//! activates the rotate points tool
void rotatePointSymbols();
//! activates the offset point symbol tool
void offsetPointSymbol();
//! shows the snapping Options
void snappingOptions();

@@ -1569,6 +1571,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsMapTool *mDeletePart;
QgsMapTool *mNodeTool;
QgsMapTool *mRotatePointSymbolsTool;
QgsMapTool *mOffsetPointSymbolTool;
QgsMapTool *mAnnotation;
QgsMapTool *mFormAnnotation;
QgsMapTool *mHtmlAnnotation;

0 comments on commit 79b9794

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