def AddLinkShape(self, lnk, shapeTmpl = None): """Add link-shape information to the layer. ShapeTmpl can be given to describe shape's paramenters :param lnk: :class:`Deca.Link` to add shape :param shapeTmpl: :class:`Deca.Shape` describes the drawing parameters :returns: :class:`Deca.Shape` of the created shape """ line = None fromShape = self.storage.graph_data.get(lnk.StartObject, None) toShape = self.storage.graph_data.get(lnk.FinishObject, None) if fromShape and toShape: if shapeTmpl : line = shapeTmpl.copy(shapeTmpl.ID) else: line = DecaShape(lnk.ID) line.Tag = 'link' line.start = lnk.StartObject line.finish = lnk.FinishObject line.direct = lnk.Directional line.label = getattr(lnk, 'Title', '') if not shapeTmpl: line.pen = () line.brush = () if not hasattr(line, 'ControlPoints'): line.ControlPoints = self.GetViewOption('defaultLineCP', 2) line.CPArray = [] if not hasattr(line, 'spline'): line.spline = self.GetViewOption('defaultLineSpline', False) self.storage.graph_data[lnk.ID] = line self.Modified = True # link added return line
def AddLinkShape(self, lnk, shapeTmpl=None): """Add link-shape information to the layer. ShapeTmpl can be given to describe shape's paramenters :param lnk: :class:`Deca.Link` to add shape :param shapeTmpl: :class:`Deca.Shape` describes the drawing parameters :returns: :class:`Deca.Shape` of the created shape """ line = None fromShape = self.storage.graph_data.get(lnk.StartObject, None) toShape = self.storage.graph_data.get(lnk.FinishObject, None) if fromShape and toShape: if shapeTmpl: line = shapeTmpl.copy(shapeTmpl.ID) else: line = DecaShape(lnk.ID) line.Tag = 'link' line.start = lnk.StartObject line.finish = lnk.FinishObject line.direct = lnk.Directional line.label = getattr(lnk, 'Title', '') if not shapeTmpl: line.pen = () line.brush = () if not hasattr(line, 'ControlPoints'): line.ControlPoints = self.GetViewOption('defaultLineCP', 2) line.CPArray = [] if not hasattr(line, 'spline'): line.spline = self.GetViewOption('defaultLineSpline', False) self.storage.graph_data[lnk.ID] = line self.Modified = True # link added return line