|
| 1 | +/************************************************************************ |
| 2 | + * This file has been generated automatically from * |
| 3 | + * * |
| 4 | + * src/core/layout/qgslayoutitemnodeitem.h * |
| 5 | + * * |
| 6 | + * Do not edit manually ! Edit header and run scripts/sipify.pl again * |
| 7 | + ************************************************************************/ |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +class QgsLayoutNodesItem: QgsLayoutItem |
| 13 | +{ |
| 14 | +%Docstring |
| 15 | + An abstract layout item that provides generic methods for node based |
| 16 | + shapes such as polygon or polylines. |
| 17 | +.. versionadded:: 3.0 |
| 18 | +%End |
| 19 | + |
| 20 | +%TypeHeaderCode |
| 21 | +#include "qgslayoutitemnodeitem.h" |
| 22 | +%End |
| 23 | + public: |
| 24 | + |
| 25 | + bool addNode( QPointF point, bool checkArea = true, double radius = 10 ); |
| 26 | +%Docstring |
| 27 | + Add a node in current shape. |
| 28 | + \param point is the location of the new node (in scene coordinates) |
| 29 | + \param checkArea is a flag to indicate if there's a space constraint. |
| 30 | + \param radius is the space contraint and is used only if checkArea is |
| 31 | + true. Typically, if this flag is true, the new node has to be nearer |
| 32 | + than radius to the shape to be added. |
| 33 | + :rtype: bool |
| 34 | +%End |
| 35 | + |
| 36 | + void setDisplayNodes( bool display = true ); |
| 37 | +%Docstring |
| 38 | + Set whether the item's nodes should be displayed. |
| 39 | +%End |
| 40 | + |
| 41 | + bool moveNode( int index, QPointF node ); |
| 42 | +%Docstring |
| 43 | + Moves a node to a new position. |
| 44 | + \param index the index of the node to move |
| 45 | + \param node is the new position in scene coordinate |
| 46 | + :rtype: bool |
| 47 | +%End |
| 48 | + |
| 49 | + int nodeAtPosition( QPointF point, bool searchInRadius = true, double radius = 10 ) const; |
| 50 | +%Docstring |
| 51 | + Search for the nearest node in the shape within a maximal area. Returns the |
| 52 | + index of the nearest node or -1 if no node was found. |
| 53 | + \param point is the location to search for nodes from (in scene coordinates) |
| 54 | + \param searchInRadius is a flag to indicate if the area of research is |
| 55 | + limited in space. |
| 56 | + \param radius is only used if searchInRadius is true |
| 57 | + :rtype: int |
| 58 | +%End |
| 59 | + |
| 60 | + bool nodePosition( int index, QPointF &position ) const; |
| 61 | +%Docstring |
| 62 | + Gets the position of a node in scene coordinates. |
| 63 | + \param index of the node |
| 64 | + \param position the position of the node |
| 65 | + :return: true if the index is valid and the position is set, false otherwise |
| 66 | + :rtype: bool |
| 67 | +%End |
| 68 | + |
| 69 | + bool removeNode( int index ); |
| 70 | +%Docstring |
| 71 | + Remove a node with specified ``index`` from the shape. |
| 72 | + :rtype: bool |
| 73 | +%End |
| 74 | + |
| 75 | + int nodesSize() const; |
| 76 | +%Docstring |
| 77 | +Returns the number of nodes in the shape. |
| 78 | + :rtype: int |
| 79 | +%End |
| 80 | + |
| 81 | + bool setSelectedNode( int index ); |
| 82 | +%Docstring |
| 83 | + Selects a node by ``index``. |
| 84 | + :rtype: bool |
| 85 | +%End |
| 86 | + |
| 87 | + int selectedNode() const; |
| 88 | +%Docstring |
| 89 | + Returns the currently selected node, or -1 if no node is selected. |
| 90 | + :rtype: int |
| 91 | +%End |
| 92 | + |
| 93 | + void deselectNode(); |
| 94 | +%Docstring |
| 95 | + Deselects any selected nodes. |
| 96 | +%End |
| 97 | + |
| 98 | + QPolygonF nodes() const; |
| 99 | +%Docstring |
| 100 | + Returns the nodes the shape consists of. |
| 101 | + :rtype: QPolygonF |
| 102 | +%End |
| 103 | + |
| 104 | + protected: |
| 105 | + |
| 106 | + QgsLayoutNodesItem( QgsLayout *layout ); |
| 107 | +%Docstring |
| 108 | + Constructor |
| 109 | + \param tagName tag used in XML file |
| 110 | + \param layout parent layout |
| 111 | +%End |
| 112 | + |
| 113 | + QgsLayoutNodesItem( const QPolygonF &polygon, QgsLayout *layout ); |
| 114 | +%Docstring |
| 115 | + Constructor |
| 116 | + \param tagName tag used in XML file |
| 117 | + \param polygon nodes of the shape |
| 118 | + \param layout parent layout |
| 119 | +%End |
| 120 | + |
| 121 | + virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ); |
| 122 | + |
| 123 | + virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const; |
| 124 | + |
| 125 | + virtual bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ); |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + virtual bool _addNode( const int nodeIndex, QPointF newNode, const double radius ) = 0; |
| 130 | +%Docstring |
| 131 | +Method called in addNode. |
| 132 | + :rtype: bool |
| 133 | +%End |
| 134 | + |
| 135 | + virtual bool _removeNode( const int nodeIndex ) = 0; |
| 136 | +%Docstring |
| 137 | +Method called in removeNode. |
| 138 | + :rtype: bool |
| 139 | +%End |
| 140 | + |
| 141 | + virtual void _draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0; |
| 142 | +%Docstring |
| 143 | +Method called in paint. |
| 144 | +%End |
| 145 | + |
| 146 | + virtual void _readXmlStyle( const QDomElement &elmt, const QgsReadWriteContext &context ) = 0; |
| 147 | +%Docstring |
| 148 | +Method called in readXml. |
| 149 | +%End |
| 150 | + |
| 151 | + virtual void _writeXmlStyle( QDomDocument &doc, QDomElement &elmt, const QgsReadWriteContext &context ) const = 0; |
| 152 | +%Docstring |
| 153 | +Method called in writeXml. |
| 154 | +%End |
| 155 | + |
| 156 | + void rescaleToFitBoundingBox(); |
| 157 | +%Docstring |
| 158 | + Rescale the current shape according to the item's bounding box. Useful when |
| 159 | + the shape is resized thanks to the rubber band. |
| 160 | +%End |
| 161 | + |
| 162 | + double computeDistance( QPointF pt1, QPointF pt2 ) const; |
| 163 | +%Docstring |
| 164 | +Compute an euclidian distance between 2 nodes. |
| 165 | + :rtype: float |
| 166 | +%End |
| 167 | + |
| 168 | + void updateSceneRect(); |
| 169 | +%Docstring |
| 170 | +Update the current scene rectangle for this item. |
| 171 | +%End |
| 172 | + |
| 173 | +}; |
| 174 | + |
| 175 | +/************************************************************************ |
| 176 | + * This file has been generated automatically from * |
| 177 | + * * |
| 178 | + * src/core/layout/qgslayoutitemnodeitem.h * |
| 179 | + * * |
| 180 | + * Do not edit manually ! Edit header and run scripts/sipify.pl again * |
| 181 | + ************************************************************************/ |
0 commit comments