TreePlotTransform

Provides a means of re-interpreting the coordinate system when plotting trees so that the the tree root can be top/left/bottom/right and the child order plotted anti-clockwise or clockwise.

This can convert ‘logical’ positions into ‘physical’ positions. Where a ‘logical’ position is one with the root of the tree at the top and the child nodes below in left-to-right (i.e. anti-clockwise) order. A ‘physical’ position is a plot-able position where the root of the tree is top/left/bottom or right and the child nodes are in anti-clockwise or clockwise order.

Transfoming sizes and positions

If the first suffix is ‘l’ this is the “logical” coordinate system. If the first suffix is ‘p’ this is the “physical” coordinate system.

Then:

C    The canvas dimension, Cpw is "Canvas physical width"                            
W    Width dimension, physical and logical.                            
D    Depth dimension, physical and logical.                            
B    Box datum position ("top-left"), physical and logical, x and y.                            
P    Arbitrary point, physical and logical, x and y.                            

So this “logical view” of the tree graph (‘top’ and ‘-‘): i.e. Root(s) is a top and children are written in an anti-clockwise.

 ---> x
 |
 \/
 y

<------------------------ Clw ------------------------>
|                                  To Parent
|                                     |
|             Blx, Bly -->*************************
|                         *                  |    *
Cld                       *                 Dl    *
|                         *<-------- Wl -----|--->*
|                         *                  |    *
|       Plx, Ply ->.      *                  |    *
|                         *************************
|                             |        |       |
|                        To C[0]  To C[c]   To C[C-1]

Or:

Origin Cpw Cpd Wp Dp Bpx Bpy Ppx Ppy
top Clw Cld Wl Dl Blx Bly Plx Ply
left Cld Clw Dl Wl Bly (Clw-Plx-Wl) Ply Clw-Plx
bottom Clw Cld Wl Dl (Clw-Plx-Wl) (Cld-Ply-Dl) Clw-Plx Cld-Ply
right Cld Clw Dl Wl (Cld-Ply-Dl) Blx Cld-Ply Plx

Note the diagonal top-right to bottom-left transference between each pair of columns. That is because with each successive line we are doing a 90 degree rotation (anti-clockwise) plus a +ve y translation by Clw (top->left or bottom->right) or Cld (left->bottom or right->top).

Incrementing child positions

Moving from one child to another is done in the following combinations:

Origin ‘-‘ ‘+’
top right left
left up down
bottom left right
right down up
exception cpip.plot.TreePlotTransform.ExceptionTreePlotTransform

Exception class for TreePlotTransform.

exception cpip.plot.TreePlotTransform.ExceptionTreePlotTransformRangeCtor

Exception class for out of range input on construction.

class cpip.plot.TreePlotTransform.TreePlotTransform(theLogicalCanvas, rootPos='top', sweepDir='-')

Provides a means of re-interpreting the coordinate system when plotting trees.

rootPosition = frozenset([‘top’, ‘bottom’, ‘left’, ‘right’]) default: ‘top’

sweepDirection = frozenset([‘+’, ‘-‘]) default: ‘-‘

Has functionality for interpreting width/depth to actual postions given rootPostion.

bdcL(theBlxy, theBl)

Given a logical datum (logical top left) and a logical box this returns logical bottom dead centre of a box.

bdcP(theBlxy, theBl)

Given a logical datum (logical top left) and a logical box this returns physical bottom dead centre of a box.

boxDatumP(theBlxy, theBl)

Given a logical point and logical box this returns a physical point that is the box datum (“upper left”).

boxP(theBl)

Given a logical box this returns a Coord.Box that describes the physical box.

canvasP()

Returns a Coord.Box that describes the physical canvass.

genRootPos()

Yield all possible root positions.

genSweepDir()

Yield all possible root positions.

incPhysicalChildPos(thePt, theDim)

Given a child physical datum point and a distance to next child this returns the next childs physical datum point. TODO: Remove this as redundant?

nextdcL(theBlxy, theBl)

Given a logical datum (logical top left) and a logical box this returns logical ‘next’ dead centre of a box.

positiveSweepDir

True if positive sweep, false otherwise.

postIncChildLogicalPos(thePt, theBox)

Post-incrempents the child logical datum point (‘top-left’) given the child logical datum point and the child.bbSigma. Returns a Coord.Pt(). This takes into account the sweep direction.

preIncChildLogicalPos(thePt, theBox)

Pre-incrempents the child logical datum point (‘top-left’) given the child logical datum point and the child.bbSigma. Returns a Coord.Pt(). This takes into account the sweep direction.

prevdcL(theBlxy, theBl)

Given a logical datum (logical top left) and a logical box this returns logical ‘previous’ dead centre of a box.

pt(thePt, units=None)

Given an arbitrary logical point as a Coord.Pt(), this returns the physical point as a Coord.Pt(). If units is supplied then the return value will be in those units.

startChildrenLogicalPos(thePt, theBox)

Returns the starting child logical datum point (‘top-left’) given the children logical datum point and the children.bbSigma. Returns a Coord.Pt(). This takes into account the sweep direction.

tdcL(theBlxy, theBl)

Given a logical datum (logical top left) and a logical box this returns logical top dead centre of a box.

tdcP(theBlxy, theBl)

Given a logical datum (logical top left) and a logical box this returns physical top dead centre of a box.

Table Of Contents

Previous topic

SVGWriter

This Page