diff --git a/src/callback.c b/src/callback.c index f05ccbb1..504a19eb 100644 --- a/src/callback.c +++ b/src/callback.c @@ -107,6 +107,7 @@ void redraw_w_a_l_r_p_z_rubbers(int force) { double mx = xctx->mousex_snap; double my = xctx->mousey_snap; + double origin_shifted_x2, origin_shifted_y2; if(!force && xctx->mousex_snap == xctx->prev_rubberx && xctx->mousey_snap == xctx->prev_rubbery) return; @@ -115,17 +116,17 @@ void redraw_w_a_l_r_p_z_rubbers(int force) if(xctx->constr_mv == 1) my = xctx->my_double_save; if(xctx->constr_mv == 2) mx = xctx->mx_double_save; if(tclgetboolvar("orthogonal_wiring")) { - /* Origin shift the cartesian coordinate p2(x2,y2) w.r.t. p1(x1,y1) */ - double origin_shifted_x2 = xctx->nl_x2 - xctx->nl_x1, origin_shifted_y2 = xctx->nl_y2 - xctx->nl_y1; new_wire(RUBBER|CLEAR, xctx->mousex_snap, xctx->mousey_snap); - /* Draw whichever component of the resulting orthogonal-wire is bigger - * (either horizontal or vertical), first */ + /* Origin shift the cartesian coordinate p2(x2,y2) w.r.t. p1(x1,y1) */ + origin_shifted_x2 = xctx->nl_x2 - xctx->nl_x1; + origin_shifted_y2 = xctx->nl_y2 - xctx->nl_y1; + /* Draw whichever component of the resulting orthogonal-wire is bigger (either horizontal or vertical), first */ if(origin_shifted_x2*origin_shifted_x2 > origin_shifted_y2*origin_shifted_y2){ - xctx->manhattan_lines = 1; + xctx->manhattan_lines = 1; } else { - xctx->manhattan_lines = 2; + xctx->manhattan_lines = 2; } - } + } new_wire(RUBBER, mx, my); } if(xctx->ui_state & STARTARC) { @@ -242,7 +243,7 @@ static void start_wire(double mx, double my) xctx->constr_mv = xctx->manhattan_lines; new_wire(CLEAR, mx, my); redraw_w_a_l_r_p_z_rubbers(1); - } + } if(xctx->constr_mv != 2) { xctx->mx_double_save = mx; } @@ -252,13 +253,12 @@ static void start_wire(double mx, double my) if(xctx->constr_mv == 1) my = xctx->my_double_save; if(xctx->constr_mv == 2) mx = xctx->mx_double_save; } else { - xctx->manhattan_lines = 1; xctx->mx_double_save=mx; xctx->my_double_save=my; } new_wire(PLACE,mx, my); - if(tclgetboolvar("orthogonal_wiring") && !tclgetboolvar("constr_mv")) { - xctx->constr_mv = 0; + if(tclgetboolvar("orthogonal_wiring") && !tclgetboolvar("constr_mv")){ + xctx->constr_mv = 0; } } @@ -2472,11 +2472,12 @@ static void handle_enter_notify(int draw_xhair, int crosshair_size) xctx->mousey_snap = -340; merge_file(1, ".sch"); } + return; } -static void handle_motion_notify(int event, KeySym key, int state, int rstate, int button, - int mx, int my, int aux, int draw_xhair, int enable_stretch, int snap_cursor, int wire_draw_active) +static void handle_motion_notify(int event, KeySym key, int state, int rstate, int button, + int mx, int my, int aux, int draw_xhair, int enable_stretch, int snap_cursor, int wire_draw_active) { char str[PATH_MAX + 100]; if( waves_selected(event, key, state, button)) { @@ -2596,15 +2597,15 @@ static void handle_motion_notify(int event, KeySym key, int state, int rstate, i draw_crosshair(2, state); /* what = 2(draw) */ } if(snap_cursor && ((state == ShiftMask) || wire_draw_active)) draw_snap_cursor(2); /* redraw */ + + return; } -static void handle_key_press(int event, KeySym key, int state, int rstate, int mx, int my, - int button, int aux, int infix_interface, int enable_stretch, - int wire_draw_active, const char *win_path, double c_snap) +static void handle_key_press(int event, KeySym key, int state, int rstate, int mx, int my, + int button, int aux, int infix_interface, int enable_stretch, const char *win_path, double c_snap, + int cadence_compat, int wire_draw_active, int snap_cursor) { char str[PATH_MAX + 100]; - int cadence_compat = tclgetboolvar("cadence_compat"); - int snap_cursor = tclgetboolvar("snap_cursor"); if(key==' ') { if(xctx->ui_state & STARTWIRE) { /* & instead of == 20190409 */ new_wire(RUBBER|CLEAR, xctx->mousex_snap, xctx->mousey_snap); @@ -2843,12 +2844,7 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m /* create wire snapping to closest instance pin */ if(key== 'W' /* && !xctx->ui_state */ && rstate == 0 && !cadence_compat) { if(xctx->semaphore >= 2) return; - if(infix_interface) { - snapped_wire(c_snap); - } else { - xctx->ui_state |= MENUSTART; - xctx->ui_state2 = MENUSTARTSNAPWIRE; - } + snapped_wire(c_snap); return; } /* create wire snapping to closest instance pin (cadence keybind) */ @@ -2872,6 +2868,7 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m xctx->last_command = 0; xctx->ui_state |= MENUSTART; xctx->ui_state2 = MENUSTARTWIRE; + if(prev_state & STARTWIRE) start_wire(xctx->mousex_snap, xctx->mousey_snap); } return; } @@ -2905,6 +2902,19 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m { view_zoom(0.0); return; } + if(key=='z' && EQUAL_MODMASK && cadence_compat) /* toggle snap-cursor option */ + { + if(tclgetboolvar("snap_cursor")) { + tclsetvar("snap_cursor", "0"); + draw_snap_cursor(1); + xctx->closest_pin_found = 0; + xctx->prev_snapx = 0.0; + xctx->prev_snapy = 0.0; + } else { + tclsetvar("snap_cursor", "1"); + if(wire_draw_active) draw_snap_cursor(3); + } + } if(key=='p' && EQUAL_MODMASK) /* add symbol pin */ { xctx->push_undo(); @@ -3097,12 +3107,7 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m draw(); /* needed to ungrey or grey out components due to *_ignore attribute */ return; } - if(key== 's' /* && !xctx->ui_state */ && rstate == 0 && cadence_compat) { /* create wire snapping to closest instance pin (cadence keybind) */ - if(xctx->semaphore >= 2) return; - snapped_wire(c_snap); - return; - } - if((key=='s' && rstate == 0) && !cadence_compat) /* simulate, original binding for s */ + if((key=='s' && rstate == 0) && !cadence_compat) /* simulate (original keybind) */ { if(xctx->semaphore >= 2) return; if(waves_selected(event, key, state, button)) { @@ -3634,6 +3639,16 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m place_net_label(0); return; } + if(key=='L' && rstate == 0) { /* toggle orthogonal routing */ + if(tclgetboolvar("orthogonal_wiring")){ + tclsetboolvar("orthogonal_wiring", 0); + xctx->manhattan_lines = 0; + } else { + tclsetboolvar("orthogonal_wiring", 1); + } + redraw_w_a_l_r_p_z_rubbers(1); + return; + } if(key=='F' && rstate == 0) /* flip */ { if(xctx->ui_state & STARTMOVE) move_objects(FLIP,0,0,0); @@ -4084,14 +4099,16 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m break_wires_at_pins(1); return; } + + return; } static void handle_button_press(int event, int state, int rstate, KeySym key, int button, int mx, int my, - double c_snap, int draw_xhair, int crosshair_size, int enable_stretch, int aux ) + double c_snap, int draw_xhair, int crosshair_size, int enable_stretch, int aux) { + dbg(1, "callback(): ButtonPress ui_state=%d state=%d\n",xctx->ui_state,state); int use_cursor_for_sel = tclgetintvar("use_cursor_for_selection"); int excl = xctx->ui_state & (STARTWIRE | STARTRECT | STARTLINE | STARTPOLYGON | STARTARC); - dbg(1, "callback(): ButtonPress ui_state=%d state=%d\n",xctx->ui_state,state); if(waves_selected(event, key, state, button)) { waves_callback(event, mx, my, key, button, aux, state); return; @@ -4332,10 +4349,12 @@ static void handle_button_press(int event, int state, int rstate, KeySym key, in return; } /* if(!excl) */ } /* button==Button1 */ + + return; } -static void handle_button_release(int event, KeySym key, int state, int button, int mx, int my, - int aux, double c_snap, int enable_stretch, int draw_xhair, int snap_cursor, int wire_draw_active) +static void handle_button_release(int event, KeySym key, int state, int button, int mx, int my, + int aux, double c_snap, int enable_stretch, int draw_xhair, int snap_cursor, int wire_draw_active) { char str[PATH_MAX + 100]; if(waves_selected(event, key, state, button)) { @@ -4425,7 +4444,7 @@ static void handle_button_release(int event, KeySym key, int state, int button, xctx->mousex_snap, xctx->mousey_snap, xctx->lastsel, xctx->sch_path[xctx->currsch] ); statusmsg(str,1); } - + /* clear start from menu flag or infix_interface=0 start commands */ if( state == Button1Mask && xctx->ui_state & MENUSTART) { xctx->ui_state &= ~MENUSTART; @@ -4433,10 +4452,11 @@ static void handle_button_release(int event, KeySym key, int state, int button, } if(draw_xhair) draw_crosshair(3, state); /* restore crosshair when selecting / unselecting */ if(snap_cursor && ((state == ShiftMask) || wire_draw_active)) draw_snap_cursor(3); /* erase & redraw */ + return; } static void handle_double_click(int event, int state, KeySym key, int button, - int mx, int my, int aux, int cadence_compat ) + int mx, int my, int aux, int cadence_compat) { if( waves_selected(event, key, state, button)) { waves_callback(event, mx, my, key, button, aux, state); @@ -4459,10 +4479,8 @@ static void handle_double_click(int event, int state, KeySym key, int button, edit_property(0); } else { if(xctx->ui_state & STARTWIRE) { - if( cadence_compat ) { - redraw_w_a_l_r_p_z_rubbers(1); - start_wire(mx, my); - } + redraw_w_a_l_r_p_z_rubbers(1); + start_wire(mx, my); xctx->ui_state &= ~STARTWIRE; } if(xctx->ui_state & STARTLINE) { @@ -4658,7 +4676,8 @@ int wire_draw_active = (xctx->ui_state & STARTWIRE) || case MotionNotify: handle_motion_notify(event, key, state, rstate, button, mx, my, - aux, draw_xhair, enable_stretch, snap_cursor, wire_draw_active); + aux, draw_xhair, enable_stretch, + snap_cursor, wire_draw_active); break; case KeyRelease: @@ -4667,22 +4686,24 @@ int wire_draw_active = (xctx->ui_state & STARTWIRE) || break; case KeyPress: - handle_key_press(event, key, state, rstate, mx, my, button, aux, - infix_interface, enable_stretch, wire_draw_active, win_path, c_snap); - break; + handle_key_press(event, key, state, rstate, mx, my, button, aux, + infix_interface, enable_stretch, win_path, c_snap, + cadence_compat, wire_draw_active, snap_cursor); + break; case ButtonPress: handle_button_press(event, state, rstate, key, button, mx, my, - c_snap, draw_xhair, crosshair_size, enable_stretch, aux); + c_snap, draw_xhair, crosshair_size, enable_stretch, aux); break; case ButtonRelease: - handle_button_release(event, key, state, button, mx, my, aux, c_snap, enable_stretch, draw_xhair, snap_cursor, wire_draw_active); + handle_button_release(event, key, state, button, mx, my, aux, c_snap, enable_stretch, + draw_xhair, snap_cursor, wire_draw_active); break; - + case -3: /* double click : edit prop */ - handle_double_click(event, state, key, button, mx, my, aux, cadence_compat); - break; + handle_double_click(event, state, key, button, mx, my, aux, cadence_compat); + break; default: dbg(1, "callback(): Event:%d\n",event); @@ -4700,6 +4721,6 @@ int wire_draw_active = (xctx->ui_state & STARTWIRE) || if(old_win_path[0]) dbg(1, "callback(): reset old_win_path: %s <- %s\n", old_win_path, win_path); my_strncpy(old_win_path, win_path, S(old_win_path)); } - return 0; + return 0; } diff --git a/src/xschem.tcl b/src/xschem.tcl index 1b0cfef2..5c6a95c6 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -8305,9 +8305,9 @@ proc build_widgets { {topwin {} } } { global dark_gui_colorscheme draw_crosshair grid_point_size global recentfile color_ps transparent_svg menu_debug_var enable_stretch global netlist_show flat_netlist split_files compare_sch intuitive_interface - global draw_grid big_grid_points sym_txt change_lw incr_hilight symbol_width - global cadsnap cadgrid draw_window toolbar_visible hide_symbols undo_type - global disable_unique_names persistent_command autotrim_wires en_hilight_conn_inst + global draw_grid big_grid_points sym_txt change_lw incr_hilight symbol_width cadence_compat + global cadsnap cadgrid draw_window toolbar_visible hide_symbols undo_type snap_cursor + global disable_unique_names persistent_command autotrim_wires infix_interface orthogonal_wiring en_hilight_conn_inst global local_netlist_dir editor netlist_type netlist_dir spiceprefix initial_geometry if { $dark_gui_colorscheme} { set selectcolor white @@ -8430,6 +8430,10 @@ proc build_widgets { {topwin {} } } { -onvalue disk -offvalue memory -command {switch_undo} $topwin.menubar.option add checkbutton -label "Enable stretch" -variable enable_stretch \ -selectcolor $selectcolor -accelerator Y + $topwin.menubar.option add checkbutton -label "Enable infix-interface" -variable infix_interface \ + -selectcolor $selectcolor + $topwin.menubar.option add checkbutton -label "Enable orthogonal wiring" -variable orthogonal_wiring \ + -selectcolor $selectcolor -accelerator Shift-L $topwin.menubar.option add checkbutton -label "Unsel. partial sel. wires after stretch move" \ -selectcolor $selectcolor -variable unselect_partial_sel_wires @@ -8446,6 +8450,10 @@ proc build_widgets { {topwin {} } } { -variable intuitive_interface -selectcolor $selectcolor \ -command {xschem set intuitive_interface $intuitive_interface} + $topwin.menubar.option add checkbutton -label "Draw crosshair" \ + -variable draw_crosshair -selectcolor $selectcolor -accelerator {Alt-X} + $topwin.menubar.option add checkbutton -label "Draw persistent snap cursor" -variable snap_cursor \ + -selectcolor $selectcolor -accelerator {Alt-Z} $topwin.menubar.option add cascade -label "Crosshair" \ -menu $topwin.menubar.option.crosshair @@ -9358,6 +9366,7 @@ set_ne ps_page_title 1 ;# add a title in the top left page corner set_ne draw_crosshair 0 set_ne crosshair_layer 8 ;# Yellow set_ne crosshair_size 0 +set_ne snap_cursor_size 6 set_ne ps_paper_size {a4 842 595} set_ne transparent_svg 0 set_ne only_probes 0 ; # 20110112 @@ -9389,13 +9398,12 @@ set_ne grid_point_size -1 ;# grid point size (>=0) or unspecified (-1) set_ne draw_grid_axes 1 set_ne persistent_command 0 set_ne intuitive_interface 1 -set_ne infix_interface 1 -set_ne orthogonal_wiring 0 -set_ne snap_cursor 0 -set_ne snap_cursor_size 6 -set_ne cadence_compat 0 set_ne use_cursor_for_selection 0 set_ne autotrim_wires 0 +set_ne cadence_compat 0 +set_ne infix_interface 1 +set_ne snap_cursor 0 +set_ne orthogonal_wiring 0 set_ne compare_sch 0 set_ne disable_unique_names 0 set_ne sym_txt 1 diff --git a/src/xschemrc b/src/xschemrc index 64304589..fae161fe 100644 --- a/src/xschemrc +++ b/src/xschemrc @@ -226,6 +226,12 @@ #### if not set show selected items at end of drag. Default: enabled (1) # set incremental_select 0 +#### wires are drawn in free-form mode with this mode disabled (default). +#### if set to 1, wires drawn on the schematic will strictly follow +#### orthogonal routes to connect two distinct points together. +#### default: 0 +# set orthogonal_wiring 1 + #### if set to 1 automatically join/trim wires while editing #### this may slow down on rally big designs. Can be disabled via menu #### default: 0 @@ -271,7 +277,7 @@ # set crosshair_layer 8 #### set crosshair size; Default: 0 (full screen spanning crosshair) -# set crosshair_size 5 +# set crosshair_size 2 #### enable drawing a diamond-shaped cursor at the closest circuit endpoint. Default: disabled (0) # set snap_cursor 1