Skip to content

Commit f69d8d2

Browse files
committedAug 11, 2012
Small refactoring to switch freeze/thaw to pin/unpin label tool
- Thanks to Tim for the better metaphor for the tool - Freeze/thaw was a bit obtuse, pinning a label is a more ubiquitous mapping concept - New icons to represent switch
1 parent 304cc4b commit f69d8d2

22 files changed

+1858
-441
lines changed
 

‎images/images.qrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<file>themes/default/mActionFileSmall.png</file>
7878
<file>themes/default/mActionFolder.png</file>
7979
<file>themes/default/mActionFormAnnotation.png</file>
80-
<file>themes/default/mActionFreezeLabels.svg</file>
80+
<file>themes/default/mActionPinLabels.svg</file>
8181
<file>themes/default/mActionFromSelectedFeature.png</file>
8282
<file>themes/default/mActionFullCumulativeCutStretch.png</file>
8383
<file>themes/default/mActionFullHistogramStretch.png</file>
@@ -149,7 +149,7 @@
149149
<file>themes/default/mActionSelectRectangle.png</file>
150150
<file>themes/default/mActionShowAllLayers.png</file>
151151
<file>themes/default/mActionShowBookmarks.png</file>
152-
<file>themes/default/mActionShowFrozenLabels.svg</file>
152+
<file>themes/default/mActionShowPinnedLabels.svg</file>
153153
<file>themes/default/mActionShowPluginManager.png</file>
154154
<file>themes/default/mActionSimplify.png</file>
155155
<file>themes/default/mActionSplitFeatures.png</file>
@@ -295,7 +295,7 @@
295295
<file>themes/gis/mActionFileSave.png</file>
296296
<file>themes/gis/mActionFolder.png</file>
297297
<file>themes/gis/mActionFormAnnotation.png</file>
298-
<file>themes/gis/mActionFreezeLabels.svg</file>
298+
<file>themes/gis/mActionPinLabels.svg</file>
299299
<file>themes/gis/mActionGroupItems.png</file>
300300
<file>themes/gis/mActionHelpContents.png</file>
301301
<file>themes/gis/mActionHideAllLayers.png</file>
@@ -348,7 +348,7 @@
348348
<file>themes/gis/mActionSelectRectangle.png</file>
349349
<file>themes/gis/mActionShowAllLayers.png</file>
350350
<file>themes/gis/mActionShowBookmarks.png</file>
351-
<file>themes/gis/mActionShowFrozenLabels.svg</file>
351+
<file>themes/gis/mActionShowPinnedLabels.svg</file>
352352
<file>themes/gis/mActionSimplify.png</file>
353353
<file>themes/gis/mActionSplitFeatures.png</file>
354354
<file>themes/gis/mActionSplitFeatures.svg</file>

‎images/themes/default/mActionFreezeLabels.svg

Lines changed: 0 additions & 105 deletions
This file was deleted.

‎images/themes/default/mActionPinLabels.svg

Lines changed: 559 additions & 0 deletions
Loading

‎images/themes/default/mActionShowFrozenLabels.svg

Lines changed: 0 additions & 90 deletions
This file was deleted.

‎images/themes/default/mActionShowPinnedLabels.svg

Lines changed: 974 additions & 0 deletions
Loading

‎images/themes/gis/mActionFreezeLabels.svg renamed to ‎images/themes/gis/mActionPinLabels.svg

Lines changed: 83 additions & 34 deletions
Loading

‎images/themes/gis/mActionShowFrozenLabels.svg renamed to ‎images/themes/gis/mActionShowPinnedLabels.svg

Lines changed: 93 additions & 64 deletions
Loading

