Graphical interface¶
The reasitic.gui package re-exports a few names at the
top level (run, Viewport, the colour helpers); see the
submodule pages below for the full surface.
Pan / zoom viewport math for the layout view.
Mirrors the world↔screen transformation used by the original ASITIC X11
front-end (see decomp/output/asitic_repl.c lines ~6920 / 21800):
/* world coords (μm) → screen coords (px) */
sx = (wx + g_pan_x) * g_zoom_scale + g_x11_canvas_width / 2
sy = -(wy + g_pan_y) * g_zoom_scale + g_x11_canvas_height / 2
The screen Y axis points down, the world Y axis points up, hence the sign flip on the Y term. The transformation is implemented here with no Tkinter dependency so that it can be unit-tested headlessly.
- class reasitic.gui.viewport.Viewport[source]¶
Bases:
objectA 2-D pan/zoom transform from layout (μm) to canvas (px) coordinates.
Mirrors the binary’s view-state globals:
zoomisg_zoom_scaleandpan_x/pan_yareg_pan_x/g_pan_y.canvas_width/canvas_heighttrack the live canvas widget size in pixels (the binary usesg_x11_canvas_width/g_x11_canvas_height).- screen_to_world(sx, sy)[source]¶
Inverse of
world_to_screen().
- zoom_at_screen(sx, sy, factor)[source]¶
Multiply
zoombyfactor, keeping the world point under(sx, sy)fixed on the canvas (matches the binary’scmd_scale_clamp_viewzoom behaviour).
- fit_bbox(x_min, y_min, x_max, y_max, *, margin=0.05)[source]¶
Set
zoomandpanso the bbox fits the canvas with margin.
Per-metal-layer color palette for the layout view.
The original ASITIC binary indexes metals by g_metal_layer_color_index
(see decomp/output/asitic_repl.c line ~3427) and resolves each entry
through XParseColor against the X11 rgb.txt color database. Tech
files name each colour with an X11 colour string (red, blue,
greenish, …); we re-use that mapping but normalise unusual names
(greenish, yellowish…) to standard CSS hex codes that Tk
understands.
- reasitic.gui.colors.normalize(name)[source]¶
Return a Tk-acceptable colour string for an X11 colour name.
- reasitic.gui.colors.metal_color(tech, metal_name)[source]¶
Return the canvas colour for
metal_nameintech.Falls back to a deterministic palette entry keyed by index if the metal has no colour assigned.
- reasitic.gui.colors.via_color(tech, via_name)[source]¶
Return the canvas colour for
via_nameintech.
Tk Canvas renderer for layout shapes.
Mirrors the pipeline in xui_render_layout_view /
xui_redraw_substrate_polygons (see decomp/output/asitic_repl.c
~22217 / 22825):
Clear the canvas (X11
XClearWindow).Draw the chip outline (
xui_draw_chip_outline).Draw the snap/view grid (
xui_draw_grid_or_ruler).For every shape, fill each polygon stroke with the metal colour and stamp the shape name at its centroid (
xui_draw_string_at_world).Highlight the currently-selected shape with a thick border (
xui_draw_zoom_box_around_current_shape).
Tkinter takes the role of the X11 GC + pixmap pair; the
Viewport handles world↔screen.
- reasitic.gui.renderer.draw_chip_outline(canvas, tech, vp)[source]¶
Draw the rectangular chip boundary on the canvas.
- reasitic.gui.renderer.draw_grid(canvas, vp, *, step_um, color='#2c2c2c')[source]¶
Stamp a regular grid of points over the visible world bbox.
Mirrors
xui_draw_grid_or_rulerminus the ruler labels (those show up in the dedicated dimension-overlay path on selection).
- reasitic.gui.renderer.draw_polygon(canvas, poly, vp, color, *, tags=())[source]¶
Render a single polygon onto the canvas as a filled stroke band.
- reasitic.gui.renderer.draw_shape(canvas, shape, tech, vp, *, label=True, extra_tags=())[source]¶
Render every polygon of
shapeplus a name label.
- reasitic.gui.renderer.draw_selection(canvas, shape, vp)[source]¶
Highlight
shapewith a thick yellow bbox.
- reasitic.gui.renderer.render_all(canvas, tech, shapes, vp, *, grid_step_um=0.0, selected=None)[source]¶
Top-level redraw — wipe existing layout, draw chip + grid + shapes.
reASITIC interactive GUI — a single-window layout viewer + console.
Mirrors the original ASITIC X11 front-end (decomp/output/asitic_repl.c):
A 2-D top-down layout view (
xui_render_layout_view) with pan/zoom, chip outline (xui_draw_chip_outline) and a substrate grid (xui_draw_grid_or_ruler).A status bar showing current zoom and world cursor coordinates.
An embedded REPL pane that drives
reasitic.cli.Replexactly the way the original binary’s terminal-side readline did, so every one of the 117 binary commands works in the GUI.Mouse interactions: drag to pan, scroll wheel to zoom around the cursor, click on a shape to select it (highlights its bounding box, matching
xui_draw_zoom_box_around_current_shape).
- class reasitic.gui.app.GuiApp[source]¶
Bases:
objectThe reASITIC graphical workspace.
The GUI is a thin presentation layer over an embedded
Repl. Each command typed into the console pane is forwarded verbatim torepl.execute(with stdout / stderr captured into the console widget) and then the layout view is redrawn fromrepl.shapes. This means every command that works in the headless CLI also works in the GUI, with identical output.- __init__(*, repl=None, width=1100, height=720, title='reASITIC')[source]¶
Build the Tk window. Tk imports are deferred so the rest of
reasitic.guistays importable on headless boxes.