From b9000bb2851937abb756d66b84ee89bb186612f1 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 4 Apr 2016 13:43:05 +0200 Subject: [PATCH] Starting with the fictional point. --- pandora_console/include/class/Map.class.php | 1 + .../include/javascript/map/MapController.js | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/pandora_console/include/class/Map.class.php b/pandora_console/include/class/Map.class.php index 6617fc2a3b..bd99e1cafa 100644 --- a/pandora_console/include/class/Map.class.php +++ b/pandora_console/include/class/Map.class.php @@ -230,6 +230,7 @@ abstract class Map { $contants["ITEM_TYPE_AGENT_NETWORKMAP"] = ITEM_TYPE_AGENT_NETWORKMAP; $contants["ITEM_TYPE_MODULE_NETWORKMAP"] = ITEM_TYPE_MODULE_NETWORKMAP; $contants["ITEM_TYPE_EDGE_NETWORKMAP"] = ITEM_TYPE_EDGE_NETWORKMAP; + $contants["ITEM_TYPE_FICTIONAL_NODE"] = ITEM_TYPE_FICTIONAL_NODE; $contants["AGENT_MODULE_STATUS_ALL"] = AGENT_MODULE_STATUS_ALL; $contants["AGENT_MODULE_STATUS_CRITICAL_BAD"] = AGENT_MODULE_STATUS_CRITICAL_BAD; diff --git a/pandora_console/include/javascript/map/MapController.js b/pandora_console/include/javascript/map/MapController.js index bc8e6f8186..57ccdce4fe 100644 --- a/pandora_console/include/javascript/map/MapController.js +++ b/pandora_console/include/javascript/map/MapController.js @@ -1396,6 +1396,12 @@ MapController.prototype.init_events = function(principalObject) { ]; var map_menu = [ + { + title: 'Add fictional node', + action: function(elm, d, i) { + self.add_fictional_node(); + } + }, { title: 'Edit map', action: function(elm, d, i) { @@ -1883,6 +1889,51 @@ MapController.prototype.multiple_selection_start = function() { } } +MapController.prototype.add_fictional_node = function() { + var self = this; + + // Apply the zoom and panning + var zoom = d3.transform( + d3.select(self._target + " .viewport").attr("transform")); + + var x = self._last_mouse_position[0] / zoom.scale[0] + - zoom.translate[0] / zoom.scale[0]; + var y = self._last_mouse_position[1] / zoom.scale[1] + - zoom.translate[1] / zoom.scale[1]; + + var new_node = {}; + + new_node['id'] = 0; + new_node['id_agent'] = 0 + new_node['graph_id'] = self.get_last_graph_id() + 1; + new_node['height'] = 30; + new_node['width'] = 30; + new_node['status'] = AGENT_MODULE_STATUS_NO_DATA; + new_node['title'] = "fictional point"; + new_node['type'] = ITEM_TYPE_FICTIONAL_NODE; + new_node['x'] = x; + new_node['y'] = y; + + nodes.push(new_node); + + self.paint_nodes(); + self.paint_items_minimap(); +} + +MapController.prototype.get_last_graph_id = function() { + var self = this; + + var return_var = 0; + + $.each(nodes, function(i, node) { + if (node['graph_id'] > return_var) { + return_var = node['graph_id']; + } + }); + + return return_var; +} + /** * Function multiple_selection_dragging * Return void