Example #1
0
static void 
endpointsprop_load(EndpointsProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
{
  data_point(data,&prop->endpoints_data[0], ctx);
  data = data_next(data);
  data_point(data,&prop->endpoints_data[1], ctx);
}
Example #2
0
File: aadlbox.c Project: 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);
}
Example #3
0
static Object *
implements_load(ObjectNode obj_node, int version, const char *filename)
{
  Implements *implements;
  AttributeNode attr;
  Connection *conn;
  Object *obj;

  if (implements_font == NULL)
    implements_font = font_getfont("Courier");

  implements = g_malloc(sizeof(Implements));

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

  obj->type = &implements_type;
  obj->ops = &implements_ops;

  connection_load(conn, obj_node);
  
  connection_init(conn, 4, 0);

  implements->circle_diameter = 1.0;
  attr = object_find_attribute(obj_node, "diameter");
  if (attr != NULL)
    implements->circle_diameter = data_real(attribute_first_data(attr));

  implements->text = NULL;
  attr = object_find_attribute(obj_node, "text");
  if (attr != NULL)
    implements->text = data_string(attribute_first_data(attr));

  attr = object_find_attribute(obj_node, "text_pos");
  if (attr != NULL)
    data_point(attribute_first_data(attr), &implements->text_pos);

  implements->text_width =
      font_string_width(implements->text, implements_font,
			IMPLEMENTS_FONTHEIGHT);

  implements->text_handle.id = HANDLE_MOVE_TEXT;
  implements->text_handle.type = HANDLE_MINOR_CONTROL;
  implements->text_handle.connect_type = HANDLE_NONCONNECTABLE;
  implements->text_handle.connected_to = NULL;
  obj->handles[2] = &implements->text_handle;
  
  implements->circle_handle.id = HANDLE_CIRCLE_SIZE;
  implements->circle_handle.type = HANDLE_MINOR_CONTROL;
  implements->circle_handle.connect_type = HANDLE_NONCONNECTABLE;
  implements->circle_handle.connected_to = NULL;
  obj->handles[3] = &implements->circle_handle;

  implements->properties_dialog = NULL;

  
  implements_update_data(implements);
  
  return (Object *)implements;
}
Example #4
0
static DiaObject *
bus_load(ObjectNode obj_node, int version, const char *filename)
{
  Bus *bus;
  Connection *conn;
  LineBBExtras *extra;
  DiaObject *obj;
  AttributeNode attr;
  DataNode data;
  int i;

  bus = g_malloc0(sizeof(Bus));

  conn = &bus->connection;
  obj = &conn->object;
  extra = &conn->extra_spacing;

  obj->type = &bus_type;
  obj->ops = &bus_ops;

  connection_load(conn, obj_node);

  attr = object_find_attribute(obj_node, "bus_handles");

  bus->num_handles = 0;
  if (attr != NULL)
    bus->num_handles = attribute_num_data(attr);

  connection_init(conn, 2 + bus->num_handles, 0);
  
  data = attribute_first_data(attr);
  bus->handles = g_malloc(sizeof(Handle *)*bus->num_handles);
  bus->parallel_points = g_malloc(sizeof(Point)*bus->num_handles);
  for (i=0;i<bus->num_handles;i++) {
    bus->handles[i] = g_new0(Handle,1);
    bus->handles[i]->id = HANDLE_BUS;
    bus->handles[i]->type = HANDLE_MINOR_CONTROL;
    bus->handles[i]->connect_type = HANDLE_CONNECTABLE_NOBREAK;
    bus->handles[i]->connected_to = NULL;
    data_point(data, &bus->handles[i]->pos);
    obj->handles[2+i] = bus->handles[i];

    data = data_next(data);
  }

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

  extra->start_trans = 
    extra->end_trans = 
    extra->start_long =
    extra->end_long = LINE_WIDTH/2.0;  
  bus_update_data(bus);

  return &bus->connection.object;
}
 //----------------------------------------------------------------------
 Bart::LogitResidualData *
 LogitBartPosteriorSampler::create_and_store_residual(int i) {
   Ptr<BinomialRegressionData> data_point(model_->dat()[i]);
   double original_prediction = model_->predict(data_point->x());
   boost::shared_ptr<Bart::LogitResidualData> residual(
       new Bart::LogitResidualData(data_point, original_prediction));
   residuals_.push_back(residual);
   return residual.get();
 }
