Changing license to MIT.
[PyCIM.git] / CIM15 / IEC61970 / Graphics / VisibilityLayer.py
blob96c51d6fae1a7edb7bbbcf0b9174a830fcba8146
1 # Copyright (C) 2010-2011 Richard Lincoln
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 # IN THE SOFTWARE.
21 from CIM15.IEC61970.Core.IdentifiedObject import IdentifiedObject
23 class VisibilityLayer(IdentifiedObject):
24 """Layers are typically used for grouping diagram objects according to themes and scales. Themes are used to display or hide certain information (e.g., lakes, borders), while scales are used for hiding or displaying information depending on the current zoom level (hide text when it is too small to be read, or when it exceeds the screen size). This is also called de-cluttering. CIM based graphics exchange will support an m:n relationship between diagram objects and layers. It will be the task of the importing system to convert an m:n case into an appropriate 1:n representation if the importing system does not support m:n.Layers are typically used for grouping diagram objects according to themes and scales. Themes are used to display or hide certain information (e.g., lakes, borders), while scales are used for hiding or displaying information depending on the current zoom level (hide text when it is too small to be read, or when it exceeds the screen size). This is also called de-cluttering. CIM based graphics exchange will support an m:n relationship between diagram objects and layers. It will be the task of the importing system to convert an m:n case into an appropriate 1:n representation if the importing system does not support m:n.
25 """
27 def __init__(self, drawingOrder=0, DiagramObjects=None, *args, **kw_args):
28 """Initialises a new 'VisibilityLayer' instance.
30 @param drawingOrder: The drawing order for this layer. As with the drawingOrder for diagram objects, the higher the number, the later the layer and the objects within it are rendered.
31 @param DiagramObjects: A visibility layer can contain one or more diagram objects
32 """
33 #: The drawing order for this layer. As with the drawingOrder for diagram objects, the higher the number, the later the layer and the objects within it are rendered.
34 self.drawingOrder = drawingOrder
36 self._DiagramObjects = []
37 self.DiagramObjects = [] if DiagramObjects is None else DiagramObjects
39 super(VisibilityLayer, self).__init__(*args, **kw_args)
41 _attrs = ["drawingOrder"]
42 _attr_types = {"drawingOrder": int}
43 _defaults = {"drawingOrder": 0}
44 _enums = {}
45 _refs = ["DiagramObjects"]
46 _many_refs = ["DiagramObjects"]
48 def getDiagramObjects(self):
49 """A visibility layer can contain one or more diagram objects
50 """
51 return self._DiagramObjects
53 def setDiagramObjects(self, value):
54 for p in self._DiagramObjects:
55 filtered = [q for q in p.VisibilityLayers if q != self]
56 self._DiagramObjects._VisibilityLayers = filtered
57 for r in value:
58 if self not in r._VisibilityLayers:
59 r._VisibilityLayers.append(self)
60 self._DiagramObjects = value
62 DiagramObjects = property(getDiagramObjects, setDiagramObjects)
64 def addDiagramObjects(self, *DiagramObjects):
65 for obj in DiagramObjects:
66 if self not in obj._VisibilityLayers:
67 obj._VisibilityLayers.append(self)
68 self._DiagramObjects.append(obj)
70 def removeDiagramObjects(self, *DiagramObjects):
71 for obj in DiagramObjects:
72 if self in obj._VisibilityLayers:
73 obj._VisibilityLayers.remove(self)
74 self._DiagramObjects.remove(obj)