Layout
pd2af.building.layout
Layout helpers shared by both language builders: styling, arcs and dot.
Functions:
| Name | Description |
|---|---|
dim_layout_elements |
Wash out |
get_layout_elements_sorted_by_id |
Return the glyphs that draw |
get_nearest_layout_element |
Return the layout element whose position is nearest |
harmonize_root_layout |
Return |
influence_layout_pairs |
Return the (source_layout, target_layout) pairs an arc is drawn between. |
make_arc_segments_from_source_and_target |
Segments for a modulation / influence arc connecting two node layouts. |
make_auto_layout |
Reposition an already-built layout with graphviz (dot). |
nearest_layout_pair |
Return the (source_layout, target_layout) pair closest in Euclidean distance. |
dim_layout_elements
Wash out layout_element_builders in place: the overlay background.
Source code in src/pd2af/building/layout.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
get_layout_elements_sorted_by_id
Return the glyphs that draw model_element, sorted by id_.
Source code in src/pd2af/building/layout.py
get_nearest_layout_element
Return the layout element whose position is nearest position.
Source code in src/pd2af/building/layout.py
harmonize_root_layout
Return layout with a white fill, fitted around its children.
Applied uniformly across all layout modes so the rendered canvas has consistent background and padding.
Source code in src/pd2af/building/layout.py
influence_layout_pairs
influence_layout_pairs(source_layouts: Any, target_layouts: Any, prefer_nearest: bool) -> list[tuple]
Return the (source_layout, target_layout) pairs an arc is drawn between.
By default the full source x target cross product. prefer_nearest
(-p nearest) collapses the fan-out to the single closest pair, but only
where there is fan-out (more than one layout on a side) and every layout
has a real position -- in dot mode positions are throwaway
placeholders that graphviz overwrites, so the cross product is kept.
Source code in src/pd2af/building/layout.py
make_arc_segments_from_source_and_target
Segments for a modulation / influence arc connecting two node layouts.
A self-loop (source is target) bows out into a visible loop via
:func:_make_self_loop_segments; otherwise it is drawn straight by
:func:_make_straight_segments. Returns a list of segments.
Source code in src/pd2af/building/layout.py
make_auto_layout
make_auto_layout(cd_map: Any, compartment_layout_classes: Any = (RectangleCompartmentLayout, OvalCompartmentLayout), reversed_arc_classes: Any = (), operator_arc_resolver: Any = None) -> Any
Reposition an already-built layout with graphviz (dot).
Generic over the map language except for the compartment-layout classes,
which differ per language: pass compartment_layout_classes to identify
the compartment containers (so they become dot clusters rather than nodes).
Defaults to the CellDesigner compartment-layout classes.
reversed_arc_classes flips the dot-edge direction of the given arc
classes for ranking only (see :func:_build_dot_graph);
operator_arc_resolver overrides the rebuilt segments of selected arcs
(see :func:_rebuild_arc_geometry). Both default to inert, so callers
that pass neither (e.g. CellDesigner) are unaffected.
The root layout of the returned map is fitted around the repositioned
elements (see :func:harmonize_root_layout).
Source code in src/pd2af/building/layout.py
nearest_layout_pair
Return the (source_layout, target_layout) pair closest in Euclidean distance.
min over itertools.product is deterministic: on a distance tie it
keeps the first pair in product order (source-major), so the choice mirrors
the order the cross product would have emitted.