Slightly improved markers for highlighted nodes and circular nodes

This commit is contained in:
Martin Dobias 2017-04-05 16:10:46 +08:00
parent 52113d7c38
commit 61ace1cc61
4 changed files with 34 additions and 3 deletions

View File

@ -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 );

View File

@ -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 ) )
@ -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 );
}

View File

@ -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 );
}
}
}
}

View File

@ -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,
};
/**