IncGraphSVG

class cpip.IncGraphSVG.SVGTreeNodeMain(theFig, theLineNum)

This does most of the heavy lifting of plotting the include graph SVG. The challenges are plotting things in the ‘right’ order and with the ‘right’ JavaScript so that the DHTML does not look too hideous.

Basic principle here is that plotInitialise() writes static data. In our case just the pretty histogram pop-up (Ed. is this right???).

Then SVGTreeNodeBase.plotToSVGStream() is called - this is implemented in the base class.

Finally plotFinalise() is called - this overlays the DHTML text. This is a little tricky as our way of DHTML is to switch opacity on underlying objects the switching boundary being the overlying object (e.g. ' ? ').

So all the underlying objects need to be written first so that the overlying objects are always ‘visible’ to trigger onmouseover / onmouseout on the underlying object.

ATTRS_LINE_CONDITIONAL_FROM = {'stroke-width': '0.25', 'stroke-dasharray': '8,2,2,2', 'stroke': 'black'}

Attributes, conditional line from.

ATTRS_LINE_CONDITIONAL_TO = {'stroke-width': '0.5', 'stroke-dasharray': '8,2,2,2', 'stroke': 'black'}

Attributes, conditional line to.

ATTRS_LINE_MT_FROM = {'stroke-width': '0.5', 'stroke-dasharray': '8,8', 'stroke': 'aqua'}

Attributes, empty line from.

ATTRS_LINE_MT_TO = {'stroke-width': '2', 'stroke-dasharray': '8,8', 'stroke': 'aqua'}

Attributes, empty line to.

ATTRS_LINE_NORMAL_FROM = {'stroke-width': '0.5', 'stroke': 'black'}

Attributes, normal line from.

ATTRS_LINE_NORMAL_TO = {'stroke-width': '2', 'stroke': 'black'}

Attributes, normal line to.

ATTRS_LINE_ROOT_CHILDREN_JOIN = {'stroke-width': '8', 'stroke': 'lightgrey'}

Lines joining root level children

ATTRS_NODE_CONDITIONAL = {'stroke-width': '1', 'fill': 'salmon', 'stroke': 'black'}

Conditionally compiled stuff

ATTRS_NODE_MT = {'stroke-width': '1', 'fill': 'aqua', 'stroke': 'black'}

Nodes that are empty

ATTRS_NODE_NORMAL = {'stroke-width': '1', 'fill': 'mistyrose', 'stroke': 'black'}

Node attributes (e.e. for rectangles) Normal nodes

CHEVRON_COLOUR_FILL = 'palegreen'

CSS for chevron attributes

COMMON_UNITS = 'mm'

Common units.

FILE_DEPTH = Dim(value=32.0, units='mm')

File box depth.

FILE_PADDING = Pad(prev=Dim(value=4.0, units='mm'), next=Dim(value=2.0, units='mm'), parent=Dim(value=16.0, units='mm'), child=Dim(value=16.0, units='mm'))

Padding round file box..

HIST_DEPTH = Dim(value=4.0, units='mm')

Histogram depth.

HIST_LEGEND_ID = 'HistogramLegend'

Histogram rectangle ID.

HIST_PP_TOKEN_TYPES_COLOURS = (('header-name', 'orange'), ('identifier', 'blue'), ('string-literal', 'cyan'), ('pp-number', 'green'), ('character-literal', 'magenta'), ('preprocessing-op-or-punc', 'red'), ('non-whitespace', 'black'), ('concat', 'yellow'), ('whitespace', 'white'))

This controls plot order as well as colour Note: Unusually they are in sweep=’-‘ i.e logical left-to-right order

HIST_RECT_COLOUR_STROKE = 'black'

Histogram rectangle colour.

HIST_RECT_STROKE_WIDTH = '.5'

Histogram rectangle width.

POPUP_TEXT = ' ? '

The placeholder text for JavaScript rollover

SPACE_PARENT_CHILD = Dim(value=16.0, units='mm')

Space between parent and child.

STYLE_COURIER_10 = 'text.C10'

