Ticket #206: RadialNet.py.patch

File RadialNet.py.patch, 3.2 kB (added by ignotus, 17 months ago)

Work in progress patch. Not finished yet.

  • umitGUI/radialnet/RadialNet.py

    old new  
    11371137                while group.get_draw_info('group_node') is not None: 
    11381138                    group = group.get_draw_info('group_node') 
    11391139 
    1140                 ring = group.get_draw_info('ring') 
    1141                 node.set_coordinate_radius(self.__calc_radius(ring)) 
     1140                radius = self.__calc_radius(group.get_draw_info('ring')) 
     1141                flip = group.get_draw_info('flip') 
    11421142 
    11431143            else: 
    1144                 ring = node.get_draw_info('ring') 
    1145                 node.set_coordinate_radius(self.__calc_radius(ring)) 
     1144 
     1145                radius = self.__calc_radius(node.get_draw_info('ring')) 
     1146                flip = node.get_draw_info('flip') 
     1147 
     1148            if flip: 
     1149                radius += flip 
     1150 
     1151            node.set_coordinate_radius(radius) 
    11461152 
    11471153 
    11481154    @graph_is_not_empty 
     
    12951301                    node_total = max - min 
    12961302                    children_need = node.get_draw_info('children_need') 
    12971303 
     1304                    flip = 1 
     1305 
    12981306                    for child in children: 
    12991307 
    13001308                        child_need = child.get_draw_info('space_need') 
    13011309                        child_total = node_total * child_need / children_need 
    13021310 
     1311                        print node_total, children_need 
     1312 
     1313                        if node_total < children_need: 
     1314 
     1315                            r = child.get_draw_info('radius') 
     1316                            child.set_draw_info({'flip':(r * flip)}) 
     1317 
     1318                            flip *= -1 
     1319 
     1320                        else: 
     1321                            child.set_draw_info({'flip':0}) 
     1322 
    13031323                        theta = child_total / 2 + min + self.__rotate 
    13041324 
    13051325                        child.set_coordinate_theta(theta) 
     
    13911411        # set nodes' coordinate radius 
    13921412        for node in self.__graph.get_nodes(): 
    13931413 
    1394             ring = node.get_draw_info('ring') 
    1395             node.set_coordinate_radius(self.__calc_radius(ring)) 
     1414            radius = self.__calc_radius(node.get_draw_info('ring')) 
     1415            flip = node.get_draw_info('flip') 
     1416 
     1417            if flip: 
     1418                radius += flip 
     1419 
     1420            node.set_coordinate_radius(radius) 
    13961421 
    13971422        # set nodes' coordinate theta 
    13981423        self.__calc_layout(reference) 
     
    15651590            self.__graph = graph 
    15661591 
    15671592            self.__calc_node_positions() 
     1593 
     1594            # [TODO] Perform computation and set best values for: 
     1595            # - base ring gap; 
     1596            # - rotation; 
     1597            # - use or not fisheye? 
     1598 
    15681599            self.queue_draw() 
    15691600 
    15701601        else: 
     
    18421873    def angle_from_object(distance, size): 
    18431874        """ 
    18441875        """ 
    1845         return math.degrees(math.atan2(size / 2.0, distance)) 
     1876        return math.degrees(math.atan2(size, distance)) 
    18461877         
    18471878    # End of Geometry 
    18481879     
     
    20102041                sum_angle += child.get_draw_info('space_need') 
    20112042         
    20122043        distance = self.get_coordinate_radius() 
    2013         size = self.get_draw_info('radius') * 2 
     2044        size = self.get_draw_info('radius') * 2.0 
    20142045        own_angle = RadialNet.angle_from_object(distance, size) 
    20152046 
    20162047        self.set_draw_info({'children_need':sum_angle})