Update selected vertices when drawing in select mode

This is a better solution to catching and drawing new verteices that
got added because a user double clicked on a line.
This commit is contained in:
Bryan Housel
2017-12-19 09:08:59 -05:00
parent 7a8f50c74e
commit 563c496a65
3 changed files with 15 additions and 13 deletions
+1 -2
View File
@@ -13,8 +13,7 @@ import { behaviorDraw } from './draw';
import {
geoChooseEdge,
geoEdgeEqual,
geoViewportEdge
geoEdgeEqual
} from '../geo';
import {
+9 -1
View File
@@ -208,7 +208,7 @@ export function rendererMap(context) {
all = context.features().filter(all, graph);
surface.selectAll('.data-layer-osm')
.call(drawVertices.drawSelected, graph, all, map.extent())
.call(drawVertices.drawSelected, graph, map.extent())
.call(drawMidpoints, graph, all, filter, map.trimmedExtent());
dispatch.call('drawn', this, { full: false });
@@ -269,6 +269,7 @@ export function rendererMap(context) {
function drawVector(difference, extent) {
var mode = context.mode();
var graph = context.graph();
var features = context.features();
var all = context.intersects(map.extent());
@@ -303,6 +304,13 @@ export function rendererMap(context) {
data = features.filter(data, graph);
if (mode && mode.id === 'select') {
// update selected vertices - the user might have just double-clicked a way,
// creating a new vertex, triggering a partial redraw without a mode change
surface.selectAll('.data-layer-osm')
.call(drawVertices.drawSelected, graph, map.extent());
}
surface.selectAll('.data-layer-osm')
.call(drawVertices, graph, data, filter, map.extent(), fullRedraw)
.call(drawLines, graph, data, filter)
+5 -10
View File
@@ -287,15 +287,10 @@ export function svgVertices(projection, context) {
keep = true;
// a vertex of some importance..
} else if (geometry === 'vertex') {
if (entity.hasInterestingTags() || entity.isEndpoint(graph) || entity.isConnected(graph)) {
_currPersistent[entity.id] = entity;
keep = true;
}
// partial redraw in select mode - probably because the user double clicked a way.
if (!fullRedraw && mode && mode.id === 'select') {
_currSelected[entity.id] = entity;
}
} else if (geometry === 'vertex' &&
(entity.hasInterestingTags() || entity.isEndpoint(graph) || entity.isConnected(graph))) {
_currPersistent[entity.id] = entity;
keep = true;
}
// whatever this is, it's not a persistent vertex..
@@ -336,7 +331,7 @@ export function svgVertices(projection, context) {
// partial redraw - only update the selected items..
drawVertices.drawSelected = function(selection, graph, target, extent) {
drawVertices.drawSelected = function(selection, graph, extent) {
var wireframe = context.surface().classed('fill-wireframe');
var zoom = geoScaleToZoom(projection.scale());