def get_selected_data(axes, x1, y1, x2, y2): """ Verifies that the axes in question overlaps with the canvas area from C{(x1, y1)} to C{(x1, y1)}. The corresponding X and Y axes ranges are returned as a 3-tuple. If no axes overlaps with the specified area, 2-tuple of C{None}s is returned. """ if axes is None: return None, None bbox = bound_vertices([(x1, y1), (x2, y2)]) bxr, byr = wxmpl.get_bbox_lims(bbox) axr, ayr = wxmpl.get_bbox_lims(axes.bbox) xmin = max(bxr[0], axr[0]) xmax = min(bxr[1], axr[1]) ymin = max(byr[0], ayr[0]) ymax = min(byr[1], ayr[1]) return wxmpl.get_bbox_lims( inverse_transform_bbox(axes.transData, bound_vertices([(xmin, ymin), (xmax, ymax)])))
assert(bbox.xmin()==-30) assert(bbox.xmax()==400) assert(bbox.ymin()==-10) assert(bbox.ymax()==40) num = Value(200.0) den = Value(100.0) div = num/den assert(div.get()==2.0) # test the inverse bbox functions trans = rand_transform() bbox1 = rand_bbox() ibbox = inverse_transform_bbox(trans, bbox1) bbox2 = transform_bbox(trans, ibbox) assert(closeto_bbox(bbox1, bbox2)) ll = Point( Value(-10), Value(-10) ) ur = Point( Value(200), Value(40) ) bbox = Bbox(ll, ur) transform = get_bbox_transform(unit_bbox(), bbox) assert( closeto_seq( inverse_transform_bbox(transform, bbox).get_bounds(), (0,0,1,1))) assert( closeto_seq( transform_bbox(transform, unit_bbox()).get_bounds(), (-10,-10,210,50))) # test the bbox all bounding functions
ix.set_bounds(-30, 400) assert (bbox.xmin() == -30) assert (bbox.xmax() == 400) assert (bbox.ymin() == -10) assert (bbox.ymax() == 40) num = Value(200.0) den = Value(100.0) div = num / den assert (div.get() == 2.0) # test the inverse bbox functions trans = rand_transform() bbox1 = rand_bbox() ibbox = inverse_transform_bbox(trans, bbox1) bbox2 = transform_bbox(trans, ibbox) assert (closeto_bbox(bbox1, bbox2)) ll = Point(Value(-10), Value(-10)) ur = Point(Value(200), Value(40)) bbox = Bbox(ll, ur) transform = get_bbox_transform(unit_bbox(), bbox) assert (closeto_seq( inverse_transform_bbox(transform, bbox).get_bounds(), (0, 0, 1, 1))) assert (closeto_seq( transform_bbox(transform, unit_bbox()).get_bounds(), (-10, -10, 210, 50))) # test the bbox all bounding functions boxes = [rand_bbox() for i in range(20)] xmin = min([box.xmin() for box in boxes])