Example #6
0
DataPoint<Num>
DisjointCoreData<Num,ChunkSize>::get( const DataRow& chunk, int in_chunk ) const
{
    return data_point( 
        xs[in_chunk],
        chunk.inputs(0,0),
        chunk.output[in_chunk],
        chunk.logoutput[in_chunk],
        chunk.residues[in_chunk]);
}
Example #7
0
static void 
pointarrayprop_load(PointarrayProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
{
  guint nvals = attribute_num_data(attr);
  guint i;
  g_array_set_size(prop->pointarray_data,nvals);
  for (i=0; (i < nvals) && data; i++, data = data_next(data)) 
    data_point(data,&g_array_index(prop->pointarray_data,Point,i),ctx);
  if (i != nvals) 
    g_warning("attribute_num_data() and actual data count mismatch "
              "(shouldn't happen)");
}
Example #8
0
static Object *
message_load(ObjectNode obj_node, int version, const char *filename)
{
  Message *message;
  AttributeNode attr;
  Connection *conn;
  Object *obj;

  if (message_font == NULL)
    message_font = font_getfont("Helvetica");

  message = g_malloc(sizeof(Message));

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

  obj->type = &message_type;
  obj->ops = &message_ops;

  connection_load(conn, obj_node);
  
  connection_init(conn, 3, 0);

  message->text = NULL;
  attr = object_find_attribute(obj_node, "text");
  if (attr != NULL)
    message->text = data_string(attribute_first_data(attr));

  attr = object_find_attribute(obj_node, "text_pos");
  if (attr != NULL)
    data_point(attribute_first_data(attr), &message->text_pos);

  attr = object_find_attribute(obj_node, "type");
  if (attr != NULL)
    message->type = (MessageType)data_int(attribute_first_data(attr));

  if (message->text)
    message->text_width =
      font_string_width(message->text, message_font, MESSAGE_FONTHEIGHT);
  else
    message->text_width = 0;
  
  message->text_handle.id = HANDLE_MOVE_TEXT;
  message->text_handle.type = HANDLE_MINOR_CONTROL;
  message->text_handle.connect_type = HANDLE_NONCONNECTABLE;
  message->text_handle.connected_to = NULL;
  obj->handles[2] = &message->text_handle;
  
  message_update_data(message);
  
  return (Object *)message;
}
Example #9
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;
}
Example #10
0
static Object *
constraint_load(ObjectNode obj_node, int version, const char *filename)
{
  Constraint *constraint;
  AttributeNode attr;
  Connection *conn;
  Object *obj;

  if (constraint_font == NULL)
    constraint_font = font_getfont("Courier");

  constraint = g_malloc(sizeof(Constraint));

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

  obj->type = &constraint_type;
  obj->ops = &constraint_ops;

  connection_load(conn, obj_node);
  
  connection_init(conn, 3, 0);

  constraint->text = NULL;
  attr = object_find_attribute(obj_node, "text");
  if (attr != NULL)
    constraint->text = data_string(attribute_first_data(attr));

  attr = object_find_attribute(obj_node, "text_pos");
  if (attr != NULL)
    data_point(attribute_first_data(attr), &constraint->text_pos);

  constraint->text_width =
      font_string_width(constraint->text, constraint_font, CONSTRAINT_FONTHEIGHT);

  constraint->text_handle.id = HANDLE_MOVE_TEXT;
  constraint->text_handle.type = HANDLE_MINOR_CONTROL;
  constraint->text_handle.connect_type = HANDLE_NONCONNECTABLE;
  constraint->text_handle.connected_to = NULL;
  obj->handles[2] = &constraint->text_handle;
  
  constraint->properties_dialog = NULL;
  
  constraint_update_data(constraint);
  
  return (Object *)constraint;
}
Example #11
0
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;
}
Example #12
0
void
polyconn_load(PolyConn *poly, ObjectNode obj_node, DiaContext *ctx) /* NOTE: Does object_init() */
{
  int i;
  AttributeNode attr;
  DataNode data;
  
  DiaObject *obj = &poly->object;

  object_load(obj, obj_node, ctx);

  attr = object_find_attribute(obj_node, "poly_points");

  if (attr != NULL)
    poly->numpoints = attribute_num_data(attr);
  else
    poly->numpoints = 0;

  object_init(obj, poly->numpoints, 0);

  data = attribute_first_data(attr);
  poly->points = g_malloc(poly->numpoints*sizeof(Point));
  for (i=0;i<poly->numpoints;i++) {
    data_point(data, &poly->points[i], ctx);
    data = data_next(data);
  }

  obj->handles[0] = g_malloc(sizeof(Handle));
  obj->handles[0]->connect_type = HANDLE_CONNECTABLE;
  obj->handles[0]->connected_to = NULL;
  obj->handles[0]->type = HANDLE_MAJOR_CONTROL;
  obj->handles[0]->id = HANDLE_MOVE_STARTPOINT;
  
  obj->handles[poly->numpoints-1] = g_malloc(sizeof(Handle));
  obj->handles[poly->numpoints-1]->connect_type = HANDLE_CONNECTABLE;
  obj->handles[poly->numpoints-1]->connected_to = NULL;
  obj->handles[poly->numpoints-1]->type = HANDLE_MAJOR_CONTROL;
  obj->handles[poly->numpoints-1]->id = HANDLE_MOVE_ENDPOINT;

  for (i=1;i<poly->numpoints-1;i++) {
    obj->handles[i] = g_malloc(sizeof(Handle));
    setup_handle(obj->handles[i], PC_HANDLE_CORNER);
  }

  polyconn_update_data(poly);
}
Example #13
0
static DiaObject *
compound_load (ObjectNode obj_node, int version, DiaContext *ctx)
{
  Compound * comp;
  DiaObject * obj;
  AttributeNode attr;
  DataNode data;
  gint i, num_handles;

  comp = g_new0 (Compound, 1);
  obj = &comp->object;
  /* load the objects position and bounding box */
  object_load (obj, obj_node, ctx);
  /* init the object */
  obj->type = &compound_type;
  obj->ops = &compound_ops;

  /* load the object's handles and its positions */
  attr = object_find_attribute (obj_node, "comp_points");
  g_assert (attr != NULL);
  num_handles = attribute_num_data (attr);
  g_assert (num_handles >= 3);
  /* allocate space for object handles and connectionpoints point arrays */
  object_init (obj, num_handles, 1);
  data = attribute_first_data (attr);
  /* init our mount_point */
  setup_mount_point (&comp->mount_point, obj, NULL);
  data_point (data, &comp->mount_point.pos, ctx);
  obj->connections[0] = &comp->mount_point;
  /* now init the handles */
  comp->num_arms = num_handles-1;
  comp->handles = g_new0 (Handle, num_handles);
  setup_handle (&comp->handles[0], HANDLE_MOUNT_POINT,
                HANDLE_MAJOR_CONTROL, HANDLE_NONCONNECTABLE);
  comp->handles[0].pos = comp->mount_point.pos;
  obj->handles[0] = &comp->handles[0];
  data = data_next (data);
  for (i = 1; i < num_handles; i++)
    {
      obj->handles[i] = &comp->handles[i];
      setup_handle (obj->handles[i], HANDLE_ARM,
                    HANDLE_MINOR_CONTROL, HANDLE_CONNECTABLE_NOBREAK);
      data_point (data, &obj->handles[i]->pos, ctx);
      data = data_next (data);
    }

  /* load remainding properties */
  attr = object_find_attribute (obj_node, PROP_STDTYPE_LINE_WIDTH);
  if (attr == NULL)
    comp->line_width = 0.1;
  else
    comp->line_width = data_real (attribute_first_data (attr), ctx);
  attr = object_find_attribute (obj_node, "line_colour");
  if (attr == NULL)
    comp->line_color = color_black;
  else
    data_color (attribute_first_data (attr), &comp->line_color, ctx);

  compound_update_data (comp);
  compound_sanity_check (comp, "Loaded");
  return &comp->object;
}
Example #14
0
static void 
pointprop_load(PointProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
{
  data_point(data,&prop->point_data, ctx);
}