QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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}
QgsAnnotationItemCommonPropertiesWidget(QWidget *parent)
Constructor for QgsAnnotationItemCommonPropertiesWidget.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
QgsSymbolWidgetContext context() const
Returns the context in which the widget is shown, e.g., the associated map canvas and expression cont...
void setItem(QgsAnnotationItem *item)
Sets the item whose properties should be shown in the widget.
void itemChanged()
Emitted when the annotation item definition in the widget is changed by the user.
void updateItem(QgsAnnotationItem *item)
Updates an item, setting the properties defined in the widget.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
void setUseSymbologyReferenceScale(bool enabled)
Sets whether the annotation item uses a symbology reference scale.
void setZIndex(int index)
Sets the item's z index, which controls the order in which annotation items are rendered in the layer...
bool useSymbologyReferenceScale() const
Returns true if the annotation item uses a symbology reference scale.
void setSymbologyReferenceScale(double scale)
Sets the annotation's symbology reference scale.
int zIndex() const
Returns the item's z index, which controls the order in which annotation items are rendered in the la...
double symbologyReferenceScale() const
Returns the annotation's symbology reference scale.
void scaleChanged(double scale)
Emitted when user has finished editing/selecting a new scale.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.