559 changes: 559 additions & 0 deletions images/themes/default/mActionPinLabels.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 0 additions & 90 deletions images/themes/default/mActionShowFrozenLabels.svg

This file was deleted.

974 changes: 974 additions & 0 deletions images/themes/default/mActionShowPinnedLabels.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ SET(QGIS_APP_SRCS
qgsmaptooledit.cpp
qgsmaptoolfeatureaction.cpp
qgsmaptoolformannotation.cpp
qgsmaptoolfreezelabels.cpp
qgsmaptoolpinlabels.cpp
qgsmaptoolidentify.cpp
qgsmaptoollabel.cpp
qgsmaptoolmeasureangle.cpp
Expand Down Expand Up @@ -205,7 +205,7 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptooldeletering.h
qgsmaptooldeletevertex.h
qgsmaptoolfeatureaction.h
qgsmaptoolfreezelabels.h
qgsmaptoolpinlabels.h
qgsmaptoolidentify.h
qgsmaptoolmeasureangle.h
qgsmaptoolmovefeature.h
Expand Down
44 changes: 22 additions & 22 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
#include "qgsmaptoolzoom.h"
#include "qgsmaptoolsimplify.h"
#include "qgsmeasuretool.h"
#include "qgsmaptoolfreezelabels.h"
#include "qgsmaptoolpinlabels.h"
#include "qgsmaptoolmovelabel.h"
#include "qgsmaptoolrotatelabel.h"
#include "qgsmaptoolchangelabelproperties.h"
Expand Down Expand Up @@ -714,7 +714,7 @@ QgisApp::~QgisApp()
delete mMapTools.mAddPart;
delete mMapTools.mNodeTool;
delete mMapTools.mRotatePointSymbolsTool;
delete mMapTools.mFreezeLabels;
delete mMapTools.mPinLabels;
delete mMapTools.mMoveLabel;
delete mMapTools.mRotateLabel;
delete mMapTools.mChangeLabelProperties;
Expand Down Expand Up @@ -982,8 +982,8 @@ void QgisApp::createActions()
connect( mActionAbout, SIGNAL( triggered() ), this, SLOT( about() ) );
connect( mActionSponsors, SIGNAL( triggered() ), this, SLOT( sponsors() ) );

connect( mActionShowFrozenLabels, SIGNAL( toggled( bool ) ), this, SLOT( showFrozenLabels( bool ) ) );
connect( mActionFreezeLabels, SIGNAL( triggered() ), this, SLOT( freezeLabels() ) );
connect( mActionShowPinnedLabels, SIGNAL( toggled( bool ) ), this, SLOT( showPinnedLabels( bool ) ) );
connect( mActionPinLabels, SIGNAL( triggered() ), this, SLOT( pinLabels() ) );
connect( mActionMoveLabel, SIGNAL( triggered() ), this, SLOT( moveLabel() ) );
connect( mActionRotateLabel, SIGNAL( triggered() ), this, SLOT( rotateLabel() ) );
connect( mActionChangeLabelProperties, SIGNAL( triggered() ), this, SLOT( changeLabelProperties() ) );
Expand Down Expand Up @@ -1093,7 +1093,7 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction( mActionMergeFeatureAttributes );
mMapToolGroup->addAction( mActionNodeTool );
mMapToolGroup->addAction( mActionRotatePointSymbols );
mMapToolGroup->addAction( mActionFreezeLabels );
mMapToolGroup->addAction( mActionPinLabels );
mMapToolGroup->addAction( mActionMoveLabel );
mMapToolGroup->addAction( mActionRotateLabel );
mMapToolGroup->addAction( mActionChangeLabelProperties );
Expand Down Expand Up @@ -1626,8 +1626,8 @@ void QgisApp::setTheme( QString theThemeName )
mActionFormAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionFormAnnotation.png" ) );
mActionTextAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionTextAnnotation.png" ) );
mActionLabeling->setIcon( QgsApplication::getThemeIcon( "/mActionLabeling.png" ) );
mActionShowFrozenLabels->setIcon( QgsApplication::getThemeIcon( "/mActionShowFrozenLabels.svg" ) );
mActionFreezeLabels->setIcon( QgsApplication::getThemeIcon( "/mActionFreezeLabels.svg" ) );
mActionShowPinnedLabels->setIcon( QgsApplication::getThemeIcon( "/mActionShowPinnedLabels.svg" ) );
mActionPinLabels->setIcon( QgsApplication::getThemeIcon( "/mActionPinLabels.svg" ) );
mActionMoveLabel->setIcon( QgsApplication::getThemeIcon( "/mActionMoveLabel.png" ) );
mActionRotateLabel->setIcon( QgsApplication::getThemeIcon( "/mActionRotateLabel.svg" ) );
mActionChangeLabelProperties->setIcon( QgsApplication::getThemeIcon( "/mActionChangeLabelProperties.png" ) );
Expand Down Expand Up @@ -1794,8 +1794,8 @@ void QgisApp::createCanvasTools()
mMapTools.mNodeTool->setAction( mActionNodeTool );
mMapTools.mRotatePointSymbolsTool = new QgsMapToolRotatePointSymbols( mMapCanvas );
mMapTools.mRotatePointSymbolsTool->setAction( mActionRotatePointSymbols );
mMapTools.mFreezeLabels = new QgsMapToolFreezeLabels( mMapCanvas );
mMapTools.mFreezeLabels->setAction( mActionFreezeLabels );
mMapTools.mPinLabels = new QgsMapToolPinLabels( mMapCanvas );
mMapTools.mPinLabels->setAction( mActionPinLabels );
mMapTools.mMoveLabel = new QgsMapToolMoveLabel( mMapCanvas );
mMapTools.mMoveLabel->setAction( mActionMoveLabel );
mMapTools.mRotateLabel = new QgsMapToolRotateLabel( mMapCanvas );
Expand Down Expand Up @@ -4308,15 +4308,15 @@ bool QgisApp::loadAnnotationItemsFromProject( const QDomDocument& doc )
return true;
}

