bug fixes for mapping experience. able to store multiple references to synapses on each edge
This commit is contained in:
parent
96d883bde7
commit
06f18215dd
6 changed files with 95 additions and 42 deletions
|
@ -7081,7 +7081,8 @@ Graph.Plot = {
|
||||||
var l = Metamaps.Mouse.synapseStartCoordinates.length;
|
var l = Metamaps.Mouse.synapseStartCoordinates.length;
|
||||||
for (var i = l - 1; i >= 0; i -= 1) {
|
for (var i = l - 1; i >= 0; i -= 1) {
|
||||||
start = Metamaps.Mouse.synapseStartCoordinates[i];
|
start = Metamaps.Mouse.synapseStartCoordinates[i];
|
||||||
Metamaps.JIT.renderMidArrow(start, end, 13, false, canvas, 0.5, true);
|
Metamaps.JIT.renderMidArrow(start, end, 13, false, canvas, 0.3, true);
|
||||||
|
Metamaps.JIT.renderMidArrow(start, end, 13, false, canvas, 0.7, true);
|
||||||
}
|
}
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ Metamaps.JIT = {
|
||||||
*/
|
*/
|
||||||
prepareVizData: function () {
|
prepareVizData: function () {
|
||||||
var self = Metamaps.JIT;
|
var self = Metamaps.JIT;
|
||||||
|
var synapsesToRemove = [];
|
||||||
var topic;
|
var topic;
|
||||||
var mapping;
|
var mapping;
|
||||||
var node;
|
var node;
|
||||||
|
@ -39,7 +40,12 @@ Metamaps.JIT = {
|
||||||
Metamaps.Synapses.each(function (s) {
|
Metamaps.Synapses.each(function (s) {
|
||||||
edge = s.createEdge();
|
edge = s.createEdge();
|
||||||
|
|
||||||
if (nodes[edge.nodeFrom] && nodes[edge.nodeTo]) {
|
if(Metamaps.Topics.get(s.get('node1_id')) === undefined || Metamaps.Topics.get(s.get('node2_id')) === undefined) {
|
||||||
|
// this means it's an invalid synapse
|
||||||
|
synapsesToRemove.push(s);
|
||||||
|
}
|
||||||
|
else if (nodes[edge.nodeFrom] && nodes[edge.nodeTo]) {
|
||||||
|
|
||||||
existingEdge = _.findWhere(edges, {
|
existingEdge = _.findWhere(edges, {
|
||||||
nodeFrom: edge.nodeFrom,
|
nodeFrom: edge.nodeFrom,
|
||||||
nodeTo: edge.nodeTo
|
nodeTo: edge.nodeTo
|
||||||
|
@ -53,15 +59,24 @@ Metamaps.JIT = {
|
||||||
// for when you're dealing with multiple relationships between the same two topics
|
// for when you're dealing with multiple relationships between the same two topics
|
||||||
if (Metamaps.Active.Map) {
|
if (Metamaps.Active.Map) {
|
||||||
mapping = s.getMapping();
|
mapping = s.getMapping();
|
||||||
existingEdge['$mappingIDs'].push(mapping.isNew() ? mapping.cid : mapping.id);
|
existingEdge.data['$mappingIDs'].push(mapping.id);
|
||||||
}
|
}
|
||||||
existingEdge['$synapseIDs'].push(s.id);
|
existingEdge.data['$synapseIDs'].push(s.id);
|
||||||
} else {
|
} else {
|
||||||
// for when you're dealing with a topic that has relationships to many different nodes
|
// for when you're dealing with a topic that has relationships to many different nodes
|
||||||
nodes[edge.nodeFrom].adjacencies.push(edge);
|
nodes[edge.nodeFrom].adjacencies.push(edge);
|
||||||
|
edges.push(edge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// clean up the synapses array in case of any faulty data
|
||||||
|
_.each(synapsesToRemove, function (synapse) {
|
||||||
|
mapping = synapse.getMapping();
|
||||||
|
Metamaps.Synapses.remove(synapse);
|
||||||
|
Metamaps.Mappings.remove(mapping);
|
||||||
|
});
|
||||||
|
|
||||||
_.each(nodes, function (node) {
|
_.each(nodes, function (node) {
|
||||||
self.vizData.push(node);
|
self.vizData.push(node);
|
||||||
});
|
});
|
||||||
|
@ -319,7 +334,7 @@ Metamaps.JIT = {
|
||||||
if (Metamaps.Mouse.boxStartCoordinates) {
|
if (Metamaps.Mouse.boxStartCoordinates) {
|
||||||
Metamaps.Visualize.mGraph.busy = false;
|
Metamaps.Visualize.mGraph.busy = false;
|
||||||
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
|
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
|
||||||
Metamaps.JIT.zoomToBox();
|
Metamaps.JIT.zoomToBox(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,8 +831,8 @@ Metamaps.JIT = {
|
||||||
} else if (tempInit && tempNode2 != null) {
|
} else if (tempInit && tempNode2 != null) {
|
||||||
// this means you want to create a synapse between two existing topics
|
// this means you want to create a synapse between two existing topics
|
||||||
Metamaps.Create.newTopic.addSynapse = false;
|
Metamaps.Create.newTopic.addSynapse = false;
|
||||||
Metamaps.Create.newSynapse.topic1id = tempNode.id;
|
Metamaps.Create.newSynapse.topic1id = tempNode.getData('topic').id;
|
||||||
Metamaps.Create.newSynapse.topic2id = tempNode2.id;
|
Metamaps.Create.newSynapse.topic2id = tempNode2.getData('topic').id;
|
||||||
tempNode2.setData('dim', 25, 'current');
|
tempNode2.setData('dim', 25, 'current');
|
||||||
Metamaps.Visualize.mGraph.plot();
|
Metamaps.Visualize.mGraph.plot();
|
||||||
midpoint.x = tempNode.pos.getc().x + (tempNode2.pos.getc().x - tempNode.pos.getc().x) / 2;
|
midpoint.x = tempNode.pos.getc().x + (tempNode2.pos.getc().x - tempNode.pos.getc().x) / 2;
|
||||||
|
@ -1414,9 +1429,9 @@ Metamaps.JIT = {
|
||||||
var v2 = intermediatePoint.$add(normal.$scale(-1));
|
var v2 = intermediatePoint.$add(normal.$scale(-1));
|
||||||
|
|
||||||
if (newSynapse) {
|
if (newSynapse) {
|
||||||
ctx.strokeStyle = "#222222";
|
ctx.strokeStyle = "#4fc059";
|
||||||
ctx.lineWidth = 2;
|
ctx.lineWidth = 2;
|
||||||
ctx.globalAlpha = 0.4;
|
ctx.globalAlpha = 1;
|
||||||
}
|
}
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(from.x, from.y);
|
ctx.moveTo(from.x, from.y);
|
||||||
|
@ -1465,8 +1480,7 @@ Metamaps.JIT = {
|
||||||
y: posChild.y
|
y: posChild.y
|
||||||
}, 13, false, canvas, 0.7);
|
}, 13, false, canvas, 0.7);
|
||||||
} else if (directionCat == "from-to") {
|
} else if (directionCat == "from-to") {
|
||||||
var direction = adj.data.$direction;
|
var inv = (direction[0] != adj.nodeFrom.id);
|
||||||
var inv = (direction && direction.length > 1 && direction[0] != adj.nodeFrom.id);
|
|
||||||
self.renderMidArrow({
|
self.renderMidArrow({
|
||||||
x: pos.x,
|
x: pos.x,
|
||||||
y: pos.y
|
y: pos.y
|
||||||
|
@ -1502,7 +1516,7 @@ Metamaps.JIT = {
|
||||||
|
|
||||||
canvas.translate(-1*offsetX,-1*offsetY);
|
canvas.translate(-1*offsetX,-1*offsetY);
|
||||||
},
|
},
|
||||||
zoomToBox: function () {
|
zoomToBox: function (event) {
|
||||||
var sX = Metamaps.Mouse.boxStartCoordinates.x,
|
var sX = Metamaps.Mouse.boxStartCoordinates.x,
|
||||||
sY = Metamaps.Mouse.boxStartCoordinates.y,
|
sY = Metamaps.Mouse.boxStartCoordinates.y,
|
||||||
eX = Metamaps.Mouse.boxEndCoordinates.x,
|
eX = Metamaps.Mouse.boxEndCoordinates.x,
|
||||||
|
@ -1538,14 +1552,14 @@ Metamaps.JIT = {
|
||||||
var cogY = (sY + eY)/2;
|
var cogY = (sY + eY)/2;
|
||||||
|
|
||||||
canvas.translate(-1* cogX, -1* cogY);
|
canvas.translate(-1* cogX, -1* cogY);
|
||||||
|
$(document).trigger(Metamaps.JIT.events.zoom, [event]);
|
||||||
|
|
||||||
Metamaps.Mouse.boxStartCoordinates = false;
|
Metamaps.Mouse.boxStartCoordinates = false;
|
||||||
Metamaps.Mouse.boxEndCoordinates = false;
|
Metamaps.Mouse.boxEndCoordinates = false;
|
||||||
Metamaps.Visualize.mGraph.plot();
|
Metamaps.Visualize.mGraph.plot();
|
||||||
|
|
||||||
},
|
},
|
||||||
zoomExtents: function () {
|
zoomExtents: function (event) {
|
||||||
Metamaps.JIT.centerMap();
|
Metamaps.JIT.centerMap();
|
||||||
var height = $(document).height(),
|
var height = $(document).height(),
|
||||||
width = $(document).width(),
|
width = $(document).width(),
|
||||||
|
|
|
@ -130,6 +130,7 @@
|
||||||
Metamaps.GlobalUI.Search.unlock();
|
Metamaps.GlobalUI.Search.unlock();
|
||||||
Metamaps.GlobalUI.Search.close(0, true);
|
Metamaps.GlobalUI.Search.close(0, true);
|
||||||
|
|
||||||
|
Metamaps.Loading.show();
|
||||||
Metamaps.Map.end();
|
Metamaps.Map.end();
|
||||||
Metamaps.Map.launch(id);
|
Metamaps.Map.launch(id);
|
||||||
},
|
},
|
||||||
|
|
|
@ -217,15 +217,15 @@ Metamaps.Backbone.init = function () {
|
||||||
else return false;
|
else return false;
|
||||||
},
|
},
|
||||||
getTopic1: function () {
|
getTopic1: function () {
|
||||||
return Metamaps.Topic.get(this.get('node1_id'));
|
return Metamaps.Topics.get(this.get('node1_id'));
|
||||||
},
|
},
|
||||||
getTopic2: function () {
|
getTopic2: function () {
|
||||||
return Metamaps.Topic.get(this.get('node2_id'));
|
return Metamaps.Topics.get(this.get('node2_id'));
|
||||||
},
|
},
|
||||||
getDirection: function () {
|
getDirection: function () {
|
||||||
return [
|
return [
|
||||||
this.get('node1_id'),
|
this.getTopic1().get('node').id,
|
||||||
this.get('node2_id')
|
this.getTopic2().get('node').id
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
getMapping: function () {
|
getMapping: function () {
|
||||||
|
@ -1232,12 +1232,16 @@ Metamaps.Visualize = {
|
||||||
topic.updateNode();
|
topic.updateNode();
|
||||||
|
|
||||||
n.eachAdjacency(function (edge) {
|
n.eachAdjacency(function (edge) {
|
||||||
|
if(!edge.getData('init')) {
|
||||||
|
edge.setData('init', true);
|
||||||
|
|
||||||
l = edge.getData('synapseIDs').length;
|
l = edge.getData('synapseIDs').length;
|
||||||
for (i = 0; i < l; i++) {
|
for (i = 0; i < l; i++) {
|
||||||
synapse = Metamaps.Synapses.get(edge.getData('synapseIDs')[i]);
|
synapse = Metamaps.Synapses.get(edge.getData('synapseIDs')[i]);
|
||||||
synapse.set('edge', edge);
|
synapse.set('edge', edge);
|
||||||
synapse.updateEdge();
|
synapse.updateEdge();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var pos = n.getPos();
|
var pos = n.getPos();
|
||||||
|
@ -1254,12 +1258,16 @@ Metamaps.Visualize = {
|
||||||
mapping = topic.getMapping();
|
mapping = topic.getMapping();
|
||||||
|
|
||||||
n.eachAdjacency(function (edge) {
|
n.eachAdjacency(function (edge) {
|
||||||
|
if(!edge.getData('init')) {
|
||||||
|
edge.setData('init', true);
|
||||||
|
|
||||||
l = edge.getData('synapseIDs').length;
|
l = edge.getData('synapseIDs').length;
|
||||||
for (i = 0; i < l; i++) {
|
for (i = 0; i < l; i++) {
|
||||||
synapse = Metamaps.Synapses.get(edge.getData('synapseIDs')[i]);
|
synapse = Metamaps.Synapses.get(edge.getData('synapseIDs')[i]);
|
||||||
synapse.set('edge', edge);
|
synapse.set('edge', edge);
|
||||||
synapse.updateEdge();
|
synapse.updateEdge();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
startPos = new $jit.Complex(0, 0);
|
startPos = new $jit.Complex(0, 0);
|
||||||
|
@ -1274,7 +1282,6 @@ Metamaps.Visualize = {
|
||||||
/**
|
/**
|
||||||
* render does the heavy lifting of creating the engine that renders the graph with the properties we desire
|
* render does the heavy lifting of creating the engine that renders the graph with the properties we desire
|
||||||
*
|
*
|
||||||
* @param vizData a json structure containing the data to be rendered.
|
|
||||||
*/
|
*/
|
||||||
render: function () {
|
render: function () {
|
||||||
var self = Metamaps.Visualize, RGraphSettings, FDSettings;
|
var self = Metamaps.Visualize, RGraphSettings, FDSettings;
|
||||||
|
@ -2902,6 +2909,8 @@ Metamaps.Topic = {
|
||||||
|
|
||||||
var newnode = topic.createNode();
|
var newnode = topic.createNode();
|
||||||
|
|
||||||
|
var midpoint = {}, pixelPos;
|
||||||
|
|
||||||
if (!$.isEmptyObject(Metamaps.Visualize.mGraph.graph.nodes)) {
|
if (!$.isEmptyObject(Metamaps.Visualize.mGraph.graph.nodes)) {
|
||||||
Metamaps.Visualize.mGraph.graph.addNode(newnode);
|
Metamaps.Visualize.mGraph.graph.addNode(newnode);
|
||||||
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
|
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
|
||||||
|
@ -2927,8 +2936,15 @@ Metamaps.Topic = {
|
||||||
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), "end");
|
nodeOnViz.setPos(new $jit.Complex(mapping.get('xloc'), mapping.get('yloc')), "end");
|
||||||
}
|
}
|
||||||
if (Metamaps.Create.newTopic.addSynapse) {
|
if (Metamaps.Create.newTopic.addSynapse) {
|
||||||
Metamaps.Create.newSynapse.topic1id = tempNode.id;
|
Metamaps.Create.newSynapse.topic1id = tempNode.getData('topic').id;
|
||||||
Metamaps.Create.newSynapse.topic2id = nodeOnViz.id;
|
|
||||||
|
// position the form
|
||||||
|
midpoint.x = tempNode.pos.getc().x + (nodeOnViz.pos.getc().x - tempNode.pos.getc().x) / 2;
|
||||||
|
midpoint.y = tempNode.pos.getc().y + (nodeOnViz.pos.getc().y - tempNode.pos.getc().y) / 2;
|
||||||
|
pixelPos = Metamaps.Util.coordsToPixels(midpoint);
|
||||||
|
$('#new_synapse').css('left', pixelPos.x + "px");
|
||||||
|
$('#new_synapse').css('top', pixelPos.y + "px");
|
||||||
|
// show the form
|
||||||
Metamaps.Create.newSynapse.open();
|
Metamaps.Create.newSynapse.open();
|
||||||
Metamaps.Visualize.mGraph.fx.animate({
|
Metamaps.Visualize.mGraph.fx.animate({
|
||||||
modes: ["node-property:dim"],
|
modes: ["node-property:dim"],
|
||||||
|
@ -2970,14 +2986,21 @@ Metamaps.Topic = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Metamaps.Settings.sandbox && createNewInDB) {
|
|
||||||
if (topic.isNew()) {
|
var successCallback = function (topicModel, response) {
|
||||||
topic.save(null, {
|
|
||||||
success: function (topicModel, response) {
|
|
||||||
if (Metamaps.Active.Map) {
|
if (Metamaps.Active.Map) {
|
||||||
mapping.save({ topic_id: topicModel.id });
|
mapping.save({ topic_id: topicModel.id });
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
if (Metamaps.Create.newTopic.addSynapse) {
|
||||||
|
Metamaps.Create.newSynapse.topic2id = topicModel.id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!Metamaps.Settings.sandbox && createNewInDB) {
|
||||||
|
if (topic.isNew()) {
|
||||||
|
topic.save(null, {
|
||||||
|
success: successCallback,
|
||||||
error: function (model, response) {
|
error: function (model, response) {
|
||||||
console.log('error saving topic to database');
|
console.log('error saving topic to database');
|
||||||
}
|
}
|
||||||
|
@ -3116,12 +3139,13 @@ Metamaps.Synapse = {
|
||||||
//for each node in this array we will create a synapse going to the position2 node.
|
//for each node in this array we will create a synapse going to the position2 node.
|
||||||
var synapsesToCreate = [];
|
var synapsesToCreate = [];
|
||||||
|
|
||||||
node2 = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic2id);
|
topic2 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic2id);
|
||||||
topic2 = node2.getData('topic');
|
node2 = topic2.get('node');
|
||||||
|
|
||||||
var len = Metamaps.Selected.Nodes.length;
|
var len = Metamaps.Selected.Nodes.length;
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
synapsesToCreate[0] = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic1id);
|
topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic1id);
|
||||||
|
synapsesToCreate[0] = topic1.get('node');
|
||||||
} else if (len > 0) {
|
} else if (len > 0) {
|
||||||
synapsesToCreate = Metamaps.Selected.Nodes;
|
synapsesToCreate = Metamaps.Selected.Nodes;
|
||||||
}
|
}
|
||||||
|
@ -3150,6 +3174,8 @@ Metamaps.Synapse = {
|
||||||
},
|
},
|
||||||
getSynapseFromAutocomplete: function (id) {
|
getSynapseFromAutocomplete: function (id) {
|
||||||
var self = Metamaps.Synapse,
|
var self = Metamaps.Synapse,
|
||||||
|
topic1,
|
||||||
|
topic2,
|
||||||
node1,
|
node1,
|
||||||
node2;
|
node2;
|
||||||
|
|
||||||
|
@ -3161,8 +3187,10 @@ Metamaps.Synapse = {
|
||||||
});
|
});
|
||||||
Metamaps.Mappings.add(mapping);
|
Metamaps.Mappings.add(mapping);
|
||||||
|
|
||||||
node1 = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic1id);
|
topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic1id);
|
||||||
node2 = Metamaps.Visualize.mGraph.graph.getNode(Metamaps.Create.newSynapse.topic2id);
|
node1 = topic1.get('node');
|
||||||
|
topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic2id);
|
||||||
|
node2 = topic2.get('node');
|
||||||
Metamaps.Create.newSynapse.hide();
|
Metamaps.Create.newSynapse.hide();
|
||||||
|
|
||||||
self.renderSynapse(mapping, synapse, node1, node2, true);
|
self.renderSynapse(mapping, synapse, node1, node2, true);
|
||||||
|
@ -3220,6 +3248,7 @@ Metamaps.Map = {
|
||||||
Metamaps.Filter.checkMappers();
|
Metamaps.Filter.checkMappers();
|
||||||
|
|
||||||
Metamaps.Realtime.startActiveMap();
|
Metamaps.Realtime.startActiveMap();
|
||||||
|
Metamaps.Loading.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
|
@ -862,7 +862,7 @@ label[for="user_remember_me"] {
|
||||||
|
|
||||||
.sidebarFilterBox {
|
.sidebarFilterBox {
|
||||||
display:none;
|
display:none;
|
||||||
width: 304px;
|
width: 319px;
|
||||||
padding: 16px 0;
|
padding: 16px 0;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -606,6 +606,14 @@
|
||||||
background-color: #9150bc;
|
background-color: #9150bc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.github-fork-ribbon-wrapper {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.homePage .github-fork-ribbon-wrapper {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
/* end home page */
|
/* end home page */
|
||||||
|
|
||||||
/* infoAndHelp */
|
/* infoAndHelp */
|
||||||
|
|
Loading…
Reference in a new issue