CSS for monospaced text font-family="Courier" font-size="10" font-weight="normal"

STYLE_RECT_INVIS = 'rect.invis'

CSS for invisible rectangle

STYLE_TEXT_SCALE = 'text.scale'

CSS used for scale

STYLE_VERDANA_12 = 'text.V12'

CSS entries

STYLE_VERDANA_9 = 'text.V9'

CSS used for histogram

WIDTH_MINIMUM = Dim(value=5, units='mm')

Minimum width

WIDTH_PER_TOKEN = Dim(value=0.001, units='mm')

Token width

_SVGTreeNodeMain__mustPlotChildHistogram()
Returns:boolTrue if the child histogram should be plotted.
_SVGTreeNodeMain__mustPlotSelfHistogram()
Returns:boolTrue if my histogram should be plotted.
__init__(theFig, theLineNum)

Constructor.

Parameters:
  • theFig (NoneType, cpip.core.FileIncludeGraph.FileIncludeGraph) – File include graph.
  • theLineNum (int) – Line number.
Returns:

NoneType

_altTextsForTokenCount()

Returns a list of strings that are the alternate text for token counts.

Returns:list([str]) – Alternate text.
_fileIdStackToListOfStr(theIdStack)

Given a list of alternating file names and line numbers such as: ['root', 3, foo.h, 7, bar.h] this returns a list of strings thus: ['root#3, 'foo.h#7, 'bar.h']

Parameters:theIdStack (list([int, str]), list([str])) – File ID stack.
Returns:list([str]) – Merged file stack.
_fileNamePoint(theDatumL, theTpt)

Returns the point to plot the file name or None.

Parameters:
  • theDatumL (cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])) – Logical position.
  • theTpt (cpip.plot.TreePlotTransform.TreePlotTransform) – Transformer of logical to physical points.
Returns:

cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])]) – Physical position.

_plotChevron(theSvg, theDl, theTpt)

Plots a wedge to represent the relative number of tokens in me and my children.

D------------------.------------------|
|                                     |
|------------------.------------------|
|                                     |
A-----------B------.------D-----------|
|            \     .     /            |
|             \    .    /             |
|              \   .   /              |
|               \  .  /               |
|                \ . /                |
------------------\C/------------------

We plot in the order: D moveto A moveto B lineto C lineto D lineto B

Parameters:
Returns:

NoneType

_plotFileName(theSvg, theDatumL, theTpt)

Writes out the file name adjacent to the file box as static text.

Parameters:
Returns:

NoneType

_plotFileNameStackPopup(theSvg, theDatumL, theTpt, idStack)

Writes out the file name at the top with a pop-up with the absolute path.

Parameters:
Returns:

NoneType

_plotHistogram(theSvg, theHistDl, theTpt, theTokCounter)

Plots the histogram.

Parameters:
Returns:

NoneType

_plotHistogramLegend(theSvg, theTpt)

Plot a standardised legend. This is plotted as a group within a defs.

Parameters:
Returns:

NoneType

_plotRootChildToChild(theSvg, theDatumL, theTpt)

Join up children of root node with vertical lines.

Parameters:
Returns:

NoneType

_plotSelf(theSvg, theDatumL, theTpt, thePassNum, idStack)

Plot me to a stream at the logical datum point.

Parameters:
  • theSvg (cpip.plot.SVGWriter.SVGWriter) – SVG stream.
  • theDatumL (cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])) – Logical position.
  • theTpt (cpip.plot.TreePlotTransform.TreePlotTransform) – Transformer of logical to physical points.
  • thePassNum (int) – Pass number, if 1 then the histogram legend is written out.
  • idStack (list([int, str]), list([str])) – Stack of file IDs (paths).
Returns:

NoneType

_plotSelfInternals(theSvg, theDl, theTpt)

Plot structures inside the box and the static text that is the file name.

Parameters:
Returns:

NoneType

_plotSelfToChildren(theSvg, theDatumL, theTpt)

Plot links from me to my children to a stream at the (self) logical datum point.

Parameters:
Returns:

NoneType

