Пример #1
0
static DiaObject *
transition_create(Point *startpoint,
                  void *user_data,
                  Handle **handle1,
                  Handle **handle2)
{
  Transition *transition;
  OrthConn *orth;
  DiaObject *obj;
  Point temp_point;
  
  if (transition_font == NULL) {
    transition_font = 
      dia_font_new_from_style (DIA_FONT_SANS, TRANSITION_FONTHEIGHT);
  }

  transition = g_malloc0(sizeof(Transition));
  
  orth = &transition->orth;
  obj = &orth->object;
  obj->type = &uml_transition_type;
  obj->ops = &uml_transition_ops;
  
  orthconn_init(orth, startpoint);
  
  transition->text_color = color_black;
  transition->line_color = attributes_get_foreground();
  /* Prepare the handles for trigger and guard text */
  transition->trigger_text_handle.id = HANDLE_MOVE_TRIGGER_TEXT;
  transition->trigger_text_handle.type = HANDLE_MINOR_CONTROL;
  transition->trigger_text_handle.connect_type = HANDLE_NONCONNECTABLE;
  transition->trigger_text_handle.connected_to = NULL;
  temp_point = *startpoint;
  temp_point.y -= TEXT_HANDLE_DISTANCE_FROM_STARTPOINT;
  transition->trigger_text_pos = temp_point;
  transition->trigger_text_handle.pos = temp_point;
  object_add_handle(obj, &transition->trigger_text_handle);  
  
  transition->guard_text_handle.id = HANDLE_MOVE_GUARD_TEXT;
  transition->guard_text_handle.type = HANDLE_MINOR_CONTROL;
  transition->guard_text_handle.connect_type = HANDLE_NONCONNECTABLE;
  transition->guard_text_handle.connected_to = NULL;
  temp_point = *startpoint;
  temp_point.y += TEXT_HANDLE_DISTANCE_FROM_STARTPOINT;
  transition->guard_text_pos = transition->guard_text_handle.pos = temp_point;
  object_add_handle(obj, &transition->guard_text_handle);
  
  transition->guard_text = NULL;
  transition->trigger_text = NULL;
  transition->action_text = NULL;
  
  uml_transition_update_data(transition);
   
  *handle1 = obj->handles[0];
  *handle2 = obj->handles[1];
  return obj;
}
Пример #2
0
static void
aadlbox_add_port(Aadlbox *aadlbox, const Point *p, Aadlport *port)
{
  int i;

  aadlbox->num_ports++;

  if (aadlbox->ports == NULL)
    aadlbox->ports = g_malloc(sizeof(Aadlport*)*aadlbox->num_ports);

  else
    /* Allocate more ports */
    aadlbox->ports = g_realloc(aadlbox->ports,
         			       sizeof(Aadlport*)*aadlbox->num_ports);

  i = aadlbox->num_ports - 1;

  aadlbox->ports[i] = port;
  aadlbox->ports[i]->handle->id = PORT_HANDLE_AADLBOX;
  aadlbox->ports[i]->handle->type = HANDLE_MINOR_CONTROL;
  aadlbox->ports[i]->handle->connect_type = HANDLE_CONNECTABLE_NOBREAK;
  aadlbox->ports[i]->handle->connected_to = NULL;
  aadlbox->ports[i]->handle->pos = *p;
  object_add_handle(&aadlbox->element.object, aadlbox->ports[i]->handle);


  port->in.connected = NULL; port->in.object = &aadlbox->element.object;
  port->out.connected = NULL; port->out.object = &aadlbox->element.object;
  object_add_connectionpoint(&aadlbox->element.object, &port->in);
  object_add_connectionpoint(&aadlbox->element.object, &port->out);

}
Пример #3
0
static DiaObject *
compfeat_create(Point *startpoint,
		void *user_data,
		Handle **handle1,
		Handle **handle2)
{
  Compfeat *compfeat;
  OrthConn *orth;
  DiaObject *obj;
  Point p;
  DiaFont *font;

  font = dia_font_new_from_style(DIA_FONT_MONOSPACE, 0.8);

  compfeat = g_new0(Compfeat, 1);
  compfeat->role = compfeat->roletmp = GPOINTER_TO_INT(user_data);
  compfeat->line_width = 0.1;

  orth = &compfeat->orth;
  obj = &orth->object;

  obj->type = &compfeat_type;
  obj->ops = &compfeat_ops;

  orthconn_init(orth, startpoint);

  p = *startpoint;
  p.y -= COMPPROP_TEXTOFFSET;

  compfeat->line_color = attributes_get_foreground();
  compfeat->text = new_text("", font,
			    COMPPROP_FONTHEIGHT, &p, &compfeat->line_color,
			    ALIGN_CENTER);
  dia_font_unref(font);

  compfeat->text_handle.id = HANDLE_MOVE_TEXT;
  compfeat->text_handle.type = HANDLE_MINOR_CONTROL;
  compfeat->text_handle.connect_type = HANDLE_NONCONNECTABLE;
  compfeat->text_handle.connected_to = NULL;
  compfeat->text_handle.pos = compfeat->text_pos = p;
  object_add_handle(obj, &compfeat->text_handle);

  if (compfeat->role == COMPPROP_FACET
      || compfeat->role == COMPPROP_EVENTSOURCE) {
    int pos = obj->num_connections;
    object_add_connectionpoint(&orth->object, &compfeat->cp);
    obj->connections[pos] = &compfeat->cp;
    compfeat->cp.object = obj;
    compfeat->cp.connected = NULL;
  }

  compfeat_update_data(compfeat);

  *handle1 = orth->handles[0];
  *handle2 = orth->handles[orth->numpoints-2];

  return &compfeat->orth.object;
}
Пример #4
0
static void
bus_add_handle(Bus *bus, Point *p, Handle *handle)
{
  int i;
  
  bus->num_handles++;

  /* Allocate more handles */
  bus->handles = g_realloc(bus->handles,
			   sizeof(Handle *)*bus->num_handles);
  bus->parallel_points = g_realloc(bus->parallel_points,
				   sizeof(Point)*bus->num_handles);

  i = bus->num_handles - 1;
  
  bus->handles[i] = handle;
  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;
  bus->handles[i]->pos = *p;
  object_add_handle(&bus->connection.object, bus->handles[i]);
}