QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsannotationitemwidget_impl.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsannotationitemwidget_impl.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 ***************************************************************************/
16
18#include "qgsstyle.h"
19#include "qgsfillsymbol.h"
20#include "qgslinesymbol.h"
21#include "qgsmarkersymbol.h"
28#include "qgstextformatwidget.h"
29#include "qgsapplication.h"
31
33
34QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent )
36{
37 setupUi( this );
38
39 mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
40 mSelector->setDockMode( dockMode() );
41 connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
42 {
43 if ( !mBlockChangedSignal )
44 {
45 emit itemChanged();
46 QgsApplication::recentStyleHandler()->pushRecentSymbol( QStringLiteral( "polygon_annotation_item" ), qgis::down_cast< QgsFillSymbol * >( mSelector->symbol()->clone() ) );
47 }
48 } );
49 connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );
50
51 QVBoxLayout *layout = new QVBoxLayout();
52 layout->setContentsMargins( 0, 0, 0, 0 );
53 layout->addWidget( mSelector );
54 mSymbolSelectorFrame->setLayout( layout );
55
56 connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
57 {
58 if ( !mBlockChangedSignal )
59 emit itemChanged();
60 } );
61}
62
63QgsAnnotationItem *QgsAnnotationPolygonItemWidget::createItem()
64{
65 QgsAnnotationPolygonItem *newItem = mItem->clone();
66 newItem->setSymbol( mSymbol->clone() );
67 mPropertiesWidget->updateItem( newItem );
68 return newItem;
69}
70
71void QgsAnnotationPolygonItemWidget::updateItem( QgsAnnotationItem *item )
72{
73 if ( QgsAnnotationPolygonItem *polygonItem = dynamic_cast< QgsAnnotationPolygonItem * >( item ) )
74 {
75 polygonItem->setSymbol( mSymbol->clone() );
76 mPropertiesWidget->updateItem( polygonItem );
77 }
78}
79
80void QgsAnnotationPolygonItemWidget::setDockMode( bool dockMode )
81{
83 if ( mSelector )
84 mSelector->setDockMode( dockMode );
85}
86
87void QgsAnnotationPolygonItemWidget::setContext( const QgsSymbolWidgetContext &context )
88{
90 if ( mSelector )
91 mSelector->setContext( context );
92 mPropertiesWidget->setContext( context );
93}
94
95QgsAnnotationPolygonItemWidget::~QgsAnnotationPolygonItemWidget() = default;
96
97bool QgsAnnotationPolygonItemWidget::setNewItem( QgsAnnotationItem *item )
98{
99 QgsAnnotationPolygonItem *polygonItem = dynamic_cast< QgsAnnotationPolygonItem * >( item );
100 if ( !polygonItem )
101 return false;
102
103 mItem.reset( polygonItem->clone() );
104 if ( mItem->symbol() )
105 {
106 mSymbol.reset( mItem->symbol()->clone() );
107 }
108 else
109 {
110 mSymbol.reset( QgsFillSymbol::createSimple( {} ) );
111 }
112 mBlockChangedSignal = true;
113 mSelector->loadSymbol( mSymbol.get() );
114 mSelector->updatePreview();
115 mPropertiesWidget->setItem( mItem.get() );
116 mBlockChangedSignal = false;
117
118 return true;
119}
120
121
122//
123// QgsAnnotationLineItemWidget
124//
125
126QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
128{
129 setupUi( this );
130
131 mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
132 mSelector->setDockMode( dockMode() );
133 connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
134 {
135 if ( !mBlockChangedSignal )
136 {
137 emit itemChanged();
138 QgsApplication::recentStyleHandler()->pushRecentSymbol( QStringLiteral( "line_annotation_item" ), qgis::down_cast< QgsLineSymbol * >( mSelector->symbol()->clone() ) );
139 }
140 } );
141 connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );
142
143 QVBoxLayout *layout = new QVBoxLayout();
144 layout->setContentsMargins( 0, 0, 0, 0 );
145 layout->addWidget( mSelector );
146 mSymbolSelectorFrame->setLayout( layout );
147
148 connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
149 {
150 if ( !mBlockChangedSignal )
151 emit itemChanged();
152 } );
153}
154
155QgsAnnotationItem *QgsAnnotationLineItemWidget::createItem()
156{
157 QgsAnnotationLineItem *newItem = mItem->clone();
158 newItem->setSymbol( mSymbol->clone() );
159 mPropertiesWidget->updateItem( newItem );
160 return newItem;
161}
162
163void QgsAnnotationLineItemWidget::updateItem( QgsAnnotationItem *item )
164{
165 if ( QgsAnnotationLineItem *lineItem = dynamic_cast< QgsAnnotationLineItem * >( item ) )
166 {
167 lineItem->setSymbol( mSymbol->clone() );
168 mPropertiesWidget->updateItem( lineItem );
169 }
170}
171
172void QgsAnnotationLineItemWidget::setDockMode( bool dockMode )
173{
175 if ( mSelector )
176 mSelector->setDockMode( dockMode );
177}
178
179void QgsAnnotationLineItemWidget::setContext( const QgsSymbolWidgetContext &context )
180{
182 if ( mSelector )
183 mSelector->setContext( context );
184 mPropertiesWidget->setContext( context );
185}
186
187QgsAnnotationLineItemWidget::~QgsAnnotationLineItemWidget() = default;
188
189bool QgsAnnotationLineItemWidget::setNewItem( QgsAnnotationItem *item )
190{
191 QgsAnnotationLineItem *lineItem = dynamic_cast< QgsAnnotationLineItem * >( item );
192 if ( !lineItem )
193 return false;
194
195 mItem.reset( lineItem->clone() );
196 if ( mItem->symbol() )
197 {
198 mSymbol.reset( mItem->symbol()->clone() );
199 }
200 else
201 {
202 mSymbol.reset( QgsLineSymbol::createSimple( {} ) );
203 }
204 mBlockChangedSignal = true;
205 mSelector->loadSymbol( mSymbol.get() );
206 mSelector->updatePreview();
207 mPropertiesWidget->setItem( mItem.get() );
208 mBlockChangedSignal = false;
209
210 return true;
211}
212
213
214//
215// QgsAnnotationMarkerItemWidget
216//
217
218QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
220{
221 setupUi( this );
222
223 mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
224 mSelector->setDockMode( dockMode() );
225 connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
226 {
227 if ( !mBlockChangedSignal )
228 {
229 emit itemChanged();
230 QgsApplication::recentStyleHandler()->pushRecentSymbol( QStringLiteral( "marker_annotation_item" ), qgis::down_cast< QgsMarkerSymbol * >( mSelector->symbol()->clone() ) );
231 }
232 } );
233 connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );
234
235 QVBoxLayout *layout = new QVBoxLayout();
236 layout->setContentsMargins( 0, 0, 0, 0 );
237 layout->addWidget( mSelector );
238 mSymbolSelectorFrame->setLayout( layout );
239
240 connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
241 {
242 if ( !mBlockChangedSignal )
243 emit itemChanged();
244 } );
245}
246
247QgsAnnotationItem *QgsAnnotationMarkerItemWidget::createItem()
248{
249 QgsAnnotationMarkerItem *newItem = mItem->clone();
250 newItem->setSymbol( mSymbol->clone() );
251 mPropertiesWidget->updateItem( newItem );
252 return newItem;
253}
254
255void QgsAnnotationMarkerItemWidget::updateItem( QgsAnnotationItem *item )
256{
257 if ( QgsAnnotationMarkerItem *markerItem = dynamic_cast< QgsAnnotationMarkerItem * >( item ) )
258 {
259 markerItem->setSymbol( mSymbol->clone() );
260 mPropertiesWidget->updateItem( markerItem );
261 }
262}
263
264void QgsAnnotationMarkerItemWidget::setDockMode( bool dockMode )
265{
267 if ( mSelector )
268 mSelector->setDockMode( dockMode );
269}
270
271void QgsAnnotationMarkerItemWidget::setContext( const QgsSymbolWidgetContext &context )
272{
274 if ( mSelector )
275 mSelector->setContext( context );
276 mPropertiesWidget->setContext( context );
277}
278
279QgsAnnotationMarkerItemWidget::~QgsAnnotationMarkerItemWidget() = default;
280
281bool QgsAnnotationMarkerItemWidget::setNewItem( QgsAnnotationItem *item )
282{
283 QgsAnnotationMarkerItem *markerItem = dynamic_cast< QgsAnnotationMarkerItem * >( item );
284 if ( !markerItem )
285 return false;
286
287 mItem.reset( markerItem->clone() );
288 if ( mItem->symbol() )
289 {
290 mSymbol.reset( mItem->symbol()->clone() );
291 }
292 else
293 {
294 mSymbol.reset( QgsMarkerSymbol::createSimple( {} ) );
295 }
296 mBlockChangedSignal = true;
297 mSelector->loadSymbol( mSymbol.get() );
298 mSelector->updatePreview();
299 mPropertiesWidget->setItem( mItem.get() );
300 mBlockChangedSignal = false;
301
302 return true;
303}
304
305
306
307//
308// QgsAnnotationPointTextItemWidget
309//
310
311QgsAnnotationPointTextItemWidget::QgsAnnotationPointTextItemWidget( QWidget *parent )
313{
314 setupUi( this );
315
316 mTextFormatWidget = new QgsTextFormatWidget();
317 QVBoxLayout *vLayout = new QVBoxLayout();
318 vLayout->setContentsMargins( 0, 0, 0, 0 );
319 vLayout->addWidget( mTextFormatWidget );
320 mTextFormatWidgetContainer->setLayout( vLayout );
321
322 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
323
324 mSpinTextAngle->setClearValue( 0 );
325
326 mRotationModeCombo->addItem( tr( "Ignore Map Rotation" ), QVariant::fromValue( Qgis::SymbolRotationMode::IgnoreMapRotation ) );
327 mRotationModeCombo->addItem( tr( "Rotate With Map" ), QVariant::fromValue( Qgis::SymbolRotationMode::RespectMapRotation ) );
328
329 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight );
330
331 mTextFormatWidget->setDockMode( dockMode() );
332 connect( mTextFormatWidget, &QgsTextFormatWidget::widgetChanged, this, [ = ]
333 {
334 if ( !mBlockChangedSignal )
335 emit itemChanged();
336 } );
337 connect( mTextEdit, &QPlainTextEdit::textChanged, this, [ = ]
338 {
339 if ( !mBlockChangedSignal )
340 emit itemChanged();
341 } );
342 connect( mInsertExpressionButton, &QPushButton::clicked, this, &QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked );
343 connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
344 {
345 if ( !mBlockChangedSignal )
346 emit itemChanged();
347 } );
348
349 connect( mSpinTextAngle, qOverload< double >( &QgsDoubleSpinBox::valueChanged ), this, [ = ]
350 {
351 if ( !mBlockChangedSignal )
352 emit itemChanged();
353 } );
354
355 connect( mRotationModeCombo, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]
356 {
357 if ( !mBlockChangedSignal )
358 emit itemChanged();
359 } );
360
361 connect( mAlignmentComboBox, &QgsAlignmentComboBox::changed, this, [ = ]
362 {
363 if ( !mBlockChangedSignal )
364 emit itemChanged();
365 } );
366}
367
368QgsAnnotationItem *QgsAnnotationPointTextItemWidget::createItem()
369{
370 QgsAnnotationPointTextItem *newItem = mItem->clone();
371 newItem->setFormat( mTextFormatWidget->format() );
372 newItem->setText( mTextEdit->toPlainText() );
373 newItem->setAngle( mSpinTextAngle->value() );
374 newItem->setRotationMode( mRotationModeCombo->currentData().value< Qgis::SymbolRotationMode >() );
375 newItem->setAlignment( mAlignmentComboBox->currentAlignment() );
376 mPropertiesWidget->updateItem( newItem );
377 return newItem;
378}
379
380void QgsAnnotationPointTextItemWidget::updateItem( QgsAnnotationItem *item )
381{
382 if ( QgsAnnotationPointTextItem *pointTextItem = dynamic_cast< QgsAnnotationPointTextItem * >( item ) )
383 {
384 pointTextItem->setFormat( mTextFormatWidget->format() );
385 pointTextItem->setText( mTextEdit->toPlainText() );
386 pointTextItem->setAngle( mSpinTextAngle->value() );
387 pointTextItem->setRotationMode( mRotationModeCombo->currentData().value< Qgis::SymbolRotationMode >() );
388 pointTextItem->setAlignment( mAlignmentComboBox->currentAlignment() );
389 mPropertiesWidget->updateItem( pointTextItem );
390 }
391}
392
393void QgsAnnotationPointTextItemWidget::setDockMode( bool dockMode )
394{
396 if ( mTextFormatWidget )
397 mTextFormatWidget->setDockMode( dockMode );
398}
399
400void QgsAnnotationPointTextItemWidget::setContext( const QgsSymbolWidgetContext &context )
401{
403 if ( mTextFormatWidget )
404 mTextFormatWidget->setContext( context );
405 mPropertiesWidget->setContext( context );
406}
407
408void QgsAnnotationPointTextItemWidget::focusDefaultWidget()
409{
410 mTextEdit->selectAll();
411 mTextEdit->setFocus();
412}
413
414QgsAnnotationPointTextItemWidget::~QgsAnnotationPointTextItemWidget() = default;
415
416bool QgsAnnotationPointTextItemWidget::setNewItem( QgsAnnotationItem *item )
417{
418 QgsAnnotationPointTextItem *textItem = dynamic_cast< QgsAnnotationPointTextItem * >( item );
419 if ( !textItem )
420 return false;
421
422 mItem.reset( textItem->clone() );
423
424 mBlockChangedSignal = true;
425 mTextFormatWidget->setFormat( mItem->format() );
426 mTextEdit->setPlainText( mItem->text() );
427 mSpinTextAngle->setValue( mItem->angle() );
428 mRotationModeCombo->setCurrentIndex( mRotationModeCombo->findData( QVariant::fromValue( mItem->rotationMode() ) ) );
429 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
430 mPropertiesWidget->setItem( mItem.get() );
431 mBlockChangedSignal = false;
432
433 return true;
434}
435
436void QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked()
437{
438 QString selText = mTextEdit->textCursor().selectedText();
439
440 // html editor replaces newlines with Paragraph Separator characters - see https://github.com/qgis/QGIS/issues/27568
441 selText = selText.replace( QChar( 0x2029 ), QChar( '\n' ) );
442
443 // edit the selected expression if there's one
444 if ( selText.startsWith( QLatin1String( "[%" ) ) && selText.endsWith( QLatin1String( "%]" ) ) )
445 selText = selText.mid( 2, selText.size() - 4 );
446
447 QgsExpressionContext expressionContext;
448 if ( context().expressionContext() )
449 expressionContext = *( context().expressionContext() );
450 else
451 expressionContext = QgsProject::instance()->createExpressionContext();
452
453 QgsExpressionBuilderDialog exprDlg( nullptr, selText, this, QStringLiteral( "generic" ), expressionContext );
454
455 exprDlg.setWindowTitle( tr( "Insert Expression" ) );
456 if ( exprDlg.exec() == QDialog::Accepted )
457 {
458 QString expression = exprDlg.expressionText();
459 if ( !expression.isEmpty() )
460 {
461 mTextEdit->insertPlainText( "[%" + expression + "%]" );
462 }
463 }
464}
465
466
467//
468// QgsAnnotationLineTextItemWidget
469//
470
471QgsAnnotationLineTextItemWidget::QgsAnnotationLineTextItemWidget( QWidget *parent )
473{
474 setupUi( this );
475
476 mTextFormatWidget = new QgsTextFormatWidget();
477 QVBoxLayout *vLayout = new QVBoxLayout();
478 vLayout->setContentsMargins( 0, 0, 0, 0 );
479 vLayout->addWidget( mTextFormatWidget );
480 mTextFormatWidgetContainer->setLayout( vLayout );
481
482 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
483
484 mTextFormatWidget->setDockMode( dockMode() );
485 connect( mTextFormatWidget, &QgsTextFormatWidget::widgetChanged, this, [ = ]
486 {
487 if ( !mBlockChangedSignal )
488 emit itemChanged();
489 } );
490 connect( mTextEdit, &QPlainTextEdit::textChanged, this, [ = ]
491 {
492 if ( !mBlockChangedSignal )
493 emit itemChanged();
494 } );
495 connect( mInsertExpressionButton, &QPushButton::clicked, this, &QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked );
496 connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
497 {
498 if ( !mBlockChangedSignal )
499 emit itemChanged();
500 } );
501
504 mSpinOffset->setClearValue( 0.0 );
505 connect( mSpinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]
506 {
507 if ( !mBlockChangedSignal )
508 emit itemChanged();
509 } );
510
511 connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
512 {
513 if ( !mBlockChangedSignal )
514 emit itemChanged();
515 } );
516}
517
518QgsAnnotationLineTextItemWidget::~QgsAnnotationLineTextItemWidget() = default;
519
520QgsAnnotationItem *QgsAnnotationLineTextItemWidget::createItem()
521{
522 QgsAnnotationLineTextItem *newItem = mItem->clone();
523 newItem->setFormat( mTextFormatWidget->format() );
524 newItem->setText( mTextEdit->toPlainText() );
525
526 newItem->setOffsetFromLine( mSpinOffset->value() );
527 newItem->setOffsetFromLineUnit( mOffsetUnitWidget->unit() );
528 newItem->setOffsetFromLineMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
529
530 mPropertiesWidget->updateItem( newItem );
531 return newItem;
532}
533
534void QgsAnnotationLineTextItemWidget::updateItem( QgsAnnotationItem *item )
535{
536 if ( QgsAnnotationLineTextItem *lineTextItem = dynamic_cast< QgsAnnotationLineTextItem * >( item ) )
537 {
538 lineTextItem->setFormat( mTextFormatWidget->format() );
539 lineTextItem->setText( mTextEdit->toPlainText() );
540
541 lineTextItem->setOffsetFromLine( mSpinOffset->value() );
542 lineTextItem->setOffsetFromLineUnit( mOffsetUnitWidget->unit() );
543 lineTextItem->setOffsetFromLineMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
544
545 mPropertiesWidget->updateItem( lineTextItem );
546 }
547}
548
549void QgsAnnotationLineTextItemWidget::setDockMode( bool dockMode )
550{
552 if ( mTextFormatWidget )
553 mTextFormatWidget->setDockMode( dockMode );
554}
555
556void QgsAnnotationLineTextItemWidget::setContext( const QgsSymbolWidgetContext &context )
557{
559 if ( mTextFormatWidget )
560 mTextFormatWidget->setContext( context );
561 mPropertiesWidget->setContext( context );
562}
563
564void QgsAnnotationLineTextItemWidget::focusDefaultWidget()
565{
566 mTextEdit->selectAll();
567 mTextEdit->setFocus();
568}
569
570bool QgsAnnotationLineTextItemWidget::setNewItem( QgsAnnotationItem *item )
571{
572 QgsAnnotationLineTextItem *textItem = dynamic_cast< QgsAnnotationLineTextItem * >( item );
573 if ( !textItem )
574 return false;
575
576 mItem.reset( textItem->clone() );
577
578 mBlockChangedSignal = true;
579 mTextFormatWidget->setFormat( mItem->format() );
580 mTextEdit->setPlainText( mItem->text() );
581 mPropertiesWidget->setItem( mItem.get() );
582
583 mSpinOffset->setValue( mItem->offsetFromLine() );
584 mOffsetUnitWidget->setUnit( mItem->offsetFromLineUnit() );
585 mOffsetUnitWidget->setMapUnitScale( mItem->offsetFromLineMapUnitScale() );
586
587 mBlockChangedSignal = false;
588
589 return true;
590}
591
592void QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked()
593{
594 QString selText = mTextEdit->textCursor().selectedText();
595
596 // html editor replaces newlines with Paragraph Separator characters - see https://github.com/qgis/QGIS/issues/27568
597 selText = selText.replace( QChar( 0x2029 ), QChar( '\n' ) );
598
599 // edit the selected expression if there's one
600 if ( selText.startsWith( QLatin1String( "[%" ) ) && selText.endsWith( QLatin1String( "%]" ) ) )
601 selText = selText.mid( 2, selText.size() - 4 );
602
603 QgsExpressionContext expressionContext;
604 if ( context().expressionContext() )
605 expressionContext = *( context().expressionContext() );
606 else
607 expressionContext = QgsProject::instance()->createExpressionContext();
608
609 QgsExpressionBuilderDialog exprDlg( nullptr, selText, this, QStringLiteral( "generic" ), expressionContext );
610
611 exprDlg.setWindowTitle( tr( "Insert Expression" ) );
612 if ( exprDlg.exec() == QDialog::Accepted )
613 {
614 QString expression = exprDlg.expressionText();
615 if ( !expression.isEmpty() )
616 {
617 mTextEdit->insertPlainText( "[%" + expression + "%]" );
618 }
619 }
620}
621
623
SymbolRotationMode
Modes for handling how symbol and text entity rotation is handled when maps are rotated.
Definition qgis.h:525
@ RespectMapRotation
Entity is rotated along with the map.
@ IgnoreMapRotation
Entity ignores map rotation.
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MapUnits
Map units.
@ MetersInMapUnits
Meters value as Map units.
void changed()
Emitted when the alignment is changed.
A base class for property widgets for annotation items.
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the widget is shown, e.g., the associated map canvas and expression context...
void itemChanged()
Emitted when the annotation item definition in the widget is changed by the user.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
An annotation item which renders a line symbol along a line geometry.
void setSymbol(QgsLineSymbol *symbol)
Sets the symbol used to render the marker item.
QgsAnnotationLineItem * clone() override
Returns a clone of the item.
An annotation item which renders text along a line geometry.
void setOffsetFromLine(double distance)
Sets the offset distance from the line geometry() to the text's baseline.
void setOffsetFromLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the offset from line geometry() distance.
void setText(const QString &text)
Sets the text rendered by the item.
void setOffsetFromLineUnit(Qgis::RenderUnit unit)
Sets the unit for the offset from line geometry() distance.
QgsAnnotationLineTextItem * clone() override
Returns a clone of the item.
void setFormat(const QgsTextFormat &format)
Sets the text format used to render the text.
An annotation item which renders a marker symbol at a point location.
QgsAnnotationMarkerItem * clone() override
Returns a clone of the item.
void setSymbol(QgsMarkerSymbol *symbol)
Sets the symbol used to render the marker item.
An annotation item which renders a text string at a point location.
void setText(const QString &text)
Sets the text rendered by the item.
void setFormat(const QgsTextFormat &format)
Sets the text format used to render the text.
void setAngle(double angle)
Sets the text's rotation angle, in degrees clockwise.
void setAlignment(Qt::Alignment alignment)
Sets the text's alignment relative to the reference point().
QgsAnnotationPointTextItem * clone() override
Returns a clone of the item.
void setRotationMode(Qgis::SymbolRotationMode mode)
Sets the rotation mode for the text item.
An annotation item which renders a fill symbol for a polygon geometry.
void setSymbol(QgsFillSymbol *symbol)
Sets the symbol used to render the polygon item.
QgsAnnotationPolygonItem * clone() override
Returns a clone of the item.
static QgsRecentStyleHandler * recentStyleHandler()
Returns the handler for recently used style items.
A generic dialog for building expression strings.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static QgsFillSymbol * createSimple(const QVariantMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
static QgsLineSymbol * createSimple(const QVariantMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties.
static QgsMarkerSymbol * createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
void showPanel(QgsPanelWidget *panel)
Emit when you require a panel to be show in the interface.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void pushRecentSymbol(const QString &identifier, QgsSymbol *symbol)
Pushes a recently used symbol with the specified identifier.
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition qgsstyle.cpp:145
Symbol selector widget that can be used to select and build a symbol.
void symbolModified()
Emitted when a symbol is modified in the widget.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
A widget for customizing text formatting settings.
void widgetChanged()
Emitted when the text format defined by the widget changes.
QList< Qgis::RenderUnit > RenderUnitList
List of render units.