Commit 9ed93264 authored by hertzhaft's avatar hertzhaft

seems we need not save editable state when drawing a shape

parent 6caf1ca6
...@@ -629,7 +629,7 @@ ...@@ -629,7 +629,7 @@
var pt = geom.position(evt); var pt = geom.position(evt);
// setup shape // setup shape
var p = data.imgTrafo.invtransform(pt); var p = data.imgTrafo.invtransform(pt);
var vtxidx = 1; var vtx = 1;
if (shapeType === 'Point') { if (shapeType === 'Point') {
shape.geometry.coordinates = [[p.x, p.y]]; shape.geometry.coordinates = [[p.x, p.y]];
} else if (isSupported(data, shapeType)) { } else if (isSupported(data, shapeType)) {
...@@ -639,14 +639,12 @@ ...@@ -639,14 +639,12 @@
$overlayDiv.remove(); $overlayDiv.remove();
return false; return false;
} }
// save editable state and set to non-editable // shape is not editable by default
if (shape.properties != null) { if (shape.properties == null) {
shape.properties._editable = shape.properties.editable;
shape.properties.editable = false;
shape.properties.screenpos = [pt];
} else {
shape.properties = {'editable' : false}; shape.properties = {'editable' : false};
} }
// save first mousedown position
shape.properties.screenpos = [pt];
// draw shape // draw shape
renderShape(data, shape, layer); renderShape(data, shape, layer);
// vertex drag end handler // vertex drag end handler
...@@ -657,21 +655,21 @@ ...@@ -657,21 +655,21 @@
// single click adds next line to LineString/Polygon // single click adds next line to LineString/Polygon
unrenderShape(data, shape); unrenderShape(data, shape);
// copy last vertex as starting point // copy last vertex as starting point
coords.push(coords[vtxidx].slice()); coords.push(coords[vtx].slice());
vtxidx += 1; vtx += 1;
// draw shape // draw shape
renderShape(data, shape, layer); renderShape(data, shape, layer);
// execute vertex drag handler on next vertex // execute vertex drag handler on next vertex
getVertexDragHandler(data, shape, vtxidx, vertexDragDone)(evt); getVertexDragHandler(data, shape, vtx, vertexDragDone)(evt);
return false; return false;
} else if (evt.type === 'dblclick') { } else if (evt.type === 'dblclick') {
// double click ends LineString/Polygon // double click ends LineString/Polygon
// remove duplicate vertices (from mouseup) // remove duplicate vertices (from mouseup)
var rerender = false; var rerender = false;
while (coords[vtxidx][0] === coords[vtxidx-1][0] && while (coords[vtx][0] === coords[vtx-1][0] &&
coords[vtxidx][1] === coords[vtxidx-1][1]) { coords[vtx][1] === coords[vtx-1][1]) {
coords.pop(); coords.pop();
vtxidx -= 1; vtx -= 1;
rerender = true; rerender = true;
} }
if (rerender) { if (rerender) {
...@@ -690,27 +688,23 @@ ...@@ -690,27 +688,23 @@
shapeDone(data, shape); shapeDone(data, shape);
} else { } else {
// execute vertex drag handler on second vertex // execute vertex drag handler on second vertex
getVertexDragHandler(data, shape, vtxidx, vertexDragDone)(evt); getVertexDragHandler(data, shape, vtx, vertexDragDone)(evt);
} }
return false; return false;
}; };
var shapeDone = function (data, shape) { var shapeDone = function (data, shape) {
// defining shape done // defining shape done
if (shape.properties._editable != null) {
// re-set editable
unrenderShape(data, shape); unrenderShape(data, shape);
shape.properties.editable = shape.properties._editable;
delete shape.properties._editable;
renderShape(data, shape, layer); renderShape(data, shape, layer);
} // save shape
// save shape
layer.shapes.push(shape); layer.shapes.push(shape);
$overlayDiv.remove(); $overlayDiv.remove();
if (onComplete != null) { if (onComplete != null) {
onComplete(data, shape); onComplete(data, shape);
} }
}; };
// start by clicking // start by clicking
$overlayDiv.one('mousedown.dlShape', shapeStart); $overlayDiv.one('mousedown.dlShape', shapeStart);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment