Skip to content
Permalink
Browse files

activate/deactivate labeling tools

git-svn-id: http://svn.osgeo.org/qgis/trunk@14798 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 29, 2010
1 parent 978cc79 commit 245a23001ffb5099930dc1984e3ca61e58eec217
Showing with 33 additions and 7 deletions.
  1. +25 −0 src/app/qgisapp.cpp
  2. +6 −6 src/app/qgsmaptoolmovelabel.h
  3. +2 −1 src/app/qgsmaptoolrotatelabel.h
@@ -584,6 +584,7 @@ QgisApp::~QgisApp()
delete mMapTools.mAddIsland;
delete mMapTools.mNodeTool;
delete mMapTools.mMoveLabel;
delete mMapTools.mRotateLabel;
delete mMapTools.mChangeLabelProperties;

delete mPythonUtils;
@@ -3955,6 +3956,8 @@ void QgisApp::labeling()
// alter labeling - save the changes
labelGui.layerSettings().writeToLayer( vlayer );

activateDeactivateLayerRelatedActions( layer );

// trigger refresh
if ( mMapCanvas )
{
@@ -6171,6 +6174,10 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionCaptureLine->setVisible( false );
mActionCapturePolygon->setVisible( false );

mActionMoveLabel->setEnabled( false );
mActionRotateLabel->setEnabled( false );
mActionChangeLabelProperties->setEnabled( false );

return;
}

@@ -6247,11 +6254,29 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
dprovider->capabilities() & QgsVectorDataProvider::AddFeatures );

mActionMergeFeatureAttributes->setEnabled( layerHasSelection );

if ( layer->customProperty( "labeling" ).toString() == QString( "pal" ) )
{
int colX, colY, colAng;
mActionMoveLabel->setEnabled( qobject_cast<QgsMapToolMoveLabel*>( mMapTools.mMoveLabel ) && qobject_cast<QgsMapToolMoveLabel*>( mMapTools.mMoveLabel )->layerIsMoveable( layer, colX, colY ) );
mActionRotateLabel->setEnabled( qobject_cast<QgsMapToolRotateLabel*>( mMapTools.mRotateLabel ) && qobject_cast<QgsMapToolRotateLabel*>( mMapTools.mMoveLabel )->layerIsRotatable( layer, colAng ) );
mActionChangeLabelProperties->setEnabled( true );
}
else
{
mActionMoveLabel->setEnabled( false );
mActionRotateLabel->setEnabled( false );
mActionChangeLabelProperties->setEnabled( false );
}
}
else
{
mActionMergeFeatures->setEnabled( false );
mActionMergeFeatureAttributes->setEnabled( false );

mActionMoveLabel->setEnabled( false );
mActionRotateLabel->setEnabled( false );
mActionChangeLabelProperties->setEnabled( false );
}

// moving enabled if geometry changes are supported
@@ -35,6 +35,12 @@ class QgsMapToolMoveLabel: public QgsMapToolLabel

virtual void canvasReleaseEvent( QMouseEvent * e );

/**Returns true if layer move can be applied to a layer
@param xCol out: index of the attribute for data defined x coordinate
@param yCol out: index of the attribute for data defined y coordinate
@return true if labels of layer can be moved*/
bool layerIsMoveable( const QgsMapLayer* ml, int& xCol, int& yCol ) const;

protected:
/**Get data defined position of a feature
@param layerId layer identification string
@@ -47,12 +53,6 @@ class QgsMapToolMoveLabel: public QgsMapToolLabel
@return false if layer does not have data defined label position enabled*/
bool dataDefinedPosition( QgsVectorLayer* vlayer, int featureId, double& x, bool& xSuccess, double& y, bool& ySuccess, int& xCol, int& yCol ) const;

/**Returns true if layer move can be applied to a layer
@param xCol out: index of the attribute for data defined x coordinate
@param yCol out: index of the attribute for data defined y coordinate
@return true if labels of layer can be moved*/
bool layerIsMoveable( const QgsMapLayer* ml, int& xCol, int& yCol ) const;

/**Start point of the move in map coordinates*/
QgsPoint mStartPointMapCoords;

@@ -33,10 +33,11 @@ class QgsMapToolRotateLabel: public QgsMapToolLabel
virtual void canvasMoveEvent( QMouseEvent * e );
virtual void canvasReleaseEvent( QMouseEvent * e );

protected:
/**Checks if labels in a layer can be rotated
@param rotationCol out: attribute column for data defined label rotation*/
bool layerIsRotatable( const QgsMapLayer* layer, int& rotationCol ) const;

protected:
/**Returns data defined rotation of a feature.
@param rotation out: rotation value
@param rotationSuccess out: false if rotation value is NULL

0 comments on commit 245a230

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