QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
33 createDefaultPolygonStyleSymbol();
39 createDefaultPolygonStyleSymbol();
62 mPolygon.insert( indexPoint + 1, newPoint );
66 void QgsLayoutItemPolygon::createDefaultPolygonStyleSymbol()
69 properties.insert( QStringLiteral(
"color" ), QStringLiteral(
"white" ) );
70 properties.insert( QStringLiteral(
"style" ), QStringLiteral(
"solid" ) );
71 properties.insert( QStringLiteral(
"style_border" ), QStringLiteral(
"solid" ) );
72 properties.insert( QStringLiteral(
"color_border" ), QStringLiteral(
"black" ) );
73 properties.insert( QStringLiteral(
"width_border" ), QStringLiteral(
"0.3" ) );
74 properties.insert( QStringLiteral(
"joinstyle" ), QStringLiteral(
"miter" ) );
81 void QgsLayoutItemPolygon::refreshSymbol()
83 if (
auto *lLayout =
layout() )
96 if ( !
id().isEmpty() )
99 return tr(
"<Polygon>" );
104 if ( mPolygonStyleSymbol )
123 QPolygonF path = mapToScene(
mPolygon );
125 if ( path.at( 0 ) != path.constLast() )
126 path << path.at( 0 );
134 QTransform t = QTransform::fromScale( scale, scale );
136 QVector<QPolygonF> rings;
137 QPainterPath polygonPath;
141 mPolygonStyleSymbol->renderPolygon( polygonPath.toFillPolygon( t ), &rings,
148 mPolygonStyleSymbol.reset( QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( elmt, context ) );
160 mPolygonStyleSymbol.get(),
163 elmt.appendChild( pe );
168 if ( index < 0 || index >=
mPolygon.size() )
177 int newSelectNode = index;
@ LayoutPolygon
Polygon shape item.
QString id() const
Returns the item's ID name.
const QgsLayout * layout() const
Returns the layout the object is attached to.
void setSymbol(QgsFillSymbol *symbol)
Sets the symbol used to draw the shape.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
double mMaxSymbolBleed
Max symbol bleed.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
The class is used as a container of context for various read/write operations on other objects.
QgsFillSymbol * symbol()
Returns the fill symbol used to draw the shape.
A symbol entity for QgsStyle databases.
void _readXmlStyle(const QDomElement &elmt, const QgsReadWriteContext &context) override
Method called in readXml.
Contains settings and helpers relating to a render of a QgsLayoutItem.
Contains information about the context of a rendering operation.
An interface for classes which can visit style entity (e.g.
@ RenderMillimeters
Millimeters.
bool setSelectedNode(int index)
Selects a node by index.
Contains information relating to the style entity currently being visited.
void updateSceneRect()
Update the current scene rectangle for this item.
@ FlagProvidesClipPath
Item can act as a clipping path provider (see clipPath())
QPolygonF mPolygon
Shape's nodes.
QgsLayoutItemPolygon(QgsLayout *layout)
Constructor for QgsLayoutItemPolygon for the specified layout.
static QgsRenderContext createRenderContextForLayout(QgsLayout *layout, QPainter *painter, double dpi=-1)
Creates a render context suitable for the specified layout and painter destination.
QgsGeometry clipPath() const override
Returns the clipping path generated by this item, in layout coordinates.
QString displayName() const override
Gets item display name.
void frameChanged()
Emitted if the item's frame style changes.
void _writeXmlStyle(QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context) const override
Method called in writeXml.
QgsLayoutItem::Flags itemFlags() const override
Returns the item's flags, which indicate how the item behaves.
virtual Flags itemFlags() const
Returns the item's flags, which indicate how the item behaves.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
virtual QString uuid() const
Returns the item identification string.
bool _removeNode(int nodeIndex) override
Method called in removeNode.
QMap< QString, QString > QgsStringMap
void _draw(QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle=nullptr) override
Method called in paint.
A geometry is the spatial representation of a feature.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
bool _addNode(int indexPoint, QPointF newPoint, double radius) override
Method called in addNode.
An abstract layout item that provides generic methods for node based shapes such as polygon or polyli...
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
Layout item for node based polygon shapes.
static QgsLayoutItemPolygon * create(QgsLayout *layout)
Returns a new polygon item for the specified layout.
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
static double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
QIcon icon() const override
Returns the item's icon.
int type() const override