Implementation overview

The installed C interface is primarily the vector API in rbc.h and rbcVector.h, with generated declarations and stubs. Renderer interfaces are private; adding a renderer declaration does not add a public stub entry.

Layer

Responsibility

Commands and configuration

Parse Tcl requests, own option transactions and component resources, schedule mapping and redraw.

Mapping

Convert data through axes and track viewports into display geometry; retain source indices needed for picking.

Components

Choose painter order, batches and fallback paths; supply mapped geometry and borrowed resources.

Renderer interface

Dispatch supported operations, manage context lifetime and clip nesting.

Backends

Convert geometry to native requests or document primitives, preserving backend rounding, batching and resource rules.

Export orchestration

Set up documents, remap for requested size, restore screen geometry, finalize and deliver output.

rbcGraph.c manages the common widget. Track services live in rbcGrTrack.c; polar work lives in rbcGrPolar.c. Components such as rbcGrAxis.c, rbcGrLine.c and rbcGrMarker.c use this infrastructure.

See Image storage and tile clients for pixel copies, tile clients and idle notifications. See Text layout and document fonts for borrowed text layouts and document-local font caches. See Export orchestration and document ownership for document lifecycle, geometry restoration and delivery. See Marker lifecycle and drawing for marker layers, window ownership and XOR handling. See Crosshair state and presentation for XOR state and final-frame presentation. See Legend ownership and layout for global, external and track-local legend services. See Grid mapping and inheritance for tick-derived segments and local-grid inheritance. See Pens and style palettes for shared pen references and palette selection. See Element data and dispatch for data-slot ownership, staged updates and type dispatch. See Axes, mapping and track viewports for axis normalization, inverted coordinates, track viewports and the distinction between mapping and clipping.

See Package loading and stubs for package loading, command registration and client stubs.

See Spline interpolation and graph smoothing for interpolation kernels, vector outputs and trace smoothing.

Supporting modules

See Allocation, strings and interned names for allocation, UID references and scratch strings; Typed command dispatch for typed operation tables; and Shared value conversion and numeric policy for parser commit rules, expression callbacks and numeric compatibility limits.

See Chains and keyed lists for chain/list payload ownership and mutation rules.

rbcGeometry.c contains geometry algorithms without graph state or drawing. See Geometry, clipping and simplification for clipping boundaries, hit testing and simplification. rbcScroll.c parses scroll requests and computes viewports; callers retain widget mutation and redraw responsibilities. See Scrolling and viewport policy for request parsing, axis/track viewport policy and scrollbar notification. rbcConfig.c owns common option conversion and rollback helpers. See Component configuration and resources for resource lookup, transaction boundaries and the distinction between option and derived resources. rbcDraw.c contains shared Tk/Xlib services used outside graph rendering too, rather than a universal renderer backend.

rbcWinDraw.c is Windows/Tk compatibility infrastructure used by renderers, image and tile code. It owns private Tk drawable/DC integration and Xlib emulation. See Rendering architecture and contracts for backend boundaries.

See Shared drawing and window services for private GC ownership, native identifiers and window instance associations. See Window and photo command implementation for standalone window and photo commands, and EPS canvas item implementation for the legacy canvas item. These services are outside the graph renderer lifecycle even when they reuse shared pixel or PostScript helpers.

Lifetime and callbacks

A borrowed pointer does not keep a graph, component, Tcl object or Tk resource alive. Callers retain that responsibility. Tcl callbacks can reconfigure or delete the owning widget; call sites invoking user code must preserve the appropriate state and revalidate it before continuing.

Rendering is synchronous and used on the owning Tk thread. The interface does not provide worker-thread drawing or context synchronization. An internal renderer run callback does not authorize arbitrary Tcl reentry.

See Graph lifecycle and redisplay for widget scheduling, callback cancellation and the two phases of destruction. See Vector ownership and notifications for borrowed numeric storage and observer lifetime. Detailed component destruction contracts remain with their owning modules.

Object interaction

See Binding dispatch and picking for component hit priority, per-family tag identities, legend entry contexts and callback lifetime. Generic event dispatch does not interpret component layouts; graph and legend pickers supply those decisions.

Core record index

The shared headers define ownership and storage contracts, not just function signatures. These records are private C interfaces; their layouts are not a public extension ABI. A pointer member does not automatically retain its target.

Record

Responsibility and reference

Graph / GraphStruct

Widget owner, component registries, export options and layout caches; Graph lifecycle C reference.

Component and Margin

Registry/display order and axis-margin layout; Graph lifecycle C reference.

Grid and GridSegments

Graph/track grid options and owned mapped segment arrays; Grid C reference.

Pen / PenStruct

Concrete pen prefix and counted named-pen lifetime; Pen and palette C reference.

Element / ElementStruct

Element prefix, data slots, mapping and pen references; Element data C reference.

ElementProcs

Concrete element dispatch contracts; Element data C reference.

Rbc_BindTableStruct

Owned Tk bindings and borrowed picked/focus objects; Binding and picking C reference.

PostScript

Persistent output options and computed page placement; PostScript token C reference.

FreqKey and FreqInfo

Coincident-bar grouping and per-pass accumulation; Bar element C reference.