int plotstuff_text_xy(plot_args_t* pargs, double x, double y, const char* label) { assert(pargs->cairo); get_text_position(pargs, pargs->cairo, label, &x, &y); plotstuff_move_to(pargs, x, y); cairo_show_text(pargs->cairo, label); return 0; }
void plotstuff_stack_text(plot_args_t* pargs, cairo_t* cairo, const char* txt, double px, double py) { cairocmd_t cmd; cairocmd_init(&cmd); set_cmd_args(pargs, &cmd); get_text_position(pargs, cairo, txt, &px, &py); cmd.type = TEXT; if (pargs->bg_rgba[3] > 0) { int dx, dy; logverb("Background text RGB [%g, %g, %g] alpha %g\n", pargs->bg_rgba[0], pargs->bg_rgba[1], pargs->bg_rgba[2], pargs->bg_rgba[3]); cmd.layer = pargs->text_bg_layer; memcpy(cmd.rgba, pargs->bg_rgba, sizeof(cmd.rgba)); for (dy=-1; dy<=1; dy++) { for (dx=-1; dx<=1; dx++) { cmd.text = strdup(txt); cmd.x = px + dx; cmd.y = py + dy; add_cmd(pargs, &cmd); } } } else logverb("No background behind text\n"); cmd.layer = pargs->text_fg_layer; memcpy(cmd.rgba, pargs->rgba, sizeof(cmd.rgba)); cmd.text = strdup(txt); cmd.x = px; cmd.y = py; add_cmd(pargs, &cmd); }
int plotstuff_text_radec(plot_args_t* pargs, double ra, double dec, const char* label) { double x,y; if (!plotstuff_radec2xy(pargs, ra, dec, &x, &y)) { ERROR("Failed to convert RA,Dec (%g,%g) to pixel position in plot_text_radec\n", ra, dec); return -1; } assert(pargs->cairo); //plotstuff_stack_text(pargs, pargs->cairo, label, x, y); get_text_position(pargs, pargs->cairo, label, &x, &y); plotstuff_move_to(pargs, x, y); cairo_show_text(pargs->cairo, label); return 0; }
static void draw_area_ui_object (ui_object *obj) { float x, y, x1, y1, x2, y2; int redraw_flag = FALSE, masked, width, height, pitch; font_types font_id; area_ui_object *area; struct SCREEN *old_active_screen, *memory_graphic; unsigned short int *graphic; struct ZOOMABLE_GRAPHIC *zoomable_graphic; unsigned char *data; ui_object *parent; if (get_ui_object_redraw (obj)) { area = (area_ui_object *) obj->data; //debug_log ("AR_DRAW: drawing area %f, %f %f, %f", area->x, area->y, area->x_size, area->y_size); x1 = area->x; y1 = area->y; x2 = x1 + area->x_size; y2 = y1 + area->y_size; old_active_screen = get_active_screen (); if (get_ui_object_active_screen (obj)) { set_active_screen (get_ui_object_active_screen (obj)); } else { set_active_screen (video_screen); } if (lock_screen (active_screen)) { switch (get_ui_object_graphic_type (obj)) { case UI_OBJECT_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_MEMORY_GRAPHIC: { memory_graphic = get_ui_object_memory_graphic (obj); if (lock_screen (memory_graphic)) { width = get_screen_width (memory_graphic); height = get_screen_height (memory_graphic); data = get_screen_data (memory_graphic); pitch = get_screen_pitch (memory_graphic); masked = get_ui_object_clear (obj); ui_draw_memory_graphic (obj, x1, y1, x2, y2, width, height, pitch, masked); unlock_screen (memory_graphic); } redraw_flag = TRUE; break; } case UI_OBJECT_ALPHA_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_alpha_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_alpha_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_ZOOMABLE_PALETTE_GRAPHIC: { if (!get_ui_object_clear (obj)) { zoomable_graphic = get_ui_object_zoomable_palette_graphic (obj); draw_zoomable_graphic (zoomable_graphic, area->cx, area->cy, x1, y1, x2, y2, area->zoom); redraw_flag = TRUE; } break; } case UI_OBJECT_NO_GRAPHIC: default: { if (!get_ui_object_clear (obj)) { ui_draw_area (x1, y1, x2, y2); redraw_flag = TRUE; } } } // text position if (get_ui_object_text (obj)) { font_id = get_ui_font (); set_ui_font (get_ui_object_font (obj)); get_text_position (&x, &y, x1, y1, x2, y2, obj); ui_display_text (get_ui_object_text (obj), x, y); set_ui_font (font_id); redraw_flag = TRUE; } if (redraw_flag) { set_ui_repaint_area (x1 + ui_x_origin, y1 + ui_y_origin, x2 + ui_x_origin + 1, y2 + ui_y_origin + 1); } unlock_screen (active_screen); } set_active_screen (old_active_screen); area->redraw --; call_ui_object_draw_function (obj, NULL); } }