- struct drawing_context *cxt = (struct drawing_context *) user_data;
- double *d = (double*)data;
- fprintf(stderr, "draw_point(x=%g(%g) y=%g(%g)) xscaling=%g yscaling=%g xoffset=%g yoffset=%g\n", d[0], (d[0] + cxt->xoffset)*cxt->xscaling, d[1], (d[1] + cxt->yoffset)*cxt->yscaling, cxt->xscaling, cxt->yscaling, cxt->xoffset, cxt->yoffset);
- cairo_arc(cxt->cr, (d[0] + cxt->xoffset)*cxt->xscaling, (d[1] + cxt->yoffset)*cxt->yscaling, cxt->radius, 0, 2*M_PI);
- cairo_set_source_rgb(cxt->cr, 1, 1, 1);
- cairo_fill_preserve(cxt->cr);
- cairo_set_source_rgb(cxt->cr, 0, 0, 0);
- cairo_stroke(cxt->cr);
+ struct drawing_context *cxt = user_data;
+ struct graph_point *pt = data;
+ double x = (pt->x + cxt->xoffset)*cxt->xscaling;
+ double y = (pt->y + cxt->yoffset)*cxt->yscaling;
+ double bezier_p2_x = (pt->bezier_to_x + cxt->xoffset)*cxt->xscaling;
+ double bezier_p2_y = (pt->bezier_to_y + cxt->yoffset)*cxt->yscaling;
+ #ifdef DEBUG
+ fprintf(stderr, "\tcxt=(cr=%x, rad=%g, xoffset=%g, yoffset=%g, xscaling=%g, yscaling=%g, p0_x=%g, p0_y=%g, p1_x=%g, p1_y=%g, draw_line=%d, not_first_point=%d)\n", (unsigned int)cxt->cr, cxt->radius, cxt->xoffset, cxt->yoffset, cxt->xscaling, cxt->yscaling, cxt->bezier_p0_x, cxt->bezier_p0_y, cxt->bezier_p1_x, cxt->bezier_p1_y, cxt->draw_line, cxt->not_first_point);
+ #endif
+ /*Draw line to here if we need to.*/
+ if(cxt->draw_line && cxt->not_first_point) {
+ /*Note that the cxt points are already normalized*/
+ //cairo_move_to(cxt->cr, cxt->bezier_p0_x, cxt->bezier_p0_y);
+ cairo_curve_to(cxt->cr, cxt->bezier_p1_x, cxt->bezier_p1_y, bezier_p2_x, bezier_p2_y, x, y);
+ }else{
+ cairo_move_to(cxt->cr, x, y);
+ }
+ #ifdef DEBUG
+ fprintf(stderr, "\t\tpt=(x=%g, y=%g, label=%s, from_x=%g, from_y=%g, to_x=%g, to_y=%g)\n", pt->x, pt->y, pt->label->str, pt->bezier_from_x, pt->bezier_from_y, pt->bezier_to_x, pt->bezier_to_y);
+ fprintf(stderr, "\t\tx=%g, y=%g, p2_x=%g, p2_y=%g\n", x, y, bezier_p2_x, bezier_p2_y);
+ #endif
+ cairo_arc(cxt->cr, x, y, cxt->radius, 0, 2*M_PI);
+ if(pt->label != NULL) {
+ cairo_save(cxt->cr);
+ cairo_translate(cxt->cr, 0, 1);
+ cairo_scale(cxt->cr, 1, -1);
+ cairo_show_text(cxt->cr, pt->label->str);
+ cairo_restore(cxt->cr);
+ }
+ /*Set up the context for the next point*/
+ cxt->bezier_p0_x = x;
+ cxt->bezier_p0_y = y;
+ cxt->bezier_p1_x = (pt->bezier_from_x + cxt->xoffset)*cxt->xscaling;
+ cxt->bezier_p1_y = (pt->bezier_from_y + cxt->yoffset)*cxt->yscaling;
+ cxt->not_first_point=1;