コード例 #1
0
ファイル: beziergon.c プロジェクト: brunetton/dia
static void
beziergon_draw(Beziergon *beziergon, DiaRenderer *renderer)
{
  DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer);

  BezierShape *bez = &beziergon->bezier;
  BezPoint *points;
  int n;
  
  points = &bez->bezier.points[0];
  n = bez->bezier.num_points;

  renderer_ops->set_linewidth(renderer, beziergon->line_width);
  renderer_ops->set_linestyle(renderer, beziergon->line_style);
  renderer_ops->set_dashlength(renderer, beziergon->dashlength);
  renderer_ops->set_linejoin(renderer, beziergon->line_join);
  renderer_ops->set_linecaps(renderer, LINECAPS_BUTT);

  if (beziergon->show_background)
    renderer_ops->fill_bezier(renderer, points, n, &beziergon->inner_color);

  renderer_ops->draw_bezier(renderer, points, n, &beziergon->line_color);

  /* these lines should only be displayed when object is selected.
   * Unfortunately the draw function is not aware of the selected
   * state.  This is a compromise until I fix this properly. */
  if (renderer->is_interactive &&
      dia_object_is_selected((DiaObject*)beziergon)) {
    bezier_draw_control_lines (beziergon->bezier.bezier.num_points, beziergon->bezier.bezier.points, renderer);
  }
}
コード例 #2
0
ファイル: textobj.c プロジェクト: GNOME/dia
static void
textobj_draw(Textobj *textobj, DiaRenderer *renderer)
{
  assert(textobj != NULL);
  assert(renderer != NULL);

  if (textobj->show_background) {
    Rectangle box;
    Point ul, lr;
    text_calc_boundingbox (textobj->text, &box);
    ul.x = box.left - textobj->margin;
    ul.y = box.top - textobj->margin;
    lr.x = box.right + textobj->margin;
    lr.y = box.bottom + textobj->margin;
    if (textobj->text_angle == 0) {
      DIA_RENDERER_GET_CLASS (renderer)->draw_rect (renderer, &ul, &lr, &textobj->fill_color, NULL);
    } else {
      Point poly[4];

      _textobj_get_poly (textobj, poly);
      DIA_RENDERER_GET_CLASS (renderer)->draw_polygon (renderer, poly, 4, &textobj->fill_color, NULL);
    }
  }
  if (textobj->text_angle == 0) {
    text_draw(textobj->text, renderer);
  } else {
    DIA_RENDERER_GET_CLASS (renderer)->draw_rotated_text (renderer, textobj->text,
							  &textobj->text_handle.pos, textobj->text_angle);
    /* XXX: interactive case not working correctly */
    if (renderer->is_interactive &&
        dia_object_is_selected(&textobj->object) &&
	textobj->text->focus.has_focus) {
      /* editing is not rotated */
      text_draw(textobj->text, renderer);
    }

  }
}
コード例 #3
0
ファイル: bezier.c プロジェクト: GNOME/dia
static void
bezierline_draw(Bezierline *bezierline, DiaRenderer *renderer)
{
  Point gap_points[4]; /* two first and two last bez points */

  BezierConn *bez = &bezierline->bez;
  DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer);

  renderer_ops->set_linewidth(renderer, bezierline->line_width);
  renderer_ops->set_linestyle(renderer, bezierline->line_style, bezierline->dashlength);
  renderer_ops->set_linejoin(renderer, bezierline->line_join);
  renderer_ops->set_linecaps(renderer, bezierline->line_caps);

  if (connpoint_is_autogap(bez->object.handles[0]->connected_to) ||
      connpoint_is_autogap(bez->object.handles[3*(bez->bezier.num_points-1)]->connected_to) ||
      bezierline->absolute_start_gap || bezierline->absolute_end_gap) {

    compute_gap_points(bezierline,gap_points);
    exchange_bez_gap_points(bez,gap_points);
    renderer_ops->draw_bezier_with_arrows(renderer, bez->bezier.points, bez->bezier.num_points,
					 bezierline->line_width,
					 &bezierline->line_color,
					 &bezierline->start_arrow,
					 &bezierline->end_arrow);
    exchange_bez_gap_points(bez,gap_points);
  } else {
    renderer_ops->draw_bezier_with_arrows(renderer, bez->bezier.points, bez->bezier.num_points,
					  bezierline->line_width,
					  &bezierline->line_color,
					  &bezierline->start_arrow,
					  &bezierline->end_arrow);
  }

