CanvasObjectBase

class ginga.canvas.CanvasObject.CanvasObjectBase(**kwdargs)[source]

Bases: ginga.misc.Callback.Callbacks

This 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 points and a target point pt.

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 points and point pt are 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 points must 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 points and line endpoints p_start, p_stop are in data coordinates.

within_radius(viewer, points, pt, canvas_radius)

Points points and point pt are in data coordinates.

Methods Documentation

calc_dual_scale_from_pt(pt, detail)[source]
calc_radius(viewer, p1, p2)[source]
calc_rotation_from_pt(pt, detail)[source]
calc_scale_from_pt(pt, detail)[source]
calc_vertexes(start_cx, start_cy, end_cx, end_cy, arrow_length=10, arrow_degrees=0.35)[source]
canvascoords(viewer, data_x, data_y, center=None)[source]
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.

contains_pt(pt)[source]
contains_pts(points)[source]
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.

draw_arrowhead(cr, x1, y1, x2, y2)[source]
draw_caps(cr, cap, points, radius=None)[source]
draw_edit(cr, viewer)[source]
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_center_pt()[source]

Return the geometric average of points as data_points.

get_cpoints(viewer, points=None, no_rotate=False)[source]
get_data(*args)[source]
get_data_points(points=None)[source]

Points returned are in data coordinates.

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_num_points()[source]
get_point_by_index(i)[source]
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 points and a target point pt. 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.

get_reference_pt()[source]
initialize(canvas, viewer, logger)[source]
is_compound()[source]
move_delta(xoff, yoff)[source]

For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use move_delta_pt instead.

move_delta_pt(off_pt)[source]
move_to(xdst, ydst)[source]

For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use move_to_pt() instead.

move_to_pt(dst_pt)[source]
point_within_line(points, p_start, p_stop, canvas_radius)[source]
point_within_radius(points, pt, canvas_radius, scales=1.0, 1.0)[source]

Points points and point pt are in data coordinates. Return True for points within the circle defined by a center at point pt and within canvas_radius.

rerotate_by_deg(thetas, detail)[source]
rescale_by(scale_x, scale_y, detail)[source]

For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use rescale_by_factors() instead.

rescale_by_factors(factors, detail)[source]
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.

rotate_by_deg(thetas)[source]
rotate_deg(thetas, offset)[source]
scale_by(scale_x, scale_y)[source]

For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use scale_by_factors() instead.

scale_by_factors(factors)[source]
scale_font(viewer)[source]
select_contains(viewer, x, y)[source]

For backward compatibility. TO BE DEPRECATED–DO NOT USE. Use select_contains_pt() instead.

select_contains_pt(viewer, pt)[source]
set_data(**kwdargs)[source]
set_data_points(points)[source]

Input points must be in data coordinates, will be converted to the coordinate space of the object and stored.

set_point_by_index(i, pt)[source]
setup_edit(detail)[source]

subclass should override as necessary.

swapxy(x1, y1, x2, y2)[source]
sync_state()[source]

This method called when changes are made to the parameters. subclasses should override if they need any special state handling.

use_coordmap(mapobj)[source]
within_line(viewer, points, p_start, p_stop, canvas_radius)[source]

Points points and line endpoints p_start, p_stop are in data coordinates. Return True for points within the line defined by a line from p_start to p_end and within canvas_radius. The distance between points is scaled by the viewer’s canvas scale.

within_radius(viewer, points, pt, canvas_radius)[source]

Points points and point pt are in data coordinates. Return True for points within the circle defined by a center at point pt and within canvas_radius. The distance between points is scaled by the canvas scale.