From c3d03cd6d275e0b40cd7122c495b748cfaff1b45 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Wed, 14 Jun 2023 10:08:50 +0200 Subject: [PATCH] show red dot when cuting a wire with new alt-right button click on a wire. Added also menu command in Tools --- doc/xschem_man/developer_info.html | 7 +++++++ src/callback.c | 5 +++++ src/check.c | 12 ++++++++++-- src/scheduler.c | 9 +++++++++ src/xschem.h | 3 ++- src/xschem.tcl | 2 ++ 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index c936661c..417cfb0a 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -493,6 +493,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" + +
  • abort_operation
  •     Resets UI state, unselect all and abort any pending operation 
  • add_symbol_pin
  • @@ -1195,6 +1197,9 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
        
  • wire [x1 y1 x2 y2] [pos] [prop] [sel]
  •     Place a new wire
        if no coordinates are given start a GUI wire placement 
    +
  • wire_cut
  • +   start a wire cut operation. Point the mouse in the middle of a wire and
    +   click left button. 
  • xcb_info
  •     For debug 
  • zoom_box [x1 y1 x2 y2] [factor]
  • @@ -1227,6 +1232,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
     
     
     
    +
    +
      
     
       
    diff --git a/src/callback.c b/src/callback.c
    index eb29ae89..79bbab95 100644
    --- a/src/callback.c
    +++ b/src/callback.c
    @@ -2638,6 +2638,11 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
            if(xctx->last_command == STARTWIRE)  start_wire(mx, my);
            break;
          }
    +     if(xctx->ui_state & MENUSTARTWIRECUT) {
    +       break_wires_at_point(xctx->mousex_snap, xctx->mousey_snap);
    +       xctx->ui_state &=~MENUSTARTWIRECUT;
    +       break;
    +     }
          if(xctx->ui_state & MENUSTARTMOVE) {
            xctx->mx_double_save=xctx->mousex_snap;
            xctx->my_double_save=xctx->mousey_snap;
    diff --git a/src/check.c b/src/check.c
    index b1129974..443632cb 100644
    --- a/src/check.c
    +++ b/src/check.c
    @@ -421,7 +421,7 @@ void break_wires_at_point(double x0, double y0)
             xctx->wire[xctx->wires].end2 = 1;
             xctx->wire[xctx->wires].x2=x0;
             xctx->wire[xctx->wires].y2=y0;
    -        xctx->wire[xctx->wires].sel=SELECTED;
    +        xctx->wire[xctx->wires].sel=0;
             xctx->wire[xctx->wires].prop_ptr=NULL;
             my_strdup(_ALLOC_ID_, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[i].prop_ptr);
             if(!strcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true"))
    @@ -438,15 +438,23 @@ void break_wires_at_point(double x0, double y0)
             xctx->wires++;
             xctx->wire[i].x1 = x0;
             xctx->wire[i].y1 = y0;
    -        xctx->wire[i].sel = SELECTED;
    +        xctx->wire[i].sel = 0;
             xctx->wire[i].end1 = 1;
           } /* if( (x0!=xctx->wire[i].x1 && x0!=xctx->wire[i].x2) || ... ) */
         } /* if( touch(xctx->wire[i].x1, xctx->wire[i].y1, xctx->wire[i].x2, xctx->wire[i].y2, x0,y0) ) */
       } /* for(wptr=xctx->wire_spatial_table[sqx][sqy]; wptr; wptr=wptr->next) */
       if(changed) {
    +    int w = xctx->draw_window;
    +    int p = xctx->draw_pixmap;
         xctx->need_reb_sel_arr = 1;
         rebuild_selected_array();
         draw();
    +    xctx->draw_window = 1;
    +    xctx->draw_pixmap = 0;
    +    filledarc(PINLAYER, NOW, x0, y0, cadhalfdotsize, 0, 360);
    +    xctx->draw_window = w;
    +    xctx->draw_pixmap = p;
    +
       }
     }
     
    diff --git a/src/scheduler.c b/src/scheduler.c
    index ece7095f..fb7e553f 100644
    --- a/src/scheduler.c
    +++ b/src/scheduler.c
    @@ -4045,6 +4045,15 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
           }
           else xctx->ui_state |= MENUSTARTWIRE;
         }
    +    /* wire_cut
    +     *   start a wire cut operation. Point the mouse in the middle of a wire and
    +     *   click left button. */
    +    else if(!strcmp(argv[1], "wire_cut"))
    +    {
    +      xctx->ui_state |= MENUSTARTWIRECUT;
    +      Tcl_ResetResult(interp);
    +    }
    +
         else { cmd_found = 0;}
         break;
         case 'x': /*----------------------------------------------*/
    diff --git a/src/xschem.h b/src/xschem.h
    index 42358ff5..bef7e811 100644
    --- a/src/xschem.h
    +++ b/src/xschem.h
    @@ -227,8 +227,9 @@ extern char win_temp_dir[PATH_MAX];
     #define MENUSTARTCIRCLE 2097152U
     #define PLACE_SYMBOL 4194304U /* used in move_objects after place_symbol to avoid storing intermediate undo state */
     #define START_SYMPIN 8388608U
    -#define GRAPHPAN 16777216U
    +#define GRAPHPAN 16777216U /* bit 24 */
     #define MENUSTARTMOVE 33554432U
    +#define MENUSTARTWIRECUT 67108864U /* bit 26 */
     #define SELECTED 1U         /*  used in the .sel field for selected objs. */
     #define SELECTED1 2U        /*  first point selected... */
     #define SELECTED2 4U        /*  second point selected... */
    diff --git a/src/xschem.tcl b/src/xschem.tcl
    index 94c9b276..573bf035 100644
    --- a/src/xschem.tcl
    +++ b/src/xschem.tcl
    @@ -6105,6 +6105,8 @@ proc build_widgets { {topwin {} } } {
          -command "xschem break_wires" -accelerator {!}
       $topwin.menubar.tools.menu add command -label "Remove wires running through selected inst. pins" \
          -command "xschem break_wires 1" -accelerator {Ctrl-!}
    +  $topwin.menubar.tools.menu add command -label "Break wires at mouse position" \
    +     -command "xschem wire_cut" -accelerator {Alt-Right Butt.}
        toolbar_add ToolBreak "xschem break_wires" "Break wires at selected\ninstance pin intersections" $topwin
       $topwin.menubar.tools.menu add checkbutton -label "Auto Join/Trim Wires" -variable autotrim_wires \
          -command {