Fix tracing functionality

This commit is contained in:
Tom MacWright
2012-10-17 15:40:50 -04:00
parent b0773a83da
commit 69a1f5a9ef
5 changed files with 45 additions and 30 deletions
+3 -1
View File
@@ -32,7 +32,9 @@
require(["dojo/_base/lang","dojo/dom-geometry","dojo/dom-class","dojo/on","dojo/dom","dojo/Evented",
"dijit/form/Button","dijit/form/ToggleButton",
"dojox/layout/FloatingPane",
"iD/actions/UndoStack","iD/actions/CreatePOIAction",
"iD/actions/UndoStack",
"iD/actions/CreatePOIAction",
"iD/actions/AddNodeToWayAction",
"iD/Controller",
"iD/actions/CreateEntityAction",
"iD/controller/edit/NoSelection",
+2 -2
View File
@@ -105,10 +105,10 @@ iD.Connection.prototype = {
});
},
refreshEntity:function(_entity) {
refreshEntity: function(entity) {
// summary: Redraw a particular entity on all the Map objects that take data from this Connection.
_.each(this.maps, function(map) {
map.refreshUI(_entity);
map.refreshUI(entity);
});
},
+15 -10
View File
@@ -22,39 +22,44 @@ declare("iD.actions.AddNodeToWayAction", [iD.actions.UndoableEntityAction], {
this.autoDelete = autoDelete;
},
doAction:function() {
var way=this.entity; // shorthand
doAction: function() {
var way = this.entity; // shorthand
// undelete way if it was deleted before (only happens on redo)
if (way.deleted) {
way.setDeletedState(false);
if (!this.firstNode.hasParentWays()) this.firstNode.connection.unregisterPOI(firstNode);
if (!this.firstNode.hasParentWays()) {
this.firstNode.connection.unregisterPOI(firstNode);
}
this.firstNode.addParent(way);
}
// add the node
if (this.index==-1) this.index=this.nodeList.length;
this.node.addParent(way);
if (this.index === -1) this.index = this.nodeList.length;
this.node.entity.addParent(way);
this.node.connection.unregisterPOI(this.node);
this.nodeList.splice(this.index, 0, this.node);
this.markDirty();
way.expandBbox(this.node);
way.refresh();
way.connection.refreshEntity(way);
return this.SUCCESS;
},
undoAction:function() {
undoAction: function() {
// summary: Remove the added node. Fixme: if the way is now 1-length, we should
// do something like deleting it and converting the remaining node to a POI.
var way=this.entity; // shorthand
if (this.autoDelete && way.length()==2 && way.parentRelations().length()) return this.FAIL;
if (this.autoDelete && way.length() === 2 &&
way.parentRelations().length()) return this.FAIL;
// remove node
var removed=nodeList.splice(index, 1);
if (this.nodeList.indexOf(removed[0])==-1) { removed[0].removeParent(way); }
if (!_.contains(this.nodeList, removed[0])) {
removed[0].removeParent(way);
}
this.markClean();
way.refresh();
way.connection.refreshEntity(way);
return this.SUCCESS;
}
+24 -16
View File
@@ -29,14 +29,14 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
constructor: function(way) {
this.way = way;
},
enterState:function() {
this.wayUI=this.controller.map.getUI(this.way);
enterState: function() {
this.wayUI = this.controller.map.getUI(this.way);
this.wayUI.setStateClass('selected');
this.wayUI.setStateClass('shownodes');
this.wayUI.redraw();
this.controller.stepper.highlight('draw');
},
exitState:function() {
exitState: function() {
this.controller.map.clearElastic();
this.wayUI.resetStateClass('selected');
this.wayUI.resetStateClass('shownodes');
@@ -46,8 +46,8 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
processMouseEvent:function(event,entityUI) {
var entity=entityUI ? entityUI.entity : null;
var entityType=entity ? entity.entityType : null;
var map=this.controller.map;
var ways;
var map = this.controller.map;
var ways, undo, action;
if (event.type=='mouseover' && entityType=='way' && entityUI!=this.wayUI) {
// Mouse over way, show hover highlight
@@ -62,7 +62,12 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
// Find what object we're moving into
var into=shape.byId((event.hasOwnProperty('toElement') ? event.toElement : event.relatedTarget).__gfxObject__);
// If it's a nodeUI that belongs to a hovering way, don't deselect
if (into && into.hasOwnProperty('source') && into.source.hasStateClass('hoverway') && into.source.entity.hasParent(entity)) { return this; }
if (into &&
into.hasOwnProperty('source') &&
into.source.hasStateClass('hoverway') &&
into.source.entity.entity.hasParent(entity)) {
return this;
}
entityUI.resetStateClass('shownodeshover');
entityUI.redraw();
this.wayUI.redraw();
@@ -71,9 +76,9 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
} else if (event.type=='mouseout' && entityType=='node') {
// Mouse left node, remove hover highlight from parent way too
ways=entity.parentWays();
ways = entity.entity.parentWays();
for (var i in ways) {
var ui=this.controller.map.getUI(ways[i]);
var ui = this.controller.map.getUI(ways[i]);
if (ui && ui.hasStateClass('shownodeshover')) {
ui.resetStateClass('shownodeshover');
ui.redraw();
@@ -92,11 +97,11 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
switch (entityType) {
case 'node':
// Click on node
if (entity==this.getDrawingNode()) {
if (entity === this.getDrawingNode()) {
// Double-click, so complete drawing
this.controller.stepper.highlight('tag');
return new iD.controller.edit.SelectedWay(this.way, null);
} else if (entity==this.getStartNode()) {
} else if (entity === this.getStartNode()) {
// Start of this way, so complete drawing
this.appendNode(entity, this.undoAdder() );
this.controller.stepper.highlight('tag');
@@ -110,19 +115,22 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
case 'way':
// Click on way, add new junction node to way
ways=[entity]; // ** needs to find all the ways under the mouse
var undo=new iD.actions.CompositeUndoableAction();
ways = [entity]; // ** needs to find all the ways under the mouse
undo = new iD.actions.CompositeUndoableAction();
var node=this.appendNewNode(event, undo);
array.forEach(ways, function(w) { w.doInsertNodeAtClosestPosition(node, true, lang.hitch(undo,undo.push)); } );
var action=this.undoAdder(); action(undo);
_.each(ways, function(w) {
w.doInsertNodeAtClosestPosition(node, true, lang.hitch(undo, undo.push));
});
action = this.undoAdder();
action(undo);
return this;
}
} else if (event.type=='click') {
// Click on empty space, add new node to way
var undo=new iD.actions.CompositeUndoableAction();
undo = new iD.actions.CompositeUndoableAction();
this.appendNewNode(event, undo);
var action=this.undoAdder(); action(undo);
action = this.undoAdder(); action(undo);
return this;
}
+1 -1
View File
@@ -11,7 +11,7 @@ declare("iD.tags.TagEditor", null, {
dialog: null,
editorContainers: null, // hash of DOM nodes to put editors in
constructor:function(entity, controller) {
constructor: function(entity, controller) {
// summary: Construct a tag editor dialog box.
this.entity = entity;
this.controller = controller;