Skip to content
Permalink
Browse files

Draw vertices of unsegmentized geometry

  • Loading branch information
mhugent committed May 23, 2016
1 parent d2b2189 commit 71712ac565cec1b723e8575dd5e755ea0e6945bd
Showing with 28 additions and 66 deletions.
  1. +25 −66 src/core/symbology-ng/qgssymbolv2.cpp
  2. +3 −0 src/core/symbology-ng/qgssymbolv2.h
@@ -744,9 +744,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
mSymbolRenderContext->expressionContextScope()->setVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, 1 );
}

// Collection of markers to paint
QPolygonF markers;

switch ( QgsWKBTypes::flatType( segmentizedGeometry->geometry()->wkbType() ) )
{
case QgsWKBTypes::Point:
@@ -769,11 +766,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
context.painter()->setBrush( QColor( 255, 0, 0, 100 ) );
context.painter()->drawRect( static_cast<QgsMarkerSymbolV2*>( this )->bounds( pt, context, feature ) );
}

if ( drawVertexMarker )
{
markers << pt;
}
}
break;
case QgsWKBTypes::LineString:
@@ -786,11 +778,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
}
_getLineString( pts, context, QgsConstWkbPtr( segmentizedGeometry->asWkb(), segmentizedGeometry->wkbSize() ), !tileMapRendering && clipFeaturesToExtent() );
static_cast<QgsLineSymbolV2*>( this )->renderPolyline( pts, &feature, context, layer, selected );

if ( drawVertexMarker )
{
markers = pts;
}
}
break;
case QgsWKBTypes::Polygon:
@@ -804,16 +791,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
}
_getPolygon( pts, holes, context, QgsConstWkbPtr( segmentizedGeometry->asWkb(), segmentizedGeometry->wkbSize() ), !tileMapRendering && clipFeaturesToExtent() );
static_cast<QgsFillSymbolV2*>( this )->renderPolygon( pts, ( !holes.isEmpty() ? &holes : nullptr ), &feature, context, layer, selected );

if ( drawVertexMarker )
{
markers = pts;

Q_FOREACH ( const QPolygonF& hole, holes )
{
markers << hole;
}
}
}
break;

@@ -829,11 +806,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co

QgsMultiPointV2* mp = static_cast< QgsMultiPointV2* >( segmentizedGeometry->geometry() );

if ( drawVertexMarker )
{
markers.reserve( mp->numGeometries() );
}

for ( int i = 0; i < mp->numGeometries(); ++i )
{
mSymbolRenderContext->setGeometryPartNum( i + 1 );
@@ -842,11 +814,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
const QgsPointV2* point = static_cast< const QgsPointV2* >( mp->geometryN( i ) );
_getPoint( pt, context, point );
static_cast<QgsMarkerSymbolV2*>( this )->renderPoint( pt, &feature, context, layer, selected );

if ( drawVertexMarker )
{
markers.append( pt );
}
}
}
break;
@@ -881,18 +848,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
}
wkbPtr = _getLineString( pts, context, wkbPtr, !tileMapRendering && clipFeaturesToExtent() );
static_cast<QgsLineSymbolV2*>( this )->renderPolyline( pts, &feature, context, layer, selected );

if ( drawVertexMarker )
{
if ( i == 0 )
{
markers = pts;
}
else
{
markers << pts;
}
}
}
}
break;
@@ -929,23 +884,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co

wkbPtr = _getPolygon( pts, holes, context, wkbPtr, !tileMapRendering && clipFeaturesToExtent() );
static_cast<QgsFillSymbolV2*>( this )->renderPolygon( pts, ( !holes.isEmpty() ? &holes : nullptr ), &feature, context, layer, selected );

if ( drawVertexMarker )
{
if ( i == 0 )
{
markers = pts;
}
else
{
markers << pts;
}

Q_FOREACH ( const QPolygonF& hole, holes )
{
markers << hole;
}
}
}
break;
}
@@ -974,11 +912,27 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co

if ( drawVertexMarker )
{
Q_FOREACH ( QPointF marker, markers )
const QgsCoordinateTransform* ct = context.coordinateTransform();
const QgsMapToPixel& mtp = context.mapToPixel();

QgsPointV2 vertexPoint;
QgsVertexId vertexId;
double x, y, z;
QPointF mapPoint;
while ( geom->geometry()->nextVertex( vertexId, vertexPoint ) )
{
QgsVectorLayer::drawVertexMarker( marker.x(), marker.y(), *context.painter(),
static_cast< QgsVectorLayer::VertexMarkerType >( currentVertexMarkerType ),
currentVertexMarkerSize );
//transform
x = vertexPoint.x();
y = vertexPoint.y();
z = vertexPoint.z();
if ( ct )
{
ct->transformInPlace( x, y, z );
}
mapPoint.setX( x );
mapPoint.setY( y );
mtp.transformInPlace( mapPoint.rx(), mapPoint.ry() );
renderVertexMarker( mapPoint, context, currentVertexMarkerType, currentVertexMarkerSize );
}
}

@@ -996,6 +950,11 @@ QgsSymbolV2RenderContext* QgsSymbolV2::symbolRenderContext()
return mSymbolRenderContext;
}

void QgsSymbolV2::renderVertexMarker( QPointF& pt, QgsRenderContext& context, int currentVertexMarkerType, int currentVertexMarkerSize )
{
QgsVectorLayer::drawVertexMarker( pt.x(), pt.y(), *context.painter(), static_cast< QgsVectorLayer::VertexMarkerType >( currentVertexMarkerType ), currentVertexMarkerSize );
}

////////////////////


@@ -315,6 +315,9 @@ class CORE_EXPORT QgsSymbolV2
//! @deprecated since 2.14, use QgsSymbolLayerV2::isCompatibleWithSymbol instead
Q_DECL_DEPRECATED bool isSymbolLayerCompatible( SymbolType layerType );

//! render editing vertex marker at specified point
void renderVertexMarker( QPointF& pt, QgsRenderContext& context, int currentVertexMarkerType, int currentVertexMarkerSize );

SymbolType mType;
QgsSymbolLayerV2List mLayers;

5 comments on commit 71712ac

@ahuarte47

This comment has been minimized.

Copy link
Contributor

@ahuarte47 ahuarte47 replied May 31, 2016

Hi @mhugent, about this change, the "_getLineString" and "_getPolygon" methods return the simplified point array of the original geometry. It will be faster use them to paint the markers. Sorry, what is the reason about this change? Can I restore the original code?

Kind regards
Alvaro

@mhugent

This comment has been minimized.

Copy link
Contributor Author

@mhugent mhugent replied May 31, 2016

Sorry, what is the reason about this change? Can I restore the original code?

The reason is that we see the real vertices for curved geometries (not the segmented vertices). Please don't restore the original code. It is important to see the correct geometry vertices for editing (where the markers are shown).

@ahuarte47

This comment has been minimized.

Copy link
Contributor

@ahuarte47 ahuarte47 replied May 31, 2016

Ok, thanks, I see it. I would like to propose this pull ( #3155 ). Do you agree?

@mhugent

This comment has been minimized.

Copy link
Contributor Author

@mhugent mhugent replied May 31, 2016

Ok, looks good to me.

@ahuarte47

This comment has been minimized.

Copy link
Contributor

@ahuarte47 ahuarte47 replied May 31, 2016

ok, thanks @mhugent

Please sign in to comment.
You can’t perform that action at this time.