QGIS API Documentation  2.9.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgscomposerlabel.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerlabel.cpp
3  -------------------
4  begin : January 2005
5  copyright : (C) 2005 by Radim Blazek
6  email : blazek@itc.it
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgscomposerlabel.h"
19 #include "qgscomposition.h"
20 #include "qgscomposerutils.h"
21 #include "qgsexpression.h"
23 #include "qgscomposermodel.h"
24 #include "qgsvectorlayer.h"
25 #include "qgsproject.h"
26 #include "qgsdistancearea.h"
27 
28 #include <QCoreApplication>
29 #include <QDate>
30 #include <QDomElement>
31 #include <QPainter>
32 #include <QSettings>
33 #include <QTimer>
34 #include <QWebFrame>
35 #include <QWebPage>
36 #include <QEventLoop>
37 
39  : QgsComposerItem( composition )
40  , mHtmlState( 0 )
41  , mHtmlUnitsToMM( 1.0 )
42  , mHtmlLoaded( false )
43  , mMarginX( 1.0 )
44  , mMarginY( 1.0 )
45  , mFontColor( QColor( 0, 0, 0 ) )
46  , mHAlignment( Qt::AlignLeft )
47  , mVAlignment( Qt::AlignTop )
48  , mExpressionFeature( 0 )
49  , mExpressionLayer( 0 )
50  , mDistanceArea( 0 )
51 {
52  mDistanceArea = new QgsDistanceArea();
53  mHtmlUnitsToMM = htmlUnitsToMM();
54 
55  //get default composer font from settings
56  QSettings settings;
57  QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
58  if ( !defaultFontString.isEmpty() )
59  {
60  mFont.setFamily( defaultFontString );
61  }
62 
63  //default to a 10 point font size
64  mFont.setPointSizeF( 10 );
65 
66  //default to no background
67  setBackgroundEnabled( false );
68 
70  {
71  //a label added while atlas preview is enabled needs to have the expression context set,
72  //otherwise fields in the label aren't correctly evaluated until atlas preview feature changes (#9457)
74  }
75 
76  if ( mComposition )
77  {
78  //connect to atlas feature changes
79  //to update the expression context
80  connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshExpressionContext() ) );
81  }
82 }
83 
85 {
86  delete mDistanceArea;
87 }
88 
89 void QgsComposerLabel::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
90 {
91  Q_UNUSED( itemStyle );
92  Q_UNUSED( pWidget );
93  if ( !painter )
94  {
95  return;
96  }
97  if ( !shouldDrawItem() )
98  {
99  return;
100  }
101 
102  drawBackground( painter );
103  painter->save();
104 
105  //antialiasing on
106  painter->setRenderHint( QPainter::Antialiasing, true );
107 
108  double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0;
109  double xPenAdjust = mMarginX < 0 ? -penWidth : penWidth;
110  double yPenAdjust = mMarginY < 0 ? -penWidth : penWidth;
111  QRectF painterRect( xPenAdjust + mMarginX, yPenAdjust + mMarginY, rect().width() - 2 * xPenAdjust - 2 * mMarginX, rect().height() - 2 * yPenAdjust - 2 * mMarginY );
112 
113  QString textToDraw = displayText();
114 
115  if ( mHtmlState )
116  {
117  painter->scale( 1.0 / mHtmlUnitsToMM / 10.0, 1.0 / mHtmlUnitsToMM / 10.0 );
118  QWebPage *webPage = new QWebPage();
119  webPage->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
120 
121  //Setup event loop and timeout for rendering html
122  QEventLoop loop;
123  QTimer timeoutTimer;
124  timeoutTimer.setSingleShot( true );
125 
126  //This makes the background transparent. Found on http://blog.qt.digia.com/blog/2009/06/30/transparent-qwebview-or-qwebpage/
127  QPalette palette = webPage->palette();
128  palette.setBrush( QPalette::Base, Qt::transparent );
129  webPage->setPalette( palette );
130  //webPage->setAttribute(Qt::WA_OpaquePaintEvent, false); //this does not compile, why ?
131 
132  webPage->setViewportSize( QSize( painterRect.width() * mHtmlUnitsToMM * 10.0, painterRect.height() * mHtmlUnitsToMM * 10.0 ) );
133  webPage->mainFrame()->setZoomFactor( 10.0 );
134  webPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
135  webPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
136 
137  // QGIS segfaults when rendering web page while in composer if html
138  // contains images. So if we are not printing the composition, then
139  // disable image loading
142  {
143  webPage->settings()->setAttribute( QWebSettings::AutoLoadImages, false );
144  }
145 
146  //Connect timeout and webpage loadFinished signals to loop
147  connect( &timeoutTimer, SIGNAL( timeout() ), &loop, SLOT( quit() ) );
148  connect( webPage, SIGNAL( loadFinished( bool ) ), &loop, SLOT( quit() ) );
149 
150  //mHtmlLoaded tracks whether the QWebPage has completed loading
151  //its html contents, set it initially to false. The loadingHtmlFinished slot will
152  //set this to true after html is loaded.
153  mHtmlLoaded = false;
154  connect( webPage, SIGNAL( loadFinished( bool ) ), SLOT( loadingHtmlFinished( bool ) ) );
155 
156  webPage->mainFrame()->setHtml( textToDraw );
157 
158  //For very basic html labels with no external assets, the html load will already be
159  //complete before we even get a chance to start the QEventLoop. Make sure we check
160  //this before starting the loop
161  if ( !mHtmlLoaded )
162  {
163  // Start a 20 second timeout in case html loading will never complete
164  timeoutTimer.start( 20000 );
165  // Pause until html is loaded
166  loop.exec();
167  }
168  webPage->mainFrame()->render( painter );//DELETE WEBPAGE ?
169  }
170  else
171  {
172  painter->setFont( mFont );
173  //debug
174  //painter->setPen( QColor( Qt::red ) );
175  //painter->drawRect( painterRect );
176  QgsComposerUtils::drawText( painter, painterRect, textToDraw, mFont, mFontColor, mHAlignment, mVAlignment, Qt::TextWordWrap );
177  }
178 
179  painter->restore();
180 
181  drawFrame( painter );
182  if ( isSelected() )
183  {
184  drawSelectionBoxes( painter );
185  }
186 }
187 
188 /*Track when QWebPage has finished loading its html contents*/
189 void QgsComposerLabel::loadingHtmlFinished( bool result )
190 {
191  Q_UNUSED( result );
192  mHtmlLoaded = true;
193 }
194 
195 double QgsComposerLabel::htmlUnitsToMM()
196 {
197  if ( !mComposition )
198  {
199  return 1.0;
200  }
201 
202  //TODO : fix this more precisely so that the label's default text size is the same with or without "display as html"
203  return ( mComposition->printResolution() / 72.0 ); //webkit seems to assume a standard dpi of 72
204 }
205 
206 void QgsComposerLabel::setText( const QString& text )
207 {
208  mText = text;
209  emit itemChanged();
210 
211  if ( mComposition && id().isEmpty() && !mHtmlState )
212  {
213  //notify the model that the display name has changed
215  }
216 }
217 
219 {
220  if ( state == mHtmlState )
221  {
222  return;
223  }
224 
225  mHtmlState = state;
226 
227  if ( mComposition && id().isEmpty() )
228  {
229  //notify the model that the display name has changed
231  }
232 }
233 
234 void QgsComposerLabel::setExpressionContext( QgsFeature* feature, QgsVectorLayer* layer, QMap<QString, QVariant> substitutions )
235 {
236  mExpressionFeature = feature;
237  mExpressionLayer = layer;
238  mSubstitutions = substitutions;
239 
240  //setup distance area conversion
241  if ( layer )
242  {
243  mDistanceArea->setSourceCrs( layer->crs().srsid() );
244  }
245  else if ( mComposition )
246  {
247  //set to composition's mapsettings' crs
248  mDistanceArea->setSourceCrs( mComposition->mapSettings().destinationCrs().srsid() );
249  }
250  if ( mComposition )
251  {
253  }
254  mDistanceArea->setEllipsoid( QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ) );
255 
256  // Force label to redraw -- fixes label printing for labels with blend modes when used with atlas
257  update();
258 }
259 
261 {
262  QgsVectorLayer * vl = 0;
263  QgsFeature* feature = 0;
264 
266  {
268  }
270  {
272  }
273 
274  setExpressionContext( feature, vl );
275 }
276 
278 {
279  QString displayText = mText;
280  replaceDateText( displayText );
281  QMap<QString, QVariant> subs = mSubstitutions;
282  subs[ "$page" ] = QVariant(( int )mComposition->itemPageNumber( this ) + 1 );
283  return QgsExpression::replaceExpressionText( displayText, mExpressionFeature, mExpressionLayer, &subs, mDistanceArea );
284 }
285 
286 void QgsComposerLabel::replaceDateText( QString& text ) const
287 {
288  QString constant = "$CURRENT_DATE";
289  int currentDatePos = text.indexOf( constant );
290  if ( currentDatePos != -1 )
291  {
292  //check if there is a bracket just after $CURRENT_DATE
293  QString formatText;
294  int openingBracketPos = text.indexOf( "(", currentDatePos );
295  int closingBracketPos = text.indexOf( ")", openingBracketPos + 1 );
296  if ( openingBracketPos != -1 &&
297  closingBracketPos != -1 &&
298  ( closingBracketPos - openingBracketPos ) > 1 &&
299  openingBracketPos == currentDatePos + constant.size() )
300  {
301  formatText = text.mid( openingBracketPos + 1, closingBracketPos - openingBracketPos - 1 );
302  text.replace( currentDatePos, closingBracketPos - currentDatePos + 1, QDate::currentDate().toString( formatText ) );
303  }
304  else //no bracket
305  {
306  text.replace( "$CURRENT_DATE", QDate::currentDate().toString() );
307  }
308  }
309 }
310 
311 void QgsComposerLabel::setFont( const QFont& f )
312 {
313  mFont = f;
314 }
315 
316 void QgsComposerLabel::setMargin( const double m )
317 {
318  mMarginX = m;
319  mMarginY = m;
320  prepareGeometryChange();
321 }
322 
323 void QgsComposerLabel::setMarginX( const double margin )
324 {
325  mMarginX = margin;
326  prepareGeometryChange();
327 }
328 
329 void QgsComposerLabel::setMarginY( const double margin )
330 {
331  mMarginY = margin;
332  prepareGeometryChange();
333 }
334 
336 {
337  double textWidth = QgsComposerUtils::textWidthMM( mFont, displayText() );
338  double fontHeight = QgsComposerUtils::fontHeightMM( mFont );
339 
340  double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0;
341 
342  double width = textWidth + 2 * mMarginX + 2 * penWidth + 1;
343  double height = fontHeight + 2 * mMarginY + 2 * penWidth;
344 
345  //keep alignment point constant
346  double xShift = 0;
347  double yShift = 0;
348  itemShiftAdjustSize( width, height, xShift, yShift );
349 
350  //update rect for data defined size and position
351  QRectF evaluatedRect = evalItemRect( QRectF( pos().x() + xShift, pos().y() + yShift, width, height ) );
352  setSceneRect( evaluatedRect );
353 }
354 
356 {
357  return mFont;
358 }
359 
360 bool QgsComposerLabel::writeXML( QDomElement& elem, QDomDocument & doc ) const
361 {
362  QString alignment;
363 
364  if ( elem.isNull() )
365  {
366  return false;
367  }
368 
369  QDomElement composerLabelElem = doc.createElement( "ComposerLabel" );
370 
371  composerLabelElem.setAttribute( "htmlState", mHtmlState );
372 
373  composerLabelElem.setAttribute( "labelText", mText );
374  composerLabelElem.setAttribute( "marginX", QString::number( mMarginX ) );
375  composerLabelElem.setAttribute( "marginY", QString::number( mMarginY ) );
376  composerLabelElem.setAttribute( "halign", mHAlignment );
377  composerLabelElem.setAttribute( "valign", mVAlignment );
378 
379  //font
380  QDomElement labelFontElem = doc.createElement( "LabelFont" );
381  labelFontElem.setAttribute( "description", mFont.toString() );
382  composerLabelElem.appendChild( labelFontElem );
383 
384  //font color
385  QDomElement fontColorElem = doc.createElement( "FontColor" );
386  fontColorElem.setAttribute( "red", mFontColor.red() );
387  fontColorElem.setAttribute( "green", mFontColor.green() );
388  fontColorElem.setAttribute( "blue", mFontColor.blue() );
389  composerLabelElem.appendChild( fontColorElem );
390 
391  elem.appendChild( composerLabelElem );
392  return _writeXML( composerLabelElem, doc );
393 }
394 
395 bool QgsComposerLabel::readXML( const QDomElement& itemElem, const QDomDocument& doc )
396 {
397  QString alignment;
398 
399  if ( itemElem.isNull() )
400  {
401  return false;
402  }
403 
404  //restore label specific properties
405 
406  //text
407  mText = itemElem.attribute( "labelText" );
408 
409  //html state
410  mHtmlState = itemElem.attribute( "htmlState" ).toInt();
411 
412  //margin
413  bool marginXOk = false;
414  bool marginYOk = false;
415  mMarginX = itemElem.attribute( "marginX" ).toDouble( &marginXOk );
416  mMarginY = itemElem.attribute( "marginY" ).toDouble( &marginYOk );
417  if ( !marginXOk || !marginYOk )
418  {
419  //upgrade old projects where margins where stored in a single attribute
420  double margin = itemElem.attribute( "margin", "1.0" ).toDouble();
421  mMarginX = margin;
422  mMarginY = margin;
423  }
424 
425  //Horizontal alignment
426  mHAlignment = ( Qt::AlignmentFlag )( itemElem.attribute( "halign" ).toInt() );
427 
428  //Vertical alignment
429  mVAlignment = ( Qt::AlignmentFlag )( itemElem.attribute( "valign" ).toInt() );
430 
431  //font
432  QDomNodeList labelFontList = itemElem.elementsByTagName( "LabelFont" );
433  if ( labelFontList.size() > 0 )
434  {
435  QDomElement labelFontElem = labelFontList.at( 0 ).toElement();
436  mFont.fromString( labelFontElem.attribute( "description" ) );
437  }
438 
439  //font color
440  QDomNodeList fontColorList = itemElem.elementsByTagName( "FontColor" );
441  if ( fontColorList.size() > 0 )
442  {
443  QDomElement fontColorElem = fontColorList.at( 0 ).toElement();
444  int red = fontColorElem.attribute( "red", "0" ).toInt();
445  int green = fontColorElem.attribute( "green", "0" ).toInt();
446  int blue = fontColorElem.attribute( "blue", "0" ).toInt();
447  mFontColor = QColor( red, green, blue );
448  }
449  else
450  {
451  mFontColor = QColor( 0, 0, 0 );
452  }
453 
454  //restore general composer item properties
455  QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
456  if ( composerItemList.size() > 0 )
457  {
458  QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
459 
460  //rotation
461  if ( composerItemElem.attribute( "rotation", "0" ).toDouble() != 0 )
462  {
463  //check for old (pre 2.1) rotation attribute
464  setItemRotation( composerItemElem.attribute( "rotation", "0" ).toDouble() );
465  }
466 
467  _readXML( composerItemElem, doc );
468  }
469  emit itemChanged();
470  return true;
471 }
472 
474 {
475  if ( !id().isEmpty() )
476  {
477  return id();
478  }
479 
480  if ( mHtmlState )
481  {
482  return tr( "<HTML label>" );
483  }
484 
485  //if no id, default to portion of label text
486  QString text = mText;
487  if ( text.isEmpty() )
488  {
489  return tr( "<label>" );
490  }
491  if ( text.length() > 25 )
492  {
493  return QString( tr( "%1..." ) ).arg( text.left( 25 ).simplified() );
494  }
495  else
496  {
497  return text.simplified();
498  }
499 }
500 
502 {
503  QRectF rectangle = rect();
504  double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0;
505  rectangle.adjust( -penWidth, -penWidth, penWidth, penWidth );
506 
507  if ( mMarginX < 0 )
508  {
509  rectangle.adjust( mMarginX, 0, -mMarginX, 0 );
510  }
511  if ( mMarginY < 0 )
512  {
513  rectangle.adjust( 0, mMarginY, 0, -mMarginY );
514  }
515 
516  return rectangle;
517 }
518 
519 void QgsComposerLabel::setFrameEnabled( const bool drawFrame )
520 {
522  prepareGeometryChange();
523 }
524 
526 {
528  prepareGeometryChange();
529 }
530 
531 void QgsComposerLabel::itemShiftAdjustSize( double newWidth, double newHeight, double& xShift, double& yShift ) const
532 {
533  //keep alignment point constant
534  double currentWidth = rect().width();
535  double currentHeight = rect().height();
536  xShift = 0;
537  yShift = 0;
538 
539  if ( mItemRotation >= 0 && mItemRotation < 90 )
540  {
541  if ( mHAlignment == Qt::AlignHCenter )
542  {
543  xShift = - ( newWidth - currentWidth ) / 2.0;
544  }
545  else if ( mHAlignment == Qt::AlignRight )
546  {
547  xShift = - ( newWidth - currentWidth );
548  }
549  if ( mVAlignment == Qt::AlignVCenter )
550  {
551  yShift = -( newHeight - currentHeight ) / 2.0;
552  }
553  else if ( mVAlignment == Qt::AlignBottom )
554  {
555  yShift = - ( newHeight - currentHeight );
556  }
557  }
558  if ( mItemRotation >= 90 && mItemRotation < 180 )
559  {
560  if ( mHAlignment == Qt::AlignHCenter )
561  {
562  yShift = -( newHeight - currentHeight ) / 2.0;
563  }
564  else if ( mHAlignment == Qt::AlignRight )
565  {
566  yShift = -( newHeight - currentHeight );
567  }
568  if ( mVAlignment == Qt::AlignTop )
569  {
570  xShift = -( newWidth - currentWidth );
571  }
572  else if ( mVAlignment == Qt::AlignVCenter )
573  {
574  xShift = -( newWidth - currentWidth / 2.0 );
575  }
576  }
577  else if ( mItemRotation >= 180 && mItemRotation < 270 )
578  {
579  if ( mHAlignment == Qt::AlignHCenter )
580  {
581  xShift = -( newWidth - currentWidth ) / 2.0;
582  }
583  else if ( mHAlignment == Qt::AlignLeft )
584  {
585  xShift = -( newWidth - currentWidth );
586  }
587  if ( mVAlignment == Qt::AlignVCenter )
588  {
589  yShift = ( newHeight - currentHeight ) / 2.0;
590  }
591  else if ( mVAlignment == Qt::AlignTop )
592  {
593  yShift = ( newHeight - currentHeight );
594  }
595  }
596  else if ( mItemRotation >= 270 && mItemRotation < 360 )
597  {
598  if ( mHAlignment == Qt::AlignHCenter )
599  {
600  yShift = -( newHeight - currentHeight ) / 2.0;
601  }
602  else if ( mHAlignment == Qt::AlignLeft )
603  {
604  yShift = -( newHeight - currentHeight );
605  }
606  if ( mVAlignment == Qt::AlignBottom )
607  {
608  xShift = -( newWidth - currentWidth );
609  }
610  else if ( mVAlignment == Qt::AlignVCenter )
611  {
612  xShift = -( newWidth - currentWidth / 2.0 );
613  }
614  }
615 }
QgsComposition::AtlasMode atlasMode() const
Returns the current atlas mode of the composition.
double outlineWidth
Definition: qgssvgcache.cpp:78
void setHtmlState(int state)
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
sets state from Dom document
QgsComposerModel * itemsModel()
Returns the items model attached to the composition.
void itemChanged()
Emitted when the item changes.
const QgsMapSettings & mapSettings() const
Return setting of QGIS map canvas.
void setSourceCrs(long srsid)
sets source spatial reference system (by QGIS CRS)
static QgsNetworkAccessManager * instance()
Definition: qgssingleton.h:23
A item that forms part of a map composition.
static void drawText(QPainter *painter, const QPointF &pos, const QString &text, const QFont &font, const QColor &color=QColor())
Draws text on a painter at a specific position, taking care of composer specific issues (calculation ...
bool enabled() const
Returns whether the atlas generation is enabled.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
virtual void drawFrame(QPainter *p)
Draw black frame around item.
virtual void setFrameEnabled(const bool drawFrame)
Set whether this item has a frame drawn around it or not.
bool setEllipsoid(const QString &ellipsoid)
sets ellipsoid by its acronym
void setFont(const QFont &f)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:113
void updateItemDisplayName(QgsComposerItem *item)
Must be called when an item's display name is modified.
bool writeXML(QDomElement &elem, QDomDocument &doc) const override
stores state in Dom element
bool _readXML(const QDomElement &itemElem, const QDomDocument &doc)
Reads parameter that are not subclass specific in document.
int itemPageNumber(const QgsComposerItem *) const
Returns on which page number (0-based) is displayed an item.
QFont font() const
virtual void drawSelectionBoxes(QPainter *p)
Draws additional graphics on selected items.
int printResolution() const
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
QgsComposerLabel(QgsComposition *composition)
bool shouldDrawItem() const
Returns whether the item should be drawn in the current context.
void setBackgroundEnabled(const bool drawBackground)
Set whether this item has a Background drawn around it or not.
QRectF boundingRect() const override
In case of negative margins, the bounding rect may be larger than the label's frame.
void setMarginX(const double margin)
Sets the horizontal margin between the edge of the frame and the label contents.
Graphics scene for map printing.
QgsFeature * currentFeature()
Returns the current atlas feature.
void setMarginY(const double margin)
Sets the vertical margin between the edge of the frame and the label contents.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
Reimplementation of QCanvasItem::paint.
virtual void setFrameOutlineWidth(const double outlineWidth)
Sets frame outline width.
General purpose distance and area calculator.
static double textWidthMM(const QFont &font, const QString &text)
Calculate font width in millimeters for a string, including workarounds for QT font rendering issues...
QgsComposition * mComposition
static double fontHeightMM(const QFont &font)
Calculate font height in millimeters, including workarounds for QT font rendering issues The font hei...
QRectF evalItemRect(const QRectF &newRect, const bool resizeOnly=false)
Evaluates an item's bounding rect to consider data defined position and size of item and reference po...
bool _writeXML(QDomElement &itemElem, QDomDocument &doc) const
Writes parameter that are not subclass specific in document.
virtual void setItemRotation(const double r, const bool adjustPosition=false)
Sets the item rotation.
virtual void drawBackground(QPainter *p)
Draw background.
bool hasFrame() const
Whether this item has a frame or not.
static QgsProject * instance()
access to canonical QgsProject instance
Definition: qgsproject.cpp:351
void setMargin(const double m)
Sets the margin between the edge of the frame and the label contents.
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
const CORE_EXPORT QString GEO_NONE
Constant that holds the string representation for "No ellips/No CRS".
Definition: qgis.cpp:74
void setText(const QString &text)
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
Q_DECL_DEPRECATED double margin()
Returns the margin between the edge of the frame and the label contents.
QgsAtlasComposition & atlasComposition()
void setExpressionContext(QgsFeature *feature, QgsVectorLayer *layer, QMap< QString, QVariant > substitutions=(QMap< QString, QVariant >()))
Sets the current feature, the current layer and a list of local variable substitutions for evaluating...
QgsVectorLayer * coverageLayer() const
Returns the coverage layer used for the atlas features.
QgsComposition::PlotStyle plotStyle() const
Represents a vector layer which manages a vector based data sets.
QString displayText() const
Returns the text as it appears on screen (with replaced data field)
double mItemRotation
Item rotation in degrees, clockwise.
void adjustSizeToText()
resizes the widget such that the text fits to the item.
void setEllipsoidalMode(bool flag)
sets whether coordinates must be projected to ellipsoid before measuring
virtual void setFrameEnabled(const bool drawFrame) override
Reimplemented to call prepareGeometryChange after toggling frame.
virtual QString displayName() const override
Get item display name.
#define tr(sourceText)
static QString replaceExpressionText(const QString &action, const QgsFeature *feat, QgsVectorLayer *layer, const QMap< QString, QVariant > *substitutionMap=0, const QgsDistanceArea *distanceArea=0)
This function currently replaces each expression between [% and %] in the string with the result of i...
virtual void setFrameOutlineWidth(const double outlineWidth) override
Reimplemented to call prepareGeometryChange after changing outline width.
QString id() const
Get item's id (which is not necessarly unique)