100724_qgis_label.diff
python/core/qgsmaprenderer.sip (Arbeitskopie) | ||
---|---|---|
18 | 18 |
virtual bool willUseLayer( QgsVectorLayer* layer ) = 0; |
19 | 19 |
//! called when starting rendering of a layer |
20 | 20 |
virtual int prepareLayer(QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx ) = 0; |
21 |
//! called when starting rendering of a layer |
|
22 |
//! @note: this method was added in version 1.6 |
|
23 |
virtual int prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices, QgsRenderContext& ctx ) = 0; |
|
21 | 24 |
//! called for every feature |
22 | 25 |
virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ) = 0; |
23 | 26 |
//! called when the map is drawn and labels should be placed |
src/app/qgslabelinggui.h (Arbeitskopie) | ||
---|---|---|
48 | 48 |
protected: |
49 | 49 |
void populatePlacementMethods(); |
50 | 50 |
void populateFieldNames(); |
51 |
void populateDataDefinedCombos( QgsPalLayerSettings& s ); |
|
52 |
/**Sets data defined property attribute to map (if selected in combo box)*/ |
|
53 |
void setDataDefinedProperty( const QComboBox* c, QgsPalLayerSettings::DataDefinedProperties p, QgsPalLayerSettings& lyr ); |
|
54 |
void setCurrentComboValue( QComboBox* c, const QgsPalLayerSettings& s, QgsPalLayerSettings::DataDefinedProperties p ); |
|
51 | 55 |
void updateFont( QFont font ); |
52 | 56 | |
53 | 57 |
private: |
src/app/qgslabelinggui.cpp (Arbeitskopie) | ||
---|---|---|
70 | 70 |
QgsPalLayerSettings lyr; |
71 | 71 |
lyr.readFromLayer( layer ); |
72 | 72 | |
73 |
populateDataDefinedCombos( lyr ); |
|
74 | ||
73 | 75 |
// placement |
74 | 76 |
switch ( lyr.placement ) |
75 | 77 |
{ |
... | ... | |
237 | 239 |
lyr.bufferSize = 0; |
238 | 240 |
} |
239 | 241 |
lyr.minFeatureSize = mMinSizeSpinBox->value(); |
242 | ||
243 |
//data defined labeling |
|
244 |
setDataDefinedProperty( mSizeAttributeComboBox, QgsPalLayerSettings::Size, lyr ); |
|
245 |
setDataDefinedProperty( mColorAttributeComboBox, QgsPalLayerSettings::Color, lyr ); |
|
246 |
setDataDefinedProperty( mBoldAttributeComboBox, QgsPalLayerSettings::Bold, lyr ); |
|
247 |
setDataDefinedProperty( mItalicAttributeComboBox, QgsPalLayerSettings::Italic, lyr ); |
|
248 |
setDataDefinedProperty( mUnderlineAttributeComboBox, QgsPalLayerSettings::Underline, lyr ); |
|
249 |
setDataDefinedProperty( mStrikeoutAttributeComboBox, QgsPalLayerSettings::Strikeout, lyr ); |
|
250 |
setDataDefinedProperty( mFontFamilyAttributeComboBox, QgsPalLayerSettings::Family, lyr ); |
|
251 |
setDataDefinedProperty( mBufferSizeAttributeComboBox, QgsPalLayerSettings:: BufferSize, lyr ); |
|
252 |
setDataDefinedProperty( mBufferColorAttributeComboBox, QgsPalLayerSettings::BufferColor, lyr ); |
|
253 | ||
240 | 254 |
return lyr; |
241 | 255 |
} |
242 | 256 | |
... | ... | |
250 | 264 |
} |
251 | 265 |
} |
252 | 266 | |
267 |
void QgsLabelingGui::setDataDefinedProperty( const QComboBox* c, QgsPalLayerSettings::DataDefinedProperties p, QgsPalLayerSettings& lyr ) |
|
268 |
{ |
|
269 |
if ( !c ) |
|
270 |
{ |
|
271 |
return; |
|
272 |
} |
|
273 | ||
274 |
QVariant propertyField = c->itemData( c->currentIndex() ); |
|
275 |
if ( propertyField.isValid() ) |
|
276 |
{ |
|
277 |
lyr.setDataDefinedProperty( p, propertyField.toInt() ); |
|
278 |
} |
|
279 |
} |
|
280 | ||
281 |
void QgsLabelingGui::setCurrentComboValue( QComboBox* c, const QgsPalLayerSettings& s, QgsPalLayerSettings::DataDefinedProperties p ) |
|
282 |
{ |
|
283 |
if ( !c ) |
|
284 |
{ |
|
285 |
return; |
|
286 |
} |
|
287 | ||
288 |
QMap< QgsPalLayerSettings::DataDefinedProperties, int >::const_iterator it = s.dataDefinedProperties.find( p ); |
|
289 |
if ( it == s.dataDefinedProperties.constEnd() ) |
|
290 |
{ |
|
291 |
c->setCurrentIndex( 0 ); |
|
292 |
} |
|
293 |
else |
|
294 |
{ |
|
295 |
c->setCurrentIndex( c->findData( it.value() ) ); |
|
296 |
} |
|
297 |
} |
|
298 | ||
299 |
void QgsLabelingGui::populateDataDefinedCombos( QgsPalLayerSettings& s ) |
|
300 |
{ |
|
301 |
QList<QComboBox*> comboList; |
|
302 |
comboList << mSizeAttributeComboBox; |
|
303 |
comboList << mColorAttributeComboBox; |
|
304 |
comboList << mBoldAttributeComboBox; |
|
305 |
comboList << mItalicAttributeComboBox; |
|
306 |
comboList << mUnderlineAttributeComboBox; |
|
307 |
comboList << mStrikeoutAttributeComboBox; |
|
308 |
comboList << mFontFamilyAttributeComboBox; |
|
309 |
comboList << mBufferSizeAttributeComboBox; |
|
310 |
comboList << mBufferColorAttributeComboBox; |
|
311 | ||
312 |
QList<QComboBox*>::iterator comboIt = comboList.begin(); |
|
313 |
for ( ; comboIt != comboList.end(); ++comboIt ) |
|
314 |
{ |
|
315 |
( *comboIt )->addItem( "", QVariant() ); |
|
316 |
} |
|
317 | ||
318 |
const QgsFieldMap& fields = mLayer->dataProvider()->fields(); |
|
319 |
for ( QgsFieldMap::const_iterator it = fields.constBegin(); it != fields.constEnd(); it++ ) |
|
320 |
{ |
|
321 |
for ( comboIt = comboList.begin(); comboIt != comboList.end(); ++comboIt ) |
|
322 |
{ |
|
323 |
( *comboIt )->addItem( it.value().name(), it.key() ); |
|
324 |
} |
|
325 | ||
326 |
} |
|
327 | ||
328 |
//set current combo boxes to already existing indices |
|
329 |
setCurrentComboValue( mSizeAttributeComboBox, s, QgsPalLayerSettings::Size ); |
|
330 |
setCurrentComboValue( mColorAttributeComboBox, s, QgsPalLayerSettings::Color ); |
|
331 |
setCurrentComboValue( mBoldAttributeComboBox, s, QgsPalLayerSettings::Bold ); |
|
332 |
setCurrentComboValue( mItalicAttributeComboBox, s, QgsPalLayerSettings::Italic ); |
|
333 |
setCurrentComboValue( mUnderlineAttributeComboBox, s, QgsPalLayerSettings::Underline ); |
|
334 |
setCurrentComboValue( mStrikeoutAttributeComboBox, s, QgsPalLayerSettings::Strikeout ); |
|
335 |
setCurrentComboValue( mFontFamilyAttributeComboBox, s, QgsPalLayerSettings::Family ); |
|
336 |
setCurrentComboValue( mBufferSizeAttributeComboBox, s , QgsPalLayerSettings::BufferSize ); |
|
337 |
setCurrentComboValue( mBufferColorAttributeComboBox, s, QgsPalLayerSettings::BufferColor ); |
|
338 |
} |
|
339 | ||
253 | 340 |
void QgsLabelingGui::changeTextColor() |
254 | 341 |
{ |
255 | 342 |
QColor color = QColorDialog::getColor( btnTextColor->color(), this ); |
src/core/qgsvectorlayer.cpp (Arbeitskopie) | ||
---|---|---|
922 | 922 |
bool labeling = false; |
923 | 923 |
if ( rendererContext.labelingEngine() ) |
924 | 924 |
{ |
925 |
int attrIndex;
|
|
925 |
QSet<int> attrIndex;
|
|
926 | 926 |
if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex, rendererContext ) ) |
927 | 927 |
{ |
928 |
if ( !attributes.contains( attrIndex ) ) |
|
929 |
attributes << attrIndex; |
|
928 |
QSet<int>::const_iterator attIt = attrIndex.constBegin(); |
|
929 |
for ( ; attIt != attrIndex.constEnd(); ++attIt ) |
|
930 |
{ |
|
931 |
if ( !attributes.contains( *attIt ) ) |
|
932 |
{ |
|
933 |
attributes << *attIt; |
|
934 |
} |
|
935 |
} |
|
930 | 936 |
labeling = true; |
931 | 937 |
} |
932 | 938 |
} |
... | ... | |
978 | 984 |
bool labeling = false; |
979 | 985 |
if ( rendererContext.labelingEngine() ) |
980 | 986 |
{ |
981 |
int attrIndex;
|
|
987 |
QSet<int> attrIndex;
|
|
982 | 988 |
if ( rendererContext.labelingEngine()->prepareLayer( this, attrIndex, rendererContext ) ) |
983 | 989 |
{ |
984 |
if ( !attributes.contains( attrIndex ) ) |
|
985 |
attributes << attrIndex; |
|
990 |
QSet<int>::const_iterator attIt = attrIndex.constBegin(); |
|
991 |
for ( ; attIt != attrIndex.constEnd(); ++attIt ) |
|
992 |
{ |
|
993 |
if ( !attributes.contains( *attIt ) ) |
|
994 |
{ |
|
995 |
attributes << *attIt; |
|
996 |
} |
|
997 |
} |
|
986 | 998 |
labeling = true; |
987 | 999 |
} |
988 | 1000 |
} |
src/core/qgsmaprenderer.h (Arbeitskopie) | ||
---|---|---|
50 | 50 |
virtual void init( QgsMapRenderer* mp ) = 0; |
51 | 51 |
//! called to find out whether the layer is used for labeling |
52 | 52 |
virtual bool willUseLayer( QgsVectorLayer* layer ) = 0; |
53 |
//! legacy method. Use prepareLayer with QSet for new code |
|
54 |
virtual int prepareLayer( QgsVectorLayer* layer, int& attributeIndex, QgsRenderContext& ctx ) = 0; |
|
53 | 55 |
//! called when starting rendering of a layer |
54 |
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx ) = 0; |
|
56 |
//! @note: this method was added in version 1.6 |
|
57 |
virtual int prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices, QgsRenderContext& ctx ) = 0; |
|
55 | 58 |
//! called for every feature |
56 | 59 |
virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ) = 0; |
57 | 60 |
//! called when the map is drawn and labels should be placed |
src/core/qgspallabeling.cpp (Arbeitskopie) | ||
---|---|---|
95 | 95 |
return mInfo; |
96 | 96 |
} |
97 | 97 | |
98 |
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant >& dataDefinedValues() const { return mDataDefinedValues; } |
|
99 |
void addDataDefinedValue( QgsPalLayerSettings::DataDefinedProperties p, QVariant v ) { mDataDefinedValues.insert( p, v ); } |
|
100 | ||
98 | 101 |
protected: |
99 | 102 |
GEOSGeometry* mG; |
100 | 103 |
QString mText; |
101 | 104 |
QByteArray mStrId; |
102 | 105 |
int mId; |
103 | 106 |
LabelInfo* mInfo; |
107 |
/**Stores attribute values for data defined properties*/ |
|
108 |
QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > mDataDefinedValues; |
|
104 | 109 |
}; |
105 | 110 | |
106 | 111 |
// ------------- |
... | ... | |
151 | 156 |
vectorScaleFactor = s.vectorScaleFactor; |
152 | 157 |
rasterCompressFactor = s.rasterCompressFactor; |
153 | 158 | |
159 |
dataDefinedProperties = s.dataDefinedProperties; |
|
154 | 160 |
fontMetrics = NULL; |
155 | 161 |
ct = NULL; |
156 | 162 |
} |
... | ... | |
179 | 185 |
layer->setCustomProperty( property + "B", color.blue() ); |
180 | 186 |
} |
181 | 187 | |
188 |
static void _writeDataDefinedPropertyMap( QgsVectorLayer* layer, const QMap< QgsPalLayerSettings::DataDefinedProperties, int >& propertyMap ) |
|
189 |
{ |
|
190 |
if ( !layer ) |
|
191 |
{ |
|
192 |
return; |
|
193 |
} |
|
194 | ||
195 |
for ( int i = 0; i < 9; ++i ) |
|
196 |
{ |
|
197 |
QMap< QgsPalLayerSettings::DataDefinedProperties, int >::const_iterator it = propertyMap.find(( QgsPalLayerSettings::DataDefinedProperties )i ); |
|
198 |
QVariant propertyValue; |
|
199 |
if ( it == propertyMap.constEnd() ) |
|
200 |
{ |
|
201 |
propertyValue = QVariant(); //we cannot delete properties, so we just insert an invalid variant |
|
202 |
} |
|
203 |
else |
|
204 |
{ |
|
205 |
propertyValue = *it; |
|
206 |
} |
|
207 |
layer->setCustomProperty( "labeling/dataDefinedProperty" + QString::number( i ), propertyValue ); |
|
208 |
} |
|
209 |
} |
|
210 | ||
211 |
static void _readDataDefinedProperty( QgsVectorLayer* layer, QgsPalLayerSettings::DataDefinedProperties p, \ |
|
212 |
QMap< QgsPalLayerSettings::DataDefinedProperties, int >& propertyMap ) |
|
213 |
{ |
|
214 |
QVariant propertyField = layer->customProperty( "labeling/dataDefinedProperty" + QString::number( p ) ); |
|
215 |
bool conversionOk; |
|
216 |
int fieldIndex; |
|
217 | ||
218 |
if ( propertyField.isValid() ) |
|
219 |
{ |
|
220 |
fieldIndex = propertyField.toInt( &conversionOk ); |
|
221 |
if( conversionOk ) |
|
222 |
{ |
|
223 |
propertyMap.insert( p, fieldIndex ); |
|
224 |
} |
|
225 |
} |
|
226 |
} |
|
227 | ||
228 |
static void _readDataDefinedPropertyMap( QgsVectorLayer* layer, QMap< QgsPalLayerSettings::DataDefinedProperties, int >& propertyMap ) |
|
229 |
{ |
|
230 |
if ( !layer ) |
|
231 |
{ |
|
232 |
return; |
|
233 |
} |
|
234 | ||
235 |
_readDataDefinedProperty( layer, QgsPalLayerSettings::Size, propertyMap ); |
|
236 |
_readDataDefinedProperty( layer, QgsPalLayerSettings::Color, propertyMap ); |
|
237 |
_readDataDefinedProperty( layer, QgsPalLayerSettings::Bold, propertyMap ); |
|
238 |
_readDataDefinedProperty( layer, QgsPalLayerSettings::Italic, propertyMap ); |
|
239 |
_readDataDefinedProperty( layer, QgsPalLayerSettings::Underline, propertyMap ); |
|
240 |
_readDataDefinedProperty( layer, QgsPalLayerSettings::Strikeout, propertyMap ); |
|
241 |
_readDataDefinedProperty( layer, QgsPalLayerSettings::Family, propertyMap ); |
|
242 |
_readDataDefinedProperty( layer, QgsPalLayerSettings::BufferSize, propertyMap ); |
|
243 |
_readDataDefinedProperty( layer, QgsPalLayerSettings::BufferColor, propertyMap ); |
|
244 |
} |
|
245 | ||
182 | 246 |
void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer ) |
183 | 247 |
{ |
184 | 248 |
if ( layer->customProperty( "labeling" ).toString() != QString( "pal" ) ) |
... | ... | |
205 | 269 |
mergeLines = layer->customProperty( "labeling/mergeLines" ).toBool(); |
206 | 270 |
multiLineLabels = layer->customProperty( "labeling/multiLineLabels" ).toBool(); |
207 | 271 |
minFeatureSize = layer->customProperty( "labeling/minFeatureSize" ).toDouble(); |
272 |
_readDataDefinedPropertyMap( layer, dataDefinedProperties ); |
|
208 | 273 |
} |
209 | 274 | |
210 | 275 |
void QgsPalLayerSettings::writeToLayer( QgsVectorLayer* layer ) |
... | ... | |
234 | 299 |
layer->setCustomProperty( "labeling/mergeLines", mergeLines ); |
235 | 300 |
layer->setCustomProperty( "labeling/multiLineLabels", multiLineLabels ); |
236 | 301 |
layer->setCustomProperty( "labeling/minFeatureSize", minFeatureSize ); |
302 |
_writeDataDefinedPropertyMap( layer, dataDefinedProperties ); |
|
237 | 303 |
} |
238 | 304 | |
305 |
void QgsPalLayerSettings::setDataDefinedProperty( DataDefinedProperties p, int attributeIndex ) |
|
306 |
{ |
|
307 |
dataDefinedProperties.insert( p, attributeIndex ); |
|
308 |
} |
|
309 | ||
310 |
void QgsPalLayerSettings::removeDataDefinedProperty( DataDefinedProperties p ) |
|
311 |
{ |
|
312 |
dataDefinedProperties.remove( p ); |
|
313 |
} |
|
314 | ||
239 | 315 |
bool QgsPalLayerSettings::checkMinimumSizeMM( const QgsRenderContext& ct, QgsGeometry* geom, double minSize ) const |
240 | 316 |
{ |
241 | 317 |
if ( minSize <= 0 ) |
... | ... | |
274 | 350 |
return true; //should never be reached. Return true in this case to label such geometries anyway. |
275 | 351 |
} |
276 | 352 | |
277 |
void QgsPalLayerSettings::calculateLabelSize( QString text, double& labelX, double& labelY ) |
|
353 |
void QgsPalLayerSettings::calculateLabelSize( const QFontMetrics* fm, QString text, double& labelX, double& labelY )
|
|
278 | 354 |
{ |
279 |
QRectF labelRect = fontMetrics->boundingRect( text ); |
|
355 |
if ( !fm ) |
|
356 |
{ |
|
357 |
return; |
|
358 |
} |
|
359 | ||
360 |
QRectF labelRect = fm->boundingRect( text ); |
|
280 | 361 |
double w, h; |
281 | 362 |
if ( !multiLineLabels ) |
282 | 363 |
{ |
... | ... | |
286 | 367 |
else |
287 | 368 |
{ |
288 | 369 |
QStringList multiLineSplit = text.split( "\n" ); |
289 |
h = fontMetrics->height() * multiLineSplit.size() / rasterCompressFactor;
|
|
370 |
h = fm->height() * multiLineSplit.size() / rasterCompressFactor;
|
|
290 | 371 |
w = 0; |
291 | 372 |
for ( int i = 0; i < multiLineSplit.size(); ++i ) |
292 | 373 |
{ |
293 |
double width = fontMetrics->width( multiLineSplit.at( i ) );
|
|
374 |
double width = fm->width( multiLineSplit.at( i ) );
|
|
294 | 375 |
if ( width > w ) |
295 | 376 |
{ |
296 | 377 |
w = width; |
... | ... | |
309 | 390 |
{ |
310 | 391 |
QString labelText = f.attributeMap()[fieldIndex].toString(); |
311 | 392 |
double labelX, labelY; // will receive label size |
312 |
calculateLabelSize( labelText, labelX, labelY ); |
|
313 | 393 | |
394 |
//data defined label size? |
|
395 |
QMap< DataDefinedProperties, int >::const_iterator it = dataDefinedProperties.find( QgsPalLayerSettings::Size ); |
|
396 |
if( it != dataDefinedProperties.constEnd() ) |
|
397 |
{ |
|
398 |
QFont labelFont = textFont; |
|
399 |
//find out size |
|
400 |
QVariant size = f.attributeMap().value( *it ); |
|
401 |
if ( size.isValid() ) |
|
402 |
{ |
|
403 |
double sizeDouble = size.toDouble(); |
|
404 |
if ( sizeDouble <= 0 ) |
|
405 |
{ |
|
406 |
return; |
|
407 |
} |
|
408 |
labelFont.setPointSize( sizeToPixel( sizeDouble, context ) ); |
|
409 |
} |
|
410 |
QFontMetrics labelFontMetrics( labelFont ); |
|
411 |
calculateLabelSize( &labelFontMetrics, labelText, labelX, labelY ); |
|
412 |
} |
|
413 |
else |
|
414 |
{ |
|
415 |
calculateLabelSize( fontMetrics, labelText, labelX, labelY ); |
|
416 |
} |
|
417 | ||
314 | 418 |
QgsGeometry* geom = f.geometry(); |
315 | 419 |
if ( ct != NULL ) // reproject the geometry if necessary |
316 | 420 |
geom->transform( *ct ); |
... | ... | |
344 | 448 |
// TODO: allow layer-wide feature dist in PAL...? |
345 | 449 |
if ( dist != 0 ) |
346 | 450 |
feat->setDistLabel( fabs( ptOne.x() - ptZero.x() )* dist * vectorScaleFactor ); |
451 | ||
452 |
//add parameters for data defined labeling to QgsPalGeometry |
|
453 |
QMap< DataDefinedProperties, int >::const_iterator dIt = dataDefinedProperties.constBegin(); |
|
454 |
for ( ; dIt != dataDefinedProperties.constEnd(); ++dIt ) |
|
455 |
{ |
|
456 |
lbl->addDataDefinedValue( dIt.key(), f.attributeMap()[dIt.value()] ); |
|
457 |
} |
|
347 | 458 |
} |
348 | 459 | |
460 |
int QgsPalLayerSettings::sizeToPixel( double size, const QgsRenderContext& c ) const |
|
461 |
{ |
|
462 |
// set font size from points to output size |
|
463 |
double pixelSize = 0.3527 * size * c.scaleFactor() * c.rasterScaleFactor() + 0.5; |
|
464 |
return ( int )pixelSize; |
|
465 |
} |
|
349 | 466 | |
467 | ||
350 | 468 |
// ------------- |
351 | 469 | |
352 | 470 |
QgsPalLabeling::QgsPalLabeling() |
... | ... | |
387 | 505 |
return lyrTmp.enabled; |
388 | 506 |
} |
389 | 507 | |
508 |
int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, int& attributeIndex, QgsRenderContext& ctx ) |
|
509 |
{ |
|
510 |
//for backward compatibility |
|
511 |
QSet<int> attributeSet; |
|
512 |
prepareLayer( layer, attributeSet, ctx ); |
|
513 |
if ( attributeSet.size() > 0 ) |
|
514 |
{ |
|
515 |
attributeIndex = *attributeSet.constBegin(); |
|
516 |
} |
|
517 |
return 1; |
|
518 |
} |
|
390 | 519 | |
391 |
int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx ) |
|
520 | ||
521 |
int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices, QgsRenderContext& ctx ) |
|
392 | 522 |
{ |
393 | 523 |
Q_ASSERT( mMapRenderer != NULL ); |
394 | 524 | |
... | ... | |
403 | 533 |
int fldIndex = layer->fieldNameIndex( lyrTmp.fieldName ); |
404 | 534 |
if ( fldIndex == -1 ) |
405 | 535 |
return 0; |
406 |
attrIndex = fldIndex;
|
|
536 |
attrIndices.insert( fldIndex );
|
|
407 | 537 | |
538 |
//add indices of data defined fields |
|
539 |
QMap< QgsPalLayerSettings::DataDefinedProperties, int >::const_iterator dIt = lyrTmp.dataDefinedProperties.constBegin(); |
|
540 |
for ( ; dIt != lyrTmp.dataDefinedProperties.constEnd(); ++dIt ) |
|
541 |
{ |
|
542 |
attrIndices.insert( dIt.value() ); |
|
543 |
} |
|
544 | ||
408 | 545 |
// add layer settings to the pallabeling hashtable: <QgsVectorLayer*, QgsPalLayerSettings> |
409 | 546 |
mActiveLayers.insert( layer, lyrTmp ); |
410 | 547 |
// start using the reference to the layer in hashtable instead of local instance |
... | ... | |
445 | 582 |
// set whether adjacent lines should be merged |
446 | 583 |
l->setMergeConnectedLines( lyr.mergeLines ); |
447 | 584 | |
448 |
// set font size from points to output size |
|
449 |
double size = 0.3527 * lyr.textFont.pointSizeF() * ctx.scaleFactor(); |
|
450 |
// request larger font and then scale down painter (to avoid Qt font scale bug) |
|
451 |
lyr.textFont.setPixelSize(( int )( size*ctx.rasterScaleFactor() + 0.5 ) ); |
|
585 |
lyr.textFont.setPixelSize( lyr.sizeToPixel( lyr.textFont.pointSizeF(), ctx ) ); |
|
452 | 586 | |
453 | 587 |
//raster and vector scale factors |
454 | 588 |
lyr.vectorScaleFactor = ctx.scaleFactor(); |
... | ... | |
587 | 721 |
for ( ; it != labels->end(); ++it ) |
588 | 722 |
{ |
589 | 723 |
const QgsPalLayerSettings& lyr = layer(( *it )->getLayerName() ); |
724 |
QFont fontForLabel = lyr.textFont; |
|
725 |
QColor fontColor = lyr.textColor; |
|
726 |
double bufferSize = lyr.bufferSize; |
|
727 |
QColor bufferColor = lyr.bufferColor; |
|
590 | 728 | |
729 |
QgsPalGeometry* palGeometry = dynamic_cast< QgsPalGeometry* >(( *it )->getFeaturePart()->getUserGeometry() ); |
|
730 |
if ( !palGeometry ) |
|
731 |
{ |
|
732 |
continue; |
|
733 |
} |
|
734 | ||
735 |
//apply data defined settings for the label |
|
736 |
//font size |
|
737 |
QVariant dataDefinedSize = palGeometry->dataDefinedValues().value( QgsPalLayerSettings::Size ); |
|
738 |
if ( dataDefinedSize.isValid() ) |
|
739 |
{ |
|
740 |
fontForLabel.setPointSize( lyr.sizeToPixel( dataDefinedSize.toDouble(), context ) ); |
|
741 |
} |
|
742 |
//font color |
|
743 |
QVariant dataDefinedColor = palGeometry->dataDefinedValues().value( QgsPalLayerSettings::Color ); |
|
744 |
if ( dataDefinedColor.isValid() ) |
|
745 |
{ |
|
746 |
fontColor.setNamedColor( dataDefinedColor.toString() ); |
|
747 |
if ( !fontColor.isValid() ) |
|
748 |
{ |
|
749 |
fontColor = lyr.textColor; |
|
750 |
} |
|
751 |
} |
|
752 |
//font bold |
|
753 |
QVariant dataDefinedBold = palGeometry->dataDefinedValues().value( QgsPalLayerSettings::Bold ); |
|
754 |
if ( dataDefinedBold.isValid() ) |
|
755 |
{ |
|
756 |
fontForLabel.setBold(( bool )dataDefinedBold.toInt() ); |
|
757 |
} |
|
758 |
//font italic |
|
759 |
QVariant dataDefinedItalic = palGeometry->dataDefinedValues().value( QgsPalLayerSettings::Italic ); |
|
760 |
if ( dataDefinedItalic.isValid() ) |
|
761 |
{ |
|
762 |
fontForLabel.setItalic(( bool ) dataDefinedItalic.toInt() ); |
|
763 |
} |
|
764 |
//font underline |
|
765 |
QVariant dataDefinedUnderline = palGeometry->dataDefinedValues().value( QgsPalLayerSettings::Underline ); |
|
766 |
if ( dataDefinedUnderline.isValid() ) |
|
767 |
{ |
|
768 |
fontForLabel.setUnderline(( bool ) dataDefinedUnderline.toInt() ); |
|
769 |
} |
|
770 |
//font strikeout |
|
771 |
QVariant dataDefinedStrikeout = palGeometry->dataDefinedValues().value( QgsPalLayerSettings::Strikeout ); |
|
772 |
if ( dataDefinedStrikeout.isValid() ) |
|
773 |
{ |
|
774 |
fontForLabel.setStrikeOut(( bool ) dataDefinedStrikeout.toInt() ); |
|
775 |
} |
|
776 |
//font family |
|
777 |
QVariant dataDefinedFontFamily = palGeometry->dataDefinedValues().value( QgsPalLayerSettings::Family ); |
|
778 |
if ( dataDefinedFontFamily.isValid() ) |
|
779 |
{ |
|
780 |
fontForLabel.setFamily( dataDefinedFontFamily.toString() ); |
|
781 |
} |
|
782 |
//buffer size |
|
783 |
QVariant dataDefinedBufferSize = palGeometry->dataDefinedValues().value( QgsPalLayerSettings::BufferSize ); |
|
784 |
if ( dataDefinedBufferSize.isValid() ) |
|
785 |
{ |
|
786 |
bufferSize = dataDefinedBufferSize.toDouble(); |
|
787 |
} |
|
788 | ||
789 |
//buffer color |
|
790 |
QVariant dataDefinedBufferColor = palGeometry->dataDefinedValues().value( QgsPalLayerSettings::BufferColor ); |
|
791 |
if ( dataDefinedBufferColor.isValid() ) |
|
792 |
{ |
|
793 |
bufferColor.setNamedColor( dataDefinedBufferColor.toString() ); |
|
794 |
if ( !bufferColor.isValid() ) |
|
795 |
{ |
|
796 |
bufferColor = lyr.bufferColor; |
|
797 |
} |
|
798 |
} |
|
799 | ||
591 | 800 |
if ( lyr.bufferSize != 0 ) |
592 |
drawLabel( *it, painter, xform, true );
|
|
801 |
drawLabel( *it, painter, fontForLabel, fontColor, xform, bufferSize, bufferColor, true );
|
|
593 | 802 | |
594 |
drawLabel( *it, painter, xform ); |
|
803 |
drawLabel( *it, painter, fontForLabel, fontColor, xform );
|
|
595 | 804 |
} |
596 | 805 | |
597 | 806 |
QgsDebugMsg( QString( "LABELING draw: %1 ms" ).arg( t.elapsed() ) ); |
... | ... | |
660 | 869 | |
661 | 870 |
#include "qgslogger.h" |
662 | 871 | |
663 |
void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QPainter* painter, const QgsMapToPixel* xform, bool drawBuffer ) |
|
872 |
void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QPainter* painter, const QFont& f, const QColor& c, const QgsMapToPixel* xform, double bufferSize, \ |
|
873 |
const QColor& bufferColor, bool drawBuffer ) |
|
664 | 874 |
{ |
665 | 875 |
QgsPoint outPt = xform->transform( label->getX(), label->getY() ); |
666 | 876 | |
... | ... | |
698 | 908 |
if ( drawBuffer ) |
699 | 909 |
{ |
700 | 910 |
// we're drawing buffer |
701 |
drawLabelBuffer( painter, multiLineList.at( i ), lyr.textFont, lyr.bufferSize * lyr.vectorScaleFactor * lyr.rasterCompressFactor , lyr.bufferColor );
|
|
911 |
drawLabelBuffer( painter, multiLineList.at( i ), f, bufferSize * lyr.vectorScaleFactor * lyr.rasterCompressFactor , bufferColor );
|
|
702 | 912 |
} |
703 | 913 |
else |
704 | 914 |
{ |
705 | 915 |
// we're drawing real label |
706 | 916 |
QPainterPath path; |
707 |
path.addText( 0, 0, lyr.textFont, multiLineList.at( i ) );
|
|
917 |
path.addText( 0, 0, f, multiLineList.at( i ) );
|
|
708 | 918 |
painter->setPen( Qt::NoPen ); |
709 |
painter->setBrush( lyr.textColor );
|
|
919 |
painter->setBrush( c );
|
|
710 | 920 |
painter->drawPath( path ); |
711 | 921 |
} |
712 | 922 |
painter->restore(); |
713 | 923 | |
714 | 924 |
if ( label->getNextPart() ) |
715 |
drawLabel( label->getNextPart(), painter, xform, drawBuffer ); |
|
925 |
drawLabel( label->getNextPart(), painter, f, c, xform, drawBuffer );
|
|
716 | 926 |
} |
717 | 927 |
} |
718 | 928 |
src/core/qgspallabeling.h (Arbeitskopie) | ||
---|---|---|
72 | 72 |
MapOrientation = 8 |
73 | 73 |
}; |
74 | 74 | |
75 |
enum DataDefinedProperties |
|
76 |
{ |
|
77 |
Size = 0, |
|
78 |
Bold, |
|
79 |
Italic, |
|
80 |
Underline, |
|
81 |
Color, |
|
82 |
Strikeout, |
|
83 |
Family, |
|
84 |
BufferSize, |
|
85 |
BufferColor, |
|
86 |
}; |
|
87 | ||
75 | 88 |
QString fieldName; |
76 | 89 |
Placement placement; |
77 | 90 |
unsigned int placementFlags; |
... | ... | |
92 | 105 |
double minFeatureSize; // minimum feature size to be labelled (in mm) |
93 | 106 | |
94 | 107 |
// called from register feature hook |
95 |
void calculateLabelSize( QString text, double& labelX, double& labelY ); |
|
108 |
void calculateLabelSize( const QFontMetrics* fm, QString text, double& labelX, double& labelY );
|
|
96 | 109 | |
97 | 110 |
// implementation of register feature hook |
98 | 111 |
void registerFeature( QgsFeature& f, const QgsRenderContext& context ); |
... | ... | |
100 | 113 |
void readFromLayer( QgsVectorLayer* layer ); |
101 | 114 |
void writeToLayer( QgsVectorLayer* layer ); |
102 | 115 | |
116 |
/**Set a property as data defined*/ |
|
117 |
void setDataDefinedProperty( DataDefinedProperties p, int attributeIndex ); |
|
118 |
/**Set a property to static instead data defined*/ |
|
119 |
void removeDataDefinedProperty( DataDefinedProperties p ); |
|
120 | ||
103 | 121 |
// temporary stuff: set when layer gets prepared |
104 | 122 |
pal::Layer* palLayer; |
105 | 123 |
int fieldIndex; |
... | ... | |
109 | 127 |
QgsPoint ptZero, ptOne; |
110 | 128 |
QList<QgsPalGeometry*> geometries; |
111 | 129 | |
130 |
/**Stores field indices for data defined layer properties*/ |
|
131 |
QMap< DataDefinedProperties, int > dataDefinedProperties; |
|
132 | ||
133 |
/**Calculates pixel size (considering scale factors and oversampling) |
|
134 |
@param label size (pixels, possibily map units in future) |
|
135 |
@param c rendercontext |
|
136 |
@return font pixel size*/ |
|
137 |
int sizeToPixel( double size, const QgsRenderContext& c ) const; |
|
138 | ||
112 | 139 |
private: |
113 | 140 |
/**Checks if a feature is larger than a minimum size (in mm) |
114 | 141 |
@return true if above size, false if below*/ |
... | ... | |
153 | 180 |
virtual void init( QgsMapRenderer* mr ); |
154 | 181 |
//! called to find out whether the layer is used for labeling |
155 | 182 |
virtual bool willUseLayer( QgsVectorLayer* layer ); |
183 |
//! legacy method. Use prepareLayer with QSet for new code |
|
184 |
virtual int prepareLayer( QgsVectorLayer* layer, int& attributeIndex, QgsRenderContext& ctx ); |
|
156 | 185 |
//! hook called when drawing layer before issuing select() |
157 |
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex, QgsRenderContext& ctx );
|
|
186 |
virtual int prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices, QgsRenderContext& ctx );
|
|
158 | 187 |
//! hook called when drawing for every feature in a layer |
159 | 188 |
virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat, const QgsRenderContext& context = QgsRenderContext() ); |
160 | 189 |
//! called when the map is drawn and labels should be placed |
... | ... | |
166 | 195 |
virtual QgsLabelingEngineInterface* clone(); |
167 | 196 | |
168 | 197 |
void drawLabelCandidateRect( pal::LabelPosition* lp, QPainter* painter, const QgsMapToPixel* xform ); |
169 |
void drawLabel( pal::LabelPosition* label, QPainter* painter, const QgsMapToPixel* xform, bool drawBuffer = false ); |
|
198 |
//!drawLabel |
|
199 |
void drawLabel( pal::LabelPosition* label, QPainter* painter, const QFont& f, const QColor& c, const QgsMapToPixel* xform, double bufferSize = -1, \ |
|
200 |
const QColor& bufferColor = QColor( 255, 255, 255 ), bool drawBuffer = false ); |
|
170 | 201 |
static void drawLabelBuffer( QPainter* p, QString text, const QFont& font, double size, QColor color ); |
171 | 202 | |
172 | 203 |
protected: |
173 | 204 | |
174 | 205 |
void initPal(); |
175 | 206 | |
176 | ||
177 | 207 |
protected: |
178 | 208 |
// temporary hashtable of layer settings, being filled during labeling, cleared once labeling's done |
179 | 209 |
QHash<QgsVectorLayer*, QgsPalLayerSettings> mActiveLayers; |
src/ui/qgslabelingguibase.ui (Arbeitskopie) | ||
---|---|---|
6 | 6 |
<rect> |
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 |
<width>482</width>
|
|
10 |
<height>610</height>
|
|
9 |
<width>496</width>
|
|
10 |
<height>659</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="windowTitle"> |
... | ... | |
17 | 17 |
<iconset> |
18 | 18 |
<normaloff>../../../../.designer/backup</normaloff>../../../../.designer/backup</iconset> |
19 | 19 |
</property> |
20 |
<layout class="QGridLayout" name="gridLayout_5">
|
|
20 |
<layout class="QGridLayout" name="gridLayout_13">
|
|
21 | 21 |
<item row="0" column="0"> |
22 |
<widget class="QCheckBox" name="chkEnableLabeling">
|
|
23 |
<property name="text">
|
|
24 |
<string>Label this layer</string>
|
|
22 |
<widget class="QTabWidget" name="mTabWidget">
|
|
23 |
<property name="currentIndex">
|
|
24 |
<number>0</number>
|
|
25 | 25 |
</property> |
26 |
</widget> |
|
27 |
</item> |
|
28 |
<item row="1" column="0"> |
|
29 |
<layout class="QHBoxLayout" name="horizontalLayout_9"> |
|
30 |
<item> |
|
31 |
<widget class="QLabel" name="label_6"> |
|
32 |
<property name="text"> |
|
33 |
<string>Field with labels</string> |
|
34 |
</property> |
|
35 |
<property name="alignment"> |
|
36 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
37 |
</property> |
|
38 |
</widget> |
|
39 |
</item> |
|
40 |
<item> |
|
41 |
<widget class="QComboBox" name="cboFieldName"/> |
|
42 |
</item> |
|
43 |
<item> |
|
44 |
<spacer name="horizontalSpacer_4"> |
|
45 |
<property name="orientation"> |
|
46 |
<enum>Qt::Horizontal</enum> |
|
47 |
</property> |
|
48 |
<property name="sizeHint" stdset="0"> |
|
49 |
<size> |
|
50 |
<width>40</width> |
|
51 |
<height>20</height> |
|
52 |
</size> |
|
53 |
</property> |
|
54 |
</spacer> |
|
55 |
</item> |
|
56 |
</layout> |
|
57 |
</item> |
|
58 |
<item row="2" column="0"> |
|
59 |
<widget class="QGroupBox" name="groupBox_4"> |
|
60 |
<property name="title"> |
|
61 |
<string>Placement</string> |
|
62 |
</property> |
|
63 |
<layout class="QHBoxLayout" name="horizontalLayout_8"> |
|
64 |
<property name="leftMargin"> |
|
65 |
<number>0</number> |
|
66 |
</property> |
|
67 |
<property name="topMargin"> |
|
68 |
<number>0</number> |
|
69 |
</property> |
|
70 |
<property name="rightMargin"> |
|
71 |
<number>0</number> |
|
72 |
</property> |
|
73 |
<property name="bottomMargin"> |
|
74 |
<number>4</number> |
|
75 |
</property> |
|
76 |
<item> |
|
77 |
<widget class="QStackedWidget" name="stackedPlacement"> |
|
78 |
<property name="currentIndex"> |
|
79 |
<number>0</number> |
|
80 |
</property> |
|
81 |
<widget class="QWidget" name="pagePoint"> |
|
82 |
<layout class="QVBoxLayout" name="verticalLayout_2"> |
|
83 |
<item> |
|
84 |
<widget class="QRadioButton" name="radAroundPoint"> |
|
85 |
<property name="text"> |
|
86 |
<string>around point</string> |
|
87 |
</property> |
|
88 |
<property name="checked"> |
|
89 |
<bool>true</bool> |
|
90 |
</property> |
|
91 |
</widget> |
|
92 |
</item> |
|
93 |
<item> |
|
94 |
<widget class="QRadioButton" name="radOverPoint"> |
|
95 |
<property name="text"> |
|
96 |
<string>over point</string> |
|
97 |
</property> |
|
98 |
</widget> |
|
99 |
</item> |
|
100 |
</layout> |
|
26 |
<widget class="QWidget" name="tab_3"> |
|
27 |
<attribute name="title"> |
|
28 |
<string>Label settings</string> |
|
29 |
</attribute> |
|
30 |
<layout class="QGridLayout" name="gridLayout_6"> |
|
31 |
<item row="0" column="0"> |
|
32 |
<widget class="QCheckBox" name="chkEnableLabeling"> |
|
33 |
<property name="text"> |
|
34 |
<string>Label this layer</string> |
|
35 |
</property> |
|
101 | 36 |
</widget> |
102 |
<widget class="QWidget" name="pageLine"> |
|
103 |
<layout class="QVBoxLayout" name="verticalLayout_3"> |
|
37 |
</item> |
|
38 |
<item row="1" column="0"> |
|
39 |
<layout class="QHBoxLayout" name="horizontalLayout_11"> |
|
40 |
<item> |
|
41 |
<widget class="QLabel" name="label_20"> |
|
42 |
<property name="text"> |
|
43 |
<string>Field with labels</string> |
|
44 |
</property> |
|
45 |
<property name="alignment"> |
|
46 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
47 |
</property> |
|
48 |
</widget> |
|
49 |
</item> |
|
50 |
<item> |
|
51 |
<widget class="QComboBox" name="cboFieldName"/> |
|
52 |
</item> |
|
53 |
<item> |
|
54 |
<spacer name="horizontalSpacer_5"> |
|
55 |
<property name="orientation"> |
|
56 |
<enum>Qt::Horizontal</enum> |
|
57 |
</property> |
|
58 |
<property name="sizeHint" stdset="0"> |
|
59 |
<size> |
|
60 |
<width>40</width> |
|
61 |
<height>20</height> |
|
62 |
</size> |
|
63 |
</property> |
|
64 |
</spacer> |
|
65 |
</item> |
|
66 |
</layout> |
|
67 |
</item> |
|
68 |
<item row="2" column="0"> |
|
69 |
<widget class="QGroupBox" name="groupBox_5"> |
|
70 |
<property name="title"> |
|
71 |
<string>Placement</string> |
|
72 |
</property> |
|
73 |
<layout class="QHBoxLayout" name="horizontalLayout_12"> |
|
74 |
<property name="leftMargin"> |
|
75 |
<number>0</number> |
|
76 |
</property> |
|
77 |
<property name="topMargin"> |
|
78 |
<number>0</number> |
|
79 |
</property> |
|
80 |
<property name="rightMargin"> |
|
81 |
<number>0</number> |
|
82 |
</property> |
|
83 |
<property name="bottomMargin"> |
|
84 |
<number>4</number> |
|
85 |
</property> |
|
104 | 86 |
<item> |
105 |
<widget class="QRadioButton" name="radLineParallel">
|
|
106 |
<property name="text">
|
|
107 |
<string>parallel</string>
|
|
87 |
<widget class="QStackedWidget" name="stackedPlacement">
|
|
88 |
<property name="currentIndex">
|
|
89 |
<number>2</number>
|
|
108 | 90 |
</property> |
109 |
<property name="checked"> |
|
110 |
<bool>true</bool> |
|
111 |
</property> |
|
91 |
<widget class="QWidget" name="pagePoint"> |
|
92 |
<layout class="QVBoxLayout" name="verticalLayout_6"> |
|
93 |
<item> |
|
94 |
<widget class="QRadioButton" name="radAroundPoint"> |
|
95 |
<property name="text"> |
|
96 |
<string>around point</string> |
|
97 |
</property> |
|
98 |
<property name="checked"> |
|
99 |
<bool>true</bool> |
|
100 |
</property> |
|
101 |
</widget> |
|
102 |
</item> |
|
103 |
<item> |
|
104 |
<widget class="QRadioButton" name="radOverPoint"> |
|
105 |
<property name="text"> |
|
106 |
<string>over point</string> |
|
107 |
</property> |
|
108 |
</widget> |
|
109 |
</item> |
|
110 |
</layout> |
|
111 |
</widget> |
|
112 |
<widget class="QWidget" name="pageLine"> |
|
113 |
<layout class="QVBoxLayout" name="verticalLayout_7"> |
|
114 |
<item> |
|
115 |
<widget class="QRadioButton" name="radLineParallel"> |
|
116 |
<property name="text"> |
|
117 |
<string>parallel</string> |
|
118 |
</property> |
|
119 |
<property name="checked"> |
|
120 |
<bool>true</bool> |
|
121 |
</property> |
|
122 |
</widget> |
|
123 |
</item> |
|
124 |
<item> |
|
125 |
<widget class="QRadioButton" name="radLineCurved"> |
|
126 |
<property name="text"> |
|
127 |
<string>curved</string> |
|
128 |
</property> |
|
129 |
</widget> |
|
130 |
</item> |
|
131 |
<item> |
|
132 |
<widget class="QRadioButton" name="radLineHorizontal"> |
|
133 |
<property name="text"> |
|
134 |
<string>horizontal</string> |
|
135 |
</property> |
|
136 |
</widget> |
|
137 |
</item> |
|
138 |
</layout> |
|
139 |
</widget> |
|
140 |
<widget class="QWidget" name="pagePolygon"> |
|
141 |
<layout class="QVBoxLayout" name="verticalLayout_8"> |
|
142 |
<item> |
|
143 |
<widget class="QRadioButton" name="radOverCentroid"> |
|
144 |
<property name="text"> |
|
145 |
<string>over centroid</string> |
|
146 |
</property> |
|
147 |
<property name="checked"> |
|
148 |
<bool>true</bool> |
|
149 |
</property> |
|
150 |
</widget> |
|
151 |
</item> |
|
152 |
<item> |
|
153 |
<widget class="QRadioButton" name="radAroundCentroid"> |
|
154 |
<property name="text"> |
|
155 |
<string>around centroid</string> |
|
156 |
</property> |
|
157 |
</widget> |
|
158 |
</item> |
|
159 |
<item> |
|
160 |
<widget class="QRadioButton" name="radPolygonHorizontal"> |
|
161 |
<property name="text"> |
|
162 |
<string>horizontal (slow)</string> |
|
163 |
</property> |
|
164 |
</widget> |
|
165 |
</item> |
|
166 |
<item> |
|
167 |
<widget class="QRadioButton" name="radPolygonFree"> |
|
168 |
<property name="text"> |
|
169 |
<string>free (slow)</string> |
|
170 |
</property> |
|
171 |
</widget> |
|
172 |
</item> |
|
173 |
<item> |
|
174 |
<widget class="QRadioButton" name="radPolygonPerimeter"> |
|
175 |
<property name="text"> |
|
176 |
<string>using perimeter</string> |
|
177 |
</property> |
|
178 |
</widget> |
|
179 |
</item> |
|
180 |
</layout> |
|
181 |
</widget> |
|
112 | 182 |
</widget> |
113 | 183 |
</item> |
114 | 184 |
<item> |
115 |
<widget class="QRadioButton" name="radLineCurved">
|
|
116 |
<property name="text">
|
|
117 |
<string>curved</string>
|
|
185 |
<widget class="Line" name="line_3">
|
|
186 |
<property name="orientation">
|
|
187 |
<enum>Qt::Vertical</enum>
|
|
118 | 188 |
</property> |
119 | 189 |
</widget> |
120 | 190 |
</item> |
121 | 191 |
<item> |
122 |
<widget class="QRadioButton" name="radLineHorizontal">
|
|
123 |
<property name="text">
|
|
124 |
<string>horizontal</string>
|
|
192 |
<widget class="QStackedWidget" name="stackedOptions">
|
|
193 |
<property name="currentIndex">
|
|
194 |
<number>1</number>
|
|
125 | 195 |
</property> |
196 |
<widget class="QWidget" name="pageOptionsPoint"> |
|
197 |
<layout class="QGridLayout" name="gridLayout_7"> |
|
198 |
<item row="0" column="0"> |
|
199 |
<widget class="QLabel" name="label_21"> |
|
200 |
<property name="text"> |
|
201 |
<string>Label distance</string> |
|
202 |
</property> |
|
203 |
<property name="alignment"> |
|
204 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
205 |
</property> |
|
206 |
</widget> |
|
207 |
</item> |
|
208 |
<item row="0" column="1"> |
|
209 |
<widget class="QDoubleSpinBox" name="spinDistPoint"> |
|
210 |
<property name="decimals"> |
|
211 |
<number>2</number> |
|
212 |
</property> |
|
213 |
</widget> |
|
214 |
</item> |
|
215 |
<item row="0" column="2"> |
|
216 |
<widget class="QLabel" name="label_22"> |
|
217 |
<property name="text"> |
|
218 |
<string>mm</string> |
|
219 |
</property> |
|
220 |
</widget> |
|
221 |
</item> |
|
222 |
<item row="1" column="0"> |
|
223 |
<widget class="QLabel" name="label_23"> |
|
224 |
<property name="text"> |
|
225 |
<string>Rotation</string> |
|
226 |
</property> |
|
227 |
<property name="alignment"> |
|
228 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
229 |
</property> |
|
230 |
</widget> |
|
231 |
</item> |
|
232 |
<item row="1" column="1"> |
|
233 |
<widget class="QSpinBox" name="spinAngle"> |
|
234 |
<property name="enabled"> |
|
235 |
<bool>false</bool> |
|
236 |
</property> |
|
237 |
</widget> |
|
238 |
</item> |
|
239 |
<item row="1" column="2"> |
|
240 |
<widget class="QLabel" name="label_24"> |
|
241 |
<property name="text"> |
|
242 |
<string>degrees</string> |
|
243 |
</property> |
|
244 |
</widget> |
|
245 |
</item> |
|
246 |
</layout> |
|
247 |
</widget> |
|
248 |
<widget class="QWidget" name="pageOptionsLine"> |
|
249 |
<layout class="QVBoxLayout" name="verticalLayout_9"> |
|
250 |
<item> |
|
251 |
<widget class="QCheckBox" name="chkLineAbove"> |
|
252 |
<property name="text"> |
|
253 |
<string>above line</string> |
|
254 |
</property> |
|
255 |
<property name="checked"> |
|
256 |
<bool>true</bool> |
|
257 |
</property> |
|
258 |
</widget> |
|
259 |
</item> |
|
260 |
<item> |
|
261 |
<widget class="QCheckBox" name="chkLineOn"> |
|
262 |
<property name="text"> |
|
263 |
<string>on line</string> |
|
264 |
</property> |
|
265 |
</widget> |
|
266 |
</item> |
|
267 |
<item> |
|
268 |
<widget class="QCheckBox" name="chkLineBelow"> |
|
269 |
<property name="text"> |
|
270 |
<string>below line</string> |
|
271 |
</property> |
|
272 |
</widget> |
|
273 |
</item> |
|
274 |
<item> |
|
275 |
<layout class="QHBoxLayout" name="horizontalLayout_13"> |
|
276 |
<item> |
|
277 |
<widget class="QLabel" name="label_25"> |
|
278 |
<property name="text"> |
|
279 |
<string>Orientation</string> |
|
280 |
</property> |
|
281 |
</widget> |
|
282 |
</item> |
|
283 |
<item> |
|
284 |
<widget class="QRadioButton" name="radOrientationMap"> |
|
285 |
<property name="text"> |
|
286 |
<string>map</string> |
|
287 |
</property> |
|
288 |
<property name="checked"> |
|
289 |
<bool>true</bool> |
|
290 |
</property> |
|
291 |
</widget> |
|
292 |
</item> |
|
293 |
<item> |
|
294 |
<widget class="QRadioButton" name="radOrientationLine"> |
|
295 |
<property name="text"> |
|
296 |
<string>line</string> |
|
297 |
</property> |
|
298 |
</widget> |
|
299 |
</item> |
|
300 |
</layout> |
|
301 |
</item> |
|
302 |
<item> |
|
303 |
<layout class="QHBoxLayout" name="horizontalLayout_14"> |
|
304 |
<item> |
|
305 |
<widget class="QLabel" name="label_26"> |
|
306 |
<property name="text"> |
|
307 |
<string>Label distance</string> |
|
308 |
</property> |
|
309 |
<property name="alignment"> |
|
310 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
311 |
</property> |
|
312 |
</widget> |
|
313 |
</item> |
|
314 |
<item> |
|
315 |
<widget class="QDoubleSpinBox" name="spinDistLine"> |
|
316 |
<property name="decimals"> |
|
317 |
<number>2</number> |
|
318 |
</property> |
|
319 |
</widget> |
|
320 |
</item> |
|
321 |
<item> |
|
322 |
<widget class="QLabel" name="label_27"> |
|
323 |
<property name="text"> |
|
324 |
<string>mm</string> |
|
325 |
</property> |
|
326 |
</widget> |
|
327 |
</item> |
|
328 |
</layout> |
|
329 |
</item> |
|
330 |
</layout> |
|
331 |
</widget> |
|
332 |
<widget class="QWidget" name="pageOptionsEmpty"/> |
|
126 | 333 |
</widget> |
127 | 334 |
</item> |
128 | 335 |
</layout> |
129 | 336 |
</widget> |
130 |
<widget class="QWidget" name="pagePolygon"> |
|
131 |
<layout class="QVBoxLayout" name="verticalLayout_4"> |
|
132 |
<item> |
|
133 |
<widget class="QRadioButton" name="radOverCentroid"> |
|
134 |
<property name="text"> |
|
135 |
<string>over centroid</string> |
|
136 |
</property> |
|
137 |
<property name="checked"> |
|
138 |
<bool>true</bool> |
|
139 |
</property> |
|
140 |
</widget> |
|
141 |
</item> |
|
142 |
<item> |
|
143 |
<widget class="QRadioButton" name="radAroundCentroid"> |
|
144 |
<property name="text"> |
|
145 |
<string>around centroid</string> |
|
146 |
</property> |
|
147 |
</widget> |
|
148 |
</item> |
|
149 |
<item> |
|
150 |
<widget class="QRadioButton" name="radPolygonHorizontal"> |
|
151 |
<property name="text"> |
|
152 |
<string>horizontal (slow)</string> |
|
153 |
</property> |
|
154 |
</widget> |
|
155 |
</item> |
|
156 |
<item> |
|
157 |
<widget class="QRadioButton" name="radPolygonFree"> |
|
158 |
<property name="text"> |
|
159 |
<string>free (slow)</string> |
|
160 |
</property> |
|
161 |
</widget> |
|
162 |
</item> |
|
163 |
<item> |
|
164 |
<widget class="QRadioButton" name="radPolygonPerimeter"> |
|
165 |
<property name="text"> |
|
166 |
<string>using perimeter</string> |
|
167 |
</property> |
|
168 |
</widget> |
|
169 |
</item> |
|
170 |
</layout> |
|
171 |
</widget> |
|
172 |
</widget> |
|
173 |
</item> |
|
174 |
<item> |
|
175 |
<widget class="Line" name="line_2"> |
|
176 |
<property name="orientation"> |
|
177 |
<enum>Qt::Vertical</enum> |
|
178 |
</property> |
|
179 |
</widget> |
|
180 |
</item> |
|
181 |
<item> |
|
182 |
<widget class="QStackedWidget" name="stackedOptions"> |
|
183 |
<property name="currentIndex"> |
|
184 |
<number>0</number> |
|
185 |
</property> |
|
186 |
<widget class="QWidget" name="pageOptionsPoint"> |
|
187 |
<layout class="QGridLayout" name="gridLayout_2"> |
|
188 |
<item row="0" column="0"> |
|
189 |
<widget class="QLabel" name="label_8"> |
|
190 |
<property name="text"> |
|
191 |
<string>Label distance</string> |
|
192 |
</property> |
|
193 |
<property name="alignment"> |
|
194 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
195 |
</property> |
|
196 |
</widget> |
|
197 |
</item> |
|
198 |
<item row="0" column="1"> |
|
199 |
<widget class="QDoubleSpinBox" name="spinDistPoint"> |
|
200 |
<property name="decimals"> |
|
201 |
<number>2</number> |
|
202 |
</property> |
|
203 |
</widget> |
|
204 |
</item> |
|
205 |
<item row="0" column="2"> |
|
206 |
<widget class="QLabel" name="label_9"> |
|
207 |
<property name="text"> |
|
208 |
<string>mm</string> |
|
209 |
</property> |
|
210 |
</widget> |
|
211 |
</item> |
|
212 |
<item row="1" column="0"> |
|
213 |
<widget class="QLabel" name="label_17"> |
|
214 |
<property name="text"> |
|
215 |
<string>Rotation</string> |
|
216 |
</property> |
|
217 |
<property name="alignment"> |
|
218 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
219 |
</property> |
|
220 |
</widget> |
|
221 |
</item> |
|
222 |
<item row="1" column="1"> |
|
223 |
<widget class="QSpinBox" name="spinAngle"> |
|
224 |
<property name="enabled"> |
|
225 |
<bool>false</bool> |
|
226 |
</property> |
|
227 |
</widget> |
|
228 |
</item> |
|
229 |
<item row="1" column="2"> |
|
230 |
<widget class="QLabel" name="label_18"> |
|
231 |
<property name="text"> |
|
232 |
<string>degrees</string> |
|
233 |
</property> |
|
234 |
</widget> |
|
235 |
</item> |
|
236 |
</layout> |
|
237 |
</widget> |
|
238 |
<widget class="QWidget" name="pageOptionsLine"> |
|
239 |
<layout class="QVBoxLayout" name="verticalLayout_5"> |
|
240 |
<item> |
|
241 |
<widget class="QCheckBox" name="chkLineAbove"> |
|
242 |
<property name="text"> |
|
243 |
<string>above line</string> |
|
244 |
</property> |
|
245 |
<property name="checked"> |
|
246 |
<bool>true</bool> |
|
247 |
</property> |
|
248 |
</widget> |
|
249 |
</item> |
|
250 |
<item> |
|
251 |
<widget class="QCheckBox" name="chkLineOn"> |
|
252 |
<property name="text"> |
|
253 |
<string>on line</string> |
|
254 |
</property> |
|
255 |
</widget> |
|
256 |
</item> |
|
257 |
<item> |
|
258 |
<widget class="QCheckBox" name="chkLineBelow"> |
|
259 |
<property name="text"> |
|
260 |
<string>below line</string> |
|
261 |
</property> |
|
262 |
</widget> |
|
263 |
</item> |
|
264 |
<item> |
|
265 |
<layout class="QHBoxLayout" name="horizontalLayout_7"> |
|
266 |
<item> |
|
267 |
<widget class="QLabel" name="label"> |
|
337 |
</item> |
|
338 |
<item row="3" column="0"> |
|
339 |
<layout class="QGridLayout" name="gridLayout_8"> |
|
340 |
<item row="0" column="0" rowspan="2"> |
|
341 |
<widget class="QGroupBox" name="groupBox_6"> |
|
342 |
<property name="title"> |
|
343 |
<string>Text style</string> |
|
344 |
</property> |
|
345 |
<layout class="QGridLayout" name="gridLayout_9"> |
|
346 |
<item row="0" column="0"> |
|
347 |
<widget class="QLabel" name="label_28"> |
|
348 |
<property name="sizePolicy"> |
|
349 |
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> |
|
350 |
<horstretch>0</horstretch> |
|
351 |
<verstretch>0</verstretch> |
|
352 |
</sizepolicy> |
|
353 |
</property> |
|
268 | 354 |
<property name="text"> |
269 |
<string>Orientation</string>
|
|
355 |
<string>Font</string>
|
|
270 | 356 |
</property> |
357 |
<property name="alignment"> |
|
358 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
359 |
</property> |
|
271 | 360 |
</widget> |
272 | 361 |
</item> |
362 |
<item row="0" column="1"> |
|
363 |
<layout class="QHBoxLayout" name="horizontalLayout_15"> |
|
364 |
<item> |
|
365 |
<widget class="QLabel" name="lblFontName"> |
|
366 |
<property name="sizePolicy"> |
|
367 |
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> |
|
368 |
<horstretch>1</horstretch> |
|
369 |
<verstretch>0</verstretch> |
|
370 |
</sizepolicy> |
|
371 |
</property> |
|
372 |
<property name="text"> |
|
373 |
<string>TextLabel</string> |
|
374 |
</property> |
|
375 |
</widget> |
|
376 |
</item> |
|
377 |
<item> |
|
378 |
<spacer name="horizontalSpacer_6"> |
|
379 |
<property name="orientation"> |
|
380 |
<enum>Qt::Horizontal</enum> |
|
381 |
</property> |
|
382 |
<property name="sizeHint" stdset="0"> |
|
383 |
<size> |
|
384 |
<width>40</width> |
|
385 |
<height>20</height> |
|
386 |
</size> |
|
387 |
</property> |
|
388 |
</spacer> |
|
389 |
</item> |
|
390 |
<item> |
|
391 |
<widget class="QToolButton" name="btnChangeFont"> |
|
392 |
<property name="text"> |
|
393 |
<string>...</string> |
|
394 |
</property> |
|
395 |
</widget> |
|
396 |
</item> |
|
397 |
</layout> |
|
398 |
</item> |
|
399 |
<item row="1" column="0"> |
|
400 |
<widget class="QLabel" name="label_29"> |
|
401 |
<property name="sizePolicy"> |
|
402 |
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> |
|
403 |
<horstretch>0</horstretch> |
|
404 |
<verstretch>0</verstretch> |
|
405 |
</sizepolicy> |
|
406 |
</property> |
|
407 |
<property name="text"> |
|
408 |
<string>Color</string> |
|
409 |
</property> |
|
410 |
<property name="alignment"> |
|
411 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
412 |
</property> |
|
413 |
</widget> |
|
414 |
</item> |
|
415 |
<item row="1" column="1"> |
|
416 |
<layout class="QHBoxLayout" name="horizontalLayout_16"> |
|
417 |
<item> |
|
418 |
<widget class="QgsColorButton" name="btnTextColor"> |
|
419 |
<property name="sizePolicy"> |
|
420 |
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> |
|
421 |
<horstretch>0</horstretch> |
|
422 |
<verstretch>0</verstretch> |
|
423 |
</sizepolicy> |
|
424 |
</property> |
|
425 |
<property name="text"> |
|
426 |
<string/> |
|
427 |
</property> |
|
428 |
</widget> |
|
429 |
</item> |
|
430 |
<item> |
|
431 |
<spacer name="horizontalSpacer_7"> |
|
432 |
<property name="orientation"> |
|
433 |
<enum>Qt::Horizontal</enum> |
|
434 |
</property> |
|
435 |
<property name="sizeType"> |
|
436 |
<enum>QSizePolicy::Preferred</enum> |
|
437 |
</property> |
|
438 |
<property name="sizeHint" stdset="0"> |
|
439 |
<size> |
|
440 |
<width>142</width> |
|
441 |
<height>20</height> |
|
442 |
</size> |
|
443 |
</property> |
|
444 |
</spacer> |
|
445 |
</item> |
|
446 |
</layout> |
|
447 |
</item> |
|
448 |
<item row="2" column="0"> |
|
449 |
<widget class="QLabel" name="label_30"> |
|
450 |
<property name="text"> |
|
451 |
<string>Buffer</string> |
|
452 |
</property> |
|
453 |
<property name="alignment"> |
|
454 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
455 |
</property> |
|
456 |
</widget> |
|
457 |
</item> |
|
458 |
<item row="2" column="1"> |
|
459 |
<layout class="QHBoxLayout" name="horizontalLayout_17"> |
|
460 |
<item> |
|
461 |
<widget class="QCheckBox" name="chkBuffer"> |
|
462 |
<property name="sizePolicy"> |
|
463 |
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
|
464 |
<horstretch>0</horstretch> |
|
465 |
<verstretch>0</verstretch> |
|
466 |
</sizepolicy> |
|
467 |
</property> |
|
468 |
<property name="text"> |
|
469 |
<string/> |
|
470 |
</property> |
|
471 |
</widget> |
|
472 |
</item> |
|
473 |
<item> |
|
474 |
<widget class="QLabel" name="label_31"> |
|
475 |
<property name="text"> |
|
476 |
<string>Size</string> |
|
477 |
</property> |
|
478 |
<property name="alignment"> |
|
479 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
480 |
</property> |
|
481 |
</widget> |
|
482 |
</item> |
|
483 |
<item> |
|
484 |
<widget class="QDoubleSpinBox" name="spinBufferSize"> |
|
485 |
<property name="suffix"> |
|
486 |
<string> mm</string> |
|
487 |
</property> |
|
488 |
</widget> |
|
489 |
</item> |
|
490 |
<item> |
|
491 |
<widget class="QLabel" name="label_32"> |
|
492 |
<property name="text"> |
|
493 |
<string>Color</string> |
|
494 |
</property> |
|
495 |
<property name="alignment"> |
|
496 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
497 |
</property> |
|
498 |
</widget> |
|
499 |
</item> |
|
500 |
<item> |
|
501 |
<widget class="QgsColorButton" name="btnBufferColor"> |
|
502 |
<property name="sizePolicy"> |
|
503 |
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> |
|
504 |
<horstretch>0</horstretch> |
|
505 |
<verstretch>0</verstretch> |
|
506 |
</sizepolicy> |
|
507 |
</property> |
|
508 |
<property name="text"> |
|
509 |
<string>...</string> |
|
510 |
</property> |
|
511 |
</widget> |
|
512 |
</item> |
|
513 |
</layout> |
|
514 |
</item> |
|
515 |
<item row="4" column="0"> |
|
516 |
<widget class="QLabel" name="label_33"> |
|
517 |
<property name="sizePolicy"> |
|
518 |
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> |
|
519 |
<horstretch>0</horstretch> |
|
520 |
<verstretch>0</verstretch> |
|
521 |
</sizepolicy> |
|
522 |
</property> |
|
523 |
<property name="text"> |
|
524 |
<string>Sample</string> |
|
525 |
</property> |
|
526 |
<property name="alignment"> |
|
527 |
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|
528 |
</property> |
|
529 |
</widget> |
|
530 |
</item> |
|
531 |
<item row="4" column="1"> |
|
532 |
<widget class="QgsLabelPreview" name="lblFontPreview"> |
|
533 |
<property name="minimumSize"> |
|
534 |
<size> |
|
535 |
<width>30</width> |
|
536 |
<height>30</height> |
|
537 |
</size> |
|
538 |
</property> |
|
539 |
<property name="text"> |
|
540 |
<string>Lorem Ipsum</string> |
|
541 |
</property> |
|
542 |
<property name="alignment"> |
|
543 |
<set>Qt::AlignCenter</set> |
|
544 |
</property> |
|
545 |
</widget> |
|
546 |
</item> |
|
547 |
<item row="3" column="0" colspan="2"> |
|
548 |
<widget class="Line" name="line_4"> |
|
549 |
<property name="orientation"> |
|
550 |
<enum>Qt::Horizontal</enum> |
|
551 |
</property> |
|
552 |
</widget> |
|
553 |
</item> |
|
554 |
</layout> |
|
555 |
</widget> |
|
556 |
</item> |
|
557 |
<item row="0" column="1"> |
|
558 |
<widget class="QGroupBox" name="groupBox_7"> |
|
559 |
<property name="title"> |
|
560 |
<string>Priority</string> |
|
561 |
</property> |
|
562 |
<layout class="QHBoxLayout" name="horizontalLayout_18"> |
|
273 | 563 |
<item> |
274 |
<widget class="QRadioButton" name="radOrientationMap">
|
|
564 |
<widget class="QLabel" name="label_34">
|
|
275 | 565 |
<property name="text"> |
276 |
<string>map</string>
|
|
566 |
<string>Low</string>
|
|
277 | 567 |
</property> |
278 |
<property name="checked"> |
|
279 |
<bool>true</bool> |
|
568 |
</widget> |
|
569 |
</item> |
|
570 |
<item> |
|
571 |
<widget class="QSlider" name="sliderPriority"> |
|
572 |
<property name="maximum"> |
|
573 |
<number>10</number> |
|
280 | 574 |
</property> |
575 |
<property name="value"> |
|
576 |
<number>5</number> |
|
577 |
</property> |
|
578 |
<property name="orientation"> |
|
579 |
<enum>Qt::Horizontal</enum> |
|
580 |
</property> |
|
581 |
<property name="tickPosition"> |
|
582 |
<enum>QSlider::TicksBelow</enum> |
|
583 |
</property> |