QgsLayoutItemPolyline class
Layout item for node based polyline shapes.
Contents
Base classes
- class QgsLayoutNodesItem
- An abstract layout item that provides generic methods for node based shapes such as polygon or polylines.
Public types
- enum MarkerMode { NoMarker, ArrowHead, SvgMarker }
- Vertex marker mode.
Public static functions
- static auto create(QgsLayout* layout) -> QgsLayoutItemPolyline*
- Returns a new polyline item for the specified layout.
Constructors, destructors, conversion operators
- QgsLayoutItemPolyline(QgsLayout* layout)
- Constructor for QgsLayoutItemPolyline for the specified layout.
- QgsLayoutItemPolyline(const QPolygonF& polyline, QgsLayout* layout)
- Constructor for QgsLayoutItemPolyline for the specified polyline and layout.
Public functions
- auto arrowHeadFillColor() const -> QColor
- Returns the color used to fill the arrow head.
- auto arrowHeadStrokeColor() const -> QColor
- Returns the color used to draw the stroke around the the arrow head.
- auto arrowHeadStrokeWidth() const -> double
- Returns the pen width in millimeters for the stroke of the arrow head.
- auto arrowHeadWidth() const -> double
- Returns the width of line arrow heads in mm.
- auto displayName() const -> QString override
- Gets item display name.
- auto endMarker() const -> MarkerMode
- Returns the end marker mode, which controls what marker is drawn at the end of the line.
- auto endSvgMarkerPath() const -> QString
- Returns the path the an SVG marker drawn at the end of the line.
- auto icon() const -> QIcon override
- Returns the item's icon.
- void setArrowHeadFillColor(const QColor& color)
- Sets the color used to fill the arrow head.
- void setArrowHeadStrokeColor(const QColor& color)
- Sets the color used to draw the stroke around the arrow head.
- void setArrowHeadStrokeWidth(double width)
- Sets the pen width in millimeters for the stroke of the arrow head.
- void setArrowHeadWidth(double width)
- Sets the width of line arrow heads in mm.
- void setEndMarker(MarkerMode mode)
- Sets the end marker mode, which controls what marker is drawn at the end of the line.
- void setEndSvgMarkerPath(const QString& path)
- Sets the path to a SVG marker to draw at the end of the line.
- void setStartMarker(MarkerMode mode)
- Sets the start marker mode, which controls what marker is drawn at the start of the line.
- void setStartSvgMarkerPath(const QString& path)
- Sets the path to a SVG marker to draw at the start of the line.
- void setSymbol(QgsLineSymbol* symbol)
- Sets the symbol used to draw the shape.
- auto startMarker() const -> MarkerMode
- Returns the start marker mode, which controls what marker is drawn at the start of the line.
- auto startSvgMarkerPath() const -> QString
- Returns the path the an SVG marker drawn at the start of the line.
- auto symbol() -> QgsLineSymbol*
- Returns the line symbol used to draw the shape.
Protected functions
- auto _addNode(int nodeIndex, QPointF newNode, double radius) -> bool override
- Method called in addNode.
- void _draw(QgsLayoutItemRenderContext& context, const QStyleOptionGraphicsItem* itemStyle = nullptr) override
- Method called in paint.
- void _readXmlStyle(const QDomElement& elmt, const QgsReadWriteContext& context) override
- Method called in readXml.
- auto _removeNode(int nodeIndex) -> bool override
- Method called in removeNode.
- void _writeXmlStyle(QDomDocument& doc, QDomElement& elmt, const QgsReadWriteContext& context) const override
- Method called in writeXml.
- auto readPropertiesFromElement(const QDomElement& element, const QDomDocument& document, const QgsReadWriteContext& context) -> bool override
- Sets item state from a DOM element.
- auto writePropertiesToElement(QDomElement& element, QDomDocument& document, const QgsReadWriteContext& context) const -> bool override
- Stores item state within an XML DOM element.
Enum documentation
enum QgsLayoutItemPolyline:: MarkerMode
Vertex marker mode.
| Enumerators | |
|---|---|
| NoMarker |
Don't show marker. |
| ArrowHead |
Show arrow marker. |
| SvgMarker |
Show SVG marker. |
Function documentation
static QgsLayoutItemPolyline* QgsLayoutItemPolyline:: create(QgsLayout* layout)
Returns a new polyline item for the specified layout.
The caller takes responsibility for deleting the returned object.
QColor QgsLayoutItemPolyline:: arrowHeadFillColor() const
Returns the color used to fill the arrow head.
QColor QgsLayoutItemPolyline:: arrowHeadStrokeColor() const
Returns the color used to draw the stroke around the the arrow head.
double QgsLayoutItemPolyline:: arrowHeadStrokeWidth() const
Returns the pen width in millimeters for the stroke of the arrow head.
double QgsLayoutItemPolyline:: arrowHeadWidth() const
Returns the width of line arrow heads in mm.
QString QgsLayoutItemPolyline:: displayName() const override
Gets item display name.
This is the item's id if set, and if not, a user-friendly string identifying item type.
MarkerMode QgsLayoutItemPolyline:: endMarker() const
Returns the end marker mode, which controls what marker is drawn at the end of the line.
QString QgsLayoutItemPolyline:: endSvgMarkerPath() const
Returns the path the an SVG marker drawn at the end of the line.
void QgsLayoutItemPolyline:: setArrowHeadFillColor(const QColor& color)
Sets the color used to fill the arrow head.
void QgsLayoutItemPolyline:: setArrowHeadStrokeColor(const QColor& color)
Sets the color used to draw the stroke around the arrow head.
void QgsLayoutItemPolyline:: setArrowHeadStrokeWidth(double width)
Sets the pen width in millimeters for the stroke of the arrow head.
void QgsLayoutItemPolyline:: setArrowHeadWidth(double width)
Sets the width of line arrow heads in mm.
void QgsLayoutItemPolyline:: setEndMarker(MarkerMode mode)
Sets the end marker mode, which controls what marker is drawn at the end of the line.
void QgsLayoutItemPolyline:: setEndSvgMarkerPath(const QString& path)
Sets the path to a SVG marker to draw at the end of the line.
void QgsLayoutItemPolyline:: setStartMarker(MarkerMode mode)
Sets the start marker mode, which controls what marker is drawn at the start of the line.
void QgsLayoutItemPolyline:: setStartSvgMarkerPath(const QString& path)
Sets the path to a SVG marker to draw at the start of the line.
void QgsLayoutItemPolyline:: setSymbol(QgsLineSymbol* symbol)
Sets the symbol used to draw the shape.
Ownership of symbol is not transferred.
MarkerMode QgsLayoutItemPolyline:: startMarker() const
Returns the start marker mode, which controls what marker is drawn at the start of the line.
QString QgsLayoutItemPolyline:: startSvgMarkerPath() const
Returns the path the an SVG marker drawn at the start of the line.
QgsLineSymbol* QgsLayoutItemPolyline:: symbol()
Returns the line symbol used to draw the shape.
bool QgsLayoutItemPolyline:: readPropertiesFromElement(const QDomElement& element,
const QDomDocument& document,
const QgsReadWriteContext& context) override protected
Sets item state from a DOM element.
| Parameters | |
|---|---|
| element | is the DOM element for the item |
| document | DOM document |
| context | read write context |
Note that item subclasses should not rely on all other items being present in the layout at the time this method is called. Instead, any connections and links to other items must be made in the finalizeRestoreFromXml() method. E.g. when restoring a scalebar, the connection to the linked map's signals should be implemented in finalizeRestoreFromXml(), not readPropertiesFromElement().
bool QgsLayoutItemPolyline:: writePropertiesToElement(QDomElement& element,
QDomDocument& document,
const QgsReadWriteContext& context) const override protected
Stores item state within an XML DOM element.
| Parameters | |
|---|---|
| element | is the DOM element to store the item's properties in |
| document | DOM document |
| context | read write context |