Show a busy window while the solve runs

On OK the dialog closed and nothing appeared until the figures did,
which on a real board is minutes of looking like the plugin did
nothing. Put a small always-on-top window up for that stretch: the
stage now running, elapsed seconds, and Cancel.

Qt only repaints while the event loop runs and the solve owns the
thread, so the window pumps events itself - from inside the CG/AMG
iteration callback, which is where the time actually goes. That is
also where Cancel is noticed. The state is module-level because the
tick happens several frames deep in scipy/pyamg, and threading a
handle through those signatures for a progress bar is not worth it;
it stays inert until start(), so the standalone runner and the tests
are unaffected.

The window covers the figure work too, not just the solve: laying out
labels and writing four PNGs at full DPI is seconds on a real board -
10-15 of them on a large one - and closing before that left the same
silent gap one step later.
This commit is contained in:
2026-07-22 16:54:29 +07:00
parent d7c3089031
commit 979b69960f
7 changed files with 191 additions and 14 deletions
+11 -1
View File
@@ -13,7 +13,7 @@ import argparse
import sys
from pathlib import Path
from . import config, pipeline
from . import config, pipeline, progress
from .errors import UserFacingError
from .geometry import load_problem
from .skin import parse_frequency
@@ -51,6 +51,9 @@ def main(argv=None) -> int:
ap.add_argument("--force-iterative", action="store_true",
help="use the iterative solver (AMG-CG, or Jacobi-CG "
"without pyamg) regardless of problem size")
ap.add_argument("--progress", action="store_true",
help="show the busy window during the solve, as the "
"KiCad plugin does (needs a GUI)")
ap.add_argument("--adaptive", action=argparse.BooleanOptionalAction,
default=None,
help="adaptive quadtree grid (coarse plane interiors); "
@@ -86,13 +89,20 @@ def main(argv=None) -> int:
return 1
outdir = args.out if args.out is not None else args.dump.parent
if args.progress:
progress.start()
try:
pipeline.run(problem, outdir, show=not args.no_show,
i_test=args.current, freq_hz=args.freq,
contact_model=args.contact_model)
except progress.Cancelled:
print("cancelled")
return 1
except UserFacingError as e:
print(f"ERROR: {e}", file=sys.stderr)
return 1
finally:
progress.done()
return 0