mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Implement $map variable, which returns the current composer map item id where the map is being drawn, or 'canvas' if the map is being drawn in the main QGIS window. Partly implements #9288.
This commit is contained in:
parent
9a58828906
commit
c45bf504e7
16
resources/function_help/$map
Normal file
16
resources/function_help/$map
Normal file
@ -0,0 +1,16 @@
|
||||
<h3>$map function</h3>
|
||||
Returns the id of the current map item if the map is being drawn in a composition, or "canvas" if the map is being
|
||||
drawn within the main QGIS window.
|
||||
|
||||
<h4>Syntax</h4>
|
||||
<pre>$map</pre>
|
||||
|
||||
<h4>Arguments</h4>
|
||||
None
|
||||
|
||||
<h4>Example</h4>
|
||||
<!-- Show example of function.-->
|
||||
<pre>$map → "overview_map" (within a composer item)<br />
|
||||
$map → "canvas" (within the main QGIS main canvas)</pre>
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "qgsscalecalculator.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgspallabeling.h"
|
||||
#include "qgsexpression.h"
|
||||
|
||||
#include "qgslabel.h"
|
||||
#include "qgslabelattributes.h"
|
||||
@ -226,6 +227,9 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const
|
||||
bool bkLayerCaching = s.value( "/qgis/enable_render_caching", false ).toBool();
|
||||
s.setValue( "/qgis/enable_render_caching", false );
|
||||
|
||||
//update $map variable. Use QgsComposerItem's id since that is user-definable
|
||||
QgsExpression::setSpecialColumn( "$map", QgsComposerItem::id() );
|
||||
|
||||
if ( forceWidthScale ) //force wysiwyg line widths / marker sizes
|
||||
{
|
||||
theMapRenderer.render( painter, forceWidthScale );
|
||||
|
@ -417,6 +417,9 @@ void QgsMapCanvas::refresh()
|
||||
|
||||
mDrawing = true;
|
||||
|
||||
//update $map variable to canvas
|
||||
QgsExpression::setSpecialColumn( "$map", tr( "canvas" ) );
|
||||
|
||||
if ( mRenderFlag && !mFrozen )
|
||||
{
|
||||
clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user