‎src/app/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ SET(QGIS_APP_SRCS
5555
qgsmaptooledit.cpp
5656
qgsmaptoolfeatureaction.cpp
5757
qgsmaptoolformannotation.cpp
58-
qgsmaptoolfreezelabels.cpp
58+
qgsmaptoolpinlabels.cpp
5959
qgsmaptoolidentify.cpp
6060
qgsmaptoollabel.cpp
6161
qgsmaptoolmeasureangle.cpp
@@ -205,7 +205,7 @@ SET (QGIS_APP_MOC_HDRS
205205
qgsmaptooldeletering.h
206206
qgsmaptooldeletevertex.h
207207
qgsmaptoolfeatureaction.h
208-
qgsmaptoolfreezelabels.h
208+
qgsmaptoolpinlabels.h
209209
qgsmaptoolidentify.h
210210
qgsmaptoolmeasureangle.h
211211
qgsmaptoolmovefeature.h

‎src/app/qgisapp.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
#include "qgsmaptoolzoom.h"
235235
#include "qgsmaptoolsimplify.h"
236236
#include "qgsmeasuretool.h"
237-
#include "qgsmaptoolfreezelabels.h"
237+
#include "qgsmaptoolpinlabels.h"
238238
#include "qgsmaptoolmovelabel.h"
239239
#include "qgsmaptoolrotatelabel.h"
240240
#include "qgsmaptoolchangelabelproperties.h"
@@ -714,7 +714,7 @@ QgisApp::~QgisApp()
714714
delete mMapTools.mAddPart;
715715
delete mMapTools.mNodeTool;
716716
delete mMapTools.mRotatePointSymbolsTool;
717-
delete mMapTools.mFreezeLabels;
717+
delete mMapTools.mPinLabels;
718718
delete mMapTools.mMoveLabel;
719719
delete mMapTools.mRotateLabel;
720720
delete mMapTools.mChangeLabelProperties;
@@ -982,8 +982,8 @@ void QgisApp::createActions()
982982
connect( mActionAbout, SIGNAL( triggered() ), this, SLOT( about() ) );
983983
connect( mActionSponsors, SIGNAL( triggered() ), this, SLOT( sponsors() ) );
984984

985-
connect( mActionShowFrozenLabels, SIGNAL( toggled( bool ) ), this, SLOT( showFrozenLabels( bool ) ) );
986-
connect( mActionFreezeLabels, SIGNAL( triggered() ), this, SLOT( freezeLabels() ) );
985+
connect( mActionShowPinnedLabels, SIGNAL( toggled( bool ) ), this, SLOT( showPinnedLabels( bool ) ) );
986+
connect( mActionPinLabels, SIGNAL( triggered() ), this, SLOT( pinLabels() ) );
987987
connect( mActionMoveLabel, SIGNAL( triggered() ), this, SLOT( moveLabel() ) );
988988
connect( mActionRotateLabel, SIGNAL( triggered() ), this, SLOT( rotateLabel() ) );
989989
connect( mActionChangeLabelProperties, SIGNAL( triggered() ), this, SLOT( changeLabelProperties() ) );
@@ -1093,7 +1093,7 @@ void QgisApp::createActionGroups()
10931093
mMapToolGroup->addAction( mActionMergeFeatureAttributes );
10941094
mMapToolGroup->addAction( mActionNodeTool );
10951095
mMapToolGroup->addAction( mActionRotatePointSymbols );
1096-
mMapToolGroup->addAction( mActionFreezeLabels );
1096+
mMapToolGroup->addAction( mActionPinLabels );
10971097
mMapToolGroup->addAction( mActionMoveLabel );
10981098
mMapToolGroup->addAction( mActionRotateLabel );
10991099
mMapToolGroup->addAction( mActionChangeLabelProperties );
@@ -1626,8 +1626,8 @@ void QgisApp::setTheme( QString theThemeName )
16261626
mActionFormAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionFormAnnotation.png" ) );
16271627
mActionTextAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionTextAnnotation.png" ) );
16281628
mActionLabeling->setIcon( QgsApplication::getThemeIcon( "/mActionLabeling.png" ) );
1629-
mActionShowFrozenLabels->setIcon( QgsApplication::getThemeIcon( "/mActionShowFrozenLabels.svg" ) );
1630-
mActionFreezeLabels->setIcon( QgsApplication::getThemeIcon( "/mActionFreezeLabels.svg" ) );
1629+
mActionShowPinnedLabels->setIcon( QgsApplication::getThemeIcon( "/mActionShowPinnedLabels.svg" ) );
1630+
mActionPinLabels->setIcon( QgsApplication::getThemeIcon( "/mActionPinLabels.svg" ) );
16311631
mActionMoveLabel->setIcon( QgsApplication::getThemeIcon( "/mActionMoveLabel.png" ) );
16321632
mActionRotateLabel->setIcon( QgsApplication::getThemeIcon( "/mActionRotateLabel.svg" ) );
16331633
mActionChangeLabelProperties->setIcon( QgsApplication::getThemeIcon( "/mActionChangeLabelProperties.png" ) );
@@ -1794,8 +1794,8 @@ void QgisApp::createCanvasTools()
17941794
mMapTools.mNodeTool->setAction( mActionNodeTool );
17951795
mMapTools.mRotatePointSymbolsTool = new QgsMapToolRotatePointSymbols( mMapCanvas );
17961796
mMapTools.mRotatePointSymbolsTool->setAction( mActionRotatePointSymbols );
1797-
mMapTools.mFreezeLabels = new QgsMapToolFreezeLabels( mMapCanvas );
1798-
mMapTools.mFreezeLabels->setAction( mActionFreezeLabels );
1797+
mMapTools.mPinLabels = new QgsMapToolPinLabels( mMapCanvas );
1798+
mMapTools.mPinLabels->setAction( mActionPinLabels );
17991799
mMapTools.mMoveLabel = new QgsMapToolMoveLabel( mMapCanvas );
18001800
mMapTools.mMoveLabel->setAction( mActionMoveLabel );
18011801
mMapTools.mRotateLabel = new QgsMapToolRotateLabel( mMapCanvas );
@@ -4308,15 +4308,15 @@ bool QgisApp::loadAnnotationItemsFromProject( const QDomDocument& doc )
43084308
return true;
43094309
}
43104310

4311-
void QgisApp::showFrozenLabels( bool show )
4311+
void QgisApp::showPinnedLabels( bool show )
43124312
{
4313-
qobject_cast<QgsMapToolFreezeLabels*>( mMapTools.mFreezeLabels )->showFrozenLabels( show );
4313+
qobject_cast<QgsMapToolPinLabels*>( mMapTools.mPinLabels )->showPinnedLabels( show );
43144314
}
43154315

4316-
void QgisApp::freezeLabels()
4316+
void QgisApp::pinLabels()
43174317
{
4318-
mActionShowFrozenLabels->setChecked( true );
4319-
mMapCanvas->setMapTool( mMapTools.mFreezeLabels );
4318+
mActionShowPinnedLabels->setChecked( true );
4319+
mMapCanvas->setMapTool( mMapTools.mPinLabels );
43204320
}
43214321

43224322
void QgisApp::moveLabel()
@@ -6668,7 +6668,7 @@ void QgisApp::legendLayerSelectionChanged( void )
66686668

66696669
void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
66706670
{
6671-
bool enableMove = false, enableRotate = false, enableFreeze = false, enableChange = false;
6671+
bool enableMove = false, enableRotate = false, enablePin = false, enableChange = false;
66726672

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

66816681
int colX, colY, colAng;
6682-
enableFreeze =
6683-
enableFreeze ||
6684-
( qobject_cast<QgsMapToolFreezeLabels*>( mMapTools.mFreezeLabels ) &&
6685-
qobject_cast<QgsMapToolFreezeLabels*>( mMapTools.mFreezeLabels )->layerCanFreeze( vlayer, colX, colY ) );
6682+
enablePin =
6683+
enablePin ||
6684+
( qobject_cast<QgsMapToolPinLabels*>( mMapTools.mPinLabels ) &&
6685+
qobject_cast<QgsMapToolPinLabels*>( mMapTools.mPinLabels )->layerCanPin( vlayer, colX, colY ) );
66866686

66876687
enableMove =
66886688
enableMove ||
@@ -6698,11 +6698,11 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
66986698

66996699
enableChange = true;
67006700

6701-
if ( enableFreeze && enableMove && enableRotate && enableChange )
6701+
if ( enablePin && enableMove && enableRotate && enableChange )
67026702
break;
67036703
}
67046704

6705-
mActionFreezeLabels->setEnabled( enableFreeze );
6705+
mActionPinLabels->setEnabled( enablePin );
67066706
mActionMoveLabel->setEnabled( enableMove );
67076707
mActionRotateLabel->setEnabled( enableRotate );
67086708
mActionChangeLabelProperties->setEnabled( enableChange );
@@ -6749,7 +6749,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
67496749
mActionMergeFeatureAttributes->setEnabled( false );
67506750
mActionRotatePointSymbols->setEnabled( false );
67516751

6752-
mActionFreezeLabels->setEnabled( false );
6752+
mActionPinLabels->setEnabled( false );
67536753
mActionMoveLabel->setEnabled( false );
67546754
mActionRotateLabel->setEnabled( false );
67556755
mActionChangeLabelProperties->setEnabled( false );

‎src/app/qgisapp.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
314314
QAction *actionAbout() { return mActionAbout; }
315315
QAction *actionSponsors() { return mActionSponsors; }
316316

317-
QAction *actionShowFrozenLabels() { return mActionShowFrozenLabels; }
317+
QAction *actionShowPinnedLabels() { return mActionShowPinnedLabels; }
318318

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

873873
bool loadAnnotationItemsFromProject( const QDomDocument& doc );
874874

875-
//! Toggles whether to show frozen labels
876-
void showFrozenLabels( bool show );
877-
//! Activates freeze labels tool
878-
void freezeLabels();
875+
//! Toggles whether to show pinned labels
876+
void showPinnedLabels( bool show );
877+
//! Activates pin labels tool
878+
void pinLabels();
879879
//! Activates the move label tool
880880
void moveLabel();
881881
//! Activates rotate label tool
@@ -1077,7 +1077,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
10771077
QgsMapTool* mAnnotation;
10781078
QgsMapTool* mFormAnnotation;
10791079
QgsMapTool* mTextAnnotation;
1080-
QgsMapTool* mFreezeLabels;
1080+
QgsMapTool* mPinLabels;
10811081
QgsMapTool* mMoveLabel;
10821082
QgsMapTool* mRotateLabel;
10831083
QgsMapTool* mChangeLabelProperties;

‎src/app/qgsmaptoollabel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ bool QgsMapToolLabel::labelMoveable( const QgsMapLayer* ml, int& xCol, int& yCol
531531
return true;
532532
}
533533

534-
bool QgsMapToolLabel::layerCanFreeze( const QgsMapLayer* ml, int& xCol, int& yCol ) const
534+
bool QgsMapToolLabel::layerCanPin( const QgsMapLayer* ml, int& xCol, int& yCol ) const
535535
{
536536
const QgsVectorLayer* vlayer = dynamic_cast<const QgsVectorLayer*>( ml );
537537
if ( !vlayer || !vlayer->isEditable() )

‎src/app/qgsmaptoollabel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class QgsMapToolLabel: public QgsMapTool
4545
@param xCol out: index of the attribute for data defined x coordinate
4646
@param yCol out: index of the attribute for data defined y coordinate
4747
@return true if layer fields set up and exist*/
48-
bool layerCanFreeze( const QgsMapLayer* ml, int& xCol, int& yCol ) const;
48+
bool layerCanPin( const QgsMapLayer* ml, int& xCol, int& yCol ) const;
4949
/**Checks if labels in a layer can be rotated
5050
@param rotationCol out: attribute column for data defined label rotation*/
5151
bool layerIsRotatable( const QgsMapLayer* layer, int& rotationCol ) const;
@@ -93,7 +93,7 @@ class QgsMapToolLabel: public QgsMapTool
9393
/**Returns the font for the current feature (considering default font and data defined properties*/
9494
QFont labelFontCurrentFeature();
9595

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

9999
/**Get data defined position of a feature

‎src/app/qgsmaptoolmovelabel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ void QgsMapToolMoveLabel::canvasReleaseEvent( QMouseEvent * e )
154154
vlayer->changeAttributeValue( mCurrentLabelPos.featureId, yCol, yPosNew, false );
155155

156156
// set rotation to that of label, if data-defined and no rotation set yet
157-
// honor whether to preserve preexisting data on freeze
157+
// honor whether to preserve preexisting data on pin
158158
// must come after setting x and y positions
159159
int rCol;
160160
if ( !mCurrentLabelPos.isDiagram
161-
&& !mCurrentLabelPos.isFrozen
161+
&& !mCurrentLabelPos.isPinned
162162
&& !preserveRotation()
163163
&& layerIsRotatable( vlayer, rCol ) )
164164
{

‎src/app/qgsmaptoolfreezelabels.cpp renamed to ‎src/app/qgsmaptoolpinlabels.cpp

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
qgsmaptoolfreezelabels.cpp
2+
qgsmaptoolpinlabels.cpp
33
-----------------------
44
begin : 2012-07-12
55
copyright : (C) 2012 by Larry Shaffer
@@ -15,7 +15,7 @@
1515
* *
1616
***************************************************************************/
1717

18-
#include "qgsmaptoolfreezelabels.h"
18+
#include "qgsmaptoolpinlabels.h"
1919

2020
#include "qgisapp.h"
2121
#include "qgsapplication.h"
@@ -30,23 +30,23 @@
3030
#include <qgslogger.h>
3131
#include <QMouseEvent>
3232

33-
QgsMapToolFreezeLabels::QgsMapToolFreezeLabels( QgsMapCanvas* canvas ): QgsMapToolLabel( canvas )
33+
QgsMapToolPinLabels::QgsMapToolPinLabels( QgsMapCanvas* canvas ): QgsMapToolLabel( canvas )
3434
{
3535
mRender = 0;
3636
mRubberBand = 0;
37-
mShowFrozen = false;
37+
mShowPinned = false;
3838

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

43-
QgsMapToolFreezeLabels::~QgsMapToolFreezeLabels()
43+
QgsMapToolPinLabels::~QgsMapToolPinLabels()
4444
{
4545
delete mRubberBand;
46-
removeFrozenHighlights();
46+
removePinnedHighlights();
4747
}
4848

49-
void QgsMapToolFreezeLabels::canvasPressEvent( QMouseEvent * e )
49+
void QgsMapToolPinLabels::canvasPressEvent( QMouseEvent * e )
5050
{
5151
Q_UNUSED( e );
5252
mSelectRect.setRect( 0, 0, 0, 0 );
@@ -55,7 +55,7 @@ void QgsMapToolFreezeLabels::canvasPressEvent( QMouseEvent * e )
5555
mRubberBand = new QgsRubberBand( mCanvas, true );
5656
}
5757

58-
void QgsMapToolFreezeLabels::canvasMoveEvent( QMouseEvent * e )
58+
void QgsMapToolPinLabels::canvasMoveEvent( QMouseEvent * e )
5959
{
6060
if ( e->buttons() != Qt::LeftButton )
6161
return;
@@ -69,7 +69,7 @@ void QgsMapToolFreezeLabels::canvasMoveEvent( QMouseEvent * e )
6969
QgsMapToolSelectUtils::setRubberBand( mCanvas, mSelectRect, mRubberBand );
7070
}
7171

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

104-
freezeThawLabels( ext, e );
104+
pinUnpinLabels( ext, e );
105105

106106
delete selectGeom;
107107

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

116-
void QgsMapToolFreezeLabels::showFrozenLabels( bool show )
116+
void QgsMapToolPinLabels::showPinnedLabels( bool show )
117117
{
118-
mShowFrozen = show;
119-
if ( mShowFrozen )
118+
mShowPinned = show;
119+
if ( mShowPinned )
120120
{
121-
QgsDebugMsg( QString( "Toggling on frozen label highlighting" ) );
122-
highlightFrozenLabels();
121+
QgsDebugMsg( QString( "Toggling on pinned label highlighting" ) );
122+
highlightPinnedLabels();
123123
}
124124
else
125125
{
126-
QgsDebugMsg( QString( "Toggling off frozen label highlighting" ) );
127-
removeFrozenHighlights();
126+
QgsDebugMsg( QString( "Toggling off pinned label highlighting" ) );
127+
removePinnedHighlights();
128128
}
129129
}
130130

131-
// public slot to update frozen label highlights on layer edit mode change
132-
void QgsMapToolFreezeLabels::updateFrozenLabels()
131+
// public slot to update pinned label highlights on layer edit mode change
132+
void QgsMapToolPinLabels::updatePinnedLabels()
133133
{
134-
if ( mShowFrozen )
134+
if ( mShowPinned )
135135
{
136136
QgsDebugMsg( QString( "Updating highlighting due to layer editing mode change" ) );
137137
mCanvas->refresh();
138138
}
139139
}
140140

141-
void QgsMapToolFreezeLabels::highlightLabel( QgsVectorLayer* vlayer,
141+
void QgsMapToolPinLabels::highlightLabel( QgsVectorLayer* vlayer,
142142
const QgsLabelPosition& labelpos,
143143
const QString& id,
144144
const QColor& color )
@@ -168,12 +168,12 @@ void QgsMapToolFreezeLabels::highlightLabel( QgsVectorLayer* vlayer,
168168
}
169169
}
170170

171-
// public slot to render highlight rectangles around frozen labels
172-
void QgsMapToolFreezeLabels::highlightFrozenLabels()
171+
// public slot to render highlight rectangles around pinned labels
172+
void QgsMapToolPinLabels::highlightPinnedLabels()
173173
{
174-
removeFrozenHighlights();
174+
removePinnedHighlights();
175175

176-
if ( !mShowFrozen )
176+
if ( !mShowPinned )
177177
{
178178
return;
179179
}
@@ -188,7 +188,7 @@ void QgsMapToolFreezeLabels::highlightFrozenLabels()
188188
}
189189
}
190190

191-
QgsDebugMsg( QString( "Highlighting frozen labels" ) );
191+
QgsDebugMsg( QString( "Highlighting pinned labels" ) );
192192

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

212-
if ( mCurrentLabelPos.isFrozen )
212+
if ( mCurrentLabelPos.isPinned )
213213
{
214214
QString labelStringID = QString( "%0|%1" ).arg( mCurrentLabelPos.layerID, QString::number( mCurrentLabelPos.featureId ) );
215215

@@ -242,7 +242,7 @@ void QgsMapToolFreezeLabels::highlightFrozenLabels()
242242
QApplication::restoreOverrideCursor();
243243
}
244244

245-
void QgsMapToolFreezeLabels::removeFrozenHighlights()
245+
void QgsMapToolPinLabels::removePinnedHighlights()
246246
{
247247
QApplication::setOverrideCursor( Qt::BusyCursor );
248248
foreach ( QgsHighlight *h, mHighlights )
@@ -253,12 +253,12 @@ void QgsMapToolFreezeLabels::removeFrozenHighlights()
253253
QApplication::restoreOverrideCursor();
254254
}
255255

256-
void QgsMapToolFreezeLabels::freezeThawLabels( const QgsRectangle& ext, QMouseEvent * e )
256+
void QgsMapToolPinLabels::pinUnpinLabels( const QgsRectangle& ext, QMouseEvent * e )
257257
{
258258

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

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

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

317-
// thaw label
318-
if ( mCurrentLabelPos.isFrozen && !doHide && ( doThaw || toggleThawOrFreeze ) )
317+
// unpin label
318+
if ( mCurrentLabelPos.isPinned && !doHide && ( doUnpin || toggleUnpinOrPin ) )
319319
{
320-
// thaw previously frozen label (set attribute table fields to NULL)
321-
if ( freezeThawLabel( vlayer, mCurrentLabelPos, false ) )
320+
// unpin previously pinned label (set attribute table fields to NULL)
321+
if ( pinUnpinLabel( vlayer, mCurrentLabelPos, false ) )
322322
{
323323
labelChanged = true;
324324
}
325325
else
326326
{
327-
QgsDebugMsg( QString( "Thaw failed for layer, label: %0, %1" ).arg( labellyr, labeltxt ) );
327+
QgsDebugMsg( QString( "Unpin failed for layer, label: %0, %1" ).arg( labellyr, labeltxt ) );
328328
}
329329
}
330330

331-
// freeze label
332-
if ( !mCurrentLabelPos.isFrozen && !doHide && ( !doThaw || toggleThawOrFreeze ) )
331+
// pin label
332+
if ( !mCurrentLabelPos.isPinned && !doHide && ( !doUnpin || toggleUnpinOrPin ) )
333333
{
334-
// freeze label's location, and optionally rotation, to attribute table
335-
if ( freezeThawLabel( vlayer, mCurrentLabelPos, true ) )
334+
// pin label's location, and optionally rotation, to attribute table
335+
if ( pinUnpinLabel( vlayer, mCurrentLabelPos, true ) )
336336
{
337337
labelChanged = true;
338338
}
339339
else
340340
{
341-
QgsDebugMsg( QString( "Freeze failed for layer, label: %0, %1" ).arg( labellyr, labeltxt ) );
341+
QgsDebugMsg( QString( "Pin failed for layer, label: %0, %1" ).arg( labellyr, labeltxt ) );
342342
}
343343
}
344344

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

364-
if ( !mShowFrozen )
364+
if ( !mShowPinned )
365365
{
366-
// toggle it on (freeze-thaw tool doesn't work well without it)
367-
QgisApp::instance()->actionShowFrozenLabels()->setChecked( true );
366+
// toggle it on (pin-unpin tool doesn't work well without it)
367+
QgisApp::instance()->actionShowPinnedLabels()->setChecked( true );
368368
}
369369
}
370370
}
371371

372-
bool QgsMapToolFreezeLabels::freezeThawLabel( QgsVectorLayer* vlayer,
372+
bool QgsMapToolPinLabels::pinUnpinLabel( QgsVectorLayer* vlayer,
373373
const QgsLabelPosition& labelpos,
374-
bool freeze )
374+
bool pin )
375375
{
376376
// skip diagrams
377377
if ( labelpos.isDiagram )
@@ -399,15 +399,15 @@ bool QgsMapToolFreezeLabels::freezeThawLabel( QgsVectorLayer* vlayer,
399399
bool hasRCol = ( layerIsRotatable( vlayer, rCol )
400400
&& dataDefinedRotation( vlayer, mCurrentLabelPos.featureId, defRot, rSuccess, true ) );
401401

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

405405
// edit attribute table
406406
int fid = labelpos.featureId;
407407

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

410-
if ( freeze )
410+
if ( pin )
411411
{
412412

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

434-
vlayer->beginEditCommand( tr( "Label frozen" ) );
434+
vlayer->beginEditCommand( tr( "Label pinned" ) );
435435
if ( !vlayer->changeAttributeValue( fid, xCol, labelX, false ) )
436436
{
437437
QgsDebugMsg( failedWrite );
@@ -454,7 +454,7 @@ bool QgsMapToolFreezeLabels::freezeThawLabel( QgsVectorLayer* vlayer,
454454
}
455455
else
456456
{
457-
vlayer->beginEditCommand( tr( "Label thawed" ) );
457+
vlayer->beginEditCommand( tr( "Label unpinned" ) );
458458
if ( !vlayer->changeAttributeValue( fid, xCol, QVariant(), false ) )
459459
{
460460
QgsDebugMsg( failedWrite );
@@ -478,7 +478,7 @@ bool QgsMapToolFreezeLabels::freezeThawLabel( QgsVectorLayer* vlayer,
478478
return true;
479479
}
480480

481-
bool QgsMapToolFreezeLabels::hideLabel( QgsVectorLayer* vlayer,
481+
bool QgsMapToolPinLabels::hideLabel( QgsVectorLayer* vlayer,
482482
const QgsLabelPosition& labelpos )
483483
{
484484
// skip diagrams
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
qgsmaptoolfreezelabels.h
2+
qgsmaptoolpinlabels.h
33
--------------------
44
begin : 2012-07-12
55
copyright : (C) 2012 by Larry Shaffer
@@ -15,8 +15,8 @@
1515
* *
1616
***************************************************************************/
1717

18-
#ifndef QGSMAPTOOLFREEZELABELS_H
19-
#define QGSMAPTOOLFREEZELABELS_H
18+
#ifndef QGSMAPTOOLPINLABELS_H
19+
#define QGSMAPTOOLPINLABELS_H
2020

2121
#include "qgsmaptoollabel.h"
2222
#include "qgsrectangle.h"
@@ -26,14 +26,14 @@
2626
class QgsHighlight;
2727
struct QgsLabelPosition;
2828

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

3434
public:
35-
QgsMapToolFreezeLabels( QgsMapCanvas *canvas );
36-
~QgsMapToolFreezeLabels();
35+
QgsMapToolPinLabels( QgsMapCanvas *canvas );
36+
~QgsMapToolPinLabels();
3737

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

47-
bool isShowingFrozen() const { return mShowFrozen; }
48-
void setShowingFrozen( bool showing ) { mShowFrozen = showing; }
47+
bool isShowingPinned() const { return mShowPinned; }
48+
void setShowingPinned( bool showing ) { mShowPinned = showing; }
4949

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

53-
//! Remove rectangles from around frozen labels
54-
void removeFrozenHighlights();
53+
//! Remove rectangles from around pinned labels
54+
void removePinnedHighlights();
5555

5656
public slots:
5757

58-
//! Update frozen label highlights on layer edit mode change
59-
void updateFrozenLabels();
58+
//! Update pinned label highlights on layer edit mode change
59+
void updatePinnedLabels();
6060

61-
//! Render highlight rectangles around frozen labels
62-
void highlightFrozenLabels();
61+
//! Render highlight rectangles around pinned labels
62+
void highlightPinnedLabels();
6363

6464
protected:
6565

@@ -68,8 +68,8 @@ class QgsMapToolFreezeLabels: public QgsMapToolLabel
6868

6969
//! Flag to indicate a map canvas drag operation is taking place
7070
bool mDragging;
71-
//! Flag to indicate whether to draw the highlight for frozen labels
72-
bool mShowFrozen;
71+
//! Flag to indicate whether to draw the highlight for pinned labels
72+
bool mShowPinned;
7373

7474
//! Stores actual select rect
7575
QRect mSelectRect;
@@ -82,22 +82,22 @@ class QgsMapToolFreezeLabels: public QgsMapToolLabel
8282
//! Pointer to map renderer
8383
QgsMapRenderer* mRender;
8484

85-
//! Highlights a given label relative to whether its frozen and editable
85+
//! Highlights a given label relative to whether its pinned and editable
8686
void highlightLabel( QgsVectorLayer* vlayer,
8787
const QgsLabelPosition& labelpos,
8888
const QString& id,
8989
const QColor& color );
9090

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

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

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

103-
#endif // QGSMAPTOOLFREEZELABELS_H
103+
#endif // QGSMAPTOOLPINLABELS_H

‎src/core/qgslabelsearchtree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void QgsLabelSearchTree::labelsInRect( const QgsRectangle& r, QList<QgsLabelPosi
6767
}
6868
}
6969

70-
bool QgsLabelSearchTree::insertLabel( LabelPosition* labelPos, int featureId, const QString& layerName, bool diagram, bool frozen )
70+
bool QgsLabelSearchTree::insertLabel( LabelPosition* labelPos, int featureId, const QString& layerName, bool diagram, bool pinned )
7171
{
7272
if ( !labelPos )
7373
{
@@ -84,7 +84,7 @@ bool QgsLabelSearchTree::insertLabel( LabelPosition* labelPos, int featureId, co
8484
cornerPoints.push_back( QgsPoint( labelPos->getX( i ), labelPos->getY( i ) ) );
8585
}
8686
QgsLabelPosition* newEntry = new QgsLabelPosition( featureId, labelPos->getAlpha(), cornerPoints, QgsRectangle( c_min[0], c_min[1], c_max[0], c_max[1] ),
87-
labelPos->getWidth(), labelPos->getHeight(), layerName, labelPos->getUpsideDown(), diagram, frozen );
87+
labelPos->getWidth(), labelPos->getHeight(), layerName, labelPos->getUpsideDown(), diagram, pinned );
8888
mSpatialIndex.Insert( c_min, c_max, newEntry );
8989
return true;
9090
}

‎src/core/qgslabelsearchtree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CORE_EXPORT QgsLabelSearchTree
4747

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

5252
private:
5353
RTree<QgsLabelPosition*, double, 2, double> mSpatialIndex;

‎src/core/qgsmaprenderer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ struct QgsDiagramLayerSettings;
4343

4444
struct CORE_EXPORT QgsLabelPosition
4545
{
46-
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 ):
47-
featureId( id ), rotation( r ), cornerPoints( corners ), labelRect( rect ), width( w ), height( h ), layerID( layer ), upsideDown( upside_down ), isDiagram( diagram ), isFrozen( frozen ) {}
48-
QgsLabelPosition(): featureId( -1 ), rotation( 0 ), labelRect( QgsRectangle() ), width( 0 ), height( 0 ), layerID( "" ), upsideDown( false ), isDiagram( false ), isFrozen( false ) {}
46+
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 ):
47+
featureId( id ), rotation( r ), cornerPoints( corners ), labelRect( rect ), width( w ), height( h ), layerID( layer ), upsideDown( upside_down ), isDiagram( diagram ), isPinned( pinned ) {}
48+
QgsLabelPosition(): featureId( -1 ), rotation( 0 ), labelRect( QgsRectangle() ), width( 0 ), height( 0 ), layerID( "" ), upsideDown( false ), isDiagram( false ), isPinned( false ) {}
4949
int featureId;
5050
double rotation;
5151
QVector< QgsPoint > cornerPoints;
@@ -55,7 +55,7 @@ struct CORE_EXPORT QgsLabelPosition
5555
QString layerID;
5656
bool upsideDown;
5757
bool isDiagram;
58-
bool isFrozen;
58+
bool isPinned;
5959
};
6060

6161
/** Labeling engine interface.

‎src/core/qgspallabeling.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class QgsPalGeometry : public PalGeometry
6262
, mId( id )
6363
, mInfo( NULL )
6464
, mIsDiagram( false )
65-
, mIsFrozen( false )
65+
, mIsPinned( false )
6666
{
6767
mStrId = FID_TO_STRING( id ).toAscii();
6868
}
@@ -113,8 +113,8 @@ class QgsPalGeometry : public PalGeometry
113113
void setIsDiagram( bool d ) { mIsDiagram = d; }
114114
bool isDiagram() const { return mIsDiagram; }
115115

116-
void setIsFrozen( bool f ) { mIsFrozen = f; }
117-
bool isFrozen() const { return mIsFrozen; }
116+
void setIsPinned( bool f ) { mIsPinned = f; }
117+
bool isPinned() const { return mIsPinned; }
118118

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

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

719-
// set geometry's frozen property
720-
lbl->setIsFrozen( dataDefinedPosition );
719+
// set geometry's pinned property
720+
lbl->setIsPinned( dataDefinedPosition );
721721
}
722722

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

12471247
if ( mLabelSearchTree )
12481248
{
1249-
mLabelSearchTree->insertLabel( *it, QString( palGeometry->strId() ).toInt(), ( *it )->getLayerName(), false, palGeometry->isFrozen() );
1249+
mLabelSearchTree->insertLabel( *it, QString( palGeometry->strId() ).toInt(), ( *it )->getLayerName(), false, palGeometry->isPinned() );
12501250
}
12511251
}
12521252

‎src/core/qgspallabeling.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class CORE_EXPORT QgsPalLayerSettings
161161
/**Stores field indices for data defined layer properties*/
162162
QMap< DataDefinedProperties, int > dataDefinedProperties;
163163

164-
bool preserveRotation; // preserve predefined rotation data during label freeze/thaw operations
164+
bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
165165

166166
/**Calculates pixel size (considering output size should be in pixel or map units, scale factors and oversampling)
167167
@param size size to convert

‎src/ui/qgisapp.ui

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@
401401
<bool>false</bool>
402402
</attribute>
403403
<addaction name="mActionLabeling"/>
404-
<addaction name="mActionShowFrozenLabels"/>
405-
<addaction name="mActionFreezeLabels"/>
404+
<addaction name="mActionShowPinnedLabels"/>
405+
<addaction name="mActionPinLabels"/>
406406
<addaction name="mActionMoveLabel"/>
407407
<addaction name="mActionRotateLabel"/>
408408
<addaction name="mActionChangeLabelProperties"/>
@@ -1707,35 +1707,36 @@
17071707
<string>Creates a scale bar that is displayed on the map canvas</string>
17081708
</property>
17091709
</action>
1710-
<action name="mActionFreezeLabels">
1710+
<action name="mActionPinLabels">
17111711
<property name="checkable">
17121712
<bool>true</bool>
17131713
</property>
17141714
<property name="icon">
17151715
<iconset resource="../../images/images.qrc">
1716-
<normaloff>:/images/themes/default/mActionFreezeLabels.png</normaloff>:/images/themes/default/mActionFreezeLabels.png</iconset>
1716+
<normaloff>:/images/themes/default/mActionPinLabels.svg</normaloff>:/images/themes/default/mActionPinLabels.svg</iconset>
17171717
</property>
17181718
<property name="text">
1719-
<string>Freeze or Thaw Labels</string>
1719+
<string>Pin/Unpin Labels</string>
17201720
</property>
17211721
<property name="toolTip">
1722-
<string>Freeze or Thaw Labels
1723-
Shift thaws, Ctl (Cmd) toggles, Shift+Ctl (Cmd) hides</string>
1722+
<string>Pin/Unpin and Hide/Show Labels
1723+
Shift unpins, Ctl (Cmd) toggles pin/unpin
1724+
Shift+Ctl (Cmd) on label hides, Shift+Ctl (Cmd) on feature shows label</string>
17241725
</property>
17251726
</action>
1726-
<action name="mActionShowFrozenLabels">
1727+
<action name="mActionShowPinnedLabels">
17271728
<property name="checkable">
17281729
<bool>true</bool>
17291730
</property>
17301731
<property name="icon">
17311732
<iconset resource="../../images/images.qrc">
1732-
<normaloff>:/images/themes/default/mActionShowFrozenLabels.png</normaloff>:/images/themes/default/mActionShowFrozenLabels.png</iconset>
1733+
<normaloff>:/images/themes/default/mActionShowPinnedLabels.svg</normaloff>:/images/themes/default/mActionShowPinnedLabels.svg</iconset>
17331734
</property>
17341735
<property name="text">
1735-
<string>Show Frozen Labels</string>
1736+
<string>Highlight Pinned Labels</string>
17361737
</property>
17371738
<property name="toolTip">
1738-
<string>Show Frozen Labels</string>
1739+
<string>Highlight Pinned Labels</string>
17391740
</property>
17401741
</action>
17411742
<action name="mActionNewBlankProject">

‎src/ui/qgslabelingguibase.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,13 +1113,13 @@
11131113
<item row="6" column="0" colspan="2">
11141114
<widget class="QCheckBox" name="chkPreserveRotation">
11151115
<property name="toolTip">
1116-
<string>Uncheck to write labeling engine derived rotation on freeze and NULL on thaw</string>
1116+
<string>Uncheck to write labeling engine derived rotation on pin and NULL on unpin</string>
11171117
</property>
11181118
<property name="styleSheet">
11191119
<string notr="true">margin-left: 12px;</string>
11201120
</property>
11211121
<property name="text">
1122-
<string>Preserve existing rotation values during label freeze/thaw operations</string>
1122+
<string>Preserve existing rotation values during label pin/unpin operations</string>
11231123
</property>
11241124
<property name="checked">
11251125
<bool>true</bool>

0 commit comments

Comments
 (0)
Please sign in to comment.