mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Rotation support
This commit is contained in:
parent
4f78efa0c8
commit
03e9eac55b
@ -24,7 +24,7 @@ class Shape:
|
|||||||
Shape are visual element not used by the network emulation. Like
|
Shape are visual element not used by the network emulation. Like
|
||||||
text, images, rectangle... They are pure SVG elements.
|
text, images, rectangle... They are pure SVG elements.
|
||||||
"""
|
"""
|
||||||
def __init__(self, project, shape_id=None, svg="<svg></svg>", x=0, y=0, z=0):
|
def __init__(self, project, shape_id=None, svg="<svg></svg>", x=0, y=0, z=0, rotation=0):
|
||||||
self.svg = svg
|
self.svg = svg
|
||||||
self._project = project
|
self._project = project
|
||||||
if shape_id is None:
|
if shape_id is None:
|
||||||
@ -34,6 +34,7 @@ class Shape:
|
|||||||
self._x = x
|
self._x = x
|
||||||
self._y = y
|
self._y = y
|
||||||
self._z = z
|
self._z = z
|
||||||
|
self._rotation = rotation
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self):
|
def id(self):
|
||||||
@ -71,6 +72,14 @@ class Shape:
|
|||||||
def z(self, val):
|
def z(self, val):
|
||||||
self._z = val
|
self._z = val
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rotation(self):
|
||||||
|
return self._rotation
|
||||||
|
|
||||||
|
@rotation.setter
|
||||||
|
def rotation(self, val):
|
||||||
|
self._rotation = val
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def update(self, **kwargs):
|
def update(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -96,6 +105,7 @@ class Shape:
|
|||||||
"x": self._x,
|
"x": self._x,
|
||||||
"y": self._y,
|
"y": self._y,
|
||||||
"z": self._z,
|
"z": self._z,
|
||||||
|
"rotation": self._rotation,
|
||||||
"svg": self._svg
|
"svg": self._svg
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@ -104,6 +114,7 @@ class Shape:
|
|||||||
"x": self._x,
|
"x": self._x,
|
||||||
"y": self._y,
|
"y": self._y,
|
||||||
"z": self._z,
|
"z": self._z,
|
||||||
|
"rotation": self._rotation,
|
||||||
"svg": self._svg
|
"svg": self._svg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,12 @@ SHAPE_OBJECT_SCHEMA = {
|
|||||||
"description": "Z property",
|
"description": "Z property",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"rotation": {
|
||||||
|
"description": "Rotation of the element",
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 360
|
||||||
|
},
|
||||||
"svg": {
|
"svg": {
|
||||||
"description": "SVG content of the shape",
|
"description": "SVG content of the shape",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -55,13 +55,15 @@ def test_json(project):
|
|||||||
"x": i.x,
|
"x": i.x,
|
||||||
"y": i.y,
|
"y": i.y,
|
||||||
"z": i.z,
|
"z": i.z,
|
||||||
"svg": i.svg
|
"svg": i.svg,
|
||||||
|
"rotation": i.rotation
|
||||||
}
|
}
|
||||||
assert i.__json__(topology_dump=True) == {
|
assert i.__json__(topology_dump=True) == {
|
||||||
"shape_id": i.id,
|
"shape_id": i.id,
|
||||||
"x": i.x,
|
"x": i.x,
|
||||||
"y": i.y,
|
"y": i.y,
|
||||||
"z": i.z,
|
"z": i.z,
|
||||||
|
"rotation": i.rotation,
|
||||||
"svg": i.svg
|
"svg": i.svg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user