Bug report #11588

QgsMapSettings.DrawSelection doesn't work with QgsComposition

Added by SC SC about 5 years ago. Updated almost 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Python plugins
Affected QGIS version:2.6.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:wontfix
Crashes QGIS or corrupts data:No Copied to github as #:19847

Description

hi i need to print a composition on a pdf with map and evidence of selected features
before in qgis 2.2 with mapRenderer api this is normal but since qgis 2.4 it not works

i noticed that new api QgsMapSettings has flag DrawSelection for this but it doesn't work with QgsComposition
i put a code that i used with a vector layer that print always the pdf without selected feature with QgsMapSettings.DrawSelection setted on

from PyQt4.QtCore import *
from PyQt4.QtGui import *

mapRenderer = iface.mapCanvas().mapSettings()
mapRenderer.setFlag( QgsMapSettings.DrawSelection)

c = QgsComposition(mapRenderer)
c.setPlotStyle(QgsComposition.Print)

#mappa
x, y = 2, 36
w, h = 200,158
composerMap = QgsComposerMap(c, x,y,w,h)
c.addItem(composerMap)

c.exportAsPDF(QFileDialog.getSaveFileName(iface.mainWindow(), "Salva file",filter="(*.pdf)"))

History

#1 Updated by Nyall Dawson about 5 years ago

  • Resolution set to wontfix
  • Status changed from Open to Closed

Yes - this setting is overwritten by the composer map while rendering. It's not behavior which is possible to change via the python api.

#2 Updated by SC SC about 5 years ago

  • Status changed from Closed to Reopened

Nyall Dawson wrote:

Yes - this setting is overwritten by the composer map while rendering. It's not behavior which is possible to change via the python api.

why???

why qgscomposition take mapSettings if after not respect it?
why it's not possible make composition with selected features it very useful for indicate a specific position?

#3 Updated by Matthias Kuhn almost 5 years ago

  • Status changed from Reopened to Closed

Please install the Expressions+ plugin and use the isselected( layer ) method in the style.
It is much more powerful as it allows you to define an arbitrary style.

The composer does not respect transient properties like selections. You also wouldn't expect your text processor (oo writer/ms word) to print your selection, would you?

#12028

#4 Updated by SC SC almost 5 years ago

Matthias Kuhn wrote:

Please install the Expressions+ plugin and use the isselected( layer ) method in the style.
It is much more powerful as it allows you to define an arbitrary style.

The composer does not respect transient properties like selections. You also wouldn't expect your text processor (oo writer/ms word) to print your selection, would you?

#12028

i use python code and api, it was better for me to get a qgscomposition that respect mapSettings, many people preferred old system , print map is not print text

however for general application expression+ is very good , thank you

Also available in: Atom PDF