def UpdateZoomGizmo(scale, xrange, yrange): global axis, zoom_factor, img_offset, z_container, z_box aspect = yrange / xrange # Change the size of the Gizmo size = 320 if zoom_factor > 1: gizmo_w = size * scale gizmo_h = size * scale * aspect gizmo_pos = img_offset[0] - xrange * scale, img_offset[ 1] + yrange * scale - gizmo_h if z_container is None: z_container = Rectangle(gizmo_pos, gizmo_w, gizmo_h, edgecolor="w", facecolor='none') z_container.label = "zoom_container" z_box = Rectangle(gizmo_pos, gizmo_w, gizmo_h, alpha=0.5) z_box.label = "zoom_box" axis.add_artist(z_container) axis.add_artist(z_box) else: z_container.set_xy(gizmo_pos) z_container.set_width(gizmo_w) z_container.set_height(gizmo_h) z_box.set_x(gizmo_pos[0] + 0.5 * (img_offset[0] * gizmo_w / xrange - gizmo_w * scale)) z_box.set_y(gizmo_pos[1] + 0.5 * (img_offset[1] * gizmo_h / yrange - gizmo_h * scale)) z_box.set_width(gizmo_w * scale) z_box.set_height(gizmo_h * scale) else: if z_container is not None: z_container.remove() z_container = None z_box.remove() z_box = None
def UpdateCanvasOverlay(): for a in reversed(axis.artists): if a.label == "zoom_container" or a.label == "zoom_box": continue a.remove() for t in reversed(axis.texts): t.remove() stIndex = 0 for ts in TrackedStars: trackPos = (ts.currPos[1], ts.currPos[0]) if len(ts.trackedPos) > 0: trackPos = ts.trackedPos[CurrentFile] col = "w" if ts.star.type == 1: col = "y" if len(trackPos) == 0: continue if CurrentFile in ts.lostPoints: col = "r" if Settings._SHOW_TRACKEDPOS_.get() == 1: try: points = ts.trackedPos[max(CurrentFile - 4, 0):CurrentFile + 1] poly = Polygon(points, closed=False, fill=False, edgecolor="w", linewidth=2) poly.label = "Poly" + str(stIndex) axis.add_artist(poly) except: pass rect_pos = (trackPos[0] - ts.star.radius, trackPos[1] - ts.star.radius) rect = Rectangle(rect_pos, ts.star.radius * 2, ts.star.radius * 2, edgecolor=col, facecolor='none') rect.label = "Rect" + str(stIndex) axis.add_artist(rect) text_pos = (trackPos[0], trackPos[1] - ts.star.radius - 6) text = axis.annotate(ts.star.name, text_pos, color=col, weight='bold', fontsize=6, ha='center', va='center') text.label = "Text" + str(stIndex) stIndex += 1 canvas.draw_idle()
def UpdateCanvasOverlay(): # Si se elimina el primer elemento de un lista en un ciclo for, entonces # ya no podra seguir iterando, lo que producir errores, se utiliza reversed para eliminar # el ultimo elemento de la lista primero y asi. for a in reversed(axis.artists): if a.label == "zoom_container" or a.label == "zoom_box": continue a.remove() for t in reversed(axis.texts): t.remove() for s in Stars: rect_pos = (s.location[1] - s.radius, s.location[0] - s.radius) rect = Rectangle(rect_pos, s.radius * 2, s.radius * 2, edgecolor="w", facecolor='none') rect.label = "Rect" + str(Stars.index(s)) bound_pos = (s.location[1] - s.bounds, s.location[0] - s.bounds) bound = Rectangle(bound_pos, s.bounds * 2, s.bounds * 2, edgecolor="y", linestyle='dashed', facecolor='none') bound.label = "Bound" + str(Stars.index(s)) axis.add_artist(rect) axis.add_artist(bound) text_pos = (s.location[1], s.location[0] - s.bounds - 6) text = axis.annotate(s.name, text_pos, color='w', weight='bold', fontsize=6, ha='center', va='center') text.label = "Text" + str(Stars.index(s)) canvas.draw_idle()