qgis_label_buffers_patch.diff
python/core/qgslabel.sip (working copy) | ||
---|---|---|
30 | 30 |
YOffset, |
31 | 31 |
Angle, |
32 | 32 |
Alignment, |
33 |
BufferEnabled, |
|
33 |
BufferType, |
|
34 |
BufferArrowType, |
|
34 | 35 |
BufferSize, |
35 | 36 |
BufferColor, |
36 | 37 |
BufferBrush, |
... | ... | |
62 | 63 |
* \param classAttributes attributes to use for labeling |
63 | 64 |
* \note added in 1.2 |
64 | 65 |
*/ |
65 |
void renderLabel ( QgsRenderContext &renderContext, QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes=0); |
|
66 |
void renderLabel ( QgsRenderContext &renderContext, QgsFeature &feature, |
|
67 |
bool selected, QgsLabelAttributes *classAttributes=0); |
|
66 | 68 | |
67 | 69 |
/** Reads the renderer configuration from an XML file |
68 | 70 |
@param rnode the Dom node to read |
src/app/qgslabeldialog.cpp (working copy) | ||
---|---|---|
44 | 44 | |
45 | 45 |
connect( btnDefaultFont, SIGNAL( clicked() ), |
46 | 46 |
this, SLOT( changeFont() ) ); |
47 |
connect( pbnDefaultBufferColor_2, SIGNAL( clicked() ),
|
|
47 |
connect( pbnBufferColor, SIGNAL( clicked() ),
|
|
48 | 48 |
this, SLOT( changeBufferColor() ) ); |
49 | 49 |
connect( pbnDefaultFontColor, SIGNAL( clicked() ), |
50 | 50 |
this, SLOT( changeFontColor() ) ); |
... | ... | |
258 | 258 |
//set the state of the multiline enabled checkbox |
259 | 259 |
chkUseMultiline->setChecked( myLabelAttributes->multilineEnabled() ); |
260 | 260 |
//set the state of the buffer enabled checkbox |
261 |
chkUseBuffer->setChecked( myLabelAttributes->bufferEnabled() ); |
|
261 |
cboBufferType->setCurrentIndex( myLabelAttributes->bufferType() ); |
|
262 |
//cboBufferArrowType->setCurrentIndex( myLabelAttributes->bufferArrowType() ); |
|
262 | 263 | |
263 | 264 |
//NOTE: do we need this line too? TS |
264 | 265 |
spinBufferSize->setValue( myLabelAttributes->bufferSize() ); |
... | ... | |
366 | 367 |
{ |
367 | 368 |
myTypeInt = QgsLabelAttributes::MapUnits; |
368 | 369 |
} |
370 | ||
371 | ||
369 | 372 |
myLabelAttributes->setOffset( spinXOffset->value(), spinYOffset->value(), myTypeInt ); |
370 | 373 |
myLabelAttributes->setAutoAngle( spinAngle->value() == -1 ); |
371 | 374 |
myLabelAttributes->setAngle( spinAngle->value() ); |
... | ... | |
384 | 387 |
if ( radioOver->isChecked() ) myLabelAttributes->setAlignment( Qt::AlignCenter ); |
385 | 388 | |
386 | 389 |
myLabelAttributes->setMultilineEnabled( chkUseMultiline->isChecked() ); |
387 |
myLabelAttributes->setBufferEnabled( chkUseBuffer->isChecked() ); |
|
390 |
myLabelAttributes->setBufferType( cboBufferType->currentIndex() ); |
|
391 |
//myLabelAttributes->setBufferArrowType( cboBufferArrowType->currentIndex() ); |
|
388 | 392 |
myLabelAttributes->setBufferColor( mBufferColor ); |
389 | 393 |
myTypeInt = 0; |
390 | 394 |
if ( radioBufferUnitsPoints->isChecked() ) |
... | ... | |
395 | 399 |
{ |
396 | 400 |
myTypeInt = QgsLabelAttributes::MapUnits; |
397 | 401 |
} |
402 | ||
398 | 403 |
myLabelAttributes->setBufferSize( spinBufferSize->value(), myTypeInt ); |
399 | 404 |
//TODO - transparency attributes for buffers |
400 | 405 |
src/core/qgslabelattributes.cpp (working copy) | ||
---|---|---|
44 | 44 |
mAngleIsAuto( false ), |
45 | 45 |
mAlignment( 0 ), |
46 | 46 |
mAlignmentIsSet( false ), |
47 |
mBufferEnabledFlag( false ), |
|
48 | 47 |
mBufferSizeType( 0 ), |
49 | 48 |
mBufferSize( 0.0 ), |
50 | 49 |
mBufferSizeIsSet( false ), |
... | ... | |
288 | 287 |
} |
289 | 288 | |
290 | 289 |
/* Buffer */ |
290 |
/** @note since v1.4 this just tests to see if |
|
291 |
buffer type is font and returns true if it is */ |
|
291 | 292 |
bool QgsLabelAttributes::bufferEnabled() const |
292 | 293 |
{ |
293 |
return mBufferEnabledFlag;
|
|
294 |
return false; //FIXME!
|
|
294 | 295 |
} |
296 |
/** @note since v1.4 this just returns true if |
|
297 |
buffer type is font */ |
|
295 | 298 |
void QgsLabelAttributes::setBufferEnabled( bool useBufferFlag ) |
296 | 299 |
{ |
297 |
mBufferEnabledFlag = useBufferFlag;
|
|
300 |
return ; // FIXME!
|
|
298 | 301 |
} |
302 |
void QgsLabelAttributes::setBufferArrowType( int BufferArrowType ) |
|
303 |
{ |
|
304 |
mBufferArrowType = BufferArrowType; |
|
305 |
} |
|
306 |
int QgsLabelAttributes::bufferType() |
|
307 |
{ |
|
308 |
return mBufferType; |
|
309 |
} |
|
310 |
int QgsLabelAttributes::bufferArrowType() |
|
311 |
{ |
|
312 |
return mBufferArrowType; |
|
313 |
} |
|
314 |
void QgsLabelAttributes::setBufferType( int BufferType ) |
|
315 |
{ |
|
316 |
mBufferType = BufferType; |
|
317 |
} |
|
318 | ||
299 | 319 |
void QgsLabelAttributes::setBufferSize( double size, int type ) |
300 | 320 |
{ |
301 | 321 |
mBufferSizeType = type; |
src/core/qgslabel.cpp (working copy) | ||
---|---|---|
250 | 250 | |
251 | 251 |
int dx = 0; |
252 | 252 |
int dy = 0; |
253 |
int labeltype = -1; |
|
253 | 254 | |
254 | 255 |
value = fieldValue( Alignment, feature ); |
255 | 256 |
if ( value.isEmpty() ) |
... | ... | |
275 | 276 |
alignment |= Qt::AlignTop; |
276 | 277 |
else |
277 | 278 |
alignment |= Qt::AlignVCenter; |
279 | ||
280 |
labeltype = -1; // not set |
|
281 |
if ( value.contains( "plaintext" ) ) |
|
282 |
labeltype = 1; |
|
283 |
else if ( value.contains( "plainrect" ) ) |
|
284 |
labeltype = 2; |
|
285 |
else if ( value.contains( "plainroundrect" ) ) |
|
286 |
labeltype = 3; |
|
287 |
else if ( value.contains( "linerect" ) ) |
|
288 |
labeltype = 4; |
|
289 |
else if ( value.contains( "lineroundrect" ) ) |
|
290 |
labeltype = 5; |
|
291 |
else if ( value.contains( "arrowrect" ) ) |
|
292 |
labeltype = 6; |
|
293 |
else if ( value.contains( "arrowroundrect" ) ) |
|
294 |
labeltype = 7; |
|
278 | 295 |
} |
279 | 296 | |
280 | 297 |
if ( alignment & Qt::AlignLeft ) |
... | ... | |
352 | 369 |
// Work out a suitable position to put the label for the |
353 | 370 |
// feature. For multi-geometries, put the same label on each |
354 | 371 |
// part. |
355 |
if ( useOverridePoint ) |
|
372 |
std::vector<labelpoint> points; |
|
373 |
labelPoint( points, feature ); |
|
374 |
for ( uint i = 0; i < points.size(); ++i ) |
|
356 | 375 |
{ |
357 |
renderLabel( renderContext, overridePoint, text, font, pen, dx, dy, |
|
358 |
xoffset, yoffset, ang, width, height, alignment ); |
|
359 |
} |
|
360 |
else |
|
361 |
{ |
|
362 |
std::vector<labelpoint> points; |
|
363 |
labelPoint( points, feature ); |
|
364 |
for ( uint i = 0; i < points.size(); ++i ) |
|
365 |
{ |
|
376 |
if ( useOverridePoint ) { |
|
377 |
QgsPoint pointtmp01 = renderContext.mapToPixel().transform( points[i].p ); |
|
378 |
QgsPoint pointtmp02 = renderContext.mapToPixel().transform( overridePoint ); |
|
366 | 379 |
renderLabel( renderContext, points[i].p, text, font, pen, dx, dy, |
367 |
xoffset, yoffset, mLabelAttributes->angleIsAuto() ? points[i].angle : ang, width, height, alignment ); |
|
380 |
pointtmp02.x()-pointtmp01.x(), pointtmp01.y()-pointtmp02.y(), mLabelAttributes->angleIsAuto() ? points[i].angle : ang, width, height, alignment, labeltype ); |
|
381 |
} else { |
|
382 |
renderLabel( renderContext, points[i].p, text, font, pen, dx, dy, |
|
383 |
xoffset, yoffset, mLabelAttributes->angleIsAuto() ? points[i].angle : ang, width, height, alignment, labeltype ); |
|
368 | 384 |
} |
369 | 385 |
} |
370 | 386 |
} |
... | ... | |
375 | 391 |
int dx, int dy, |
376 | 392 |
double xoffset, double yoffset, |
377 | 393 |
double ang, |
378 |
int width, int height, int alignment ) |
|
394 |
int width, int height, int alignment, int labeltype )
|
|
379 | 395 |
{ |
380 | 396 |
QPainter *painter = renderContext.painter(); |
381 | 397 | |
... | ... | |
415 | 431 |
// |
416 | 432 |
// Draw a buffer behind the text if one is desired |
417 | 433 |
// |
418 |
if ( mLabelAttributes->bufferSizeIsSet() && mLabelAttributes->bufferEnabled() )
|
|
434 |
if ( mLabelAttributes->bufferSizeIsSet() && (mLabelAttributes->bufferType() != 0) )
|
|
419 | 435 |
{ |
420 | 436 |
double myBufferSize = mLabelAttributes->bufferSize() * 0.3527 * renderContext.scaleFactor() * renderContext.rasterScaleFactor(); |
421 | 437 |
QPen bufferPen; |
... | ... | |
439 | 455 |
bufferStepSize = 1 / renderContext.rasterScaleFactor(); |
440 | 456 |
} |
441 | 457 | |
442 |
for ( double i = dx - myBufferSize; i <= dx + myBufferSize; i += bufferStepSize ) |
|
443 |
{ |
|
444 |
for ( double j = dy - myBufferSize; j <= dy + myBufferSize; j += bufferStepSize ) |
|
445 |
{ |
|
446 |
if ( mLabelAttributes->multilineEnabled() ) |
|
447 |
painter->drawText( QRectF( i, j - height, width, height ), alignment, text ); |
|
448 |
else |
|
449 |
painter->drawText( QPointF( i, j ), text ); |
|
450 |
} |
|
451 |
} |
|
458 |
if (labeltype==-1) { |
|
459 |
labeltype = mLabelAttributes->bufferType(); |
|
460 |
} |
|
461 |
if (labeltype==2) { // plainrect |
|
462 |
int lxl = dx - myBufferSize; // label x left |
|
463 |
int lxr = dx + myBufferSize + width; // label x right |
|
464 |
int lyt = dy - myBufferSize - height; // label y top |
|
465 |
int lyb = dy + myBufferSize; // label y bottom |
|
466 |
QPainterPath rectPath; |
|
467 |
rectPath.moveTo( lxl, lyt ); |
|
468 |
rectPath.lineTo( lxr, lyt ); |
|
469 |
rectPath.lineTo( lxr, lyb ); |
|
470 |
rectPath.lineTo( lxl, lyb ); |
|
471 |
rectPath.closeSubpath(); |
|
472 |
QColor brushColor = mLabelAttributes->bufferColor(); |
|
473 |
brushColor.setAlpha( 50 ); |
|
474 |
QBrush symbolBrush = QBrush( brushColor ); |
|
475 |
painter->fillPath( rectPath, symbolBrush ); |
|
476 |
QColor frameColor = mLabelAttributes->color(); |
|
477 |
QPen framePen = QPen( QColor( frameColor ) ); |
|
478 |
framePen.setWidth( 2 ); |
|
479 |
painter->setPen( framePen ); |
|
480 |
painter->drawPath( rectPath ); |
|
481 |
} else if (labeltype==3) { // plainroundrect |
|
482 |
int lxl = dx - myBufferSize; // label x left |
|
483 |
int lxr = dx + myBufferSize + width; // label x right |
|
484 |
int lyt = dy - myBufferSize - height; // label y top |
|
485 |
int lyb = dy + myBufferSize; // label y bottom |
|
486 |
QPainterPath roundRectPath; |
|
487 |
roundRectPath.moveTo( lxl, lyt+5 ); |
|
488 |
roundRectPath.arcTo( lxl, lyt, 10.0, 10.0, 180.0, -90.0); |
|
489 |
roundRectPath.lineTo( lxr-5, lyt ); |
|
490 |
roundRectPath.arcTo( lxr-10, lyt, 10.0, 10.0, 90.0, -90.0); |
|
491 |
roundRectPath.lineTo( lxr, lyb-5 ); |
|
492 |
roundRectPath.arcTo( lxr-10, lyb-10, 10.0, 10.0, 0.0, -90.0); |
|
493 |
roundRectPath.lineTo( lxl+5, lyb ); |
|
494 |
roundRectPath.arcTo( lxl, lyb-10 , 10.0, 10.0, 270.0, -90.0); |
|
495 |
roundRectPath.closeSubpath(); |
|
496 |
QColor brushColor = mLabelAttributes->bufferColor(); |
|
497 |
brushColor.setAlpha( 50 ); |
|
498 |
QBrush symbolBrush = QBrush( brushColor ); |
|
499 |
painter->fillPath( roundRectPath, symbolBrush ); |
|
500 |
QColor frameColor = mLabelAttributes->color(); |
|
501 |
QPen framePen = QPen( QColor( frameColor ) ); |
|
502 |
framePen.setWidth( 2 ); |
|
503 |
painter->setPen( framePen ); |
|
504 |
painter->drawPath( roundRectPath ); |
|
505 |
} else if (labeltype==4) { // linerect |
|
506 |
int lxl = dx - myBufferSize; // label x left |
|
507 |
int lxr = dx + myBufferSize + width; // label x right |
|
508 |
int lyt = dy - myBufferSize - height; // label y top |
|
509 |
int lyb = dy + myBufferSize; // label y bottom |
|
510 |
bool bNeedArrow = !( (lxl<=0-xoffset) and (0-xoffset<=lxr) and (lyt<=0+yoffset) and (0+yoffset<=lyb) ); |
|
511 |
QPainterPath rectPath; |
|
512 |
rectPath.moveTo( lxl, lyt ); |
|
513 |
rectPath.lineTo( lxr, lyt ); |
|
514 |
rectPath.lineTo( lxr, lyb ); |
|
515 |
rectPath.lineTo( lxl, lyb ); |
|
516 |
rectPath.closeSubpath(); |
|
517 |
QColor brushColor = mLabelAttributes->bufferColor(); |
|
518 |
brushColor.setAlpha( 50 ); |
|
519 |
QBrush symbolBrush = QBrush( brushColor ); |
|
520 |
painter->fillPath( rectPath, symbolBrush ); |
|
521 |
QColor frameColor = mLabelAttributes->color(); |
|
522 |
QPen framePen = QPen( QColor( frameColor ) ); |
|
523 |
framePen.setWidth( 2 ); |
|
524 |
painter->setPen( framePen ); |
|
525 |
painter->drawPath( rectPath ); |
|
526 |
if (bNeedArrow) { |
|
527 |
int llx; |
|
528 |
int lly; |
|
529 |
if (abs(0-xoffset-lxl)>(abs(0-xoffset-lxr))) { |
|
530 |
llx = lxr; |
|
531 |
} else { |
|
532 |
llx = lxl; |
|
533 |
} |
|
534 |
if (abs(0+yoffset-lyt)>(abs(0+yoffset-lyb))) { |
|
535 |
lly = lyb; |
|
536 |
} else { |
|
537 |
lly = lyt; |
|
538 |
} |
|
539 |
painter->drawLine( 0-xoffset,0+yoffset, llx,lly ); |
|
540 |
//painter->drawRect( -5,-5, 10,10 ); |
|
541 |
} |
|
542 |
} else if (labeltype==5) { // lineroundrect |
|
543 |
int lxl = dx - myBufferSize; // label x left |
|
544 |
int lxr = dx + myBufferSize + width; // label x right |
|
545 |
int lyt = dy - myBufferSize - height; // label y top |
|
546 |
int lyb = dy + myBufferSize; // label y bottom |
|
547 |
bool bNeedArrow = !( (lxl<=0-xoffset) and (0-xoffset<=lxr) and (lyt<=0+yoffset) and (0+yoffset<=lyb) ); |
|
548 |
QPainterPath roundRectPath; |
|
549 |
roundRectPath.moveTo( lxl, lyt+5 ); |
|
550 |
roundRectPath.arcTo( lxl, lyt, 10.0, 10.0, 180.0, -90.0); |
|
551 |
roundRectPath.lineTo( lxr-5, lyt ); |
|
552 |
roundRectPath.arcTo( lxr-10, lyt, 10.0, 10.0, 90.0, -90.0); |
|
553 |
roundRectPath.lineTo( lxr, lyb-5 ); |
|
554 |
roundRectPath.arcTo( lxr-10, lyb-10, 10.0, 10.0, 0.0, -90.0); |
|
555 |
roundRectPath.lineTo( lxl+5, lyb ); |
|
556 |
roundRectPath.arcTo( lxl, lyb-10 , 10.0, 10.0, 270.0, -90.0); |
|
557 |
roundRectPath.closeSubpath(); |
|
558 |
QColor brushColor = mLabelAttributes->bufferColor(); |
|
559 |
brushColor.setAlpha( 50 ); |
|
560 |
QBrush symbolBrush = QBrush( brushColor ); |
|
561 |
painter->fillPath( roundRectPath, symbolBrush ); |
|
562 |
QColor frameColor = mLabelAttributes->color(); |
|
563 |
QPen framePen = QPen( QColor( frameColor ) ); |
|
564 |
framePen.setWidth( 2 ); |
|
565 |
painter->setPen( framePen ); |
|
566 |
painter->drawPath( roundRectPath ); |
|
567 |
if (bNeedArrow) { |
|
568 |
int llx; |
|
569 |
int lly; |
|
570 |
if (abs(0-xoffset-lxl)>(abs(0-xoffset-lxr))) { |
|
571 |
llx = lxr-2; |
|
572 |
} else { |
|
573 |
llx = lxl+2; |
|
574 |
} |
|
575 |
if (abs(0+yoffset-lyt)>(abs(0+yoffset-lyb))) { |
|
576 |
lly = lyb-2; |
|
577 |
} else { |
|
578 |
lly = lyt+2; |
|
579 |
} |
|
580 |
painter->drawLine( 0-xoffset,0+yoffset, llx,lly ); |
|
581 |
//painter->drawRect( -5,-5, 10,10 ); |
|
582 |
} |
|
583 |
} else if (labeltype==6) { // arrowrect (not ready yet) |
|
584 |
int lxl = dx - myBufferSize; // label x left |
|
585 |
int lxr = dx + myBufferSize + width; // label x right |
|
586 |
int lyt = dy - myBufferSize - height; // label y top |
|
587 |
int lyb = dy + myBufferSize; // label y bottom |
|
588 |
bool bNeedArrow = !( (lxl<=0-xoffset) and (0-xoffset<=lxr) and (lyt<=0+yoffset) and (0+yoffset<=lyb) ); |
|
589 |
QPainterPath rectPath; |
|
590 |
rectPath.moveTo( lxl, lyt ); |
|
591 |
rectPath.lineTo( lxr, lyt ); |
|
592 |
rectPath.lineTo( lxr, lyb ); |
|
593 |
rectPath.lineTo( lxl, lyb ); |
|
594 |
rectPath.closeSubpath(); |
|
595 |
QColor brushColor = mLabelAttributes->bufferColor(); |
|
596 |
brushColor.setAlpha( 50 ); |
|
597 |
QBrush symbolBrush = QBrush( brushColor ); |
|
598 |
painter->fillPath( rectPath, symbolBrush ); |
|
599 |
QColor frameColor = mLabelAttributes->color(); |
|
600 |
QPen framePen = QPen( QColor( frameColor ) ); |
|
601 |
framePen.setWidth( 2 ); |
|
602 |
painter->setPen( framePen ); |
|
603 |
painter->drawPath( rectPath ); |
|
604 |
if (bNeedArrow) { |
|
605 |
int llx; |
|
606 |
int lly; |
|
607 |
if (abs(0-xoffset-lxl)>(abs(0-xoffset-lxr))) { |
|
608 |
llx = lxr; |
|
609 |
} else { |
|
610 |
llx = lxl; |
|
611 |
} |
|
612 |
if (abs(0+yoffset-lyt)>(abs(0+yoffset-lyb))) { |
|
613 |
lly = lyb; |
|
614 |
} else { |
|
615 |
lly = lyt; |
|
616 |
} |
|
617 |
painter->drawLine( 0-xoffset,0+yoffset, llx,lly ); |
|
618 |
//painter->drawRect( -5,-5, 10,10 ); |
|
619 |
} |
|
620 |
} else if (labeltype==7) { // arrowroundrect (not ready yet) |
|
621 |
int lxl = dx - myBufferSize; // label x left |
|
622 |
int lxr = dx + myBufferSize + width; // label x right |
|
623 |
int lyt = dy - myBufferSize - height; // label y top |
|
624 |
int lyb = dy + myBufferSize; // label y bottom |
|
625 |
bool bNeedArrow = !( (lxl<=0-xoffset) and (0-xoffset<=lxr) and (lyt<=0+yoffset) and (0+yoffset<=lyb) ); |
|
626 |
QPainterPath roundRectPath; |
|
627 |
roundRectPath.moveTo( lxl, lyt+5 ); |
|
628 |
roundRectPath.arcTo( lxl, lyt, 10.0, 10.0, 180.0, -90.0); |
|
629 |
roundRectPath.lineTo( lxr-5, lyt ); |
|
630 |
roundRectPath.arcTo( lxr-10, lyt, 10.0, 10.0, 90.0, -90.0); |
|
631 |
roundRectPath.lineTo( lxr, lyb-5 ); |
|
632 |
roundRectPath.arcTo( lxr-10, lyb-10, 10.0, 10.0, 0.0, -90.0); |
|
633 |
roundRectPath.lineTo( lxl+5, lyb ); |
|
634 |
roundRectPath.arcTo( lxl, lyb-10 , 10.0, 10.0, 270.0, -90.0); |
|
635 |
roundRectPath.closeSubpath(); |
|
636 |
QColor brushColor = mLabelAttributes->bufferColor(); |
|
637 |
brushColor.setAlpha( 50 ); |
|
638 |
QBrush symbolBrush = QBrush( brushColor ); |
|
639 |
painter->fillPath( roundRectPath, symbolBrush ); |
|
640 |
QColor frameColor = mLabelAttributes->color(); |
|
641 |
QPen framePen = QPen( QColor( frameColor ) ); |
|
642 |
framePen.setWidth( 2 ); |
|
643 |
painter->setPen( framePen ); |
|
644 |
painter->drawPath( roundRectPath ); |
|
645 |
if (bNeedArrow) { |
|
646 |
int llx; |
|
647 |
int lly; |
|
648 |
if (abs(0-xoffset-lxl)>(abs(0-xoffset-lxr))) { |
|
649 |
llx = lxr-2; |
|
650 |
} else { |
|
651 |
llx = lxl+2; |
|
652 |
} |
|
653 |
if (abs(0+yoffset-lyt)>(abs(0+yoffset-lyb))) { |
|
654 |
lly = lyb-2; |
|
655 |
} else { |
|
656 |
lly = lyt+2; |
|
657 |
} |
|
658 |
painter->drawLine( 0-xoffset,0+yoffset, llx,lly ); |
|
659 |
//painter->drawRect( -5,-5, 10,10 ); |
|
660 |
} |
|
661 |
} else { // plaintext |
|
662 |
for ( double i = dx - myBufferSize; i <= dx + myBufferSize; i += bufferStepSize ) |
|
663 |
{ |
|
664 |
for ( double j = dy - myBufferSize; j <= dy + myBufferSize; j += bufferStepSize ) |
|
665 |
{ |
|
666 |
if ( mLabelAttributes->multilineEnabled() ) |
|
667 |
painter->drawText( QRectF( i, j - height, width, height ), alignment, text ); |
|
668 |
else |
|
669 |
painter->drawText( QPointF( i, j ), text ); |
|
670 |
} |
|
671 |
} |
|
672 |
}; |
|
452 | 673 |
} |
453 | ||
454 | 674 |
painter->setPen( pen ); |
455 | 675 |
if ( mLabelAttributes->multilineEnabled() ) |
456 | 676 |
painter->drawText( dx, dy - height, width, height, alignment, text ); |
... | ... | |
975 | 1195 |
{ |
976 | 1196 |
el = scratchNode.toElement(); |
977 | 1197 | |
978 |
mLabelAttributes->setBufferEnabled(( bool )el.attribute( "on", "0" ).toInt() );
|
|
979 |
readLabelField( el, BufferEnabled );
|
|
1198 |
mLabelAttributes->setBufferType(( int )el.attribute( "on", "0" ).toInt() );
|
|
1199 |
readLabelField( el, BufferType );
|
|
980 | 1200 |
} |
981 | 1201 | |
982 | 1202 |
scratchNode = node.namedItem( "multilineenabled" ); |
... | ... | |
1272 | 1492 | |
1273 | 1493 |
// buffer enabled |
1274 | 1494 |
QDomElement bufferenabled = document.createElement( "bufferenabled" ); |
1275 |
if ( mLabelAttributes->bufferEnabled() )
|
|
1495 |
if ( mLabelAttributes->bufferType() != 0 )
|
|
1276 | 1496 |
{ |
1277 |
bufferenabled.setAttribute( "on", mLabelAttributes->bufferEnabled() );
|
|
1278 |
if ( mLabelFieldIdx[BufferEnabled] != -1 )
|
|
1497 |
bufferenabled.setAttribute( "on", mLabelAttributes->bufferType() );
|
|
1498 |
if ( mLabelFieldIdx[BufferType] != 0 )
|
|
1279 | 1499 |
{ |
1280 |
bufferenabled.setAttribute( "fieldname", labelField( BufferEnabled ) );
|
|
1500 |
bufferenabled.setAttribute( "fieldname", labelField( BufferType ) );
|
|
1281 | 1501 |
} |
1282 | 1502 |
else |
1283 | 1503 |
{ |
src/core/qgslabel.h (working copy) | ||
---|---|---|
73 | 73 |
YOffset, |
74 | 74 |
Angle, |
75 | 75 |
Alignment, |
76 |
BufferEnabled, |
|
76 |
BufferType, |
|
77 |
BufferArrowType, |
|
77 | 78 |
BufferSize, |
78 | 79 |
BufferColor, |
79 | 80 |
BufferBrush, |
... | ... | |
113 | 114 |
* \param sizeScale global scale factor for size in pixels, labels in map units are not scaled |
114 | 115 |
* \note added in 1.2 |
115 | 116 |
*/ |
116 |
void renderLabel( QgsRenderContext &renderContext, QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes = 0 ); |
|
117 |
void renderLabel( QgsRenderContext &renderContext, |
|
118 |
QgsFeature &feature, |
|
119 |
bool selected, |
|
120 |
QgsLabelAttributes *classAttributes = 0 ); |
|
117 | 121 | |
118 | 122 |
/** Reads the renderer configuration from an XML file |
119 | 123 |
@param rnode the Dom node to read |
... | ... | |
181 | 185 |
int dx, int dy, |
182 | 186 |
double xoffset, double yoffset, |
183 | 187 |
double ang, |
184 |
int width, int height, int alignment ); |
|
188 |
int width, int height, int alignment, int labeltype );
|
|
185 | 189 | |
186 | 190 |
bool readLabelField( QDomElement &el, int attr, QString prefix ); |
187 | 191 |
src/core/qgslabelattributes.h (working copy) | ||
---|---|---|
149 | 149 |
int alignment( void ) const; |
150 | 150 | |
151 | 151 |
/* Buffer */ |
152 |
/** @note since v1.4 this just tests to see if |
|
153 |
buffer type is font and returns true if it is */ |
|
152 | 154 |
bool bufferEnabled() const; |
155 |
/** @note since v1.4 this just returns true if |
|
156 |
buffer type is font */ |
|
153 | 157 |
void setBufferEnabled( bool useBufferFlag ); |
158 |
void setBufferType( int BufferType ); |
|
159 |
void setBufferArrowType( int BufferArrowType ); |
|
160 |
int bufferType(); |
|
161 |
int bufferArrowType(); |
|
154 | 162 |
void setBufferSize( double size, int type ); |
155 | 163 |
bool bufferSizeIsSet( void ) const; |
156 | 164 |
int bufferSizeType( void ) const; |
... | ... | |
217 | 225 |
bool mAlignmentIsSet; |
218 | 226 | |
219 | 227 |
/** Buffer enablement */ |
220 |
bool mBufferEnabledFlag; |
|
228 |
int mBufferType; |
|
229 |
int mBufferArrowType; |
|
221 | 230 |
/** Buffer size, size type */ |
222 | 231 |
int mBufferSizeType; |
223 | 232 |
double mBufferSize; |
src/ui/qgslabeldialogbase.ui (working copy) | ||
---|---|---|
6 | 6 |
<rect> |
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 |
<width>642</width>
|
|
10 |
<height>516</height>
|
|
9 |
<width>756</width>
|
|
10 |
<height>567</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="sizePolicy"> |
... | ... | |
32 | 32 |
<property name="geometry"> |
33 | 33 |
<rect> |
34 | 34 |
<x>0</x> |
35 |
<y>-990</y>
|
|
36 |
<width>619</width>
|
|
37 |
<height>1440</height>
|
|
35 |
<y>0</y> |
|
36 |
<width>733</width>
|
|
37 |
<height>1551</height>
|
|
38 | 38 |
</rect> |
39 | 39 |
</property> |
40 |
<layout class="QGridLayout" name="gridLayout"> |
|
40 |
<layout class="QGridLayout" name="gridLayout_8">
|
|
41 | 41 |
<item row="0" column="0"> |
42 | 42 |
<layout class="QGridLayout"> |
43 | 43 |
<item row="0" column="0"> |
... | ... | |
45 | 45 |
<property name="title"> |
46 | 46 |
<string>Basic label options</string> |
47 | 47 |
</property> |
48 |
<layout class="QGridLayout" name="gridLayout_8">
|
|
48 |
<layout class="QGridLayout" name="gridLayout"> |
|
49 | 49 |
<item row="0" column="0"> |
50 | 50 |
<widget class="QLabel" name="textLabel5"> |
51 | 51 |
<property name="text"> |
... | ... | |
56 | 56 |
</property> |
57 | 57 |
</widget> |
58 | 58 |
</item> |
59 |
<item row="0" column="2">
|
|
59 |
<item row="0" column="1">
|
|
60 | 60 |
<widget class="QComboBox" name="cboLabelField"> |
61 | 61 |
<property name="sizePolicy"> |
62 | 62 |
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> |
... | ... | |
76 | 76 |
</property> |
77 | 77 |
</widget> |
78 | 78 |
</item> |
79 |
<item row="1" column="2">
|
|
79 |
<item row="1" column="1">
|
|
80 | 80 |
<widget class="QLineEdit" name="leDefaultLabel"> |
81 | 81 |
<property name="sizePolicy"> |
82 | 82 |
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> |
... | ... | |
100 | 100 |
</widget> |
101 | 101 |
</item> |
102 | 102 |
<item row="2" column="1"> |
103 |
<widget class="QLabel" name="textLabel5_2_2_3_2"> |
|
104 |
<property name="text"> |
|
105 |
<string>Font size</string> |
|
106 |
</property> |
|
107 |
<property name="alignment"> |
|
108 |
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> |
|
109 |
</property> |
|
110 |
<property name="buddy"> |
|
111 |
<cstring>spinFontSize</cstring> |
|
112 |
</property> |
|
113 |
</widget> |
|
103 |
<layout class="QHBoxLayout" name="horizontalLayout_4"> |
|
104 |
<item> |
|
105 |
<widget class="QLabel" name="textLabel5_2_2_3_2"> |
|
106 |
<property name="text"> |
|
107 |
<string>Font size</string> |
|
108 |
</property> |
|
109 |
<property name="alignment"> |
|
110 |
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> |
|
111 |
</property> |
|
112 |
<property name="buddy"> |
|
113 |
<cstring>spinFontSize</cstring> |
|
114 |
</property> |
|
115 |
</widget> |
|
116 |
</item> |
|
117 |
<item> |
|
118 |
<widget class="QDoubleSpinBox" name="spinFontSize"> |
|
119 |
<property name="sizePolicy"> |
|
120 |
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
|
121 |
<horstretch>0</horstretch> |
|
122 |
<verstretch>0</verstretch> |
|
123 |
</sizepolicy> |
|
124 |
</property> |
|
125 |
<property name="minimumSize"> |
|
126 |
<size> |
|
127 |
<width>50</width> |
|
128 |
<height>0</height> |
|
129 |
</size> |
|
130 |
</property> |
|
131 |
<property name="decimals"> |
|
132 |
<number>6</number> |
|
133 |
</property> |
|
134 |
<property name="maximum"> |
|
135 |
<double>1000000.000000000000000</double> |
|
136 |
</property> |
|
137 |
<property name="value"> |
|
138 |
<double>0.000000000000000</double> |
|
139 |
</property> |
|
140 |
</widget> |
|
141 |
</item> |
|
142 |
</layout> |
|
114 | 143 |
</item> |
115 |
<item row="2" column="2"> |
|
116 |
<widget class="QDoubleSpinBox" name="spinFontSize"> |
|
117 |
<property name="sizePolicy"> |
|
118 |
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
|
119 |
<horstretch>0</horstretch> |
|
120 |
<verstretch>0</verstretch> |
|
121 |
</sizepolicy> |
|
122 |
</property> |
|
123 |
<property name="minimumSize"> |
|
124 |
<size> |
|
125 |
<width>50</width> |
|
126 |
<height>0</height> |
|
127 |
</size> |
|
128 |
</property> |
|
129 |
<property name="decimals"> |
|
130 |
<number>6</number> |
|
131 |
</property> |
|
132 |
<property name="maximum"> |
|
133 |
<double>1000000.000000000000000</double> |
|
134 |
</property> |
|
135 |
<property name="value"> |
|
136 |
<double>0.000000000000000</double> |
|
137 |
</property> |
|
138 |
</widget> |
|
139 |
</item> |
|
140 | 144 |
<item row="3" column="0"> |
141 | 145 |
<widget class="QPushButton" name="pbnDefaultFontColor"> |
142 | 146 |
<property name="sizePolicy"> |
... | ... | |
151 | 155 |
</widget> |
152 | 156 |
</item> |
153 | 157 |
<item row="3" column="1"> |
154 |
<widget class="QLabel" name="textLabel1_2_2_2_2_2"> |
|
155 |
<property name="text"> |
|
156 |
<string>Angle (deg)</string> |
|
157 |
</property> |
|
158 |
<property name="buddy"> |
|
159 |
<cstring>spinAngle</cstring> |
|
160 |
</property> |
|
161 |
</widget> |
|
158 |
<layout class="QHBoxLayout" name="horizontalLayout_3"> |
|
159 |
<item> |
|
160 |
<widget class="QLabel" name="textLabel1_2_2_2_2_2"> |
|
161 |
<property name="text"> |
|
162 |
<string>Angle (deg)</string> |
|
163 |
</property> |
|
164 |
<property name="buddy"> |
|
165 |
<cstring>spinAngle</cstring> |
|
166 |
</property> |
|
167 |
</widget> |
|
168 |
</item> |
|
169 |
<item> |
|
170 |
<widget class="QSpinBox" name="spinAngle"> |
|
171 |
<property name="suffix"> |
|
172 |
<string>°</string> |
|
173 |
</property> |
|
174 |
<property name="maximum"> |
|
175 |
<number>360</number> |
|
176 |
</property> |
|
177 |
<property name="value"> |
|
178 |
<number>0</number> |
|
179 |
</property> |
|
180 |
</widget> |
|
181 |
</item> |
|
182 |
</layout> |
|
162 | 183 |
</item> |
163 |
<item row="3" column="2"> |
|
164 |
<widget class="QSpinBox" name="spinAngle"> |
|
165 |
<property name="suffix"> |
|
166 |
<string>°</string> |
|
167 |
</property> |
|
168 |
<property name="maximum"> |
|
169 |
<number>360</number> |
|
170 |
</property> |
|
171 |
<property name="value"> |
|
172 |
<number>0</number> |
|
173 |
</property> |
|
174 |
</widget> |
|
175 |
</item> |
|
176 | 184 |
<item row="4" column="0"> |
177 | 185 |
<widget class="QCheckBox" name="chkUseMultiline"> |
178 | 186 |
<property name="text"> |
... | ... | |
189 | 197 |
</layout> |
190 | 198 |
</item> |
191 | 199 |
<item row="1" column="0"> |
200 |
<widget class="QGroupBox" name="groupBox_9"> |
|
201 |
<property name="title"> |
|
202 |
<string>Buffer</string> |
|
203 |
</property> |
|
204 |
<layout class="QGridLayout" name="gridLayout_11"> |
|
205 |
<item row="0" column="0"> |
|
206 |
<widget class="QLabel" name="label_2"> |
|
207 |
<property name="text"> |
|
208 |
<string>Type</string> |
|
209 |
</property> |
|
210 |
</widget> |
|
211 |
</item> |
|
212 |
<item row="0" column="1"> |
|
213 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
214 |
<item> |
|
215 |
<widget class="QComboBox" name="cboBufferType"> |
|
216 |
<item> |
|
217 |
<property name="text"> |
|
218 |
<string>None</string> |
|
219 |
</property> |
|
220 |
</item> |
|
221 |
<item> |
|
222 |
<property name="text"> |
|
223 |
<string>Text buffer</string> |
|
224 |
</property> |
|
225 |
</item> |
|
226 |
<item> |
|
227 |
<property name="text"> |
|
228 |
<string>Plain rectangle</string> |
|
229 |
</property> |
|
230 |
</item> |
|
231 |
<item> |
|
232 |
<property name="text"> |
|
233 |
<string>Rounded rectangle</string> |
|
234 |
</property> |
|
235 |
</item> |
|
236 |
<item> |
|
237 |
<property name="text"> |
|
238 |
<string>Plain rect with arrow</string> |
|
239 |
</property> |
|
240 |
</item> |
|
241 |
<item> |
|
242 |
<property name="text"> |
|
243 |
<string>Rounded rect with arrow</string> |
|
244 |
</property> |
|
245 |
</item> |
|
246 |
</widget> |
|
247 |
</item> |
|
248 |
<item> |
|
249 |
<widget class="QToolButton" name="pbnBufferColor"> |
|
250 |
<property name="text"> |
|
251 |
<string>Color</string> |
|
252 |
</property> |
|
253 |
</widget> |
|
254 |
</item> |
|
255 |
</layout> |
|
256 |
</item> |
|
257 |
<item row="1" column="0"> |
|
258 |
<widget class="QLabel" name="textLabel4_3_2_7"> |
|
259 |
<property name="text"> |
|
260 |
<string>Buffer size</string> |
|
261 |
</property> |
|
262 |
</widget> |
|
263 |
</item> |
|
264 |
<item row="1" column="1"> |
|
265 |
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
|
266 |
<item> |
|
267 |
<widget class="QDoubleSpinBox" name="spinBufferSize_2"/> |
|
268 |
</item> |
|
269 |
<item> |
|
270 |
<widget class="QCheckBox" name="chkBufferUnitsMap"> |
|
271 |
<property name="text"> |
|
272 |
<string>Map units</string> |
|
273 |
</property> |
|
274 |
</widget> |
|
275 |
</item> |
|
276 |
</layout> |
|
277 |
</item> |
|
278 |
</layout> |
|
279 |
</widget> |
|
280 |
</item> |
|
281 |
<item row="2" column="0"> |
|
192 | 282 |
<widget class="QGroupBox" name="groupBox_2"> |
193 | 283 |
<property name="title"> |
194 | 284 |
<string>Placement</string> |
... | ... | |
350 | 440 |
</layout> |
351 | 441 |
</widget> |
352 | 442 |
</item> |
353 |
<item row="10" column="0">
|
|
443 |
<item row="5" column="0">
|
|
354 | 444 |
<widget class="QGroupBox" name="groupBox_4"> |
355 | 445 |
<property name="title"> |
356 | 446 |
<string>Buffer size units</string> |
... | ... | |
441 | 531 |
</layout> |
442 | 532 |
</widget> |
443 | 533 |
</item> |
444 |
<item row="11" column="0">
|
|
534 |
<item row="6" column="0">
|
|
445 | 535 |
<widget class="QGroupBox" name="buttonGroup10"> |
446 | 536 |
<property name="title"> |
447 | 537 |
<string>Offset units</string> |
... | ... | |
492 | 582 |
</layout> |
493 | 583 |
</widget> |
494 | 584 |
</item> |
495 |
<item row="12" column="0">
|
|
585 |
<item row="7" column="0">
|
|
496 | 586 |
<widget class="QGroupBox" name="groupBox_5"> |
497 | 587 |
<property name="title"> |
498 | 588 |
<string>Data defined placement</string> |
... | ... | |
533 | 623 |
</layout> |
534 | 624 |
</widget> |
535 | 625 |
</item> |
536 |
<item row="13" column="0">
|
|
626 |
<item row="8" column="0">
|
|
537 | 627 |
<widget class="QGroupBox" name="groupBox"> |
538 | 628 |
<property name="title"> |
539 | 629 |
<string>Data defined properties</string> |
... | ... | |
701 | 791 |
</layout> |
702 | 792 |
</widget> |
703 | 793 |
</item> |
704 |
<item row="14" column="0">
|
|
794 |
<item row="9" column="0">
|
|
705 | 795 |
<widget class="QGroupBox" name="groupBox_6"> |
706 | 796 |
<property name="title"> |
707 | 797 |
<string>Data defined buffer</string> |
... | ... | |
761 | 851 |
</layout> |
762 | 852 |
</widget> |
763 | 853 |
</item> |
764 |
<item row="15" column="0">
|
|
854 |
<item row="10" column="0">
|
|
765 | 855 |
<widget class="QGroupBox" name="groupBox_7"> |
766 | 856 |
<property name="title"> |
767 | 857 |
<string>Data defined position</string> |
... | ... | |
881 | 971 |
<tabstop>pbnDefaultFontColor</tabstop> |
882 | 972 |
<tabstop>spinAngle</tabstop> |
883 | 973 |
<tabstop>chkUseMultiline</tabstop> |
974 |
<tabstop>cboBufferType</tabstop> |
|
975 |
<tabstop>pbnBufferColor</tabstop> |
|
976 |
<tabstop>spinBufferSize_2</tabstop> |
|
977 |
<tabstop>chkBufferUnitsMap</tabstop> |
|
884 | 978 |
<tabstop>radioAboveLeft</tabstop> |
885 | 979 |
<tabstop>radioAbove</tabstop> |
886 | 980 |
<tabstop>radioAboveRight</tabstop> |