mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-20 23:44:47 +02:00
Fix way drawing
This commit is contained in:
+1
-5
@@ -82,7 +82,7 @@ require(["dojo/dom-geometry","dojo/dom-class","dojo/on","dojo/dom","dojo/Evented
|
||||
});
|
||||
|
||||
$('#add-road').click(function() {
|
||||
controller.setState(new iD.controller.shape.NoSelection());
|
||||
controller.setState(new iD.controller.shape.NoSelection('way'));
|
||||
});
|
||||
|
||||
$('#add-area').click(function() {
|
||||
@@ -100,10 +100,6 @@ require(["dojo/dom-geometry","dojo/dom-class","dojo/on","dojo/dom","dojo/Evented
|
||||
map.zoomOut();
|
||||
});
|
||||
|
||||
$('#map').dblclick(function() {
|
||||
map.zoomIn();
|
||||
});
|
||||
|
||||
var scroll = 0;
|
||||
$('#map').bind('mousewheel', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
+1
-3
@@ -27,7 +27,6 @@ declare("iD.Controller", [Evented], {
|
||||
// summary: Enter a new ControllerState, firing exitState on the old one, and enterState on the new one.
|
||||
if (newState === this.state) { return; }
|
||||
if (this.state) {
|
||||
this.state.exitState(newState);
|
||||
this.emit("exitState", {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
@@ -47,10 +46,9 @@ declare("iD.Controller", [Evented], {
|
||||
entityMouseEvent:function(event,entityUI) {
|
||||
// summary: Pass a MouseEvent on an EntityUI (e.g. clicking a way) to the current ControllerState.
|
||||
if (!this.state) { return; }
|
||||
var newState=this.state.processMouseEvent(event,entityUI);
|
||||
var newState = this.state.processMouseEvent(event,entityUI);
|
||||
this.setState(newState);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
+2
-2
@@ -83,14 +83,14 @@ iD.Way.prototype = {
|
||||
// --------------
|
||||
// Action callers
|
||||
|
||||
doAppendNode:function(node, performAction) {
|
||||
doAppendNode: function(node, performAction) {
|
||||
// summary: Add a node to the end of the way, using an undo stack.
|
||||
// returns: New length of the way.
|
||||
if (node!=this.getLastNode()) performAction(new iD.actions.AddNodeToWayAction(this, node, this.nodes, -1, true));
|
||||
return this.nodes.length + 1; // int
|
||||
},
|
||||
|
||||
doPrependNode:function(node, performAction) {
|
||||
doPrependNode: function(node, performAction) {
|
||||
// summary: Add a node to the start of the way, using an undo stack.
|
||||
// returns: New length of the way.
|
||||
if (node!=this.nodes[0]) performAction(new iD.actions.AddNodeToWayAction(this, node, this.nodes, 0, true));
|
||||
|
||||
@@ -13,7 +13,7 @@ declare("iD.actions.AddNodeToWayAction", [iD.actions.UndoableEntityAction], {
|
||||
firstNode: null,
|
||||
autoDelete: true,
|
||||
|
||||
constructor:function(way, node, nodeList, index, autoDelete) {
|
||||
constructor: function(way, node, nodeList, index, autoDelete) {
|
||||
// summary: Add a node to a way at a specified index, or -1 for the end of the way.
|
||||
this.entity = way;
|
||||
this.node = node;
|
||||
@@ -41,7 +41,6 @@ declare("iD.actions.AddNodeToWayAction", [iD.actions.UndoableEntityAction], {
|
||||
this.nodeList.splice(this.index, 0, this.node);
|
||||
this.markDirty();
|
||||
way.expandBbox(this.node);
|
||||
way.connection.refreshEntity(way);
|
||||
|
||||
return this.SUCCESS;
|
||||
},
|
||||
|
||||
@@ -10,13 +10,13 @@ declare("iD.actions.CreateEntityAction", [iD.actions.UndoableEntityAction], {
|
||||
setCreate:null,
|
||||
deleteAction:null,
|
||||
|
||||
constructor:function(entity,setCreate) {
|
||||
constructor: function(entity,setCreate) {
|
||||
// summary: Create a new entity - way, node or relation.
|
||||
this.setCreate = setCreate;
|
||||
this.setName("Create "+entity.entityType);
|
||||
this.setName("Create " + entity.entityType);
|
||||
},
|
||||
|
||||
doAction:function() {
|
||||
doAction: function() {
|
||||
// summary: Call out to the specified method (in the Controller) to create the entity.
|
||||
// See undoAction for explanation of special redo handling.
|
||||
if (this.deleteAction!==null) {
|
||||
@@ -28,7 +28,7 @@ declare("iD.actions.CreateEntityAction", [iD.actions.UndoableEntityAction], {
|
||||
return this.SUCCESS;
|
||||
},
|
||||
|
||||
undoAction:function() {
|
||||
undoAction: function() {
|
||||
// summary: Special handling for undoing a create. When undo is called, instead
|
||||
// of simply removing the entity, we work through to make a Delete[Entity]Action,
|
||||
// call that, and store it for later. Then, when this action is called again
|
||||
@@ -39,7 +39,7 @@ declare("iD.actions.CreateEntityAction", [iD.actions.UndoableEntityAction], {
|
||||
return this.SUCCESS;
|
||||
},
|
||||
|
||||
setAction:function(action) {
|
||||
setAction: function(action) {
|
||||
// summary: Set the associated delete action (see undoAction for explanation).
|
||||
deleteAction = action;
|
||||
}
|
||||
|
||||
+11
-11
@@ -15,7 +15,7 @@ declare("iD.actions.UndoStack", null, {
|
||||
SUCCESS: 1,
|
||||
NO_CHANGE: 2,
|
||||
|
||||
constructor:function() {
|
||||
constructor: function() {
|
||||
// summary: An undo stack. There can be any number of these, but almost all operations will
|
||||
// take place on the global undo stack - implemented as a singleton-like property of
|
||||
// the Controller.
|
||||
@@ -23,7 +23,7 @@ declare("iD.actions.UndoStack", null, {
|
||||
this.redoActions=[];
|
||||
},
|
||||
|
||||
addAction:function(_action) {
|
||||
addAction: function(_action) {
|
||||
// summary: Do an action, and add it to the undo stack if it succeeded.
|
||||
var result = _action.doAction();
|
||||
switch (result) {
|
||||
@@ -50,30 +50,30 @@ declare("iD.actions.UndoStack", null, {
|
||||
}
|
||||
},
|
||||
|
||||
breakUndo:function() {
|
||||
breakUndo: function() {
|
||||
// summary: Wipe the undo stack - typically used after saving.
|
||||
this.undoActions = [];
|
||||
this.redoActions = [];
|
||||
},
|
||||
|
||||
canUndo:function() {
|
||||
canUndo: function() {
|
||||
// summary: Are there any items on the undo stack?
|
||||
return this.undoActions.length > 0;
|
||||
},
|
||||
|
||||
canRedo:function() {
|
||||
canRedo: function() {
|
||||
// summary: Are there any redoable actions?
|
||||
return this.redoActions.length > 0;
|
||||
},
|
||||
|
||||
undo:function() {
|
||||
undo: function() {
|
||||
// summary: Undo the most recent action, and add it to the top of the redo stack.
|
||||
if (!this.undoActions.length) { return; }
|
||||
var action = undoActions.pop();
|
||||
action.undoAction();
|
||||
redoActions.push(action);
|
||||
},
|
||||
undoIfAction:function(_action) {
|
||||
undoIfAction: function(_action) {
|
||||
// summary: Undo the most recent action _only_ if it was of a certain type.
|
||||
// Fixme: isInstanceOf needs to be made into JavaScript.
|
||||
if (!this.undoActions.length) { return; }
|
||||
@@ -83,7 +83,7 @@ declare("iD.actions.UndoStack", null, {
|
||||
}
|
||||
return false;
|
||||
},
|
||||
removeLastIfAction:function(_action) {
|
||||
removeLastIfAction: function(_action) {
|
||||
// summary: Remove the most recent action from the stack _only_ if it was of a certain type.
|
||||
// Fixme: isInstanceOf needs to be made into JavaScript.
|
||||
if (this.undoActions.length && this.undoActions[this.undoActions.length-1].isInstanceOf(_action)) {
|
||||
@@ -91,7 +91,7 @@ declare("iD.actions.UndoStack", null, {
|
||||
}
|
||||
},
|
||||
|
||||
getUndoDescription:function() {
|
||||
getUndoDescription: function() {
|
||||
// summary: Get the name of the topmost item on the undo stack.
|
||||
if (!this.undoActions.length) return null;
|
||||
if (this.undoActions[this.undoActions.length-1].name) {
|
||||
@@ -100,7 +100,7 @@ declare("iD.actions.UndoStack", null, {
|
||||
return null;
|
||||
},
|
||||
|
||||
getRedoDescription:function() {
|
||||
getRedoDescription: function() {
|
||||
// summary: Get the name of the topmost item on the redo stack.
|
||||
if (!this.redoActions.length) return null;
|
||||
if (this.redoActions[this.redoActions.length-1].name) {
|
||||
@@ -109,7 +109,7 @@ declare("iD.actions.UndoStack", null, {
|
||||
return null;
|
||||
},
|
||||
|
||||
redo:function() {
|
||||
redo: function() {
|
||||
// summary: Takes the action most recently undone, does it, and adds it to the undo stack.
|
||||
if (!this.redoActions.length) { return; }
|
||||
var action = this.redoActions.pop();
|
||||
|
||||
@@ -29,6 +29,7 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
|
||||
constructor: function(way) {
|
||||
this.way = way;
|
||||
},
|
||||
|
||||
enterState: function() {
|
||||
this.wayUI = this.controller.map.getUI(this.way);
|
||||
this.wayUI.setStateClass('selected')
|
||||
@@ -36,6 +37,7 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
|
||||
.redraw();
|
||||
this.controller.stepper.step(1);
|
||||
},
|
||||
|
||||
exitState: function() {
|
||||
this.controller.map.clearElastic();
|
||||
this.wayUI
|
||||
@@ -155,11 +157,14 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
|
||||
},
|
||||
|
||||
getStartNode:function() {
|
||||
return (this.editEnd ? this.way.nodes[0] : this.way.nodes[this.way.node.length - 1]);
|
||||
return (this.editEnd ? this.way.nodes[0] : this.way.nodes[this.way.nodes.length - 1]);
|
||||
},
|
||||
|
||||
appendNode:function(node, performAction) {
|
||||
if (this.editEnd) { this.way.doAppendNode(node, performAction); }
|
||||
if (this.editEnd) {
|
||||
this.way.doAppendNode(node, performAction);
|
||||
this.controller.map.refreshUI(this.way);
|
||||
}
|
||||
else { this.way.doPrependNode(node, performAction); }
|
||||
},
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ declare("iD.controller.shape.NoSelection", [iD.controller.ControllerState], {
|
||||
}
|
||||
},
|
||||
|
||||
processMouseEvent:function(event, entityUI) {
|
||||
processMouseEvent: function(event, entityUI) {
|
||||
var entity = entityUI ? entityUI.entity : null;
|
||||
var entityType = entity ? entity.entityType : null;
|
||||
var map = this.controller.map;
|
||||
|
||||
@@ -149,7 +149,7 @@ declare("iD.renderer.Map", null, {
|
||||
// summary: Find the gfx.Group for a given OSM layer and rendering sublayer, creating it
|
||||
// if necessary. Note that sublayers are only implemented for stroke and fill.
|
||||
// groupType: String 'casing','text','hit','stroke', or 'fill'
|
||||
var collection=this.layers[layer][groupType], sub;
|
||||
var collection = this.layers[layer][groupType], sub;
|
||||
switch (groupType) {
|
||||
case 'casing':
|
||||
case 'text':
|
||||
@@ -158,7 +158,7 @@ declare("iD.renderer.Map", null, {
|
||||
}
|
||||
// Find correct sublayer, inserting if necessary
|
||||
var insertAt=collection.children.length;
|
||||
for (var i=0; i<collection.children.length; i++) {
|
||||
for (var i = 0; i < collection.children.length; i++) {
|
||||
sub=collection.children[i];
|
||||
if (sub.sublayer==sublayer) { return sub; }
|
||||
else if (sub.sublayer>sublayer) {
|
||||
@@ -173,7 +173,7 @@ declare("iD.renderer.Map", null, {
|
||||
return sub; // dojox.gfx.Group
|
||||
},
|
||||
|
||||
createUI:function(entity,stateClasses) {
|
||||
createUI: function(entity,stateClasses) {
|
||||
// summary: Create a UI (sprite) for an entity, assigning any specified state classes
|
||||
// (temporary attributes such as ':hover' or ':selected')
|
||||
var id = entity.id;
|
||||
@@ -194,7 +194,7 @@ declare("iD.renderer.Map", null, {
|
||||
}
|
||||
},
|
||||
|
||||
getUI:function(entity) {
|
||||
getUI: function(entity) {
|
||||
// summary: Return the UI for an entity, if it exists.
|
||||
if (entity.entityType === 'node') {
|
||||
return this.nodeuis[entity.id]; // iD.renderer.EntityUI
|
||||
@@ -204,7 +204,7 @@ declare("iD.renderer.Map", null, {
|
||||
return null;
|
||||
},
|
||||
|
||||
refreshUI:function(entity) {
|
||||
refreshUI: function(entity) {
|
||||
// summary: Redraw the UI for an entity.
|
||||
if (entity.entityType === 'node') {
|
||||
if (this.nodeuis[entity.id]) { this.nodeuis[entity.id].redraw(); }
|
||||
@@ -213,7 +213,7 @@ declare("iD.renderer.Map", null, {
|
||||
}
|
||||
},
|
||||
|
||||
deleteUI:function(entity) {
|
||||
deleteUI: function(entity) {
|
||||
// summary: Delete the UI for an entity.
|
||||
var uis = { node: 'nodeuis', way: 'wayuis' }[entity.entityType];
|
||||
if (uis && this[uis][entity.id]) {
|
||||
@@ -222,7 +222,7 @@ declare("iD.renderer.Map", null, {
|
||||
}
|
||||
},
|
||||
|
||||
download:function() {
|
||||
download: function() {
|
||||
// summary: Ask the connection to download data for the current viewport.
|
||||
$('#progress').show().addClass('spinner');
|
||||
this.conn.loadFromAPI(this.extent, _.bind(this.updateUIs, this));
|
||||
|
||||
Reference in New Issue
Block a user