示例#1
0
    def _calcEdgeLines(self):

        h_hpad = self.width_pad / 2
        h_vpad = self.height_pad / 2

        for eid, n1, n2, einfo in self.graph.getEdges():

            pre_lines = []
            post_lines = []

            pinfo = self.graph.getNodeProps(n1)
            kinfo = self.graph.getNodeProps(n2)

            pwidth, pheight = pinfo.get('size', (0,0))
            pweight = pinfo.get('weight')
            lheight = self.lheights[pweight]
            voffset = lheight - pheight

            if einfo.get('looptop'):

                x1, y1 = vg_layout.entry_pos(pinfo)
                x2, y2 = vg_layout.entry_pos(kinfo)

                xhalf = (x1 - x2) / 2

                b = [ (x1, y1),
                      (x1, y1 - h_vpad),
                      (x2, y2 - h_vpad),
                      (x2, y2),
                    ]

            elif einfo.get('loopbot'):

                x1, y1 = vg_layout.exit_pos(pinfo)
                x2, y2 = vg_layout.exit_pos(kinfo)

                kwidth, kheight = kinfo.get('size', (0,0))
                kweight = kinfo.get('weight')
                klheight = self.lheights[kweight]

                kvoffset = klheight - kheight

                pre_lines = [(x1, y1), (x1, y1 + voffset)]
                post_lines = [(x2, y2), (x2, y2 + kvoffset)]

                b = [ (x1, y1 + voffset),
                      (x1, y1 + voffset + h_vpad),
                      (x2, y2 + kvoffset + h_vpad),
                      (x2, y2 + kvoffset),
                    ]

            else:

                x1, y1 = vg_layout.exit_pos(pinfo)
                x2, y2 = vg_layout.entry_pos(kinfo)

                pre_lines = [(x1,y1), (x1, y1 + voffset)]

                b = [ (x1, y1 + voffset),
                      (x1, y1 + voffset + h_vpad),
                      (x2, y2 - h_vpad),
                      (x2, y2),
                    ]

            bez_lines = vg_bezier.calculate_bezier(b, 20)

            einfo['edge_points'] = pre_lines + bez_lines + post_lines
示例#2
0
文件: dynadag.py 项目: BwRy/vivisect
    def _calcEdgeLines(self):

        h_hpad = self.width_pad / 2
        h_vpad = self.height_pad / 2

        for eid, n1, n2, einfo in self.graph.getEdges():

            pre_lines = []
            post_lines = []

            pinfo = self.graph.getNodeProps(n1)
            kinfo = self.graph.getNodeProps(n2)

            pwidth, pheight = pinfo.get('size', (0,0))
            pweight = pinfo.get('weight')
            lheight = self.lheights[pweight]
            voffset = lheight - pheight

            if einfo.get('looptop'):

                x1, y1 = vg_layout.entry_pos(pinfo)
                x2, y2 = vg_layout.entry_pos(kinfo)

                xhalf = (x1 - x2) / 2

                b = [ (x1, y1),
                      (x1, y1 - h_vpad),
                      (x2, y2 - h_vpad),
                      (x2, y2),
                    ]
                
            elif einfo.get('loopbot'):

                x1, y1 = vg_layout.exit_pos(pinfo)
                x2, y2 = vg_layout.exit_pos(kinfo)

                kwidth, kheight = kinfo.get('size', (0,0))
                kweight = kinfo.get('weight')
                klheight = self.lheights[kweight]

                kvoffset = klheight - kheight

                pre_lines = [(x1, y1), (x1, y1 + voffset)]
                post_lines = [(x2, y2), (x2, y2 + kvoffset)]

                b = [ (x1, y1 + voffset),
                      (x1, y1 + voffset + h_vpad),
                      (x2, y2 + kvoffset + h_vpad),
                      (x2, y2 + kvoffset),
                    ]

            else:

                x1, y1 = vg_layout.exit_pos(pinfo)
                x2, y2 = vg_layout.entry_pos(kinfo)

                pre_lines = [(x1,y1), (x1, y1 + voffset)]

                b = [ (x1, y1 + voffset),
                      (x1, y1 + voffset + h_vpad),
                      (x2, y2 - h_vpad),
                      (x2, y2),
                    ]

            bez_lines = vg_bezier.calculate_bezier(b, 20)

            einfo['edge_points'] = pre_lines + bez_lines + post_lines