56   return sqrt( pow( pt1.
x() - pt2.
x(), 2 ) + pow( pt1.
y() - pt2.
y(), 2 ) );
    65   double maxDistance = ( checkArea ) ? radius : minDistance;
    78     const double coef = ( pt2.
y() - pt1.
y() ) / ( pt2.
x() - pt1.
x() );
    79     const double b = pt1.
y() - coef * pt1.
x();
    83       distance = qAbs( pt1.
x() - start.
x() );
    86       const double coef2 = ( -1 / coef );
    87       const double b2 = start.
y() - coef2 * start.
x();
    90       if ( qIsInf( coef2 ) )
    92         distance = qAbs( pt1.
y() - start.
y() );
    93         inter.
setX( start.
x() );
    94         inter.
setY( pt1.
y() );
    98         const double interx = ( b - b2 ) / ( coef2 - coef );
    99         const double intery = interx * coef2 + b2;
   100         inter.
setX( interx );
   101         inter.
setY( intery );
   108       const double length4 = length1 + length2;
   110       if ( qAbs( length3 - length4 ) < std::numeric_limits<float>::epsilon() )
   114     if ( distance < minDistance && distance < maxDistance )
   116       minDistance = distance;
   123     rc = 
_addNode( idx, start, maxDistance );
   130 void QgsComposerNodesItem::drawNodes( 
QPainter *painter )
 const   135   properties.
insert( 
"name", 
"cross" );
   136   properties.
insert( 
"color_border", 
"red" );
   140   symbol.
data()->setSize( rectSize );
   141   symbol.
data()->setAngle( 45 );
   154   symbol.
data()->startRender( context );
   157     symbol.
data()->renderPoint( pt, 
nullptr, context );
   159   symbol.
data()->stopRender( context );
   161   if ( mSelectedNode >= 0 && mSelectedNode < 
mPolygon.
size() )
   162     drawSelectedNode( painter );
   165 void QgsComposerNodesItem::drawSelectedNode( 
QPainter *painter )
 const   170   properties.
insert( 
"name", 
"square" );
   171   properties.
insert( 
"color", 
"0, 0, 0, 0" );
   172   properties.
insert( 
"color_border", 
"blue" );
   173   properties.
insert( 
"width_border", 
"4" );
   177   symbol.
data()->setSize( rectSize );
   190   symbol.
data()->startRender( context );
   191   symbol.
data()->renderPoint( 
mPolygon.
at( mSelectedNode ), 
nullptr, context );
   192   symbol.
data()->stopRender( context );
   199   Q_UNUSED( itemStyle );
   211   painter->
setPen( Qt::NoPen );
   219     drawNodes( painter );
   225     const bool searchInRadius,
   226     const double radius )
   230   double maxDistance = ( searchInRadius ) ? radius : nearestDistance;
   238     if ( distance < nearestDistance && distance < maxDistance )
   240       nearestDistance = distance;
   290   if ( !composerItemList.
isEmpty() )
   302   if ( !styleSymbolElem.
isNull() )
   308   for ( 
int i = 0; i < nodesList.
size(); i++ )
   332   trans = trans.
scale( ratioX, ratioY );
   342     mSelectedNode = 
index;
   386   return _writeXML( composerPolygonElem, doc );
 bool moveNode(const int index, const QPointF &node)
Move a node to a new position. 
 
void setForceVectorOutput(bool force)
 
QDomNodeList elementsByTagName(const QString &tagname) const
 
static QgsMarkerSymbolV2 * createSimple(const QgsStringMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties. 
 
QPolygonF mPolygon
Storage meaning for shape's nodes. 
 
double horizontalViewScaleFactor() const
Returns the zoom factor of the graphics view. 
 
bool removeNode(const int index)
Remove a node from the shape. 
 
int nodeAtPosition(QPointF node, const bool searchInRadius=true, const double radius=10)
Search the nearest node in shape within a maximal area. 
 
bool shouldDrawItem() const
Returns whether the item should be drawn in the current context. 
 
void setRenderHint(RenderHint hint, bool on)
 
virtual void _readXMLStyle(const QDomElement &elmt)=0
Method called in readXML. 
 
QDomNode appendChild(const QDomNode &newChild)
 
void append(const T &value)
 
QString attribute(const QString &name, const QString &defValue) const
 
virtual void _writeXMLStyle(QDomDocument &doc, QDomElement &elmt) const =0
Method called in writeXML. 
 
void itemChanged()
Emitted when the item changes. 
 
virtual bool _removeNode(const int nodeIndex)=0
Method called in removeNode. 
 
const_iterator constEnd() const
 
A item that forms part of a map composition. 
 
QPolygonF translated(qreal dx, qreal dy) const
 
void setOutputDpi(double dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels. 
 
bool _writeXML(QDomElement &itemElem, QDomDocument &doc) const
Writes parameter that are not subclass specific in document. 
 
double toDouble(bool *ok) const
 
virtual QgsExpressionContext * createExpressionContext() const override
Creates an expression context relating to the item's current state. 
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference) 
 
void update(const QRectF &rect)
 
double computeDistance(const QPointF &pt1, const QPointF &pt2) const
Compute an euclidian distance between 2 nodes. 
 
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
Sets state from Dom document. 
 
The QgsMapSettings class contains configuration for rendering of the map. 
 
bool _readXML(const QDomElement &itemElem, const QDomDocument &doc)
Reads parameter that are not subclass specific in document. 
 
QDomElement toElement() const
 
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal. 
 
virtual QRectF boundingRect() const
 
void updateSceneRect()
Update the current scene rectangle for this item. 
 
QString number(int n, int base)
 
bool addNode(const QPointF &pt, const bool checkArea=true, const double radius=10)
Add a node in current shape. 
 
void setPen(const QColor &color)
 
void setAttribute(const QString &name, const QString &value)
 
bool nodePosition(const int index, QPointF &position)
Gets the position of a node in scene coordinate. 
 
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
Reimplementation of QCanvasItem::paint - draw on canvas. 
 
QPointF mapFromScene(const QPointF &point) const
 
QPaintDevice * device() const
 
virtual bool _addNode(const int nodeIndex, const QPointF &newNode, const double radius)=0
Method called in addNode. 
 
void translate(qreal dx, qreal dy)
 
void setBrush(const QBrush &brush)
 
void setPainter(QPainter *p)
 
bool setSelectedNode(const int index)
Select a node. 
 
virtual void _draw(QPainter *painter)=0
Method called in paint. 
 
void rescaleToFitBoundingBox()
Rescale the current shape according to the boudning box. 
 
void prepareGeometryChange()
 
Graphics scene for map printing. 
 
const QgsMapSettings & mapSettings() const
Return setting of QGIS map canvas. 
 
QgsComposition * mComposition
 
QgsComposerNodesItem(QString mTagName, QgsComposition *c)
Constructor. 
 
const T & at(int i) const
 
const_iterator constBegin() const
 
Contains information about the context of a rendering operation. 
 
QRectF boundingRect() const
 
QPointF mapToScene(const QPointF &point) const
 
const QgsComposition * composition() const
Returns the composition the item is attached to. 
 
virtual void setItemRotation(const double r, const bool adjustPosition=false)
Sets the item rotation. 
 
~QgsComposerNodesItem()
Destructor. 
 
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings 
 
QDomElement firstChildElement(const QString &tagName) const
 
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
 
void replace(int i, const T &value)
 
iterator insert(const Key &key, const T &value)
 
bool writeXML(QDomElement &elem, QDomDocument &doc) const override
Stores state in Dom element. 
 
QDomElement createElement(const QString &tagName)
 
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context. 
 
QDomNode at(int index) const