diff --git a/docs/glossary.rst b/docs/glossary.rst index 3c1bd914..3fde097f 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -37,7 +37,10 @@ Compute The process running on each server with GNS3. The GNS3 compute node is controlled by the GNS3 controller. - Symbol ------ Symbol are the icon used for nodes. + +Scene +----- +The drawing area diff --git a/docs/index.rst b/docs/index.rst index 5dc420bb..1acea149 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,6 +23,7 @@ API glossary curl notifications + position endpoints GNS3 developements diff --git a/docs/position.rst b/docs/position.rst new file mode 100644 index 00000000..c3d6511d --- /dev/null +++ b/docs/position.rst @@ -0,0 +1,7 @@ +Positions +========= + +In a the project object you have properties scene_height and scene_width this define the +size of the drawing area as px. + +The position of the node are relative to this with 0,0 as center of the area. diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index 48d9543d..34419609 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -62,7 +62,9 @@ class Project: :param status: Status of the project (opened / closed) """ - def __init__(self, name=None, project_id=None, path=None, controller=None, status="opened", filename=None, auto_start=False, auto_open=False, auto_close=True): + def __init__(self, name=None, project_id=None, path=None, controller=None, status="opened", + filename=None, auto_start=False, auto_open=False, auto_close=True, + scene_height=1000, scene_width=2000): self._controller = controller assert name is not None @@ -71,6 +73,8 @@ class Project: self._auto_close = auto_close self._auto_open = auto_open self._status = status + self._scene_height = scene_height + self._scene_width = scene_width # Disallow overwrite of existing project if project_id is None and path is not None: @@ -139,6 +143,28 @@ class Project: # Create the project on demand on the compute node self._project_created_on_compute = set() + @property + def scene_height(self): + return self._scene_height + + @scene_height.setter + def scene_height(self, val): + """ + Height of the drawing area + """ + self._scene_height = val + + @property + def scene_width(self): + return self._scene_width + + @scene_width.setter + def scene_width(self, val): + """ + Width of the drawing area + """ + self._scene_width = val + @property def auto_start(self): """ @@ -694,7 +720,9 @@ class Project: "status": self._status, "auto_start": self._auto_start, "auto_close": self._auto_close, - "auto_open": self._auto_open + "auto_open": self._auto_open, + "scene_height": self._scene_height, + "scene_width": self._scene_width } def __repr__(self): diff --git a/gns3server/schemas/project.py b/gns3server/schemas/project.py index e3733508..d103539a 100644 --- a/gns3server/schemas/project.py +++ b/gns3server/schemas/project.py @@ -41,6 +41,14 @@ PROJECT_CREATE_SCHEMA = { "minLength": 36, "maxLength": 36, "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + }, + "scene_height": { + "type": "integer", + "description": "Height of the drawing area" + }, + "scene_width": { + "type": "integer", + "description": "Width of the drawing area" } }, "additionalProperties": False, @@ -71,6 +79,14 @@ PROJECT_UPDATE_SCHEMA = { "auto_start": { "description": "Project start when opened", "type": "boolean" + }, + "scene_height": { + "type": "integer", + "description": "Height of the drawing area" + }, + "scene_width": { + "type": "integer", + "description": "Width of the drawing area" } }, "additionalProperties": False, @@ -118,6 +134,14 @@ PROJECT_OBJECT_SCHEMA = { "auto_start": { "description": "Project start when opened", "type": "boolean" + }, + "scene_height": { + "type": "integer", + "description": "Height of the drawing area" + }, + "scene_width": { + "type": "integer", + "description": "Width of the drawing area" } }, "additionalProperties": False, diff --git a/gns3server/schemas/topology.py b/gns3server/schemas/topology.py index 43c5acee..ad383c5d 100644 --- a/gns3server/schemas/topology.py +++ b/gns3server/schemas/topology.py @@ -65,6 +65,14 @@ TOPOLOGY_SCHEMA = { "type": "string", "description": "Name of the project" }, + "scene_height": { + "type": "integer", + "description": "Height of the drawing area" + }, + "scene_width": { + "type": "integer", + "description": "Width of the drawing area" + }, "topology": { "description": "The topology content", "type": "object", diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index 113452dc..ba554e4e 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -68,7 +68,9 @@ def test_json(tmpdir): "filename": "Test.gns3", "auto_start": False, "auto_close": True, - "auto_open": False + "auto_open": False, + "scene_width": 2000, + "scene_height": 1000 }