static void fix_box(int x, int y) { canvas_ref_proc = canvas_locmove_proc = null_proc; elastic_box(fix_x, fix_y, cur_x, cur_y); /* erase last lengths if appres.showlengths is true */ erase_box_lengths(); adjust_box_pos(x, y, from_x, from_y, &x, &y); new_l = copy_line(cur_l); if (new_l->type == T_PICTURE) { if (signof(fix_x - from_x) != signof(fix_x - x)) new_l->pic->flipped = 1 - new_l->pic->flipped; if (signof(fix_y - from_y) != signof(fix_y - y)) new_l->pic->flipped = 1 - new_l->pic->flipped; } assign_newboxpoint(new_l, fix_x, fix_y, x, y); change_line(cur_l, new_l); /* redraw anything under the old line */ redisplay_line(cur_l); /* and the new line */ redisplay_line(new_l); /* turn back on all relevant markers */ update_markers(new_objmask); wrapup_movepoint(); }
static void fix_movedcompoundpoint(int x, int y) { float scalex, scaley; canvas_ref_proc = canvas_locmove_proc = null_proc; elastic_box(fix_x, fix_y, cur_x, cur_y); /* erase last lengths if appres.showlengths is true */ erase_lengths(); adjust_box_pos(x, y, from_x, from_y, &cur_x, &cur_y); /* make a copy of the original and save as unchanged object */ old_c = copy_compound(cur_c); clean_up(); old_c->next = cur_c; set_latestcompound(old_c); set_action_object(F_EDIT, O_COMPOUND); scalex = ((float) (cur_x - fix_x)) / (from_x - fix_x); scaley = ((float) (cur_y - fix_y)) / (from_y - fix_y); /* scale the compound */ scale_compound(cur_c, scalex, scaley, fix_x, fix_y); /* redraw anything under the old compound */ redisplay_compound(old_c); /* and the new compound */ redisplay_compound(cur_c); /* turn back on all relevant markers */ update_markers(new_objmask); set_lastposition(from_x, from_y); set_newposition(cur_x, cur_y); set_modifiedflag(); wrapup_movepoint(); }
static void cancel_tag_region(void) { elastic_box(fix_x, fix_y, cur_x, cur_y); /* erase last lengths if appres.showlengths is true */ erase_box_lengths(); compound_selected(); draw_mousefun_canvas(); }
static void cancel_compound(void) { canvas_ref_proc = canvas_locmove_proc = null_proc; elastic_box(fix_x, fix_y, cur_x, cur_y); /* erase last lengths if appres.showlengths is true */ erase_lengths(); /* turn back on all relevant markers */ update_markers(new_objmask); wrapup_movepoint(); }
void elastic_movebox(void) { register int x1, y1, x2, y2; x1 = cur_x + x1off; x2 = cur_x + x2off; y1 = cur_y + y1off; y2 = cur_y + y2off; elastic_box(x1, y1, x2, y2); elastic_links(cur_x - fix_x, cur_y - fix_y, 1.0, 1.0); }
static void cancel_movept_box(void) { canvas_ref_proc = canvas_locmove_proc = null_proc; /* erase the elastic box */ elastic_box(fix_x, fix_y, cur_x, cur_y); /* erase last lengths if appres.showlengths is true */ erase_box_lengths(); /* redraw original box */ redisplay_line(cur_l); /* turn back on all relevant markers */ update_markers(new_objmask); wrapup_movepoint(); }
static void tag_region(int x, int y) { int xmin, ymin, xmax, ymax; elastic_box(fix_x, fix_y, cur_x, cur_y); /* erase last lengths if appres.showlengths is true */ erase_box_lengths(); xmin = min2(fix_x, x); ymin = min2(fix_y, y); xmax = max2(fix_x, x); ymax = max2(fix_y, y); tag_obj_in_region(xmin, ymin, xmax, ymax); compound_selected(); draw_mousefun_canvas(); }
static void init_compoundpointmoving(void) { double dx, dy, l; F_line *line, *dum; set_action_on(); if (cur_x == cur_c->nwcorner.x) fix_x = cur_c->secorner.x; else fix_x = cur_c->nwcorner.x; if (cur_y == cur_c->nwcorner.y) fix_y = cur_c->secorner.y; else fix_y = cur_c->nwcorner.y; from_x = cur_x; from_y = cur_y; /* turn off all markers */ update_markers(0); set_cursor(crosshair_cursor); elastic_box(fix_x, fix_y, cur_x, cur_y); /* is this a dimension line? */ if (dimline_components(cur_c, &line, &dum, &dum, &dum) && line) { /* yes, constrain the resizing in the direction of the line */ if (line->points->x == line->points->next->x) /* vertical line */ constrained = BOX_VSTRETCH; else /* horizontal line */ constrained = BOX_HSTRETCH; } if (constrained) { dx = cur_x - fix_x; dy = cur_y - fix_y; l = sqrt(dx * dx + dy * dy); cosa = fabs(dx / l); sina = fabs(dy / l); } canvas_locmove_proc = constrained_resizing_scale_box; canvas_ref_proc = elastic_fixedbox; canvas_leftbut_proc = fix_movedcompoundpoint; canvas_rightbut_proc = cancel_compound; /* show current length(s) */ (canvas_locmove_proc)(cur_x, cur_y); }
static void put_draw(int paint_mode) { register int x1, y1, x2, y2; if (draw_box) { x1=cur_x; y1=cur_y; x2=cur_x+off_library_x; y2=cur_y+off_library_y; elastic_box(x1, y1, x2, y2); } else { if (paint_mode==ERASE) redisplay_compound(new_c); else redisplay_objects(new_c); } }
void elastic_scalecompound(F_compound *c) { double newx, newy, oldx, oldy; double newd, oldd, scalefact; int x1, y1, x2, y2; newx = cur_x - fix_x; newy = cur_y - fix_y; newd = sqrt(newx * newx + newy * newy); oldx = from_x - fix_x; oldy = from_y - fix_y; oldd = sqrt(oldx * oldx + oldy * oldy); scalefact = newd / oldd; x1 = fix_x + round((c->secorner.x - fix_x) * scalefact); y1 = fix_y + round((c->secorner.y - fix_y) * scalefact); x2 = fix_x + round((c->nwcorner.x - fix_x) * scalefact); y2 = fix_y + round((c->nwcorner.y - fix_y) * scalefact); boxsize_scale_msg(2); elastic_box(x1, y1, x2, y2); }
static void init_linepointmoving(void) { F_point *p; set_action_on(); /* turn off all markers */ update_markers(0); from_x = cur_x = moved_point->x; from_y = cur_y = moved_point->y; set_cursor(crosshair_cursor); switch (cur_l->type) { case T_POLYGON: if (left_point == NULL) for (left_point = right_point, p = left_point->next; p->next != NULL; left_point = p, p = p->next); force_noanglegeom(); canvas_locmove_proc = reshaping_line; canvas_ref_proc = elastic_linelink; break; case T_BOX: case T_ARCBOX: case T_PICTURE: if (right_point->next == NULL) { /* point 4 */ fix_x = cur_l->points->next->x; fix_y = cur_l->points->next->y; } else { fix_x = right_point->next->x; fix_y = right_point->next->y; } if (constrained) { double dx, dy, l; dx = cur_x - fix_x; dy = cur_y - fix_y; l = sqrt(dx * dx + dy * dy); cosa = fabs(dx / l); sina = fabs(dy / l); } force_noanglegeom(); if (cur_l->thickness != 1) elastic_box(fix_x, fix_y, cur_x, cur_y); canvas_locmove_proc = constrained_resizing_box; canvas_ref_proc = elastic_fixedbox; canvas_leftbut_proc = fix_box; canvas_rightbut_proc = cancel_movept_box; /* show current length(s) */ (canvas_locmove_proc)(cur_x, cur_y); return; case T_POLYLINE: if (left_point == NULL || right_point == NULL) { if (left_point != NULL) { fix_x = left_point->x; fix_y = left_point->y; } else if (right_point != NULL) { fix_x = right_point->x; fix_y = right_point->y; } if (latexline_mode || latexarrow_mode) { canvas_locmove_proc = latex_line; canvas_ref_proc = elastic_line; cur_latexcursor = crosshair_cursor; } else if (mountain_mode || manhattan_mode) { canvas_locmove_proc = constrainedangle_line; canvas_ref_proc = elastic_line; } else { /* unconstrained or freehand line */ canvas_locmove_proc = reshaping_line; canvas_ref_proc = elastic_linelink; } } else { /* linelink, always freehand */ force_noanglegeom(); canvas_locmove_proc = reshaping_line; canvas_ref_proc = elastic_linelink; } break; } canvas_leftbut_proc = fix_movedlinepoint; canvas_rightbut_proc = cancel_movedlinepoint; /* show current length(s) */ (canvas_locmove_proc)(cur_x, cur_y); }
void elastic_fixedbox(void) { elastic_box(fix_x, fix_y, cur_x, cur_y); }