Skip to content

Commit e2ae059

Browse files
committed
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents cc63a1e + d83b618 commit e2ae059

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/app/qgsmaptoollabel.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ bool QgsMapToolLabel::rotationPoint( QgsPoint& pos, bool ignoreUpsideDown )
322322
QString haliString, valiString;
323323
currentAlignment( haliString, valiString );
324324

325+
if ( !mCurrentLabelPos.isPinned )
326+
{
327+
haliString = "Center";
328+
valiString = "Half";
329+
}
330+
325331
QFont labelFont = labelFontCurrentFeature();
326332
QFontMetricsF labelFontMetrics( labelFont );
327333

src/app/qgsmaptoolrotatelabel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void QgsMapToolRotateLabel::canvasPressEvent( QMouseEvent *e )
6464

6565

6666
bool hasRotationValue;
67-
if ( dataDefinedRotation( vlayer, mCurrentLabelPos.featureId, mCurrentRotation, hasRotationValue ) )
67+
if ( dataDefinedRotation( vlayer, mCurrentLabelPos.featureId, mCurrentRotation, hasRotationValue, true ) )
6868
{
6969
if ( !hasRotationValue )
7070
{

src/core/qgspallabeling.cpp

+12-9
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
805805
}
806806
}
807807

808-
if( dataDefinedRotation )
808+
if ( dataDefinedRotation )
809809
{
810810
//adjust xdiff and ydiff because the hali/vali point needs to be the rotation center
811811
double xd = xdiff * cos( angle ) - ydiff * sin( angle );
@@ -831,7 +831,7 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
831831
// does not flag label as pinned or rotateable
832832
// always set rotation center as if Center/Half were set for data defined
833833
bool overPointCentroid = false;
834-
if ( !dataDefinedPosition
834+
if ( !labelIsPinned
835835
&& placement == QgsPalLayerSettings::OverPoint
836836
&& geom->type() == QGis::Point )
837837
{
@@ -854,11 +854,14 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
854854
double descentRatio = labelFontMetrics.descent() / labelFontMetrics.height();
855855
ydiff -= labelY * 0.5 * ( 1 - descentRatio );
856856

857-
if ( angleOffset != 0 )
857+
if ( !dataDefinedRotation && angleOffset != 0 )
858858
{
859+
dataDefinedRotation = true;
859860
angle = angleOffset * M_PI / 180; // convert to radians
861+
}
860862

861-
dataDefinedRotation = true;
863+
if ( dataDefinedRotation )
864+
{
862865
//adjust xdiff and ydiff for Center/Half
863866
double xd = xdiff * cos( angle ) - ydiff * sin( angle );
864867
double yd = xdiff * sin( angle ) + ydiff * cos( angle );
@@ -924,12 +927,11 @@ void QgsPalLayerSettings::registerFeature( QgsVectorLayer* layer, QgsFeature& f
924927
double labelW = labelX;
925928
double labelH = labelY;
926929

927-
if ( angleOffset != 0 )
930+
if ( dataDefinedRotation )
928931
{
929932
// use LabelPosition construction to calculate new rotated label dimensions
930933
pal::FeaturePart* fpart = new FeaturePart( feat, geom->asGeos() );
931-
pal::LabelPosition* lp = new LabelPosition( 1, xPos, yPos, labelX, labelY,
932-
( angleOffset * M_PI / 180 ), 0.0, fpart );
934+
pal::LabelPosition* lp = new LabelPosition( 1, xPos, yPos, labelX, labelY, angle, 0.0, fpart );
933935

934936
// lp->getWidth or lp->getHeight doesn't account for rotation, get bbox instead
935937
double amin[2], amax[2];
@@ -1726,8 +1728,9 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QPainter* painter, co
17261728
painter->scale( 1.0 / lyr.rasterCompressFactor, 1.0 / lyr.rasterCompressFactor );
17271729

17281730
double yMultiLineOffset = ( multiLineList.size() - 1 - i ) * lyr.fontMetrics->height();
1729-
// yMultiLineOffset += lyr.fontMetrics->descent();
1730-
painter->translate( QPointF( 0, -yMultiLineOffset ) );
1731+
double ascentOffset = 0.0;
1732+
ascentOffset = lyr.fontMetrics->height() * 0.25 * lyr.fontMetrics->ascent() / lyr.fontMetrics->height();
1733+
painter->translate( QPointF( 0, - ascentOffset - yMultiLineOffset ) );
17311734

17321735
if ( drawBuffer )
17331736
{

0 commit comments

Comments
 (0)