QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsannotationitemcommonpropertieswidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsannotationitemcommonpropertieswidget.cpp
3  ------------------------
4  Date : September 2021
5  Copyright : (C) 2021 Nyall Dawson
6  Email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 #include "qgsannotationitem.h"
18 
20  : QWidget( parent )
21 {
22  setupUi( this );
23 
24  connect( mSpinZIndex, qOverload<int>( &QSpinBox::valueChanged ), this, [ = ]
25  {
26  if ( !mBlockChangedSignal )
27  emit itemChanged();
28  } );
29  mSpinZIndex->setClearValue( 0 );
30 
31  connect( mReferenceScaleGroup, &QGroupBox::toggled, this, [ = ]
32  {
33  if ( !mBlockChangedSignal )
34  emit itemChanged();
35  } );
36  connect( mReferenceScaleWidget, &QgsScaleWidget::scaleChanged, this, [ = ]
37  {
38  if ( !mBlockChangedSignal )
39  emit itemChanged();
40  } );
41 }
42 
44 {
45  mSpinZIndex->setValue( item->zIndex() );
46  mReferenceScaleGroup->setChecked( item->useSymbologyReferenceScale() );
47  mReferenceScaleWidget->setScale( item->symbologyReferenceScale() );
48 }
49 
51 {
52  item->setZIndex( mSpinZIndex->value() );
53  item->setUseSymbologyReferenceScale( mReferenceScaleGroup->isChecked() );
54  item->setSymbologyReferenceScale( mReferenceScaleWidget->scale() );
55 }
56 
58 {
59  mContext = context;
60  mReferenceScaleWidget->setMapCanvas( context.mapCanvas() );
61  if ( context.mapCanvas() )
62  mReferenceScaleWidget->setShowCurrentScaleButton( true );
63 }
64 
66 {
67  return mContext;
68 }
QgsSymbolWidgetContext::mapCanvas
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
Definition: qgssymbolwidgetcontext.cpp:54
QgsAnnotationItem::useSymbologyReferenceScale
bool useSymbologyReferenceScale() const
Returns true if the annotation item uses a symbology reference scale.
Definition: qgsannotationitem.h:188
QgsSymbolWidgetContext
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Definition: qgssymbolwidgetcontext.h:35
QgsAnnotationItemCommonPropertiesWidget::setItem
void setItem(QgsAnnotationItem *item)
Sets the item whose properties should be shown in the widget.
Definition: qgsannotationitemcommonpropertieswidget.cpp:43
QgsSymbolWidgetContext::setMapCanvas
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
Definition: qgssymbolwidgetcontext.cpp:49
QgsAnnotationItem::zIndex
int zIndex() const
Returns the item's z index, which controls the order in which annotation items are rendered in the la...
Definition: qgsannotationitem.h:165
QgsAnnotationItemCommonPropertiesWidget::itemChanged
void itemChanged()
Emitted when the annotation item definition in the widget is changed by the user.
QgsAnnotationItemCommonPropertiesWidget::QgsAnnotationItemCommonPropertiesWidget
QgsAnnotationItemCommonPropertiesWidget(QWidget *parent)
Constructor for QgsAnnotationItemCommonPropertiesWidget.
Definition: qgsannotationitemcommonpropertieswidget.cpp:19
QgsScaleWidget::scaleChanged
void scaleChanged(double scale)
Emitted when user has finished editing/selecting a new scale.
qgsannotationitemcommonpropertieswidget.h
qgsannotationitem.h
QgsAnnotationItemCommonPropertiesWidget::context
QgsSymbolWidgetContext context() const
Returns the context in which the widget is shown, e.g., the associated map canvas and expression cont...
Definition: qgsannotationitemcommonpropertieswidget.cpp:65
QgsAnnotationItemCommonPropertiesWidget::updateItem
void updateItem(QgsAnnotationItem *item)
Updates an item, setting the properties defined in the widget.
Definition: qgsannotationitemcommonpropertieswidget.cpp:50
QgsAnnotationItem::setSymbologyReferenceScale
void setSymbologyReferenceScale(double scale)
Sets the annotation's symbology reference scale.
Definition: qgsannotationitem.h:230
QgsAnnotationItem::symbologyReferenceScale
double symbologyReferenceScale() const
Returns the annotation's symbology reference scale.
Definition: qgsannotationitem.h:213
QgsAnnotationItem::setZIndex
void setZIndex(int index)
Sets the item's z index, which controls the order in which annotation items are rendered in the layer...
Definition: qgsannotationitem.h:173
QgsAnnotationItem
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Definition: qgsannotationitem.h:42
QgsAnnotationItem::setUseSymbologyReferenceScale
void setUseSymbologyReferenceScale(bool enabled)
Sets whether the annotation item uses a symbology reference scale.
Definition: qgsannotationitem.h:196
QgsAnnotationItemCommonPropertiesWidget::setContext
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
Definition: qgsannotationitemcommonpropertieswidget.cpp:57