void get_intermediatepoint(int x, int y, int shift) { /* in freehand mode call unconstrained_line explicitely to move the mouse */ if (freehand_line) { unconstrained_line(x,y); /* pointer must move by at least freehand_resolution in any direction */ if (abs(fix_x-cur_x) < appres.freehand_resolution && (abs(fix_y-cur_y) < appres.freehand_resolution)) return; } else { /* otherwise call the (possibly) constrained movement procedure */ (*canvas_locmove_proc) (x, y); } /* don't allow coincident consecutive points */ if (fix_x == cur_x && fix_y == cur_y) return; num_point++; fix_x = cur_x; fix_y = cur_y; elastic_line(); if (cur_cursor != null_cursor) { set_cursor(null_cursor); } if (shift && num_point > 2) { F_point *p; num_point -= 2; p = prev_point(first_point, cur_point); p->next = NULL; /* erase the newest segment */ pw_vector(canvas_win, fix_x, fix_y, cur_point->x, cur_point->y, INV_PAINT, 1, RUBBER_LINE, 0.0, DEFAULT); /* and segment drawn before */ pw_vector(canvas_win, p->x, p->y, cur_point->x, cur_point->y, INV_PAINT, 1, RUBBER_LINE, 0.0, DEFAULT); /* and draw new elastic segment */ pw_vector(canvas_win, fix_x, fix_y, p->x, p->y, PAINT, 1, RUBBER_LINE, 0.0, DEFAULT); fix_x = p->x; fix_y = p->y; free_points(cur_point); cur_point = p; } else { append_point(fix_x, fix_y, &cur_point); } if (num_point == min_num_points - 1) { if (freehand_line) set_mousefun("", "final point", "cancel", "del point", "", ""); else set_mousefun("next point", "final point", "cancel", "del point", "", ""); draw_mousefun_canvas(); canvas_middlebut_proc = (FCallBack)canvas_middlebut_save; } }
static void place_lib_object(int x, int y, unsigned int shift) { F_compound *this_c; canvas_leftbut_proc = null_proc; canvas_middlebut_proc = null_proc; canvas_rightbut_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; put_draw(ERASE); clean_up(); if (draw_box) translate_compound(new_c,cur_x,cur_y); /* remove it from the depths because it will be added when it is put in the main list */ remove_compound_depth(new_c); add_compound(new_c); set_modifiedflag(); redisplay_compound(new_c); if (shift) { /* temporarily turn off library place mode so we can edit the object just placed */ canvas_kbd_proc = null_proc; clear_mousefun(); set_mousefun("","","", "", "", ""); turn_off_current(); set_cursor(arrow_cursor); edit_remember_lib_mode = True; this_c = new_c; edit_item(this_c, O_COMPOUND, 0, 0); } else { put_selected(); } }
static void init_arb_move(F_line *p, int type, int x, int y, int px, int py) { constrained = MOVE_ARB; init_move(p, type, x, y, px, py); canvas_middlebut_proc = null_proc; set_mousefun("place object", "", "cancel", LOC_OBJ, LOC_OBJ, LOC_OBJ); draw_mousefun_canvas(); }
static void init_arb_move_point(F_line *obj, int type, int x, int y, F_point *p, F_point *q) { constrained = MOVE_ARB; if (!init_move_point(obj, type, x, y, p, q)) return; set_mousefun("new posn", "", "cancel", LOC_OBJ, LOC_OBJ, LOC_OBJ); draw_mousefun_canvas(); canvas_middlebut_proc = null_proc; }
static void init_tag_region(int x, int y) { init_box_drawing(x, y); set_mousefun("", "final corner", "cancel", "", "", ""); draw_mousefun_canvas(); canvas_leftbut_proc = null_proc; canvas_middlebut_proc = tag_region; canvas_rightbut_proc = cancel_tag_region; }
void init_trace_drawing(int x, int y) { if ((first_point = create_point()) == NULL) return; cur_point = first_point; set_action_on(); cur_point->x = fix_x = cur_x = x; cur_point->y = fix_y = cur_y = y; cur_point->next = NULL; canvas_leftbut_proc = (FCallBack)get_intermediatepoint; if (freehand_line) { canvas_locmove_proc = freehand_get_intermediatepoint; } else { /* only two points in a dimension line */ if (dimension_line) canvas_leftbut_proc = (FCallBack)create_lineobject; if (latexline_mode || latexarrow_mode) { canvas_locmove_proc = latex_line; } else if (manhattan_mode || mountain_mode) { canvas_locmove_proc = constrainedangle_line; } else { canvas_locmove_proc = unconstrained_line; } } canvas_middlebut_save = create_lineobject; canvas_rightbut_proc = (FCallBack)cancel_line_drawing; return_proc = line_drawing_selected; num_point = 1; set_mousefun("next point", "", "cancel", "del point", "", ""); if (dimension_line) { set_mousefun("final point", "", "cancel", "del point", "", ""); canvas_middlebut_proc = (FCallBack)null_proc; } else if (num_point >= min_num_points - 1) { set_mousefun("next point", "final point", "cancel", "del point", "", ""); canvas_middlebut_proc = (FCallBack)canvas_middlebut_save; } draw_mousefun_canvas(); set_cursor(null_cursor); elastic_line(); }
void circle_ellipse_bydiameter_drawing_selected(void) { set_mousefun("Circle diameter", "Ellipse corner", "", "", "", ""); canvas_kbd_proc = null_proc; canvas_locmove_proc = null_proc; canvas_leftbut_proc = init_circlebydiameter_drawing; canvas_middlebut_proc = init_ellipsebydiameter_drawing; canvas_rightbut_proc = null_proc; set_cursor(crosshair_cursor); reset_action_on(); }
void line_drawing_selected(void) { canvas_kbd_proc = (FCallBack)null_proc; canvas_locmove_proc = null_proc; canvas_leftbut_proc = (FCallBack)init_line_drawing; canvas_middlebut_proc = (FCallBack)init_line_freehand_drawing; set_cursor(crosshair_cursor); reset_action_on(); if (cur_mode == F_POLYGON) { set_mousefun("first point", "freehand", "", "", "", ""); min_num_points = 3; canvas_rightbut_proc = (FCallBack)null_proc; } else { set_mousefun("first point", "freehand", "single point", "dimension line", "", ""); min_num_points = 1; num_point = 0; fix_x = fix_y = -1; canvas_rightbut_proc = (FCallBack)create_lineobject; } }
static void set_unset_anchor(int x, int y) { if (setanchor) { set_mousefun("flip", "copy & flip", "set anchor", LOC_OBJ, LOC_OBJ, "set anchor"); draw_mousefun_canvas(); setanchor = 0; center_marker(setanchor_x,setanchor_y); /* second call to center_mark on same position deletes */ } else { set_mousefun("flip", "copy & flip", "unset anchor", LOC_OBJ, LOC_OBJ, "unset anchor"); draw_mousefun_canvas(); setanchor = 1; setanchor_x = x; setanchor_y = y; center_marker(setanchor_x,setanchor_y); } }
void convert_selected(void) { set_mousefun("spline<->line", "", "open<->closed", LOC_OBJ, LOC_OBJ, LOC_OBJ); canvas_kbd_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; init_searchproc_left(init_convert_line_spline); init_searchproc_right(init_convert_open_closed); canvas_leftbut_proc = object_search_left; canvas_middlebut_proc = null_proc; canvas_rightbut_proc = point_search_right; set_cursor(pick15_cursor); reset_action_on(); }
void delete_point_selected(void) { set_mousefun("delete point", "", "", LOC_OBJ, LOC_OBJ, LOC_OBJ); canvas_kbd_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; init_searchproc_left(init_delete_point); canvas_leftbut_proc = point_search_left; canvas_middlebut_proc = null_proc; canvas_rightbut_proc = null_proc; set_cursor(pick9_cursor); reset_action_on(); }
void align_selected(void) { set_mousefun("align compound", "align canvas", "", LOC_OBJ, "", LOC_OBJ); canvas_kbd_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; init_searchproc_left(init_align); canvas_leftbut_proc = object_search_left; canvas_middlebut_proc = init_align_canvas; canvas_rightbut_proc = null_proc; set_cursor(pick15_cursor); reset_action_on(); }
void compound_selected(void) { set_mousefun("tag object", "tag region", "compound tagged", LOC_OBJ, "", ""); canvas_kbd_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; init_searchproc_left(tag_object); canvas_leftbut_proc = object_search_left; canvas_middlebut_proc = init_tag_region; canvas_rightbut_proc = create_compoundobject; set_cursor(pick9_cursor); reset_action_on(); }
void arrow_head_selected(void) { set_mousefun("add arrow", "delete arrow", "", LOC_OBJ, LOC_OBJ, LOC_OBJ); canvas_kbd_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; init_searchproc_left(add_arrow_head); init_searchproc_middle(delete_arrow_head); canvas_leftbut_proc = point_search_left; canvas_middlebut_proc = point_search_middle; canvas_rightbut_proc = null_proc; set_cursor(pick9_cursor); reset_action_on(); }
void tangent_selected(void) { set_mousefun("add tangent", "add normal", "", LOC_OBJ, LOC_OBJ, LOC_OBJ); canvas_kbd_proc = null_proc; canvas_locmove_proc = smart_null_proc; canvas_ref_proc = smart_null_proc; init_smart_searchproc_left(init_tangent_adding); init_smart_searchproc_middle(init_normal_adding); canvas_leftbut_proc = smart_object_search_left; canvas_middlebut_proc = smart_object_search_middle; canvas_rightbut_proc = smart_null_proc; set_cursor(pick9_cursor); /* force_nopositioning(); */ reset_action_on(); }
void move_selected(void) { set_mousefun("move object", "horiz/vert move", "", LOC_OBJ, LOC_OBJ, LOC_OBJ); canvas_kbd_proc = null_proc; canvas_locmove_proc = null_proc; init_searchproc_left(init_arb_move); init_searchproc_middle(init_constrained_move); canvas_leftbut_proc = object_search_left; canvas_middlebut_proc = object_search_middle; canvas_rightbut_proc = null_proc; return_proc = move_selected; set_cursor(pick9_cursor); reset_action_on(); }
void move_point_selected(void) { set_mousefun("move point", "horiz/vert move", "", LOC_OBJ, LOC_OBJ, LOC_OBJ); canvas_kbd_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; init_searchproc_left(init_arb_move_point); init_searchproc_middle(init_stretch_move_point); canvas_leftbut_proc = point_search_left; canvas_middlebut_proc = point_search_middle; canvas_rightbut_proc = null_proc; set_cursor(pick9_cursor); force_anglegeom(); reset_action_on(); }
static void flip_selected(void) { set_mousefun("flip", "copy & flip", "set anchor", LOC_OBJ, LOC_OBJ, "set anchor"); canvas_kbd_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; init_searchproc_left(init_flip); init_searchproc_middle(init_copynflip); canvas_leftbut_proc = object_search_left; canvas_middlebut_proc = object_search_middle; canvas_rightbut_proc = set_unset_anchor; set_cursor(pick15_cursor); }
static void init_circlebydiameter_drawing(int x, int y) { cur_mode = F_CIRCLE_BY_DIA; cur_x = fix_x = x; cur_y = fix_y = y; center_marker(fix_x, fix_y); set_mousefun("final point", "", "cancel", "", "", ""); draw_mousefun_canvas(); canvas_locmove_proc = resizing_cbd; canvas_leftbut_proc = create_circlebydia; canvas_middlebut_proc = null_proc; canvas_rightbut_proc = cancel_circlebydia; set_cursor(null_cursor); elastic_cbd(); set_action_on(); }
void put_selected(void) { int i, x,y; char *com; set_mousefun("place object","new object","cancel library", "place and edit","change draw mode", "place at orig posn"); set_action_on(); cur_c = lib_compounds[cur_library_object]->compound; new_c = copy_compound(cur_c); /* add it to the depths so it is displayed */ add_compound_depth(new_c); /* find lower-right corner for draw_box() */ off_library_x = new_c->secorner.x; off_library_y = new_c->secorner.y; /* and upper-left in case the user wants to place it at its original position */ /* this is saved here because the compound was shifted to 0,0 when reading in */ orig_put_x = lib_compounds[cur_library_object]->corner.x; orig_put_y = lib_compounds[cur_library_object]->corner.y; canvas_locmove_proc = init_move_object; canvas_ref_proc = null_proc; canvas_leftbut_proc = place_lib_object; canvas_middlebut_proc = sel_place_lib_obj_proc; canvas_rightbut_proc = cancel_place_lib_obj; set_cursor(null_cursor); /* get the pointer position */ get_pointer_win_xy(&x, &y); /* draw the first image */ init_move_object(BACKX(x), BACKY(y)); /* message that we're placing object so and so */ com = strdup(lib_compounds[cur_library_object]->compound->comments); if (strlen(com)) { /* change newlines to blanks */ for (i=strlen(com); i>=0; i--) if (com[i] == '\n') com[i] = ' '; put_msg("Placing library object \"%s\" (%s.fig)", com, library_objects_texts[cur_library_object]); } else { put_msg("Placing library object %s.fig", library_objects_texts[cur_library_object]); } }
static void init_ellipsebyradius_drawing(int x, int y) { cur_mode = F_ELLIPSE_BY_RAD; cur_x = fix_x = x; cur_y = fix_y = y; cur_angle = cur_elltextangle/180.0*M_PI; center_marker(fix_x, fix_y); set_mousefun("Ellipse corner", "Ellipse corner", "cancel", "", "", ""); draw_mousefun_canvas(); canvas_locmove_proc = resizing_ebr; canvas_leftbut_proc = create_ellipsebyrad; canvas_middlebut_proc = create_ellipsebyrad; canvas_rightbut_proc = cancel_ellipsebyrad; set_cursor(null_cursor); elastic_ebr(); set_action_on(); }
void cancel_place_lib_obj(int x, int y, int shift) { /* if shift right-button, actually do a place in original position */ if (shift) { place_lib_object_orig(x, y, shift); return; } reset_action_on(); canvas_leftbut_proc = null_proc; canvas_middlebut_proc = null_proc; canvas_rightbut_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; canvas_kbd_proc = null_proc; clear_mousefun(); set_mousefun("","","", "", "", ""); turn_off_current(); set_cursor(arrow_cursor); put_draw(ERASE); /* remove it from the depths */ remove_compound_depth(new_c); }
void chop_selected(void) { set_mousefun("Select axe object", "Select log object", "Clear axe list", LOC_OBJ, LOC_OBJ, LOC_OBJ); draw_mousefun_canvas(); canvas_kbd_proc = null_proc; canvas_locmove_proc = null_proc; canvas_ref_proc = null_proc; init_searchproc_left(select_axe_object); init_searchproc_middle(select_log_object); /* init_searchproc_right(init_chop_right); */ /* fixme don't need this now */ canvas_leftbut_proc = object_search_left; /* point search for axe */ canvas_middlebut_proc = object_search_middle; /* object search for log */ canvas_rightbut_proc = clear_axe_objects; set_cursor(pick9_cursor); /* set the markers to show we only allow POLYLINES, ARCS and ELLIPSES */ /* (the markers are originally set this way from the mode panel, but we need to set them again after the previous chop */ /* fixme -- neede for chop ? */ update_markers(M_POLYLINE | M_ARC | M_ELLIPSE); reset_action_on(); axe_objects_next = 0; }