static void note_update_data(Note *note) { Element *elem = ¬e->element; DiaObject *obj = &elem->object; Point p; text_calc_boundingbox(note->text, NULL); elem->width = note->text->max_width + NOTE_MARGIN_X + NOTE_CORNER; elem->height = note->text->height*note->text->numlines + NOTE_MARGIN_Y + NOTE_CORNER; p = elem->corner; p.x += note->line_width/2.0 + NOTE_MARGIN_X; p.y += note->line_width/2.0 + NOTE_CORNER + note->text->ascent; text_set_position(note->text, &p); /* Update connections: */ element_update_connections_rectangle(elem, note->connections); element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); }
static void grid_object_update_data(Grid_Object *grid_object) { Element *elem = &grid_object->element; DiaObject *obj = &elem->object; ElementBBExtras *extra = &elem->extra_spacing; real inset = (grid_object->border_line_width - grid_object->gridline_width)/2.0; real cell_width = (elem->width - 2.0 * inset) / grid_object->grid_cols; real cell_height = (elem->height - 2.0 * inset) / grid_object->grid_rows; int i, j; coord left, top; extra->border_trans = grid_object->border_line_width / 2.0; element_update_boundingbox(elem); element_update_handles(elem); element_update_connections_rectangle(elem, grid_object->base_cps); obj->position = elem->corner; left = obj->position.x; top = obj->position.y; for (i = 0; i < grid_object->grid_cols; ++i) for (j = 0; j < grid_object->grid_rows; ++j) { int cell = grid_cell(i, j, grid_object->grid_rows, grid_object->grid_cols); grid_object->cells[cell].pos.x = left + inset + i*cell_width + cell_width/2.0; grid_object->cells[cell].pos.y = top + inset + j*cell_height + cell_height/2.0; } }
static void basestation_update_data(Basestation *basestation) { Element *elem = &basestation->element; DiaObject *obj = &elem->object; Rectangle text_box; Point p; elem->width = BASESTATION_WIDTH; elem->height = BASESTATION_HEIGHT+basestation->text->height; p = elem->corner; p.x += elem->width/2; p.y += elem->height + basestation->text->ascent; text_set_position(basestation->text, &p); text_calc_boundingbox(basestation->text, &text_box); /* Update connections: */ element_update_connections_rectangle (elem, basestation->connections); element_update_boundingbox(elem); /* Add bounding box for text: */ rectangle_union(&obj->bounding_box, &text_box); obj->position = elem->corner; obj->position.x += elem->width/2.0; obj->position.y += elem->height/2.0; element_update_handles(elem); }
static void node_update_data(Node *node) { Element *elem = &node->element; DiaObject *obj = &node->element.object; Point p1; real h; text_calc_boundingbox(node->name, NULL); h = elem->corner.y + NODE_TEXT_MARGIN; p1.x = elem->corner.x + NODE_TEXT_MARGIN; p1.y = h + node->name->ascent; /* position of text */ text_set_position(node->name, &p1); h += node->name->height * node->name->numlines; elem->width = MAX(elem->width, node->name->max_width + 2*NODE_TEXT_MARGIN); elem->height = MAX(elem->height, node->name->height * node->name->numlines + 2*NODE_TEXT_MARGIN); /* Update connections: */ element_update_connections_rectangle(elem, node->connections); element_update_boundingbox(elem); /* fix boundingbox for depth: */ obj->bounding_box.top -= NODE_DEPTH; obj->bounding_box.right += NODE_DEPTH; obj->position = elem->corner; element_update_handles(elem); }
static void branch_update_data(Branch *branch) { Element *elem = &branch->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; elem->width = BRANCH_WIDTH; elem->height = BRANCH_HEIGHT; /* Update connections: */ branch->connections[0].pos.x = elem->corner.x; branch->connections[0].pos.y = elem->corner.y + elem->height / 2.; branch->connections[0].directions = DIR_WEST; branch->connections[1].pos.x = elem->corner.x + elem->width / 2.; branch->connections[1].pos.y = elem->corner.y; branch->connections[1].directions = DIR_NORTH; branch->connections[2].pos.x = elem->corner.x + elem->width; branch->connections[2].pos.y = elem->corner.y + elem->height / 2.; branch->connections[2].directions = DIR_EAST; branch->connections[3].pos.x = elem->corner.x + elem->width / 2.;; branch->connections[3].pos.y = elem->corner.y + elem->height; branch->connections[3].directions = DIR_SOUTH; extra->border_trans = BRANCH_BORDERWIDTH / 1.4142; /* not 2.0, it is rotated 45° */ element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); }
static void image_update_data(Image *image) { Element *elem = (Element *)image; Object *obj = (Object *)image; /* Update connections: */ image->connections[0].pos = elem->corner; image->connections[1].pos.x = elem->corner.x + elem->width / 2.0; image->connections[1].pos.y = elem->corner.y; image->connections[2].pos.x = elem->corner.x + elem->width; image->connections[2].pos.y = elem->corner.y; image->connections[3].pos.x = elem->corner.x; image->connections[3].pos.y = elem->corner.y + elem->height / 2.0; image->connections[4].pos.x = elem->corner.x + elem->width; image->connections[4].pos.y = elem->corner.y + elem->height / 2.0; image->connections[5].pos.x = elem->corner.x; image->connections[5].pos.y = elem->corner.y + elem->height; image->connections[6].pos.x = elem->corner.x + elem->width / 2.0; image->connections[6].pos.y = elem->corner.y + elem->height; image->connections[7].pos.x = elem->corner.x + elem->width; image->connections[7].pos.y = elem->corner.y + elem->height; element_update_boundingbox(elem); /* fix boundingbox for line_width: */ obj->bounding_box.top -= image->border_width; obj->bounding_box.left -= image->border_width; obj->bounding_box.bottom += image->border_width; obj->bounding_box.right += image->border_width; obj->position = elem->corner; element_update_handles(elem); }
static void analog_clock_update_data(Analog_Clock *analog_clock) { Element *elem = &analog_clock->element; DiaObject *obj = &elem->object; int i; ElementBBExtras *extra = &elem->extra_spacing; extra->border_trans = analog_clock->border_line_width / 2; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); analog_clock->centre.x = obj->position.x + elem->width/2; analog_clock->centre.y = obj->position.y + elem->height/2; analog_clock->radius = MIN(elem->width/2,elem->height/2); /* Update connections: */ for (i = 0; i < 12; ++i) { make_hours(&analog_clock->centre, i+1, 0, analog_clock->radius, &analog_clock->hours[i].pos); analog_clock->hours[i].directions = DIR_ALL; } analog_clock->center_cp.pos.x = elem->corner.x + elem->width/2; analog_clock->center_cp.pos.y = elem->corner.y + elem->height/2; analog_clock_update_arrow_tips(analog_clock); }
static void _dae_update_data(DiagramAsElement *dae) { struct stat statbuf; Element *elem = &dae->element; DiaObject *obj = &elem->object; static int working = 0; if (working > 2) return; /* protect against infinite recursion */ ++working; if ( strlen(dae->filename) && g_stat(dae->filename, &statbuf) == 0 && dae->mtime != statbuf.st_mtime) { DiaImportFilter *inf; if (dae->data) g_object_unref(dae->data); dae->data = g_object_new (DIA_TYPE_DIAGRAM_DATA, NULL); inf = filter_guess_import_filter(dae->filename); if (inf) { DiaContext *ctx = dia_context_new (diagram_as_element_type.name); dia_context_set_filename (ctx, dae->filename); if (inf->import_func(dae->filename, dae->data, ctx, inf->user_data)) { data_update_extents (dae->data); /* should already be called by importer? */ dae->scale = dae->element.width / (dae->data->extents.right - dae->data->extents.left); dae->element.height = (dae->data->extents.bottom - dae->data->extents.top) * dae->scale; dae->mtime = statbuf.st_mtime; } /* FIXME: where to put the message in case of an error? */ dia_context_release (ctx); } /* invalidate possibly cached image */ if (dae->image) { g_object_unref (dae->image); dae->image = NULL; } } /* fixme - fit the scale to draw the diagram in elements size ?*/ if (dae->scale) dae->scale = dae->element.width / (dae->data->extents.right - dae->data->extents.left); elem->extra_spacing.border_trans = dae->border_line_width/2.0; element_update_boundingbox(elem); element_update_handles(elem); element_update_connections_rectangle(elem, dae->connections); /* adjust objects position, otherwise it'll jump on move */ obj->position = elem->corner; --working; }
static void state_update_data(State *state) { real w, h; Element *elem = &state->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; Point p; text_calc_boundingbox(state->text, NULL); w = state->text->max_width + 2*STATE_MARGIN_X; h = state->text->height*state->text->numlines +2*STATE_MARGIN_Y; if (w < STATE_WIDTH) w = STATE_WIDTH; p.x = elem->corner.x + w/2.0; p.y = elem->corner.y + STATE_MARGIN_Y + state->text->ascent; text_set_position(state->text, &p); elem->width = w; elem->height = h; extra->border_trans = STATE_LINEWIDTH / 2.0; /* Update connections: */ state->connections[0].pos = elem->corner; state->connections[1].pos.x = elem->corner.x + elem->width / 2.0; state->connections[1].pos.y = elem->corner.y; state->connections[2].pos.x = elem->corner.x + elem->width; state->connections[2].pos.y = elem->corner.y; state->connections[3].pos.x = elem->corner.x; state->connections[3].pos.y = elem->corner.y + elem->height / 2.0; state->connections[4].pos.x = elem->corner.x + elem->width; state->connections[4].pos.y = elem->corner.y + elem->height / 2.0; state->connections[5].pos.x = elem->corner.x; state->connections[5].pos.y = elem->corner.y + elem->height; state->connections[6].pos.x = elem->corner.x + elem->width / 2.0; state->connections[6].pos.y = elem->corner.y + elem->height; state->connections[7].pos.x = elem->corner.x + elem->width; state->connections[7].pos.y = elem->corner.y + elem->height; state->connections[0].directions = DIR_NORTH|DIR_WEST; state->connections[1].directions = DIR_NORTH; state->connections[2].directions = DIR_NORTH|DIR_EAST; state->connections[3].directions = DIR_WEST; state->connections[4].directions = DIR_EAST; state->connections[5].directions = DIR_SOUTH|DIR_WEST; state->connections[6].directions = DIR_SOUTH; state->connections[7].directions = DIR_SOUTH|DIR_EAST; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); }
static void rendobj_update_data(RenderObject *rend_obj) { Point p; const RenderObjectDescriptor *desc; Element *elem; Object *obj; int i; elem = &rend_obj->element; obj = &elem->object; desc = rend_obj->desc; rend_obj->magnify = elem->width / rend_obj->desc->width; /* Update connections: */ for (i=0;i<desc->num_connection_points;i++) { rend_obj->connections[i].pos = desc->connection_points[i]; point_scale(&rend_obj->connections[i].pos, rend_obj->magnify); point_add(&rend_obj->connections[i].pos, &elem->corner); } if (desc->use_text) { p = desc->text_pos; point_scale(&p, rend_obj->magnify); point_add(&p, &elem->corner); p.y += rend_obj->text->ascent; text_set_position(rend_obj->text, &p); } element_update_boundingbox(elem); /* fix boundingbox for extra_border: */ obj->bounding_box.top -= desc->extra_border; obj->bounding_box.left -= desc->extra_border; obj->bounding_box.bottom += desc->extra_border; obj->bounding_box.right += desc->extra_border; if (desc->use_text) { Rectangle text_box; text_calc_boundingbox(rend_obj->text, &text_box); rectangle_union(&obj->bounding_box, &text_box); } obj->position = elem->corner; p = desc->move_position; point_scale(&p, rend_obj->magnify); point_add(&obj->position, &p); element_update_handles(elem); }
static void state_update_data(State *state) { real w, h; Element *elem = &state->element; Object *obj = (Object *) state; Point p; if (state->state_type==STATE_NORMAL) { w = state->text->max_width + 2*STATE_MARGIN_X; h = state->text->height*state->text->numlines +2*STATE_MARGIN_Y; if (w < STATE_WIDTH) w = STATE_WIDTH; p.x = elem->corner.x + w/2.0; p.y = elem->corner.y + STATE_MARGIN_Y + state->text->ascent; text_set_position(state->text, &p); } else { w = h = (state->state_type==STATE_END) ? STATE_ENDRATIO: STATE_RATIO; } elem->width = w; elem->height = h; /* Update connections: */ state->connections[0].pos = elem->corner; state->connections[1].pos.x = elem->corner.x + elem->width / 2.0; state->connections[1].pos.y = elem->corner.y; state->connections[2].pos.x = elem->corner.x + elem->width; state->connections[2].pos.y = elem->corner.y; state->connections[3].pos.x = elem->corner.x; state->connections[3].pos.y = elem->corner.y + elem->height / 2.0; state->connections[4].pos.x = elem->corner.x + elem->width; state->connections[4].pos.y = elem->corner.y + elem->height / 2.0; state->connections[5].pos.x = elem->corner.x; state->connections[5].pos.y = elem->corner.y + elem->height; state->connections[6].pos.x = elem->corner.x + elem->width / 2.0; state->connections[6].pos.y = elem->corner.y + elem->height; state->connections[7].pos.x = elem->corner.x + elem->width; state->connections[7].pos.y = elem->corner.y + elem->height; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); }
static void image_update_data(Image *image) { Element *elem = &image->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; if (image->keep_aspect && image->image) { /* maybe the image got changes since */ real aspect_org = (float)dia_image_width(image->image) / (float)dia_image_height(image->image); real aspect_now = elem->width / elem->height; if (fabs (aspect_now - aspect_org) > 1e-4) { elem->height = elem->width /aspect_org; } } /* Update connections: */ image->connections[0].pos = elem->corner; image->connections[1].pos.x = elem->corner.x + elem->width / 2.0; image->connections[1].pos.y = elem->corner.y; image->connections[2].pos.x = elem->corner.x + elem->width; image->connections[2].pos.y = elem->corner.y; image->connections[3].pos.x = elem->corner.x; image->connections[3].pos.y = elem->corner.y + elem->height / 2.0; image->connections[4].pos.x = elem->corner.x + elem->width; image->connections[4].pos.y = elem->corner.y + elem->height / 2.0; image->connections[5].pos.x = elem->corner.x; image->connections[5].pos.y = elem->corner.y + elem->height; image->connections[6].pos.x = elem->corner.x + elem->width / 2.0; image->connections[6].pos.y = elem->corner.y + elem->height; image->connections[7].pos.x = elem->corner.x + elem->width; image->connections[7].pos.y = elem->corner.y + elem->height; image->connections[8].pos.x = elem->corner.x + elem->width / 2.0; image->connections[8].pos.y = elem->corner.y + elem->height / 2.0; /* the image border is drawn vompletely outside of the image, so no /2.0 on border width */ extra->border_trans = (image->draw_border ? image->border_width : 0.0); element_update_boundingbox(elem); obj->position = elem->corner; image->connections[8].directions = DIR_ALL; element_update_handles(elem); }
static void largepackage_update_data(LargePackage *pkg) { Element *elem = &pkg->element; DiaObject *obj = &elem->object; pkg->stereotype = remove_stereotype_from_string(pkg->stereotype); if (!pkg->st_stereotype) { pkg->st_stereotype = string_to_stereotype(pkg->stereotype); } pkg->topheight = LARGEPACKAGE_FONTHEIGHT + 0.1*2; pkg->topwidth = 2.0; if (pkg->name != NULL) pkg->topwidth = MAX(pkg->topwidth, dia_font_string_width(pkg->name, pkg->font, LARGEPACKAGE_FONTHEIGHT)+2*0.1); if (pkg->st_stereotype != NULL && pkg->st_stereotype[0] != '\0') { pkg->topwidth = MAX(pkg->topwidth, dia_font_string_width(pkg->st_stereotype, pkg->font, LARGEPACKAGE_FONTHEIGHT)+2*0.1); pkg->topheight += LARGEPACKAGE_FONTHEIGHT; } if (elem->width < (pkg->topwidth + 0.2)) elem->width = pkg->topwidth + 0.2; if (elem->height < 1.0) elem->height = 1.0; /* Update connections: */ element_update_connections_rectangle(elem, pkg->connections); element_update_boundingbox(elem); /* fix boundingbox for top rectangle: */ obj->bounding_box.top -= pkg->topheight; obj->position = elem->corner; element_update_handles(elem); }
static void smallpackage_update_data(SmallPackage *pkg) { Element *elem = &pkg->element; Object *obj = (Object *) pkg; elem->width = pkg->text->max_width + 2*SMALLPACKAGE_MARGIN_X; elem->width = MAX(elem->width, SMALLPACKAGE_TOPWIDTH+1.0); elem->height = pkg->text->height*pkg->text->numlines + 2*SMALLPACKAGE_MARGIN_Y; /* Update connections: */ pkg->connections[0].pos = elem->corner; pkg->connections[1].pos.x = elem->corner.x + elem->width / 2.0; pkg->connections[1].pos.y = elem->corner.y; pkg->connections[2].pos.x = elem->corner.x + elem->width; pkg->connections[2].pos.y = elem->corner.y; pkg->connections[3].pos.x = elem->corner.x; pkg->connections[3].pos.y = elem->corner.y + elem->height / 2.0; pkg->connections[4].pos.x = elem->corner.x + elem->width; pkg->connections[4].pos.y = elem->corner.y + elem->height / 2.0; pkg->connections[5].pos.x = elem->corner.x; pkg->connections[5].pos.y = elem->corner.y + elem->height; pkg->connections[6].pos.x = elem->corner.x + elem->width / 2.0; pkg->connections[6].pos.y = elem->corner.y + elem->height; pkg->connections[7].pos.x = elem->corner.x + elem->width; pkg->connections[7].pos.y = elem->corner.y + elem->height; element_update_boundingbox(elem); /* fix boundingsmallpackage for line width and top rectangle: */ obj->bounding_box.top -= SMALLPACKAGE_BORDERWIDTH/2.0 + SMALLPACKAGE_TOPHEIGHT; obj->bounding_box.left -= SMALLPACKAGE_BORDERWIDTH/2.0; obj->bounding_box.bottom += SMALLPACKAGE_BORDERWIDTH/2.0; obj->bounding_box.right += SMALLPACKAGE_BORDERWIDTH/2.0; obj->position = elem->corner; element_update_handles(elem); }
static void image_update_data(EImage *image) { Element *elem = &image->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; if (image->name != NULL) { g_free(image->name); } image->name = g_strdup(image->embed_id); /* Update connections: */ image->connections[0].pos = elem->corner; image->connections[1].pos.x = elem->corner.x + elem->width / 2.0; image->connections[1].pos.y = elem->corner.y; image->connections[2].pos.x = elem->corner.x + elem->width; image->connections[2].pos.y = elem->corner.y; image->connections[3].pos.x = elem->corner.x; image->connections[3].pos.y = elem->corner.y + elem->height / 2.0; image->connections[4].pos.x = elem->corner.x + elem->width; image->connections[4].pos.y = elem->corner.y + elem->height / 2.0; image->connections[5].pos.x = elem->corner.x; image->connections[5].pos.y = elem->corner.y + elem->height; image->connections[6].pos.x = elem->corner.x + elem->width / 2.0; image->connections[6].pos.y = elem->corner.y + elem->height; image->connections[7].pos.x = elem->corner.x + elem->width; image->connections[7].pos.y = elem->corner.y + elem->height; image->connections[8].pos.x = elem->corner.x + elem->width / 2.0; image->connections[8].pos.y = elem->corner.y + elem->height / 2.0; extra->border_trans = image->border_width / 2.0; element_update_boundingbox(elem); obj->position = elem->corner; image->connections[8].directions = DIR_ALL; element_update_handles(elem); }
static void aadlbox_update_data(Aadlbox *aadlbox) { Element *elem = &aadlbox->element; DiaObject *obj = &aadlbox->element.object; Point min_size; int i; real tmp; aadlbox->specific->min_size(aadlbox, &min_size); elem->width = MAX(elem->width, min_size.x); elem->height = MAX(elem->height, min_size.y); element_update_boundingbox(elem); /* extend bounding box because of ports */ /* FIXME: This cause the box to be selectionned when clicking out of it !! */ obj->bounding_box.top -= AADL_PORT_MAX_OUT + 0.1; obj->bounding_box.right += AADL_PORT_MAX_OUT + 0.1; obj->bounding_box.bottom += AADL_PORT_MAX_OUT + 0.1; obj->bounding_box.left -= AADL_PORT_MAX_OUT + 0.1; obj->position = elem->corner; aadlbox_update_text_position(aadlbox); element_update_handles(elem); aadlbox_update_ports(aadlbox); for (i=0;i<aadlbox->num_connections;i++) aadlbox->specific->project_point_on_nearest_border(aadlbox, &aadlbox->connections[i]->pos, &tmp); }
static void state_update_data(State *state) { real w, h; Element *elem = &state->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; w = h = (state->is_final) ? STATE_ENDRATIO: STATE_RATIO; elem->width = w; elem->height = h; extra->border_trans = STATE_LINEWIDTH / 2.0; /* Update connections: */ element_update_connections_rectangle(elem, state->connections); element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); }
static void chronoref_update_data(Chronoref *chronoref) { Element *elem = &chronoref->element; DiaObject *obj = &elem->object; real time_span,t; Point p1,p2; Point ur_corner; int shouldbe,i; real labelwidth; char biglabel[10]; ElementBBExtras *extra = &elem->extra_spacing; chronoref->majgrad_height = elem->height; chronoref->mingrad_height = elem->height / 3.0; /* build i = -log_{10}(time_step), then make a %.if format out of it. */ t = 1; i = 0; while (t > chronoref->time_step) { t /= 10; i++; } chronoref->spec = i; /* update precision */ g_snprintf(biglabel,sizeof(biglabel),"%.*f", chronoref->spec, MIN(-ABS(chronoref->start_time),-ABS(chronoref->end_time))); labelwidth = dia_font_string_width(biglabel,chronoref->font, chronoref->font_size); /* Now, update the drawing helper counters */ time_span = chronoref->end_time - chronoref->start_time; if (time_span == 0) { chronoref->end_time = chronoref->start_time + .1; time_span = .1; } else if (time_span < 0) { chronoref->start_time = chronoref->end_time; time_span = -time_span; chronoref->end_time = chronoref->start_time + time_span; } chronoref->firstmaj = chronoref->time_step * ceil(chronoref->start_time / chronoref->time_step); if (chronoref->firstmaj < chronoref->start_time) chronoref->firstmaj += chronoref->time_step; chronoref->firstmin = chronoref->time_lstep * ceil(chronoref->start_time / chronoref->time_lstep); if (chronoref->firstmin < chronoref->start_time) chronoref->firstmin += chronoref->time_lstep; chronoref->firstmaj_x = elem->corner.x + elem->width*((chronoref->firstmaj-chronoref->start_time)/time_span); chronoref->firstmin_x = elem->corner.x + elem->width*((chronoref->firstmin-chronoref->start_time)/time_span); chronoref->majgrad = (chronoref->time_step * elem->width) / time_span; chronoref->mingrad = (chronoref->time_lstep * elem->width) / time_span; extra->border_trans = chronoref->main_lwidth/2; element_update_boundingbox(elem); /* fix boundingbox for special extras: */ obj->bounding_box.left -= (chronoref->font_size + labelwidth)/2; obj->bounding_box.bottom += chronoref->font_size; obj->bounding_box.right += (chronoref->font_size + labelwidth)/2; obj->position = elem->corner; element_update_handles(elem); /* Update connections: */ ur_corner.x = elem->corner.x + elem->width; ur_corner.y = elem->corner.y; shouldbe = (int)(ceil((chronoref->end_time-chronoref->firstmin)/ chronoref->time_lstep)); if (shouldbe == 0) shouldbe++; if (shouldbe < 0) shouldbe = 0; shouldbe++; /* off by one.. */ connpointline_adjust_count(chronoref->scale,shouldbe,&ur_corner); connpointline_update(chronoref->scale); point_copy(&p1,&elem->corner); point_copy(&p2,&ur_corner); p1.x -= chronoref->mingrad; p2.x += chronoref->mingrad; connpointline_putonaline(chronoref->scale,&p1,&p2, DIR_SOUTH); }
static void usecase_update_data(Usecase *usecase) { real w, h, ratio; Point c, half, r,p; Element *elem = &usecase->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; text_calc_boundingbox(usecase->text, NULL); w = usecase->text->max_width; h = usecase->text->height*usecase->text->numlines; if (!usecase->text_outside) { ratio = w/h; if (ratio > USECASE_MAX_RATIO) ratio = USECASE_MAX_RATIO; if (ratio < USECASE_MIN_RATIO) { ratio = USECASE_MIN_RATIO; r.y = w / ratio + h; r.x = r.y * ratio; } else { r.x = ratio*h + w; r.y = r.x / ratio; } if (r.x < USECASE_WIDTH) r.x = USECASE_WIDTH; if (r.y < USECASE_HEIGHT) r.y = USECASE_HEIGHT; } else { r.x = USECASE_WIDTH; r.y = USECASE_HEIGHT; } elem->width = r.x; elem->height = r.y; extra->border_trans = usecase->line_width / 2.0; if (usecase->text_outside) { elem->width = MAX(elem->width, w); elem->height += h + USECASE_MARGIN_Y; } r.x /= 2.0; r.y /= 2.0; c.x = elem->corner.x + elem->width / 2.0; c.y = elem->corner.y + r.y; half.x = r.x * M_SQRT1_2; half.y = r.y * M_SQRT1_2; /* Update connections: */ usecase->connections[0].pos.x = c.x - half.x; usecase->connections[0].pos.y = c.y - half.y; usecase->connections[1].pos.x = c.x; usecase->connections[1].pos.y = elem->corner.y; usecase->connections[2].pos.x = c.x + half.x; usecase->connections[2].pos.y = c.y - half.y; usecase->connections[3].pos.x = c.x - r.x; usecase->connections[3].pos.y = c.y; usecase->connections[4].pos.x = c.x + r.x; usecase->connections[4].pos.y = c.y; if (usecase->text_outside) { usecase->connections[5].pos.x = elem->corner.x; usecase->connections[5].pos.y = elem->corner.y + elem->height; usecase->connections[6].pos.x = c.x; usecase->connections[6].pos.y = elem->corner.y + elem->height; usecase->connections[7].pos.x = elem->corner.x + elem->width; usecase->connections[7].pos.y = elem->corner.y + elem->height; } else { usecase->connections[5].pos.x = c.x - half.x; usecase->connections[5].pos.y = c.y + half.y; usecase->connections[6].pos.x = c.x; usecase->connections[6].pos.y = elem->corner.y + elem->height; usecase->connections[7].pos.x = c.x + half.x; usecase->connections[7].pos.y = c.y + half.y; } usecase->connections[8].pos.x = c.x; usecase->connections[8].pos.y = c.y; usecase->connections[0].directions = DIR_NORTH|DIR_WEST; usecase->connections[1].directions = DIR_NORTH; usecase->connections[2].directions = DIR_NORTH|DIR_EAST; usecase->connections[3].directions = DIR_WEST; usecase->connections[4].directions = DIR_EAST; usecase->connections[5].directions = DIR_SOUTH|DIR_WEST; usecase->connections[6].directions = DIR_SOUTH; usecase->connections[7].directions = DIR_SOUTH|DIR_EAST; usecase->connections[8].directions = DIR_ALL; h = usecase->text->height*usecase->text->numlines; p = usecase->element.corner; p.x += usecase->element.width/2.0; if (usecase->text_outside) { p.y += usecase->element.height - h + usecase->text->ascent; } else { p.y += (usecase->element.height - h)/2.0 + usecase->text->ascent; } text_set_position(usecase->text, &p); element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); }
static void ellipse_update_data(Ellipse *ellipse, AnchorShape horiz, AnchorShape vert) { Element *elem = &ellipse->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; Point center, bottom_right; Point p, c; real dw, dh; real width, height; real radius1, radius2; int i; /* save starting points */ center = bottom_right = elem->corner; center.x += elem->width/2; bottom_right.x += elem->width; center.y += elem->height/2; bottom_right.y += elem->height; text_calc_boundingbox(ellipse->text, NULL); width = ellipse->text->max_width + 2 * ellipse->padding; height = ellipse->text->height * ellipse->text->numlines + 2 * ellipse->padding; /* stop ellipse from getting infinite width/height */ if (elem->width / elem->height > 4) elem->width = elem->height * 4; else if (elem->height / elem->width > 4) elem->height = elem->width * 4; c.x = elem->corner.x + elem->width / 2; c.y = elem->corner.y + elem->height / 2; p.x = c.x - width / 2; p.y = c.y - height / 2; radius1 = ellipse_radius(ellipse, p.x, p.y) - ellipse->border_width/2; radius2 = distance_point_point(&c, &p); if ( radius1 < radius2 && ( ellipse->text_fitting == TEXTFIT_ALWAYS || ellipse->text_fitting == TEXTFIT_WHEN_NEEDED)) { /* increase size of the ellipse while keeping its aspect ratio */ elem->width *= radius2 / radius1; elem->height *= radius2 / radius1; } /* move shape if necessary ... */ switch (horiz) { case ANCHOR_MIDDLE: elem->corner.x = center.x - elem->width/2; break; case ANCHOR_END: elem->corner.x = bottom_right.x - elem->width; break; default: break; } switch (vert) { case ANCHOR_MIDDLE: elem->corner.y = center.y - elem->height/2; break; case ANCHOR_END: elem->corner.y = bottom_right.y - elem->height; break; default: break; } p = elem->corner; p.x += elem->width / 2.0; p.y += elem->height / 2.0 - ellipse->text->height*ellipse->text->numlines/2 + ellipse->text->ascent; switch (ellipse->text->alignment) { case ALIGN_LEFT: p.x -= (elem->width - 2*(ellipse->padding + ellipse->border_width))/2; break; case ALIGN_RIGHT: p.x += (elem->width - 2*(ellipse->padding + ellipse->border_width))/2; break; case ALIGN_CENTER: break; } text_set_position(ellipse->text, &p); /* Update connections: */ c.x = elem->corner.x + elem->width / 2; c.y = elem->corner.y + elem->height / 2; dw = elem->width / 2.0; dh = elem->height / 2.0; for (i = 0; i < NUM_CONNECTIONS-1; i++) { real theta = M_PI / 8.0 * i; real costheta = cos(theta); real sintheta = sin(theta); connpoint_update(&ellipse->connections[i], c.x + dw * costheta, c.y - dh * sintheta, (costheta > .5?DIR_EAST:(costheta < -.5?DIR_WEST:0))| (sintheta > .5?DIR_NORTH:(sintheta < -.5?DIR_SOUTH:0))); } connpoint_update(&ellipse->connections[16], c.x, c.y, DIR_ALL); extra->border_trans = ellipse->border_width / 2.0; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); }
static void box_update_data(Box *box) { Element *elem = &box->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; real radius; if (box->aspect == SQUARE_ASPECT){ float size = elem->height < elem->width ? elem->height : elem->width; elem->height = elem->width = size; } radius = box->corner_radius; radius = MIN(radius, elem->width/2); radius = MIN(radius, elem->height/2); radius *= (1-M_SQRT1_2); /* Update connections: */ box->connections[0].pos.x = elem->corner.x + radius; box->connections[0].pos.y = elem->corner.y + radius; box->connections[1].pos.x = elem->corner.x + elem->width / 2.0; box->connections[1].pos.y = elem->corner.y; box->connections[2].pos.x = elem->corner.x + elem->width - radius; box->connections[2].pos.y = elem->corner.y + radius; box->connections[3].pos.x = elem->corner.x; box->connections[3].pos.y = elem->corner.y + elem->height / 2.0; box->connections[4].pos.x = elem->corner.x + elem->width; box->connections[4].pos.y = elem->corner.y + elem->height / 2.0; box->connections[5].pos.x = elem->corner.x + radius; box->connections[5].pos.y = elem->corner.y + elem->height - radius; box->connections[6].pos.x = elem->corner.x + elem->width / 2.0; box->connections[6].pos.y = elem->corner.y + elem->height; box->connections[7].pos.x = elem->corner.x + elem->width - radius; box->connections[7].pos.y = elem->corner.y + elem->height - radius; box->connections[8].pos.x = elem->corner.x + elem->width / 2.0; box->connections[8].pos.y = elem->corner.y + elem->height / 2.0; box->connections[0].directions = DIR_NORTH|DIR_WEST; box->connections[1].directions = DIR_NORTH; box->connections[2].directions = DIR_NORTH|DIR_EAST; box->connections[3].directions = DIR_WEST; box->connections[4].directions = DIR_EAST; box->connections[5].directions = DIR_SOUTH|DIR_WEST; box->connections[6].directions = DIR_SOUTH; box->connections[7].directions = DIR_SOUTH|DIR_EAST; box->connections[8].directions = DIR_ALL; extra->border_trans = box->border_width / 2.0; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); if (radius > 0.0) { /* Fix the handles, too */ elem->resize_handles[0].pos.x += radius; elem->resize_handles[0].pos.y += radius; elem->resize_handles[2].pos.x -= radius; elem->resize_handles[2].pos.y += radius; elem->resize_handles[5].pos.x += radius; elem->resize_handles[5].pos.y -= radius; elem->resize_handles[7].pos.x -= radius; elem->resize_handles[7].pos.y -= radius; } }
static void box_update_data(Box *box, AnchorShape horiz, AnchorShape vert) { Element *elem = &box->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; Point center, bottom_right; Point p; real radius; real width, height; /* save starting points */ center = bottom_right = elem->corner; center.x += elem->width/2; bottom_right.x += elem->width; center.y += elem->height/2; bottom_right.y += elem->height; text_calc_boundingbox(box->text, NULL); width = box->text->max_width + box->padding*2 + box->border_width; height = box->text->height * box->text->numlines + box->padding*2 + box->border_width; /* * If elem->width (e.g. the new requested dimensions of this object * from move_handle()) is smaller than the minimum width (i.e. the * width calculated from text-width, padding and border), then * set the width to the minimum. Or else;) */ if (box->text_fitting != TEXTFIT_NEVER) { if ( box->text_fitting == TEXTFIT_ALWAYS || width > elem->width) elem->width = width; if ( box->text_fitting == TEXTFIT_ALWAYS || height > elem->height) elem->height = height; } /* move shape if necessary ... */ switch (horiz) { case ANCHOR_MIDDLE: elem->corner.x = center.x - elem->width/2; break; case ANCHOR_END: elem->corner.x = bottom_right.x - elem->width; break; default: break; } switch (vert) { case ANCHOR_MIDDLE: elem->corner.y = center.y - elem->height/2; break; case ANCHOR_END: elem->corner.y = bottom_right.y - elem->height; break; default: break; } p = elem->corner; p.x += elem->width / 2.0; p.y += elem->height / 2.0 - box->text->height * box->text->numlines / 2 + box->text->ascent; switch (box->text->alignment) { case ALIGN_LEFT: p.x -= (elem->width - box->padding*2 + box->border_width)/2; break; case ALIGN_RIGHT: p.x += (elem->width - box->padding*2 + box->border_width)/2; break; case ALIGN_CENTER: break; } text_set_position(box->text, &p); radius = box->corner_radius; radius = MIN(radius, elem->width/2); radius = MIN(radius, elem->height/2); radius *= (1-M_SQRT1_2); /* Update connections: */ connpoint_update(&box->connections[0], elem->corner.x + radius, elem->corner.y + radius, DIR_NORTHWEST); connpoint_update(&box->connections[1], elem->corner.x + elem->width / 4.0, elem->corner.y, DIR_NORTH); connpoint_update(&box->connections[2], elem->corner.x + elem->width / 2.0, elem->corner.y, DIR_NORTH); connpoint_update(&box->connections[3], elem->corner.x + elem->width * 3.0 / 4.0, elem->corner.y, DIR_NORTH); connpoint_update(&box->connections[4], elem->corner.x + elem->width - radius, elem->corner.y + radius, DIR_NORTHEAST); connpoint_update(&box->connections[5], elem->corner.x, elem->corner.y + elem->height / 4.0, DIR_WEST); connpoint_update(&box->connections[6], elem->corner.x + elem->width, elem->corner.y + elem->height / 4.0, DIR_EAST); connpoint_update(&box->connections[7], elem->corner.x, elem->corner.y + elem->height / 2.0, DIR_WEST); connpoint_update(&box->connections[8], elem->corner.x + elem->width, elem->corner.y + elem->height / 2.0, DIR_EAST); connpoint_update(&box->connections[9], elem->corner.x, elem->corner.y + elem->height * 3.0 / 4.0, DIR_WEST); connpoint_update(&box->connections[10], elem->corner.x + elem->width, elem->corner.y + elem->height * 3.0 / 4.0, DIR_EAST); connpoint_update(&box->connections[11], elem->corner.x + radius, elem->corner.y + elem->height - radius, DIR_SOUTHWEST); connpoint_update(&box->connections[12], elem->corner.x + elem->width / 4.0, elem->corner.y + elem->height, DIR_SOUTH); connpoint_update(&box->connections[13], elem->corner.x + elem->width / 2.0, elem->corner.y + elem->height, DIR_SOUTH); connpoint_update(&box->connections[14], elem->corner.x + elem->width * 3.0 / 4.0, elem->corner.y + elem->height, DIR_SOUTH); connpoint_update(&box->connections[15], elem->corner.x + elem->width - radius, elem->corner.y + elem->height - radius, DIR_SOUTHEAST); connpoint_update(&box->connections[16], elem->corner.x + elem->width / 2, elem->corner.y + elem->height / 2, DIR_ALL); extra->border_trans = box->border_width / 2.0; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); if (radius > 0.0) { /* Fix the handles, too */ elem->resize_handles[0].pos.x += radius; elem->resize_handles[0].pos.y += radius; elem->resize_handles[2].pos.x -= radius; elem->resize_handles[2].pos.y += radius; elem->resize_handles[5].pos.x += radius; elem->resize_handles[5].pos.y -= radius; elem->resize_handles[7].pos.x -= radius; elem->resize_handles[7].pos.y -= radius; } }
static void actor_update_data(Actor *actor, AnchorShape horiz, AnchorShape vert) { Element *elem = &actor->element; DiaObject *obj = &elem->object; ElementBBExtras *extra = &elem->extra_spacing; Point center, bottom_right,p,c; real width, height, dw, dh; real radius, mradius; int i; center = bottom_right = elem->corner; center.x += elem->width/2; bottom_right.x += elem->width; center.y += elem->height/2; bottom_right.y += elem->height; text_calc_boundingbox(actor->text, NULL); width = actor->text->max_width+0.5; height = actor->text->height * (actor->text->numlines + 3); /* added 3 blank lines for top */ /* minimal radius */ mradius=width; if (mradius<height) mradius=height; if (mradius<ACTOR_RADIUS) mradius=ACTOR_RADIUS; /* radius */ radius=elem->width; if (radius<elem->height) radius=elem->height; /* enforce (minimal or resized) radius */ if (radius<mradius) radius=mradius; elem->width=elem->height=radius; /* move shape if necessary ... (untouched) */ switch (horiz) { case ANCHOR_MIDDLE: elem->corner.x = center.x - elem->width/2; break; case ANCHOR_END: elem->corner.x = bottom_right.x - elem->width; break; default: break; } switch (vert) { case ANCHOR_MIDDLE: elem->corner.y = center.y - elem->height/2; break; case ANCHOR_END: elem->corner.y = bottom_right.y - elem->height; break; default: break; } p = elem->corner; p.x += elem->width / 2.0; p.y += elem->height / 2.0 - actor->text->height*actor->text->numlines/2 + actor->text->ascent; text_set_position(actor->text, &p); /* compute connection positions */ c.x = elem->corner.x + elem->width / 2; c.y = elem->corner.y + elem->height / 2; dw = elem->width / 2.0; dh = elem->height / 2.0; for (i = 0; i < NUM_CONNECTIONS-1; i++) { real theta = M_PI / 8.0 * i; /* TODO: Set up directions for autorouting */ actor->connections[i].pos.x = c.x + dw * cos(theta); actor->connections[i].pos.y = c.y - dh * sin(theta); } actor->connections[16].pos.x = c.x; actor->connections[16].pos.y = c.y; extra->border_trans = ACTOR_BORDER_WIDTH / 2.0; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); }
static void objet_update_data(Objet *ob) { Element *elem = &ob->element; DiaObject *obj = &elem->object; DiaFont *font; Point p1, p2; real h, w = 0; text_calc_boundingbox(ob->text, NULL); ob->stereotype = remove_stereotype_from_string(ob->stereotype); if (!ob->st_stereotype) { ob->st_stereotype = string_to_stereotype(ob->stereotype); } font = ob->text->font; h = elem->corner.y + OBJET_MARGIN_Y(ob); if (ob->is_multiple) { h += OBJET_MARGIN_M(ob); } if ((ob->stereotype != NULL) && (ob->stereotype[0] != '\0')) { w = dia_font_string_width(ob->st_stereotype, font, OBJET_FONTHEIGHT(ob)); h += OBJET_FONTHEIGHT(ob); ob->st_pos.y = h; h += OBJET_MARGIN_Y(ob)/2.0; } w = MAX(w, ob->text->max_width); p1.y = h + ob->text->ascent; /* position of text */ h += ob->text->height*ob->text->numlines; if ((ob->exstate != NULL) && (ob->exstate[0] != '\0')) { w = MAX(w, dia_font_string_width(ob->exstate, font, OBJET_FONTHEIGHT(ob))); h += OBJET_FONTHEIGHT(ob); ob->ex_pos.y = h; } h += OBJET_MARGIN_Y(ob); if (ob->show_attributes) { h += OBJET_MARGIN_Y(ob) + ob->attributes->ascent; p2.x = elem->corner.x + OBJET_MARGIN_X(ob); p2.y = h; text_set_position(ob->attributes, &p2); h += ob->attributes->height*ob->attributes->numlines; text_calc_boundingbox(ob->attributes, NULL); w = MAX(w, ob->attributes->max_width); } w += 2*OBJET_MARGIN_X(ob); p1.x = elem->corner.x + w/2.0; text_set_position(ob->text, &p1); ob->ex_pos.x = ob->st_pos.x = p1.x; if (ob->is_multiple) { w += OBJET_MARGIN_M(ob); } elem->width = w; elem->height = h - elem->corner.y; /* Update connections: */ element_update_connections_rectangle(elem, ob->connections); element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); }
static void req_update_data(Requirement *req) { real w, h, ratio; Point c, half, r,p; Element *elem = &req->element; DiaObject *obj = &elem->object; text_calc_boundingbox(req->text, NULL); w = req->text->max_width; h = req->text->height*req->text->numlines; ratio = w/h; if (ratio > REQ_MAX_RATIO) ratio = REQ_MAX_RATIO; if (ratio < REQ_MIN_RATIO) { ratio = REQ_MIN_RATIO; r.y = w / ratio + h; r.x = r.y * ratio; } else { r.x = ratio*h + w; r.y = r.x / ratio; } if (r.x < REQ_WIDTH) r.x = REQ_WIDTH; if (r.y < REQ_HEIGHT) r.y = REQ_HEIGHT; elem->width = r.x; elem->height = r.y; r.x /= 2.0; r.y /= 2.0; c.x = elem->corner.x + elem->width / 2.0; c.y = elem->corner.y + r.y; half.x = r.x * M_SQRT1_2; half.y = r.y * M_SQRT1_2; /* Update connections: */ req->connections[0].pos.x = c.x - half.x; req->connections[0].pos.y = c.y - half.y; req->connections[1].pos.x = c.x; req->connections[1].pos.y = elem->corner.y; req->connections[2].pos.x = c.x + half.x; req->connections[2].pos.y = c.y - half.y; req->connections[3].pos.x = c.x - r.x; req->connections[3].pos.y = c.y; req->connections[4].pos.x = c.x + r.x; req->connections[4].pos.y = c.y; req->connections[5].pos.x = c.x - half.x; req->connections[5].pos.y = c.y + half.y; req->connections[6].pos.x = c.x; req->connections[6].pos.y = elem->corner.y + elem->height; req->connections[7].pos.x = c.x + half.x; req->connections[7].pos.y = c.y + half.y; req->connections[8].pos.x = elem->corner.x + elem->width/2; req->connections[8].pos.y = elem->corner.y + elem->height/2; h = req->text->height*req->text->numlines; p = req->element.corner; p.x += req->element.width/2.0; p.y += (req->element.height - h)/2.0 + req->text->ascent; text_set_position(req->text, &p); element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); /* Boundingbox calculation including the line width */ { Rectangle bbox; ellipse_bbox (&c, elem->width, elem->height, &elem->extra_spacing, &bbox); rectangle_union(&obj->bounding_box, &bbox); } }
static void attribute_update_data(Attribute *attribute) { Element *elem = &attribute->element; DiaObject *obj = &elem->object; Point center; ElementBBExtras *extra = &elem->extra_spacing; real half_x, half_y; attribute->name_width = dia_font_string_width(attribute->name, attribute->font, attribute->font_height); elem->width = attribute->name_width + 2*TEXT_BORDER_WIDTH_X; elem->height = attribute->font_height + 2*TEXT_BORDER_WIDTH_Y; center.x = elem->corner.x + elem->width / 2.0; center.y = elem->corner.y + elem->height / 2.0; half_x = elem->width * M_SQRT1_2 / 2.0; half_y = elem->height * M_SQRT1_2 / 2.0; /* Update connections: */ connpoint_update(&attribute->connections[0], center.x - half_x, center.y - half_y, DIR_NORTHWEST); connpoint_update(&attribute->connections[1], center.x, elem->corner.y, DIR_NORTH); connpoint_update(&attribute->connections[2], center.x + half_x, center.y - half_y, DIR_NORTHEAST); connpoint_update(&attribute->connections[3], elem->corner.x, center.y, DIR_WEST); connpoint_update(&attribute->connections[4], elem->corner.x + elem->width, elem->corner.y + elem->height / 2.0, DIR_EAST); connpoint_update(&attribute->connections[5], center.x - half_x, center.y + half_y, DIR_SOUTHWEST); connpoint_update(&attribute->connections[6], elem->corner.x + elem->width / 2.0, elem->corner.y + elem->height, DIR_SOUTH); connpoint_update(&attribute->connections[7], center.x + half_x, center.y + half_y, DIR_SOUTHEAST); connpoint_update(&attribute->connections[8], center.x, center.y, DIR_ALL); extra->border_trans = attribute->border_width/2.0; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); }
static void ellipse_update_data(Ellipse *ellipse) { Element *elem = &ellipse->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; Point center; real half_x, half_y; /* handle circle implies height=width */ if (ellipse->aspect == CIRCLE_ASPECT){ float size = elem->height < elem->width ? elem->height : elem->width; elem->height = elem->width = size; } center.x = elem->corner.x + elem->width / 2.0; center.y = elem->corner.y + elem->height / 2.0; half_x = elem->width * M_SQRT1_2 / 2.0; half_y = elem->height * M_SQRT1_2 / 2.0; /* Update connections: */ ellipse->connections[0].pos.x = center.x - half_x; ellipse->connections[0].pos.y = center.y - half_y; ellipse->connections[1].pos.x = center.x; ellipse->connections[1].pos.y = elem->corner.y; ellipse->connections[2].pos.x = center.x + half_x; ellipse->connections[2].pos.y = center.y - half_y; ellipse->connections[3].pos.x = elem->corner.x; ellipse->connections[3].pos.y = center.y; ellipse->connections[4].pos.x = elem->corner.x + elem->width; ellipse->connections[4].pos.y = elem->corner.y + elem->height / 2.0; ellipse->connections[5].pos.x = center.x - half_x; ellipse->connections[5].pos.y = center.y + half_y; ellipse->connections[6].pos.x = elem->corner.x + elem->width / 2.0; ellipse->connections[6].pos.y = elem->corner.y + elem->height; ellipse->connections[7].pos.x = center.x + half_x; ellipse->connections[7].pos.y = center.y + half_y; ellipse->connections[8].pos.x = center.x; ellipse->connections[8].pos.y = center.y; /* Update directions -- if the ellipse is very thin, these may not be good */ ellipse->connections[0].directions = DIR_NORTH|DIR_WEST; ellipse->connections[1].directions = DIR_NORTH; ellipse->connections[2].directions = DIR_NORTH|DIR_EAST; ellipse->connections[3].directions = DIR_WEST; ellipse->connections[4].directions = DIR_EAST; ellipse->connections[5].directions = DIR_SOUTH|DIR_WEST; ellipse->connections[6].directions = DIR_SOUTH; ellipse->connections[7].directions = DIR_SOUTH|DIR_EAST; ellipse->connections[8].directions = DIR_ALL; extra->border_trans = ellipse->border_width / 2.0; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); obj->handles[8]->pos.x = center.x; obj->handles[8]->pos.y = center.y; }
static void goal_update_data(Goal *goal, AnchorShape horiz, AnchorShape vert) { Element *elem = &goal->element; ElementBBExtras *extra = &elem->extra_spacing; DiaObject *obj = &elem->object; Point center, bottom_right; Point p; real w, h; ConnectionPoint *c; /* save starting points */ center = bottom_right = elem->corner; center.x += elem->width/2; bottom_right.x += elem->width; center.y += elem->height/2; bottom_right.y += elem->height; text_calc_boundingbox(goal->text, NULL); w = goal->text->max_width + goal->padding*2; h = goal->text->height * goal->text->numlines + goal->padding*2; /* autoscale here */ if (w > elem->width) elem->width = w; if (h > elem->height) elem->height = h; if (elem->width<elem->height) elem->width=elem->height; /* move shape if necessary ... */ switch (horiz) { case ANCHOR_MIDDLE: elem->corner.x = center.x - elem->width/2; break; case ANCHOR_END: elem->corner.x = bottom_right.x - elem->width; break; default: break; } switch (vert) { case ANCHOR_MIDDLE: elem->corner.y = center.y - elem->height/2; break; case ANCHOR_END: elem->corner.y = bottom_right.y - elem->height; break; default: break; } p = elem->corner; p.x += elem->width / 2.0; p.y += elem->height / 2.0 - goal->text->height * goal->text->numlines / 2 + goal->text->ascent; text_set_position(goal->text, &p); extra->border_trans = GOAL_LINE_WIDTH; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); /* Update connections: */ p = elem->corner; w = elem->width; h = elem->height; c = goal->connector; switch (goal->type) { case SOFTGOAL: update_softgoal_connectors(c,p,w,h); break; case GOAL: update_goal_connectors(c,p,w,h); break; } }
static void newgroup_update_data(NewGroup *group) { Element *elem = &group->element; /* ElementBBExtras *extra = &elem->extra_spacing; */ DiaObject *obj = &elem->object; /* Update connections: */ group->connections[0].pos.x = elem->corner.x; group->connections[0].pos.y = elem->corner.y; group->connections[1].pos.x = elem->corner.x + elem->width / 2.0; group->connections[1].pos.y = elem->corner.y; group->connections[2].pos.x = elem->corner.x + elem->width; group->connections[2].pos.y = elem->corner.y; group->connections[3].pos.x = elem->corner.x; group->connections[3].pos.y = elem->corner.y + elem->height / 2.0; group->connections[4].pos.x = elem->corner.x + elem->width; group->connections[4].pos.y = elem->corner.y + elem->height / 2.0; group->connections[5].pos.x = elem->corner.x; group->connections[5].pos.y = elem->corner.y + elem->height; group->connections[6].pos.x = elem->corner.x + elem->width / 2.0; group->connections[6].pos.y = elem->corner.y + elem->height; group->connections[7].pos.x = elem->corner.x + elem->width; group->connections[7].pos.y = elem->corner.y + elem->height; group->connections[8].pos.x = elem->corner.x + elem->width / 2.0; group->connections[8].pos.y = elem->corner.y + elem->height / 2.0; group->connections[0].directions = DIR_NORTH|DIR_WEST; group->connections[1].directions = DIR_NORTH; group->connections[2].directions = DIR_NORTH|DIR_EAST; group->connections[3].directions = DIR_WEST; group->connections[4].directions = DIR_EAST; group->connections[5].directions = DIR_SOUTH|DIR_WEST; group->connections[6].directions = DIR_SOUTH; group->connections[7].directions = DIR_SOUTH|DIR_EAST; group->connections[8].directions = DIR_ALL; element_update_boundingbox(elem); obj->position = elem->corner; element_update_handles(elem); if (group->is_open) { obj->flags &= ~DIA_OBJECT_GRABS_CHILD_INPUT; } else { gboolean newlySet = FALSE; Layer *layer; if (!object_flags_set(obj, DIA_OBJECT_GRABS_CHILD_INPUT)) { newlySet = TRUE; } obj->flags |= DIA_OBJECT_GRABS_CHILD_INPUT; if (newlySet) { layer = dia_object_get_parent_layer(obj); if (layer != NULL) { /* Placed in diagram already */ GList *children = g_list_prepend(NULL, obj); children = parent_list_affected(children); /* Remove the group object that stayed at the start of the list, leaving only the children */ children = g_list_remove_link(children, children); #if 0 /* this introduces a crircular dependency, does not work on win32 and is bad style everywhere */ diagram_unselect_objects(layer_get_parent_diagram(layer), children); #else g_warning ("used to call diagram_unselect_objects()"); #endif g_list_free(children); } } } }
static void step_update_data(Step *step) { Element *elem = &step->element; DiaObject *obj = &elem->object; ElementBBExtras *extra = &elem->extra_spacing; Point *p,ulc; ulc = elem->corner; ulc.x += ((STEP_DECLAREDWIDTH - STEP_WIDTH) / 2.0); /* we cheat a little */ step->A.x = 0.0 + (STEP_WIDTH / 2.0); step->A.y = 0.0; step->D.x = 0.0 + (STEP_WIDTH / 2.0); step->D.y = 0.0 + STEP_HEIGHT; step->E.x = 0.0; step->E.y = 0.5; step->F.x = STEP_WIDTH; step->F.y = STEP_HEIGHT- 0.5; switch(step->type) { case STEP_INITIAL: step->I.x = step->E.x - 2 * STEP_LINE_WIDTH; step->I.y = step->E.y - 2 * STEP_LINE_WIDTH; step->J.x = step->F.x + 2 * STEP_LINE_WIDTH; step->J.y = step->F.y + 2 * STEP_LINE_WIDTH; step->B.x = step->A.x; step->B.y = step->I.y; step->C.x = step->D.x; step->C.y = step->J.y; step->Z.x = step->J.x; step->Z.y = STEP_HEIGHT / 2; break; case STEP_MACROCALL: step->I.x = step->E.x; step->I.y = step->E.y - 2 * STEP_LINE_WIDTH; step->J.x = step->F.x; step->J.y = step->F.y + 2 * STEP_LINE_WIDTH; step->B.x = step->A.x; step->B.y = step->I.y; step->C.x = step->D.x; step->C.y = step->J.y; step->Z.x = step->J.x; step->Z.y = STEP_HEIGHT / 2; break; case STEP_SUBPCALL: step->I.x = step->E.x - 2 * STEP_LINE_WIDTH; step->I.y = step->E.y; step->J.x = step->F.x + 2 * STEP_LINE_WIDTH; step->J.y = step->F.y; step->B.x = step->A.x; step->B.y = step->I.y; step->C.x = step->D.x; step->C.y = step->J.y; step->Z.x = step->J.x; step->Z.y = STEP_HEIGHT / 2; break; default: /* regular or macro end steps */ step->B.x = step->A.x; step->B.y = step->E.y; step->C.x = step->D.x; step->C.y = step->F.y; step->Z.x = step->F.x; step->Z.y = STEP_HEIGHT / 2; } step->G.x = step->A.x; step->G.y = (STEP_HEIGHT / 2) + (.3 * step->font_size); step->H.x = step->E.x + (1.2 * STEP_DOT_RADIUS); step->H.y = step->F.y - (1.2 * STEP_DOT_RADIUS); for (p=&(step->A); p<=&(step->Z) ; p++) point_add(p,&ulc); /* Update handles: */ if (step->north.pos.x == -65536.0) { step->north.pos = step->A; step->south.pos = step->D; } step->NU1.x = step->north.pos.x; step->NU2.x = step->A.x; step->NU1.y = step->NU2.y = (step->north.pos.y + step->A.y) / 2.0; step->SD1.x = step->D.x; step->SD2.x = step->south.pos.x; step->SD1.y = step->SD2.y = (step->south.pos.y + step->D.y) / 2.0; /* Update connections: */ step->connections[0].pos = step->A; step->connections[0].directions = DIR_NORTH; step->connections[1].pos = step->D; step->connections[1].directions = DIR_SOUTH; step->connections[2].pos = step->Z; step->connections[2].directions = DIR_EAST; step->connections[3].pos = step->H; step->connections[3].directions = DIR_WEST; /* recalc the bounding box : */ if ((step->type == STEP_INITIAL) || (step->type == STEP_SUBPCALL)) { extra->border_trans = 2.5 * STEP_LINE_WIDTH; } else { extra->border_trans = STEP_LINE_WIDTH / 2; } element_update_boundingbox(elem); rectangle_add_point(&obj->bounding_box,&step->north.pos); rectangle_add_point(&obj->bounding_box,&step->south.pos); obj->position = elem->corner; element_update_handles(elem); }