// Draw the dio scan void dio_draw(dio_t *dio) { int i; char ntext[64], str[1024]; uint32_t digin = dio->proxy->digin; uint32_t count = dio->proxy->count; rtk_fig_show(dio->fig, 1); rtk_fig_clear(dio->fig); str[0] = '\0'; if (count > 0) { for (i = count-1; i >= 0 ; i--) { snprintf(str, sizeof(str), "%s%i", str, (digin & (1 << i)) > 0); if (3==(count-1-i)%4) snprintf(str, sizeof(str), "%s ", str); } } rtk_fig_color_rgb32(dio->fig, COLOR_DIO); rtk_fig_text(dio->fig, +1, +0.5, 0, str); return; }
int main(int argc, char **argv) { rtk_app_t *app; rtk_canvas_t *canvas; rtk_fig_t *fig1, *fig2, *fig3; int i; app = rtk_app_create(); canvas = rtk_canvas_create(app); rtk_app_start(app); fig1 = rtk_fig_create(canvas, NULL); rtk_fig_rectangle(fig1, 0, 0, 0, 1.0, 0.5); rtk_fig_ellipse(fig1, 0, 0, 0, 1.0, 0.5); rtk_fig_arrow(fig1, 0, 0, M_PI / 4, 1.0, 0.2); fig2 = rtk_fig_create(canvas, fig1); rtk_fig_origin(fig2, 1, 0, 0); rtk_fig_scale(fig2, 0.5); rtk_fig_rectangle(fig2, 0, 0, 0, 1.0, 0.5); rtk_fig_ellipse(fig2, 0, 0, 0, 1.0, 0.5); rtk_fig_arrow(fig2, 0, 0, M_PI / 4, 1.0, 0.2); fig3 = rtk_fig_create(canvas, NULL); i = 0; while (!rtk_app_quit(app)) { //rtk_fig_origin(fig1, 0, 0, i * 0.012); rtk_fig_clear(fig3); rtk_fig_origin(fig3, sin(i * 0.07), -1.0, 0); rtk_fig_rectangle(fig3, 0, 0, i * 0.1, 0.5, 1.0); rtk_fig_arrow(fig3, 0, 0, -i * 0.1, 0.8, 0.20); rtk_fig_text(fig3, 0.0, 0.2, 0, "some text"); i++; usleep(20000); } rtk_app_stop(app); rtk_canvas_export(canvas, "test.fig"); //rtk_canvas_destroy(canvas); rtk_app_destroy(app); return 0; }
// Update the objects void ident_update() { int i, j; double r; char text[64]; double ax, ay, aa, bx, by, ba; mezz_object_t *object; rtk_fig_clear(ident->fig); for (i = 0; i < ident->objectlist->count; i++) { object = ident->objectlist->objects + i; if (!object->valid) continue; r = object->max_sep; dewarp_world2image(object->px, object->py, &ax, &ay); dewarp_world2image(object->px + r * cos(object->pa+M_PI_2), object->py + r * sin(object->pa+M_PI_2), &bx, &by); rtk_fig_color(ident->fig, COLOR_IDENT); rtk_fig_arrow_ex(ident->fig, ax, ay, bx, by, 5); snprintf(text, sizeof(text), "obj [%d] (%.2f, %.2f)\n (%.0f, %.0f)", i, object->px, object->py, (object->ablob.ox + object->bblob.ox) / 2.0, (object->ablob.oy + object->bblob.oy) / 2.0); rtk_fig_text(ident->fig, ax + 10, ay - 20, 0, text); for (j = 0; j < 4; j++) { aa = object->pa + M_PI/4 + j * M_PI/2; ba = object->pa + M_PI/4 + (j + 1) * M_PI/2; dewarp_world2image(object->px + r * cos(aa), object->py + r * sin(aa), &ax, &ay); dewarp_world2image(object->px + r * cos(ba), object->py + r * sin(ba), &bx, &by); rtk_fig_line(ident->fig, ax, ay, bx, by); } } }
// Draw the aio scan void aio_draw(aio_t *aio) { int i; char ntext[64], text[1024]; rtk_fig_show(aio->fig, 1); rtk_fig_clear(aio->fig); text[0] = 0; for (i = 0; i < aio->proxy->voltages_count; i++) { snprintf(ntext, sizeof(ntext), "%i: %0.3f\n", i, aio->proxy->voltages[i]); strcat(text, ntext); } // Draw in the aio reading // TODO: get text origin from somewhere rtk_fig_color_rgb32(aio->fig, COLOR_AIO); rtk_fig_text(aio->fig, +1, 0, 0, text); return; }