23 #include <pal/feature.h>
24 #include <pal/layer.h>
25 #include <pal/palgeometry.h>
26 #include <pal/palexception.h>
27 #include <pal/problem.h>
28 #include <pal/labelposition.h>
34 #include <QApplication>
37 #include <QFontMetrics>
41 #include "diagram/qgsdiagram.h"
58 #include <QMessageBox>
67 qreal ltrSpacing = 0.0, qreal wordSpacing = 0.0,
bool curvedLabeling =
false )
74 , mFontMetrics( NULL )
75 , mLetterSpacing( ltrSpacing )
76 , mWordSpacing( wordSpacing )
77 , mCurvedLabeling( curvedLabeling )
80 mDefinedFont = QFont();
86 GEOSGeom_destroy( mG );
93 const GEOSGeometry* getGeosGeometry()
97 void releaseGeosGeometry(
const GEOSGeometry* )
102 const char*
strId() {
return mStrId.data(); }
103 QString
text() {
return mText; }
105 pal::LabelInfo* info( QFontMetricsF* fm,
const QgsMapToPixel* xform,
double fontScale,
double maxinangle,
double maxoutangle )
110 mFontMetrics =
new QFontMetricsF( *fm );
113 if ( maxinangle < 20.0 )
115 if ( 60.0 < maxinangle )
117 if ( maxoutangle > -20.0 )
119 if ( -95.0 > maxoutangle )
130 mInfo =
new pal::LabelInfo( mText.count(), ptSize.
y() - ptZero.
y(), maxinangle, maxoutangle );
131 for (
int i = 0; i < mText.count(); i++ )
133 mInfo->char_info[i].chr = mText[i].unicode();
137 charWidth = fm->width( mText[i] );
138 if ( mCurvedLabeling )
140 wordSpaceFix = qreal( 0.0 );
141 if ( mText[i] == QString(
" " )[0] )
145 wordSpaceFix = ( nxt < mText.count() && mText[nxt] != QString(
" " )[0] ) ? mWordSpacing : qreal( 0.0 );
147 if ( fm->width( QString( mText[i] ) ) - fm->width( mText[i] ) - mLetterSpacing != qreal( 0.0 ) )
150 wordSpaceFix -= mWordSpacing;
152 charWidth = fm->width( QString( mText[i] ) ) + wordSpaceFix;
156 mInfo->char_info[i].width = ptSize.
x() - ptZero.
x();
161 const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >&
dataDefinedValues()
const {
return mDataDefinedValues; }
206 , mFeaturesToLabel( 0 )
207 , mFeatsSendingToPal( 0 )
219 blendMode = QPainter::CompositionMode_SourceOver;
577 int r = layer->
customProperty( property +
"R", QVariant( defaultColor.red() ) ).toInt();
578 int g = layer->
customProperty( property +
"G", QVariant( defaultColor.green() ) ).toInt();
579 int b = layer->
customProperty( property +
"B", QVariant( defaultColor.blue() ) ).toInt();
580 int a = withAlpha ? layer->
customProperty( property +
"A", QVariant( defaultColor.alpha() ) ).toInt() : 255;
581 return QColor( r, g, b, a );
595 if ( str.compare(
"Point", Qt::CaseInsensitive ) == 0
597 if ( str.compare(
"MapUnit", Qt::CaseInsensitive ) == 0
605 if ( str.compare(
"Lighten", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Lighten;
606 if ( str.compare(
"Screen", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Screen;
607 if ( str.compare(
"Dodge", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorDodge;
608 if ( str.compare(
"Addition", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Plus;
609 if ( str.compare(
"Darken", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Darken;
610 if ( str.compare(
"Multiply", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Multiply;
611 if ( str.compare(
"Burn", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_ColorBurn;
612 if ( str.compare(
"Overlay", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Overlay;
613 if ( str.compare(
"SoftLight", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_SoftLight;
614 if ( str.compare(
"HardLight", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_HardLight;
615 if ( str.compare(
"Difference", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Difference;
616 if ( str.compare(
"Subtract", Qt::CaseInsensitive ) == 0 )
return QPainter::CompositionMode_Exclusion;
617 return QPainter::CompositionMode_SourceOver;
622 if ( str.compare(
"Miter", Qt::CaseInsensitive ) == 0 )
return Qt::MiterJoin;
623 if ( str.compare(
"Round", Qt::CaseInsensitive ) == 0 )
return Qt::RoundJoin;
624 return Qt::BevelJoin;
628 QMap < QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* > & propertyMap )
635 QMapIterator<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > i(
mDataDefinedNames );
636 while ( i.hasNext() )
644 const QMap < QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* > & propertyMap )
651 QMapIterator<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > i(
mDataDefinedNames );
652 while ( i.hasNext() )
655 QString newPropertyName =
"labeling/dataDefined/" + i.value().first;
656 QVariant propertyValue = QVariant();
658 QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* >::const_iterator it = propertyMap.find( i.key() );
659 if ( it != propertyMap.constEnd() )
667 QString field = dd->
field();
669 bool defaultVals = ( !active && !useExpr && expr.isEmpty() && field.isEmpty() );
675 values << ( active ?
"1" :
"0" );
676 values << ( useExpr ?
"1" :
"0" );
679 if ( !values.isEmpty() )
681 propertyValue = QVariant( values.join(
"~~" ) );
687 if ( propertyValue.isValid() )
697 if ( layer->
customProperty( newPropertyName, QVariant() ).isValid() && i.value().second > -1 )
700 layer->
removeCustomProperty( QString(
"labeling/dataDefinedProperty" ) + QString::number( i.value().second ) );
707 QMap < QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* > & propertyMap )
709 QString newPropertyName =
"labeling/dataDefined/" +
mDataDefinedNames.value( p ).first;
710 QVariant newPropertyField = layer->
customProperty( newPropertyName, QVariant() );
712 QString ddString = QString();
713 if ( newPropertyField.isValid() )
715 ddString = newPropertyField.toString();
726 QString oldPropertyName =
"labeling/dataDefinedProperty" + QString::number( oldIndx );
727 QVariant oldPropertyField = layer->
customProperty( oldPropertyName, QVariant() );
729 if ( !oldPropertyField.isValid() )
736 int indx = oldPropertyField.toInt( &conversionOk );
746 if ( !oldIndicesToNames.isEmpty() )
748 ddString = oldIndicesToNames.value( indx );
753 if ( indx < fields.
size() )
755 ddString = fields.
at( indx ).
name();
760 if ( !ddString.isEmpty() )
773 if ( oldIndx == 16 || oldIndx == 17 )
784 if ( !ddString.isEmpty() && ddString != QString(
"0~~0~~~~" ) )
788 QStringList ddv = newStyleString.split(
"~~" );
791 propertyMap.insert( p, dd );
802 if ( layer->
customProperty(
"labeling" ).toString() != QString(
"pal" ) )
812 QFont appFont = QApplication::font();
824 fontFamily = appFont.family();
827 double fontSize = layer->
customProperty(
"labeling/fontSize" ).toDouble();
829 int fontWeight = layer->
customProperty(
"labeling/fontWeight" ).toInt();
830 bool fontItalic = layer->
customProperty(
"labeling/fontItalic" ).toBool();
831 textFont = QFont( fontFamily, fontSize, fontWeight, fontItalic );
835 textFont.setCapitalization(( QFont::Capitalization )layer->
customProperty(
"labeling/fontCapitals", QVariant( 0 ) ).toUInt() );
838 textFont.setLetterSpacing( QFont::AbsoluteSpacing, layer->
customProperty(
"labeling/fontLetterSpacing", QVariant( 0.0 ) ).toDouble() );
839 textFont.setWordSpacing( layer->
customProperty(
"labeling/fontWordSpacing", QVariant( 0.0 ) ).toDouble() );
861 double bufSize = layer->
customProperty(
"labeling/bufferSize", QVariant( 0.0 ) ).toDouble();
864 QVariant drawBuffer = layer->
customProperty(
"labeling/bufferDraw", QVariant() );
865 if ( drawBuffer.isValid() )
870 else if ( bufSize != 0.0 )
895 layer->
customProperty(
"labeling/shapeSizeY", QVariant( 0.0 ) ).toDouble() );
900 layer->
customProperty(
"labeling/shapeOffsetY", QVariant( 0.0 ) ).toDouble() );
903 layer->
customProperty(
"labeling/shapeRadiiY", QVariant( 0.0 ) ).toDouble() );
947 int scalemn = layer->
customProperty(
"labeling/scaleMin", QVariant( 0 ) ).toInt();
948 int scalemx = layer->
customProperty(
"labeling/scaleMax", QVariant( 0 ) ).toInt();
951 QVariant scalevis = layer->
customProperty(
"labeling/scaleVisibility", QVariant() );
952 if ( scalevis.isValid() )
958 else if ( scalemn > 0 || scalemx > 0 )
1113 bool active,
bool useExpr,
const QString& expr,
const QString& field )
1115 bool defaultVals = ( !active && !useExpr && expr.isEmpty() && field.isEmpty() );
1119 QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* >::const_iterator it =
dataDefinedProperties.find( p );
1129 else if ( !defaultVals )
1141 delete( it.value() );
1149 QString newValue = value;
1150 if ( !value.isEmpty() && !value.contains(
"~~" ) )
1157 newValue = values.join(
"~~" );
1165 QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* >::const_iterator it =
dataDefinedProperties.find( p );
1175 QMap<QString, QString> map;
1176 QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* >::const_iterator it =
dataDefinedProperties.find( p );
1179 return it.value()->toMap();
1192 QMap< DataDefinedProperties, QgsDataDefined* >::const_iterator it =
dataDefinedProperties.find( p );
1208 QVariant result = QVariant();
1210 QString field = dd->
field();
1229 else if ( !useExpression && !field.isEmpty() )
1248 if ( result.isValid() )
1261 bool isActive =
false;
1262 QMap< DataDefinedProperties, QgsDataDefined* >::const_iterator it =
dataDefinedProperties.find( p );
1265 isActive = it.value()->isActive();
1273 bool useExpression =
false;
1274 QMap< DataDefinedProperties, QgsDataDefined* >::const_iterator it =
dataDefinedProperties.find( p );
1277 useExpression = it.value()->useExpression();
1280 return useExpression;
1304 double length = geom->
length();
1305 if ( length >= 0.0 )
1307 return ( length >= ( minSize * mapUnitsPerMM ) );
1312 double area = geom->
area();
1315 return ( sqrt( area ) >= ( minSize * mapUnitsPerMM ) );
1375 QVariant exprVal = QVariant();
1378 if ( exprVal.isValid() )
1380 wrapchr = exprVal.toString();
1384 if ( exprVal.isValid() )
1387 double size = exprVal.toDouble( &ok );
1396 if ( exprVal.isValid() )
1398 addDirSymb = exprVal.toBool();
1405 if ( exprVal.isValid() )
1407 leftDirSymb = exprVal.toString();
1411 if ( exprVal.isValid() )
1413 rightDirSymb = exprVal.toString();
1417 if ( exprVal.isValid() )
1420 int enmint = exprVal.toInt( &ok );
1430 if ( wrapchr.isEmpty() )
1432 wrapchr = QString(
"\n" );
1437 && ( !leftDirSymb.isEmpty() || !rightDirSymb.isEmpty() ) )
1439 QString dirSym = leftDirSymb;
1441 if ( fm->width( rightDirSymb ) > fm->width( dirSym ) )
1442 dirSym = rightDirSymb;
1446 text.append( dirSym );
1450 text.prepend( dirSym + wrapchr );
1454 double w = 0.0, h = 0.0;
1455 QStringList multiLineSplit = text.split( wrapchr );
1456 int lines = multiLineSplit.size();
1458 double labelHeight = fm->ascent() + fm->descent();
1460 h += fm->height() + ( double )(( lines - 1 ) * labelHeight * multilineH );
1463 for (
int i = 0; i < lines; ++i )
1465 double width = fm->width( multiLineSplit.at( i ) );
1474 labelX = qAbs( ptSize.
x() -
ptZero.
x() );
1475 labelY = qAbs( ptSize.
y() -
ptZero.
y() );
1493 QgsDebugMsgLevel( QString(
"exprVal Show:%1" ).arg( exprVal.toBool() ?
"true" :
"false" ), 4 );
1494 if ( !exprVal.toBool() )
1504 QgsDebugMsgLevel( QString(
"exprVal ScaleVisibility:%1" ).arg( exprVal.toBool() ?
"true" :
"false" ), 4 );
1505 useScaleVisibility = exprVal.toBool();
1508 if ( useScaleVisibility )
1514 QgsDebugMsgLevel( QString(
"exprVal MinScale:%1" ).arg( exprVal.toDouble() ), 4 );
1516 double mins = exprVal.toDouble( &conversionOk );
1526 minScale = 1 / qAbs( minScale );
1538 QgsDebugMsgLevel( QString(
"exprVal MaxScale:%1" ).arg( exprVal.toDouble() ), 4 );
1540 double maxs = exprVal.toDouble( &conversionOk );
1550 maxScale = 1 / qAbs( maxScale );
1566 QString units = exprVal.toString().trimmed();
1568 if ( !units.isEmpty() )
1575 double fontSize = labelFont.pointSizeF();
1578 QgsDebugMsgLevel( QString(
"exprVal Size:%1" ).arg( exprVal.toDouble() ), 4 );
1580 double size = exprVal.toDouble( &ok );
1586 if ( fontSize <= 0.0 )
1591 int fontPixelSize =
sizeToPixel( fontSize, context, fontunits,
true );
1593 if ( fontPixelSize < 1 )
1597 labelFont.setPixelSize( fontPixelSize );
1607 QgsDebugMsgLevel( QString(
"exprVal FontLimitPixel:%1" ).arg( exprVal.toBool() ?
"true" :
"false" ), 4 );
1608 useFontLimitPixelSize = exprVal.toBool();
1611 if ( useFontLimitPixelSize )
1617 int sizeInt = exprVal.toInt( &ok );
1618 QgsDebugMsgLevel( QString(
"exprVal FontMinPixel:%1" ).arg( sizeInt ), 4 );
1621 fontMinPixel = sizeInt;
1629 int sizeInt = exprVal.toInt( &ok );
1630 QgsDebugMsgLevel( QString(
"exprVal FontMaxPixel:%1" ).arg( sizeInt ), 4 );
1633 fontMaxPixel = sizeInt;
1637 if ( fontMinPixel > labelFont.pixelSize() || labelFont.pixelSize() > fontMaxPixel )
1668 QVariant result = exp->
evaluate( &f );
1674 labelText = result.toString();
1685 formatnum = exprVal.toBool();
1686 QgsDebugMsgLevel( QString(
"exprVal NumFormat:%1" ).arg( formatnum ?
"true" :
"false" ), 4 );
1697 int dInt = exprVal.toInt( &ok );
1699 if ( ok && dInt > 0 )
1701 decimalPlaces = dInt;
1709 signPlus = exprVal.toBool();
1710 QgsDebugMsgLevel( QString(
"exprVal NumPlusSign:%1" ).arg( signPlus ?
"true" :
"false" ), 4 );
1713 QVariant textV = QVariant( labelText );
1715 double d = textV.toDouble( &ok );
1718 QString numberFormat;
1719 if ( d > 0 && signPlus )
1721 numberFormat.append(
"+" );
1723 numberFormat.append(
"%1" );
1724 labelText = numberFormat.arg( d, 0,
'f', decimalPlaces );
1730 QFontMetricsF* labelFontMetrics =
new QFontMetricsF( labelFont );
1731 double labelX, labelY;
1737 double maxcharanglein = 20.0;
1738 double maxcharangleout = -20.0;
1748 QString ptstr = exprVal.toString().trimmed();
1749 QgsDebugMsgLevel( QString(
"exprVal CurvedCharAngleInOut:%1" ).arg( ptstr ), 4 );
1751 if ( !ptstr.isEmpty() )
1754 maxcharanglein = qBound( 20.0, (
double )maxcharanglePt.x(), 60.0 );
1755 maxcharangleout = qBound( 20.0, (
double )maxcharanglePt.y(), 95.0 );
1759 maxcharangleout = -( qAbs( maxcharangleout ) );
1777 QgsDebugMsgLevel( QString(
"Ignoring feature %1 due transformation exception" ).arg( f.
id() ), 4 );
1796 QString str = exprVal.toString().trimmed();
1799 if ( !str.isEmpty() )
1801 if ( str.compare(
"Visible", Qt::CaseInsensitive ) == 0 )
1803 wholeCentroid =
false;
1805 else if ( str.compare(
"Whole", Qt::CaseInsensitive ) == 0 )
1807 wholeCentroid =
true;
1814 bool do_clip =
false;
1815 if ( !centroidPoly || ( centroidPoly && !wholeCentroid ) )
1828 const GEOSGeometry* geos_geom = geom->
asGeos();
1830 if ( geos_geom == NULL )
1859 GEOSGeometry* geos_geom_clone = GEOSGeom_clone( geos_geom );
1862 bool dataDefinedPosition =
false;
1863 bool labelIsPinned =
false;
1864 bool layerDefinedRotation =
false;
1865 bool dataDefinedRotation =
false;
1866 double xPos = 0.0, yPos = 0.0,
angle = 0.0;
1867 bool ddXPos =
false, ddYPos =
false;
1868 double quadOffsetX = 0.0, quadOffsetY = 0.0;
1869 double offsetX = 0.0, offsetY = 0.0;
1876 int quadInt = exprVal.toInt( &ok );
1878 if ( ok && 0 <= quadInt && quadInt <= 8 )
1929 QString ptstr = exprVal.toString().trimmed();
1932 if ( !ptstr.isEmpty() )
1944 QString units = exprVal.toString().trimmed();
1946 if ( !units.isEmpty() )
1958 if ( !offinmapunits )
1960 offsetX *= mapUntsPerMM;
1966 if ( !offinmapunits )
1968 offsetY *= mapUntsPerMM;
1976 layerDefinedRotation =
true;
1984 double rotD = exprVal.toDouble( &ok );
1988 dataDefinedRotation =
true;
1995 xPos = exprVal.toDouble( &ddXPos );
2001 yPos = exprVal.toDouble( &ddYPos );
2004 if ( ddXPos && ddYPos )
2006 dataDefinedPosition =
true;
2007 labelIsPinned =
true;
2009 if ( layerDefinedRotation && !dataDefinedRotation )
2021 QString haliString = exprVal.toString();
2023 if ( haliString.compare(
"Center", Qt::CaseInsensitive ) == 0 )
2025 xdiff -= labelX / 2.0;
2027 else if ( haliString.compare(
"Right", Qt::CaseInsensitive ) == 0 )
2036 QString valiString = exprVal.toString();
2039 if ( valiString.compare(
"Bottom", Qt::CaseInsensitive ) != 0 )
2041 if ( valiString.compare(
"Top", Qt::CaseInsensitive ) == 0 )
2047 double descentRatio = labelFontMetrics->descent() / labelFontMetrics->height();
2048 if ( valiString.compare(
"Base", Qt::CaseInsensitive ) == 0 )
2050 ydiff -= labelY * descentRatio;
2054 double capHeightRatio = ( labelFontMetrics->boundingRect(
'H' ).height() + 1 + labelFontMetrics->descent() ) / labelFontMetrics->height();
2055 ydiff -= labelY * capHeightRatio;
2056 if ( valiString.compare(
"Half", Qt::CaseInsensitive ) == 0 )
2058 ydiff += labelY * ( capHeightRatio - descentRatio ) / 2.0;
2065 if ( dataDefinedRotation )
2068 double xd = xdiff * cos(
angle ) - ydiff * sin(
angle );
2069 double yd = xdiff * sin(
angle ) + ydiff * cos(
angle );
2085 QgsDebugMsgLevel( QString(
"Ignoring feature %1 due transformation exception on data-defined position" ).arg( f.
id() ), 4 );
2105 bool alwaysShow =
false;
2108 alwaysShow = exprVal.toBool();
2115 labelFont.letterSpacing(),
2116 labelFont.wordSpacing(),
2123 #if QT_VERSION >= 0x040800
2124 QgsDebugMsgLevel( QString(
"PAL font stored definedFont: %1, Style: %2" ).arg( labelFont.toString() ).arg( labelFont.styleName() ), 4 );
2131 if ( !
palLayer->registerFeature( lbl->
strId(), lbl, labelX, labelY, labelText.toUtf8().constData(),
2132 xPos, yPos, dataDefinedPosition,
angle, dataDefinedRotation,
2133 quadOffsetX, quadOffsetY, offsetX, offsetY, alwaysShow ) )
2136 catch ( std::exception &e )
2139 QgsDebugMsgLevel( QString(
"Ignoring feature %1 due PAL exception:" ).arg( f.
id() ) + QString::fromLatin1( e.what() ), 4 );
2147 delete labelFontMetrics;
2152 double distance =
dist;
2156 double distD = exprVal.toDouble( &ok );
2167 QString units = exprVal.toString().trimmed();
2169 if ( !units.isEmpty() )
2175 if ( distance != 0 )
2177 if ( distinmapunit )
2185 feat->setDistLabel( qAbs(
ptOne.
x() -
ptZero.
x() )* distance );
2189 QMap< DataDefinedProperties, QVariant >::const_iterator dIt =
dataDefinedValues.constBegin();
2205 QString dbgStr = QString(
"exprVal %1:" ).arg(
mDataDefinedNames.value( p ).first ) +
"%1";
2207 if ( valType == QString(
"bool" ) )
2209 bool bol = exprVal.toBool();
2214 if ( valType == QString(
"int" ) )
2217 int size = exprVal.toInt( &ok );
2226 if ( valType == QString(
"intpos" ) )
2229 int size = exprVal.toInt( &ok );
2232 if ( ok && size > 0 )
2238 if ( valType == QString(
"double" ) )
2241 double size = exprVal.toDouble( &ok );
2250 if ( valType == QString(
"doublepos" ) )
2253 double size = exprVal.toDouble( &ok );
2256 if ( ok && size > 0.0 )
2262 if ( valType == QString(
"rotation180" ) )
2265 double rot = exprVal.toDouble( &ok );
2269 if ( rot < -180.0 && rot >= -360 )
2273 if ( rot > 180.0 && rot <= 360 )
2277 if ( rot >= -180 && rot <= 180 )
2284 if ( valType == QString(
"transp" ) )
2287 int size = exprVal.toInt( &ok );
2289 if ( ok && size >= 0 && size <= 100 )
2295 if ( valType == QString(
"string" ) )
2297 QString str = exprVal.toString();
2303 if ( valType == QString(
"units" ) )
2305 QString unitstr = exprVal.toString().trimmed();
2308 if ( !unitstr.isEmpty() )
2314 if ( valType == QString(
"color" ) )
2316 QString colorstr = exprVal.toString().trimmed();
2320 if ( color.isValid() )
2326 if ( valType == QString(
"joinstyle" ) )
2328 QString joinstr = exprVal.toString().trimmed();
2331 if ( !joinstr.isEmpty() )
2337 if ( valType == QString(
"blendmode" ) )
2339 QString blendstr = exprVal.toString().trimmed();
2342 if ( !blendstr.isEmpty() )
2348 if ( valType == QString(
"pointf" ) )
2350 QString ptstr = exprVal.toString().trimmed();
2353 if ( !ptstr.isEmpty() )
2376 QString ddFontFamily(
"" );
2379 QString family = exprVal.toString().trimmed();
2382 if ( labelFont.family() != family )
2388 ddFontFamily = family;
2394 QString ddFontStyle(
"" );
2397 QString fontstyle = exprVal.toString().trimmed();
2398 QgsDebugMsgLevel( QString(
"exprVal Font style:%1" ).arg( fontstyle ), 4 );
2399 ddFontStyle = fontstyle;
2403 bool ddBold =
false;
2406 bool bold = exprVal.toBool();
2407 QgsDebugMsgLevel( QString(
"exprVal Font bold:%1" ).arg( bold ?
"true" :
"false" ), 4 );
2412 bool ddItalic =
false;
2415 bool italic = exprVal.toBool();
2416 QgsDebugMsgLevel( QString(
"exprVal Font italic:%1" ).arg( italic ?
"true" :
"false" ), 4 );
2423 QFont appFont = QApplication::font();
2424 bool newFontBuilt =
false;
2425 if ( ddBold || ddItalic )
2428 newFont = QFont( !ddFontFamily.isEmpty() ? ddFontFamily : labelFont.family() );
2429 newFontBuilt =
true;
2430 newFont.setBold( ddBold );
2431 newFont.setItalic( ddItalic );
2433 else if ( !ddFontStyle.isEmpty()
2434 && ddFontStyle.compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
2436 if ( !ddFontFamily.isEmpty() )
2439 QFont styledfont =
mFontDB.font( ddFontFamily, ddFontStyle, appFont.pointSize() );
2440 if ( appFont != styledfont )
2442 newFont = styledfont;
2443 newFontBuilt =
true;
2450 else if ( !ddFontFamily.isEmpty() )
2452 if ( ddFontStyle.compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
2456 if ( appFont != styledfont )
2458 newFont = styledfont;
2459 newFontBuilt =
true;
2464 newFont = QFont( ddFontFamily );
2465 newFontBuilt =
true;
2473 newFont.setPixelSize( labelFont.pixelSize() );
2474 newFont.setCapitalization( labelFont.capitalization() );
2475 newFont.setUnderline( labelFont.underline() );
2476 newFont.setStrikeOut( labelFont.strikeOut() );
2477 newFont.setWordSpacing( labelFont.wordSpacing() );
2478 newFont.setLetterSpacing( QFont::AbsoluteSpacing, labelFont.letterSpacing() );
2480 labelFont = newFont;
2484 double wordspace = labelFont.wordSpacing();
2488 double wspacing = exprVal.toDouble( &ok );
2489 QgsDebugMsgLevel( QString(
"exprVal FontWordSpacing:%1" ).arg( wspacing ), 4 );
2492 wordspace = wspacing;
2495 labelFont.setWordSpacing(
sizeToPixel( wordspace, context, fontunits,
false ) );
2498 double letterspace = labelFont.letterSpacing();
2502 double lspacing = exprVal.toDouble( &ok );
2503 QgsDebugMsgLevel( QString(
"exprVal FontLetterSpacing:%1" ).arg( lspacing ), 4 );
2506 letterspace = lspacing;
2509 labelFont.setLetterSpacing( QFont::AbsoluteSpacing,
sizeToPixel( letterspace, context, fontunits,
false ) );
2512 QFont::Capitalization fontcaps = labelFont.capitalization();
2515 QString fcase = exprVal.toString().trimmed();
2518 if ( !fcase.isEmpty() )
2520 if ( fcase.compare(
"NoChange", Qt::CaseInsensitive ) == 0 )
2522 fontcaps = QFont::MixedCase;
2524 else if ( fcase.compare(
"Upper", Qt::CaseInsensitive ) == 0 )
2526 fontcaps = QFont::AllUppercase;
2528 else if ( fcase.compare(
"Lower", Qt::CaseInsensitive ) == 0 )
2530 fontcaps = QFont::AllLowercase;
2532 else if ( fcase.compare(
"Capitalize", Qt::CaseInsensitive ) == 0 )
2534 fontcaps = QFont::Capitalize;
2537 if ( fontcaps != labelFont.capitalization() )
2539 labelFont.setCapitalization( fontcaps );
2547 bool strikeout = exprVal.toBool();
2548 QgsDebugMsgLevel( QString(
"exprVal Font strikeout:%1" ).arg( strikeout ?
"true" :
"false" ), 4 );
2549 labelFont.setStrikeOut( strikeout );
2555 bool underline = exprVal.toBool();
2556 QgsDebugMsgLevel( QString(
"exprVal Font underline:%1" ).arg( underline ?
"true" :
"false" ), 4 );
2557 labelFont.setUnderline( underline );
2581 drawBuffer = exprVal.toBool();
2593 bufrSize = exprVal.toDouble();
2600 bufTransp = exprVal.toInt();
2603 drawBuffer = ( drawBuffer && bufrSize > 0.0 && bufTransp < 100 );
2634 wrapchr = exprVal.toString();
2643 QString str = exprVal.toString().trimmed();
2644 QgsDebugMsgLevel( QString(
"exprVal MultiLineAlignment:%1" ).arg( str ), 4 );
2646 if ( !str.isEmpty() )
2651 if ( str.compare(
"Center", Qt::CaseInsensitive ) == 0 )
2655 else if ( str.compare(
"Right", Qt::CaseInsensitive ) == 0 )
2667 drawDirSymb = exprVal.toBool();
2681 QString str = exprVal.toString().trimmed();
2682 QgsDebugMsgLevel( QString(
"exprVal DirSymbPlacement:%1" ).arg( str ), 4 );
2684 if ( !str.isEmpty() )
2689 if ( str.compare(
"Above", Qt::CaseInsensitive ) == 0 )
2693 else if ( str.compare(
"Below", Qt::CaseInsensitive ) == 0 )
2716 drawShape = exprVal.toBool();
2728 shapeTransp = exprVal.toInt();
2731 drawShape = ( drawShape && shapeTransp < 100 );
2744 QString skind = exprVal.toString().trimmed();
2747 if ( !skind.isEmpty() )
2752 if ( skind.compare(
"Square", Qt::CaseInsensitive ) == 0 )
2756 else if ( skind.compare(
"Ellipse", Qt::CaseInsensitive ) == 0 )
2760 else if ( skind.compare(
"Circle", Qt::CaseInsensitive ) == 0 )
2764 else if ( skind.compare(
"SVG", Qt::CaseInsensitive ) == 0 )
2768 shapeKind = shpkind;
2777 QString svgfile = exprVal.toString().trimmed();
2778 QgsDebugMsgLevel( QString(
"exprVal ShapeSVGFile:%1" ).arg( svgfile ), 4 );
2789 QString stype = exprVal.toString().trimmed();
2792 if ( !stype.isEmpty() )
2797 if ( stype.compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
2801 shpSizeType = sizType;
2810 ddShpSizeX = exprVal.toDouble();
2817 ddShpSizeY = exprVal.toDouble();
2823 && ( svgPath.isEmpty()
2824 || ( !svgPath.isEmpty()
2826 && ddShpSizeX == 0.0 ) ) )
2832 && ( ddShpSizeX == 0.0 || ddShpSizeY == 0.0 ) )
2854 QString rotstr = exprVal.toString().trimmed();
2855 QgsDebugMsgLevel( QString(
"exprVal ShapeRotationType:%1" ).arg( rotstr ), 4 );
2857 if ( !rotstr.isEmpty() )
2862 if ( rotstr.compare(
"Offset", Qt::CaseInsensitive ) == 0 )
2866 else if ( rotstr.compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
2917 drawShadow = exprVal.toBool();
2929 shadowTransp = exprVal.toInt();
2936 shadowOffDist = exprVal.toDouble();
2943 shadowRad = exprVal.toDouble();
2946 drawShadow = ( drawShadow && shadowTransp < 100 && !( shadowOffDist == 0.0 && shadowRad == 0.0 ) );
2960 QString str = exprVal.toString().trimmed();
2963 if ( !str.isEmpty() )
2968 if ( str.compare(
"Text", Qt::CaseInsensitive ) == 0 )
2972 else if ( str.compare(
"Buffer", Qt::CaseInsensitive ) == 0 )
2976 else if ( str.compare(
"Background", Qt::CaseInsensitive ) == 0 )
3016 if ( unit ==
MapUnits && mapUnitsPerPixel > 0.0 )
3022 double ptsTomm = ( unit ==
Points ? 0.352778 : 1 );
3031 : mMapRenderer( NULL ), mPal( NULL )
3040 switch ( p.getSearch() )
3070 bool enabled =
false;
3071 if ( layer->
customProperty(
"labeling" ).toString() == QString(
"pal" ) )
3072 enabled = layer->
customProperty(
"labeling/enabled", QVariant(
false ) ).toBool();
3079 QHash<QgsVectorLayer*, QgsPalLayerSettings>::iterator lit;
3092 QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* >::iterator it = lyr.
dataDefinedProperties.begin();
3095 delete( it.value() );
3116 if ( lyrTmp.fieldName.isEmpty() )
3122 if ( lyrTmp.isExpression )
3135 if ( fldIndex == -1 )
3166 if ( fldIndex != -1 )
3168 attrIndices.insert( fldIndex );
3173 QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* >::const_iterator dIt = lyr.
dataDefinedProperties.constBegin();
3185 QMap<QString, QVariant> exprParams;
3194 foreach ( QString name, cols )
3201 Arrangement arrangement;
3210 default: Q_ASSERT(
"unsupported placement" && 0 );
return 0;
3214 double priority = 1 - lyr.
priority / 10.0;
3215 double min_scale = -1, max_scale = -1;
3224 Layer* l =
mPal->addLayer( layer->
id().toUtf8().data(),
3225 min_scale, max_scale, arrangement,
3226 METER, priority, lyr.
obstacle,
true,
true,
3233 l->setLabelMode( lyr.
labelPerPart ? Layer::LabelPerFeaturePart : Layer::LabelPerFeature );
3239 Layer::UpsideDownLabels upsdnlabels;
3245 default: Q_ASSERT(
"unsupported upside-down label setting" && 0 );
return 0;
3247 l->setUpsidedownLabels( upsdnlabels );
3307 Layer* l =
mPal->addLayer( layer->
id().append(
"d" ).toUtf8().data(), -1, -1, pal::Arrangement( s->
placement ), METER, s->
priority, s->
obstacle,
true, true );
3329 QHash<QgsVectorLayer*, QgsDiagramLayerSettings>::iterator layerIt =
mActiveDiagramLayers.find( layer );
3340 geom->
transform( *( layerIt.value().ct ) );
3343 const GEOSGeometry* geos_geom = geom->
asGeos();
3344 if ( geos_geom == 0 )
3354 layerIt.value().geometries.append( lbl );
3356 double diagramWidth = 0;
3357 double diagramHeight = 0;
3362 if ( diagSize.isValid() )
3364 diagramWidth = diagSize.width();
3365 diagramHeight = diagSize.height();
3373 int ddColX = layerIt.value().xPosColumn;
3374 int ddColY = layerIt.value().yPosColumn;
3375 double ddPosX = 0.0;
3376 double ddPosY = 0.0;
3377 bool ddPos = ( ddColX >= 0 && ddColY >= 0 );
3380 bool posXOk, posYOk;
3382 ddPosX = feat.
attribute( ddColX ).toDouble( &posXOk ) - diagramWidth / 2.0;
3383 ddPosY = feat.
attribute( ddColY ).toDouble( &posYOk ) - diagramHeight / 2.0;
3384 if ( !posXOk || !posYOk )
3401 if ( !layerIt.value().palLayer->registerFeature( lbl->
strId(), lbl, diagramWidth, diagramHeight,
"", ddPosX, ddPosY, ddPos ) )
3406 catch ( std::exception &e )
3409 QgsDebugMsgLevel( QString(
"Ignoring feature %1 due PAL exception:" ).arg( feat.
id() ) + QString::fromLatin1( e.what() ), 4 );
3413 pal::Feature* palFeat = layerIt.value().palLayer->getFeature( lbl->
strId() );
3414 QgsPoint ptZero = layerIt.value().xform->toMapCoordinates( 0, 0 );
3415 QgsPoint ptOne = layerIt.value().xform->toMapCoordinates( 1, 0 );
3416 palFeat->setDistLabel( qAbs( ptOne.
x() - ptZero.
x() ) * layerIt.value().dist );
3434 case Chain: s = CHAIN;
break;
3438 case Falp: s = FALP;
break;
3440 mPal->setSearch( s );
3460 QHash<QgsVectorLayer*, QgsPalLayerSettings>::iterator lit;
3463 if ( lit.key() && lit.key()->id() == layerName )
3472 const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues )
3478 tmpLyr.
textColor = ddColor.value<QColor>();
3497 const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues )
3550 const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues )
3607 const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues )
3718 const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues )
3786 QPainter* painter = context.
painter();
3802 std::list<LabelPosition*>* labels;
3803 pal::Problem* problem;
3806 problem =
mPal->extractProblem( scale, bbox );
3808 catch ( std::exception& e )
3811 QgsDebugMsgLevel(
"PAL EXCEPTION :-( " + QString::fromLatin1( e.what() ), 4 );
3824 painter->setPen( QColor( 0, 0, 0, 64 ) );
3825 painter->setBrush( Qt::NoBrush );
3826 for (
int i = 0; i < problem->getNumFeatures(); i++ )
3828 for (
int j = 0; j < problem->getFeatureCandidateCount( i ); j++ )
3830 pal::LabelPosition* lp = problem->getFeatureCandidate( i, j );
3840 QgsDebugMsgLevel( QString(
"LABELING work: %1 ms ... labels# %2" ).arg( t.elapsed() ).arg( labels->size() ), 4 );
3843 painter->setRenderHint( QPainter::Antialiasing );
3846 std::list<LabelPosition*>::iterator it = labels->begin();
3847 for ( ; it != labels->end(); ++it )
3856 QString layerName = QString::fromUtf8(( *it )->getLayerName() );
3863 if ( dit.key() && dit.key()->id().append(
"d" ) == layerName )
3866 dit.value().renderer->renderDiagram( palGeometry->
diagramAttributes(), context, QPointF( outPt.
x(), outPt.
y() ) );
3874 QString layerId = layerName;
3889 const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& ddValues = palGeometry->
dataDefinedValues();
3894 #if QT_VERSION >= 0x040800
3896 QgsDebugMsgLevel( QString(
"PAL font definedFont: %1, Style: %2" ).arg( dFont.toString() ).arg( dFont.styleName() ), 4 );
3951 QString labeltext = ((
QgsPalGeometry* )( *it )->getFeaturePart()->getUserGeometry() )->text();
3957 painter->setCompositionMode( QPainter::CompositionMode_SourceOver );
3959 QgsDebugMsgLevel( QString(
"LABELING draw: %1 ms" ).arg( t.elapsed() ), 4 );
3965 QHash<QgsVectorLayer*, QgsPalLayerSettings>::iterator lit;
3969 for ( QList<QgsPalGeometry*>::iterator git = lyr.
geometries.begin(); git != lyr.
geometries.end(); ++git )
3986 for ( QList<QgsPalGeometry*>::iterator git = dls.
geometries.begin(); git != dls.
geometries.end(); ++git )
3996 QList<QgsLabelPosition> positions;
3998 QList<QgsLabelPosition*> positionPointers;
4002 QList<QgsLabelPosition*>::const_iterator pointerIt = positionPointers.constBegin();
4003 for ( ; pointerIt != positionPointers.constEnd(); ++pointerIt )
4014 QList<QgsLabelPosition> positions;
4016 QList<QgsLabelPosition*> positionPointers;
4020 QList<QgsLabelPosition*>::const_iterator pointerIt = positionPointers.constBegin();
4021 for ( ; pointerIt != positionPointers.constEnd(); ++pointerIt )
4057 QgsPoint outPt2 = xform->
transform( lp->getX() + lp->getWidth(), lp->getY() + lp->getHeight() );
4060 painter->translate( QPointF( outPt.
x(), outPt.
y() ) );
4061 painter->rotate( -lp->getAlpha() * 180 /
M_PI );
4062 QRectF rect( 0, 0, outPt2.
x() - outPt.
x(), outPt2.
y() - outPt.
y() );
4063 painter->drawRect( rect );
4067 rect.moveTo( outPt.
x(), outPt.
y() );
4071 if ( lp->getNextPart() )
4078 QPainter* painter = context.
painter();
4089 localp.begin( &localPict );
4091 double localdpi = ( localp.device()->logicalDpiX() + localp.device()->logicalDpiY() ) / 2;
4092 double contextdpi = ( painter->device()->logicalDpiX() + painter->device()->logicalDpiY() ) / 2;
4110 label->getY() + label->getHeight() / 2 );
4112 double xc = outPt2.
x() - outPt.
x();
4113 double yc = outPt2.
y() - outPt.
y();
4115 double angle = -label->getAlpha();
4116 double xd = xc * cos( angle ) - yc * sin( angle );
4117 double yd = xc * sin( angle ) + yc * cos( angle );
4119 centerPt.
setX( centerPt.
x() + xd );
4120 centerPt.
setY( centerPt.
y() + yd );
4123 component.
setSize(
QgsPoint( label->getWidth(), label->getHeight() ) );
4133 QString text = ((
QgsPalGeometry* )label->getFeaturePart()->getUserGeometry() )->text();
4134 QString txt = ( label->getPartId() == -1 ? text : QString( text[label->getPartId()] ) );
4135 QFontMetricsF* labelfm = ((
QgsPalGeometry* )label->getFeaturePart()->getUserGeometry() )->getLabelFontMetrics();
4137 QString wrapchr = !tmpLyr.
wrapChar.isEmpty() ? tmpLyr.
wrapChar : QString(
"\n" );
4143 bool prependSymb =
false;
4146 if ( label->getReversed() )
4161 prependSymb =
false;
4169 symb = symb + wrapchr;
4173 prependSymb =
false;
4174 symb = wrapchr + symb;
4179 txt.prepend( symb );
4189 QStringList multiLineList = txt.split( wrapchr );
4190 int lines = multiLineList.size();
4192 double labelWidest = 0.0;
4193 for (
int i = 0; i < lines; ++i )
4195 double labelWidth = labelfm->width( multiLineList.at( i ) );
4196 if ( labelWidth > labelWidest )
4198 labelWidest = labelWidth;
4202 double labelHeight = labelfm->ascent() + labelfm->descent();
4206 double ascentOffset = 0.25 * labelfm->ascent();
4208 for (
int i = 0; i < lines; ++i )
4211 painter->translate( QPointF( outPt.
x(), outPt.
y() ) );
4212 painter->rotate( -label->getAlpha() * 180 /
M_PI );
4219 double xMultiLineOffset = 0.0;
4220 double labelWidth = labelfm->width( multiLineList.at( i ) );
4223 double labelWidthDiff = labelWidest - labelWidth;
4226 labelWidthDiff /= 2;
4228 xMultiLineOffset = labelWidthDiff;
4232 double yMultiLineOffset = ( lines - 1 - i ) * labelHeight * tmpLyr.
multilineHeight;
4233 painter->translate( QPointF( xMultiLineOffset, - ascentOffset - yMultiLineOffset ) );
4235 component.
setText( multiLineList.at( i ) );
4250 path.addText( 0, 0, tmpLyr.
textFont, component.
text() );
4255 textp.begin( &textPict );
4256 textp.setPen( Qt::NoPen );
4258 textp.drawPath( path );
4273 painter->setCompositionMode( tmpLyr.
blendMode );
4281 painter->drawPicture( 0, 0, textPict );
4294 if ( label->getNextPart() )
4295 drawLabel( label->getNextPart(), context, tmpLyr, drawType );
4302 QPainter* p = context.
painter();
4308 path.addText( 0, 0, tmpLyr.
textFont, component.
text() );
4310 pen.setWidthF( penSize );
4316 tmpColor.setAlpha( 0 );
4322 buffp.begin( &buffPict );
4323 buffp.setPen( pen );
4324 buffp.setBrush( tmpColor );
4325 buffp.drawPath( path );
4348 p->drawPicture( 0, 0, buffPict );
4356 QPainter* p = context.
painter();
4357 double labelWidth = component.
size().
x(), labelHeight = component.
size().
y();
4387 double sizeOut = 0.0;
4396 if ( labelWidth >= labelHeight )
4397 sizeOut = labelWidth;
4398 else if ( labelHeight > labelWidth )
4399 sizeOut = labelHeight;
4404 sizeOut /= mmToMapUnits;
4418 map[
"size"] = QString::number( sizeOut );
4421 map[
"angle"] = QString::number( 0.0 );
4449 svgp.begin( &svgPict );
4468 svgShdwM->
renderPoint( QPointF( svgSize / 2, -svgSize / 2 ), svgShdwContext );
4485 p->translate( QPointF( xoff, yoff ) );
4487 p->translate( -svgSize / 2, svgSize / 2 );
4511 p->translate( QPointF( xoff, yoff ) );
4514 p->setCompositionMode( QPainter::CompositionMode_SourceOver );
4548 h = sqrt( pow( w, 2 ) + pow( h, 2 ) );
4554 h = h / sqrt( 2.0 ) * 2;
4555 w = w / sqrt( 2.0 ) * 2;
4567 QRectF rect( -w / 2.0, - h / 2.0, w, h );
4569 if ( rect.isNull() )
4573 p->translate( QPointF( component.
center().
x(), component.
center().
y() ) );
4577 p->translate( QPointF( xoff, yoff ) );
4586 pen.setWidthF( penSize );
4598 shapep.begin( &shapePict );
4599 shapep.setPen( pen );
4607 shapep.drawRoundedRect( rect, tmpLyr.
shapeRadii.x(), tmpLyr.
shapeRadii.y(), Qt::RelativeSize );
4613 shapep.drawRoundedRect( rect, xRadius, yRadius );
4619 shapep.drawEllipse( rect );
4643 p->drawPicture( 0, 0, shapePict );
4656 QPainter* p = context.
painter();
4657 double componentWidth = component.
size().
x(), componentHeight = component.
size().
y();
4658 double xOffset = component.
offset().
x(), yOffset = component.
offset().
y();
4665 radius = ( int )( radius + 0.5 );
4669 double blurBufferClippingScale = 3.75;
4670 int blurbuffer = ( radius > 17 ? 16 : radius ) * blurBufferClippingScale;
4672 QImage blurImg( componentWidth + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
4673 componentHeight + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
4674 QImage::Format_ARGB32_Premultiplied );
4678 int minBlurImgSize = 1;
4682 int maxBlurImgSize = 40000;
4683 if ( blurImg.isNull()
4684 || ( blurImg.width() < minBlurImgSize || blurImg.height() < minBlurImgSize )
4685 || ( blurImg.width() > maxBlurImgSize || blurImg.height() > maxBlurImgSize ) )
4688 blurImg.fill( QColor( Qt::transparent ).rgba() );
4690 if ( !pictp.begin( &blurImg ) )
4692 pictp.setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
4693 QPointF imgOffset( blurbuffer + pictbuffer + xOffset,
4694 blurbuffer + pictbuffer + componentHeight + yOffset );
4696 pictp.drawPicture( imgOffset,
4700 pictp.setCompositionMode( QPainter::CompositionMode_SourceIn );
4701 pictp.fillRect( blurImg.rect(), tmpLyr.
shadowColor );
4714 picti.begin( &blurImg );
4715 picti.setBrush( Qt::Dense7Pattern );
4716 QPen imgPen( QColor( 0, 0, 255, 255 ) );
4717 imgPen.setWidth( 1 );
4718 picti.setPen( imgPen );
4719 picti.setOpacity( 0.1 );
4720 picti.drawRect( 0, 0, blurImg.width(), blurImg.height() );
4736 QPointF transPt( -offsetDist * cos( angleRad +
M_PI / 2 ),
4737 -offsetDist * sin( angleRad +
M_PI / 2 ) );
4740 p->setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
4747 double scale = ( double )tmpLyr.
shadowScale / 100.0;
4749 p->scale( scale, scale );
4754 p->translate( transPt );
4755 p->translate( -imgOffset.x(),
4757 p->drawImage( 0, 0, blurImg );
4765 p->setBrush( Qt::NoBrush );
4766 QPen imgPen( QColor( 255, 0, 0, 10 ) );
4767 imgPen.setWidth( 2 );
4768 imgPen.setStyle( Qt::DashLine );
4769 p->setPen( imgPen );
4770 p->scale( scale, scale );
4775 p->translate( transPt );
4776 p->translate( -imgOffset.x(),
4778 p->drawRect( 0, 0, blurImg.width(), blurImg.height() );
4783 p->setBrush( Qt::NoBrush );
4784 QPen componentRectPen( QColor( 0, 255, 0, 70 ) );
4785 componentRectPen.setWidth( 1 );
4790 p->setPen( componentRectPen );
4791 p->drawRect( QRect( -xOffset, -componentHeight - yOffset, componentWidth, componentHeight ) );
4802 "PAL",
"/SearchMethod", (
int )p.getSearch(), &saved ) );
4804 "PAL",
"/CandidatesPoint", p.getPointP(), &saved );
4806 "PAL",
"/CandidatesLine", p.getLineP(), &saved );
4808 "PAL",
"/CandidatesPolygon", p.getPolyP(), &saved );
4810 "PAL",
"/ShowingCandidates",
false, &saved );
4812 "PAL",
"/ShowingShadowRects",
false, &saved );
4814 "PAL",
"/ShowingAllLabels",
false, &saved );