Example #1
0
File: line.c Project: mpuels/dia
static void
line_save(Line *line, ObjectNode obj_node, DiaContext *ctx)
{
#ifdef DEBUG
  dia_object_sanity_check((DiaObject*)line, "Saving line");
#endif

  connection_save(&line->connection, obj_node, ctx);

  connpointline_save(line->cpl, obj_node, "numcp", ctx);

  if (!color_equals(&line->line_color, &color_black))
    data_add_color(new_attribute(obj_node, "line_color"),
		   &line->line_color, ctx);

  if (line->line_width != 0.1)
    data_add_real(new_attribute(obj_node, PROP_STDNAME_LINE_WIDTH),
		  line->line_width, ctx);

  if (line->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  line->line_style, ctx);

  if (line->line_caps != LINECAPS_BUTT)
    data_add_enum(new_attribute(obj_node, "line_caps"),
                  line->line_caps, ctx);

  if (line->start_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &line->start_arrow,
	       "start_arrow", "start_arrow_length", "start_arrow_width", ctx);
  }

  if (line->end_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &line->end_arrow,
	       "end_arrow", "end_arrow_length", "end_arrow_width", ctx);
  }

  if (line->absolute_start_gap)
    data_add_real(new_attribute(obj_node, "absolute_start_gap"),
                 line->absolute_start_gap, ctx);
  if (line->absolute_end_gap)
    data_add_real(new_attribute(obj_node, "absolute_end_gap"),
                 line->absolute_end_gap, ctx);

  if (line->line_style != LINESTYLE_SOLID && line->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
		  line->dashlength, ctx);
}
Example #2
0
/**
 * The only purpose is to check whether the passed compound object is in
 * a consitent state. If it's not, abort the program with a message!
 */
static void
compound_sanity_check (Compound * c, gchar *msg)
{
  DiaObject * obj;
  Point * ph, * pc;
  gint i;

  obj = &c->object;

  dia_object_sanity_check (obj, msg);

  dia_assert_true (obj->num_connections == 1,
                   "%s: Compound %p has not exactly one connection but %d!\n",
                   msg, c, obj->num_connections);

  dia_assert_true (obj->connections[0] == &c->mount_point,
                   "%s: Compound %p connection mismatch %p != %p!\n",
                   msg, c, obj->connections[0], &c->mount_point);

  dia_assert_true (obj->num_handles >= 3,
                   "%s: Object %p has only %d handles, but at least %d are required!\n",
                   msg, c, obj->num_handles, 3);

  dia_assert_true (obj->num_handles == (c->num_arms+1),
                   "%s: Compound %p has %d handles and %d arms. The number of arms must be the number of handles decreased by one!\n",
                   msg, c, obj->num_handles, c->num_arms);

  for (i = 0; i < obj->num_handles; i++)
    dia_assert_true (obj->handles[i] == &c->handles[i],
                     "%s: Compound %p handles mismatch at %d: %p != %p!\n",
                     msg, c, i, obj->handles[i], &c->handles[i]);

  ph = &obj->handles[0]->pos;
  pc = &c->mount_point.pos;
  dia_assert_true (ph->x == pc->x && ph->y == pc->y,
                   "%s: Compound %p handle[0]/mount_point position mismatch: (%f, %f) != (%f, %f)!\n",
                   msg, c, ph->x, ph->y, pc->x, pc->y);
}