31 createDefaultPolygonStyleSymbol();
37 createDefaultPolygonStyleSymbol();
60 mPolygon.insert( indexPoint + 1, newPoint );
64 void QgsLayoutItemPolygon::createDefaultPolygonStyleSymbol()
67 properties.insert( QStringLiteral(
"color" ), QStringLiteral(
"white" ) );
68 properties.insert( QStringLiteral(
"style" ), QStringLiteral(
"solid" ) );
69 properties.insert( QStringLiteral(
"style_border" ), QStringLiteral(
"solid" ) );
70 properties.insert( QStringLiteral(
"color_border" ), QStringLiteral(
"black" ) );
71 properties.insert( QStringLiteral(
"width_border" ), QStringLiteral(
"0.3" ) );
72 properties.insert( QStringLiteral(
"joinstyle" ), QStringLiteral(
"miter" ) );
79 void QgsLayoutItemPolygon::refreshSymbol()
94 if ( !
id().isEmpty() )
97 return tr(
"<Polygon>" );
104 QTransform t = QTransform::fromScale( scale, scale );
106 QList<QPolygonF> rings;
107 QPainterPath polygonPath;
111 mPolygonStyleSymbol->renderPolygon( polygonPath.toFillPolygon( t ), &rings,
118 mPolygonStyleSymbol.reset( QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( elmt, context ) );
123 mPolygonStyleSymbol.reset( static_cast<QgsFillSymbol *>( symbol->
clone() ) );
130 mPolygonStyleSymbol.get(),
133 elmt.appendChild( pe );
138 if ( index < 0 || index >=
mPolygon.size() )
147 int newSelectNode = index;
The class is used as a container of context for various read/write operations on other objects...
void updateSceneRect()
Update the current scene rectangle for this item.
QgsFillSymbol * symbol()
Returns the fill symbol used to draw the shape.
static QgsLayoutItemPolygon * create(QgsLayout *layout)
Returns a new polygon item for the specified layout.
QgsLayoutItemPolygon(QgsLayout *layout)
Constructor for QgsLayoutItemPolygon for the specified layout.
An abstract layout item that provides generic methods for node based shapes such as polygon or polyli...
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
void _writeXmlStyle(QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context) const override
Method called in writeXml.
double mMaxSymbolBleed
Max symbol bleed.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Layout item for node based polygon shapes.
QPolygonF mPolygon
Shape's nodes.
int type() const override
QgsLayoutRenderContext & renderContext()
Returns a reference to the layout's render context, which stores information relating to the current ...
QMap< QString, QString > QgsStringMap
void frameChanged()
Emitted if the item's frame style changes.
void _draw(QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle=nullptr) override
Method called in paint.
const QgsLayout * layout() const
Returns the layout the object is attached to.
QgsFillSymbol * clone() const override
Gets a deep copy of this symbol.
double dpi() const
Returns the dpi for outputting the layout.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
static QgsRenderContext createRenderContextForLayout(QgsLayout *layout, QPainter *painter, double dpi=-1)
Creates a render context suitable for the specified layout and painter destination.
QIcon icon() const override
Returns the item's icon.
static double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol.
QString id() const
Returns the item's ID name.
bool _addNode(int indexPoint, QPointF newPoint, double radius) override
Method called in addNode.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
void _readXmlStyle(const QDomElement &elmt, const QgsReadWriteContext &context) override
Method called in readXml.
bool setSelectedNode(int index)
Selects a node by index.
Contains settings and helpers relating to a render of a QgsLayoutItem.
void setSymbol(QgsFillSymbol *symbol)
Sets the symbol used to draw the shape.
Contains information about the context of a rendering operation.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
bool _removeNode(int nodeIndex) override
Method called in removeNode.
static QDomElement saveSymbol(const QString &symbolName, QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
QString displayName() const override
Gets item display name.