[Qgis-developer] Custom composer items?

Chris Crook ccrook at linz.govt.nz
Mon Mar 1 13:00:15 EST 2010


Hi Marco

The thing that makes we think it might not be possible is the code in app/qgscomposer.cpp.  This looks to me like the main code for the composer, and if my understanding is correct, has hard coded the list of items (including QgsComposerScaleBar) in the QgsComposer constructor, and the read/write XMLfunctions.  So although I think I may be able to derive from the C++ class QgsComposerItem (and Python if it is exposed), I can't see how to include the new item in the interface, or in the project XML.  I think this would need some sort of registry, in the same way as other plugin items?  

But if I've missed something I'd really like to know what!

Cheers
Chris
________________________________________
From: Marco Hugentobler [marco at hugis.net]
Sent: 01 March 2010 21:09
To: qgis-developer at lists.osgeo.org
Cc: Chris Crook
Subject: Re: [Qgis-developer] Custom composer items?

Hi Chris

It is possible to derive new classes from QgsComposerItem (in C++ and Python).
You might look into qgscomposerscaleber.cpp/h as an example how to add scale
information.

Regards,
Marco


Am Sonntag, 28. Februar 2010 23.36:50 schrieb Chris Crook:
> Hi
>
> I'm wanting to add scale information for symbols to composer.  These are
>  arrow symbols representing vector fields, so I want to be able to show in
>  the composer generated page what the scale of the arrows is (ie how long
>  an arrow represents a 5cm offset at a point, or whatever).
>
> Logically this would be a custom composer item, but I cannot see any way to
>  create a custom item, either in C++ or in Python (my preference!), without
>  modifying the base composer classe(s).  Can anyone confirm this?
>
> A slightly less desirable approach would be to draw the scale information
>  onto the map item in composer.  This would constrain the placement - it
>  would be nicer to be able to place it arbitrarily as other widget items.
>
> In the main Qgis window I draw this scale information onto the map canvas
>  in response to the renderComplete signal, in the same way as the scale bar
>  or north arrow, but I don't think there is an equivalent event when the
>  composer map item is drawn?  So I can't use that approach to draw onto the
>  canvas...
>
> I think I may be able to draw the scale information by adding a custom map
>  layer.
>
> Can anyone suggest better approaches, or point me to something obvious I've
>  missed?
>
> Many thanks
>
> Chris
>
>
>
>
> ___________________________________________________________________________
> ___________________________
>
> This message contains information, which is confidential and may be subject
>  to legal privilege. If you are not the intended recipient, you must not
>  peruse, use, disseminate, distribute or copy this message. If you have
>  received this message in error, please notify us immediately (Phone 0800
>  665 463 or info at linz.govt.nz) and destroy the original message. LINZ
>  accepts no responsibility for changes to this email, or for any
>  attachments, after its transmission from LINZ.
>
> Thank you.
> ___________________________________________________________________________
> ___________________________
>

--
Dr. Marco Hugentobler
HUGIS - GIS programming and consulting
Webereistr. 66
CH-8134 Adliswil
marco at hugis.net
http://homepage.hispeed.ch/hugis/
Technical Advisor QGIS Project Steering Committee
______________________________________________________________________________________________________

This message contains information, which is confidential and may be subject to legal privilege. 
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.

Thank you.
______________________________________________________________________________________________________


More information about the Qgis-developer mailing list