[Qgis-developer] Composer Management
Larry Shaffer
larrys at dakotacarto.com
Thu Feb 28 10:10:43 PST 2013
Hi,
On Thu, Feb 28, 2013 at 10:11 AM, Bernhard Ströbl
<bernhard.stroebl at jena.de>wrote:
> Hi Larry,
>
> Am 28.02.2013 17:38, schrieb Larry Shaffer:
>
>> Hi,
>>
>> On Thu, Feb 28, 2013 at 12:01 AM, Bernhard Ströbl
>> <bernhard.stroebl at jena.de <mailto:bernhard.stroebl at jena.**de<bernhard.stroebl at jena.de>>>
>> wrote:
>>
>> Hi Kelly,
>>
>> I am doing something similar for my company but I am developing it
>> for the next release, because master has
>> QgsComposition::__**loadFromTemplate method, which 1.8 has not.
>>
>> However to get a new printComposer you can use
>> self.iface.__**actionPrintComposer().trigger(**__)
>> which adds a new composer to the project's list of composers.
>>
>>
>> In master branch, and in the last week, the actionPrintComposer() (i.e.
>> QgisApp::createNewComposer) action will now present the user with a
>> dialog to help choose a unique composer title, before the composer is
>> created. Since iface.actionPrintComposer().**trigger() still appears to
>> be
>> the best means of programmatically creating a new composer, this
>> presents an issue.
>>
>
> hmm, my master dates from Febr. 21, have to update...
> Is this a needed feature? I mean any text processing software creates
> "document1" or "unknown1" if you hit the new document button
>
IMO, yes. With the text processing software you note, it creates the
"document 1" with the understanding that the user will eventually have to
save the file, thereby prompting the user to change the default name.
With composers there is no prompted saving; they are automatically saved
into the project with the default name. This causes the user to have to
find a means of changing the name later, e.g. in the Composer Manager, and
in the meantime they have no hint at what content "Composer #n" contains.
With a prompt, the user can define the name up front, using existing names
to build on (from editable combobox) and use the Manager later, only if
needed.
Again, we can add a preference in Options for turning it on/off (with a
default of on), but that would have to be checked and turned off
programmatically in scripts if there is no other means of generating a
blank composer.
>> There are a couple of possible solutions:
>>
>> * Expose Qgis::createNewComposer in iface (which returns pointer to new
>> composer). Maybe adding duplicateComposer, deleteComposer and
>> deletePrintComposers, as well. Makes the most sense to me. New PyQGIS
>> code would be different from 1.8.
>>
>
> +1
> the actionPrintComposer().trigger(**) thing is not so straightforward
>
>>
>> * Add a preference in Options for turning it on/off (e.g. [x] Prompt for
>> composer name), and maybe simple get/set methods to QgisApp and iface.
>> New PyQGIS code would require a couple of lines of additional code if
>> the prompt was not to be shown.
>>
>> * Use a different action in the GUI than actionPrintComposer(). Might
>> lead to some confusion, having semi-redundant actions. New PyQGIS code
>> remains identical to 1.8.
>>
>>
>> But AFAIK you can not load a template into it with 1.8
>>
>>
>> I think this is possible. QgsComposition has readXML and addItemsFromXML
>> exposed in 1.8 [0]. If you look at loadFromTemplate[1], the initial
>> routines are for clearing a composition's existing items (btw: I think
>> that is bad. IMO loading from a template should always be in a fresh
>> composer).
>>
>
> Not neccessarily, I sometimes happen to work on a composer (created from
> template) but I somehow screw things up and then it is nice to restart
> again without leaving the composer. This is the behavior of QGIS, so IMHO
> it is ok if loadFromTemplate behaves in the same manner.
>
Maybe a parameter option to the function, or a new function, and a new
action in the menu, e.g. New from Template, to accompany Load Template? I
think 'load' should always mean 'replace existing'. I envision a user
accidentally clearing all their work in the current composer, when they
thought they were getting a fresh composer based upon the template.
I don't think "template load replaces existing" is the behavior of QGIS at
the QMainWindow level, maybe with styles, etc. For example, when loading a
project template, the menu action is New Project from Template (there is no
load option). I think we need the distinction, and option, between new and
load with templates, especially when they are auto-saved, or users may lose
work.
Regards,
Larry
> Not a concern if you are starting with a fresh composer
>> anyway. After that, there is substitution replacement (not sure if
>> relevant to 1.8), reading of the XML doc, then adding the items, all of
>> which should be doable in Python, unless I am mistaken.
>>
>
> I did not fiddle with those 1.8 methods, but thinking about it it should
> even be possible to do substitution using PyQt methods, i.e.
> 1) read file
> 2) do substitutions
> 3) create the XMLDoc
> 4) load into composer
>
> I will check and report back
>
> Bernhard
>
>>
>> [0] http://qgis.org/api/1.8/**classQgsComposition.html<http://qgis.org/api/1.8/classQgsComposition.html>
>> [1]
>> https://github.com/qgis/**Quantum-GIS/blob/master/src/**
>> core/composer/qgscomposition.**cpp#L382<https://github.com/qgis/Quantum-GIS/blob/master/src/core/composer/qgscomposition.cpp#L382>
>>
>>
>> Regards,
>>
>> Larry
>>
>> Bernhard
>>
>> Am 28.02.2013 03:38, schrieb Kelly Thomas:
>>
>> Hello,
>>
>>
>> I am building a python plugin for QGIS 1.8 and am trying to
>> manipulate the map composers.
>>
>> The goal is to load a template, customise a few elements, and
>> then leave the composer window up for the user to modify / print
>> / etc.
>>
>> I know that current composers can be listed by calling
>> qgis.utils.iface.__**activeComposers().
>>
>> However I have been unable to create or destroy composer windows
>> without resorting to spoofing user input to the composer manager
>> dialog!
>>
>> Is there a technique by which I can add/remove composers
>> programmatically?
>>
>> Thanks,
>> Kelly Thomas
>> ______________________________**___________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> <mailto:Qgis-developer at lists.**osgeo.org<Qgis-developer at lists.osgeo.org>
>> >
>> http://lists.osgeo.org/__**mailman/listinfo/qgis-__**developer<http://lists.osgeo.org/__mailman/listinfo/qgis-__developer>
>> <http://lists.osgeo.org/**mailman/listinfo/qgis-**developer<http://lists.osgeo.org/mailman/listinfo/qgis-developer>
>> >
>>
>>
>> __________ Information from ESET Mail Security, version of virus
>> signature database 8058 (20130227) __________
>>
>> The message was checked by ESET Mail Security.
>> http://www.eset.com
>>
>>
>>
>>
>> __________ Information from ESET Mail Security, version of virus
>> signature database 8058 (20130227) __________
>>
>> The message was checked by ESET Mail Security.
>> http://www.eset.com
>>
>>
>> ______________________________**___________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org <mailto:Qgis-developer at lists.**
>> osgeo.org <Qgis-developer at lists.osgeo.org>>
>> http://lists.osgeo.org/__**mailman/listinfo/qgis-__**developer<http://lists.osgeo.org/__mailman/listinfo/qgis-__developer>
>> <http://lists.osgeo.org/**mailman/listinfo/qgis-**developer<http://lists.osgeo.org/mailman/listinfo/qgis-developer>
>> >
>>
>>
>>
>
>
> __________ Information from ESET Mail Security, version of virus signature
> database 8061 (20130228) __________
>
> The message was checked by ESET Mail Security.
> http://www.eset.com
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130228/35ddd9d8/attachment.html>
More information about the Qgis-developer
mailing list