31#include "moc_qgslayoutitempolygon.cpp"
36 createDefaultPolygonStyleSymbol();
42 createDefaultPolygonStyleSymbol();
67 mPolygon.insert( indexPoint + 1, newPoint );
71void QgsLayoutItemPolygon::createDefaultPolygonStyleSymbol()
73 QVariantMap properties;
74 properties.insert( QStringLiteral(
"color" ), QStringLiteral(
"white" ) );
75 properties.insert( QStringLiteral(
"style" ), QStringLiteral(
"solid" ) );
76 properties.insert( QStringLiteral(
"style_border" ), QStringLiteral(
"solid" ) );
77 properties.insert( QStringLiteral(
"color_border" ), QStringLiteral(
"black" ) );
78 properties.insert( QStringLiteral(
"width_border" ), QStringLiteral(
"0.3" ) );
79 properties.insert( QStringLiteral(
"joinstyle" ), QStringLiteral(
"miter" ) );
86void QgsLayoutItemPolygon::refreshSymbol()
88 if (
auto *lLayout =
layout() )
101 if ( !
id().isEmpty() )
104 return tr(
"<Polygon>" );
109 if ( mPolygonStyleSymbol )
128 QPolygonF path = mapToScene(
mPolygon );
130 if ( path.at( 0 ) != path.constLast() )
131 path << path.at( 0 );
139 QList<QPointF> uniquePoints;
143 if ( !uniquePoints.contains( point ) )
145 uniquePoints.append( point );
155 return mPolygonStyleSymbol.get();
167 const QTransform t = QTransform::fromScale( scale, scale );
169 const QVector<QPolygonF> rings;
170 QPainterPath polygonPath;
173 mPolygonStyleSymbol->startRender( renderContext );
174 mPolygonStyleSymbol->renderPolygon( polygonPath.toFillPolygon( t ), &rings,
175 nullptr, renderContext );
176 mPolygonStyleSymbol->stopRender( renderContext );
193 mPolygonStyleSymbol.get(),
196 elmt.appendChild( pe );
206 int newSelectNode = index;
@ Millimeters
Millimeters.
@ DisableSymbolClippingToExtent
Force symbol clipping to map extent to be disabled in all situations. This will result in slower rend...
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
static std::unique_ptr< QgsFillSymbol > createSimple(const QVariantMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
A geometry is the spatial representation of a feature.
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
QIcon icon() const override
Returns the item's icon.
int type() const override
static QgsLayoutItemPolygon * create(QgsLayout *layout)
Returns a new polygon item for the specified layout.
QgsLayoutItemPolygon(QgsLayout *layout)
Constructor for QgsLayoutItemPolygon for the specified layout.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
QgsGeometry clipPath() const override
Returns the clipping path generated by this item, in layout coordinates.
void setSymbol(QgsFillSymbol *symbol)
Sets the symbol used to draw the shape.
bool isValid() const override
Must be reimplemented in subclasses.
QgsFillSymbol * symbol()
Returns the fill symbol used to draw the shape.
bool _removeNode(int nodeIndex) override
Method called in removeNode.
void _draw(QgsLayoutItemRenderContext &context, const QStyleOptionGraphicsItem *itemStyle=nullptr) override
Method called in paint.
~QgsLayoutItemPolygon() override
bool _addNode(int indexPoint, QPointF newPoint, double radius) override
Method called in addNode.
void _writeXmlStyle(QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context) const override
Method called in writeXml.
void _readXmlStyle(const QDomElement &elmt, const QgsReadWriteContext &context) override
Method called in readXml.
QgsLayoutItem::Flags itemFlags() const override
Returns the item's flags, which indicate how the item behaves.
QString displayName() const override
Gets item display name.
@ LayoutPolygon
Polygon shape item.
Contains settings and helpers relating to a render of a QgsLayoutItem.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
@ FlagProvidesClipPath
Item can act as a clipping path provider (see clipPath()).
virtual QString uuid() const
Returns the item identification string.
QString id() const
Returns the item's ID name.
void frameChanged()
Emitted if the item's frame style changes.
QgsLayoutItem::Flags itemFlags() const override
Returns the item's flags, which indicate how the item behaves.
double mMaxSymbolBleed
Max symbol bleed.
bool setSelectedNode(int index)
Selects a node by index.
void updateSceneRect()
Update the current scene rectangle for this item.
QgsLayoutNodesItem(QgsLayout *layout)
Constructor for QgsLayoutNodesItem, attached to the specified layout.
QPolygonF mPolygon
Shape's nodes.
const QgsLayout * layout() const
Returns the layout the object is attached to.
static QgsRenderContext createRenderContextForLayout(QgsLayout *layout, QPainter *painter, double dpi=-1)
Creates a render context suitable for the specified layout and painter destination.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected).
An interface for classes which can visit style entity (e.g.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
A symbol entity for QgsStyle databases.
static std::unique_ptr< QgsSymbol > loadSymbol(const QDomElement &element, const QgsReadWriteContext &context)
Attempts to load a symbol from a DOM element.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
static double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol.
Contains information relating to the style entity currently being visited.