New maps in progress... (document the code)

This commit is contained in:
Arturo Gonzalez 2016-04-08 14:26:42 +02:00
parent 7550cafbbc
commit 6d8daae60c
2 changed files with 141 additions and 76 deletions

View File

@ -265,6 +265,11 @@ MapController.prototype.get_node = function(id_graph) {
return return_node;
}
/**
* Function get_node_filter
* Return void
* This function returns the node filter
*/
MapController.prototype.get_node_filter = function(field, value) {
var return_node = null;
@ -1338,6 +1343,11 @@ MapController.prototype.resize_node = function(item, handler, delta_x, delta_y)
self.move_arrow(item["graph_id"]);
}
/**
* Function key_is_pressed
* Return void
* This function checks if the crtl key is pressed
*/
MapController.prototype.key_is_pressed = function(key) {
var self = this;
@ -1347,6 +1357,11 @@ MapController.prototype.key_is_pressed = function(key) {
return self._keys_pressed[key];
}
/**
* Function get_menu_nodes
* Return void
* This function returns the node menu
*/
MapController.prototype.get_menu_nodes = function() {
var self = this;
@ -1400,6 +1415,11 @@ MapController.prototype.get_menu_nodes = function() {
return node_menu;
}
/**
* Function events_for_minimap
* Return void
* This function init the minimap events
*/
MapController.prototype.events_for_minimap = function() {
var self = this;
@ -1415,6 +1435,11 @@ MapController.prototype.events_for_minimap = function() {
});
}
/**
* Function map_move_position
* Return void
* This function moves map position with minimap click
*/
MapController.prototype.map_move_position = function(x, y) {
var self = this;
@ -1423,6 +1448,11 @@ MapController.prototype.map_move_position = function(x, y) {
.event(self._viewport);
}
/**
* Function minimap_panning_map
* Return void
* This function calculates the position in click event (minimap)
*/
MapController.prototype.minimap_panning_map = function() {
var self = this;
@ -1445,6 +1475,11 @@ MapController.prototype.minimap_panning_map = function() {
self.map_move_position(x, y);
}
/**
* Function events_for_nodes
* Return void
* This function init the nodes events
*/
MapController.prototype.events_for_nodes = function(id_node) {
var self = this;
@ -1595,6 +1630,11 @@ MapController.prototype.events_for_nodes = function(id_node) {
}
}
/**
* Function is_draggable
* Return void
* This function checks if the node is draggable
*/
MapController.prototype.is_draggable = function(node) {
var return_var = false;
@ -1609,6 +1649,11 @@ MapController.prototype.is_draggable = function(node) {
return return_var;
}
/**
* Function is_relationshipy
* Return void
* This function checks if the node have a relathion
*/
MapController.prototype.is_relationshipy = function(node) {
var return_var = false;
@ -1623,6 +1668,11 @@ MapController.prototype.is_relationshipy = function(node) {
return return_var;
}
/**
* Function is_selecty
* Return void
* This function checks if the node is selecty
*/
MapController.prototype.is_selecty = function(node) {
var return_var = false;
@ -1637,6 +1687,11 @@ MapController.prototype.is_selecty = function(node) {
return return_var;
}
/**
* Function is_delety
* Return void
* This function checks if the node is delety
*/
MapController.prototype.is_delety = function(node) {
var return_var = false;
@ -1680,8 +1735,6 @@ MapController.prototype.events = function() {
}
});
var map_menu = [
{
title: 'Add fictional node',
@ -1705,9 +1758,6 @@ MapController.prototype.events = function() {
d3.select("#map").on("contextmenu", d3.contextMenu(map_menu));
d3.select(self._target + " svg").on("mousedown",
function() {
if (self._start_flag_multiple_selection) {
@ -1818,6 +1868,11 @@ MapController.prototype.events = function() {
setTimeout(function() { self.refresh_map();}, MAP_REFRESH_TIME);
}
/**
* Function refresh_map
* Return void
* This function refresh the map
*/
MapController.prototype.refresh_map = function() {
var self = this;
@ -1827,12 +1882,6 @@ MapController.prototype.refresh_map = function() {
setTimeout(function() { self.refresh_map();}, MAP_REFRESH_TIME);
}
MapController.prototype.refresh_nodes = function() {
}
MapController.prototype.refresh_arrows = function() {
}
/**
* Function set_as_parent
* Return void
@ -1916,9 +1965,6 @@ MapController.prototype.show_temp_arrows = function(node, type) {
.attr("data-temp", 1);
}
switch (type) {
case 'parent':
temp_arrow['from']['graph_id'] = node.graph_id;
@ -1930,10 +1976,14 @@ MapController.prototype.show_temp_arrows = function(node, type) {
break;
}
self.arrow_by_pieces(self._target + " svg", temp_arrow);
}
/**
* Function move_temp_arrows
* Return void
* This function move the temporal arrows
*/
MapController.prototype.move_temp_arrows = function(node, type) {
var self = this;
@ -1970,6 +2020,11 @@ MapController.prototype.move_temp_arrows = function(node, type) {
self.arrow_by_pieces(self._target + " svg", temp_arrow, 0);
}
/**
* Function remove_temp_arrows
* Return void
* This function remove the temporal arrows
*/
MapController.prototype.remove_temp_arrows = function() {
var self = this;
@ -1984,6 +2039,11 @@ MapController.prototype.remove_temp_arrows = function() {
self._relationship_in_progress_type = null;
}
/**
* Function apply_temp_arrows
* Return void
* This function apply the temporal arrows
*/
MapController.prototype.apply_temp_arrows = function(target_id) {
var self = this;
@ -1998,7 +2058,6 @@ MapController.prototype.apply_temp_arrows = function(target_id) {
return 1; // Continue
}
switch (self._relationship_in_progress_type) {
case 'parent':
self.make_arrow(node.graph_id, target_id);
@ -2013,9 +2072,6 @@ MapController.prototype.apply_temp_arrows = function(target_id) {
self.paint_arrows();
}
MapController.prototype.make_arrow = function(from_id, to_id) {
}
/**
* Function get_status_selection_node
* Return node status
@ -2070,6 +2126,11 @@ MapController.prototype.multiple_selection_start = function() {
}
}
/**
* Function add_fictional_node
* Return void
* This function add a fictional node
*/
MapController.prototype.add_fictional_node = function() {
var self = this;
@ -2103,6 +2164,11 @@ MapController.prototype.add_fictional_node = function() {
self.events_for_nodes(new_node['graph_id']);
}
/**
* Function get_last_graph_id
* Return id
* This function returns the last graph id
*/
MapController.prototype.get_last_graph_id = function() {
var self = this;

View File

@ -316,6 +316,11 @@ NetworkmapController.prototype.get_arrows_AMA = function(id_to, id_from) {
}
}
/**
* Function get_arrow_AF_or_FF
* Return arrow
* This function returns an arrow AF or FF (fictional-fictional or agent-fictional)
*/
NetworkmapController.prototype.get_arrow_AF_or_FF = function(id_to, id_from) {
var self = this;
var arrow_AF_or_FF;
@ -325,7 +330,6 @@ NetworkmapController.prototype.get_arrow_AF_or_FF = function(id_to, id_from) {
if (self.get_node_type(id_to) == ITEM_TYPE_FICTIONAL_NODE ||
self.get_node_type(id_from) == ITEM_TYPE_FICTIONAL_NODE) {
var arrow = self.get_arrow(id_to, id_from);
arrow_AF_or_FF = {};
@ -440,6 +444,11 @@ NetworkmapController.prototype.exists_arrow = function(arrows, arrow) {
return var_return;
}
/**
* Function update_node
* Return void
* This function updates the node status
*/
NetworkmapController.prototype.update_node = function(id) {
var self = this;
@ -454,6 +463,11 @@ NetworkmapController.prototype.update_node = function(id) {
.style("fill", node['color']);
}
/**
* Function update_arrow
* Return void
* This function updates the interfaces status
*/
NetworkmapController.prototype.update_arrow = function(graph_id) {
var self = this;
@ -464,6 +478,11 @@ NetworkmapController.prototype.update_arrow = function(graph_id) {
}
}
/**
* Function get_type_arrow
* Return void
* This function returns the arrow type
*/
NetworkmapController.prototype.get_type_arrow = function(graph_id) {
var return_var = null;
@ -477,6 +496,11 @@ NetworkmapController.prototype.get_type_arrow = function(graph_id) {
return return_var;
}
/**
* Function paint_node
* Return void
* This function paints the node
*/
NetworkmapController.prototype.paint_node = function(g_node, node) {
var self = this;
@ -517,14 +541,11 @@ NetworkmapController.prototype.paint_node = function(g_node, node) {
}
// Title
var d3_node_title = d3_node.append("text");
d3_node_title
.text(node['title'])
.style("fill", "#000000");
//Title position
var title_bbox = d3_node_title.node().getBBox();
@ -574,50 +595,6 @@ NetworkmapController.prototype.paint_nodes = function() {
NetworkmapController.prototype.paint_arrows = function() {
var self = this;
//~ var clean_arrows = [];
//~
//~ $.each(edges, function(i, edge) {
//~ var arrow_AF_or_FF = self.get_arrow_AF_or_FF(edge['to'], edge['from']);
//~ if (arrow_AF_or_FF !== null) {
//~ if (!self.exists_arrow(clean_arrows, arrow_AF_or_FF)) {
//~ clean_arrows.push(arrow_AF_or_FF);
//~ }
//~ }
//~
//~ var arrow_AA = self.get_arrow_AA(edge['graph_id'], edge['to'], edge['from']);
//~ if (arrow_AA !== null) {
//~ if (!self.exists_arrow(clean_arrows, arrow_AA)) {
//~ clean_arrows.push(arrow_AA);
//~ }
//~ }
//~
//~ var arrow_AMMA = self.get_arrow_AMMA(edge['to'], edge['from']);
//~ if (arrow_AMMA !== null) {
//~ if (!self.exists_arrow(clean_arrows, arrow_AMMA)) {
//~ clean_arrows.push(arrow_AMMA);
//~ }
//~ }
//~
//~ var arrows_AMA = self.get_arrows_AMA(edge['to'], edge['from']);
//~ if (arrows_AMA !== null) {
//~ $.each(arrows_AMA, function(i, arrow_AMA) {
//~ if (!self.exists_arrow(clean_arrows, arrow_AMA)) {
//~ clean_arrows.push(arrow_AMA);
//~ }
//~ });
//~ }
//~ });
//~
//~ var new_clean_arrows = [];
//~ clean_arrows.forEach(function(arrow, index) {
//~ console.log(arrow);
//~ for (var i = index + 1; i < clean_arrows.length; i++) {
//~
//~ }
//~ });
//~
//~ MapController.prototype.update_edges_from_clean_arrows(clean_arrows);
var arrow_layouts = self._viewport.selectAll(".arrow")
.data(edges)
.enter()
@ -676,6 +653,11 @@ NetworkmapController.prototype.arrow_by_pieces = function (target, arrow_data, w
}
}
/**
* Function make_arrow
* Return void
* This function makes AA arrows
*/
NetworkmapController.prototype.make_arrow = function(from_id, to_id) {
var self = this;
@ -983,8 +965,6 @@ NetworkmapController.prototype.arrow_by_pieces_AMMA = function (target, arrow_da
var x = -10 + (arrow_body_width * scale) - arrow_tail_width - radius_from;
var y = 0 + (arrow_body_height / 2 - arrow_head_title_height / 2);
transform.translate[0] = x;
transform.translate[1] = y;
arrow_tail_title.attr("transform", transform.toString());
@ -1005,7 +985,6 @@ NetworkmapController.prototype.arrow_by_pieces_AMMA = function (target, arrow_da
* Return void
* This function print the arrow by pieces (3 steps)
*/
//~ MapController.prototype.arrow_by_pieces = function(target, id_arrow, id_node_to, id_node_from, wait) {
NetworkmapController.prototype.arrow_by_pieces_AA = function(target, arrow_data, wait) {
var self = this;
@ -1150,7 +1129,6 @@ NetworkmapController.prototype.arrow_by_pieces_AA = function(target, arrow_data,
/*---------------------------------------------*/
/*--- Position of layer arrow (body + head) ---*/
/*---------------------------------------------*/
var arrow_body = arrow_layout.select(".body");
if (self._first_paint_arrows) {
@ -1388,6 +1366,7 @@ NetworkmapController.prototype.arrow_by_pieces_AMA = function(target, arrow_data
self.arrow_by_pieces_AMA(target, arrow_data, 0);
}
break;
/*---------------------------------------------*/
/*---- Print head and body arrow by steps -----*/
/*---------------------------------------------*/
@ -1897,11 +1876,14 @@ NetworkmapController.prototype.update_interfaces_status = function (arrow_data)
}
}
/**
* Function refresh_nodes
* Return void
* This function refresh the nodes
*/
NetworkmapController.prototype.refresh_nodes = function() {
var self = this;
var params = {};
params["refresh_nodes_open"] = 1;
params["id_map"] = self._id;
@ -1942,6 +1924,11 @@ NetworkmapController.prototype.refresh_nodes = function() {
});
}
/**
* Function refresh_arrows
* Return void
* This function refresh the arrows
*/
NetworkmapController.prototype.refresh_arrows = function() {
var self = this;
@ -1987,6 +1974,11 @@ NetworkmapController.prototype.refresh_arrows = function() {
});
}
/**
* Function cache_is_element
* Return void
* This function checks if the element is in cache
*/
NetworkmapController.prototype.cache_is_element = function(element) {
var self = this;
@ -2018,6 +2010,11 @@ NetworkmapController.prototype.getArrows = function(id_node) {
return return_var;
}
/**
* Function get_menu_nodes
* Return menu
* This function returns the node menus
*/
NetworkmapController.prototype.get_menu_nodes = function() {
var self = this;
@ -2110,12 +2107,14 @@ NetworkmapController.prototype.editNode = function(target) {
});
}
/**
* Function apply_edit_node
* Return menu
* This function aplies the new data to the node
*/
NetworkmapController.prototype.apply_edit_node = function(data_graph_id) {
var node_id = data_graph_id;
console.log(node_id);
var new_label = $("#edit_node_dialog_" + node_id + " input[id='text-label']").val();
var new_shape = $("#edit_node_dialog_" + node_id + " select[id='shape']").val();