void QgisApp::showFrozenLabels( bool show )
void QgisApp::showPinnedLabels( bool show )
{
qobject_cast<QgsMapToolFreezeLabels*>( mMapTools.mFreezeLabels )->showFrozenLabels( show );
qobject_cast<QgsMapToolPinLabels*>( mMapTools.mPinLabels )->showPinnedLabels( show );
}

void QgisApp::freezeLabels()
void QgisApp::pinLabels()
{
mActionShowFrozenLabels->setChecked( true );
mMapCanvas->setMapTool( mMapTools.mFreezeLabels );
mActionShowPinnedLabels->setChecked( true );
mMapCanvas->setMapTool( mMapTools.mPinLabels );
}

void QgisApp::moveLabel()
Expand Down Expand Up @@ -6668,7 +6668,7 @@ void QgisApp::legendLayerSelectionChanged( void )

void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
{
bool enableMove = false, enableRotate = false, enableFreeze = false, enableChange = false;
bool enableMove = false, enableRotate = false, enablePin = false, enableChange = false;

QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers();
for ( QMap<QString, QgsMapLayer*>::iterator it = layers.begin(); it != layers.end(); it++ )
Expand All @@ -6679,10 +6679,10 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
continue;

int colX, colY, colAng;
enableFreeze =
enableFreeze ||
( qobject_cast<QgsMapToolFreezeLabels*>( mMapTools.mFreezeLabels ) &&
qobject_cast<QgsMapToolFreezeLabels*>( mMapTools.mFreezeLabels )->layerCanFreeze( vlayer, colX, colY ) );
enablePin =
enablePin ||
( qobject_cast<QgsMapToolPinLabels*>( mMapTools.mPinLabels ) &&
qobject_cast<QgsMapToolPinLabels*>( mMapTools.mPinLabels )->layerCanPin( vlayer, colX, colY ) );

enableMove =
enableMove ||
Expand All @@ -6698,11 +6698,11 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )

enableChange = true;

if ( enableFreeze && enableMove && enableRotate && enableChange )
if ( enablePin && enableMove && enableRotate && enableChange )
break;
}

mActionFreezeLabels->setEnabled( enableFreeze );
mActionPinLabels->setEnabled( enablePin );
mActionMoveLabel->setEnabled( enableMove );
mActionRotateLabel->setEnabled( enableRotate );
mActionChangeLabelProperties->setEnabled( enableChange );
Expand Down Expand Up @@ -6749,7 +6749,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionMergeFeatureAttributes->setEnabled( false );
mActionRotatePointSymbols->setEnabled( false );

mActionFreezeLabels->setEnabled( false );
mActionPinLabels->setEnabled( false );
mActionMoveLabel->setEnabled( false );
mActionRotateLabel->setEnabled( false );
mActionChangeLabelProperties->setEnabled( false );
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionAbout() { return mActionAbout; }
QAction *actionSponsors() { return mActionSponsors; }

QAction *actionShowFrozenLabels() { return mActionShowFrozenLabels; }
QAction *actionShowPinnedLabels() { return mActionShowPinnedLabels; }

//! Menus
QMenu *fileMenu() { return mFileMenu; }
Expand Down Expand Up @@ -872,10 +872,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

bool loadAnnotationItemsFromProject( const QDomDocument& doc );

