CanvasObjectBase
- class ginga.canvas.CanvasObject.CanvasObjectBase(**kwdargs)[source]
Bases:
CallbacksThis is the abstract base class for a CanvasObject. A CanvasObject is an item that can be placed on a Ginga canvas.
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)contains_pt(pt)contains_pts(points)convert_mapper(tomap)Converts our object from using one coordinate map to another.
copy([share])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.
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_llur()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 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.initialize(canvas, viewer, logger)move_delta_pt(off_pt)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_factors(factors, detail)rotate_by_deg(thetas)rotate_deg(thetas, offset)scale_by_factors(factors)scale_font(viewer)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)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
- 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.
- 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.
- 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.