_plotTextOverlay(theSvg, theDatumL, theTpt, idStack)

Plots all the text associated with the parent and child. We write the hidden objects first then the visible objects. This is because the hidden objects are controlled onmouseover/onmouseout on the visible objects and they have to be later in the SVG file for this to work.

Parameters:
Returns:

NoneType

_plotTextOverlayChildren(theSvg, theDatumL, theTpt)

Plot text associated with my children to a stream at the (self) logical datum point.

Parameters:
Returns:

NoneType

_plotTextOverlayHistogram(theSvg, theHistDl, theTpt)

Plot the text associated with a histogram.

Parameters:
Returns:

NoneType

_plotTextOverlayTokenCountTable(theSvg, theDatumL, theTpt)

Plots the token count table as text+alternate text.

Parameters:
Returns:

NoneType

_plotWhereWhyHow(theSvg, iChild, theDatumL, theTpt)

Plot description of Where/Why/How inclusion of a single child to a stream at the (self) logical datum point.

Parameters:
Returns:

NoneType

_writeScaleControls(theSvg)

Write the text elements that control re-scaling.

Parameters:theSvg (cpip.plot.SVGWriter.SVGWriter) – SVG stream.
Returns:NoneType
_writeTriggers(theSvg)

Write the rectangles that trigger pop-up text last so that they are on top.

Parameters:theSvg (cpip.plot.SVGWriter.SVGWriter) – SVG stream.
Returns:NoneType
condComp

A string of conditional tests.

Returns:str – Conditional compilation string.
finalise()

Finalisation this sets up all the bounding boxes of me and my children.

Returns:NoneType
findLogic

The find logic as a string.

Returns:list([str]) – The find logic.
plotFinalise(theSvg, theDatumL, theTpt)

Finish the plot. In this case we write the text overlays.

Parameters:
Returns:

NoneType

plotInitialise(theSvg, theDatumL, theTpt)

Plot the histogram legend once only.

Parameters:
Returns:

NoneType

plotRoot(theSvg, theDatumL, theTpt, passNum)

Plot the root.

Parameters:
  • theSvg (cpip.plot.SVGWriter.SVGWriter) – SVG stream.
  • theDatumL (cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])) – Logical position.
  • theTpt (cpip.plot.TreePlotTransform.TreePlotTransform) – Transformer of logical to physical points.
  • passNum (int) – Pass number, if 1 then the histogram legend is written out.
Returns:

NoneType

tokenCounter

This is the PpTokenCount.PpTokenCount() for me only.

Returns:cpip.core.PpTokenCount.PpTokenCount – Token count.
tokenCounterChildren

This is the computed PpTokenCount.PpTokenCount() for all my descendents.

Returns:cpip.core.PpTokenCount.PpTokenCount – Token count.
tokenCounterTotal

This is the computed PpTokenCount.PpTokenCount() me plus my descendents.

Returns:cpip.core.PpTokenCount.PpTokenCount – Token count.
writeAltTextAndMouseOverRect(theSvg, theId, theAltPt, theAltS, theTrigPt, theTrigRect)

Composes and writes the (pop-up) alternate text. Also writes a trigger rectangle.

Parameters:
  • theSvg (cpip.plot.SVGWriter.SVGWriter) – SVG stream.
  • theId (str) – The ID.
  • theAltPt (cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])) – Position of alternate text.
  • theAltS (list([str])) – Alternate text lines.
  • theTrigPt (cpip.plot.Coord.Pt([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])])) – Trigger position.
  • theTrigRect (cpip.plot.Coord.Box([cpip.plot.Coord.Dim([float, str]), cpip.plot.Coord.Dim([float, <class 'str'>])]), cpip.plot.Coord.Box([cpip.plot.Coord.Dim([int, str]), cpip.plot.Coord.Dim([int, <class 'str'>])])) – Trigger area.
Returns:

NoneType

writePreamble(theS)

Write any preamble such as CSS or JavaScript. To be implemented by child classes.

Parameters:theSvg (cpip.plot.SVGWriter.SVGWriter) – SVG stream.
Returns:NoneType