//! Toggles whether to show frozen labels
void showFrozenLabels( bool show );
//! Activates freeze labels tool
void freezeLabels();
//! Toggles whether to show pinned labels
void showPinnedLabels( bool show );
//! Activates pin labels tool
void pinLabels();
//! Activates the move label tool
void moveLabel();
//! Activates rotate label tool
Expand Down Expand Up @@ -1077,7 +1077,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QgsMapTool* mAnnotation;
QgsMapTool* mFormAnnotation;
QgsMapTool* mTextAnnotation;
QgsMapTool* mFreezeLabels;
QgsMapTool* mPinLabels;
QgsMapTool* mMoveLabel;
QgsMapTool* mRotateLabel;
QgsMapTool* mChangeLabelProperties;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoollabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ bool QgsMapToolLabel::labelMoveable( const QgsMapLayer* ml, int& xCol, int& yCol
return true;
}

bool QgsMapToolLabel::layerCanFreeze( const QgsMapLayer* ml, int& xCol, int& yCol ) const
bool QgsMapToolLabel::layerCanPin( const QgsMapLayer* ml, int& xCol, int& yCol ) const
{
const QgsVectorLayer* vlayer = dynamic_cast<const QgsVectorLayer*>( ml );
if ( !vlayer || !vlayer->isEditable() )
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoollabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class QgsMapToolLabel: public QgsMapTool
@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 layer fields set up and exist*/
bool layerCanFreeze( const QgsMapLayer* ml, int& xCol, int& yCol ) const;
bool layerCanPin( const QgsMapLayer* ml, int& xCol, int& yCol ) const;
/**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;
Expand Down Expand Up @@ -93,7 +93,7 @@ class QgsMapToolLabel: public QgsMapTool
/**Returns the font for the current feature (considering default font and data defined properties*/
QFont labelFontCurrentFeature();

/**Returns whether to preserve predefined rotation data during label freeze/thaw operations*/
/**Returns whether to preserve predefined rotation data during label pin/unpin operations*/
bool preserveRotation();

/**Get data defined position of a feature
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolmovelabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ void QgsMapToolMoveLabel::canvasReleaseEvent( QMouseEvent * e )
vlayer->changeAttributeValue( mCurrentLabelPos.featureId, yCol, yPosNew, false );

// set rotation to that of label, if data-defined and no rotation set yet
// honor whether to preserve preexisting data on freeze
// honor whether to preserve preexisting data on pin
// must come after setting x and y positions
int rCol;
if ( !mCurrentLabelPos.isDiagram
&& !mCurrentLabelPos.isFrozen
&& !mCurrentLabelPos.isPinned
&& !preserveRotation()
&& layerIsRotatable( vlayer, rCol ) )
{
Expand Down
108 changes: 54 additions & 54 deletions src/app/qgsmaptoolfreezelabels.cpp → src/app/qgsmaptoolpinlabels.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
qgsmaptoolfreezelabels.cpp
qgsmaptoolpinlabels.cpp
-----------------------
begin : 2012-07-12
copyright : (C) 2012 by Larry Shaffer
Expand All @@ -15,7 +15,7 @@
* *
***************************************************************************/

#include "qgsmaptoolfreezelabels.h"
#include "qgsmaptoolpinlabels.h"

#include "qgisapp.h"
#include "qgsapplication.h"
Expand All @@ -30,23 +30,23 @@
#include <qgslogger.h>
#include <QMouseEvent>

QgsMapToolFreezeLabels::QgsMapToolFreezeLabels( QgsMapCanvas* canvas ): QgsMapToolLabel( canvas )
QgsMapToolPinLabels::QgsMapToolPinLabels( QgsMapCanvas* canvas ): QgsMapToolLabel( canvas )
{
mRender = 0;
mRubberBand = 0;
mShowFrozen = false;
mShowPinned = false;

connect( QgisApp::instance()->actionToggleEditing(), SIGNAL( triggered() ), this, SLOT( updateFrozenLabels() ) );
connect( canvas, SIGNAL( renderComplete( QPainter * ) ), this, SLOT( highlightFrozenLabels() ) );
connect( QgisApp::instance()->actionToggleEditing(), SIGNAL( triggered() ), this, SLOT( updatePinnedLabels() ) );
connect( canvas, SIGNAL( renderComplete( QPainter * ) ), this, SLOT( highlightPinnedLabels() ) );
}

QgsMapToolFreezeLabels::~QgsMapToolFreezeLabels()
QgsMapToolPinLabels::~QgsMapToolPinLabels()
{
delete mRubberBand;
removeFrozenHighlights();
removePinnedHighlights();
}

void QgsMapToolFreezeLabels::canvasPressEvent( QMouseEvent * e )
void QgsMapToolPinLabels::canvasPressEvent( QMouseEvent * e )
{
Q_UNUSED( e );
mSelectRect.setRect( 0, 0, 0, 0 );
Expand All @@ -55,7 +55,7 @@ void QgsMapToolFreezeLabels::canvasPressEvent( QMouseEvent * e )
mRubberBand = new QgsRubberBand( mCanvas, true );
}

void QgsMapToolFreezeLabels::canvasMoveEvent( QMouseEvent * e )
void QgsMapToolPinLabels::canvasMoveEvent( QMouseEvent * e )
{
if ( e->buttons() != Qt::LeftButton )
return;
Expand All @@ -69,7 +69,7 @@ void QgsMapToolFreezeLabels::canvasMoveEvent( QMouseEvent * e )
QgsMapToolSelectUtils::setRubberBand( mCanvas, mSelectRect, mRubberBand );
}

void QgsMapToolFreezeLabels::canvasReleaseEvent( QMouseEvent * e )
void QgsMapToolPinLabels::canvasReleaseEvent( QMouseEvent * e )
{
//if the user simply clicked without dragging a rect
//we will fabricate a small 1x1 pix rect and then continue
Expand Down Expand Up @@ -101,7 +101,7 @@ void QgsMapToolFreezeLabels::canvasReleaseEvent( QMouseEvent * e )
QgsGeometry* selectGeom = mRubberBand->asGeometry();
QgsRectangle ext = selectGeom->boundingBox();

freezeThawLabels( ext, e );
pinUnpinLabels( ext, e );

delete selectGeom;

Expand All @@ -113,32 +113,32 @@ void QgsMapToolFreezeLabels::canvasReleaseEvent( QMouseEvent * e )
mDragging = false;
}

void QgsMapToolFreezeLabels::showFrozenLabels( bool show )
void QgsMapToolPinLabels::showPinnedLabels( bool show )
{
mShowFrozen = show;
if ( mShowFrozen )
mShowPinned = show;
if ( mShowPinned )
{
QgsDebugMsg( QString( "Toggling on frozen label highlighting" ) );
highlightFrozenLabels();
QgsDebugMsg( QString( "Toggling on pinned label highlighting" ) );
highlightPinnedLabels();
}
else
{
QgsDebugMsg( QString( "Toggling off frozen label highlighting" ) );
removeFrozenHighlights();
QgsDebugMsg( QString( "Toggling off pinned label highlighting" ) );
removePinnedHighlights();
}
}

// public slot to update frozen label highlights on layer edit mode change
void QgsMapToolFreezeLabels::updateFrozenLabels()
// public slot to update pinned label highlights on layer edit mode change
void QgsMapToolPinLabels::updatePinnedLabels()
{
if ( mShowFrozen )
if ( mShowPinned )
{
QgsDebugMsg( QString( "Updating highlighting due to layer editing mode change" ) );
mCanvas->refresh();
}
}

void QgsMapToolFreezeLabels::highlightLabel( QgsVectorLayer* vlayer,
void QgsMapToolPinLabels::highlightLabel( QgsVectorLayer* vlayer,
const QgsLabelPosition& labelpos,
const QString& id,
const QColor& color )
Expand Down Expand Up @@ -168,12 +168,12 @@ void QgsMapToolFreezeLabels::highlightLabel( QgsVectorLayer* vlayer,
}
}

// public slot to render highlight rectangles around frozen labels
void QgsMapToolFreezeLabels::highlightFrozenLabels()
// public slot to render highlight rectangles around pinned labels
void QgsMapToolPinLabels::highlightPinnedLabels()
{
removeFrozenHighlights();
removePinnedHighlights();

if ( !mShowFrozen )
if ( !mShowPinned )
{
return;
}
Expand All @@ -188,7 +188,7 @@ void QgsMapToolFreezeLabels::highlightFrozenLabels()
}
}

