Layout
pd2af.building.layout
Layout helpers shared by both language builders: styling, arcs and dot.
Functions:
| Name | Description |
|---|---|
harmonize_root_layout |
Set the root layout's fill to white and fit it around its children. |
highlight_layout_elements |
Dim everything in |
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. |
harmonize_root_layout
Set the root layout's fill to white and fit it 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
highlight_layout_elements
Dim everything in layout that is not part of layout_elements.
The overlay mode's greying pass: a style sheet selects every element whose id is outside the kept set and washes it out, leaving the foreground drawn at full strength.
Source code in src/pd2af/building/layout.py
162 163 164 165 166 167 168 169 170 171 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 256 257 258 259 260 261 262 263 264 265 266 | |
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.
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.