예제 #1
0
파일: beziergon.c 프로젝트: brunetton/dia
static DiaObject *
beziergon_load(ObjectNode obj_node, int version, DiaContext *ctx)
{
  Beziergon *beziergon;
  BezierShape *bez;
  DiaObject *obj;
  AttributeNode attr;

  beziergon = g_malloc0(sizeof(Beziergon));

  bez = &beziergon->bezier;
  obj = &bez->object;
  
  obj->type = &beziergon_type;
  obj->ops = &beziergon_ops;

  beziershape_load(bez, obj_node, ctx);

  beziergon->line_color = color_black;
  attr = object_find_attribute(obj_node, "line_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &beziergon->line_color, ctx);

  beziergon->line_width = 0.1;
  attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
  if (attr != NULL)
    beziergon->line_width = data_real(attribute_first_data(attr), ctx);

  beziergon->inner_color = color_white;
  attr = object_find_attribute(obj_node, "inner_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &beziergon->inner_color, ctx);
  
  beziergon->show_background = TRUE;
  attr = object_find_attribute(obj_node, "show_background");
  if (attr != NULL)
    beziergon->show_background = data_boolean(attribute_first_data(attr), ctx);

  beziergon->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    beziergon->line_style = data_enum(attribute_first_data(attr), ctx);

  beziergon->line_join = LINEJOIN_MITER;
  attr = object_find_attribute(obj_node, "line_join");
  if (attr != NULL)
    beziergon->line_join = data_enum(attribute_first_data(attr), ctx);

  beziergon->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    beziergon->dashlength = data_real(attribute_first_data(attr), ctx);

  beziergon_update_data(beziergon);

  return &beziergon->bezier.object;
}
예제 #2
0
파일: aadlbox.c 프로젝트: UIKit0/dia
/* *NOT A CALLBACK* --> Must be called by inherited class (see aadldata.c) */
void aadlbox_load(ObjectNode obj_node, int version, DiaContext *ctx,
		   Aadlbox *aadlbox)
{
  AttributeNode attr;
  DataNode composite, data;
  Aadl_type type;
  gchar *declaration;
  Aadlport *port;
  ConnectionPoint *connection;
  int i, num;
  
  attr = object_find_attribute(obj_node, "aadlbox_ports");

  composite = attribute_first_data(attr);

  num = attribute_num_data(attr);
  
  for (i=0; i<num; i++) {
    
    Point p;
    attr = composite_find_attribute(composite, "point");
    data_point(attribute_first_data(attr), &p, ctx);
    
    attr = composite_find_attribute(composite, "port_type");
    type = data_enum(attribute_first_data(attr), ctx);
    
    attr = composite_find_attribute(composite, "port_declaration");
    declaration = data_string(attribute_first_data(attr), ctx);
  
    port = g_new0(Aadlport,1);
    port->handle = g_new0(Handle,1);
    port->type = type;
    port->declaration = declaration;
    

    aadlbox_add_port(aadlbox, &p, port);
    
    composite = data_next(composite);
  }
  
  attr = object_find_attribute(obj_node, "aadlbox_connections");
  num = attribute_num_data(attr);
  data = attribute_first_data(attr);
  
  for (i=0; i<num; i++) {
    Point p;
    data_point(data, &p, ctx);

    connection = g_new0(ConnectionPoint,1);
    aadlbox_add_connection(aadlbox, &p, connection);
    
    data = data_next(data);
  }
  
  object_load_props(&aadlbox->element.object,obj_node, ctx);
}
예제 #3
0
파일: textobj.c 프로젝트: jbohren-forks/dia
static DiaObject *
textobj_load(ObjectNode obj_node, int version, DiaContext *ctx)
{
  Textobj *textobj;
  DiaObject *obj;
  AttributeNode attr;
  Point startpoint = {0.0, 0.0};

  textobj = g_malloc0(sizeof(Textobj));
  obj = &textobj->object;
  
  obj->type = &textobj_type;
  obj->ops = &textobj_ops;

  object_load(obj, obj_node, ctx);

  attr = object_find_attribute(obj_node, "text");
  if (attr != NULL) {
    textobj->text = data_text(attribute_first_data(attr), ctx);
  } else {
    DiaFont* font = dia_font_new_from_style(DIA_FONT_MONOSPACE,1.0);
    textobj->text = new_text("", font, 1.0,
			     &startpoint, &color_black, ALIGN_CENTER);
    dia_font_unref(font);
  }

  attr = object_find_attribute(obj_node, "valign");
  if (attr != NULL)
    textobj->vert_align = data_enum(attribute_first_data(attr), ctx);
  else if (version == 0) {
    textobj->vert_align = VALIGN_FIRST_LINE;
  }

  /* default visibility must be off to keep compatibility */
  textobj->fill_color = attributes_get_background();
  attr = object_find_attribute(obj_node, "fill_color");
  if (attr)
    data_color(attribute_first_data(attr), &textobj->fill_color, ctx);
  attr = object_find_attribute(obj_node, "show_background");
  if (attr)
    textobj->show_background = data_boolean(attribute_first_data(attr), ctx);
  else
    textobj->show_background = FALSE;

  object_init(obj, 1, 0);

  obj->handles[0] = &textobj->text_handle;
  textobj->text_handle.id = HANDLE_TEXT;
  textobj->text_handle.type = HANDLE_MAJOR_CONTROL;
  textobj->text_handle.connect_type = HANDLE_CONNECTABLE;
  textobj->text_handle.connected_to = NULL;

  textobj_update_data(textobj);

  return &textobj->object;
}
예제 #4
0
static void 
enumarrayprop_load(EnumarrayProperty *prop, AttributeNode attr, DataNode data)
{
  guint nvals = attribute_num_data(attr);
  guint i;
  g_array_set_size(prop->enumarray_data,nvals);

  for (i=0; (i < nvals) && data; i++, data = data_next(data)) 
    g_array_index(prop->enumarray_data,gint,i) = data_enum(data);
  if (i != nvals) 
    g_warning("attribute_num_data() and actual data count mismatch "
              "(shouldn't happen)");
}
예제 #5
0
파일: text.c 프로젝트: jbohren-forks/dia
Text *
data_text(AttributeNode text_attr, DiaContext *ctx)
{
  char *string = NULL;
  DiaFont *font;
  real height;
  Point pos = {0.0, 0.0};
  Color col;
  Alignment align;
  AttributeNode attr;
  Text *text;

  attr = composite_find_attribute(text_attr, "string");
  if (attr != NULL)
    string = data_string(attribute_first_data(attr), ctx);

  height = 1.0;
  attr = composite_find_attribute(text_attr, "height");
  if (attr != NULL)
    height = data_real(attribute_first_data(attr), ctx);

  attr = composite_find_attribute(text_attr, "font");
  if (attr != NULL) {
    font = data_font(attribute_first_data(attr), ctx);
  } else {
    font = dia_font_new_from_style(DIA_FONT_SANS,1.0);
  }
  
  attr = composite_find_attribute(text_attr, "pos");
  if (attr != NULL)
    data_point(attribute_first_data(attr), &pos, ctx);

  col = color_black;
  attr = composite_find_attribute(text_attr, "color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &col, ctx);

  align = ALIGN_LEFT;
  attr = composite_find_attribute(text_attr, "alignment");
  if (attr != NULL)
    align = data_enum(attribute_first_data(attr), ctx);
  
  text = new_text(string ? string : "", font, height, &pos, &col, align);
  if (font) dia_font_unref(font);
  if (string) g_free(string);
  return text;
}
예제 #6
0
Text *
data_text(AttributeNode text_attr)
{
  char *string = "";
  Font *font;
  real height;
  Point pos = {0.0, 0.0};
  Color col;
  Alignment align;
  AttributeNode attr;
  DataNode composite_node;
  Text *text;

  composite_node = attribute_first_data(text_attr);

  attr = composite_find_attribute(text_attr, "string");
  if (attr != NULL)
    string = data_string(attribute_first_data(attr));

  font = font_getfont("Courier");
  attr = composite_find_attribute(text_attr, "font");
  if (attr != NULL)
    font = data_font(attribute_first_data(attr));

  height = 1.0;
  attr = composite_find_attribute(text_attr, "height");
  if (attr != NULL)
    height = data_real(attribute_first_data(attr));

  attr = composite_find_attribute(text_attr, "pos");
  if (attr != NULL)
    data_point(attribute_first_data(attr), &pos);

  col = color_black;
  attr = composite_find_attribute(text_attr, "color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &col);

  align = ALIGN_LEFT;
  attr = composite_find_attribute(text_attr, "alignment");
  if (attr != NULL)
    align = data_enum(attribute_first_data(attr));
  
  text = new_text(string, font, height, &pos, &col, align);
  if (string) free(string);
  return text;
}
예제 #7
0
UMLAttribute *
uml_attribute_read(DataNode composite)
{
  UMLAttribute *attr;
  AttributeNode attr_node;
  
  attr = g_new(UMLAttribute, 1);

  attr->name = NULL;
  attr_node = composite_find_attribute(composite, "name");
  if (attr_node != NULL)
    attr->name =  data_string( attribute_first_data(attr_node) );

  attr->type = NULL;
  attr_node = composite_find_attribute(composite, "type");
  if (attr_node != NULL)
    attr->type =  data_string( attribute_first_data(attr_node) );

  attr->value = NULL;
  attr_node = composite_find_attribute(composite, "value");
  if (attr_node != NULL)
    attr->value =  data_string( attribute_first_data(attr_node) );
  
  attr->visibility = FALSE;
  attr_node = composite_find_attribute(composite, "visibility");
  if (attr_node != NULL)
    attr->visibility =  data_enum( attribute_first_data(attr_node) );
  
  attr->abstract = FALSE;
  attr_node = composite_find_attribute(composite, "abstract");
  if (attr_node != NULL)
    attr->abstract =  data_boolean( attribute_first_data(attr_node) );
  
  attr->class_scope = FALSE;
  attr_node = composite_find_attribute(composite, "class_scope");
  if (attr_node != NULL)
    attr->class_scope =  data_boolean( attribute_first_data(attr_node) );
  
  attr->left_connection = NULL;
  attr->right_connection = NULL;

  return attr;
}
예제 #8
0
static void 
enumprop_load(EnumProperty *prop, AttributeNode attr, DataNode data)
{
  DataType dt = data_type (data);
  if (DATATYPE_ENUM == dt)
    prop->enum_data = data_enum(data);
  else if (DATATYPE_INT == dt) {
    gboolean cast_ok = FALSE;
    PropEnumData *enumdata = prop->common.extra_data;
    guint i, v = data_int(data);
    for (i = 0; enumdata[i].name != NULL; ++i) {
      if (v == enumdata[i].enumv) {
        prop->enum_data = v;
	cast_ok = TRUE;
	break;
      }
    }
    if (!cast_ok) {
      prop->enum_data = enumdata[0].enumv;
      message_warning (_("Property cast from int to enum out of range"));
    }
  }
}
예제 #9
0
파일: box.c 프로젝트: jbohren-forks/dia
static DiaObject *
box_load(ObjectNode obj_node, int version, DiaContext *ctx)
{
  Box *box;
  Element *elem;
  DiaObject *obj;
  int i;
  AttributeNode attr;

  box = g_malloc0(sizeof(Box));
  elem = &box->element;
  obj = &elem->object;
  
  obj->type = &box_type;
  obj->ops = &box_ops;

  element_load(elem, obj_node, ctx);
  
  box->border_width = 0.1;
  attr = object_find_attribute(obj_node, "border_width");
  if (attr != NULL)
    box->border_width =  data_real(attribute_first_data(attr), ctx);

  box->border_color = color_black;
  attr = object_find_attribute(obj_node, "border_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &box->border_color, ctx);
  
  box->inner_color = color_white;
  attr = object_find_attribute(obj_node, "inner_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &box->inner_color, ctx);
  
  box->show_background = TRUE;
  attr = object_find_attribute(obj_node, "show_background");
  if (attr != NULL)
    box->show_background = data_boolean(attribute_first_data(attr), ctx);

  box->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    box->line_style =  data_enum(attribute_first_data(attr), ctx);

  box->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    box->dashlength = data_real(attribute_first_data(attr), ctx);

  box->line_join = LINEJOIN_MITER;
  attr = object_find_attribute(obj_node, "line_join");
  if (attr != NULL)
    box->line_join =  data_enum(attribute_first_data(attr), ctx);

  box->corner_radius = 0.0;
  attr = object_find_attribute(obj_node, "corner_radius");
  if (attr != NULL)
    box->corner_radius =  data_real(attribute_first_data(attr), ctx);

  box->aspect = FREE_ASPECT;
  attr = object_find_attribute(obj_node, "aspect");
  if (attr != NULL)
    box->aspect = data_enum(attribute_first_data(attr), ctx);

  element_init(elem, 8, NUM_CONNECTIONS);

  for (i=0;i<NUM_CONNECTIONS;i++) {
    obj->connections[i] = &box->connections[i];
    box->connections[i].object = obj;
    box->connections[i].connected = NULL;
  }
  box->connections[8].flags = CP_FLAGS_MAIN;

  box_update_data(box);

  return &box->element.object;
}
예제 #10
0
파일: zigzagline.c 프로젝트: brunetton/dia
static DiaObject *
zigzagline_load(ObjectNode obj_node, int version, DiaContext *ctx)
{
  Zigzagline *zigzagline;
  OrthConn *orth;
  DiaObject *obj;
  AttributeNode attr;

  zigzagline = g_malloc0(sizeof(Zigzagline));

  orth = &zigzagline->orth;
  obj = &orth->object;
  
  obj->type = &zigzagline_type;
  obj->ops = &zigzagline_ops;

  orthconn_load(orth, obj_node, ctx);

  zigzagline->line_color = color_black;
  attr = object_find_attribute(obj_node, "line_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &zigzagline->line_color, ctx);

  zigzagline->line_width = 0.1;
  attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
  if (attr != NULL)
    zigzagline->line_width = data_real(attribute_first_data(attr), ctx);

  zigzagline->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    zigzagline->line_style = data_enum(attribute_first_data(attr), ctx);

  zigzagline->line_join = LINEJOIN_MITER;
  attr = object_find_attribute(obj_node, "line_join");
  if (attr != NULL)
    zigzagline->line_join = data_enum(attribute_first_data(attr), ctx);

  zigzagline->line_caps = LINECAPS_BUTT;
  attr = object_find_attribute(obj_node, "line_caps");
  if (attr != NULL)
    zigzagline->line_caps = data_enum(attribute_first_data(attr), ctx);

  load_arrow(obj_node, &zigzagline->start_arrow, "start_arrow",
	     "start_arrow_length", "start_arrow_width", ctx);

  load_arrow(obj_node, &zigzagline->end_arrow, "end_arrow",
	     "end_arrow_length", "end_arrow_width", ctx);

  zigzagline->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    zigzagline->dashlength = data_real(attribute_first_data(attr), ctx);

  zigzagline->corner_radius = 0.0;
  attr = object_find_attribute(obj_node, "corner_radius");
  if (attr != NULL)
    zigzagline->corner_radius = data_real(attribute_first_data(attr), ctx);

  zigzagline_update_data(zigzagline);

  return &zigzagline->orth.object;
}
예제 #11
0
파일: ellipse.c 프로젝트: brunetton/dia
static DiaObject *
ellipse_load(ObjectNode obj_node, int version,DiaContext *ctx)
{
  Ellipse *ellipse;
  Element *elem;
  DiaObject *obj;
  int i;
  AttributeNode attr;

  ellipse = g_malloc0(sizeof(Ellipse));
  elem = &ellipse->element;
  obj = &elem->object;
  
  obj->type = &fc_ellipse_type;
  obj->ops = &ellipse_ops;

  element_load(elem, obj_node, ctx);
  
  ellipse->border_width = 0.1;
  attr = object_find_attribute(obj_node, "border_width");
  if (attr != NULL)
    ellipse->border_width =  data_real(attribute_first_data(attr), ctx);

  ellipse->border_color = color_black;
  attr = object_find_attribute(obj_node, "border_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &ellipse->border_color, ctx);
  
  ellipse->inner_color = color_white;
  attr = object_find_attribute(obj_node, "inner_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &ellipse->inner_color, ctx);
  
  ellipse->show_background = TRUE;
  attr = object_find_attribute(obj_node, "show_background");
  if (attr != NULL)
    ellipse->show_background = data_boolean( attribute_first_data(attr), ctx);

  ellipse->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    ellipse->line_style =  data_enum(attribute_first_data(attr), ctx);

  ellipse->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    ellipse->dashlength = data_real(attribute_first_data(attr), ctx);

  ellipse->padding = default_properties.padding;
  attr = object_find_attribute(obj_node, "padding");
  if (attr != NULL)
    ellipse->padding =  data_real(attribute_first_data(attr), ctx);
  
  ellipse->text = NULL;
  attr = object_find_attribute(obj_node, "text");
  if (attr != NULL)
    ellipse->text = data_text(attribute_first_data(attr), ctx);
  else
    ellipse->text = new_text_default(&obj->position, &ellipse->border_color, ALIGN_CENTER);

  /* old default: only growth, manual shrink */
  ellipse->text_fitting = TEXTFIT_WHEN_NEEDED;
  attr = object_find_attribute(obj_node, PROP_STDNAME_TEXT_FITTING);
  if (attr != NULL)
    ellipse->text_fitting = data_enum(attribute_first_data(attr), ctx);

  element_init(elem, 8, NUM_CONNECTIONS);

  for (i=0;i<NUM_CONNECTIONS;i++) {
    obj->connections[i] = &ellipse->connections[i];
    ellipse->connections[i].object = obj;
    ellipse->connections[i].connected = NULL;
    ellipse->connections[i].flags = 0;
  }
  ellipse->connections[16].flags = CP_FLAGS_MAIN;

  ellipse_update_data(ellipse, ANCHOR_MIDDLE, ANCHOR_MIDDLE);

  return &ellipse->element.object;
}
예제 #12
0
파일: eimage.c 프로젝트: montsuqi/monpe
static DiaObject *
image_load(ObjectNode obj_node, int version, const char *filename)
{
  EImage *image;
  Element *elem;
  DiaObject *obj;
  int i;
  AttributeNode attr;
  char *diafile_dir;
  Diagram *dia;
  GList *list;
  
  image = g_malloc0(sizeof(EImage));
  elem = &image->element;
  obj = &elem->object;
  
  obj->type = &eimage_type;
  obj->ops = &eimage_ops;

  element_load(elem, obj_node);
  
  image->border_width = 0.1;
  attr = object_find_attribute(obj_node, "border_width");
  if (attr != NULL)
    image->border_width =  data_real( attribute_first_data(attr) );

  image->border_color = color_black;
  attr = object_find_attribute(obj_node, "border_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &image->border_color);
  
  image->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    image->line_style =  data_enum( attribute_first_data(attr) );

  image->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    image->dashlength = data_real(attribute_first_data(attr));

  image->draw_border = TRUE;
  attr = object_find_attribute(obj_node, "draw_border");
  if (attr != NULL)
    image->draw_border =  data_boolean( attribute_first_data(attr) );

  image->keep_aspect = TRUE;
  attr = object_find_attribute(obj_node, "keep_aspect");
  if (attr != NULL)
    image->keep_aspect =  data_boolean( attribute_first_data(attr) );

  image->keep_orig_aspect = TRUE;
  attr = object_find_attribute(obj_node, "keep_orig_aspect");
  if (attr != NULL)
    image->keep_orig_aspect =  data_boolean( attribute_first_data(attr) );

  attr = object_find_attribute(obj_node, "file");
  if (attr != NULL) {
    image->file =  data_filename( attribute_first_data(attr) );
  } else {
    image->file = g_strdup("");
  }

  attr = object_find_attribute(obj_node, "embed_id");
  if (attr) {
    image->embed_id = 
      dtree_conv_longname_from_xml(data_string(attribute_first_data(attr)));
  } else {
    image->embed_id = get_default_embed_id("embed_image");
  }
  register_embed_id(image->embed_id);

  element_init(elem, 8, NUM_CONNECTIONS);

  for (i=0;i<NUM_CONNECTIONS;i++) {
    obj->connections[i] = &image->connections[i];
    image->connections[i].object = obj;
    image->connections[i].connected = NULL;
  }
  image->connections[8].flags = CP_FLAGS_MAIN;

  image->image = NULL;
  
  if (strcmp(image->file, "")!=0) {
    diafile_dir = get_directory(filename);

    if (g_path_is_absolute(image->file)) { /* Absolute pathname */
      image->image = dia_image_load(image->file);
      if (image->image == NULL) {
	/* Not found as abs path, try in same dir as diagram. */
	char *temp_string;
	const char *image_file_name = image->file;
	const char *psep;

	psep = strrchr(image->file, G_DIR_SEPARATOR);
	/* try the other G_OS as well */
	if (!psep)
	  psep =  strrchr(image->file, G_DIR_SEPARATOR == '/' ? '\\' : '/');
	if (psep)
	  image_file_name = psep + 1;

	temp_string = g_build_filename(diafile_dir, image_file_name, NULL);

	image->image = dia_image_load(temp_string);

	if (image->image != NULL) {
	  /* Found file in same dir as diagram. */
	  message_warning(_("The image file '%s' was not found in that directory.\n"
			  "Using the file '%s' instead\n"), image->file, temp_string);
	  g_free(image->file);
	  image->file = temp_string;
	} else {
	  g_free(temp_string);
	  
	  image->image = dia_image_load((char *)image_file_name);
	  if (image->image != NULL) {
	    char *tmp;
	    /* Found file in current dir. */
	    message_warning(_("The image file '%s' was not found in that directory.\n"
			    "Using the file '%s' instead\n"), image->file, image_file_name);
	    tmp = image->file;
	    image->file = g_strdup(image_file_name);
	    g_free(tmp);
	  } else {
	    message_warning(_("The image file '%s' was not found.\n"),
			    image_file_name);
	  }
	}
      }
    } else { /* Relative pathname: */
      char *temp_string;

      temp_string = g_build_filename (diafile_dir, image->file, NULL);

      image->image = dia_image_load(temp_string);

      if (image->image != NULL) {
	/* Found file in same dir as diagram. */
	g_free(image->file);
	image->file = temp_string;
      } else {
	g_free(temp_string);
	  
	image->image = dia_image_load(image->file);
	if (image->image == NULL) {
	  /* Didn't find file in current dir. */
	  message_warning(_("The image file '%s' was not found.\n"),
			  image->file);
	}
      }
    }
    g_free(diafile_dir);
  }

  /* update mtime */
  {
    struct stat st;
    if (g_stat (image->file, &st) != 0)
      st.st_mtime = 0;

    image->mtime = st.st_mtime;
  }
  image_update_data(image);

  obj->node = NULL;
  list = dia_open_diagrams();
  while (list != NULL) {
    dia = (Diagram *)list->data;
    if (!g_strcmp0(dia->filename,filename)) {
      obj->node = dtree_set_data_by_longname(DIA_DIAGRAM_DATA(dia)->dtree,
        image->embed_id,&image->element.object);
    }
    list = g_list_next(list);
  }
  
  return &image->element.object;
}
예제 #13
0
파일: ellipse.c 프로젝트: mpuels/dia
static DiaObject *ellipse_load(ObjectNode obj_node, int version, DiaContext *ctx)
{
  Ellipse *ellipse;
  Element *elem;
  DiaObject *obj;
  int i;
  AttributeNode attr;

  ellipse = g_malloc0(sizeof(Ellipse));
  elem = &ellipse->element;
  obj = &elem->object;
  
  obj->type = &ellipse_type;
  obj->ops = &ellipse_ops;

  element_load(elem, obj_node, ctx);

  ellipse->border_width = 0.1;
  attr = object_find_attribute(obj_node, "border_width");
  if (attr != NULL)
    ellipse->border_width =  data_real(attribute_first_data(attr), ctx);

  ellipse->border_color = color_black;
  attr = object_find_attribute(obj_node, "border_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &ellipse->border_color, ctx);
  
  ellipse->inner_color = color_white;
  attr = object_find_attribute(obj_node, "inner_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &ellipse->inner_color, ctx);
  
  ellipse->show_background = TRUE;
  attr = object_find_attribute(obj_node, "show_background");
  if (attr != NULL)
    ellipse->show_background = data_boolean(attribute_first_data(attr), ctx);

  ellipse->aspect = FREE_ASPECT;
  attr = object_find_attribute(obj_node, "aspect");
  if (attr != NULL)
    ellipse->aspect = data_enum(attribute_first_data(attr), ctx);

  ellipse->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    ellipse->line_style =  data_enum(attribute_first_data(attr), ctx);

  ellipse->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    ellipse->dashlength = data_real(attribute_first_data(attr), ctx);

  attr = object_find_attribute(obj_node, "pattern");
  if (attr != NULL)
    ellipse->pattern = data_pattern(attribute_first_data(attr), ctx);

  element_init(elem, 9, 9);

  obj->handles[8] = &ellipse->center_handle;
  obj->handles[8]->id = HANDLE_CUSTOM1;
  obj->handles[8]->type = HANDLE_MAJOR_CONTROL;
  obj->handles[8]->connected_to = NULL;
  obj->handles[8]->connect_type = HANDLE_NONCONNECTABLE;

  for (i=0;i<9;i++) {
    obj->connections[i] = &ellipse->connections[i];
    ellipse->connections[i].object = obj;
    ellipse->connections[i].connected = NULL;
  }
  ellipse->connections[8].flags = CP_FLAGS_MAIN;

  ellipse_update_data(ellipse);

  return &ellipse->element.object;
}
예제 #14
0
파일: polyline.c 프로젝트: mpuels/dia
static DiaObject *
polyline_load(ObjectNode obj_node, int version, DiaContext *ctx)
{
  Polyline *polyline;
  PolyConn *poly;
  DiaObject *obj;
  AttributeNode attr;

  polyline = g_malloc0(sizeof(Polyline));

  poly = &polyline->poly;
  obj = &poly->object;
  
  obj->type = &polyline_type;
  obj->ops = &polyline_ops;

  polyconn_load(poly, obj_node, ctx);

  polyline->line_color = color_black;
  attr = object_find_attribute(obj_node, "line_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &polyline->line_color, ctx);

  polyline->line_width = 0.1;
  attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
  if (attr != NULL)
    polyline->line_width = data_real(attribute_first_data(attr), ctx);

  polyline->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    polyline->line_style = data_enum(attribute_first_data(attr), ctx);

  polyline->line_join = LINEJOIN_MITER;
  attr = object_find_attribute(obj_node, "line_join");
  if (attr != NULL)
    polyline->line_join = data_enum(attribute_first_data(attr), ctx);

  polyline->line_caps = LINECAPS_BUTT;
  attr = object_find_attribute(obj_node, "line_caps");
  if (attr != NULL)
    polyline->line_caps = data_enum(attribute_first_data(attr), ctx);

  polyline->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    polyline->dashlength = data_real(attribute_first_data(attr), ctx);

  load_arrow(obj_node, &polyline->start_arrow, "start_arrow",
	     "start_arrow_length", "start_arrow_width", ctx);

  load_arrow(obj_node, &polyline->end_arrow, "end_arrow",
	     "end_arrow_length", "end_arrow_width", ctx);

  polyline->absolute_start_gap = 0.0;
  attr = object_find_attribute(obj_node, "absolute_start_gap");
  if (attr != NULL)
    polyline->absolute_start_gap =  data_real(attribute_first_data(attr), ctx);
  polyline->absolute_end_gap = 0.0;
  attr = object_find_attribute(obj_node, "absolute_end_gap");
  if (attr != NULL)
    polyline->absolute_end_gap =  data_real(attribute_first_data(attr), ctx);

  polyline->corner_radius = 0.0;
  attr = object_find_attribute(obj_node, "corner_radius");
  if (attr != NULL)
    polyline->corner_radius =  data_real(attribute_first_data(attr), ctx);

  polyline_update_data(polyline);

  return &polyline->poly.object;
}
예제 #15
0
static Object *
arc_load(ObjectNode obj_node, int version, const char *filename)
{
  Arc *arc;
  Connection *conn;
  Object *obj;
  AttributeNode attr;

  arc = g_malloc(sizeof(Arc));

  conn = &arc->connection;
  obj = (Object *) arc;

  obj->type = &arc_type;;
  obj->ops = &arc_ops;

  connection_load(conn, obj_node);

  arc->arc_color = color_black;
  attr = object_find_attribute(obj_node, "arc_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &arc->arc_color);

  arc->curve_distance = 0.1;
  attr = object_find_attribute(obj_node, "curve_distance");
  if (attr != NULL)
    arc->curve_distance = data_real(attribute_first_data(attr));

  arc->line_width = 0.1;
  attr = object_find_attribute(obj_node, "line_width");
  if (attr != NULL)
    arc->line_width = data_real(attribute_first_data(attr));

  arc->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    arc->line_style = data_enum(attribute_first_data(attr));

  arc->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    arc->dashlength = data_real(attribute_first_data(attr));


  arc->start_arrow.type = ARROW_NONE;
  arc->start_arrow.length = 0.8;
  arc->start_arrow.width = 0.8;
  attr = object_find_attribute(obj_node, "start_arrow");
  if (attr != NULL)
    arc->start_arrow.type = data_enum(attribute_first_data(attr));
  attr = object_find_attribute(obj_node, "start_arrow_length");
  if (attr != NULL)
    arc->start_arrow.length = data_real(attribute_first_data(attr));
  attr = object_find_attribute(obj_node, "start_arrow_width");
  if (attr != NULL)
    arc->start_arrow.width = data_real(attribute_first_data(attr));

  arc->end_arrow.type = ARROW_NONE;
  arc->end_arrow.length = 0.8;
  arc->end_arrow.width = 0.8;
  attr = object_find_attribute(obj_node, "end_arrow");
  if (attr != NULL)
    arc->end_arrow.type = data_enum(attribute_first_data(attr));
  attr = object_find_attribute(obj_node, "end_arrow_length");
  if (attr != NULL)
    arc->end_arrow.length = data_real(attribute_first_data(attr));
  attr = object_find_attribute(obj_node, "end_arrow_width");
  if (attr != NULL)
    arc->end_arrow.width = data_real(attribute_first_data(attr));

  connection_init(conn, 3, 0);

  obj->handles[2] = &arc->middle_handle;
  arc->middle_handle.id = HANDLE_MIDDLE;
  arc->middle_handle.type = HANDLE_MINOR_CONTROL;
  arc->middle_handle.connect_type = HANDLE_NONCONNECTABLE;
  arc->middle_handle.connected_to = NULL;

  arc_update_data(arc);

  return (Object *)arc;
}
예제 #16
0
파일: image.c 프로젝트: jbohren-forks/dia
static DiaObject *
image_load(ObjectNode obj_node, int version, DiaContext *ctx)
{
  Image *image;
  Element *elem;
  DiaObject *obj;
  int i;
  AttributeNode attr;
  char *diafile_dir;
  
  image = g_malloc0(sizeof(Image));
  elem = &image->element;
  obj = &elem->object;
  
  obj->type = &image_type;
  obj->ops = &image_ops;

  element_load(elem, obj_node, ctx);
  
  image->border_width = 0.1;
  attr = object_find_attribute(obj_node, "border_width");
  if (attr != NULL)
    image->border_width =  data_real(attribute_first_data(attr), ctx);

  image->border_color = color_black;
  attr = object_find_attribute(obj_node, "border_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &image->border_color, ctx);
  
  image->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    image->line_style =  data_enum(attribute_first_data(attr), ctx);

  image->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    image->dashlength = data_real(attribute_first_data(attr), ctx);

  image->draw_border = TRUE;
  attr = object_find_attribute(obj_node, "draw_border");
  if (attr != NULL)
    image->draw_border =  data_boolean(attribute_first_data(attr), ctx);

  image->keep_aspect = TRUE;
  attr = object_find_attribute(obj_node, "keep_aspect");
  if (attr != NULL)
    image->keep_aspect =  data_boolean(attribute_first_data(attr), ctx);

  attr = object_find_attribute(obj_node, "file");
  if (attr != NULL) {
    image->file =  data_filename(attribute_first_data(attr), ctx);
  } else {
    image->file = g_strdup("");
  }

  element_init(elem, 8, NUM_CONNECTIONS);

  for (i=0;i<NUM_CONNECTIONS;i++) {
    obj->connections[i] = &image->connections[i];
    image->connections[i].object = obj;
    image->connections[i].connected = NULL;
  }
  image->connections[8].flags = CP_FLAGS_MAIN;

  image->image = NULL;
  
  if (strcmp(image->file, "")!=0) {
    diafile_dir = get_directory(dia_context_get_filename(ctx));

    if (g_path_is_absolute(image->file)) { /* Absolute pathname */
      image->image = dia_image_load(image->file);
      if (image->image == NULL) {
	/* Not found as abs path, try in same dir as diagram. */
	char *temp_string;
	const char *image_file_name = image->file;
	const char *psep;

	psep = strrchr(image->file, G_DIR_SEPARATOR);
	/* try the other G_OS as well */
	if (!psep)
	  psep =  strrchr(image->file, G_DIR_SEPARATOR == '/' ? '\\' : '/');
	if (psep)
	  image_file_name = psep + 1;

	temp_string = g_build_filename(diafile_dir, image_file_name, NULL);

	image->image = dia_image_load(temp_string);

	if (image->image != NULL) {
	  /* Found file in same dir as diagram. */
	  message_warning(_("The image file '%s' was not found in the specified directory.\n"
			  "Using the file '%s' instead.\n"), image->file, temp_string);
	  g_free(image->file);
	  image->file = temp_string;
	} else {
	  g_free(temp_string);
	  
	  image->image = dia_image_load((char *)image_file_name);
	  if (image->image != NULL) {
	    char *tmp;
	    /* Found file in current dir. */
	    message_warning(_("The image file '%s' was not found in the specified directory.\n"
			    "Using the file '%s' instead.\n"), image->file, image_file_name);
	    tmp = image->file;
	    image->file = g_strdup(image_file_name);
	    g_free(tmp);
	  } else {
	    message_warning(_("The image file '%s' was not found.\n"),
			    image_file_name);
	  }
	}
      }
    } else { /* Relative pathname: */
      char *temp_string;

      temp_string = g_build_filename (diafile_dir, image->file, NULL);

      image->image = dia_image_load(temp_string);

      if (image->image != NULL) {
	/* Found file in same dir as diagram. */
	g_free(image->file);
	image->file = temp_string;
      } else {
	g_free(temp_string);
	  
	image->image = dia_image_load(image->file);
	if (image->image == NULL) {
	  /* Didn't find file in current dir. */
	  message_warning(_("The image file '%s' was not found.\n"),
			  image->file);
	}
      }
    }
    g_free(diafile_dir);
  }
  /* if we don't have an image yet try to recover it from inlined data */
  if (!image->image) {
    attr = object_find_attribute(obj_node, "pixbuf");
    if (attr != NULL) {
      GdkPixbuf *pixbuf = data_pixbuf (attribute_first_data(attr));

      if (pixbuf) {
	image->image = dia_image_new_from_pixbuf (pixbuf);
	image->inline_data = TRUE; /* avoid loosing it */
	/* FIXME: should we reset the filename? */
	g_object_unref (pixbuf);
      }
    }
  }

  /* update mtime */
  {
    struct stat st;
    if (g_stat (image->file, &st) != 0)
      st.st_mtime = 0;

    image->mtime = st.st_mtime;
  }
  image_update_data(image);

  return &image->element.object;
}
예제 #17
0
파일: arc.c 프로젝트: jbohren-forks/dia
static DiaObject *
arc_load(ObjectNode obj_node, int version,DiaContext *ctx)
{
    Arc *arc;
    Connection *conn;
    DiaObject *obj;
    AttributeNode attr;

    arc = g_malloc0(sizeof(Arc));

    conn = &arc->connection;
    obj = &conn->object;

    obj->type = &arc_type;
    obj->ops = &arc_ops;

    connection_load(conn, obj_node, ctx);

    arc->arc_color = color_black;
    attr = object_find_attribute(obj_node, "arc_color");
    if (attr != NULL)
        data_color(attribute_first_data(attr), &arc->arc_color, ctx);

    arc->curve_distance = 0.1;
    attr = object_find_attribute(obj_node, "curve_distance");
    if (attr != NULL)
        arc->curve_distance = data_real(attribute_first_data(attr), ctx);

    arc->line_width = 0.1;
    attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
    if (attr != NULL)
        arc->line_width = data_real(attribute_first_data(attr), ctx);

    arc->line_style = LINESTYLE_SOLID;
    attr = object_find_attribute(obj_node, "line_style");
    if (attr != NULL)
        arc->line_style = data_enum(attribute_first_data(attr), ctx);

    arc->dashlength = DEFAULT_LINESTYLE_DASHLEN;
    attr = object_find_attribute(obj_node, "dashlength");
    if (attr != NULL)
        arc->dashlength = data_real(attribute_first_data(attr), ctx);

    arc->line_caps = LINECAPS_BUTT;
    attr = object_find_attribute(obj_node, "line_caps");
    if (attr != NULL)
        arc->line_caps = data_enum(attribute_first_data(attr), ctx);

    load_arrow(obj_node, &arc->start_arrow, "start_arrow",
               "start_arrow_length", "start_arrow_width", ctx);

    load_arrow(obj_node, &arc->end_arrow, "end_arrow",
               "end_arrow_length", "end_arrow_width", ctx);

    connection_init(conn, 4, 0);

    _arc_setup_handles (arc);

    /* older versions did not prohibit everything reduced to a single point
     * and afterwards failed on all the calculations producing nan.
     */
    if (distance_point_point (&arc->connection.endpoints[0],
                              &arc->connection.endpoints[1]) < 0.02) {
        arc->curve_distance = 0.0;
        arc->connection.endpoints[0].x -= 0.01;
        arc->connection.endpoints[1].x += 0.01;
        arc_update_handles (arc);
    }

    arc_update_data(arc);

    return &arc->connection.object;
}
예제 #18
0
static Object *
bezierline_load(ObjectNode obj_node, int version, const char *filename)
{
    Bezierline *bezierline;
    BezierConn *bez;
    Object *obj;
    AttributeNode attr;

    bezierline = g_new(Bezierline, 1);

    bez = &bezierline->bez;
    obj = (Object *) bezierline;

    obj->type = &bezierline_type;
    obj->ops = &bezierline_ops;

    bezierconn_load(bez, obj_node);

    bezierline->line_color = color_black;
    attr = object_find_attribute(obj_node, "line_color");
    if (attr != NULL)
        data_color(attribute_first_data(attr), &bezierline->line_color);

    bezierline->line_width = 0.1;
    attr = object_find_attribute(obj_node, "line_width");
    if (attr != NULL)
        bezierline->line_width = data_real(attribute_first_data(attr));

    bezierline->line_style = LINESTYLE_SOLID;
    attr = object_find_attribute(obj_node, "line_style");
    if (attr != NULL)
        bezierline->line_style = data_enum(attribute_first_data(attr));

    bezierline->dashlength = DEFAULT_LINESTYLE_DASHLEN;
    attr = object_find_attribute(obj_node, "dashlength");
    if (attr != NULL)
        bezierline->dashlength = data_real(attribute_first_data(attr));

    bezierline->start_arrow.type = ARROW_NONE;
    bezierline->start_arrow.length = 0.8;
    bezierline->start_arrow.width = 0.8;
    attr = object_find_attribute(obj_node, "start_arrow");
    if (attr != NULL)
        bezierline->start_arrow.type = data_enum(attribute_first_data(attr));
    attr = object_find_attribute(obj_node, "start_arrow_length");
    if (attr != NULL)
        bezierline->start_arrow.length = data_real(attribute_first_data(attr));
    attr = object_find_attribute(obj_node, "start_arrow_width");
    if (attr != NULL)
        bezierline->start_arrow.width = data_real(attribute_first_data(attr));

    bezierline->end_arrow.type = ARROW_NONE;
    bezierline->end_arrow.length = 0.8;
    bezierline->end_arrow.width = 0.8;
    attr = object_find_attribute(obj_node, "end_arrow");
    if (attr != NULL)
        bezierline->end_arrow.type = data_enum(attribute_first_data(attr));
    attr = object_find_attribute(obj_node, "end_arrow_length");
    if (attr != NULL)
        bezierline->end_arrow.length = data_real(attribute_first_data(attr));
    attr = object_find_attribute(obj_node, "end_arrow_width");
    if (attr != NULL)
        bezierline->end_arrow.width = data_real(attribute_first_data(attr));

    bezierline_update_data(bezierline);

    return (Object *)bezierline;
}
예제 #19
0
파일: line.c 프로젝트: mpuels/dia
static DiaObject *
line_load(ObjectNode obj_node, int version, DiaContext *ctx)
{
  Line *line;
  Connection *conn;
  DiaObject *obj;
  AttributeNode attr;

  line = g_malloc0(sizeof(Line));

  conn = &line->connection;
  obj = &conn->object;

  obj->type = &line_type;
  obj->ops = &line_ops;

  connection_load(conn, obj_node, ctx);

  line->line_color = color_black;
  attr = object_find_attribute(obj_node, "line_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &line->line_color, ctx);

  line->line_width = 0.1;
  attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
  if (attr != NULL)
    line->line_width = data_real(attribute_first_data(attr), ctx);

  line->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    line->line_style = data_enum(attribute_first_data(attr), ctx);

  line->line_caps = LINECAPS_BUTT;
  attr = object_find_attribute(obj_node, "line_caps");
  if (attr != NULL)
    line->line_caps = data_enum(attribute_first_data(attr), ctx);

  load_arrow(obj_node, &line->start_arrow, 
	     "start_arrow", "start_arrow_length", "start_arrow_width", ctx);

  load_arrow(obj_node, &line->end_arrow, 
	     "end_arrow", "end_arrow_length", "end_arrow_width", ctx);

  line->absolute_start_gap = 0.0;
  attr = object_find_attribute(obj_node, "absolute_start_gap");
  if (attr != NULL)
    line->absolute_start_gap =  data_real(attribute_first_data(attr), ctx);
  line->absolute_end_gap = 0.0;
  attr = object_find_attribute(obj_node, "absolute_end_gap");
  if (attr != NULL)
    line->absolute_end_gap =  data_real(attribute_first_data(attr), ctx);

  line->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    line->dashlength = data_real(attribute_first_data(attr), ctx);

  connection_init(conn, 2, 0);

  line->cpl = connpointline_load(obj,obj_node,"numcp",1,NULL, ctx);
  line_update_data(line);

  return &line->connection.object;
}
예제 #20
0
static DiaObject *
association_load(ObjectNode obj_node, int version, const char *filename)
{
  Association *assoc;
  AttributeNode attr;
  DataNode composite;
  OrthConn *orth;
  DiaObject *obj;
  int i;
  
  /* first calls our _create() method */
  obj = object_load_using_properties(&association_type, obj_node, version, filename);
  assoc = (Association *)obj;
  orth = &assoc->orth;
  /* ... butnot orthconn_load()  */
  if (version < 1)
    orth->autorouting = FALSE;

  if (version < 2) {
    /* vesrion 1 used to name it differently */
    attr = object_find_attribute(obj_node, "autorouting");
    if (attr != NULL)
      orth->autorouting = data_boolean(attribute_first_data(attr));

    attr = object_find_attribute(obj_node, "ends");
    composite = attribute_first_data(attr);
    for (i=0;i<2;i++) {

      assoc->end[i].role = NULL;
      attr = composite_find_attribute(composite, "role");
      if (attr != NULL) {
        assoc->end[i].role = data_string(attribute_first_data(attr));
      }
      if (   assoc->end[i].role != NULL 
          && 0 == strcmp(assoc->end[i].role, "")) {
        g_free(assoc->end[i].role);
        assoc->end[i].role = NULL;
      }
    
      assoc->end[i].multiplicity = NULL;
      attr = composite_find_attribute(composite, "multiplicity");
      if (attr != NULL) {
        assoc->end[i].multiplicity = data_string(attribute_first_data(attr));
      }
      if (   assoc->end[i].multiplicity != NULL
	  && 0 == strcmp(assoc->end[i].multiplicity, "")) {
        g_free(assoc->end[i].multiplicity);
        assoc->end[i].multiplicity = NULL;
      }
    
      assoc->end[i].arrow = FALSE;
      attr = composite_find_attribute(composite, "arrow");
      if (attr != NULL)
        assoc->end[i].arrow = data_boolean(attribute_first_data(attr));

      assoc->end[i].aggregate = AGGREGATE_NONE;
      attr = composite_find_attribute(composite, "aggregate");
      if (attr != NULL)
        assoc->end[i].aggregate = data_enum(attribute_first_data(attr));
  
      assoc->end[i].visibility = FALSE;
      attr = composite_find_attribute(composite, "visibility");
      if (attr != NULL)
        assoc->end[i].visibility =  data_enum( attribute_first_data(attr) );

      assoc->end[i].text_width = 0.0;
      if (assoc->end[i].role != NULL) {
        assoc->end[i].text_width = 
          dia_font_string_width(assoc->end[i].role, assoc_font,
                                ASSOCIATION_FONTHEIGHT);
      }
      if (assoc->end[i].multiplicity != NULL) {
        assoc->end[i].text_width =
          MAX(assoc->end[i].text_width,
              dia_font_string_width(assoc->end[i].multiplicity,
                                    assoc_font, ASSOCIATION_FONTHEIGHT) );
      }
      composite = data_next(composite);
    }
    /* derive new members state from ends */
    assoc->show_direction = (assoc->direction != ASSOC_NODIR);
    if (assoc->end[0].aggregate == AGGREGATE_NORMAL) {
      assoc->assoc_type = AGGREGATE_NORMAL;
      assoc->direction = ASSOC_RIGHT;
    } else if (assoc->end[0].aggregate == AGGREGATE_COMPOSITION) {
      assoc->assoc_type = AGGREGATE_COMPOSITION;
      assoc->direction = ASSOC_RIGHT;
    } else if (assoc->end[1].aggregate == AGGREGATE_NORMAL) {
      assoc->assoc_type = AGGREGATE_NORMAL;
      assoc->direction = ASSOC_LEFT;
    } else if (assoc->end[1].aggregate == AGGREGATE_COMPOSITION) {
      assoc->assoc_type = AGGREGATE_COMPOSITION;
      assoc->direction = ASSOC_LEFT;
    }
  } /* version < 2 */
  
  association_set_state(assoc, association_get_state(assoc));

  return &assoc->orth.object;
}
예제 #21
0
static Object *
line_load(ObjectNode obj_node, int version, const char *filename)
{
  Line *line;
  Connection *conn;
  Object *obj;
  AttributeNode attr;

  line = g_malloc(sizeof(Line));

  conn = &line->connection;
  obj = (Object *) line;

  obj->type = &line_type;
  obj->ops = &line_ops;

  connection_load(conn, obj_node);

  line->line_color = color_black;
  attr = object_find_attribute(obj_node, "line_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &line->line_color);

  line->line_width = 0.1;
  attr = object_find_attribute(obj_node, "line_width");
  if (attr != NULL)
    line->line_width = data_real(attribute_first_data(attr));

  line->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    line->line_style = data_enum(attribute_first_data(attr));

  line->start_arrow.type = ARROW_NONE;
  line->start_arrow.length = 0.8;
  line->start_arrow.width = 0.8;
  attr = object_find_attribute(obj_node, "start_arrow");
  if (attr != NULL)
    line->start_arrow.type = data_enum(attribute_first_data(attr));
  attr = object_find_attribute(obj_node, "start_arrow_length");
  if (attr != NULL)
    line->start_arrow.length = data_real(attribute_first_data(attr));
  attr = object_find_attribute(obj_node, "start_arrow_width");
  if (attr != NULL)
    line->start_arrow.width = data_real(attribute_first_data(attr));

  line->end_arrow.type = ARROW_NONE;
  line->end_arrow.length = 0.8;
  line->end_arrow.width = 0.8;
  attr = object_find_attribute(obj_node, "end_arrow");
  if (attr != NULL)
    line->end_arrow.type = data_enum(attribute_first_data(attr));
  attr = object_find_attribute(obj_node, "end_arrow_length");
  if (attr != NULL)
    line->end_arrow.length = data_real(attribute_first_data(attr));
  attr = object_find_attribute(obj_node, "end_arrow_width");
  if (attr != NULL)
    line->end_arrow.width = data_real(attribute_first_data(attr));

  line->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    line->dashlength = data_real(attribute_first_data(attr));

  connection_init(conn, 2, 1);

  obj->connections[0] = &line->middle_point;
  line->middle_point.object = obj;
  line->middle_point.connected = NULL;
  line_update_data(line);

  return (Object *)line;
}
예제 #22
0
static Object *
image_load(ObjectNode obj_node, int version, const char *filename)
{
  Image *image;
  Element *elem;
  Object *obj;
  int i;
  AttributeNode attr;
  char *diafile_dir;
  
  image = g_malloc(sizeof(Image));
  elem = (Element *)image;
  obj = (Object *)image;
  
  obj->type = &image_type;
  obj->ops = &image_ops;

  element_load(elem, obj_node);
  
  image->border_width = 0.1;
  attr = object_find_attribute(obj_node, "border_width");
  if (attr != NULL)
    image->border_width =  data_real( attribute_first_data(attr) );

  image->border_color = color_black;
  attr = object_find_attribute(obj_node, "border_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &image->border_color);
  
  image->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    image->line_style =  data_enum( attribute_first_data(attr) );

  image->draw_border = TRUE;
  attr = object_find_attribute(obj_node, "draw_border");
  if (attr != NULL)
    image->draw_border =  data_boolean( attribute_first_data(attr) );

  image->keep_aspect = TRUE;
  attr = object_find_attribute(obj_node, "keep_aspect");
  if (attr != NULL)
    image->keep_aspect =  data_boolean( attribute_first_data(attr) );

  attr = object_find_attribute(obj_node, "file");
  if (attr != NULL) {
    image->file =  data_string( attribute_first_data(attr) );
  } else {
    image->file = g_strdup("");
  }

  element_init(elem, 8, 8);

  for (i=0;i<8;i++) {
    obj->connections[i] = &image->connections[i];
    image->connections[i].object = obj;
    image->connections[i].connected = NULL;
  }

  image->image = NULL;
  
  if (strcmp(image->file, "")!=0) {
    diafile_dir = get_directory(filename);

    if (g_path_is_absolute(image->file)) { /* Absolute pathname */
      image->image = dia_image_load(image->file);
      if (image->image == NULL) {
	/* Not found as abs path, try in same dir as diagram. */
	char *temp_string;
	const char *image_file_name;

	image_file_name = strrchr(image->file, G_DIR_SEPARATOR) + 1;

	temp_string = g_malloc(strlen(diafile_dir) +
			       strlen(image_file_name) +1);

	strcpy(temp_string, diafile_dir);
	strcat(temp_string, image_file_name);

	image->image = dia_image_load(temp_string);

	if (image->image != NULL) {
	  /* Found file in same dir as diagram. */
	  message_warning(_("The image file '%s' was not found in that directory.\n"
			  "Using the file '%s' instead\n"), image->file, temp_string);
	  g_free(image->file);
	  image->file = temp_string;
	} else {
	  g_free(temp_string);
	  
	  image->image = dia_image_load((char *)image_file_name);
	  if (image->image != NULL) {
	    char *tmp;
	    /* Found file in current dir. */
	    message_warning(_("The image file '%s' was not found in that directory.\n"
			    "Using the file '%s' instead\n"), image->file, image_file_name);
	    tmp = image->file;
	    image->file = strdup(image_file_name);
	    g_free(tmp);
	  } else {
	    message_warning(_("The image file '%s' was not found.\n"),
			    image_file_name);
	  }
	}
      }
    } else { /* Relative pathname: */
      char *temp_string;

      temp_string = g_malloc(strlen(diafile_dir) +
			     strlen(image->file) +1);

      strcpy(temp_string, diafile_dir);
      strcat(temp_string, image->file);

      image->image = dia_image_load(temp_string);

      if (image->image != NULL) {
	/* Found file in same dir as diagram. */
	g_free(image->file);
	image->file = temp_string;
      } else {
	g_free(temp_string);
	  
	image->image = dia_image_load(image->file);
	if (image->image == NULL) {
	  /* Didn't find file in current dir. */
	  message_warning(_("The image file '%s' was not found.\n"),
			  image->file);
	}
      }
    }
    g_free(diafile_dir);
  }

  image_update_data(image);

  return (Object *)image;

}
예제 #23
0
UMLOperation *
uml_operation_read(DataNode composite)
{
  UMLOperation *op;
  UMLParameter *param;
  AttributeNode attr_node;
  AttributeNode attr_node2;
  DataNode composite2;
  int i, num;

  op = g_new(UMLOperation, 1);

  op->name = NULL;
  attr_node = composite_find_attribute(composite, "name");
  if (attr_node != NULL)
    op->name =  data_string( attribute_first_data(attr_node) );

  op->type = NULL;
  attr_node = composite_find_attribute(composite, "type");
  if (attr_node != NULL)
    op->type =  data_string( attribute_first_data(attr_node) );

  op->visibility = FALSE;
  attr_node = composite_find_attribute(composite, "visibility");
  if (attr_node != NULL)
    op->visibility =  data_enum( attribute_first_data(attr_node) );
  
  op->abstract = FALSE;
  attr_node = composite_find_attribute(composite, "abstract");
  if (attr_node != NULL)
    op->abstract =  data_boolean( attribute_first_data(attr_node) );
  
  op->class_scope = FALSE;
  attr_node = composite_find_attribute(composite, "class_scope");
  if (attr_node != NULL)
    op->class_scope =  data_boolean( attribute_first_data(attr_node) );

  op->parameters = NULL;
  attr_node2 = composite_find_attribute(composite, "parameters");
  num = attribute_num_data(attr_node2);
  composite2 = attribute_first_data(attr_node2);
  for (i=0;i<num;i++) {
    param = g_new(UMLParameter, 1);
    
    param->name = NULL;
    attr_node = composite_find_attribute(composite2, "name");
    if (attr_node != NULL)
      param->name =  data_string( attribute_first_data(attr_node) );
    
    param->type = NULL;
    attr_node = composite_find_attribute(composite2, "type");
    if (attr_node != NULL)
      param->type =  data_string( attribute_first_data(attr_node) );
    
    param->value = NULL;
    attr_node = composite_find_attribute(composite2, "value");
    if (attr_node != NULL)
      param->value =  data_string( attribute_first_data(attr_node) );
    
    param->kind = UML_UNDEF_KIND;
    attr_node = composite_find_attribute(composite2, "kind");
    if (attr_node != NULL)
      param->kind =  data_enum( attribute_first_data(attr_node) );
    
    op->parameters = g_list_append(op->parameters, param);
    composite2 = data_next(composite2);
  }

  op->left_connection = NULL;
  op->right_connection = NULL;

  return op;
}
예제 #24
0
파일: bezier.c 프로젝트: GNOME/dia
static DiaObject *
bezierline_load(ObjectNode obj_node, int version, DiaContext *ctx)
{
  Bezierline *bezierline;
  BezierConn *bez;
  DiaObject *obj;
  AttributeNode attr;

  bezierline = g_new0(Bezierline, 1);
  bezierline->bez.object.enclosing_box = g_new0 (Rectangle, 1);

  bez = &bezierline->bez;
  obj = &bez->object;

  obj->type = &bezierline_type;
  obj->ops = &bezierline_ops;

  bezierconn_load(bez, obj_node, ctx);

  bezierline->line_color = color_black;
  attr = object_find_attribute(obj_node, "line_color");
  if (attr != NULL)
    data_color(attribute_first_data(attr), &bezierline->line_color, ctx);

  bezierline->line_width = 0.1;
  attr = object_find_attribute(obj_node, PROP_STDNAME_LINE_WIDTH);
  if (attr != NULL)
    bezierline->line_width = data_real(attribute_first_data(attr), ctx);

  bezierline->line_style = LINESTYLE_SOLID;
  attr = object_find_attribute(obj_node, "line_style");
  if (attr != NULL)
    bezierline->line_style = data_enum(attribute_first_data(attr), ctx);

  bezierline->line_join = LINEJOIN_MITER;
  attr = object_find_attribute(obj_node, "line_join");
  if (attr != NULL)
    bezierline->line_join = data_enum(attribute_first_data(attr), ctx);

  bezierline->line_caps = LINECAPS_BUTT;
  attr = object_find_attribute(obj_node, "line_caps");
  if (attr != NULL)
    bezierline->line_caps = data_enum(attribute_first_data(attr), ctx);

  bezierline->dashlength = DEFAULT_LINESTYLE_DASHLEN;
  attr = object_find_attribute(obj_node, "dashlength");
  if (attr != NULL)
    bezierline->dashlength = data_real(attribute_first_data(attr), ctx);

  load_arrow(obj_node, &bezierline->start_arrow, "start_arrow",
	     "start_arrow_length", "start_arrow_width", ctx);

  load_arrow(obj_node, &bezierline->end_arrow, "end_arrow",
	     "end_arrow_length", "end_arrow_width", ctx);

  bezierline->absolute_start_gap = 0.0;
  attr = object_find_attribute(obj_node, "absolute_start_gap");
  if (attr != NULL)
    bezierline->absolute_start_gap =  data_real(attribute_first_data(attr), ctx);
  bezierline->absolute_end_gap = 0.0;
  attr = object_find_attribute(obj_node, "absolute_end_gap");
  if (attr != NULL)
    bezierline->absolute_end_gap =  data_real(attribute_first_data(attr), ctx);

  /* if "screws up the bounding box if auto_gap" it must be fixed there
   * not by copying some meaningless bounding_box before this function call!
   * But the real fix is in connectionpoint.c(connpoint_is_autogap)
   */
  bezierline_update_data(bezierline);

  return &bezierline->bez.object;
}