CanvasObjectBase¶
-
class
ginga.canvas.CanvasObject.CanvasObjectBase(**kwdargs)[source]¶ Bases:
ginga.misc.Callback.CallbacksThis is the abstract base class for a CanvasObject. A CanvasObject is an item that can be placed on a ImageViewCanvas.
This class defines common methods used by all such objects.
Methods Summary
calc_dual_scale_from_pt(pt, detail)calc_radius(viewer, p1, p2)calc_rotation_from_pt(pt, detail)calc_scale_from_pt(pt, detail)calc_vertexes(start_cx, start_cy, end_cx, end_cy)canvascoords(viewer, data_x, data_y[, center])contains(x, y)For backward compatibility. contains_arr(x_arr, y_arr)For backward compatibility. contains_pt(pt)contains_pts(points)convert_mapper(tomap)Converts our object from using one coordinate map to another. draw_arrowhead(cr, x1, y1, x2, y2)draw_caps(cr, cap, points[, radius])draw_edit(cr, viewer)get_bbox([points])Get bounding box of this object. get_center_pt()Return the geometric average of points as data_points. get_cpoints(viewer[, points, no_rotate])get_data(*args)get_data_points([points])Points returned are in data coordinates. get_move_scale_rotate_pts(viewer)Returns 3 edit control points for editing this object: a move point, a scale point and a rotate point. get_num_points()get_point_by_index(i)get_points()Get the set of points that is used to draw the object. get_pt(viewer, points, pt[, canvas_radius])Takes an array of points pointsand a target pointpt.get_reference_pt()initialize(canvas, viewer, logger)is_compound()move_delta(xoff, yoff)For backward compatibility. move_delta_pt(off_pt)move_to(xdst, ydst)For backward compatibility. move_to_pt(dst_pt)point_within_line(points, p_start, p_stop, …)point_within_radius(points, pt, canvas_radius)Points pointsand pointptare in data coordinates.rerotate_by_deg(thetas, detail)rescale_by(scale_x, scale_y, detail)For backward compatibility. rescale_by_factors(factors, detail)rotate(theta_deg[, xoff, yoff])For backward compatibility. rotate_by(theta_deg)For backward compatibility. rotate_by_deg(thetas)rotate_deg(thetas, offset)scale_by(scale_x, scale_y)For backward compatibility. scale_by_factors(factors)scale_font(viewer)select_contains(viewer, x, y)For backward compatibility. select_contains_pt(viewer, pt)set_data(**kwdargs)set_data_points(points)Input pointsmust be in data coordinates, will be converted to the coordinate space of the object and stored.set_point_by_index(i, pt)setup_edit(detail)subclass should override as necessary. swapxy(x1, y1, x2, y2)sync_state()This method called when changes are made to the parameters. use_coordmap(mapobj)within_line(viewer, points, p_start, p_stop, …)Points pointsand line endpointsp_start,p_stopare in data coordinates.within_radius(viewer, points, pt, canvas_radius)Points pointsand pointptare in data coordinates.Methods Documentation
-
contains(x, y)[source]¶ For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use contains_pt() instead.
-
contains_arr(x_arr, y_arr)[source]¶ For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use contains_pts() instead.
-
convert_mapper(tomap)[source]¶ Converts our object from using one coordinate map to another.
NOTE: In some cases this only approximately preserves the equivalent point values when transforming between coordinate spaces.
-
get_bbox(points=None)[source]¶ Get bounding box of this object.
Returns: (p1, p2, p3, p4): a 4-tuple of the points in data coordinates,
beginning with the lower-left and proceeding counter-clockwise.
-
get_move_scale_rotate_pts(viewer)[source]¶ Returns 3 edit control points for editing this object: a move point, a scale point and a rotate point. These points are all in data coordinates.
-
get_points()[source]¶ Get the set of points that is used to draw the object.
Points are returned in data coordinates.
-
get_pt(viewer, points, pt, canvas_radius=None)[source]¶ Takes an array of points
pointsand a target pointpt. Returns the first index of the point that is within the radius of the target point. If none of the points are within the radius, returns None.
-
move_delta(xoff, yoff)[source]¶ For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use move_delta_pt instead.
-
move_to(xdst, ydst)[source]¶ For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use move_to_pt() instead.
-
point_within_radius(points, pt, canvas_radius, scales=(1.0, 1.0))[source]¶ Points
pointsand pointptare in data coordinates. Return True for points within the circle defined by a center at pointptand within canvas_radius.
-
rescale_by(scale_x, scale_y, detail)[source]¶ For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use rescale_by_factors() instead.
-
rotate(theta_deg, xoff=0, yoff=0)[source]¶ For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use rotate_deg() instead.
-
rotate_by(theta_deg)[source]¶ For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use rotate_by_deg() instead.
-
scale_by(scale_x, scale_y)[source]¶ For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use scale_by_factors() instead.
-
select_contains(viewer, x, y)[source]¶ For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use select_contains_pt() instead.
-
set_data_points(points)[source]¶ Input
pointsmust be in data coordinates, will be converted to the coordinate space of the object and stored.
-
sync_state()[source]¶ This method called when changes are made to the parameters. subclasses should override if they need any special state handling.
-
within_line(viewer, points, p_start, p_stop, canvas_radius)[source]¶ Points
pointsand line endpointsp_start,p_stopare in data coordinates. Return True for points within the line defined by a line from p_start to p_end and withincanvas_radius. The distance between points is scaled by the viewer’s canvas scale.
-