QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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 "moc_qgsannotationitemcommonpropertieswidget.cpp"
18#include "qgsannotationitem.h"
20#include "qgsapplication.h"
21#include "qgscalloutsregistry.h"
22
24 : QWidget( parent )
25{
26 setupUi( this );
27
28 connect( mSpinZIndex, qOverload<int>( &QSpinBox::valueChanged ), this, [=] {
29 if ( !mBlockChangedSignal )
30 emit itemChanged();
31 } );
32 mSpinZIndex->setClearValue( 0 );
33
34 connect( mReferenceScaleGroup, &QGroupBox::toggled, this, [=] {
35 if ( !mBlockChangedSignal )
36 emit itemChanged();
37 } );
38 connect( mReferenceScaleWidget, &QgsScaleWidget::scaleChanged, this, [=] {
39 if ( !mBlockChangedSignal )
40 emit itemChanged();
41 } );
42 connect( mCalloutCheckBox, &QCheckBox::toggled, this, [=] {
43 if ( !mBlockChangedSignal )
44 emit itemChanged();
45 } );
46
47 connect( mCalloutPropertiesButton, &QToolButton::clicked, this, &QgsAnnotationItemCommonPropertiesWidget::openCalloutProperties );
48}
49
51
53{
54 mSpinZIndex->setValue( item->zIndex() );
55 mReferenceScaleGroup->setChecked( item->useSymbologyReferenceScale() );
56 mReferenceScaleWidget->setScale( item->symbologyReferenceScale() );
57 mReferenceScaleGroup->setVisible( item->flags() & Qgis::AnnotationItemFlag::SupportsReferenceScale );
58 mCalloutCheckBox->setChecked( item->callout() );
59 mCallout.reset( item->callout() ? item->callout()->clone() : nullptr );
60}
61
63{
64 item->setZIndex( mSpinZIndex->value() );
65 item->setUseSymbologyReferenceScale( mReferenceScaleGroup->isChecked() );
66 item->setSymbologyReferenceScale( mReferenceScaleWidget->scale() );
67 item->setCallout( mCallout && mCalloutCheckBox->isChecked() ? mCallout->clone() : nullptr );
68}
69
71{
72 mContext = context;
73 mReferenceScaleWidget->setMapCanvas( context.mapCanvas() );
74 if ( context.mapCanvas() )
75 mReferenceScaleWidget->setShowCurrentScaleButton( true );
76}
77
82
83void QgsAnnotationItemCommonPropertiesWidget::openCalloutProperties()
84{
86 if ( !mCallout )
87 mCallout.reset( QgsApplication::calloutRegistry()->defaultCallout() );
88 widget->setCallout( mCallout.get() );
89
90 connect( widget, &QgsCalloutPanelWidget::calloutChanged, this, [this, widget] {
91 mCallout.reset( widget->callout()->clone() );
92 if ( !mBlockChangedSignal )
93 emit itemChanged();
94 } );
95
97 {
98 panel->openPanel( widget );
99 }
100}
@ SupportsReferenceScale
Item supports reference scale based rendering.
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 setCallout(QgsCallout *callout)
Sets the item's callout renderer, responsible for drawing item callouts.
void setSymbologyReferenceScale(double scale)
Sets the annotation's symbology reference scale.
virtual Qgis::AnnotationItemFlags flags() const
Returns item flags.
int zIndex() const
Returns the item's z index, which controls the order in which annotation items are rendered in the la...
QgsCallout * callout() const
Returns the item's callout renderer, responsible for drawing item callouts.
double symbologyReferenceScale() const
Returns the annotation's symbology reference scale.
static QgsCalloutRegistry * calloutRegistry()
Returns the application's callout registry, used for managing callout types.
A panel widget for configuration of callouts.
QgsCallout * callout()
Returns a new callout, respecting the configuration from the widget.
void calloutChanged()
Emitted when the callout defined by the widget changes.
void setCallout(const QgsCallout *callout)
Sets the widget state to match the specified callout.
virtual QgsCallout * clone() const =0
Duplicates a callout by creating a deep copy of the callout.
Base class for any widget that can be shown as a inline panel.
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
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.