From fd65c8876d197316692f31644d930f6e453471c1 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 15 Mar 2025 23:29:11 +0100 Subject: [PATCH 1/9] cleanup and fixes in proc insert_symbol --- src/xschem.tcl | 64 +++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/xschem.tcl b/src/xschem.tcl index e82ec33c..a0bbe721 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -4835,16 +4835,9 @@ proc get_list_of_dirs_with_symbols {{paths {}} {levels -1} {ext {\.(sch|sym)$}} ##### new alternate insert_symbol browser ####################################################################### -#### Display preview of selected symbol -proc insert_symbol_focusin {{paths {}} {maxdepth -1}} { - global insert_symbol new_symbol_browser_ext - xschem abort_operation - set insert_symbol(ext) $new_symbol_browser_ext - insert_symbol_filelist $paths $maxdepth -} - -proc insert_symbol_preview {{paths {}}} { - # puts insert_symbol_preview +#### Display preview of selected symbol and start sym placement +proc insert_symbol_preview {} { + puts "insert_symbol_preview" global insert_symbol xschem preview_window close .ins.center.right {} .ins.center.right configure -bg white @@ -4855,22 +4848,25 @@ proc insert_symbol_preview {{paths {}}} { set sel [.ins.center.left.l index active] .ins.center.left.l selection set active } - if {$sel ne {}} { - set f [lindex $insert_symbol(fullpathlist) $sel 0] + if {$sel ne {} && [info exists insert_symbol(fullpathlist)]} { + set insert_symbol(fileindex) $sel + # puts "set fileindex=$sel" + .ins.center.left.l see $sel + set f [lindex $insert_symbol(fullpathlist) $sel] if {$f ne {}} { set type [is_xschem_file $f] if {$type ne {0}} { - set dir [rel_sym_path $f $paths] + set dir [rel_sym_path $f] .ins.top.dir_e configure -state normal .ins.top.dir_e delete 0 end .ins.top.dir_e insert 0 $dir .ins.top.dir_e configure -state readonly - .ins.top2.dir_e configure -state normal .ins.top2.dir_e delete 0 end .ins.top2.dir_e insert 0 $f .ins.top2.dir_e configure -state readonly + .ins.center.right configure -bg {} xschem preview_window create .ins.center.right {} xschem preview_window draw .ins.center.right [list $f] @@ -4884,19 +4880,19 @@ proc insert_symbol_preview {{paths {}}} { #### fill list of files matching pattern proc insert_symbol_filelist {paths {maxdepth -1}} { - # puts "insert_symbol_filelist: paths=$paths" - global insert_symbol - + global insert_symbol new_symbol_browser_ext set paths [.ins.center.leftdir.l curselection] - if {$paths eq {}} { return} + if {$paths eq {}} {return} + set insert_symbol(dirindex) $paths + # puts "set dirindex=$paths" set paths [lindex $insert_symbol(dirs) $paths] + puts "insert_symbol_filelist: paths=$paths" .ins.top2.dir_e configure -state normal .ins.top2.dir_e delete 0 end .ins.top2.dir_e insert 0 $paths .ins.top2.dir_e configure -state readonly - set insert_symbol(regex) [.ins.top.pat_e get] #check if regex is valid set err [catch {regexp $insert_symbol(regex) {12345}} res] if {$err} {return} @@ -4905,11 +4901,15 @@ proc insert_symbol_filelist {paths {maxdepth -1}} { set filelist {} set insert_symbol(fullpathlist) {} set sel [.ins.center.left.l curselection] + if {$sel ne {}} { + set insert_symbol(fileindex) $sel + # puts "set fileindex=$sel" + } if {$sel eq {}} { set sel 0} .ins.center.left.l activate $sel foreach i $f { - set err [catch {regexp $insert_symbol(ext) $i} type] + set err [catch {regexp $new_symbol_browser_ext $i} type] if {!$err && $type} { set fname [rel_sym_path $i $paths] lappend filelist $fname @@ -4937,7 +4937,7 @@ proc insert_symbol_filelist {paths {maxdepth -1}} { } proc insert_symbol_place {} { - # puts insert_symbol_place + puts insert_symbol_place global insert_symbol set sel [.ins.center.left.l curselection] if {$sel eq {}} { @@ -4959,14 +4959,15 @@ proc insert_symbol_place {} { #### paths: list of paths to use for listing symbols #### maxdepth: how many levels to descend for each $paths directory (-1: no limit) proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} { - global insert_symbol + global insert_symbol new_symbol_browser_ext set paths [cleanup_paths $paths] ;# remove ~ and other strange path combinations # xschem set semaphore [expr {[xschem get semaphore] +1}] - set insert_symbol(ext) $ext + set new_symbol_browser_ext $ext if {[winfo exists .ins]} { raise .ins return } + if {![info exists insert_symbol(regex)]} { set insert_symbol(regex) {}} toplevel .ins frame .ins.top -takefocus 0 frame .ins.top2 -takefocus 0 @@ -5007,28 +5008,25 @@ proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} { -readonlybackground [option get . background {}] -takefocus 0 label .ins.top.pat_l -text Pattern: entry .ins.top.pat_e -width 20 -highlightcolor red -highlightthickness 2 \ - -highlightbackground [option get . background {}] + -textvariable insert_symbol(regex) -highlightbackground [option get . background {}] label .ins.top.dir_l -text { Symbol ref: } entry .ins.top.dir_e -width 40 -state readonly \ -readonlybackground [option get . background {}] -takefocus 0 label .ins.top.ext_l -text Ext: entry .ins.top.ext_e -width 15 -takefocus 0 -state normal -textvariable new_symbol_browser_ext - if {[info exists insert_symbol(regex)]} { - .ins.top.pat_e insert 0 $insert_symbol(regex) - } bind .ins {.ins.bottom.dismiss invoke} bind .ins " if {{%K} eq {Tab} && {%W} eq {.ins.center.left.l}} { insert_symbol_filelist [list $paths] [list $maxdepth] - insert_symbol_preview [list $paths] + insert_symbol_preview } elseif {{%K} eq {Tab} && {%W} eq {.ins.center.leftdir.l}} { insert_symbol_filelist [list $paths] [list $maxdepth] } " bind .ins.center.leftdir.l <> "insert_symbol_filelist [list $paths] [list $maxdepth]" - bind .ins.center.left.l <> "insert_symbol_preview [list $paths]" - bind .ins.center.left.l "insert_symbol_focusin [list $paths] [list $maxdepth]" + bind .ins.center.left.l <> "insert_symbol_preview" + bind .ins.center.left.l "xschem abort_operation" label .ins.bottom.n -text { N. of items:} label .ins.bottom.nitems -textvariable insert_symbol(nitems) button .ins.bottom.dismiss -takefocus 0 -text Dismiss -command { @@ -5051,7 +5049,7 @@ proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} { pack .ins.top.ext_l -side left pack .ins.top.ext_e -side left - set insert_symbol(dirs) [get_list_of_dirs_with_symbols $paths $maxdepth $insert_symbol(ext)] + set insert_symbol(dirs) [get_list_of_dirs_with_symbols $paths $maxdepth $new_symbol_browser_ext] set insert_symbol(dirtails) {} foreach i $insert_symbol(dirs) { lappend insert_symbol(dirtails) [file tail $i] @@ -5072,9 +5070,11 @@ proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} { lappend insert_symbol(dirs) $fff } - insert_symbol_filelist $paths $maxdepth + # insert_symbol_filelist $paths $maxdepth # tkwait window .ins # xschem set semaphore [expr {[xschem get semaphore] -1}] + if {[info exists insert_symbol(dirindex)]} {.ins.center.leftdir.l selection set $insert_symbol(dirindex)} + if {[info exists insert_symbol(fileindex)]} {.ins.center.left.l selection set $insert_symbol(fileindex)} return {} } ####################################################################### From d37c872a496d5131fd04c571e6124e227aa5c2f2 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 15 Mar 2025 23:47:18 +0100 Subject: [PATCH 2/9] merge in a SuperChayan change in move.c --- src/move.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/move.c b/src/move.c index 45fd82ca..89194b78 100644 --- a/src/move.c +++ b/src/move.c @@ -1136,13 +1136,11 @@ void move_objects(int what, int merge, double dx, double dy) else if(wire[n].sel == SELECTED2) wire[n].sel = SELECTED1; } - #if 0 - if(wire[n].sel & (SELECTED|SELECTED1)) + if((wire[n].sel & (SELECTED|SELECTED1)) && tclgetboolvar("orthogonal_wiring")) { if(xctx->manhattan_lines & 1) xctx->manhattan_lines=2; else if(xctx->manhattan_lines & 2) xctx->manhattan_lines=1; } - #endif wire[n].x1 = xctx->rx1; wire[n].y1 = xctx->ry1; if(xctx->manhattan_lines&1) From ed8a6dbe110d7b18ea3f4c66fccf2486966da3a9 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 16 Mar 2025 00:02:12 +0100 Subject: [PATCH 3/9] little optimization in insert_symbol --- src/xschem.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xschem.tcl b/src/xschem.tcl index a0bbe721..1b05c3b5 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -4911,7 +4911,7 @@ proc insert_symbol_filelist {paths {maxdepth -1}} { set err [catch {regexp $new_symbol_browser_ext $i} type] if {!$err && $type} { - set fname [rel_sym_path $i $paths] + set fname [file tail $i] lappend filelist $fname lappend insert_symbol(fullpathlist) $i } From cc90201b27a388cbae8974bfeeea609877b614e1 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 16 Mar 2025 00:13:07 +0100 Subject: [PATCH 4/9] remove debug msgs in insert_symbol --- src/xschem.tcl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xschem.tcl b/src/xschem.tcl index 1b05c3b5..f63ad815 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -4837,7 +4837,7 @@ proc get_list_of_dirs_with_symbols {{paths {}} {levels -1} {ext {\.(sch|sym)$}} #### Display preview of selected symbol and start sym placement proc insert_symbol_preview {} { - puts "insert_symbol_preview" + # puts "insert_symbol_preview" global insert_symbol xschem preview_window close .ins.center.right {} .ins.center.right configure -bg white @@ -4886,7 +4886,7 @@ proc insert_symbol_filelist {paths {maxdepth -1}} { set insert_symbol(dirindex) $paths # puts "set dirindex=$paths" set paths [lindex $insert_symbol(dirs) $paths] - puts "insert_symbol_filelist: paths=$paths" + # puts "insert_symbol_filelist: paths=$paths" .ins.top2.dir_e configure -state normal .ins.top2.dir_e delete 0 end @@ -4937,7 +4937,7 @@ proc insert_symbol_filelist {paths {maxdepth -1}} { } proc insert_symbol_place {} { - puts insert_symbol_place + # puts insert_symbol_place global insert_symbol set sel [.ins.center.left.l curselection] if {$sel eq {}} { From 124d73ee6485170375e5150a3460de3ec49f73c3 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 16 Mar 2025 00:31:57 +0100 Subject: [PATCH 5/9] fix regression (start new wires in manhattan orient) --- src/callback.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/callback.c b/src/callback.c index f9d6e8a6..8ca8829a 100644 --- a/src/callback.c +++ b/src/callback.c @@ -253,6 +253,7 @@ 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; } From c02b80c79d5005dd0be5f8edf21f9ff9e907d55a Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 16 Mar 2025 00:49:38 +0100 Subject: [PATCH 6/9] fixes in insert_symbol --- src/xschem.tcl | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/xschem.tcl b/src/xschem.tcl index f63ad815..7cde38d4 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -4881,22 +4881,23 @@ proc insert_symbol_preview {} { #### fill list of files matching pattern proc insert_symbol_filelist {paths {maxdepth -1}} { global insert_symbol new_symbol_browser_ext - set paths [.ins.center.leftdir.l curselection] - if {$paths eq {}} {return} - set insert_symbol(dirindex) $paths + set sel [.ins.center.leftdir.l curselection] + if {![info exists insert_symbol(dirs)]} {return} + if {$sel eq {}} { + set sel [.ins.center.leftdir.l index active] + .ins.center.leftdir.l selection set active + } + set insert_symbol(dirindex) $sel # puts "set dirindex=$paths" - set paths [lindex $insert_symbol(dirs) $paths] + set paths [lindex $insert_symbol(dirs) $sel] # puts "insert_symbol_filelist: paths=$paths" - .ins.top2.dir_e configure -state normal .ins.top2.dir_e delete 0 end .ins.top2.dir_e insert 0 $paths .ins.top2.dir_e configure -state readonly - #check if regex is valid set err [catch {regexp $insert_symbol(regex) {12345}} res] if {$err} {return} - set f [match_file $insert_symbol(regex) $paths 0] set filelist {} set insert_symbol(fullpathlist) {} @@ -4908,7 +4909,6 @@ proc insert_symbol_filelist {paths {maxdepth -1}} { if {$sel eq {}} { set sel 0} .ins.center.left.l activate $sel foreach i $f { - set err [catch {regexp $new_symbol_browser_ext $i} type] if {!$err && $type} { set fname [file tail $i] @@ -4924,13 +4924,11 @@ proc insert_symbol_filelist {paths {maxdepth -1}} { set files [lsort -dictionary -index 0 $files] set filelist {} set insert_symbol(fullpathlist) {} - foreach f $files { lassign $f ff fff lappend filelist $ff lappend insert_symbol(fullpathlist) $fff } - set insert_symbol(nitems) [llength $filelist] # assign listbox variable all at the end, it is faster... set insert_symbol(list) $filelist From e4cf17986841b205a7c8814981660da486aa36eb Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 16 Mar 2025 01:01:49 +0100 Subject: [PATCH 7/9] insert_symbol: Return Key binding for quick dialog close --- src/xschem.tcl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xschem.tcl b/src/xschem.tcl index 7cde38d4..7078079c 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -5024,6 +5024,10 @@ proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} { " bind .ins.center.leftdir.l <> "insert_symbol_filelist [list $paths] [list $maxdepth]" bind .ins.center.left.l <> "insert_symbol_preview" + bind .ins.center.left.l " + xschem preview_window close .ins.center.right {} + destroy .ins + " bind .ins.center.left.l "xschem abort_operation" label .ins.bottom.n -text { N. of items:} label .ins.bottom.nitems -textvariable insert_symbol(nitems) From 2f26544c45e301652f6cc632ef6638f6f09bd9c5 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 16 Mar 2025 01:17:50 +0100 Subject: [PATCH 8/9] dont assume a particular manhattan_lines when starting wires or lines. Keep last one set --- src/callback.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/callback.c b/src/callback.c index 8ca8829a..2793a427 100644 --- a/src/callback.c +++ b/src/callback.c @@ -166,7 +166,7 @@ void abort_operation(void) return; } xctx->last_command=0; - xctx->manhattan_lines = 0; + /* xctx->manhattan_lines = 0; */ if(xctx->ui_state & STARTMOVE) { move_objects(ABORT,0,0,0); @@ -226,7 +226,7 @@ void start_line(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 = 0; + /* xctx->manhattan_lines = 0; */ xctx->mx_double_save=mx; xctx->my_double_save=my; } @@ -253,7 +253,7 @@ 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->manhattan_lines = 1; */ xctx->mx_double_save=mx; xctx->my_double_save=my; } @@ -1673,7 +1673,7 @@ static void snapped_wire(double c_snap) find_closest_net_or_symbol_pin(xctx->mousex, xctx->mousey, &x, &y); xctx->mx_double_save = my_round(x / c_snap) * c_snap; xctx->my_double_save = my_round(y / c_snap) * c_snap; - xctx->manhattan_lines = 1; + /* xctx->manhattan_lines = 1; */ new_wire(PLACE, x, y); new_wire(RUBBER, xctx->mousex_snap,xctx->mousey_snap); } From a0a5d9876fe23d1da540875b662b778a81d3f227 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 16 Mar 2025 05:15:40 +0100 Subject: [PATCH 9/9] drawtemp_manhattanline(): use local nl_xx[12] and nl_yy[12] variables, since xctx->nl_xx[12] and xctx->nl_yy[12] are used also in select_rect() which calls draw_selection() which calls drawtemp_manhattanline(). --- src/draw.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/draw.c b/src/draw.c index c6bbeabe..7807fd45 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1377,6 +1377,7 @@ void drawtempline(GC gc, int what, double linex1,double liney1,double linex2,dou void drawtemp_manhattanline(GC gc, int what, double x1, double y1, double x2, double y2) { + double nl_xx1, nl_yy1, nl_xx2, nl_yy2; double origin_shifted_x2, origin_shifted_y2; if(tclgetboolvar("orthogonal_wiring")) { /* Origin shift the cartesian coordinate p2(x2,y2) w.r.t. p1(x1,y1) */ @@ -1389,28 +1390,28 @@ void drawtemp_manhattanline(GC gc, int what, double x1, double y1, double x2, do xctx->manhattan_lines = 2; } if(xctx->manhattan_lines & 1) { - xctx->nl_xx1 = x1; xctx->nl_yy1 = y1; - xctx->nl_xx2 = x2; xctx->nl_yy2 = y2; - ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); - drawtempline(gc, what, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); - xctx->nl_xx1 = x1; xctx->nl_yy1 = y1; - xctx->nl_xx2 = x2; xctx->nl_yy2 = y2; - ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc, what, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + nl_xx1 = x1; nl_yy1 = y1; + nl_xx2 = x2; nl_yy2 = y2; + ORDER(nl_xx1,nl_yy1,nl_xx2,nl_yy1); + drawtempline(gc, what, nl_xx1,nl_yy1,nl_xx2,nl_yy1); + nl_xx1 = x1; nl_yy1 = y1; + nl_xx2 = x2; nl_yy2 = y2; + ORDER(nl_xx2,nl_yy1,nl_xx2,nl_yy2); + drawtempline(gc, what, nl_xx2,nl_yy1,nl_xx2,nl_yy2); } else if(xctx->manhattan_lines & 2) { - xctx->nl_xx1 = x1; xctx->nl_yy1 = y1; - xctx->nl_xx2 = x2; xctx->nl_yy2 = y2; - ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); - drawtempline(gc, what, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); - xctx->nl_xx1 = x1; xctx->nl_yy1 = y1; - xctx->nl_xx2 = x2; xctx->nl_yy2 = y2; - ORDER(xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc, what, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); + nl_xx1 = x1; nl_yy1 = y1; + nl_xx2 = x2; nl_yy2 = y2; + ORDER(nl_xx1,nl_yy1,nl_xx1,nl_yy2); + drawtempline(gc, what, nl_xx1,nl_yy1,nl_xx1,nl_yy2); + nl_xx1 = x1; nl_yy1 = y1; + nl_xx2 = x2; nl_yy2 = y2; + ORDER(nl_xx1,nl_yy2,nl_xx2,nl_yy2); + drawtempline(gc, what, nl_xx1,nl_yy2,nl_xx2,nl_yy2); } else { - xctx->nl_xx1 = x1; xctx->nl_yy1 = y1; - xctx->nl_xx2 = x2; xctx->nl_yy2 = y2; - ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc, what, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + nl_xx1 = x1; nl_yy1 = y1; + nl_xx2 = x2; nl_yy2 = y2; + ORDER(nl_xx1,nl_yy1,nl_xx2,nl_yy2); + drawtempline(gc, what, nl_xx1,nl_yy1,nl_xx2,nl_yy2); } }