Skip to content

Commit 71712ac

Browse files
committedMay 23, 2016
Draw vertices of unsegmentized geometry
1 parent d2b2189 commit 71712ac

File tree

2 files changed

+28
-66
lines changed

2 files changed

+28
-66
lines changed
 

‎src/core/symbology-ng/qgssymbolv2.cpp

Lines changed: 25 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
744744
mSymbolRenderContext->expressionContextScope()->setVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, 1 );
745745
}
746746

747-
// Collection of markers to paint
748-
QPolygonF markers;
749-
750747
switch ( QgsWKBTypes::flatType( segmentizedGeometry->geometry()->wkbType() ) )
751748
{
752749
case QgsWKBTypes::Point:
@@ -769,11 +766,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
769766
context.painter()->setBrush( QColor( 255, 0, 0, 100 ) );
770767
context.painter()->drawRect( static_cast<QgsMarkerSymbolV2*>( this )->bounds( pt, context, feature ) );
771768
}
772-
773-
if ( drawVertexMarker )
774-
{
775-
markers << pt;
776-
}
777769
}
778770
break;
779771
case QgsWKBTypes::LineString:
@@ -786,11 +778,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
786778
}
787779
_getLineString( pts, context, QgsConstWkbPtr( segmentizedGeometry->asWkb(), segmentizedGeometry->wkbSize() ), !tileMapRendering && clipFeaturesToExtent() );
788780
static_cast<QgsLineSymbolV2*>( this )->renderPolyline( pts, &feature, context, layer, selected );
789-
790-
if ( drawVertexMarker )
791-
{
792-
markers = pts;
793-
}
794781
}
795782
break;
796783
case QgsWKBTypes::Polygon:
@@ -804,16 +791,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
804791
}
805792
_getPolygon( pts, holes, context, QgsConstWkbPtr( segmentizedGeometry->asWkb(), segmentizedGeometry->wkbSize() ), !tileMapRendering && clipFeaturesToExtent() );
806793
static_cast<QgsFillSymbolV2*>( this )->renderPolygon( pts, ( !holes.isEmpty() ? &holes : nullptr ), &feature, context, layer, selected );
807-
808-
if ( drawVertexMarker )
809-
{
810-
markers = pts;
811-
812-
Q_FOREACH ( const QPolygonF& hole, holes )
813-
{
814-
markers << hole;
815-
}
816-
}
817794
}
818795
break;
819796

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

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

832-
if ( drawVertexMarker )
833-
{
834-
markers.reserve( mp->numGeometries() );
835-
}
836-
837809
for ( int i = 0; i < mp->numGeometries(); ++i )
838810
{
839811
mSymbolRenderContext->setGeometryPartNum( i + 1 );
@@ -842,11 +814,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
842814
const QgsPointV2* point = static_cast< const QgsPointV2* >( mp->geometryN( i ) );
843815
_getPoint( pt, context, point );
844816
static_cast<QgsMarkerSymbolV2*>( this )->renderPoint( pt, &feature, context, layer, selected );
845-
846-
if ( drawVertexMarker )
847-
{
848-
markers.append( pt );
849-
}
850817
}
851818
}
852819
break;
@@ -881,18 +848,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
881848
}
882849
wkbPtr = _getLineString( pts, context, wkbPtr, !tileMapRendering && clipFeaturesToExtent() );
883850
static_cast<QgsLineSymbolV2*>( this )->renderPolyline( pts, &feature, context, layer, selected );
884-
885-
if ( drawVertexMarker )
886-
{
887-
if ( i == 0 )
888-
{
889-
markers = pts;
890-
}
891-
else
892-
{
893-
markers << pts;
894-
}
895-
}
896851
}
897852
}
898853
break;
@@ -929,23 +884,6 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
929884

930885
wkbPtr = _getPolygon( pts, holes, context, wkbPtr, !tileMapRendering && clipFeaturesToExtent() );
931886
static_cast<QgsFillSymbolV2*>( this )->renderPolygon( pts, ( !holes.isEmpty() ? &holes : nullptr ), &feature, context, layer, selected );
932-
933-
if ( drawVertexMarker )
934-
{
935-
if ( i == 0 )
936-
{
937-
markers = pts;
938-
}
939-
else
940-
{
941-
markers << pts;
942-
}
943-
944-
Q_FOREACH ( const QPolygonF& hole, holes )
945-
{
946-
markers << hole;
947-
}
948-
}
949887
}
950888
break;
951889
}
@@ -974,11 +912,27 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
974912

975913
if ( drawVertexMarker )
976914
{
977-
Q_FOREACH ( QPointF marker, markers )
915+
const QgsCoordinateTransform* ct = context.coordinateTransform();
916+
const QgsMapToPixel& mtp = context.mapToPixel();
917+
918+
QgsPointV2 vertexPoint;
919+
QgsVertexId vertexId;
920+
double x, y, z;
921+
QPointF mapPoint;
922+
while ( geom->geometry()->nextVertex( vertexId, vertexPoint ) )
978923
{
979-
QgsVectorLayer::drawVertexMarker( marker.x(), marker.y(), *context.painter(),
980-
static_cast< QgsVectorLayer::VertexMarkerType >( currentVertexMarkerType ),
981-
currentVertexMarkerSize );
924+
//transform
925+
x = vertexPoint.x();
926+
y = vertexPoint.y();
927+
z = vertexPoint.z();
928+
if ( ct )
929+
{
930+
ct->transformInPlace( x, y, z );
931+
}
932+
mapPoint.setX( x );
933+
mapPoint.setY( y );
934+
mtp.transformInPlace( mapPoint.rx(), mapPoint.ry() );
935+
renderVertexMarker( mapPoint, context, currentVertexMarkerType, currentVertexMarkerSize );
982936
}
983937
}
984938

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

953+
void QgsSymbolV2::renderVertexMarker( QPointF& pt, QgsRenderContext& context, int currentVertexMarkerType, int currentVertexMarkerSize )
954+
{
955+
QgsVectorLayer::drawVertexMarker( pt.x(), pt.y(), *context.painter(), static_cast< QgsVectorLayer::VertexMarkerType >( currentVertexMarkerType ), currentVertexMarkerSize );
956+
}
957+
999958
////////////////////
1000959

1001960

‎src/core/symbology-ng/qgssymbolv2.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ class CORE_EXPORT QgsSymbolV2
315315
//! @deprecated since 2.14, use QgsSymbolLayerV2::isCompatibleWithSymbol instead
316316
Q_DECL_DEPRECATED bool isSymbolLayerCompatible( SymbolType layerType );
317317

318+
//! render editing vertex marker at specified point
319+
void renderVertexMarker( QPointF& pt, QgsRenderContext& context, int currentVertexMarkerType, int currentVertexMarkerSize );
320+
318321
SymbolType mType;
319322
QgsSymbolLayerV2List mLayers;
320323

5 commit comments

Comments
 (5)

ahuarte47 commented on May 31, 2016

@ahuarte47
Contributor

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 commented on May 31, 2016

@mhugent
ContributorAuthor

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 commented on May 31, 2016

@ahuarte47
Contributor

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

mhugent commented on May 31, 2016

@mhugent
ContributorAuthor

Ok, looks good to me.

ahuarte47 commented on May 31, 2016

@ahuarte47
Contributor

ok, thanks @mhugent

Please sign in to comment.