Skip to content

Commit

Permalink
Slightly improved markers for highlighted nodes and circular nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Apr 5, 2017
1 parent 52113d7 commit 61ace1c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
4 changes: 3 additions & 1 deletion python/gui/qgsrubberband.sip
Expand Up @@ -13,7 +13,9 @@ class QgsRubberBand: QgsMapCanvasItem
ICON_X,
ICON_BOX,
ICON_CIRCLE,
ICON_FULL_BOX
ICON_FULL_BOX,
ICON_DIAMOND,
ICON_FULL_DIAMOND
};

QgsRubberBand( QgsMapCanvas* mapCanvas /TransferThis/, QgsWkbTypes::GeometryType geometryType = QgsWkbTypes::LineGeometry );
Expand Down
3 changes: 2 additions & 1 deletion src/app/nodetool/qgsnodetool2.cpp
Expand Up @@ -656,7 +656,7 @@ void QgsNodeTool2::mouseMoveNotDragging( QgsMapMouseEvent *e )
isCircular = isCircularVertex( cachedGeometry( m.layer(), m.featureId() ), m.vertexIndex() );
}

mVertexBand->setIcon( isCircular ? QgsRubberBand::ICON_FULL_BOX : QgsRubberBand::ICON_CIRCLE );
mVertexBand->setIcon( isCircular ? QgsRubberBand::ICON_FULL_DIAMOND : QgsRubberBand::ICON_CIRCLE );
// if we are at an endpoint, let's show also the endpoint indicator
// so user can possibly add a new vertex at the end
if ( isMatchAtEndpoint( m ) )
Expand Down Expand Up @@ -1436,6 +1436,7 @@ void QgsNodeTool2::setHighlightedNodes( const QList<Vertex> &listNodes )
marker->setIconType( QgsVertexMarker::ICON_CIRCLE );
marker->setPenWidth( 3 );
marker->setColor( Qt::blue );
marker->setFillColor( Qt::blue );
marker->setCenter( toMapCoordinates( node.layer, geom.vertexAt( node.vertexId ) ) );
mSelectedNodesMarkers.append( marker );
}
Expand Down
16 changes: 16 additions & 0 deletions src/gui/qgsrubberband.cpp
Expand Up @@ -519,6 +519,22 @@ void QgsRubberBand::drawShape( QPainter *p, QVector<QPointF> &pts )
case ICON_CIRCLE:
p->drawEllipse( x - s, y - s, mIconSize, mIconSize );
break;

case ICON_DIAMOND:
case ICON_FULL_DIAMOND:
{
QPointF pts[] =
{
QPointF( x, y - s ),
QPointF( x + s, y ),
QPointF( x, y + s ),
QPointF( x - s, y )
};
if ( mIconType == ICON_FULL_DIAMOND )
p->drawPolygon( pts, 4 );
else
p->drawPolyline( pts, 4 );
}
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/gui/qgsrubberband.h
Expand Up @@ -66,7 +66,19 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
/**
* A full box is used to highlight points (■)
*/
ICON_FULL_BOX
ICON_FULL_BOX,

/**
* A diamond is used to highlight points (◇)
* @note added in QGIS 3.0
*/
ICON_DIAMOND,

/**
* A diamond is used to highlight points (◆)
* @note added in QGIS 3.0
*/
ICON_FULL_DIAMOND,
};

/**
Expand Down

0 comments on commit 61ace1c

Please sign in to comment.