QgsDebugMsg( QString( "Highlighting frozen labels" ) );
QgsDebugMsg( QString( "Highlighting pinned labels" ) );

// get list of all drawn labels from all layers within given extent
QgsPalLabeling* labelEngine = dynamic_cast<QgsPalLabeling*>( mRender->labelingEngine() );
Expand All @@ -209,7 +209,7 @@ void QgsMapToolFreezeLabels::highlightFrozenLabels()
{
mCurrentLabelPos = *it;

if ( mCurrentLabelPos.isFrozen )
if ( mCurrentLabelPos.isPinned )
{
QString labelStringID = QString( "%0|%1" ).arg( mCurrentLabelPos.layerID, QString::number( mCurrentLabelPos.featureId ) );

Expand Down Expand Up @@ -242,7 +242,7 @@ void QgsMapToolFreezeLabels::highlightFrozenLabels()
QApplication::restoreOverrideCursor();
}

void QgsMapToolFreezeLabels::removeFrozenHighlights()
void QgsMapToolPinLabels::removePinnedHighlights()
{
QApplication::setOverrideCursor( Qt::BusyCursor );
foreach ( QgsHighlight *h, mHighlights )
Expand All @@ -253,12 +253,12 @@ void QgsMapToolFreezeLabels::removeFrozenHighlights()
QApplication::restoreOverrideCursor();
}

void QgsMapToolFreezeLabels::freezeThawLabels( const QgsRectangle& ext, QMouseEvent * e )
void QgsMapToolPinLabels::pinUnpinLabels( const QgsRectangle& ext, QMouseEvent * e )
{

bool doThaw = e->modifiers() & Qt::ShiftModifier ? true : false;
bool toggleThawOrFreeze = e->modifiers() & Qt::ControlModifier ? true : false;
bool doHide = ( doThaw && toggleThawOrFreeze );
bool doUnpin = e->modifiers() & Qt::ShiftModifier ? true : false;
bool toggleUnpinOrPin = e->modifiers() & Qt::ControlModifier ? true : false;
bool doHide = ( doUnpin && toggleUnpinOrPin );

// get list of all drawn labels from all layers within, or touching, chosen extent
bool labelChanged = false;
Expand Down Expand Up @@ -314,31 +314,31 @@ void QgsMapToolFreezeLabels::freezeThawLabels( const QgsRectangle& ext, QMouseEv

QString labelStringID = QString( "%0|%1" ).arg( mCurrentLabelPos.layerID, QString::number( mCurrentLabelPos.featureId ) );

// thaw label
if ( mCurrentLabelPos.isFrozen && !doHide && ( doThaw || toggleThawOrFreeze ) )
// unpin label
if ( mCurrentLabelPos.isPinned && !doHide && ( doUnpin || toggleUnpinOrPin ) )
{
// thaw previously frozen label (set attribute table fields to NULL)
if ( freezeThawLabel( vlayer, mCurrentLabelPos, false ) )
// unpin previously pinned label (set attribute table fields to NULL)
if ( pinUnpinLabel( vlayer, mCurrentLabelPos, false ) )
{
labelChanged = true;
}
else
{
QgsDebugMsg( QString( "Thaw failed for layer, label: %0, %1" ).arg( labellyr, labeltxt ) );
QgsDebugMsg( QString( "Unpin failed for layer, label: %0, %1" ).arg( labellyr, labeltxt ) );
}
}

// freeze label
if ( !mCurrentLabelPos.isFrozen && !doHide && ( !doThaw || toggleThawOrFreeze ) )
// pin label
if ( !mCurrentLabelPos.isPinned && !doHide && ( !doUnpin || toggleUnpinOrPin ) )
{
// freeze label's location, and optionally rotation, to attribute table
if ( freezeThawLabel( vlayer, mCurrentLabelPos, true ) )
// pin label's location, and optionally rotation, to attribute table
if ( pinUnpinLabel( vlayer, mCurrentLabelPos, true ) )
{
labelChanged = true;
}
else
{
QgsDebugMsg( QString( "Freeze failed for layer, label: %0, %1" ).arg( labellyr, labeltxt ) );
QgsDebugMsg( QString( "Pin failed for layer, label: %0, %1" ).arg( labellyr, labeltxt ) );
}
}

Expand All @@ -361,17 +361,17 @@ void QgsMapToolFreezeLabels::freezeThawLabels( const QgsRectangle& ext, QMouseEv
{
mCanvas->refresh();

if ( !mShowFrozen )
if ( !mShowPinned )
{
// toggle it on (freeze-thaw tool doesn't work well without it)
QgisApp::instance()->actionShowFrozenLabels()->setChecked( true );
// toggle it on (pin-unpin tool doesn't work well without it)
QgisApp::instance()->actionShowPinnedLabels()->setChecked( true );
}
}
}

bool QgsMapToolFreezeLabels::freezeThawLabel( QgsVectorLayer* vlayer,
bool QgsMapToolPinLabels::pinUnpinLabel( QgsVectorLayer* vlayer,
const QgsLabelPosition& labelpos,
bool freeze )
bool pin )
{
// skip diagrams
if ( labelpos.isDiagram )
Expand Down Expand Up @@ -399,15 +399,15 @@ bool QgsMapToolFreezeLabels::freezeThawLabel( QgsVectorLayer* vlayer,
bool hasRCol = ( layerIsRotatable( vlayer, rCol )
&& dataDefinedRotation( vlayer, mCurrentLabelPos.featureId, defRot, rSuccess, true ) );

// get whether to preserve predefined rotation data during label freeze/thaw operations
// get whether to preserve predefined rotation data during label pin/unpin operations
bool preserveRot = preserveRotation();

// edit attribute table
int fid = labelpos.featureId;

QString failedWrite = QString( "Failed write to attribute table" );

if ( freeze )
if ( pin )
{

// QgsPoint labelpoint = labelpos.cornerPoints.at( 0 );
Expand All @@ -431,7 +431,7 @@ bool QgsMapToolFreezeLabels::freezeThawLabel( QgsVectorLayer* vlayer,
labelY = transformedPoint.y();
}

vlayer->beginEditCommand( tr( "Label frozen" ) );
vlayer->beginEditCommand( tr( "Label pinned" ) );
if ( !vlayer->changeAttributeValue( fid, xCol, labelX, false ) )
{
QgsDebugMsg( failedWrite );
Expand All @@ -454,7 +454,7 @@ bool QgsMapToolFreezeLabels::freezeThawLabel( QgsVectorLayer* vlayer,
}
else
{
vlayer->beginEditCommand( tr( "Label thawed" ) );
vlayer->beginEditCommand( tr( "Label unpinned" ) );
if ( !vlayer->changeAttributeValue( fid, xCol, QVariant(), false ) )
{
QgsDebugMsg( failedWrite );
Expand All @@ -478,7 +478,7 @@ bool QgsMapToolFreezeLabels::freezeThawLabel( QgsVectorLayer* vlayer,
return true;
}

bool QgsMapToolFreezeLabels::hideLabel( QgsVectorLayer* vlayer,
bool QgsMapToolPinLabels::hideLabel( QgsVectorLayer* vlayer,
const QgsLabelPosition& labelpos )
{
// skip diagrams
Expand Down
54 changes: 27 additions & 27 deletions src/app/qgsmaptoolfreezelabels.h → src/app/qgsmaptoolpinlabels.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
qgsmaptoolfreezelabels.h
qgsmaptoolpinlabels.h
--------------------
begin : 2012-07-12
copyright : (C) 2012 by Larry Shaffer
Expand All @@ -15,8 +15,8 @@
* *
***************************************************************************/

#ifndef QGSMAPTOOLFREEZELABELS_H
#define QGSMAPTOOLFREEZELABELS_H
#ifndef QGSMAPTOOLPINLABELS_H
#define QGSMAPTOOLPINLABELS_H

#include "qgsmaptoollabel.h"
#include "qgsrectangle.h"
Expand All @@ -26,14 +26,14 @@
class QgsHighlight;
struct QgsLabelPosition;

/**A map tool for freezing (writing to attribute table) and thawing label positions and rotation*/
class QgsMapToolFreezeLabels: public QgsMapToolLabel
/**A map tool for pinning (writing to attribute table) and unpinning labelpositions and rotation*/
class QgsMapToolPinLabels: public QgsMapToolLabel
{
Q_OBJECT

public:
QgsMapToolFreezeLabels( QgsMapCanvas *canvas );
~QgsMapToolFreezeLabels();
QgsMapToolPinLabels( QgsMapCanvas *canvas );
~QgsMapToolPinLabels();

//! Overridden mouse move event
virtual void canvasMoveEvent( QMouseEvent * e );
Expand All @@ -44,22 +44,22 @@ class QgsMapToolFreezeLabels: public QgsMapToolLabel
//! Overridden mouse release event
virtual void canvasReleaseEvent( QMouseEvent * e );

bool isShowingFrozen() const { return mShowFrozen; }
void setShowingFrozen( bool showing ) { mShowFrozen = showing; }
bool isShowingPinned() const { return mShowPinned; }
void setShowingPinned( bool showing ) { mShowPinned = showing; }

//! Called when Show Frozen Labels tool is toggled, via its qgisapp.cpp slot
void showFrozenLabels( bool show );
//! Called when Show Pinned Labels tool is toggled, via its qgisapp.cpp slot
void showPinnedLabels( bool show );

//! Remove rectangles from around frozen labels
void removeFrozenHighlights();
//! Remove rectangles from around pinned labels
void removePinnedHighlights();

public slots:

//! Update frozen label highlights on layer edit mode change
void updateFrozenLabels();
//! Update pinned label highlights on layer edit mode change
void updatePinnedLabels();

//! Render highlight rectangles around frozen labels
void highlightFrozenLabels();
//! Render highlight rectangles around pinned labels
void highlightPinnedLabels();

protected:

Expand All @@ -68,8 +68,8 @@ class QgsMapToolFreezeLabels: public QgsMapToolLabel

//! Flag to indicate a map canvas drag operation is taking place
bool mDragging;
//! Flag to indicate whether to draw the highlight for frozen labels
bool mShowFrozen;
//! Flag to indicate whether to draw the highlight for pinned labels
bool mShowPinned;

//! Stores actual select rect
QRect mSelectRect;
Expand All @@ -82,22 +82,22 @@ class QgsMapToolFreezeLabels: public QgsMapToolLabel
//! Pointer to map renderer
QgsMapRenderer* mRender;

//! Highlights a given label relative to whether its frozen and editable
//! Highlights a given label relative to whether its pinned and editable
void highlightLabel( QgsVectorLayer* vlayer,
const QgsLabelPosition& labelpos,
const QString& id,
const QColor& color );

//! Select valid labels to freeze or thaw
void freezeThawLabels( const QgsRectangle& ext, QMouseEvent * e );
//! Select valid labels to pin or unpin
void pinUnpinLabels( const QgsRectangle& ext, QMouseEvent * e );

//! Freeze or thaw label relative to whether its editable
bool freezeThawLabel( QgsVectorLayer* vlayer,
const QgsLabelPosition& labelpos,
bool freeze );
//! Pin or unpin label relative to whether its editable
bool pinUnpinLabel( QgsVectorLayer* vlayer,
const QgsLabelPosition& labelpos,
bool pin );

//! Hide chosen label by setting font size to 0
bool hideLabel( QgsVectorLayer* vlayer, const QgsLabelPosition& labelpos );
};

#endif // QGSMAPTOOLFREEZELABELS_H
#endif // QGSMAPTOOLPINLABELS_H
4 changes: 2 additions & 2 deletions src/core/qgslabelsearchtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void QgsLabelSearchTree::labelsInRect( const QgsRectangle& r, QList<QgsLabelPosi
}
}

bool QgsLabelSearchTree::insertLabel( LabelPosition* labelPos, int featureId, const QString& layerName, bool diagram, bool frozen )
bool QgsLabelSearchTree::insertLabel( LabelPosition* labelPos, int featureId, const QString& layerName, bool diagram, bool pinned )
{
if ( !labelPos )
{
Expand All @@ -84,7 +84,7 @@ bool QgsLabelSearchTree::insertLabel( LabelPosition* labelPos, int featureId, co
cornerPoints.push_back( QgsPoint( labelPos->getX( i ), labelPos->getY( i ) ) );
}
QgsLabelPosition* newEntry = new QgsLabelPosition( featureId, labelPos->getAlpha(), cornerPoints, QgsRectangle( c_min[0], c_min[1], c_max[0], c_max[1] ),
labelPos->getWidth(), labelPos->getHeight(), layerName, labelPos->getUpsideDown(), diagram, frozen );
labelPos->getWidth(), labelPos->getHeight(), layerName, labelPos->getUpsideDown(), diagram, pinned );
mSpatialIndex.Insert( c_min, c_max, newEntry );
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgslabelsearchtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CORE_EXPORT QgsLabelSearchTree

/**Inserts label position. Does not take ownership of labelPos
@return true in case of success*/
bool insertLabel( LabelPosition* labelPos, int featureId, const QString& layerName, bool diagram = false, bool frozen = false );
bool insertLabel( LabelPosition* labelPos, int featureId, const QString& layerName, bool diagram = false, bool pinned = false );

private:
RTree<QgsLabelPosition*, double, 2, double> mSpatialIndex;
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgsmaprenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ struct QgsDiagramLayerSettings;

struct CORE_EXPORT QgsLabelPosition
{
QgsLabelPosition( int id, double r, const QVector< QgsPoint >& corners, const QgsRectangle& rect, double w, double h, const QString& layer, bool upside_down, bool diagram = false, bool frozen = false ):
featureId( id ), rotation( r ), cornerPoints( corners ), labelRect( rect ), width( w ), height( h ), layerID( layer ), upsideDown( upside_down ), isDiagram( diagram ), isFrozen( frozen ) {}
QgsLabelPosition(): featureId( -1 ), rotation( 0 ), labelRect( QgsRectangle() ), width( 0 ), height( 0 ), layerID( "" ), upsideDown( false ), isDiagram( false ), isFrozen( false ) {}
QgsLabelPosition( int id, double r, const QVector< QgsPoint >& corners, const QgsRectangle& rect, double w, double h, const QString& layer, bool upside_down, bool diagram = false, bool pinned = false ):
featureId( id ), rotation( r ), cornerPoints( corners ), labelRect( rect ), width( w ), height( h ), layerID( layer ), upsideDown( upside_down ), isDiagram( diagram ), isPinned( pinned ) {}
QgsLabelPosition(): featureId( -1 ), rotation( 0 ), labelRect( QgsRectangle() ), width( 0 ), height( 0 ), layerID( "" ), upsideDown( false ), isDiagram( false ), isPinned( false ) {}
int featureId;
double rotation;
QVector< QgsPoint > cornerPoints;
Expand All @@ -55,7 +55,7 @@ struct CORE_EXPORT QgsLabelPosition
QString layerID;
bool upsideDown;
bool isDiagram;
bool isFrozen;
bool isPinned;
};

/** Labeling engine interface.
Expand Down
14 changes: 7 additions & 7 deletions src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class QgsPalGeometry : public PalGeometry
, mId( id )
, mInfo( NULL )
, mIsDiagram( false )
, mIsFrozen( false )
, mIsPinned( false )
{
mStrId = FID_TO_STRING( id ).toAscii();
}
Expand Down Expand Up @@ -113,8 +113,8 @@ class QgsPalGeometry : public PalGeometry
void setIsDiagram( bool d ) { mIsDiagram = d; }
bool isDiagram() const { return mIsDiagram; }

void setIsFrozen( bool f ) { mIsFrozen = f; }
bool isFrozen() const { return mIsFrozen; }
void setIsPinned( bool f ) { mIsPinned = f; }
bool isPinned() const { return mIsPinned; }

void addDiagramAttribute( int index, QVariant value ) { mDiagramAttributes.insert( index, value ); }
const QgsAttributeMap& diagramAttributes() { return mDiagramAttributes; }
Expand All @@ -126,7 +126,7 @@ class QgsPalGeometry : public PalGeometry
QgsFeatureId mId;
LabelInfo* mInfo;
bool mIsDiagram;
bool mIsFrozen;
bool mIsPinned;
/**Stores attribute values for data defined properties*/
QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > mDataDefinedValues;

Expand Down Expand Up @@ -716,8 +716,8 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
lbl->addDataDefinedValue( dIt.key(), f.attributeMap()[dIt.value()] );
}

// set geometry's frozen property
lbl->setIsFrozen( dataDefinedPosition );
// set geometry's pinned property
lbl->setIsPinned( dataDefinedPosition );
}

int QgsPalLayerSettings::sizeToPixel( double size, const QgsRenderContext& c ) const
Expand Down Expand Up @@ -1246,7 +1246,7 @@ void QgsPalLabeling::drawLabeling( QgsRenderContext& context )

if ( mLabelSearchTree )
{
mLabelSearchTree->insertLabel( *it, QString( palGeometry->strId() ).toInt(), ( *it )->getLayerName(), false, palGeometry->isFrozen() );
mLabelSearchTree->insertLabel( *it, QString( palGeometry->strId() ).toInt(), ( *it )->getLayerName(), false, palGeometry->isPinned() );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspallabeling.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class CORE_EXPORT QgsPalLayerSettings
/**Stores field indices for data defined layer properties*/
QMap< DataDefinedProperties, int > dataDefinedProperties;

bool preserveRotation; // preserve predefined rotation data during label freeze/thaw operations
bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations

/**Calculates pixel size (considering output size should be in pixel or map units, scale factors and oversampling)
@param size size to convert
Expand Down
23 changes: 12 additions & 11 deletions src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@
<bool>false</bool>
</attribute>
<addaction name="mActionLabeling"/>
<addaction name="mActionShowFrozenLabels"/>
<addaction name="mActionFreezeLabels"/>
<addaction name="mActionShowPinnedLabels"/>
<addaction name="mActionPinLabels"/>
<addaction name="mActionMoveLabel"/>
<addaction name="mActionRotateLabel"/>
<addaction name="mActionChangeLabelProperties"/>
Expand Down Expand Up @@ -1707,35 +1707,36 @@
<string>Creates a scale bar that is displayed on the map canvas</string>
</property>
</action>
<action name="mActionFreezeLabels">
<action name="mActionPinLabels">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionFreezeLabels.png</normaloff>:/images/themes/default/mActionFreezeLabels.png</iconset>
<normaloff>:/images/themes/default/mActionPinLabels.svg</normaloff>:/images/themes/default/mActionPinLabels.svg</iconset>
</property>
<property name="text">
<string>Freeze or Thaw Labels</string>
<string>Pin/Unpin Labels</string>
</property>
<property name="toolTip">
<string>Freeze or Thaw Labels
Shift thaws, Ctl (Cmd) toggles, Shift+Ctl (Cmd) hides</string>
<string>Pin/Unpin and Hide/Show Labels
Shift unpins, Ctl (Cmd) toggles pin/unpin
Shift+Ctl (Cmd) on label hides, Shift+Ctl (Cmd) on feature shows label</string>
</property>
</action>
<action name="mActionShowFrozenLabels">
<action name="mActionShowPinnedLabels">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionShowFrozenLabels.png</normaloff>:/images/themes/default/mActionShowFrozenLabels.png</iconset>
<normaloff>:/images/themes/default/mActionShowPinnedLabels.svg</normaloff>:/images/themes/default/mActionShowPinnedLabels.svg</iconset>
</property>
<property name="text">
<string>Show Frozen Labels</string>
<string>Highlight Pinned Labels</string>
</property>
<property name="toolTip">
<string>Show Frozen Labels</string>
<string>Highlight Pinned Labels</string>
</property>
</action>
<action name="mActionNewBlankProject">
Expand Down
4 changes: 2 additions & 2 deletions src/ui/qgslabelingguibase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1113,13 +1113,13 @@
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="chkPreserveRotation">
<property name="toolTip">
<string>Uncheck to write labeling engine derived rotation on freeze and NULL on thaw</string>
<string>Uncheck to write labeling engine derived rotation on pin and NULL on unpin</string>
</property>
<property name="styleSheet">
<string notr="true">margin-left: 12px;</string>
</property>
<property name="text">
<string>Preserve existing rotation values during label freeze/thaw operations</string>
<string>Preserve existing rotation values during label pin/unpin operations</string>
</property>
<property name="checked">
<bool>true</bool>
Expand Down