[Qgis-developer] Shields for Labels

Tim Sutton lists at linfiniti.com
Tue Aug 9 15:52:42 EDT 2011


Hi

Thanks everyone for the feedback. @Marco ok thanks for your hints - I
will apply your suggestions to my branch tomorrow and then merge to
master. In the future if I have time I will look at using svg or
symbology ng for shields (or maybe someone else will beat me to that
:-) ).

Regards

Tim

On Tue, Aug 9, 2011 at 3:54 PM, Marco Hugentobler
<marco.hugentobler at sourcepole.ch> wrote:
> Hi Tim
>
> +1 for bringing the shield code into core. I agree with the comments about
> enhancements with marker symbols or scaled svg symbols. These would be great
> additions for the future.
>
> The scaling works for me as follows (It does not need the consideration of the
> raster compress factor, because we are not dealing with the oversized fonts):
>
> if ( drawShield )
>    {
>      painter->save();
>
>      painter->translate( QPointF( outPt.x(), outPt.y() ) );
>      painter->rotate( -label->getAlpha() * 180 / M_PI );
>      double scaledSize = lyr.vectorScaleFactor * shieldSize;
>      double yMultiLineOffset = ( multiLineList.size() - 1 - i ) *
> lyr.fontMetrics->height();
>      painter->translate( QPointF( 0, - lyr.fontMetrics->descent() -
> yMultiLineOffset ) );
>      QgsPoint rectPt = xform->transform( label->getX(), label->getY() );
>      QgsPoint rectPt2 = xform->transform( label->getX() + label->getWidth(),
> label->getY() + label->getHeight() );
>      QPointF origin( double( - scaledSize ), scaledSize + lyr.fontMetrics-
>>descent() );
>      QPointF corner( double( rectPt2.x()  - rectPt.x() + ( scaledSize * 2 )
> ), double( rectPt2.y() - rectPt.y() - scaledSize + lyr.fontMetrics->descent())
> );
>
>          if ( mShowingCandidates )
>          {
>        painter->setBrush( Qt::red );
>        painter->drawEllipse( origin, 3, 3 );
>        painter->setBrush( Qt::green );
>        painter->drawEllipse( corner, 3, 3 );
>          }
>      // draw the shield
>      QRectF rect( origin, corner );
>      painter->setPen( Qt::NoPen );
>      painter->setBrush( shieldColor );
>      painter->drawRoundedRect( rect, shieldCornerRounding,
> shieldCornerRounding );
>
>      painter->restore();
>    }
>
>
> Regards,
> Marco
>
>
> Am Montag, 8. August 2011, 17.46:08 schrieb Marco Hugentobler:
>> Hi Tim
>>
>> Cool, shields for labels are very usefull, both with rectangles or with svg
>> background (probably in future).
>> Rectangular shields are also well suited as a (computationally) fast
>> alternative to font buffers.
>>
>> I didn't yet look into the details of the code. From first tries of the
>> label- shield branch, it seems to me the shields currently don't appear
>> nicely in composer printouts. Probably it needs the consideration of the
>> output device resolution.
>>
>> Regards,
>> Marco
>>
>> Am Sonntag, 7. August 2011, 23.47:07 schrieb Tim Sutton:
>> > Hi Folks
>> >
>> > Is anyone else interested in being able to have shields for labels
>> > (e.g. to mark highways etc.). I've made an initial stab at it - you
>> > can see an example and git details in case you want to try it in the
>> > link below. Is there any interest in getting this into trunk? Maybe a
>> > better way of doing things? I thought of using SVG shields but I think
>> > it might be a performance killer if you have many labels and each
>> > needs scaling.
>> >
>> > http://linfiniti.com/2011/08/shield-labels-for-qgis/
>> >
>> > Regards
>> >
>> > Tim
>
>
> --
> Dr. Marco Hugentobler
> Sourcepole -  Linux & Open Source Solutions
> Churerstrasse 22, CH-8808 Pfäffikon SZ, Switzerland
> marco.hugentobler at sourcepole.ch http://www.sourcepole.ch
> Technical Advisor QGIS Project Steering Committee
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
Tim Sutton - QGIS Project Steering Committee Member (Release  Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
 * QGIS programming and support services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================


More information about the Qgis-developer mailing list