1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-29 18:28:11 +00:00

Return size of the scene of the project

Ref #683
This commit is contained in:
Julien Duponchelle 2016-09-20 12:46:39 +02:00
parent 77eae35778
commit 64139387c4
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
7 changed files with 77 additions and 4 deletions

View File

@ -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

View File

@ -23,6 +23,7 @@ API
glossary
curl
notifications
position
endpoints
GNS3 developements

7
docs/position.rst Normal file
View File

@ -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.

View File

@ -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):

View File

@ -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,

View File

@ -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",

View File

@ -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
}