#if 0
  renderer_ops->draw_bezier(renderer, bez->bezier.points, bez->bezier.num_points,
			     &bezierline->line_color);

  if (bezierline->start_arrow.type != ARROW_NONE) {
    arrow_draw(renderer, bezierline->start_arrow.type,
	       &bez->bezier.points[0].p1, &bez->bezier.points[1].p1,
	       bezierline->start_arrow.length, bezierline->start_arrow.width,
	       bezierline->line_width,
	       &bezierline->line_color, &color_white);
  }
  if (bezierline->end_arrow.type != ARROW_NONE) {
    arrow_draw(renderer, bezierline->end_arrow.type,
	       &bez->bezier.points[bez->bezier.num_points-1].p3,
	       &bez->bezier.points[bez->bezier.num_points-1].p2,
	       bezierline->end_arrow.length, bezierline->end_arrow.width,
	       bezierline->line_width,
	       &bezierline->line_color, &color_white);
  }
#endif

  /* Only display lines while selected.  Calling dia_object_is_selected()
   * every time may take a little long.  Some time can be saved by storing
   * whether the object is currently selected in bezierline_select, and
   * only checking while selected.  But we'll do that if needed.
   */
  if (renderer->is_interactive &&
      dia_object_is_selected(&bezierline->bez.object)) {
    bezier_draw_control_lines(bezierline->bez.bezier.num_points, bezierline->bez.bezier.points, renderer);
  }
}
コード例 #4
0
ファイル: arc.c プロジェクト: jbohren-forks/dia
static void
arc_draw(Arc *arc, DiaRenderer *renderer)
{
    DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer);
    Point *endpoints;
    Point gaptmp[3];
    ConnectionPoint *start_cp, *end_cp;

    assert(arc != NULL);
    assert(renderer != NULL);

    endpoints = &arc->connection.endpoints[0];

    gaptmp[0] = endpoints[0];
    gaptmp[1] = endpoints[1];
    start_cp = arc->connection.endpoint_handles[0].connected_to;
    end_cp = arc->connection.endpoint_handles[1].connected_to;

    TRACE(printf("drawing arc:\n start:%f°:%f,%f \tend:%f°:%f,%f\n",arc->angle1,endpoints[0].x,endpoints[0].y, arc->angle2,endpoints[1].x,endpoints[1].y));

    if (connpoint_is_autogap(start_cp)) {
        TRACE(printf("computing start intersection\ncurve_distance: %f\n",arc->curve_distance));
        if (arc->curve_distance < 0)
            calculate_arc_object_edge(arc, arc->angle1, arc->angle2, start_cp->object, &gaptmp[0], FALSE);
        else
            calculate_arc_object_edge(arc, arc->angle2, arc->angle1, start_cp->object, &gaptmp[0], TRUE);
    }
    if (connpoint_is_autogap(end_cp)) {
        TRACE(printf("computing end intersection\ncurve_distance: %f\n",arc->curve_distance));
        if (arc->curve_distance < 0)
            calculate_arc_object_edge(arc, arc->angle2, arc->angle1, end_cp->object, &gaptmp[1], TRUE);
        else
            calculate_arc_object_edge(arc, arc->angle1, arc->angle2, end_cp->object, &gaptmp[1], FALSE);
    }

    /* compute new middle_point */
    arc_compute_midpoint(arc, &gaptmp[0], &gaptmp[1], &gaptmp[2]);

    renderer_ops->set_linewidth(renderer, arc->line_width);
    renderer_ops->set_linestyle(renderer, arc->line_style);
    renderer_ops->set_dashlength(renderer, arc->dashlength);
    renderer_ops->set_linecaps(renderer, arc->line_caps);

    /* Special case when almost line: */
    if (arc_is_line (arc)) {
        TRACE(printf("drawing like a line\n"));
        renderer_ops->draw_line_with_arrows(renderer,
                                            &gaptmp[0], &gaptmp[1],
                                            arc->line_width,
                                            &arc->arc_color,
                                            &arc->start_arrow,
                                            &arc->end_arrow);
        return;
    }

    renderer_ops->draw_arc_with_arrows(renderer,
                                       &gaptmp[0],
                                       &gaptmp[1],
                                       &gaptmp[2],
                                       arc->line_width,
                                       &arc->arc_color,
                                       &arc->start_arrow,
                                       &arc->end_arrow);
    if (renderer->is_interactive &&
            dia_object_is_selected(&arc->connection.object)) {
        /* draw the central angle */
        Color line_color = { 0.0, 0.0, 0.6, 1.0 };

        renderer_ops->set_linewidth(renderer, 0);
        renderer_ops->set_linestyle(renderer, LINESTYLE_DOTTED);
        renderer_ops->set_dashlength(renderer, 1);
        renderer_ops->set_linejoin(renderer, LINEJOIN_MITER);
        renderer_ops->set_linecaps(renderer, LINECAPS_BUTT);

        renderer_ops->draw_line(renderer, &endpoints[0], &arc->center, &line_color);
        renderer_ops->draw_line(renderer, &endpoints[1], &arc->center, &line_color);
    }
}